USB and CherryUSB¶
SF32 devices expose USB hardware, and SiFli-SDK documentation and examples reference CherryUSB integration. Treat USB as a software stack, not only as a hardware feature.
USB work crosses firmware, descriptors, host operating systems, power behavior, and factory tooling. A device that enumerates once on a developer laptop is not finished.
Use Cases¶
- USB CDC serial.
- HID devices.
- MSC storage.
- USB audio microphone/speaker.
- MTP.
- USB host modes such as CDC, HID, MSC, UVC, and UAC where supported by the SDK and board.
Practical Workflow¶
- Confirm the board exposes the required USB connector and power path.
- Start from the closest SDK USB example.
- Test enumeration on Windows, macOS, and Linux.
- Verify suspend/resume and cable reconnect behavior.
- Record VID/PID, descriptors, and driver expectations.
What to Test¶
- Cold plug and hot plug.
- Reset while connected.
- Host sleep/wake.
- Cable disconnect during transfer.
- Windows, macOS, and Linux enumeration.
- Composite device behavior if multiple classes are enabled.
- Power-only cable failure messaging in user docs.
Descriptor Checklist¶
- VID/PID ownership is clear.
- Product string is final or versioned.
- Serial number behavior is defined.
- Class/subclass/protocol values match the intended host driver.
- Composite interfaces are stable across firmware updates.
SDK Examples¶
The official SiFli-SDK CherryUSB example index separates USB-device and USB-host work. Start with the example that matches the intended USB role and class, then carry its descriptor, power, and host-compatibility checks into the product implementation.
Table: SiFli-SDK CherryUSB examples for SF32LB58x
| USB role | Example | Starting point |
|---|---|---|
| Device | USB microphone | USB Audio Class 1 microphone |
| Device | USB microphone and speaker | USB Audio Class 1 duplex audio |
| Device | CDC ACM | USB communications device |
| Device | CDC ACM UART | USB-to-UART bridge |
| Device | CDC + HID + MSC | Composite USB device |
| Device | HID mouse | USB HID pointing device |
| Device | MSC with NOR flash | Mass storage backed by NOR flash |
| Device | MSC with RAM disk | Mass storage backed by RAM |
| Device | MSC with dual RAM disks | Two logical units backed by RAM |
| Device | MSC with SD/eMMC | Mass storage backed by SD card or eMMC |
| Device | MTP with DFS and RAM disk | Media Transfer Protocol device |
| Host | CDC ACM host | Communicate with a CDC ACM peripheral |
| Host | HID host | Attach and read a HID peripheral |
| Host | MSC host | Attach a USB mass-storage peripheral |
| Host | UVC + UAC host | USB video and audio-class peripherals |