14 #include "sw/device/lib/testing/aon_timer_testutils.h"
15 #include "sw/device/lib/testing/flash_ctrl_testutils.h"
16 #include "sw/device/lib/testing/nv_counter_testutils.h"
17 #include "sw/device/lib/testing/pwrmgr_testutils.h"
18 #include "sw/device/lib/testing/rstmgr_testutils.h"
19 #include "sw/device/lib/testing/test_framework/check.h"
22 #include "aon_timer_regs.h"
36 OTTF_DEFINE_TEST_CONFIG();
38 static const dt_rstmgr_t kRstmgrDt = 0;
39 static_assert(kDtRstmgrCount == 1,
"this test expects a rstmgr");
40 static const dt_pwrmgr_t kPwrmgrDt = 0;
41 static_assert(kDtPwrmgrCount == 1,
"this test expects a pwrmgr");
42 static const dt_pinmux_t kPinmuxDt = 0;
43 static_assert(kDtPinmuxCount == 1,
"this test expects exactly one pinmux");
44 static const dt_flash_ctrl_t kFlashCtrlDt = 0;
45 static_assert(kDtFlashCtrlCount >= 1,
46 "this library expects at least one flash_ctrl");
47 static_assert(kDtSysrstCtrlCount >= 1,
48 "this test expects at least one sysrst_ctrl");
49 static const dt_sysrst_ctrl_t kSysrstCtrlDt = 0;
50 static_assert(kDtAonTimerCount == 1,
"this test expects an aon_timer");
51 static const dt_aon_timer_t kAonTimerDt = 0;
53 static volatile const uint8_t kNumRound;
56 static dif_sysrst_ctrl_t sysrst_ctrl;
57 static dif_pinmux_t pinmux;
64 static void prgm_push_button_wakeup(
void) {
67 .debounce_time_threshold = 1,
73 dt_sysrst_ctrl_periph_io(kSysrstCtrlDt, kDtSysrstCtrlPeriphIoPwrbIn),
87 CHECK_DIF_OK(dif_pwrmgr_init_from_dt(kPwrmgrDt, &pwrmgr));
91 CHECK_DIF_OK(dif_rstmgr_init_from_dt(kRstmgrDt, &rstmgr));
97 CHECK_DIF_OK(dif_sysrst_ctrl_init_from_dt(kSysrstCtrlDt, &sysrst_ctrl));
100 CHECK_DIF_OK(dif_pinmux_init_from_dt(kPinmuxDt, &pinmux));
103 uint32_t event_idx = 0;
104 CHECK_STATUS_OK(flash_ctrl_testutils_counter_get(0, &event_idx));
107 flash_ctrl_testutils_default_region_access(&flash_ctrl,
116 CHECK_STATUS_OK(flash_ctrl_testutils_counter_increment(&flash_ctrl, 0));
121 LOG_INFO(
"wakeup type:%d wakeup reason: 0x%02X", wakeup_reason.
types,
127 kDtAonTimerWakeupWkupReq, &pwrmgr_aon_timer_wakeups));
131 dt_sysrst_ctrl_instance_id(kSysrstCtrlDt), kDtSysrstCtrlWakeupWkupReq,
132 &pwrmgr_sysrst_ctrl_wakeups));
137 if (wakeup_reason.
types == 0) {
143 (pwrmgr_sysrst_ctrl_wakeups | pwrmgr_aon_timer_wakeups));
150 rst_info = rstmgr_testutils_reason_get();
151 rstmgr_testutils_reason_clear();
152 LOG_INFO(
"reset info = 0x%02X", rst_info);
156 LOG_ERROR(
"unexpected reset info: 0x%x", rst_info);
159 dif_aon_timer_t aon_timer;
160 CHECK_DIF_OK(dif_aon_timer_init_from_dt(kAonTimerDt, &aon_timer));
174 if (event_idx < kNumRound) {
175 LOG_INFO(
"Test round %d", event_idx);
182 prgm_push_button_wakeup();
185 CHECK_STATUS_OK(rstmgr_testutils_pre_reset(&rstmgr));
192 aon_timer_testutils_wakeup_config(&aon_timer, wakeup_threshold));
196 pwrmgr_testutils_enable_low_power(&pwrmgr, pwrmgr_all_wakeups, 0));