From e8358763b537fee42d58a507f9649a8527d78222 Mon Sep 17 00:00:00 2001 From: Anthony Rios Date: Thu, 27 May 2021 21:34:49 -0400 Subject: [PATCH] Added support for Adafruit NRF52832 Feather Used this pr as a reference: https://github.com/felis/USB_Host_Shield_2.0/pull/614 --- avrpins.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ usbhost.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/avrpins.h b/avrpins.h index 89127f19..3aa22253 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1295,6 +1295,65 @@ MAKE_PIN(P19, GPIOC, GPIO_PIN_0); // A5 #undef MAKE_PIN +#elif defined(ARDUINO_NRF52832_FEATHER) + +#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_nrf52832/variant.cpp +// g_ADigitalPinMap could be used directly, but it would be slower +MAKE_PIN(P0, (0)); +MAKE_PIN(P1, (1)); +MAKE_PIN(P2, (2)); +MAKE_PIN(P3, (3)); +MAKE_PIN(P4, (4)); +MAKE_PIN(P5, (5)); +MAKE_PIN(P6, (6)); +MAKE_PIN(P7, (7)); +MAKE_PIN(P8, (8)); +MAKE_PIN(P9, (9)); +MAKE_PIN(P10, (10)); +MAKE_PIN(P11, (11)); +MAKE_PIN(P12, (12)); +MAKE_PIN(P13, (13)); +MAKE_PIN(P14, (14)); +MAKE_PIN(P15, (15)); +MAKE_PIN(P17, (16)); +MAKE_PIN(P18, (17)); +MAKE_PIN(P16, (18)); +MAKE_PIN(P19, (19)); +MAKE_PIN(P20, (20)); +MAKE_PIN(P21, (21)); +MAKE_PIN(P22, (22)); +MAKE_PIN(P23, (23)); +MAKE_PIN(P24, (24)); +MAKE_PIN(P25, (25)); +MAKE_PIN(P26, (26)); +MAKE_PIN(P27, (27)); +MAKE_PIN(P28, (28)); +MAKE_PIN(P29, (29)); +MAKE_PIN(P30, (30)); +MAKE_PIN(P31, (31)); + +#undef MAKE_PIN + #elif defined(ARDUINO_NRF52840_FEATHER) #define MAKE_PIN(className, pin) \ diff --git a/usbhost.h b/usbhost.h index de34813b..09c956c1 100644 --- a/usbhost.h +++ b/usbhost.h @@ -120,6 +120,8 @@ typedef SPi< P16, P18, P17, P10 > spi; typedef SPi< P14, P13, P12, P15 > spi; #elif defined(ESP32) typedef SPi< P18, P23, P19, P5 > spi; +#elif defined(ARDUINO_NRF52832_FEATHER) +typedef SPi< P14, P13, P12, P11 > spi; #elif defined(ARDUINO_NRF52840_FEATHER) typedef SPi< P26, P25, P24, P5 > spi; #else