summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorClifroy Henry <[email protected]>2023-01-03 11:58:22 -0500
committerhathach <[email protected]>2024-04-11 20:57:38 +0700
commit5a9b3eab6f3aa5e9fc71b902bfdbfef1acb29b44 (patch)
treefbe4afc4524f7a544e00100676891f9e1bc569a2 /src
parent87905d30ab8c94999bd69d0ae32f91ebdfef39d3 (diff)
Resolve erroneous data on enumeration.
Diffstat (limited to 'src')
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
index c1bef86fa..46b7d6458 100644
--- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
@@ -616,11 +616,20 @@ static void handle_setup_packet(void)
_setup_packet[i] = setup_buf[i];
}
- // Clearing SETUPIFG by reading USBVECINT does not set NAK, so now that we
- // have a SETUP packet, force NAKs until tinyusb can handle the SETUP
- // packet and prepare for a new xfer.
+ // Force NAKs until tinyusb can handle the SETUP packet and prepare
+ // for a new xfer.
USBIEPCNT_0 |= NAK;
USBOEPCNT_0 |= NAK;
+
+ // Clear SETUPIFG to avoid handling in the USBVECINT switch statement.
+ // When handled there the NAKs applied to the endpoints above are
+ // cleared by hardware and the host will receive stale/duplicate data.
+ //
+ // Excerpt from MSP430x5xx and MSP430x6xx Family User's Guide:
+ //
+ // "...the SETUPIFG is cleared upon reading USBIV. In addition, the NAK on
+ // input endpoint 0 and output endpoint 0 is also cleared."
+ USBIFG &= ~SETUPIFG;
dcd_event_setup_received(0, (uint8_t*) &_setup_packet[0], true);
}