5 #include "sw/device/lib/testing/usb_testutils_simpleserial.h"
8 #include "sw/device/lib/testing/test_framework/check.h"
9 #include "sw/device/lib/testing/usb_testutils.h"
12 #define MODULE_ID MAKE_MODULE_ID('u', 't', 'i')
21 while (packet_info.
length--) {
25 sizeof(data), &bytes_written));
26 ssctx->got_byte(data);
31 static status_t ss_tx_done(
void *ssctx_v, usb_testutils_xfr_result_t result) {
34 ssctx->sending =
false;
40 static status_t ss_flush(
void *ssctx_v) {
43 if (ssctx->cur_cpos <= 0 || ssctx->sending) {
46 if ((ssctx->cur_cpos & 0x3) != 0) {
49 ssctx->cur_cpos & 0x3, &bytes_written));
52 ssctx->sending =
true;
61 if (ssctx->cur_cpos == -1) {
64 }
else if (ssctx->cur_cpos >= MAX_GATHER && ssctx->sending) {
65 return OK_STATUS(
false);
67 ssctx->chold.data_b[ssctx->cur_cpos++ & 0x3] = c;
68 if ((ssctx->cur_cpos & 0x3) == 0) {
72 if (ssctx->cur_cpos >= MAX_GATHER && !ssctx->sending) {
74 ssctx->sending =
true;
78 return OK_STATUS(
true);
83 void (*got_byte)(uint8_t)) {
84 TRY(usb_testutils_endpoint_setup(ctx, ep, kUsbTransferTypeBulk,
85 kUsbTransferTypeBulk, kUsbdevOutStream,
86 ssctx, ss_tx_done, ss_rx, ss_flush, NULL));
89 ssctx->sending =
false;
90 ssctx->got_byte = got_byte;