summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2019-12-25 23:59:07 +0700
committerGitHub <[email protected]>2019-12-25 23:59:07 +0700
commitb8cef16b58ec04649904c132152665d39862870a (patch)
treede1a01f77f6fd3485a884ea3085ef932ab40fe48 /src
parent8c674d9c11f93ace7cf99f0e9bd5b6f28e945f21 (diff)
parent5690e7b304d9179dd1b8e35b3f61e016b7822c31 (diff)
Merge pull request #245 from hathach/develop
fix samd51 setup packet handling
Diffstat (limited to 'src')
-rw-r--r--src/portable/microchip/samd21/dcd_samd21.c2
-rw-r--r--src/portable/microchip/samd51/dcd_samd51.c13
2 files changed, 6 insertions, 9 deletions
diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c
index 5e44dc387..c96c87f88 100644
--- a/src/portable/microchip/samd21/dcd_samd21.c
+++ b/src/portable/microchip/samd21/dcd_samd21.c
@@ -253,7 +253,7 @@ static bool maybe_handle_setup_packet(void) {
USB->DEVICE.DeviceEndpoint[0].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_RXSTP;
// This copies the data elsewhere so we can reuse the buffer.
- dcd_event_setup_received(0, (uint8_t*) sram_registers[0][0].ADDR.reg, true);
+ dcd_event_setup_received(0, _setup_packet, true);
return true;
}
return false;
diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c
index c298acc53..598ab7bbb 100644
--- a/src/portable/microchip/samd51/dcd_samd51.c
+++ b/src/portable/microchip/samd51/dcd_samd51.c
@@ -34,7 +34,7 @@
/*------------------------------------------------------------------*/
/* MACRO TYPEDEF CONSTANT ENUM
*------------------------------------------------------------------*/
-static UsbDeviceDescBank sram_registers[8][2];
+static TU_ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2];
static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8];
// Setup the control endpoint 0.
@@ -69,7 +69,7 @@ void dcd_init (uint8_t rhport)
USB->DEVICE.PADCAL.bit.TRANSP = (*((uint32_t*) USB_FUSES_TRANSP_ADDR) & USB_FUSES_TRANSP_Msk) >> USB_FUSES_TRANSP_Pos;
USB->DEVICE.PADCAL.bit.TRANSN = (*((uint32_t*) USB_FUSES_TRANSN_ADDR) & USB_FUSES_TRANSN_Msk) >> USB_FUSES_TRANSN_Pos;
- USB->DEVICE.PADCAL.bit.TRIM = (*((uint32_t*) USB_FUSES_TRIM_ADDR) & USB_FUSES_TRIM_Msk) >> USB_FUSES_TRIM_Pos;
+ USB->DEVICE.PADCAL.bit.TRIM = (*((uint32_t*) USB_FUSES_TRIM_ADDR) & USB_FUSES_TRIM_Msk) >> USB_FUSES_TRIM_Pos;
USB->DEVICE.QOSCTRL.bit.CQOS = 3;
USB->DEVICE.QOSCTRL.bit.DQOS = 3;
@@ -81,7 +81,7 @@ void dcd_init (uint8_t rhport)
while (USB->DEVICE.SYNCBUSY.bit.ENABLE == 1) {}
USB->DEVICE.INTFLAG.reg |= USB->DEVICE.INTFLAG.reg; // clear pending
- USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST;
+ USB->DEVICE.INTENSET.reg = /* USB_DEVICE_INTENSET_SOF | */ USB_DEVICE_INTENSET_EORST;
}
void dcd_int_enable(uint8_t rhport)
@@ -257,7 +257,8 @@ static bool maybe_handle_setup_packet(void) {
USB->DEVICE.DeviceEndpoint[0].EPINTFLAG.reg = USB_DEVICE_EPINTFLAG_RXSTP;
// This copies the data elsewhere so we can reuse the buffer.
- dcd_event_setup_received(0, (uint8_t*) sram_registers[0][0].ADDR.reg, true);
+ dcd_event_setup_received(0, _setup_packet, true);
+
return true;
}
return false;
@@ -336,11 +337,7 @@ void transfer_complete(uint8_t direction) {
continue;
}
- if (direction == TUSB_DIR_OUT && maybe_handle_setup_packet()) {
- continue;
- }
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
-
UsbDeviceDescBank* bank = &sram_registers[epnum][direction];
uint16_t total_transfer_size = bank->PCKSIZE.bit.BYTE_COUNT;