14 #include "sw/device/lib/testing/aon_timer_testutils.h"
15 #include "sw/device/lib/testing/pwrmgr_testutils.h"
16 #include "sw/device/lib/testing/rstmgr_testutils.h"
17 #include "sw/device/lib/testing/test_framework/check.h"
20 static const dt_pwrmgr_t kPwrmgrDt = 0;
21 static_assert(kDtPwrmgrCount == 1,
"this library expects exactly one pwrmgr");
22 static const dt_rstmgr_t kRstmgrDt = 0;
23 static_assert(kDtRstmgrCount == 1,
"this library expects exactly one rstmgr");
24 static const dt_aon_timer_t kAonTimerDt = 0;
25 static_assert(kDtAonTimerCount == 1,
26 "this library expects exactly one aon_timer");
28 #define IDLE_TIME_US 10
29 #define WKUP_TIME_US 2000
30 OTTF_DEFINE_TEST_CONFIG();
35 CHECK_DIF_OK(dif_pwrmgr_init_from_dt(kPwrmgrDt, &pwrmgr));
39 CHECK_DIF_OK(dif_rstmgr_init_from_dt(kRstmgrDt, &rstmgr));
42 dif_aon_timer_t aon_timer;
43 CHECK_DIF_OK(dif_aon_timer_init_from_dt(kAonTimerDt, &aon_timer));
49 kDtAonTimerWakeupWkupReq, &wakeup_sources));
53 kDtAonTimerResetReqAonTimer, &reset_sources));
62 rstmgr_testutils_reason_clear();
67 LOG_INFO(
"Booting for the first time, setting wdog");
70 uint64_t wkup_cycles = 0;
71 CHECK_STATUS_OK(aon_timer_testutils_get_aon_cycles_64_from_us(
72 WKUP_TIME_US, &wkup_cycles));
76 CHECK_STATUS_OK(aon_timer_testutils_watchdog_config(&aon_timer, UINT32_MAX,
78 CHECK_STATUS_OK(aon_timer_testutils_wakeup_config(&aon_timer, wkup_cycles));
85 CHECK(wdog_cnt >= wkup_cnt);
88 CHECK_STATUS_OK(pwrmgr_testutils_enable_low_power(&pwrmgr, wakeup_sources,
92 LOG_INFO(
"Issue WFI to enter sleep");
95 LOG_INFO(
"Booting for the second time due to wakeup");
100 CHECK(wdog_cnt < wkup_cnt);
103 LOG_ERROR(
"Got unexpected reset_info=0x%x", rst_info);