USBDevice with support for STM32F3
Fork of F042K6_USBDevice by
Diff: USBDevice/USBHAL_STM32F4.cpp
- Revision:
- 25:7c72828865f3
- Parent:
- 16:4f6df64750bd
- Child:
- 31:5bf05f9b3c7b
--- a/USBDevice/USBHAL_STM32F4.cpp Fri May 16 09:00:39 2014 +0100 +++ b/USBDevice/USBHAL_STM32F4.cpp Tue Jun 03 11:30:32 2014 +0100 @@ -36,7 +36,7 @@ return 0; } -USBHAL::USBHAL(void) { +USBHAL::USBHAL(void) { NVIC_DisableIRQ(OTG_FS_IRQn); epCallback[0] = &USBHAL::EP1_OUT_callback; epCallback[1] = &USBHAL::EP1_IN_callback; @@ -63,7 +63,7 @@ pin_mode(PA_9, OpenDrain); RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; - + // Enable interrupts OTG_FS->GREGS.GAHBCFG |= (1 << 0); @@ -116,21 +116,21 @@ uint32_t type; switch (endpoint) { - case EP0IN: + case EP0IN: case EP0OUT: type = 0; - break; + break; case EPISO_IN: case EPISO_OUT: - type = 1; + type = 1; case EPBULK_IN: case EPBULK_OUT: - type = 2; - break; + type = 2; + break; case EPINT_IN: case EPINT_OUT: - type = 3; - break; + type = 3; + break; } // Generic in or out EP controls @@ -154,7 +154,7 @@ if (endpoint != EP0IN) { control |= (1 << 28); // SD0PID } - + control |= (epIndex << 22) | // TxFIFO index (1 << 27); // SNAK OTG_FS->INEP_REGS[epIndex].DIEPCTL = control; @@ -166,7 +166,7 @@ // Set the out EP specific control settings control |= (1 << 26); // CNAK OTG_FS->OUTEP_REGS[epIndex].DOEPCTL = control; - + // Unmask the interrupt OTG_FS->DREGS.DAINTMSK |= (1 << (epIndex + 16)); } @@ -190,7 +190,7 @@ for (uint32_t i = 0; i < length; i += 4) { buffer32[i >> 2] = OTG_FS->FIFO[0][0]; } - + rxFifoCount = 0; return length; } @@ -266,7 +266,7 @@ return EP_COMPLETED; } - return EP_PENDING; + return EP_PENDING; } void USBHAL::stallEndpoint(uint8_t endpoint) { @@ -282,7 +282,7 @@ } void USBHAL::unstallEndpoint(uint8_t endpoint) { - + } bool USBHAL::getEndpointStallState(uint8_t endpoint) {