mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
Furi_hal_rtc: new function (#3294)
* furi_hal_rtc_timestamp_to_datetime added * hw targets api version sync * hw targets api version sync, bump * FuriHal: update rtc docs * unit tests added Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#include "furi_hal_rtc.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <lp5562_reg.h>
|
||||
#include "../minunit.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#define EEPROM_ADDRESS 0b10101000
|
||||
@@ -211,6 +214,37 @@ MU_TEST(furi_hal_i2c_ext_eeprom) {
|
||||
}
|
||||
}
|
||||
|
||||
MU_TEST(furi_hal_rtc_timestamp2datetime_min) {
|
||||
uint32_t test_value = 0;
|
||||
FuriHalRtcDateTime min_datetime_expected = {0, 0, 0, 1, 1, 1970, 0};
|
||||
|
||||
FuriHalRtcDateTime result = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(test_value, &result);
|
||||
|
||||
mu_assert_mem_eq(&min_datetime_expected, &result, sizeof(result));
|
||||
}
|
||||
|
||||
MU_TEST(furi_hal_rtc_timestamp2datetime_max) {
|
||||
uint32_t test_value = UINT32_MAX;
|
||||
FuriHalRtcDateTime max_datetime_expected = {6, 28, 15, 7, 2, 2106, 0};
|
||||
|
||||
FuriHalRtcDateTime result = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(test_value, &result);
|
||||
|
||||
mu_assert_mem_eq(&max_datetime_expected, &result, sizeof(result));
|
||||
}
|
||||
|
||||
MU_TEST(furi_hal_rtc_timestamp2datetime2timestamp) {
|
||||
uint32_t test_value = random();
|
||||
|
||||
FuriHalRtcDateTime datetime = {0};
|
||||
furi_hal_rtc_timestamp_to_datetime(test_value, &datetime);
|
||||
|
||||
uint32_t result = furi_hal_rtc_datetime_to_timestamp(&datetime);
|
||||
|
||||
mu_assert_int_eq(test_value, result);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(furi_hal_i2c_int_suite) {
|
||||
MU_SUITE_CONFIGURE(&furi_hal_i2c_int_setup, &furi_hal_i2c_int_teardown);
|
||||
MU_RUN_TEST(furi_hal_i2c_int_1b);
|
||||
@@ -224,8 +258,15 @@ MU_TEST_SUITE(furi_hal_i2c_ext_suite) {
|
||||
MU_RUN_TEST(furi_hal_i2c_ext_eeprom);
|
||||
}
|
||||
|
||||
MU_TEST_SUITE(furi_hal_rtc_datetime_suite) {
|
||||
MU_RUN_TEST(furi_hal_rtc_timestamp2datetime_min);
|
||||
MU_RUN_TEST(furi_hal_rtc_timestamp2datetime_max);
|
||||
MU_RUN_TEST(furi_hal_rtc_timestamp2datetime2timestamp);
|
||||
}
|
||||
|
||||
int run_minunit_test_furi_hal() {
|
||||
MU_RUN_SUITE(furi_hal_i2c_int_suite);
|
||||
MU_RUN_SUITE(furi_hal_i2c_ext_suite);
|
||||
MU_RUN_SUITE(furi_hal_rtc_datetime_suite);
|
||||
return MU_EXIT_CODE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user