|
20 | 20 | */
|
21 | 21 |
|
22 | 22 | #include <pico/mutex.h>
|
| 23 | +#include <limits.h> |
23 | 24 |
|
24 |
| -// Weak function definitions for each type of endpoint |
25 |
| -extern void __USBInstallSerial() __attribute__((weak)); |
| 25 | +// Called by an object at global init time to register a HID device, returns a localID to be mapped using findHIDReportID |
| 26 | +// vidMask is the bits in the VID that should be XOR'd when this device is present. |
| 27 | +// 0 means don't invert anything, OTW select a single bitmask 1<<n. |
| 28 | +uint8_t usbRegisterHIDDevice(const uint8_t *descriptor, size_t len, int ordering, uint32_t vidMask = 0); |
26 | 29 |
|
27 |
| -extern void __USBInstallKeyboard() __attribute__((weak)); |
| 30 | +// Called by an object at global init time to add a new interface (non-HID, like CDC or Picotool) |
| 31 | +uint8_t usbRegisterInterface(int interfaces, const uint8_t *descriptor, size_t len, int ordering = INT_MAX, uint32_t vidMask = 0); |
28 | 32 |
|
29 |
| -extern void __USBInstallJoystick() __attribute__((weak)); |
| 33 | +// Get the USB HID actual report ID from the localid |
| 34 | +uint8_t usbFindHIDReportID(unsigned int localid); |
30 | 35 |
|
31 |
| -// One or the other allowed, not both |
32 |
| -extern void __USBInstallMouse() __attribute__((weak)); |
33 |
| -extern void __USBInstallAbsoluteMouse() __attribute__((weak)); |
| 36 | +// Get the USB interface number from the localid |
| 37 | +uint8_t usbFindInterfaceID(unsigned int localid); |
34 | 38 |
|
35 |
| -extern void __USBInstallMassStorage() __attribute__((weak)); |
| 39 | +// Register a string for a USB descriptor |
| 40 | +uint8_t usbRegisterString(const char *str); |
| 41 | + |
| 42 | +// Get an unassigned in/cmd or out endpoint number |
| 43 | +uint8_t usbRegisterEndpointIn(); |
| 44 | +uint8_t usbRegisterEndpointOut(); |
36 | 45 |
|
37 | 46 | // Big, global USB mutex, shared with all USB devices to make sure we don't
|
38 | 47 | // have multiple cores updating the TUSB state in parallel
|
39 | 48 | extern mutex_t __usb_mutex;
|
40 | 49 |
|
41 |
| -// HID report ID inquiry (report ID will vary depending on the number/type of other HID) |
42 |
| -int __USBGetKeyboardReportID(); |
43 |
| -int __USBGetMouseReportID(); |
44 |
| -int __USBGetJoystickReportID(); |
45 |
| - |
46 | 50 | // Called by main() to init the USB HW/SW.
|
47 | 51 | void __USBStart();
|
48 | 52 |
|
|
0 commit comments