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:
- 9:354942d2fa38
- Parent:
- 8:335f2506f422
- Child:
- 13:16731886c049
--- a/USBDevice/USBHAL_KL25Z.cpp Fri Mar 01 13:10:29 2013 +0000 +++ b/USBDevice/USBHAL_KL25Z.cpp Mon Mar 04 13:37:51 2013 +0000 @@ -66,8 +66,8 @@ // * 16 bidirectionnal endpt -> 32 physical endpt // * as there are ODD and EVEN buffer -> 32*2 bdt __attribute__((__aligned__(512))) BDT bdt[NUMBER_OF_PHYSICAL_ENDPOINTS * 2]; -uint8_t endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2][64]; -uint8_t endpoint_buffer_iso[2*2][1023]; +uint8_t * endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2]; +uint8_t * endpoint_buffer_iso[2*2]; static uint8_t set_addr = 0; static uint8_t addr = 0; @@ -199,15 +199,21 @@ if ((flags & ISOCHRONOUS) == 0) { handshake_flag = USB_ENDPT_EPHSHK_MASK; - if (IN_EP(endpoint)) + if (IN_EP(endpoint)) { + endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD )] = (uint8_t *) malloc (64*2); buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD )][0]; - else + } else { + endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD )] = (uint8_t *) malloc (64*2); buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD )][0]; + } } else { - if (IN_EP(endpoint)) + if (IN_EP(endpoint)) { + endpoint_buffer_iso[2] = (uint8_t *) malloc (1023*2); buf = &endpoint_buffer_iso[2][0]; - else + } else { + endpoint_buffer_iso[0] = (uint8_t *) malloc (1023*2); buf = &endpoint_buffer_iso[0][0]; + } } // IN endpt -> device to host (TX)