From 236bf2c0c3b4fe44662f80616c18493f875c4365 Mon Sep 17 00:00:00 2001 From: Kyle Kearney Date: Tue, 20 Aug 2019 14:12:26 -0700 Subject: [PATCH] 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) --- targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c index fd28bc3e19..9b0cf3ae9f 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/mbed_overrides.c @@ -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) */