cnlohr / rv003usb

CH32V003 RISC-V Pure Software USB Controller
MIT License
436 stars 43 forks source link

Rename USB_DM/USB_DP to end confusion #46

Closed xsrf closed 6 months ago

xsrf commented 6 months ago

Before this, USB_DP was used for D- and USB_DM was used for D+ due to historical reasons during development of the USB stack. This however is frustratingly confusing, so this should fix it.

This renames USB_DM to USB_PIN_DP, USB_DP to USB_PIN_DM and USB_DPU to USB_PIN_DPU (for consistency). The changes include a fallback so previous code will still compile fine but issue a warning.

Users with

#define USB_DM 3 // USB_DM is the physical USB D+ Pin!
#define USB_DP 4 // USB_DP is the physical USB D- Pin!
#define USB_DPU 5 // USB_DPU feeds the 1.5K Pull-Up on USB D- Pin! Comment out if not used / tied to 3V3!
#define USB_PORT D // Pins on PORT A, C or D

are encouraged to switch to

#define USB_PIN_DP 3 // USB_PIN_DP is the physical USB D+ Pin!
#define USB_PIN_DM 4 // USB_PIN_DM is the physical USB D- Pin!
#define USB_PIN_DPU 5 // USB_PIN_DPU feeds the 1.5K Pull-Up on USB D- Pin! Comment out if not used / tied to 3V3!
#define USB_PORT D // Pins on PORT A, C or D

Users that have not switched yet will get a compiler warning

Warning: #warning "You usb_config.h is outdated. Please use USB_PIN_DP, USB_PIN_DM and USB_PIN_DPU instead with their respective signal (no swapping!)"

This replaces #44 due to user feedback