Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.
Dependencies: FastIO FastPWM SimpleDMA mbed
Fork of Pinscape_Controller by
Revision 61:a23a7b57bb95, committed 2016-02-11
- Comitter:
- mjr
- Date:
- Thu Feb 11 23:08:45 2016 +0000
- Parent:
- 60:f6e32a36f6ee
- Child:
- 62:01ce5ceee7f7
- Commit message:
- USBHAL_KL25Z stall fixes
Changed in this revision
USBDevice/USBDevice/USBHAL_KL25Z.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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;