8 #include "dt/dt_otp_ctrl.h"
14 #include "sw/device/lib/testing/otp_ctrl_testutils.h"
15 #include "sw/device/lib/testing/test_framework/check.h"
18 static dif_otp_ctrl_t otp;
20 static const char kTestData[] =
"abcdefghijklmno";
21 static_assert(
ARRAYSIZE(kTestData) %
sizeof(uint32_t) == 0,
22 "kTestData must be a word array");
24 static_assert(kDtOtpCtrlCount >= 1,
25 "This test requires at least one OTP Control instance");
27 static dt_otp_ctrl_t kTestOtpCtrl = (dt_otp_ctrl_t)0;
29 OTTF_DEFINE_TEST_CONFIG();
36 CHECK_DIF_OK(dif_otp_ctrl_init_from_dt(kTestOtpCtrl, &otp));
40 .integrity_period_mask = 0x3ffff,
41 .consistency_period_mask = 0x3ffffff,
45 for (uint32_t i = 0; i <
ARRAYSIZE(kTestData); i +=
sizeof(uint32_t)) {
47 memcpy(&word, &kTestData[i],
sizeof(word));
49 CHECK_STATUS_OK(otp_ctrl_testutils_wait_for_dai(&otp));
52 "Failed to program word kTestData[%d] = 0x%08x.", i, word);
54 CHECK_STATUS_OK(otp_ctrl_testutils_wait_for_dai(&otp));
56 uint32_t readout[
ARRAYSIZE(kTestData) /
sizeof(uint32_t)] = {0};
59 "Failed to perform OTP blocking readout.");