Skip to content

Commit 4fcbba2

Browse files
purdeaandreistephanosio
authored andcommitted
drivers: usb_dc_rpi_pico: fix toggle data1/0 on to_device control transfers
The data stage of Control transfers that are sent from Host to Device, can be made out of multiple OUT transactions, if the amount of data to be transmitted is larger than the endpoint size. When this happens, the DATA pid should be toggling. The USB Device driver of the pico must correctly prime the EP0_OUT buffer with the correct data PID, otherwise the hardware will reject the received transaction. Before this change the driver used to always prime EP0_OUT with a DATA1 pid. After this change the driver only uses DATA1 pid after a setup transaction, and then toggles the pid for each transaction. Signed-off-by: Purdea Andrei <[email protected]>
1 parent dd47f4c commit 4fcbba2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/usb/device/usb_dc_rpi_pico.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ static int udc_rpi_start_xfer(uint8_t ep, const void *data, size_t len)
102102
}
103103
} else {
104104
ep_state->read_offset = 0;
105-
106-
if (USB_EP_GET_IDX(ep) == 0) {
107-
ep_state->next_pid = 1;
108-
}
109105
}
110106

111107
LOG_DBG("xfer ep %d len %d pid: %d", ep, len, ep_state->next_pid);
@@ -125,6 +121,7 @@ static void udc_rpi_handle_setup(void)
125121

126122
/* Set DATA1 PID for the next (data or status) stage */
127123
udc_rpi_get_ep_state(USB_CONTROL_EP_IN)->next_pid = 1;
124+
udc_rpi_get_ep_state(USB_CONTROL_EP_OUT)->next_pid = 1;
128125

129126
msg.ep = USB_CONTROL_EP_OUT;
130127
msg.type = USB_DC_EP_SETUP;

0 commit comments

Comments
 (0)