Skip to content

Commit e249642

Browse files
authored
Ensure RP2040 tx buffer control is respected (#699)
See also "4.1.2.7.1. Concurrent access" in the RP2040 datasheet.
1 parent ab6e138 commit e249642

File tree

1 file changed

+2
-0
lines changed
  • port/raspberrypi/rp2xxx/src/hal

1 file changed

+2
-0
lines changed

port/raspberrypi/rp2xxx/src/hal/usb.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ pub fn F(comptime config: UsbConfig) type {
254254
// TODO: assert!(UsbDir::of_endpoint_addr(ep.descriptor.endpoint_address) == UsbDir::In);
255255

256256
const ep = hardware_endpoint_get_by_address(ep_addr);
257+
// wait for controller to give processor ownership of the buffer before writing it.
258+
while (ep.buffer_control.?.read().AVAILABLE_0 == 1) {}
257259

258260
// TODO: please fixme: https://github.com/ZigEmbeddedGroup/microzig/issues/452
259261
std.mem.copyForwards(u8, ep.data_buffer[0..buffer.len], buffer);

0 commit comments

Comments
 (0)