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)
pull/11367/head
Kyle Kearney 2019-08-20 14:12:26 -07:00
parent ad6e833450
commit 236bf2c0c3
1 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "cybsp_core.h"
#include "mbed_power_mgmt.h"
#include "rtos_idle.h"
#include "us_ticker_api.h"
#if defined(COMPONENT_SPM_MAILBOX)
void mailbox_init(void);
@ -80,6 +81,11 @@ void mbed_sdk_init(void)
#if !defined(TARGET_PSA)
/* Set up the device based on configurator selections */
cybsp_init();
/*
* Init the us Ticker here to avoid imposing on the limited stack space of the idle thread.
* This also allows the first call to sleep to occur faster.
*/
us_ticker_init();
#endif
/* Enable global interrupts (disabled in CM4 startup assembly) */