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: USBMSD/USBMSD.cpp
- Revision:
- 7:f8f057664123
- Parent:
- 5:d27e4c226965
- Child:
- 8:335f2506f422
--- a/USBMSD/USBMSD.cpp Thu Dec 20 17:05:37 2012 +0000 +++ b/USBMSD/USBMSD.cpp Mon Jan 21 10:41:28 2013 +0000 @@ -114,7 +114,7 @@ // get memory size MemorySize = disk_size(); - if (BlockCount >= 0) { + if (BlockCount > 0) { BlockSize = MemorySize / BlockCount; if (BlockSize != 0) { page = (uint8_t *)malloc(BlockSize * sizeof(uint8_t)); @@ -222,7 +222,7 @@ // if the array is filled, write it in memory if (!((addr + size)%BlockSize)) { if (!(disk_status() & WRITE_PROTECT)) { - disk_write((const char *)page, addr/BlockSize); + disk_write(page, addr/BlockSize); } } @@ -247,7 +247,7 @@ // beginning of a new block -> load a whole block in RAM if (!(addr%BlockSize)) - disk_read((char *)page, addr/BlockSize); + disk_read(page, addr/BlockSize); // info are in RAM -> no need to re-read memory for (n = 0; n < size; n++) { @@ -495,7 +495,7 @@ // we read an entire block if (!(addr%BlockSize)) - disk_read((char *)page, addr/BlockSize); + disk_read(page, addr/BlockSize); // write data which are in RAM writeNB(EPBULK_IN, &page[addr%BlockSize], n, MAX_PACKET_SIZE_EPBULK);