Skip to content

Commit 908674c

Browse files
committed
fix(support_rp2040): the first IN DATA packet must be DATA0
1 parent 92c3b06 commit 908674c

File tree

1 file changed

+14
-2
lines changed
  • src/r3_support_rp2040/src

1 file changed

+14
-2
lines changed

src/r3_support_rp2040/src/usb.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl usb_device::bus::UsbBus for UsbBus {
152152
.set(EP_BUF_CTRL_AVAIL | max_packet_size as u32);
153153
self.ep_max_packet_size[ep.index()] = max_packet_size;
154154
} else {
155-
self.ep_buf_ctrl(ep).set(0);
155+
self.ep_buf_ctrl(ep).set(EP_BUF_CTRL_PID_DATA1);
156156
}
157157

158158
self.ep_buffer_offset[address_to_index(ep)] = buffer_offset as _;
@@ -214,7 +214,19 @@ impl usb_device::bus::UsbBus for UsbBus {
214214

215215
self.ep_in_ready.set(0xffff);
216216

217-
// TODO: reset other endpoints
217+
for i in 1..16 {
218+
if (self.ep_allocation[0] & (1 << i)) != 0 {
219+
let ep = EndpointAddress::from_parts(i, UsbDirection::Out);
220+
let max_packet_size = self.ep_max_packet_size[i];
221+
self.ep_buf_ctrl(ep)
222+
.set(EP_BUF_CTRL_AVAIL | max_packet_size as u32);
223+
}
224+
225+
if (self.ep_allocation[1] & (1 << i)) != 0 {
226+
let ep = EndpointAddress::from_parts(i, UsbDirection::In);
227+
self.ep_buf_ctrl(ep).set(EP_BUF_CTRL_PID_DATA1);
228+
}
229+
}
218230
}
219231

220232
#[inline]

0 commit comments

Comments
 (0)