Skip to content

Commit 8205b60

Browse files
authored
Merge pull request #3368 from hathach/disable_isr
bsp: Disable SysTick ISR if FreeRTOS is enabled
2 parents 1281462 + 8221ea2 commit 8205b60

File tree

47 files changed

+117
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+117
-31
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 from running 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ void board_init(void) {
7474
/* vbus ignore */
7575
board_vbus_sense_init();
7676

77-
SysTick_Config(SystemCoreClock / 1000);
7877
#if CFG_TUSB_OS == OPT_OS_FREERTOS
78+
// Explicitly disable systick to prevent its ISR from running before scheduler start
79+
SysTick->CTRL &= ~1U;
7980
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
8081
NVIC_SetPriority(OTGFS1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
8182
NVIC_SetPriority(OTGFS2_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
8283
#else
84+
SysTick_Config(SystemCoreClock / 1000);
8385
NVIC_SetPriority(OTGFS1_IRQn, 0);
8486
NVIC_SetPriority(OTGFS2_IRQn, 0);
8587
#endif

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 from running 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 from running 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 from running 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 from running 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 from running 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 from running 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 from running 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 from running 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)