hw/mcu/cmac: Perform RF calibration while idle
If we are idle, we can try to perform RF recalibration. If
recalibration was executed, we skip sleep execution in current
iteration and will reevaluate sleep on next entry.
@@ -205,6 +205,8 @@ cmac_sleep_recalculate(void)
}
}
+extern bool ble_rf_try_recalibrate(uint32_t idle_time_us);
+
void
cmac_sleep(void)
{
@@ -236,6 +238,10 @@ cmac_sleep(void)
goto do_sleep;
}
+ if (ble_rf_try_recalibrate(sleep_usecs)) {
+ goto skip_sleep;
+ }
+
sleep_lp_ticks = cmac_timer_usecs_to_lp_ticks(sleep_usecs);
if (sleep_lp_ticks <= 1) {
switch_to_slp = false;
@@ -305,5 +311,6 @@ do_sleep:
g_mcu_wait_for_swd_start = cmac_timer_read_hi();
}
+skip_sleep:
MCU_DIAG_SER('>');
}
