Skip to content

Commit

Permalink
Fix build for SAME5x
Browse files Browse the repository at this point in the history
  • Loading branch information
rechrtb committed Apr 29, 2024
1 parent 1e2802d commit c19ed1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 9 additions & 5 deletions src/TinyUsbInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,8 @@ static Pin UsbModeDetect;
#endif

// Call this to initialise the hardware
#if CFG_TUH_ENABLED
void CoreUsbInit(NvicPriority priority, Pin usbVbusDetect, Pin usbVbusOn, Pin usbModeSwitch, Pin usbModeDetect) noexcept
#else
void CoreUsbInit(NvicPriority priority) noexcept
#endif
{

#if CFG_TUH_ENABLED
UsbVbusDetect = usbVbusDetect;
UsbVbusOn = usbVbusOn;
Expand Down Expand Up @@ -482,8 +477,17 @@ void CoreUsbStop()
#if CFG_TUH_ENABLED
digitalWrite(UsbVbusOn, false);
#endif

#if SAME5x
NVIC_DisableIRQ(USB_0_IRQn);
NVIC_DisableIRQ(USB_1_IRQn);
NVIC_DisableIRQ(USB_2_IRQn);
NVIC_DisableIRQ(USB_3_IRQn);
USB->DEVICE.CTRLA.reg &= ~USB_CTRLA_ENABLE;
#elif SAME70
NVIC_DisableIRQ((IRQn_Type)ID_USBHS);
USBHS->USBHS_CTRL &= ~USBHS_CTRL_USBE;
#endif
}

#if RP2040 // RP2040 USB configuration has HID enabled by default
Expand Down
10 changes: 4 additions & 6 deletions src/TinyUsbInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@
#if SUPPORT_USB && CORE_USES_TINYUSB
#include "tusb_option.h"

#if CFG_TUH_ENABLED
void CoreUsbInit(NvicPriority priority, Pin usbVbusDetect = NoPin, Pin usbVbusOn = NoPin, Pin usbModeSwitch = NoPin, Pin usbModeDetect = NoPin) noexcept; // call this to initialise the hardware
extern "C" [[noreturn]] void CoreUsbDeviceTask(void* param) noexcept; // this must be called by the USB task
void CoreUsbStop();

#if CFG_TUH_ENABLED
bool CoreUsbSetHostMode(bool hostMode, const StringRef& reply);
bool CoreUsbIsHostMode();
#else
void CoreUsbInit(NvicPriority priority) noexcept; // call this to initialise the hardware
#endif

extern "C" [[noreturn]] void CoreUsbDeviceTask(void* param) noexcept; // this must be called by the USB task
void CoreUsbStop();

#else
#define CFG_TUH_ENABLED 0
#endif
Expand Down

0 comments on commit c19ed1a

Please sign in to comment.