Use NMSIS functions for periodic systick handling

This commit is contained in:
Stefan Kerkmann 2021-03-30 18:48:12 +02:00
parent 0fb4a9b7d7
commit 14a840f775
1 changed files with 5 additions and 13 deletions

View File

@ -211,25 +211,17 @@ void st_lld_init(void) {
GD32_ST_TIM->SWEVG = TIM_EGR_UG; GD32_ST_TIM->SWEVG = TIM_EGR_UG;
GD32_ST_TIM->CTL0 = TIM_CR1_CEN; GD32_ST_TIM->CTL0 = TIM_CR1_CEN;
//TODO
#if !defined(GD32_SYSTICK_SUPPRESS_ISR) #if !defined(GD32_SYSTICK_SUPPRESS_ISR)
/* IRQ enabled.*/ /* IRQ enabled.*/
eclicEnableVector(ST_NUMBER, GD32_ST_IRQ_PRIORITY, GD32_ST_IRQ_TRIGGER); eclicEnableVector(ST_NUMBER, GD32_ST_IRQ_PRIORITY, GD32_ST_IRQ_TRIGGER);
#endif #endif
#endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */ #endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */
//TODO
#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
/* Periodic systick mode, the Cortex-Mx internal systick timer is used /* Periodic systick mode, the RISC-V MTIME internal systick timer is used
in this mode.*/ in this mode.*/
RISCV_MTIMECMP = (SYSTICK_CK / OSAL_ST_FREQUENCY) - 1; SysTimer_SetCompareValue((SYSTICK_CK / OSAL_ST_FREQUENCY) - 1);
RISCV_MTIME = 0; SysTimer_SetLoadValue(0);
/*SysTick->LOAD = (SYSTICK_CK / OSAL_ST_FREQUENCY) - 1;
SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_ENABLE_Msk |
SysTick_CTRL_TICKINT_Msk;
*/
/* IRQ enabled.*/ /* IRQ enabled.*/
eclicEnableVector(HANDLER_SYSTICK, GD32_ST_IRQ_PRIORITY, GD32_ST_IRQ_TRIGGER); eclicEnableVector(HANDLER_SYSTICK, GD32_ST_IRQ_PRIORITY, GD32_ST_IRQ_TRIGGER);
#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
@ -241,8 +233,8 @@ void st_lld_init(void) {
void st_lld_serve_interrupt(void) { void st_lld_serve_interrupt(void) {
#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
/* Reload Timer */ /* Reload Timer */
RISCV_MTIMECMP = (SYSTICK_CK / OSAL_ST_FREQUENCY) - 1; SysTimer_SetCompareValue((SYSTICK_CK / OSAL_ST_FREQUENCY) - 1);
RISCV_MTIME = 0; SysTimer_SetLoadValue(0);
#endif #endif
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING #if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
uint32_t sr; uint32_t sr;