Hi there Devs,
My app is based on ble_app_blinky_c where I added a couple TWI sensors where check periodically every 10s and also scan for peripherals about every 10s
Then I have to wait for certain time between 10-80ms in some cases for when I start a communication with a TWI sensor until it returns some data
there I implement a LowPowerDelay, where every time it is called calls sd_app_evt_wait until the time is elapse and exits from the sleep mode, which is supposed to be in the main context and not blocking others IRQs.
Is it assumption right?? because some times my device freezes and it is still a unknown source for me what is producing this behavior, I believe it could be related to the low power delay and the loop calling sd_app_evt_wait
#include "LowPowerDelay.h" bool LowPowerDelay::delay; LowPowerDelay::LowPowerDelay() { app_timer_create(&LPDelay, APP_TIMER_MODE_SINGLE_SHOT, &LowPowerDelay::DelayCb); } void LowPowerDelay::DelayCb(void *p_context){ LowPowerDelay::delay = true; } void LowPowerDelay::Delay(uint32_t ms) { LowPowerDelay::delay = false; app_timer_start(LPDelay, APP_TIMER_TICKS(ms), NULL); while (!LowPowerDelay::delay){ APP_ERROR_CHECK(sd_app_evt_wait()); } }
#ifndef _LOWPOWERDELAY #define _LOWPOWERDELAY #include "Headers.h" #include "Timer.h" APP_TIMER_DEF(LPDelay); class LowPowerDelay { public: LowPowerDelay(); static LowPowerDelay * Instance() { static LowPowerDelay instance; return &instance; } static void DelayCb(void *p_context); void Delay(uint32_t ms); static bool delay; }; #endif
nRF52832 SDK13