Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@
[submodule "FreeRTOS-Kernel"]
path = FreeRTOS-Kernel
url = https://github.com/earlephilhower/FreeRTOS-Kernel.git
[submodule "libraries/MIDIUSB"]
path = libraries/MIDIUSB
url = https://github.com/earlephilhower/MIDIUSB.git
1 change: 0 additions & 1 deletion cores/rp2040/SerialUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ void SerialUSB::end() {
_running = false;
USB.connect();
}

}

int SerialUSB::peek() {
Expand Down
13 changes: 6 additions & 7 deletions cores/rp2040/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ USBClass USB;
uint8_t _picotool_itf_num;
#endif


int usb_hid_poll_interval __attribute__((weak)) = 10;

uint8_t USBClass::registerEndpointIn() {
Expand Down Expand Up @@ -91,7 +90,7 @@ void USBClass::unregisterEndpointOut(int ep) {
_endpointOut |= (1 << (ep - 0x80));
}

uint8_t USBClass::addEntry(Entry **head, int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *param), const void *param, size_t len, int ordering, uint32_t vidMask) {
uint8_t USBClass::addEntry(Entry **head, int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *param), const void *param, size_t len, int ordering, uint32_t pidMask) {
static uint8_t id = 1;

Entry *n = (Entry *)malloc(sizeof(Entry));
Expand All @@ -101,7 +100,7 @@ uint8_t USBClass::addEntry(Entry **head, int interfaces, void (*cb)(int itf, uin
n->interfaces = interfaces;
n->order = ordering;
n->localid = id++;
n->mask = vidMask;
n->mask = pidMask;
n->next = nullptr;

// Go down list until we hit the end or an entry with ordering >= our level
Expand Down Expand Up @@ -163,17 +162,17 @@ uint8_t USBClass::findInterfaceID(unsigned int localid) {
}

// Called by a HID device to register a report. Returns the *local* ID which must be mapped to the HID report ID
uint8_t USBClass::registerHIDDevice(const uint8_t *descriptor, size_t len, int ordering, uint32_t vidMask) {
return addEntry(&_hids, 0, nullptr, (const void *)descriptor, len, ordering, vidMask);
uint8_t USBClass::registerHIDDevice(const uint8_t *descriptor, size_t len, int ordering, uint32_t pidMask) {
return addEntry(&_hids, 0, nullptr, (const void *)descriptor, len, ordering, pidMask);
}

void USBClass::unregisterHIDDevice(unsigned int localid) {
removeEntry(&_hids, localid);
}

// Called by an object at global init time to add a new interface (non-HID, like CDC or Picotool)
uint8_t USBClass::registerInterface(int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *), void *param, size_t len, int ordering, uint32_t vidMask) {
return addEntry(&_interfaces, interfaces, cb, param, len, ordering, vidMask);
uint8_t USBClass::registerInterface(int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *), void *param, size_t len, int ordering, uint32_t pidMask) {
return addEntry(&_interfaces, interfaces, cb, param, len, ordering, pidMask);
}

void USBClass::unregisterInterface(unsigned int localid) {
Expand Down
8 changes: 4 additions & 4 deletions cores/rp2040/USB.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class USBClass {
USBClass() { }

// Called by an object at global init time to register a HID device, returns a localID to be mapped using findHIDReportID
// vidMask is the bits in the VID that should be XOR'd when this device is present.
// pidMask is the bits in the PID that should be XOR'd when this device is present.
// 0 means don't invert anything, OTW select a single bitmask 1<<n.
uint8_t registerHIDDevice(const uint8_t *descriptor, size_t len, int ordering, uint32_t vidMask);
uint8_t registerHIDDevice(const uint8_t *descriptor, size_t len, int ordering, uint32_t pidMask);

// Remove a HID device from the USB descriptor. Only call after usbDisconnect or results could be unpredictable!
void unregisterHIDDevice(unsigned int localid);

// Called by an object at global init time to add a new interface (non-HID, like CDC or Picotool)
uint8_t registerInterface(int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *param), void *param, size_t len, int ordering, uint32_t vidMask);
uint8_t registerInterface(int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *param), void *param, size_t len, int ordering, uint32_t pidMask);

// Remove a USB interface from the USB descriptor. Only call after usbDisconnect or results could be unpredictable!
void unregisterInterface(unsigned int localid);
Expand Down Expand Up @@ -118,7 +118,7 @@ class USBClass {
} Entry;

// Add or remove Entry in a linked list, keeping things ordered by ordering
uint8_t addEntry(Entry **head, int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *param), const void *param, size_t len, int ordering, uint32_t vidMask);
uint8_t addEntry(Entry **head, int interfaces, void (*cb)(int itf, uint8_t *dst, int len, void *param), const void *param, size_t len, int ordering, uint32_t pidMask);
void removeEntry(Entry **head, unsigned int localid);

// Find the index (HID report ID or USB interface) of a given localid
Expand Down
1 change: 1 addition & 0 deletions libraries/MIDIUSB
Submodule MIDIUSB added at 9be8b7
3 changes: 2 additions & 1 deletion tests/restyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF
./libraries/SPISlave ./libraries/lwIP_ESPHost ./libraries/FatFS\
./libraries/FatFSUSB ./libraries/BluetoothAudio ./libraries/BluetoothHCI \
./libraries/BluetoothHIDMaster ./libraries/NetBIOS ./libraries/Ticker \
./libraries/VFS ./libraries/rp2350 ./libraries/SimpleMDNS ./libraries/SoftwareSPI ; do
./libraries/VFS ./libraries/rp2350 ./libraries/SimpleMDNS ./libraries/SoftwareSPI \
./libraries/MIDIUSB ; do
find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \;
find $dir -type f -name "*.ino" -exec astyle --suffix=none --options=./tests/astyle_examples.conf \{\} \;
done
Expand Down