Skip to content

Commit 567293a

Browse files
author
Kyle Kearney
committed
Initialize timer for us_ticker at startup
This avoids a stack overflow if sleep is called for the first time from the idle thread (which by default has a fairly small stack, and which is already fairly deep by the time it calls into the usticker adapter)
1 parent 1171a6f commit 567293a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "cybsp_api_core.h"
2323
#include "mbed_power_mgmt.h"
2424
#include "rtos_idle.h"
25+
#include "us_ticker_api.h"
2526

2627
#if defined(COMPONENT_SPM_MAILBOX)
2728
void mailbox_init(void);
@@ -83,6 +84,11 @@ void mbed_sdk_init(void)
8384
#if !defined(TARGET_PSA)
8485
/* Set up the device based on configurator selections */
8586
cybsp_init();
87+
/*
88+
* Init the us Ticker here to avoid imposing on the limited stack space of the idle thread.
89+
* This also allows the first call to sleep to occur faster.
90+
*/
91+
us_ticker_init();
8692
#endif
8793

8894
/* Enable global interrupts (disabled in CM4 startup assembly) */

0 commit comments

Comments
 (0)