diff --git a/boards.txt b/boards.txt index d7c94640..1d95d658 100644 --- a/boards.txt +++ b/boards.txt @@ -112,6 +112,61 @@ feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 feather52840.menu.debug.l3=Level 3 (Segger SystemView) feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 + +# ---------------------------------- +# Bluefruit Circuit Playground nRF52840 Express +# ---------------------------------- +cplaynrf52840.name=Adafruit Circuit Playground Bluefruit + +# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App +cplaynrf52840.vid.0=0x239A +cplaynrf52840.pid.0=0x8045 +cplaynrf52840.vid.1=0x239A +cplaynrf52840.pid.1=0x0045 +cplaynrf52840.vid.2=0x239A +cplaynrf52840.pid.2=0x0046 +cplaynrf52840.vid.3=0x239A +cplaynrf52840.pid.3=0x8046 + +# Upload +cplaynrf52840.bootloader.tool=bootburn +cplaynrf52840.upload.tool=nrfutil +cplaynrf52840.upload.protocol=nrfutil +cplaynrf52840.upload.use_1200bps_touch=true +cplaynrf52840.upload.wait_for_upload_port=true +cplaynrf52840.upload.maximum_size=815104 +cplaynrf52840.upload.maximum_data_size=248832 + +# Build +cplaynrf52840.build.mcu=cortex-m4 +cplaynrf52840.build.f_cpu=64000000 +cplaynrf52840.build.board=CIRCUITPLAY_NRF52840 +cplaynrf52840.build.core=nRF5 +cplaynrf52840.build.variant=circuitplayground_nrf52840 +cplaynrf52840.build.usb_manufacturer="Adafruit LLC" +cplaynrf52840.build.usb_product="Adafruit Circuit Playground Bluefruit" +cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52840_CIRCUITPLAY {build.flags.usb} +cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld +cplaynrf52840.build.vid=0x239A +cplaynrf52840.build.pid=0x8045 + +# SofDevice Menu +cplaynrf52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140 +cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1 +cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6 + +# Debug Menu +cplaynrf52840.menu.debug.l0=Level 0 (Release) +cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0 +cplaynrf52840.menu.debug.l1=Level 1 (Error Message) +cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1 +cplaynrf52840.menu.debug.l2=Level 2 (Full Debug) +cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2 +cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView) +cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 + + # ---------------------------------- # Bluefruit Metro nRF52840 Express # ---------------------------------- diff --git a/libraries/Bluefruit52Lib/examples/Hardware/adc_vbat/adc_vbat.ino b/libraries/Bluefruit52Lib/examples/Hardware/adc_vbat/adc_vbat.ino index fb457598..86f59b3b 100644 --- a/libraries/Bluefruit52Lib/examples/Hardware/adc_vbat/adc_vbat.ino +++ b/libraries/Bluefruit52Lib/examples/Hardware/adc_vbat/adc_vbat.ino @@ -1,5 +1,9 @@ #include +#if defined ARDUINO_NRF52840_CIRCUITPLAY +#define PIN_VBAT A8 // this is just a mock read, we'll use the light sensor, so we can run the test +#endif + uint32_t vbat_pin = PIN_VBAT; // A7 for feather nRF52832, A6 for nRF52840 #define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 @@ -77,4 +81,4 @@ void loop() { Serial.println("%)"); delay(1000); -} +} \ No newline at end of file diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino b/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino index 10ee98ca..ea87f105 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino @@ -39,14 +39,17 @@ #define BUTTON_B 6 #define BUTTON_C 5 +#elif defined ARDUINO_NRF52840_CIRCUITPLAY +// Circuit Playground nRF52840 - FYI doesnt work probably because of button polarity! +#define BUTTON_A 4 // left button +#define BUTTON_B 7 // center switch +#define BUTTON_C 5 // right button + #else #error board not supported #endif - -#define OLED_RESET 4 // TODO remove ? -Adafruit_SSD1306 oled(OLED_RESET); - +Adafruit_SSD1306 oled(-1); /*------------- Notification List -------------*/ #define MAX_COUNT 20 @@ -453,4 +456,4 @@ uint32_t readPressedButtons(void) lastDebounced = debounced; return result; -} +} \ No newline at end of file diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino b/libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino index 3ccb0c74..db26cafa 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino @@ -26,12 +26,12 @@ BLEUart bleuart; // uart over ble /* The Image Transfer module sends the image of your choice to Bluefruit LE over UART. * Each image sent begins with - * - A single byte char “!â€� (0x21) + * - A single byte char “!” (0x21) * - Image width (uint16 little endian, 2 bytes) * - Image height (uint16 little endian, 2 bytes) * - Pixel data encoded as RGB 24-bit and suffixed by a single byte CRC. * - * Format: [ ‘!’ ] [ uint16 width ] [ uint16 height ] [ r g b ] [ r g b ] [ r g b ] … [ CRC ] + * Format: [ ‘!’ ] [ uint16 width ] [ uint16 height ] [ r g b ] [ r g b ] [ r g b ] … [ CRC ] */ uint16_t imageWidth = 0; @@ -45,17 +45,19 @@ uint32_t rxLastTime = 0; #ifdef ARDUINO_NRF52832_FEATHER #define TFT_DC 11 #define TFT_CS 31 - #define STMPE_CS 30 - #define SD_CS 27 #endif #ifdef ARDUINO_NRF52840_FEATHER #define TFT_DC 10 #define TFT_CS 9 - #define STMPE_CS 6 - #define SD_CS 5 #endif +#ifdef ARDUINO_NRF52840_CIRCUITPLAY + #define TFT_DC A7 + #define TFT_CS A6 +#endif + + Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); void setup() @@ -199,4 +201,4 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason) tft.fillScreen(ILI9341_BLACK); tft.setCursor(0, 0); tft.println("Advertising ..."); -} +} \ No newline at end of file diff --git a/tools/build_all.py b/tools/build_all.py index 64725e3f..010a2358 100644 --- a/tools/build_all.py +++ b/tools/build_all.py @@ -65,6 +65,16 @@ print(build_separator) subprocess.run("arduino --board adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 --save-prefs", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) build_examples('feather52832') +print('\r\n') +print(build_separator) +print('| {:^73} |'.format('Circuit Playground Bluefruit Express')) +print(build_separator) +print((build_format + '| {:5} |').format('Library', 'Example', 'Result', 'Time')) +print(build_separator) +subprocess.run("arduino --board adafruit:nrf52:cplaynrf52840:softdevice=s140v6,debug=l0 --save-prefs", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) +build_examples('cplaynrf52840') + + print(build_separator) build_time = time.monotonic() - build_time print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, build_time)) diff --git a/variants/circuitplayground_nrf52840/variant.cpp b/variants/circuitplayground_nrf52840/variant.cpp new file mode 100644 index 00000000..8e5bb9fd --- /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 + 30, // D0 is P0.30 (GPIO D0 / A6 / UART RX) + 14, // D1 is P0.14 (GPIO D1 / UART TX) + 5, // D2 is P0.05 (GPIO D2 / A5 / SDA) + 4, // D3 is P0.04 (GPIO D3 / A4 / SCL) + 34, // D4 is P1.02 (GPIO D4 / Left Button) + 47, // D5 is P1.15 (GPIO D5 / Right button) + 2, // D6 is P0.02 (GPIO D6 / A1) + 38, // D7 is P1.06 (GPIO D7 / Slide Switch) + 13, // D8 is P0.13 (GPIO D8 / NeoPixels) + 29, // D9 is P0.29 (GPIO D9 / A2) + 3, // D10 is P0.03 (GPIO D10 / A3) + 36, // D11 is P1.04 (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 + 2, // D6 is P0.02 (GPIO D6 / A1) + 29, // D9 is P0.29 (GPIO D9 / A2) + 3, // D10 is P0.03 (GPIO D10 / A3) + 4, // D3 is P0.04 (GPIO D3 / A4 / SCL) + 5, // D2 is P0.05 (GPIO D2 / A5 / SDA) + 30, // D0 is P0.30 (GPIO D0 / A6 / UART RX) + 14, // NOT REALLY ANALOG, A PLACEHODER SINCE D1 is not analog + 28, // A8 - Light sensor + 31, // A9 - Thermistor sensor + + 45, // D24 is P1.13 (LIS IRQ) + 44, // D25 is P1.12 (LIS SCL) + 42, // D26 is P1.10 (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 + 16, // D33 is P0.16 (PDM DAT) + 17, // D34 is P0.17 (PDM CLK) + +}; + +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..7fe008fe --- /dev/null +++ b/variants/circuitplayground_nrf52840/variant.h @@ -0,0 +1,138 @@ + /* + 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_BLUE 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 (0) +#define PIN_SERIAL_TX (1) + +/* + * 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 (26) +#define PIN_WIRE_SCL (25) + +// 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