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 63:4d4c99ab8093, committed 2016-02-11
- Comitter:
- mjr
- Date:
- Thu Feb 11 23:21:17 2016 +0000
- Parent:
- 62:01ce5ceee7f7
- Child:
- 64:d839d8c94950
- Commit message:
- USBHAL_KL25Z EP0 BDT ownership tests
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:13:34 2016 +0000 +++ b/USBDevice/USBDevice/USBHAL_KL25Z.cpp Thu Feb 11 23:21:17 2016 +0000 @@ -368,14 +368,19 @@ void USBHAL::EP0readStage(void) { - Data1 &= ~1UL; // set DATA0 - bdt[0].info = (BD_DTS_MASK | BD_OWN_MASK); + if (!(bdt[0].info & BD_OWN_MASK)) + { + Data1 &= ~1UL; // set DATA0 + bdt[0].byte_count = MAX_PACKET_SIZE_EP0; + bdt[0].info = (BD_DTS_MASK | BD_OWN_MASK); + } } void USBHAL::EP0read(void) { uint32_t idx = EP_BDT_IDX(PHY_TO_LOG(EP0OUT), RX, 0); - bdt[idx].byte_count = MAX_PACKET_SIZE_EP0; + if (!(bdt[idx].info & BD_OWN_MASK)) + bdt[idx].byte_count = MAX_PACKET_SIZE_EP0; } uint32_t USBHAL::EP0getReadResult(uint8_t *buffer) @@ -401,9 +406,10 @@ EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) { - endpoint = PHY_TO_LOG(endpoint); - uint32_t idx = EP_BDT_IDX(endpoint, RX, 0); - bdt[idx].byte_count = maximumSize; + // We always start a new read when we fetch the result of the + // previous read, so we don't have to do anything here. Simply + // indicate that the read is pending so that the caller can proceed + // to check the results. return EP_PENDING; } @@ -532,6 +538,7 @@ 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); + bdt[idx].byte_count = epMaxPacket[endpoint]; Data1 &= ~(1 << endpoint); } EXIT_CRITICAL_SECTION @@ -619,9 +626,11 @@ USB0->ENDPOINT[0].ENDPT &= ~USB_ENDPT_EPSTALL_MASK; // take ownership of the RX and TX BDTs + bdt[EP_BDT_IDX(0, RX, EVEN)].info &= ~(BD_OWN_MASK | BD_STALL_MASK | BD_DATA01_MASK); 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)); + bdt[EP_BDT_IDX(0, RX, EVEN)].byte_count = MAX_PACKET_SIZE_EP0; + bdt[EP_BDT_IDX(0, TX, EVEN)].byte_count = MAX_PACKET_SIZE_EP0; + Data1 &= ~0x03; } // clear the busy-suspend bit to resume token processing