Skip to content
Snippets Groups Projects
Commit 01fb427e authored by rahix's avatar rahix
Browse files

fix(sleep): Make sleep work again when BLE is disabled

In commit 4944aa48 ("fix(ble): Update to changes from new SDK")
a call to `BbDrvDisable()` was added to `sleep_deepsleep()`.  This
function must, however, only be called when BLE was previously
initialized, otherwise a wakeup from deepsleep will not be possible (if
it ever reaches it?).

Fix this by reworking the BLE enabled check to also be usable here, to
only call `BbDrvDisable()` when BLE is active.

Fixes: 4944aa48 ("fix(ble): Update to changes from new SDK")
Fixes: #231
parent cce77607
No related branches found
No related tags found
1 merge request!466Make sleep work again when BLE is disabled
Pipeline #5187 passed
...@@ -269,17 +269,26 @@ void RSV11_IRQHandler(void) ...@@ -269,17 +269,26 @@ void RSV11_IRQHandler(void)
notify(); notify();
} }
/*************************************************************************************************/ /*************************************************************************************************/
bool ble_shall_start(void) bool ble_is_enabled(void)
{ {
bool ble_enabled = config_get_boolean_with_default("ble_enable", false); /*
* 0 = unknown, check config
* 1 = disabled
* 2 = enabled
*/
static int ble_state = 0;
if (ble_enabled) { if (ble_state == 0) {
if (config_get_boolean_with_default("ble_enable", false)) {
ble_state = 2;
LOG_INFO("ble", "BLE is enabled."); LOG_INFO("ble", "BLE is enabled.");
} else { } else {
ble_state = 1;
LOG_INFO("ble", "BLE is disabled."); LOG_INFO("ble", "BLE is disabled.");
} }
}
return ble_enabled; return ble_state == 2;
} }
/*************************************************************************************************/ /*************************************************************************************************/
static void scheduleTimer(void) static void scheduleTimer(void)
......
...@@ -156,7 +156,7 @@ int main(void) ...@@ -156,7 +156,7 @@ int main(void)
} }
/* BLE */ /* BLE */
if (ble_shall_start()) { if (ble_is_enabled()) {
if (xTaskCreate( if (xTaskCreate(
vBleTask, vBleTask,
(const char *)"BLE", (const char *)"BLE",
......
...@@ -93,7 +93,7 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result); ...@@ -93,7 +93,7 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result);
/* ---------- BLE ---------------------------------------------------------- */ /* ---------- BLE ---------------------------------------------------------- */
void vBleTask(void *pvParameters); void vBleTask(void *pvParameters);
bool ble_shall_start(void); bool ble_is_enabled(void);
void ble_uart_write(uint8_t *pValue, uint8_t len); void ble_uart_write(uint8_t *pValue, uint8_t len);
/* ---------- Hardware (Peripheral) Locks ---------------------------------- */ /* ---------- Hardware (Peripheral) Locks ---------------------------------- */
......
...@@ -190,7 +190,9 @@ void sleep_deepsleep(void) ...@@ -190,7 +190,9 @@ void sleep_deepsleep(void)
core1_stop(); core1_stop();
MAX77650_getINT_GLBL(); MAX77650_getINT_GLBL();
gpio_low_power(); gpio_low_power();
if (ble_is_enabled()) {
BbDrvDisable(); BbDrvDisable();
}
turnOffClocks(); turnOffClocks();
old_clkcn = MXC_GCR->clkcn; old_clkcn = MXC_GCR->clkcn;
switchToHIRC(); switchToHIRC();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment