7 #include "sw/device/lib/base/status.h"
11 #include "sw/device/lib/testing/json/command.h"
12 #include "sw/device/lib/testing/pinmux_testutils.h"
13 #include "sw/device/lib/testing/test_framework/check.h"
15 #include "sw/device/lib/testing/test_framework/ujson_ottf.h"
16 #include "sw/device/lib/ujson/ujson.h"
20 static dif_gpio_t gpio;
21 static dif_pinmux_t pinmux;
22 OTTF_DEFINE_TEST_CONFIG();
25 const char bits[] = {
's',
'w',
'W',
'S'};
26 char pattern[4] = {0};
27 uint32_t strap = pinmux_testutils_read_straps(&pinmux, &gpio);
28 for (
size_t i = 0; i < 3; ++i) {
29 uint32_t v = (strap >> (2 * i)) & 3;
30 pattern[2 - i] = bits[v];
32 LOG_INFO(
"strap = %02x, pattern = %s", strap, pattern);
33 return RESP_OK_STATUS(uj, (int32_t)strap);
38 test_command_t command;
39 TRY(ujson_deserialize_test_command_t(uj, &command));
41 case kTestCommandSwStrapRead:
42 RESP_ERR(uj, test_sw_strap_read(uj));
45 LOG_ERROR(
"Unrecognized command: %d", command);
46 RESP_ERR(uj, INVALID_ARGUMENT());
53 CHECK_DIF_OK(dif_pinmux_init(
58 uint32_t strap = pinmux_testutils_read_straps(&pinmux, &gpio);
59 LOG_INFO(
"Initial sw_strap=%d", strap);
61 ujson_t uj = ujson_ottf_console();
62 return status_ok(command_processor(&uj));