Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FastIO FastPWM SimpleDMA mbed
Fork of Pinscape_Controller by
Diff: USBDevice/USBDevice/USBHAL_KL25Z.cpp
- Revision:
- 61:a23a7b57bb95
- Parent:
- 60:f6e32a36f6ee
- Child:
- 62:01ce5ceee7f7
--- a/USBDevice/USBDevice/USBHAL_KL25Z.cpp Thu Feb 11 23:03:01 2016 +0000
+++ b/USBDevice/USBDevice/USBHAL_KL25Z.cpp Thu Feb 11 23:08:45 2016 +0000
@@ -525,15 +525,25 @@
return result;
}
-void USBHAL::stallEndpoint(uint8_t endpoint) {
+void USBHAL::stallEndpoint(uint8_t endpoint)
+{
USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT |= USB_ENDPT_EPSTALL_MASK;
}
-void USBHAL::unstallEndpoint(uint8_t endpoint) {
- USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
+void USBHAL::unstallEndpoint(uint8_t endpoint)
+{
+ ENTER_CRITICAL_SECTION
+ {
+ USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
+ int idx = PEP_BDT_IDX(endpoint, 0);
+ bdt[idx].info &= ~(BD_OWN_MASK | BD_STALL_MASK | BD_DATA01_MASK);
+ Data1 &= ~(1 << endpoint);
+ }
+ EXIT_CRITICAL_SECTION
}
-bool USBHAL::getEndpointStallState(uint8_t endpoint) {
+bool USBHAL::getEndpointStallState(uint8_t endpoint)
+{
uint8_t stall = (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPSTALL_MASK);
return (stall) ? true : false;
}
@@ -609,7 +619,15 @@
{
// if endpoint 0 is stalled, explicitly un-stall it
if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK)
+ {
+ // clear the stall bit in the endpoint register
USB0->ENDPOINT[0].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
+
+ // take ownership of the RX and TX BDTs
+ bdt[EP_BDT_IDX(0, TX, EVEN)].info &= ~(BD_OWN_MASK | BD_STALL_MASK | BD_DATA01_MASK);
+ bdt[EP_BDT_IDX(0, RX, EVEN)].info &= ~(BD_OWN_MASK | BD_STALL_MASK | BD_DATA01_MASK);
+ Data1 &= ~(EP(EP0OUT) | EP(EP0IN));
+ }
// clear the busy-suspend bit to resume token processing
USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK;
