2021-11-30 21:43:33 +08:00
# USB Stack
2021-12-12 15:21:56 +08:00
[中文版 ](./README_zh.md )
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
USB Stack is a tiny, beautiful and portable USB host and device stack for embedded system.
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
## USB Stack Directoy Structure
2021-12-04 14:41:09 +08:00
```
.
├── class
│ ├── audio
│ ├── cdc
│ ├── dfu
│ ├── hid
│ ├── hub
│ ├── midi
│ ├── msc
│ ├── tmc
│ └── video
├── common
├── core
├── demo
│ ├── bouffalolab
│ └── stm32
2021-12-05 21:14:19 +08:00
│ └── mm32
2022-01-11 22:43:32 +08:00
│ └── ch32
2021-12-04 14:41:09 +08:00
├── docs
├── packet capture
└── port
├── bouffalolab
│ └── bl702
├── ch32
2021-12-05 21:14:19 +08:00
├── fsdev
2021-12-04 14:41:09 +08:00
├── mm32
2021-12-12 15:21:56 +08:00
├── synopsys
2022-01-11 22:43:32 +08:00
├── musb
2021-12-04 14:41:09 +08:00
└── template
```
2021-12-12 15:21:56 +08:00
| Directory | Description |
|:-------------:|:---------------------------:|
|class | usb class driver |
|common | usb spec macros and utils |
|core | usb core implementation |
|demo | different chip demo |
|docs | doc for guiding |
2021-12-12 21:49:21 +08:00
|packet capture | packet capture file |
2021-12-12 15:21:56 +08:00
|port | usb dcd and hcd porting |
## USB Device Stack Overview
2021-12-12 21:49:21 +08:00
USB Device Stack provides a unified framework of functions for standard device requests, CLASS requests, VENDOR requests and custom special requests. The object-oriented and chained approach allows the user to quickly get started with composite devices without having to worry about the underlying logic. At the same time, a standard dcd porting interface has been standardised for adapting different USB IPs to achieve ip-oriented programming.
2021-12-12 15:21:56 +08:00
2021-12-12 21:49:21 +08:00
How USB Device Stack is implemented, this video will tell you: <https://www.bilibili.com/video/BV1Ef4y1t73d> .
2021-12-12 15:21:56 +08:00
USB Device Stack has the following functions:
- Support USB2.0 full and high speed
- Support endpoint irq callback register by users, let users do whatever they wants in endpoint irq callback.
- Support Composite class
- Support Communication Class (CDC)
- Support Human Interface Device (HID)
- Support Custom human Interface Device (HID)
- Support Mass Storage Class (MSC)
- Support USB VIDEO CLASS (UVC)
- Support USB AUDIO CLASS (UAC)
- Support Device Firmware Upgrade CLASS (DFU)
- Support USB MIDI CLASS (MIDI)
- Support Test and Measurement CLASS (TMC)
2021-12-12 21:49:21 +08:00
- Support Vendor class
2021-12-12 15:21:56 +08:00
- Support WINUSB1.0、WINUSB2.0
USB Device Stack resource usage:
2021-11-30 21:43:33 +08:00
| file | FLASH (Byte) | RAM (Byte) |
|:-----------:|:--------------:|:------------:|
|usbd_core.c | 3045 | 373 |
|usbd_cdc.c | 302 | 20 |
|usbd_msc.c | 2452 | 132 |
|usbd_hid.c | 784 | 201 |
|usbd_audio.c | 438 | 14 |
|usbd_video.c | 402 | 4 |
2021-12-12 15:21:56 +08:00
## USB Host Stack Overview
2021-11-30 21:43:33 +08:00
waiting....
2021-12-04 14:41:09 +08:00
## USB Device API
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
More of USB Device API reference, please visit : [USB Device API ](docs/usb_device.md )
2021-11-30 21:43:33 +08:00
2021-12-04 14:41:09 +08:00
## USB Host API
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
More of USB Host API reference, please visit: [USB Host API ](docs/usb_host.md )
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
## How To Use In RT-Thread package
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
How to use in RT-Thread package, please visit: [RT-Thread package Userguide with usb stack ](docs/rt-thread.md )
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
## USB Reference Manual
- USB2.0 spec: <https://www.usb.org/document-library/usb-20-specification>
- CDC: <https://www.usb.org/document-library/class-definitions-communication-devices-12>
- MSC: <https://www.usb.org/document-library/mass-storage-class-specification-overview-14>
<https://www.usb.org/document-library/mass-storage-bulk-only-10>
- HID: <https://www.usb.org/document-library/device-class-definition-hid-111>
<https://www.usb.org/document-library/hid-usage-tables-122>
- AUDIO: <https://www.usb.org/document-library/audiovideo-device-class-v10-spec-and-adopters-agreement>
<https://www.usb.org/document-library/audio-data-formats-10>
- VIDEO: <https://www.usb.org/document-library/video-class-v11-document-set>
- TMC: <https://www.usb.org/document-library/test-measurement-class-specification>
- DFU: <https://www.st.com/resource/zh/application_note/cd00264379-usb-dfu-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf>