diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index d3e796ea0..33cd6b8e5 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -12,6 +12,7 @@ jobs: - 'xiaonRF52840' - 'xiaonRF52840Sense' - 'wio_tracker_1110' + - 'xiaonRF52840Plus' runs-on: ubuntu-latest diff --git a/boards.txt b/boards.txt index c3ca6023d..a87ac6e00 100644 --- a/boards.txt +++ b/boards.txt @@ -179,3 +179,111 @@ wio_tracker_1110.menu.lbm_custom.standard=No wio_tracker_1110.menu.lbm_custom.standard.build.flags.lbm_custom=-DLBM_CUSTOM=0 wio_tracker_1110.menu.lbm_custom.sensecap=SenseCAP wio_tracker_1110.menu.lbm_custom.sensecap.build.flags.lbm_custom=-DLBM_CUSTOM=1 + +# ---------------------------------- +# Seeed XIAO nRF52840 Plus +# ---------------------------------- +xiaonRF52840Plus.name=Seeed XIAO nRF52840 Plus + +# VID/PID for bootloader +xiaonRF52840Plus.vid.0=0x2886 +xiaonRF52840Plus.pid.0=0x8064 +xiaonRF52840Plus.vid.1=0x2886 +xiaonRF52840Plus.pid.1=0x0064 +xiaonRF52840Plus.vid.2=0x2886 +xiaonRF52840Plus.pid.2=0x0064 +xiaonRF52840Plus.vid.3=0x2886 +xiaonRF52840Plus.pid.3=0x8064 + +# Upload +xiaonRF52840Plus.bootloader.tool=bootburn +xiaonRF52840Plus.upload.tool=nrfutil +xiaonRF52840Plus.upload.protocol=nrfutil +xiaonRF52840Plus.upload.use_1200bps_touch=true +xiaonRF52840Plus.upload.wait_for_upload_port=true +xiaonRF52840Plus.upload.maximum_size=811008 +xiaonRF52840Plus.upload.maximum_data_size=237568 + +# Build +xiaonRF52840Plus.build.mcu=cortex-m4 +xiaonRF52840Plus.build.f_cpu=64000000 +xiaonRF52840Plus.build.board=Seeed_XIAO_nRF52840_Plus +xiaonRF52840Plus.build.core=nRF5 +xiaonRF52840Plus.build.variant=Seeed_XIAO_nRF52840_Plus +xiaonRF52840Plus.build.usb_manufacturer="Seeed" +xiaonRF52840Plus.build.usb_product="XIAO nRF52840 Plus" +xiaonRF52840Plus.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +xiaonRF52840Plus.build.ldscript=nrf52840_s140_v7.ld +xiaonRF52840Plus.build.vid=0x2886 +xiaonRF52840Plus.build.pid=0x8044 + +# SofDevice Menu +xiaonRF52840Plus.menu.softdevice.s140v6=S140 7.3.0 +xiaonRF52840Plus.menu.softdevice.s140v6.build.sd_name=s140 +xiaonRF52840Plus.menu.softdevice.s140v6.build.sd_version=7.3.0 +xiaonRF52840Plus.menu.softdevice.s140v6.build.sd_fwid=0x0123 + +# Debug Menu +xiaonRF52840Plus.menu.debug.l0=Level 0 (Release) +xiaonRF52840Plus.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +xiaonRF52840Plus.menu.debug.l1=Level 1 (Error Message) +xiaonRF52840Plus.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +xiaonRF52840Plus.menu.debug.l2=Level 2 (Full Debug) +xiaonRF52840Plus.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +xiaonRF52840Plus.menu.debug.l3=Level 3 (Segger SystemView) +xiaonRF52840Plus.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +xiaonRF52840Plus.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 + +# ---------------------------------- +# Seeed XIAO nRF52840 Sense Plus +# ---------------------------------- +xiaonRF52840SensePlus.name=Seeed XIAO nRF52840 Sense Plus + +# VID/PID for bootloader +xiaonRF52840SensePlus.vid.0=0x2886 +xiaonRF52840SensePlus.pid.0=0x8065 +xiaonRF52840SensePlus.vid.1=0x2886 +xiaonRF52840SensePlus.pid.1=0x0065 +xiaonRF52840SensePlus.vid.2=0x2886 +xiaonRF52840SensePlus.pid.2=0x0065 +xiaonRF52840SensePlus.vid.3=0x2886 +xiaonRF52840SensePlus.pid.3=0x8065 + +# Upload +xiaonRF52840SensePlus.bootloader.tool=bootburn +xiaonRF52840SensePlus.upload.tool=nrfutil +xiaonRF52840SensePlus.upload.protocol=nrfutil +xiaonRF52840SensePlus.upload.use_1200bps_touch=true +xiaonRF52840SensePlus.upload.wait_for_upload_port=true +xiaonRF52840SensePlus.upload.maximum_size=811008 +xiaonRF52840SensePlus.upload.maximum_data_size=237568 + +# Build +xiaonRF52840SensePlus.build.mcu=cortex-m4 +xiaonRF52840SensePlus.build.f_cpu=64000000 +xiaonRF52840SensePlus.build.board=Seeed_XIAO_nRF52840_Sense_Plus +xiaonRF52840SensePlus.build.core=nRF5 +xiaonRF52840SensePlus.build.variant=Seeed_XIAO_nRF52840_Sense_Plus +xiaonRF52840SensePlus.build.usb_manufacturer="Seeed" +xiaonRF52840SensePlus.build.usb_product="XIAO nRF52840 Sense Plus" +xiaonRF52840SensePlus.build.extra_flags=-DNRF52840_XXAA {build.flags.usb} +xiaonRF52840SensePlus.build.ldscript=nrf52840_s140_v7.ld +xiaonRF52840SensePlus.build.vid=0x2886 +xiaonRF52840SensePlus.build.pid=0x8044 + +# SofDevice Menu +xiaonRF52840SensePlus.menu.softdevice.s140v6=S140 7.3.0 +xiaonRF52840SensePlus.menu.softdevice.s140v6.build.sd_name=s140 +xiaonRF52840SensePlus.menu.softdevice.s140v6.build.sd_version=7.3.0 +xiaonRF52840SensePlus.menu.softdevice.s140v6.build.sd_fwid=0x0123 + +# Debug Menu +xiaonRF52840SensePlus.menu.debug.l0=Level 0 (Release) +xiaonRF52840SensePlus.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +xiaonRF52840SensePlus.menu.debug.l1=Level 1 (Error Message) +xiaonRF52840SensePlus.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +xiaonRF52840SensePlus.menu.debug.l2=Level 2 (Full Debug) +xiaonRF52840SensePlus.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +xiaonRF52840SensePlus.menu.debug.l3=Level 3 (Segger SystemView) +xiaonRF52840SensePlus.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 +xiaonRF52840SensePlus.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1 \ No newline at end of file diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index ef27994a3..672bcbb35 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -52,7 +52,7 @@ static void loop_task(void* arg) TinyUSB_Device_Init(0); #endif -#if defined(ARDUINO_Seeed_XIAO_nRF52840) || defined(ARDUINO_Seeed_XIAO_nRF52840_Sense) +#if defined(ARDUINO_Seeed_XIAO_nRF52840) || defined(ARDUINO_Seeed_XIAO_nRF52840_Sense) || defined(ARDUINO_Seeed_XIAO_nRF52840_Plus) #if CFG_DEBUG // If Serial is not begin(), call it to avoid hard fault diff --git a/libraries/Wire/Wire_nRF52.cpp b/libraries/Wire/Wire_nRF52.cpp index 829404025..e7000ab83 100755 --- a/libraries/Wire/Wire_nRF52.cpp +++ b/libraries/Wire/Wire_nRF52.cpp @@ -29,7 +29,7 @@ extern "C" { #include "Wire.h" -#if defined(ARDUINO_Seeed_XIAO_nRF52840) || defined(ARDUINO_Seeed_XIAO_nRF52840_Sense) +#if defined(ARDUINO_Seeed_XIAO_nRF52840) || defined(ARDUINO_Seeed_XIAO_nRF52840_Sense) || defined(ARDUINO_Seeed_XIAO_nRF52840_Plus) #include // for Serial #elif defined(ARDUINO_WIO_TRACKER_1110) #else diff --git a/variants/Seeed_XIAO_nRF52840_Plus/variant.cpp b/variants/Seeed_XIAO_nRF52840_Plus/variant.cpp new file mode 100644 index 000000000..e8c62ecc6 --- /dev/null +++ b/variants/Seeed_XIAO_nRF52840_Plus/variant.cpp @@ -0,0 +1,82 @@ +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D10 + 2, // D0 is P0.02 (A0) + 3, // D1 is P0.03 (A1) + 28, // D2 is P0.28 (A2) + 29, // D3 is P0.29 (A3) + 4, // D4 is P0.04 (A4,SDA) + 5, // D5 is P0.05 (A5,SCL) + 43, // D6 is P1.11 (TX) + 44, // D7 is P1.12 (RX) + 45, // D8 is P1.13 (SCK) + 46, // D9 is P1.14 (MISO) + 47, // D10 is P1.15 (MOSI) + + // LEDs + 26, // D20 is P0.26 (LED RED) + 6, // D21 is P0.06 (LED BLUE) + 30, // D22 is P0.30 (LED GREEN) + 14, // D23 is P0.14 (READ_BAT) + + // LSM6DS3TR + 40, // D24 is P1.08 (6D_PWR) + 27, // D25 is P0.27 (6D_I2C_SCL) + 7, // D26 is P0.07 (6D_I2C_SDA) + 11, // D27 is P0.11 (6D_INT1) + + // MIC + 42, // D28 is P1.10 (MIC_PWR) + 32, // D29 is P1.00 (PDM_CLK) + 16, // D30 is P0.16 (PDM_DATA) + + // BQ25100 + 13, // D31 is P0.13 (HICHG) + 17, // D32 is P0.17 (~CHG) + + // + 21, // D33 is P0.21 (QSPI_SCK) + 25, // D34 is P0.25 (QSPI_CSN) + 20, // D35 is P0.20 (QSPI_SIO_0 DI) + 24, // D36 is P0.24 (QSPI_SIO_1 DO) + 22, // D37 is P0.22 (QSPI_SIO_2 WP) + 23, // D38 is P0.23 (QSPI_SIO_3 HOLD) + + // D11 ~ D20 + 15, // D11 is P0.15 (i2s_sd) + 19, // D12 is P0.19 (i2s_sck) + 33, // D13 is P1.1 (i2s_ws) + 9, // D15 is P0.09 (nfc1) + 10, // D16 is P0.10 (nfc2) + 31, // D18 is P0.31 (VBAT) + 39, // D19 is P1.07 (MOSI1) + 37, // D20 is P1.05 (MISO1) + 35, // D21 is P1.03 (SCK1) +}; + +void initVariant() +{ + // Disable reading of the BAT voltage. + // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging + pinMode(VBAT_ENABLE, OUTPUT); + digitalWrite(VBAT_ENABLE, HIGH); + + // Low charging current. + // https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current + pinMode(PIN_CHARGING_CURRENT, INPUT); + + pinMode(PIN_QSPI_CS, OUTPUT); + digitalWrite(PIN_QSPI_CS, HIGH); + + pinMode(LED_RED, OUTPUT); + digitalWrite(LED_RED, HIGH); + pinMode(LED_GREEN, OUTPUT); + digitalWrite(LED_GREEN, HIGH); + pinMode(LED_BLUE, OUTPUT); + digitalWrite(LED_BLUE, HIGH); +} diff --git a/variants/Seeed_XIAO_nRF52840_Plus/variant.h b/variants/Seeed_XIAO_nRF52840_Plus/variant.h new file mode 100644 index 000000000..359e80002 --- /dev/null +++ b/variants/Seeed_XIAO_nRF52840_Plus/variant.h @@ -0,0 +1,177 @@ +#ifndef _SEEED_XIAO_NRF52840_PLUS_H_ +#define _SEEED_XIAO_NRF52840_PLUS_H_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +//#define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +#define PINS_COUNT (39) +#define NUM_DIGITAL_PINS (39) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED (LED_RED) +#define LED_PWR (PINS_COUNT) +#define PIN_NEOPIXEL (PINS_COUNT) +#define NEOPIXEL_NUM (0) + +#define LED_BUILTIN (PIN_LED) + +#define LED_RED (11) +#define LED_GREEN (13) +#define LED_BLUE (12) + +#define LED_STATE_ON (1) // State when LED is litted + +// Buttons +#define PIN_BUTTON1 (PINS_COUNT) + +// Digital PINs +static const uint8_t D0 = 0 ; +static const uint8_t D1 = 1 ; +static const uint8_t D2 = 2 ; +static const uint8_t D3 = 3 ; +static const uint8_t D4 = 4 ; +static const uint8_t D5 = 5 ; +static const uint8_t D6 = 6 ; +static const uint8_t D7 = 7 ; +static const uint8_t D8 = 8 ; +static const uint8_t D9 = 9 ; +static const uint8_t D10 = 10; + +static const uint8_t D11 = 30; +static const uint8_t D12 = 31; +static const uint8_t D13 = 32; +static const uint8_t D14 = 33; +static const uint8_t D15 = 34; +static const uint8_t D16 = 35; +static const uint8_t D17 = 36; +static const uint8_t D18 = 37; +static const uint8_t D19 = 38; + +#define VBAT_ENABLE (14) // Output LOW to enable reading of the BAT voltage. + // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging + +#define PIN_CHARGING_CURRENT (22) // Battery Charging current + // https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current + +// Analog pins +#define PIN_A0 (0) +#define PIN_A1 (1) +#define PIN_A2 (2) +#define PIN_A3 (3) +#define PIN_A4 (4) +#define PIN_A5 (5) +#define PIN_VBAT (35) // Read the BAT voltage. + // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t ADC_BAT = PIN_VBAT; + +#define ADC_RESOLUTION (12) + +// Other pins +#define PIN_NFC1 (33) +#define PIN_NFC2 (34) + +// Serial interfaces +#define PIN_SERIAL1_RX (7) +#define PIN_SERIAL1_TX (6) + +static const uint8_t RX = PIN_SERIAL1_RX; +static const uint8_t TX = PIN_SERIAL1_TX; + +#define PIN_SERIAL2_RX (33) +#define PIN_SERIAL2_TX (34) + +static const uint8_t RX1 = PIN_SERIAL2_RX; +static const uint8_t TX1 = PIN_SERIAL2_TX; + +// SPI Interfaces +#define SPI_INTERFACES_COUNT (2) + +#define PIN_SPI_MISO (9) +#define PIN_SPI_MOSI (10) +#define PIN_SPI_SCK (8) + +static const uint8_t SS = 7; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK ; + +#define PIN_SPI1_MISO (37) +#define PIN_SPI1_MOSI (36) +#define PIN_SPI1_SCK (38) + +static const uint8_t MOSI1 = PIN_SPI1_MOSI; +static const uint8_t MISO1 = PIN_SPI1_MISO; +static const uint8_t SCK1 = PIN_SPI1_SCK ; + +// Wire Interfaces +#define WIRE_INTERFACES_COUNT (2) + +#define PIN_WIRE_SDA (4) +#define PIN_WIRE_SCL (5) + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +#define PIN_WIRE1_SDA (17) +#define PIN_WIRE1_SCL (16) +#define PIN_LSM6DS3TR_C_POWER (15) +#define PIN_LSM6DS3TR_C_INT1 (18) + +// i2s Interfaces +#define PIN_I2S_SCK (31) +#define PIN_I2S_SD (30) +#define PIN_I2S_WS (32) + +static const uint8_t I2S_SCK = PIN_I2S_SCK; +static const uint8_t I2S_SD = PIN_I2S_SD ; +static const uint8_t I2S_WS = PIN_I2S_WS ; + +// PDM Interfaces +#define PIN_PDM_PWR (19) +#define PIN_PDM_CLK (20) +#define PIN_PDM_DIN (21) + +// QSPI Pins +#define PIN_QSPI_SCK (24) +#define PIN_QSPI_CS (25) +#define PIN_QSPI_IO0 (26) +#define PIN_QSPI_IO1 (27) +#define PIN_QSPI_IO2 (28) +#define PIN_QSPI_IO3 (29) + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES (P25Q16H) +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif diff --git a/variants/Seeed_XIAO_nRF52840_Sense_Plus/variant.cpp b/variants/Seeed_XIAO_nRF52840_Sense_Plus/variant.cpp new file mode 100644 index 000000000..e8c62ecc6 --- /dev/null +++ b/variants/Seeed_XIAO_nRF52840_Sense_Plus/variant.cpp @@ -0,0 +1,82 @@ +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D10 + 2, // D0 is P0.02 (A0) + 3, // D1 is P0.03 (A1) + 28, // D2 is P0.28 (A2) + 29, // D3 is P0.29 (A3) + 4, // D4 is P0.04 (A4,SDA) + 5, // D5 is P0.05 (A5,SCL) + 43, // D6 is P1.11 (TX) + 44, // D7 is P1.12 (RX) + 45, // D8 is P1.13 (SCK) + 46, // D9 is P1.14 (MISO) + 47, // D10 is P1.15 (MOSI) + + // LEDs + 26, // D20 is P0.26 (LED RED) + 6, // D21 is P0.06 (LED BLUE) + 30, // D22 is P0.30 (LED GREEN) + 14, // D23 is P0.14 (READ_BAT) + + // LSM6DS3TR + 40, // D24 is P1.08 (6D_PWR) + 27, // D25 is P0.27 (6D_I2C_SCL) + 7, // D26 is P0.07 (6D_I2C_SDA) + 11, // D27 is P0.11 (6D_INT1) + + // MIC + 42, // D28 is P1.10 (MIC_PWR) + 32, // D29 is P1.00 (PDM_CLK) + 16, // D30 is P0.16 (PDM_DATA) + + // BQ25100 + 13, // D31 is P0.13 (HICHG) + 17, // D32 is P0.17 (~CHG) + + // + 21, // D33 is P0.21 (QSPI_SCK) + 25, // D34 is P0.25 (QSPI_CSN) + 20, // D35 is P0.20 (QSPI_SIO_0 DI) + 24, // D36 is P0.24 (QSPI_SIO_1 DO) + 22, // D37 is P0.22 (QSPI_SIO_2 WP) + 23, // D38 is P0.23 (QSPI_SIO_3 HOLD) + + // D11 ~ D20 + 15, // D11 is P0.15 (i2s_sd) + 19, // D12 is P0.19 (i2s_sck) + 33, // D13 is P1.1 (i2s_ws) + 9, // D15 is P0.09 (nfc1) + 10, // D16 is P0.10 (nfc2) + 31, // D18 is P0.31 (VBAT) + 39, // D19 is P1.07 (MOSI1) + 37, // D20 is P1.05 (MISO1) + 35, // D21 is P1.03 (SCK1) +}; + +void initVariant() +{ + // Disable reading of the BAT voltage. + // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging + pinMode(VBAT_ENABLE, OUTPUT); + digitalWrite(VBAT_ENABLE, HIGH); + + // Low charging current. + // https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current + pinMode(PIN_CHARGING_CURRENT, INPUT); + + pinMode(PIN_QSPI_CS, OUTPUT); + digitalWrite(PIN_QSPI_CS, HIGH); + + pinMode(LED_RED, OUTPUT); + digitalWrite(LED_RED, HIGH); + pinMode(LED_GREEN, OUTPUT); + digitalWrite(LED_GREEN, HIGH); + pinMode(LED_BLUE, OUTPUT); + digitalWrite(LED_BLUE, HIGH); +} diff --git a/variants/Seeed_XIAO_nRF52840_Sense_Plus/variant.h b/variants/Seeed_XIAO_nRF52840_Sense_Plus/variant.h new file mode 100644 index 000000000..14a839821 --- /dev/null +++ b/variants/Seeed_XIAO_nRF52840_Sense_Plus/variant.h @@ -0,0 +1,179 @@ +#ifndef _SEEED_XIAO_NRF52840_SENSE_PLUS_H_ +#define _SEEED_XIAO_NRF52840_SENSE_PLUS_H_ + +#define TARGET_SEEED_XIAO_NRF52840_SENSE_PLUS + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +//#define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +#define PINS_COUNT (39) +#define NUM_DIGITAL_PINS (39) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED (LED_RED) +#define LED_PWR (PINS_COUNT) +#define PIN_NEOPIXEL (PINS_COUNT) +#define NEOPIXEL_NUM (0) + +#define LED_BUILTIN (PIN_LED) + +#define LED_RED (11) +#define LED_GREEN (13) +#define LED_BLUE (12) + +#define LED_STATE_ON (1) // State when LED is litted + +// Buttons +#define PIN_BUTTON1 (PINS_COUNT) + +// Digital PINs +static const uint8_t D0 = 0 ; +static const uint8_t D1 = 1 ; +static const uint8_t D2 = 2 ; +static const uint8_t D3 = 3 ; +static const uint8_t D4 = 4 ; +static const uint8_t D5 = 5 ; +static const uint8_t D6 = 6 ; +static const uint8_t D7 = 7 ; +static const uint8_t D8 = 8 ; +static const uint8_t D9 = 9 ; +static const uint8_t D10 = 10; + +static const uint8_t D11 = 30; +static const uint8_t D12 = 31; +static const uint8_t D13 = 32; +static const uint8_t D14 = 33; +static const uint8_t D15 = 34; +static const uint8_t D16 = 35; +static const uint8_t D17 = 36; +static const uint8_t D18 = 37; +static const uint8_t D19 = 38; + +#define VBAT_ENABLE (14) // Output LOW to enable reading of the BAT voltage. + // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging + +#define PIN_CHARGING_CURRENT (22) // Battery Charging current + // https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current + +// Analog pins +#define PIN_A0 (0) +#define PIN_A1 (1) +#define PIN_A2 (2) +#define PIN_A3 (3) +#define PIN_A4 (4) +#define PIN_A5 (5) +#define PIN_VBAT (35) // Read the BAT voltage. + // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t ADC_BAT = PIN_VBAT; + +#define ADC_RESOLUTION (12) + +// Other pins +#define PIN_NFC1 (33) +#define PIN_NFC2 (34) + +// Serial interfaces +#define PIN_SERIAL1_RX (7) +#define PIN_SERIAL1_TX (6) + +static const uint8_t RX = PIN_SERIAL1_RX; +static const uint8_t TX = PIN_SERIAL1_TX; + +#define PIN_SERIAL2_RX (33) +#define PIN_SERIAL2_TX (34) + +static const uint8_t RX1 = PIN_SERIAL2_RX; +static const uint8_t TX1 = PIN_SERIAL2_TX; + +// SPI Interfaces +#define SPI_INTERFACES_COUNT (2) + +#define PIN_SPI_MISO (9) +#define PIN_SPI_MOSI (10) +#define PIN_SPI_SCK (8) + +static const uint8_t SS = 7; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK ; + +#define PIN_SPI1_MISO (37) +#define PIN_SPI1_MOSI (36) +#define PIN_SPI1_SCK (38) + +static const uint8_t MOSI1 = PIN_SPI1_MOSI; +static const uint8_t MISO1 = PIN_SPI1_MISO; +static const uint8_t SCK1 = PIN_SPI1_SCK ; + +// Wire Interfaces +#define WIRE_INTERFACES_COUNT (2) + +#define PIN_WIRE_SDA (4) +#define PIN_WIRE_SCL (5) + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +#define PIN_WIRE1_SDA (17) +#define PIN_WIRE1_SCL (16) +#define PIN_LSM6DS3TR_C_POWER (15) +#define PIN_LSM6DS3TR_C_INT1 (18) + +// i2s Interfaces +#define PIN_I2S_SCK (31) +#define PIN_I2S_SD (30) +#define PIN_I2S_WS (32) + +static const uint8_t I2S_SCK = PIN_I2S_SCK; +static const uint8_t I2S_SD = PIN_I2S_SD ; +static const uint8_t I2S_WS = PIN_I2S_WS ; + +// PDM Interfaces +#define PIN_PDM_PWR (19) +#define PIN_PDM_CLK (20) +#define PIN_PDM_DIN (21) + +// QSPI Pins +#define PIN_QSPI_SCK (24) +#define PIN_QSPI_CS (25) +#define PIN_QSPI_IO0 (26) +#define PIN_QSPI_IO1 (27) +#define PIN_QSPI_IO2 (28) +#define PIN_QSPI_IO3 (29) + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES (P25Q16H) +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif