diff options
Diffstat (limited to 'firmware/targets')
-rw-r--r-- | firmware/targets/f6/furi-hal/furi-hal-bt.c | 1 | ||||
-rw-r--r-- | firmware/targets/f6/furi-hal/furi-hal-rtc.c | 22 | ||||
-rw-r--r-- | firmware/targets/f7/furi-hal/furi-hal-bt.c | 1 | ||||
-rw-r--r-- | firmware/targets/f7/furi-hal/furi-hal-rtc.c | 22 | ||||
-rw-r--r-- | firmware/targets/furi-hal-include/furi-hal-rtc.h | 2 |
5 files changed, 48 insertions, 0 deletions
diff --git a/firmware/targets/f6/furi-hal/furi-hal-bt.c b/firmware/targets/f6/furi-hal/furi-hal-bt.c index bbd29754..5a457279 100644 --- a/firmware/targets/f6/furi-hal/furi-hal-bt.c +++ b/firmware/targets/f6/furi-hal/furi-hal-bt.c @@ -160,6 +160,7 @@ bool furi_hal_bt_change_app(FuriHalBtProfile profile, BleEventCallback event_cb, gap_thread_stop(); FURI_LOG_I(TAG, "Reset SHCI"); SHCI_C2_Reinit(); + osDelay(100); ble_glue_thread_stop(); FURI_LOG_I(TAG, "Start BT initialization"); furi_hal_bt_init(); diff --git a/firmware/targets/f6/furi-hal/furi-hal-rtc.c b/firmware/targets/f6/furi-hal/furi-hal-rtc.c index 13bb17cb..20e77e13 100644 --- a/firmware/targets/f6/furi-hal/furi-hal-rtc.c +++ b/firmware/targets/f6/furi-hal/furi-hal-rtc.c @@ -120,3 +120,25 @@ void furi_hal_rtc_get_datetime(FuriHalRtcDateTime* datetime) { datetime->day = __LL_RTC_CONVERT_BCD2BIN((date >> 16) & 0xFF); datetime->weekday = __LL_RTC_CONVERT_BCD2BIN((date >> 24) & 0xFF); } + +bool furi_hal_rtc_validate_datetime(FuriHalRtcDateTime* datetime) { + bool invalid = false; + + invalid |= (datetime->second > 59); + invalid |= (datetime->minute > 59); + invalid |= (datetime->hour > 23); + + invalid |= (datetime->year < 2000); + invalid |= (datetime->year > 2099); + + invalid |= (datetime->month == 0); + invalid |= (datetime->month > 12); + + invalid |= (datetime->day == 0); + invalid |= (datetime->day > 31); + + invalid |= (datetime->weekday == 0); + invalid |= (datetime->weekday > 7); + + return !invalid; +} diff --git a/firmware/targets/f7/furi-hal/furi-hal-bt.c b/firmware/targets/f7/furi-hal/furi-hal-bt.c index bbd29754..5a457279 100644 --- a/firmware/targets/f7/furi-hal/furi-hal-bt.c +++ b/firmware/targets/f7/furi-hal/furi-hal-bt.c @@ -160,6 +160,7 @@ bool furi_hal_bt_change_app(FuriHalBtProfile profile, BleEventCallback event_cb, gap_thread_stop(); FURI_LOG_I(TAG, "Reset SHCI"); SHCI_C2_Reinit(); + osDelay(100); ble_glue_thread_stop(); FURI_LOG_I(TAG, "Start BT initialization"); furi_hal_bt_init(); diff --git a/firmware/targets/f7/furi-hal/furi-hal-rtc.c b/firmware/targets/f7/furi-hal/furi-hal-rtc.c index 13bb17cb..20e77e13 100644 --- a/firmware/targets/f7/furi-hal/furi-hal-rtc.c +++ b/firmware/targets/f7/furi-hal/furi-hal-rtc.c @@ -120,3 +120,25 @@ void furi_hal_rtc_get_datetime(FuriHalRtcDateTime* datetime) { datetime->day = __LL_RTC_CONVERT_BCD2BIN((date >> 16) & 0xFF); datetime->weekday = __LL_RTC_CONVERT_BCD2BIN((date >> 24) & 0xFF); } + +bool furi_hal_rtc_validate_datetime(FuriHalRtcDateTime* datetime) { + bool invalid = false; + + invalid |= (datetime->second > 59); + invalid |= (datetime->minute > 59); + invalid |= (datetime->hour > 23); + + invalid |= (datetime->year < 2000); + invalid |= (datetime->year > 2099); + + invalid |= (datetime->month == 0); + invalid |= (datetime->month > 12); + + invalid |= (datetime->day == 0); + invalid |= (datetime->day > 31); + + invalid |= (datetime->weekday == 0); + invalid |= (datetime->weekday > 7); + + return !invalid; +} diff --git a/firmware/targets/furi-hal-include/furi-hal-rtc.h b/firmware/targets/furi-hal-include/furi-hal-rtc.h index 7c36aa09..cc2f56f5 100644 --- a/firmware/targets/furi-hal-include/furi-hal-rtc.h +++ b/firmware/targets/furi-hal-include/furi-hal-rtc.h @@ -47,6 +47,8 @@ void furi_hal_rtc_set_datetime(FuriHalRtcDateTime* datetime); void furi_hal_rtc_get_datetime(FuriHalRtcDateTime* datetime); +bool furi_hal_rtc_validate_datetime(FuriHalRtcDateTime* datetime); + #ifdef __cplusplus } #endif |