panic in debug mode if sleep methods are called in an exception handler (unless PICO_ALLOW_SLEEP_IN_EXCEPTION is set)

This commit is contained in:
graham sanderson
2021-02-17 14:54:46 -06:00
parent 6b2c249961
commit aca685ceae
4 changed files with 12 additions and 4 deletions

View File

@ -325,6 +325,11 @@ static int64_t sev_callback(__unused alarm_id_t id, __unused void *user_data) {
#endif
void sleep_until(absolute_time_t t) {
#if PICO_ON_DEVICE && !PICO_ALLOW_SLEEP_IN_EXCEPTION && !defined(NDEBUG)
if (__get_current_exception()) {
panic("Attempted to sleep inside of an exception handler");
}
#endif
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
uint64_t t_us = to_us_since_boot(t);
uint64_t t_before_us = t_us - PICO_TIME_SLEEP_OVERHEAD_ADJUST_US;