Skip to content

Commit

Permalink
Merge pull request #786 from ItsEcholot/master
Browse files Browse the repository at this point in the history
Add support for Seeed XIAO nRF52840 Sense Board
  • Loading branch information
Lauszus authored May 2, 2024
2 parents 3b1e156 + 4a6d33f commit d6cfefd
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ Currently the following boards are supported by the library:
* Any board supported by [MightyCore](https://github.com/MCUdude/MightyCore)
* RedBearLab nRF51822
* Adafruit Feather nRF52840 Express
* SEEED XIAO nRF52840 Sense
* Note it uses pin 7 and 5 for SS and INT respectively
* Digilent chipKIT
* Please see: <https://chome.nerpa.tech/mcu/usb/running-usb-host-code-on-digilent-chipkit-board>.
* STM32F4
Expand Down
2 changes: 2 additions & 0 deletions UsbCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ typedef MAX3421e<P3, P2> MAX3421E; // The Intel Galileo supports much faster rea
typedef MAX3421e<P15, P5> MAX3421E; // ESP8266 boards
#elif defined(ESP32)
typedef MAX3421e<P5, P17> MAX3421E; // ESP32 boards
#elif defined(ARDUINO_Seeed_XIAO_nRF52840_Sense)
typedef MAX3421e<P7, P5> MAX3421E; // Seeed_XIAO_nRF52840_Sense
#elif defined(MIGHTYCORE)
typedef MAX3421e<Pb4, Pb3> MAX3421E; // MightyCore
#elif (defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__))
Expand Down
62 changes: 62 additions & 0 deletions avrpins.h
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,68 @@ MAKE_PIN(P33, (9));

#undef MAKE_PIN



#elif defined(ARDUINO_Seeed_XIAO_nRF52840_Sense)

#define MAKE_PIN(className, pin) \
class className { \
public: \
static void Set() { \
nrf_gpio_pin_set(pin); \
} \
static void Clear() { \
nrf_gpio_pin_clear(pin); \
} \
static void SetDirRead() { \
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL); \
} \
static void SetDirWrite() { \
nrf_gpio_cfg_output(pin); \
} \
static uint8_t IsSet() { \
return (uint8_t)nrf_gpio_pin_read(pin); \
} \
};

// Based on variants/feather_nrf52840_express/variant.cpp
// g_ADigitalPinMap could be used directly, but it would be slower
MAKE_PIN(P0, (2));
MAKE_PIN(P1, (3));
MAKE_PIN(P2, (28));
MAKE_PIN(P3, (29));
MAKE_PIN(P4, (4));
MAKE_PIN(P5, (5));
MAKE_PIN(P6, (43));
MAKE_PIN(P7, (44));
MAKE_PIN(P8, (45));
MAKE_PIN(P9, (46));
MAKE_PIN(P10, (47));
MAKE_PIN(P11, (26));
MAKE_PIN(P12, (6));
MAKE_PIN(P13, (30));
MAKE_PIN(P14, (14));
MAKE_PIN(P15, (40));
MAKE_PIN(P17, (27));
MAKE_PIN(P18, (7));
MAKE_PIN(P16, (11));
MAKE_PIN(P19, (42));
MAKE_PIN(P20, (32));
MAKE_PIN(P21, (16));
MAKE_PIN(P22, (13));
MAKE_PIN(P23, (17));
MAKE_PIN(P24, (21));
MAKE_PIN(P25, (25));
MAKE_PIN(P26, (20));
MAKE_PIN(P27, (24));
MAKE_PIN(P28, (22));
MAKE_PIN(P29, (23));
MAKE_PIN(P30, (9));
MAKE_PIN(P31, (10));
MAKE_PIN(P32, (31));

#undef MAKE_PIN

#else
#error "Please define board in avrpins.h"

Expand Down
2 changes: 1 addition & 1 deletion examples/HID/scale/scale_rptparser.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined(ARDUINO_SAM_DUE) || defined(ARDUINO_NRF52840_FEATHER)
#if defined(ARDUINO_SAM_DUE) || defined(ARDUINO_NRF52840_FEATHER) || defined(ARDUINO_Seeed_XIAO_nRF52840_Sense)
#include <avr/dtostrf.h>
#endif

Expand Down
2 changes: 2 additions & 0 deletions usbhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ typedef SPi< P14, P13, P12, P15 > spi;
typedef SPi< P18, P23, P19, P5 > spi;
#elif defined(ARDUINO_NRF52840_FEATHER)
typedef SPi< P26, P25, P24, P5 > spi;
#elif defined(ARDUINO_Seeed_XIAO_nRF52840_Sense)
typedef SPi< P8, P10, P9, P7 > spi;
#else
#error "No SPI entry in usbhost.h"
#endif
Expand Down

0 comments on commit d6cfefd

Please sign in to comment.