summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-01-08 11:21:26 +0700
committerhathach <[email protected]>2021-01-08 11:21:26 +0700
commitcc5dfd03cd64b1faad7374f6207cb80837134c89 (patch)
tree5ebfdd31b4aff77b4920cee83eb646cf6fc955e6
parent60620dca4286fc9ce9ddf4c2f2e6a39c062a5056 (diff)
update comment and correct the size to 8+2
-rw-r--r--src/portable/microchip/samd/dcd_samd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/portable/microchip/samd/dcd_samd.c b/src/portable/microchip/samd/dcd_samd.c
index 35fac23a8..4806342cc 100644
--- a/src/portable/microchip/samd/dcd_samd.c
+++ b/src/portable/microchip/samd/dcd_samd.c
@@ -39,11 +39,14 @@
static TU_ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2];
// Setup packet is only 8 bytes in length. However under certain scenario,
-// SAMD21 USB DMA controller is "suspected" to overwrite/overflow the setup_packet with 2 extra bytes.
-// Which corrupt other variable and cause issue such as
-// https://github.com/adafruit/circuitpython/issues/3912 (on macOS)
-// Therefore we increase it to 12 bytes as walk-around until figuring out the root cause
-static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8+4];
+// USB DMA controller may decide to overwrite/overflow the buffer with
+// 2 extra bytes of CRC. From datasheet's "Management of SETUP Transactions" section
+// If the number of received data bytes is the maximum data payload specified by
+// PCKSIZE.SIZE minus one, only the first CRC data is written to the data buffer.
+// If the number of received data is equal or less than the data payload specified
+// by PCKSIZE.SIZE minus two, both CRC data bytes are written to the data buffer.
+// Therefore we will increase it to 10 bytes just to be safe
+static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8+2];
// ready for receiving SETUP packet
static inline void prepare_setup(void)