Skip to content

Commit

Permalink
add USB debug counters
Browse files Browse the repository at this point in the history
  • Loading branch information
tlyu committed Mar 16, 2023
1 parent c339cbb commit ac77b27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cores/arduino/USBCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ void (*oldResetHandler)(usb_dev *usbd);
void handleReset(usb_dev *usbd)
{
USBCore().logStatus("Reset");
USBCore().nreset++;
USBCore().setupClass(0);
EPBuffers().init();
USBCore().buildDeviceConfigDescriptor();
Expand Down Expand Up @@ -572,13 +573,15 @@ static void handleSetupErr(uint8_t len)
static void handleErr()
{
USBCore().logStatus("Error");
USBCore().nerror++;
}
#endif

void (*oldSuspendHandler)();
void handleSuspend()
{
USBCore().logStatus("Suspend");
USBCore().nsusp++;
oldSuspendHandler();
}

Expand All @@ -588,6 +591,7 @@ void handleResume()
usb_disable_interrupts();
USBCore().logStatus("Resume");
usb_enable_interrupts();
USBCore().nresume++;
oldResumeHandler();
}

Expand Down
6 changes: 6 additions & 0 deletions cores/arduino/USBCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ class USBCore_
int flush(uint8_t ep);
void setResetHook(void (*hook)());

// Debug counters
volatile uint16_t nreset;
volatile uint16_t nsusp;
volatile uint16_t nresume;
volatile uint16_t nerror;

uint8_t setupCtlOut(usb_req* req);
void setupClass(uint16_t wLength);
void ctlOut(usb_dev* udev);
Expand Down

0 comments on commit ac77b27

Please sign in to comment.