USB device stack for NUCLEO-F042K6, NUCLEO-L152RE and NUCLEO-F103RB.
Fork of L152RE_USBDevice by
I tried USB device using HAL_PCD.
Nucleo-F042K6 | USB |
---|---|
PA11 (CN3-13) | DM (2 WHITE) |
PA12 (CN3-5) | DP (3 GREEN) |
GND (CN3-4) | GND (5 BLACK) |
VIN (CN4-1) | VBUS(1 RED) |
Examples
Import programF042K6_USBDevice_example
NUCLEO-F042K6 USBDevice example code
Import programL152RE_USBDevice_example
L152RE_USBDevice example code
Import programF042K6_Simple-CMSIS-DAP
cmsis-dap debug adapter
Import programL152RE_Simple-CMSIS-DAP
cmsis-dap debug adapter
Diff: USBDevice/USBHAL_KL25Z.cpp
- Revision:
- 22:5b7d31d9d3f3
- Parent:
- 20:d38b72fed893
- Child:
- 34:a4e9ddc2e2af
--- a/USBDevice/USBHAL_KL25Z.cpp Thu Mar 27 09:45:42 2014 +0000 +++ b/USBDevice/USBHAL_KL25Z.cpp Wed Apr 02 21:00:41 2014 +0100 @@ -16,7 +16,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M) +#if defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M) | defined(TARGET_K64F) #include "USBHAL.h" @@ -86,6 +86,9 @@ // Disable IRQ NVIC_DisableIRQ(USB0_IRQn); +#if defined(TARGET_K64F) + MPU->CESR=0; +#endif // fill in callback array epCallback[0] = &USBHAL::EP1_OUT_callback; epCallback[1] = &USBHAL::EP1_IN_callback; @@ -136,9 +139,9 @@ while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK); // Set BDT Base Register - USB0->BDTPAGE1=(uint8_t)((uint32_t)bdt>>8); - USB0->BDTPAGE2=(uint8_t)((uint32_t)bdt>>16); - USB0->BDTPAGE3=(uint8_t)((uint32_t)bdt>>24); + USB0->BDTPAGE1 = (uint8_t)((uint32_t)bdt>>8); + USB0->BDTPAGE2 = (uint8_t)((uint32_t)bdt>>16); + USB0->BDTPAGE3 = (uint8_t)((uint32_t)bdt>>24); // Clear interrupt flag USB0->ISTAT = 0xff;