From dda829c85f1d80fb4e36bd5cdc6f840ee14b74e2 Mon Sep 17 00:00:00 2001 From: ladyada Date: Fri, 14 Jun 2019 22:56:02 -0400 Subject: [PATCH] draft 1 --- .../circuitplayground_nrf52840/variant.cpp | 80 ++++++++++ variants/circuitplayground_nrf52840/variant.h | 137 ++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 variants/circuitplayground_nrf52840/variant.cpp create mode 100644 variants/circuitplayground_nrf52840/variant.h diff --git a/variants/circuitplayground_nrf52840/variant.cpp b/variants/circuitplayground_nrf52840/variant.cpp new file mode 100644 index 00000000..d1f25488 --- /dev/null +++ b/variants/circuitplayground_nrf52840/variant.cpp @@ -0,0 +1,80 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 .. D13 + 29, // D0 is P0.29 (GPIO D0 / A6 / UART RX) + 14, // D1 is P0.14 (GPIO D1 / UART TX) + 4, // D2 is P0.04 (GPIO D2 / A5 / SDA) + 5, // D3 is P0.05 (GPIO D3 / A4 / SCL) + 33, // D4 is P1.01 (GPIO D4 / Left Button) + 47, // D5 is P1.15 (GPIO D5 / Right button) + 3, // D6 is P0.03 (GPIO D6 / A1) + 34, // D7 is P1.02 (GPIO D7 / Slide Switch) + 13, // D8 is P0.13 (GPIO D8 / NeoPixels) + 2, // D9 is P0.02 (GPIO D9 / A2) + 28, // D10 is P0.28 (GPIO D10 / A3) + 35, // D11 is P1.03 (GPIO D11 / Speaker Shutdown) + 26, // D12 is P0.26 (GPIO D12 / Audio Out) + 46, // D13 is P1.14 (GPIO D13 / Red LED) + + // D14 .. D23 + 26, // NOT REALLY ANALOG, A PLACEHODER SINCE D12 is not analog + 3, // D6 is P0.03 (GPIO D6 / A1) + 2, // D9 is P0.02 (GPIO D9 / A2) + 28, // D10 is P0.28 (GPIO D10 / A3) + 5, // D3 is P0.05 (GPIO D3 / A4 / SCL) + 4, // D2 is P0.04 (GPIO D2 / A5 / SDA) + 29, // D0 is P0.29 (GPIO D0 / A6 / UART RX) + 14, // NOT REALLY ANALOG, A PLACEHODER SINCE D1 is not analog + 31, // A8 - Light sensor + 30, // A9 - Thermistor sensor + + 45, // D24 is P1.13 (LIS IRQ) + 44, // D25 is P1.12 (LIS SCL) + 43, // D26 is P1.11 (LIS SDA) + + // QSPI pins (not exposed via any header / test point) + 19, // D27 is P0.19 (QSPI CLK) + 15, // D28 is P0.15 (QSPI CS) + 21, // D29 is P0.21 (QSPI Data 0) + 23, // D30 is P0.23 (QSPI Data 1) + 32, // D31 is P1.00 (QSPI Data 2) + 22, // D32 is P0.22 (QSPI Data 3) + + // D33 & D34 PDM pins + 24, // D33 is P0.24 (PDM CLK) + 25, // D34 is P0.25 (PDM DAT) + +}; + +void initVariant() +{ + // LED1 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); +} + diff --git a/variants/circuitplayground_nrf52840/variant.h b/variants/circuitplayground_nrf52840/variant.h new file mode 100644 index 00000000..2023406d --- /dev/null +++ b/variants/circuitplayground_nrf52840/variant.h @@ -0,0 +1,137 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_CIRCUITPLAY52840_ +#define _VARIANT_CIRCUITPLAY52840_ + +/** 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 + +// Number of pins defined in PinDescription array +#define PINS_COUNT (35) +#define NUM_DIGITAL_PINS (35) +#define NUM_ANALOG_INPUTS (8) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (13) +#define PIN_NEOPIXEL (8) + +#define LED_BUILTIN PIN_LED1 + +#define LED_RED PIN_LED1 + +#define LED_STATE_ON 1 // State when LED is litted + +// Buttons + +#define PIN_BUTTON1 (4) +#define PIN_BUTTON2 (5) + +/* + * Analog pins + */ +#define PIN_A0 (14) // not really analog! +#define PIN_A1 (15) +#define PIN_A2 (16) +#define PIN_A3 (17) +#define PIN_A4 (18) +#define PIN_A5 (19) +#define PIN_A6 (20) +#define PIN_A7 (21) // not really analog! +#define PIN_A8 (22) +#define PIN_A9 (23) + +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 A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +static const uint8_t A8 = PIN_A8 ; +static const uint8_t A9 = PIN_A9 ; +#define ADC_RESOLUTION 14 + +/* + * Serial interfaces + */ +// Serial +#define PIN_SERIAL_RX (1) +#define PIN_SERIAL_TX (0) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (6) +#define PIN_SPI_MOSI (9) +#define PIN_SPI_SCK (10) + +static const uint8_t SS = (5); +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (2) +#define PIN_WIRE_SCL (3) + +// QSPI Pins +#define PIN_QSPI_SCK 27 +#define PIN_QSPI_CS 28 +#define PIN_QSPI_IO0 29 +#define PIN_QSPI_IO1 30 +#define PIN_QSPI_IO2 31 +#define PIN_QSPI_IO3 32 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES GD25Q16C + +#define USB_MSC_BLOCK_SIZE 512 +#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif