dcd_msp430x5xx: Improve SETUP packet and EP0 NAK interactions, per

42.3.1.3 in Reference Manual; fix is incomplete but works.
This commit is contained in:
William D. Jones 2019-10-10 04:02:35 -04:00
parent 97af9e3332
commit c8e899fef0
1 changed files with 8 additions and 3 deletions

View File

@ -90,9 +90,9 @@ static void bus_reset(void)
USBOEPIE |= BIT0;
USBIEPIE |= BIT0;
// Set NAK until a setup packet is received.
USBOEPCNT_0 |= NAK;
USBIEPCNT_0 |= NAK;
// Clear NAK until a setup packet is received.
USBOEPCNT_0 &= ~NAK;
USBIEPCNT_0 &= ~NAK;
USBCTL |= FEN; // Enable responding to packets.
@ -515,6 +515,11 @@ static void handle_setup_packet(void)
_setup_packet[i] = setup_buf[i];
}
// The NAK bits must be clear to receive a SETUP packet. Clearing SETUPIFG
// by reading USBVECINT does not set NAK, so now that we have a SETUP packet
// force NAKs.
USBIEPCNT_0 |= NAK;
USBOEPCNT_0 |= NAK;
dcd_event_setup_received(0, (uint8_t*) &_setup_packet[0], true);
}