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
Pipeline #5187 passed with stages
in 50 seconds
......@@ -269,17 +269,26 @@ void RSV11_IRQHandler(void)
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) {
LOG_INFO("ble", "BLE is enabled.");
} else {
LOG_INFO("ble", "BLE is disabled.");
if (ble_state == 0) {
if (config_get_boolean_with_default("ble_enable", false)) {
ble_state = 2;
LOG_INFO("ble", "BLE is enabled.");
} else {
ble_state = 1;
LOG_INFO("ble", "BLE is disabled.");
}
}
return ble_enabled;
return ble_state == 2;
}
/*************************************************************************************************/
static void scheduleTimer(void)
......
......@@ -156,7 +156,7 @@ int main(void)
}
/* BLE */
if (ble_shall_start()) {
if (ble_is_enabled()) {
if (xTaskCreate(
vBleTask,
(const char *)"BLE",
......
......@@ -93,7 +93,7 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result);
/* ---------- BLE ---------------------------------------------------------- */
void vBleTask(void *pvParameters);
bool ble_shall_start(void);
bool ble_is_enabled(void);
void ble_uart_write(uint8_t *pValue, uint8_t len);
/* ---------- Hardware (Peripheral) Locks ---------------------------------- */
......
......@@ -190,7 +190,9 @@ void sleep_deepsleep(void)
core1_stop();
MAX77650_getINT_GLBL();
gpio_low_power();
BbDrvDisable();
if (ble_is_enabled()) {
BbDrvDisable();
}
turnOffClocks();
old_clkcn = MXC_GCR->clkcn;
switchToHIRC();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment