36 #include "sw/device/lib/testing/pinmux_testutils.h"
37 #include "sw/device/lib/testing/test_framework/check.h"
39 #include "sw/device/lib/testing/usb_testutils.h"
40 #include "sw/device/lib/testing/usb_testutils_controlep.h"
47 static const uint8_t kConfigDescriptors[] = {
49 USB_CFG_DSCR_LEN + 2 * (USB_INTERFACE_DSCR_LEN + 2 * USB_EP_DSCR_LEN),
51 VEND_INTERFACE_DSCR(0, 2, 0x50, 1),
52 USB_BULK_EP_DSCR(0, 1, 32, 0),
53 USB_BULK_EP_DSCR(1, 1, 32, 4),
54 VEND_INTERFACE_DSCR(1, 2, 0x50, 1),
55 USB_BULK_EP_DSCR(0, 2, 32, 0),
56 USB_BULK_EP_DSCR(1, 2, 32, 4),
62 static const uint8_t kTestDescriptor[] = {
63 USB_TESTUTILS_TEST_DSCR(kUsbTestNumberPinCfg, 0, 0, 0, 0)};
74 static dif_pinmux_t pinmux;
79 static dif_rstmgr_t rstmgr;
84 static bool verbose =
false;
86 OTTF_DEFINE_TEST_CONFIG();
89 LOG_INFO(
"Running USBDEV PINCFG test");
91 CHECK_DIF_OK(dif_pinmux_init(
93 pinmux_testutils_init(&pinmux);
97 CHECK_DIF_OK(dif_rstmgr_init(
115 test_cfg[
test].pinflip = ((
test & 1U) != 0U);
116 test_cfg[
test].en_diff_rcvr = ((
test & 2U) != 0U);
117 test_cfg[
test].tx_use_d_se0 =
false;
131 LOG_INFO(
" - CW310/340/Teacup does not support pinflipping; ignoring");
132 LOG_INFO(
" - CW310/340/Teacup employs only differential transmission");
135 test_cfg[
test].pinflip =
false;
136 test_cfg[
test].en_diff_rcvr = ((
test & 1U) != 0U);
138 test_cfg[
test].tx_use_d_se0 =
false;
151 test_cfg[
test].pinflip = ((
test & 1U) != 0U);
152 test_cfg[
test].en_diff_rcvr = ((
test & 2U) != 0U);
153 test_cfg[
test].tx_use_d_se0 = ((
test & 4U) != 0U);
159 bool tx_use_d_se0 = test_cfg[
test].tx_use_d_se0;
160 bool en_diff_rcvr = test_cfg[
test].en_diff_rcvr;
161 bool pinflip = test_cfg[
test].pinflip;
164 LOG_INFO(
"Init test %u pinflip %!b en_diff_rcvr %!b tx_use_d_se0 %!b",
165 test, pinflip, en_diff_rcvr, tx_use_d_se0);
172 usb_testutils_init(&usbdev, pinflip, en_diff_rcvr, tx_use_d_se0));
176 CHECK_STATUS_OK(usb_testutils_controlep_init(
177 &usbdev_control, &usbdev, 0, kConfigDescriptors,
178 sizeof(kConfigDescriptors), kTestDescriptor,
sizeof(kTestDescriptor)));
183 usb_testutils_controlep_config_wait(&usbdev_control, &usbdev));
190 CHECK_STATUS_OK(usb_testutils_poll(&usbdev));
192 }
while (link_state == kDifUsbdevLinkStateActive);
198 CHECK_STATUS_OK(usb_testutils_fin(&usbdev));
207 kTopEarlgreyResetManagerSwResetsUsb,
213 kTopEarlgreyResetManagerSwResetsUsb,