Skip to content

Commit

Permalink
ported to samd51, work the same as samd21
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Sep 14, 2023
1 parent 898c62f commit edd9c84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/arduino/Adafruit_USBH_Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ void tuh_max3421_spi_cs_api(uint8_t rhport, bool active) {
bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const *tx_buf,
size_t tx_len, uint8_t *rx_buf, size_t rx_len) {
(void)rhport;

if (!Adafruit_USBH_Host::_instance) {
return false;
}

Adafruit_USBH_Host *host = Adafruit_USBH_Host::_instance;

// MAX3421e max clock is 26MHz
Expand Down Expand Up @@ -171,13 +171,24 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const *tx_buf,

void tuh_max3421_int_api(uint8_t rhport, bool enabled) {
(void)rhport;

if (!Adafruit_USBH_Host::_instance) {
return;
}
Adafruit_USBH_Host *host = Adafruit_USBH_Host::_instance;

#ifdef ARDUINO_ARCH_SAMD
#ifdef __SAMD51
#ifdef __SAMD51__
const IRQn_Type irq =
(IRQn_Type)(EIC_0_IRQn + g_APinDescription[host->_intr].ulExtInt);

if (enabled) {
NVIC_EnableIRQ(irq);
} else {
NVIC_DisableIRQ(irq);
}
#else
(void)host;
if (enabled) {
NVIC_EnableIRQ(EIC_IRQn);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/arduino/ports/samd/tusb_config_samd.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ extern "C" {
#define CFG_TUSB_DEBUG 0
#endif

// For selectively disable device log (when > CFG_TUSB_DEBUG)
// #define CFG_TUD_LOG_LEVEL 3

#define CFG_TUSB_MEM_SECTION
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)

Expand Down

0 comments on commit edd9c84

Please sign in to comment.