diff --git a/boards.txt b/boards.txt index 04d201db..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 # ---------------------------------- @@ -168,7 +223,7 @@ metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 # ---------------------------------- # Nordic nRF52840DK (PCA10056) # ---------------------------------- -pca10056.name=Noridc nRF52840DK (PCA10056) +pca10056.name=Nordic nRF52840DK (PCA10056) pca10056.bootloader.tool=bootburn # Upload diff --git a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h index 3979dcb1..24f290b6 100644 --- a/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h +++ b/cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h @@ -166,6 +166,8 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re // CDC Descriptor Template // Interface number, string index, EP notification address and size, EP data address (out, in) and size. +// NOTE: This returns an list of byte (uint_8) values +// NOTE: Unwritten & unverified assumption: _itfnum is in range [0..254] (else overflows below adding 1) #define TUD_CDC_DESCRIPTOR(_itfnum, _stridx, _ep_notif, _ep_notif_size, _epout, _epin, _epsize) \ /* Interface Associate */\ 8, TUSB_DESC_INTERFACE_ASSOCIATION, _itfnum, 2, TUSB_CLASS_CDC, CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, CDC_COMM_PROTOCOL_ATCOMMAND, 0,\ @@ -174,15 +176,15 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re /* CDC Header */\ 5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_HEADER, U16_TO_U8S_LE(0x0120),\ /* CDC Call */\ - 5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_CALL_MANAGEMENT, 0, (_itfnum) + 1,\ + 5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_CALL_MANAGEMENT, 0, (uint8_t)((_itfnum) + 1),\ /* CDC ACM: support line request */\ 4, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, 2,\ /* CDC Union */\ - 5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_UNION, _itfnum, (_itfnum) + 1,\ + 5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_UNION, _itfnum, (uint8_t)((_itfnum) + 1),\ /* Endpoint Notification */\ 7, TUSB_DESC_ENDPOINT, _ep_notif, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_notif_size), 16,\ /* CDC Data Interface */\ - 9, TUSB_DESC_INTERFACE, (_itfnum)+1, 0, 2, TUSB_CLASS_CDC_DATA, 0, 0, 0,\ + 9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), 0, 2, TUSB_CLASS_CDC_DATA, 0, 0, 0,\ /* Endpoint Out */\ 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\ /* Endpoint In */\ @@ -240,13 +242,15 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re // MIDI simple descriptor // - 1 Embedded Jack In connected to 1 External Jack Out // - 1 Embedded Jack out connected to 1 External Jack In +// NOTE: This returns an list of byte (uint_8) values +// NOTE: Unwritten & unverified assumption: _itfnum is in range [0..254] (else overflows below adding 1) #define TUD_MIDI_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \ /* Audio Control (AC) Interface */\ 9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_PROTOCOL_V1, _stridx,\ /* AC Header */\ - 9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, _itfnum+1,\ + 9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, (uint8_t)((_itfnum)+1),\ /* MIDI Streaming (MS) Interface */\ - 9, TUSB_DESC_INTERFACE, _itfnum+1, 0, 2, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_MIDI_STREAMING, AUDIO_PROTOCOL_V1, 0,\ + 9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), 0, 2, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_MIDI_STREAMING, AUDIO_PROTOCOL_V1, 0,\ /* MS Header */\ 7, TUSB_DESC_CS_INTERFACE, MIDI_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0025),\ /* MS In Jack (Embedded) */\ diff --git a/cores/nRF5/utility/debug.cpp b/cores/nRF5/utility/debug.cpp index 83a4c1ac..f94c277e 100644 --- a/cores/nRF5/utility/debug.cpp +++ b/cores/nRF5/utility/debug.cpp @@ -425,12 +425,13 @@ lookup_table_t const _strerr_table = const char* dbg_err_str(int32_t err_id) { + // TODO: verify it would be safe to change to int16_t const char * str = (const char *) lookup_find(&_strerr_table, err_id); static char unknown_str[7] = {0}; if ( str == NULL ) { - sprintf(unknown_str, "0x%04X", err_id); + sprintf(unknown_str, "0x%04lX", (uint32_t)err_id); str = unknown_str; } 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 f99f7fcc..e6f072d4 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; @@ -49,15 +49,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 -#else +#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() diff --git a/platform.txt b/platform.txt index 83fca997..a7d3913e 100644 --- a/platform.txt +++ b/platform.txt @@ -32,7 +32,7 @@ compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ compiler.c.cmd=arm-none-eabi-gcc compiler.c.flags=-mcpu={build.mcu} -mthumb -c -g {compiler.warning_flags} {build.float_flags} -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD compiler.c.elf.cmd=arm-none-eabi-gcc -compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps +compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps compiler.S.cmd=arm-none-eabi-gcc compiler.S.flags=-c -g -x assembler-with-cpp compiler.cpp.cmd=arm-none-eabi-g++ @@ -59,7 +59,7 @@ nordic.path={build.core.path}/nordic # ARDUINO_FEATHER52 is defined for backward compatiable with other lib only # should be replaced by ARDUINO_NRF52_ADAFRUIT in the future -build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Os {build.debug_flags} "-I{build.core.path}/cmsis/include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/Adafruit_TinyUSB_Core" "-I{build.core.path}/Adafruit_TinyUSB_Core/tinyusb/src" +build.flags.nrf= -DSOFTDEVICE_PRESENT -DARDUINO_FEATHER52 -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DLFS_NAME_MAX=64 -Ofast {build.debug_flags} "-I{build.core.path}/cmsis/include" "-I{nordic.path}" "-I{nordic.path}/nrfx" "-I{nordic.path}/nrfx/hal" "-I{nordic.path}/nrfx/mdk" "-I{nordic.path}/nrfx/soc" "-I{nordic.path}/nrfx/drivers/include" "-I{nordic.path}/nrfx/drivers/src" "-I{nordic.path}/softdevice/{build.sd_name}_nrf52_{build.sd_version}_API/include" "-I{rtos.path}/Source/include" "-I{rtos.path}/config" "-I{rtos.path}/portable/GCC/nrf52" "-I{rtos.path}/portable/CMSIS/nrf52" "-I{build.core.path}/sysview/SEGGER" "-I{build.core.path}/sysview/Config" "-I{build.core.path}/Adafruit_TinyUSB_Core" "-I{build.core.path}/Adafruit_TinyUSB_Core/tinyusb/src" # usb flags build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' 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