summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-08-29 21:34:10 +0700
committerhathach <[email protected]>2021-08-29 21:34:10 +0700
commit61592526928be9626317ef82bbe42d0edaf7fa14 (patch)
tree77a56b76c8b1cb2e39ea9f8941127e38470fad32
parent00e66cf2e0bdb5221586f640dc25d26168ee1daf (diff)
disable systick when running freertos on other stm families
-rw-r--r--hw/bsp/stm32f0/family.c6
-rw-r--r--hw/bsp/stm32f4/family.c3
-rw-r--r--hw/bsp/stm32f7/family.c10
-rw-r--r--hw/bsp/stm32h7/family.c3
4 files changed, 18 insertions, 4 deletions
diff --git a/hw/bsp/stm32f0/family.c b/hw/bsp/stm32f0/family.c
index b2e0453c5..351a7c8c6 100644
--- a/hw/bsp/stm32f0/family.c
+++ b/hw/bsp/stm32f0/family.c
@@ -55,10 +55,14 @@ void board_init(void)
// Enable UART Clock
UART_CLK_EN();
+#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
-#if CFG_TUSB_OS == OPT_OS_FREERTOS
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
diff --git a/hw/bsp/stm32f4/family.c b/hw/bsp/stm32f4/family.c
index 4a0dbcb11..cf0cb2b08 100644
--- a/hw/bsp/stm32f4/family.c
+++ b/hw/bsp/stm32f4/family.c
@@ -50,6 +50,9 @@ void board_init(void)
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c
index c0d324598..2eb737ee3 100644
--- a/hw/bsp/stm32f7/family.c
+++ b/hw/bsp/stm32f7/family.c
@@ -70,9 +70,17 @@ void board_init(void)
UART_CLK_EN();
-#if CFG_TUSB_OS == OPT_OS_NONE
+#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
+
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
+ SysTick->CTRL &= ~1U;
+
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+ NVIC_SetPriority(OTG_HS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
GPIO_InitTypeDef GPIO_InitStruct;
diff --git a/hw/bsp/stm32h7/family.c b/hw/bsp/stm32h7/family.c
index ba3c3e954..a2116d0bd 100644
--- a/hw/bsp/stm32h7/family.c
+++ b/hw/bsp/stm32h7/family.c
@@ -80,13 +80,12 @@ void board_init(void)
SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
- // Explicitly disable systick to prevent it is trigger before scheduler start
+ // Explicitly disable systick to prevent its ISR runs before scheduler start
SysTick->CTRL &= ~1U;
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
NVIC_SetPriority(OTG_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
NVIC_SetPriority(OTG_HS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
-
#endif
GPIO_InitTypeDef GPIO_InitStruct;