Skip to content

Commit 65dca4a

Browse files
committed
bsp: Disable SysTick ISR if FreeRTOS is enabled
Signed-off-by: Zixun LI <[email protected]>
1 parent fee2d2a commit 65dca4a

File tree

32 files changed

+101
-15
lines changed

32 files changed

+101
-15
lines changed

hw/bsp/at32f402_405/family.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,17 @@ void board_init(void)
7575
/* vbus ignore */
7676
board_vbus_sense_init();
7777

78-
/* configure systick */
79-
SysTick_Config(system_core_clock / 1000);
80-
81-
#if CFG_TUSB_OS == OPT_OS_FREERTOS
78+
#if CFG_TUSB_OS == OPT_OS_NONE
79+
/* configure systick */
80+
SysTick_Config(system_core_clock / 1000);
81+
NVIC_SetPriority(OTGHS_IRQn, 0);
82+
NVIC_SetPriority(OTGFS1_IRQn, 0);
83+
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
84+
// Explicitly disable systick to prevent its ISR runs before scheduler start
85+
SysTick->CTRL &= ~1U;
8286
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
8387
NVIC_SetPriority(OTGHS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
8488
NVIC_SetPriority(OTGFS1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
85-
#else
86-
NVIC_SetPriority(OTGHS_IRQn, 0);
87-
NVIC_SetPriority(OTGFS1_IRQn, 0);
8889
#endif
8990

9091
/* config led and key */

hw/bsp/at32f435_437/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ void board_init(void) {
7676

7777
SysTick_Config(SystemCoreClock / 1000);
7878
#if CFG_TUSB_OS == OPT_OS_FREERTOS
79+
// Explicitly disable systick to prevent its ISR runs before scheduler start
80+
SysTick->CTRL &= ~1U;
7981
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
8082
NVIC_SetPriority(OTGFS1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
8183
NVIC_SetPriority(OTGFS2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);

hw/bsp/imxrt/family.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ void board_init(void) {
120120
#if CFG_TUSB_OS == OPT_OS_NONE
121121
// 1ms tick timer
122122
SysTick_Config(SystemCoreClock / 1000);
123-
124123
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
124+
// Explicitly disable systick to prevent its ISR runs before scheduler start
125+
SysTick->CTRL &= ~1U;
125126
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
126127
NVIC_SetPriority(USB_OTG1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
127128
#ifdef USBPHY2

hw/bsp/kinetis_k/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ void board_init(void) {
6161
// 1ms tick timer
6262
SysTick_Config(SystemCoreClock / 1000);
6363
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
64+
// Explicitly disable systick to prevent its ISR runs before scheduler start
65+
SysTick->CTRL &= ~1U;
6466
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
6567
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
6668
#endif

hw/bsp/kinetis_kl/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ void board_init(void)
5959
// 1ms tick timer
6060
SysTick_Config(SystemCoreClock / 1000);
6161
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
62+
// Explicitly disable systick to prevent its ISR runs before scheduler start
63+
SysTick->CTRL &= ~1U;
6264
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
6365
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
6466
#endif

hw/bsp/lpc11/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ void board_init(void) {
7474
// 1ms tick timer
7575
SysTick_Config(SystemCoreClock / 1000);
7676
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
77+
// Explicitly disable systick to prevent its ISR runs before scheduler start
78+
SysTick->CTRL &= ~1U;
7779
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
7880
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
7981
#endif

hw/bsp/lpc13/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ void board_init(void) {
5454
// 1ms tick timer
5555
SysTick_Config(SystemCoreClock / 1000);
5656
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
57+
// Explicitly disable systick to prevent its ISR runs before scheduler start
58+
SysTick->CTRL &= ~1U;
5759
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
5860
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
5961
#endif

hw/bsp/lpc15/family.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ void board_init(void)
7777
{
7878
SystemCoreClockUpdate();
7979

80+
#if CFG_TUSB_OS == OPT_OS_NONE
8081
// 1ms tick timer
8182
SysTick_Config(SystemCoreClock / 1000);
82-
83-
#if CFG_TUSB_OS == OPT_OS_FREERTOS
83+
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
84+
// Explicitly disable systick to prevent its ISR runs before scheduler start
85+
SysTick->CTRL &= ~1U;
8486
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
8587
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
8688
#endif

hw/bsp/lpc17/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ void board_init(void) {
5454
// 1ms tick timer
5555
SysTick_Config(SystemCoreClock / 1000);
5656
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
57+
// Explicitly disable systick to prevent its ISR runs before scheduler start
58+
SysTick->CTRL &= ~1U;
5759
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
5860
NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
5961
#endif

hw/bsp/lpc18/family.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ void board_init(void) {
8383
// 1ms tick timer
8484
SysTick_Config(SystemCoreClock / 1000);
8585
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
86+
// Explicitly disable systick to prevent its ISR runs before scheduler start
87+
SysTick->CTRL &= ~1U;
8688
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
8789
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
8890
NVIC_SetPriority(USB1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);

0 commit comments

Comments
 (0)