Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c19ed1a

Browse files
author
rechrtb
committedApr 29, 2024
Fix build for SAME5x
1 parent 1e2802d commit c19ed1a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
 

‎src/TinyUsbInterface.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,8 @@ static Pin UsbModeDetect;
267267
#endif
268268

269269
// Call this to initialise the hardware
270-
#if CFG_TUH_ENABLED
271270
void CoreUsbInit(NvicPriority priority, Pin usbVbusDetect, Pin usbVbusOn, Pin usbModeSwitch, Pin usbModeDetect) noexcept
272-
#else
273-
void CoreUsbInit(NvicPriority priority) noexcept
274-
#endif
275271
{
276-
277272
#if CFG_TUH_ENABLED
278273
UsbVbusDetect = usbVbusDetect;
279274
UsbVbusOn = usbVbusOn;
@@ -482,8 +477,17 @@ void CoreUsbStop()
482477
#if CFG_TUH_ENABLED
483478
digitalWrite(UsbVbusOn, false);
484479
#endif
480+
481+
#if SAME5x
482+
NVIC_DisableIRQ(USB_0_IRQn);
483+
NVIC_DisableIRQ(USB_1_IRQn);
484+
NVIC_DisableIRQ(USB_2_IRQn);
485+
NVIC_DisableIRQ(USB_3_IRQn);
486+
USB->DEVICE.CTRLA.reg &= ~USB_CTRLA_ENABLE;
487+
#elif SAME70
485488
NVIC_DisableIRQ((IRQn_Type)ID_USBHS);
486489
USBHS->USBHS_CTRL &= ~USBHS_CTRL_USBE;
490+
#endif
487491
}
488492

489493
#if RP2040 // RP2040 USB configuration has HID enabled by default

‎src/TinyUsbInterface.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@
2828
#if SUPPORT_USB && CORE_USES_TINYUSB
2929
#include "tusb_option.h"
3030

31-
#if CFG_TUH_ENABLED
3231
void CoreUsbInit(NvicPriority priority, Pin usbVbusDetect = NoPin, Pin usbVbusOn = NoPin, Pin usbModeSwitch = NoPin, Pin usbModeDetect = NoPin) noexcept; // call this to initialise the hardware
32+
extern "C" [[noreturn]] void CoreUsbDeviceTask(void* param) noexcept; // this must be called by the USB task
33+
void CoreUsbStop();
34+
35+
#if CFG_TUH_ENABLED
3336
bool CoreUsbSetHostMode(bool hostMode, const StringRef& reply);
3437
bool CoreUsbIsHostMode();
35-
#else
36-
void CoreUsbInit(NvicPriority priority) noexcept; // call this to initialise the hardware
3738
#endif
3839

39-
extern "C" [[noreturn]] void CoreUsbDeviceTask(void* param) noexcept; // this must be called by the USB task
40-
void CoreUsbStop();
41-
4240
#else
4341
#define CFG_TUH_ENABLED 0
4442
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.