Lightweight USB stack  1.0
readme.md
1 ![Travis (.org) branch](https://img.shields.io/travis/dmitrystu/libusb_stm32/master?logo=travis)
2 
3 ### Lightweight USB Device Stack ###
4 
5 + Lightweight and fast
6 + Event-driven process workflow
7 + Completely separated USB hardware driver and usb core
8 + Easy to use.
9 
10 ### Requirements ###
11 
12 + [CMSIS V4](https://github.com/ARM-software/CMSIS) or [CMSIS V5](https://github.com/ARM-software/CMSIS_5).
13 + [stm32.h](https://github.com/dmitrystu/stm32h) STM32 universal header
14 
15 All requirements can be downloaded into a directory specified in environment variable `CMSIS` using
16 `make cmsis` command.
17 
18 ### Supported hardware ###
19 
20 <table>
21  <tr><th>MCU Series</th><th>Features</th><th>Driver</th><th>File</th></tr>
22  <tr>
23  <td rowspan="2">STM32L0x2 STM32L0x3 STM32F070 STM32F0x2 STM32F0x8</td>
24  <td nowrap rowspan="2">Doublebuffered<sup>[2]</sup><br />8<sup>[1]</sup> endpoints<br /> BC1.2</td>
25  <td>usbd_devfs</td>
26  <td>usbd_stm32l052_devfs.c</td>
27  </tr>
28  <tr>
29  <td>usbd_devfs_asm</td>
30  <td>usbd_stm32l052_devfs_asm.S</td>
31  </tr>
32  <tr>
33  <td rowspan="2">STM32L4x2 STM32L4x3 STM32G4 series</td>
34  <td nowrap rowspan="2">Doublebuffered<sup>[2]</sup><br />8<sup>[1]</sup> endpoints<br /> BC1.2</td>
35  <td>usbd_devfs</td>
36  <td>usbd_stm32l433_devfs.c</td>
37  </tr>
38  <tr>
39  <td>usbd_devfs_asm</td>
40  <td>usbd_stm32l052_devfs_asm.S</td>
41  </tr>
42  <tr>
43  <td rowspan="2">STM32L1xx</td>
44  <td nowrap rowspan="2">Doublebuffered<sup>[2]</sup><br />8<sup>[1]</sup> endpoints</td>
45  <td>usbd_devfs</td>
46  <td>usbd_stm32l100_devfs.c</td>
47  </tr>
48  <tr>
49  <td>usbd_devfs_asm</td>
50  <td>usbd_stm32l100_devfs_asm.S</td>
51  </tr>
52  <tr>
53  <td rowspan="2">STM32F102 STM32F103 STM32F302 STM32F303 STM32F373</td>
54  <td nowrap rowspan="2">Doublebuffered<sup>[2]</sup><br />External DP pullup<br />8<sup>[1]</sup> endpoints</td>
55  <td>usbd_devfs</td>
56  <td>usbd_stm32f103_devfs.c</td>
57  </tr>
58  <tr>
59  <td>usbd_devfs_asm</td>
60  <td>usbd_stm32f103_devfs_asm.S</td>
61  </tr>
62  <tr>
63  <td>STM32L4x5 STM32L4x6</td>
64  <td nowrap>Doublebuffered<br />6 endpoints<br /> BC1.2<br />VBUS detection</td>
65  <td>usbd_otgfs</td>
66  <td>usbd_stm32l476_otgfs.c</td>
67  </tr>
68  <tr>
69  <td rowspan="2">STM32F4x5 STM32F4x7 STM32F4x9</td>
70  <td nowrap>Doublebuffered<br/>4 endpoints<br/>VBUS detection<br/>SOF output</td>
71  <td>usbd_otgfs</td>
72  <td>usbd_stm32f429_otgfs.c</td>
73  </tr>
74  <tr>
75  <td nowrap>Doublebuffered<br/>6 endpoints<br/>VBUS detection<br/>SOF output</td>
76  <td>usbd_otghs</td>
77  <td>usbd_stm32f429_otghs.c</td>
78  </tr>
79  <tr>
80  <td>STM32F105 STM32F107</td>
81  <td nowrap>Doublebuffered<br/>4 endpoints<br/>VBUS detection<br/>SOF output</td>
82  <td>usbd_otgfs</td>
83  <td>usbd_stm32f105_otgfs.c</td>
84  </tr>
85 </table>
86 
87 1. Single physical endpoint can be used to implement
88  + one bi-directional/single-buffer logical endpoint (CONTROL)
89  + one uni-directional/double-buffer logical endpoint (BULK OR ISOCHRONOUS)
90  + two uni-directional/single-buffer logical endpoints (BULK OR INTERRUPT)
91 
92 2. At this moment BULK IN endpoint can use both buffers, but it is not **real** doublebuffered.
93 
94 3. Tested with STM32L052K8, STM32L100RC, STM32L476RG, STM32F072C8, STM32F103C8, STM32F103CB, STM32F303CC, STM32F303RE, STM32F429ZI, STM32F105RBT6, STM32F107VCT6, STM32L433CCT6, STM32F070CBT6, STM32G431RB,
95 STM32F411CEUx
96 
97 ### Implemented definitions for classes ###
98 1. USB HID based on [Device Class Definition for Human Interface Devices (HID) Version 1.11](https://www.usb.org/sites/default/files/documents/hid1_11.pdf)
99 2. USB DFU based on [USB Device Firmware Upgrade Specification, Revision 1.1](https://www.usb.org/sites/default/files/DFU_1.1.pdf)
100 3. USB CDC based on [Class definitions for Communication Devices 1.2](https://www.usb.org/sites/default/files/CDC1.2_WMC1.1_012011.zip)
101 4. USB TMC based on [USB Device Test and Measurement Class Specification, Revision 1.0](https://www.usb.org/sites/default/files/USBTMC_1_006a.zip)
102 
103 ### Using makefile ###
104 + to build library module
105 ```
106 make module MODULE=path/module.a DEFINES="mcu spcified defines" CFLAGS="cpu cpecified compiler flags"
107 ```
108 + to build demo
109 ```
110 make bluepill program
111 make stm32l052x8
112 ```
113 + to get a help
114 ```
115 make help
116 ```
117 
118 ### Default values: ###
119 | Variable | Default Value | Means |
120 |----------|-------------------------------------|-------------------------------|
121 | CMSIS | ./CMSIS | path to CMSIS root folder |
122 | CMSISDEV | $(CMSIS)/Device | path to CMSIS device folder |
123 | CMSISCORE| $(CMSIS)/CMSIS/Include $(CMSIS)/CMSIS/Core/Include | path to CMSIS core headers |
124 | MCU | stm32l100xc | MCU selection for demo project|
125 | CFLAGS | -mcpu=cortex-m3 -mfloat-abi=soft | MCU specified compiler flags |
126 | DEFINES | STM32L1 STM32L100xC | MCU specified defines |
127 | STPROG_CLI | ~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI | Path to the ST Cube Programmer CLI |
128 | OPTFLAGS | -Os | Code optimization flags |
129 
130 ### Useful Resources ###
131 1. [USB Implementers Forum official site](https://www.usb.org/)
132 2. [USB Made Simple](http://www.usbmadesimple.co.uk/)
133 3. [LUFA - the Lightweight USB Framework for AVRs.](https://github.com/abcminiuser/lufa)
134 4. [Open Source ARM cortex m microcontroller library](https://github.com/libopencm3/libopencm3)