diff options
| author | Scott Shawcroft <[email protected]> | 2018-11-14 14:36:26 -0800 |
|---|---|---|
| committer | Scott Shawcroft <[email protected]> | 2018-11-23 11:20:23 -0800 |
| commit | bf8c4612dccfc65e0867d03d85d9ebe2e46101e0 (patch) | |
| tree | 707b9a71685bf8ad7ae7f0afb745780decfedae1 /src | |
| parent | 246c28db1a2bc2a2c0d21c62789bcc72e3fadeae (diff) | |
Make sure OUT endpoint 0 on the SAMDs always has a valid buffer to store
a SETUP token into.
Diffstat (limited to 'src')
| -rw-r--r-- | src/portable/microchip/samd21/dcd_samd21.c | 6 | ||||
| -rw-r--r-- | src/portable/microchip/samd51/dcd_samd51.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index 93425b63c..c2464d6b0 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -164,6 +164,12 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t UsbDeviceDescBank* bank = &sram_registers[epnum][dir]; UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum]; + // A setup token can occur immediately after an OUT STATUS packet so make sure we have a valid + // buffer for the control endpoint. + if (epnum == 0 && dir == 0 && buffer == NULL) { + buffer = _setup_packet; + } + bank->ADDR.reg = (uint32_t) buffer; if ( dir == TUSB_DIR_OUT ) { diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index 705e06e61..e53a8641f 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -163,6 +163,12 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t UsbDeviceDescBank* bank = &sram_registers[epnum][dir]; UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum]; + // A setup token can occur immediately after an OUT STATUS packet so make sure we have a valid + // buffer for the control endpoint. + if (epnum == 0 && dir == 0 && buffer == NULL) { + buffer = _setup_packet; + } + bank->ADDR.reg = (uint32_t) buffer; if ( dir == TUSB_DIR_OUT ) { |
