Skip to content

Commit e682542

Browse files
authored
Merge pull request #327 from adafruit/cplay_nrf
Circuit Playground Bluefruit
2 parents 809ee6d + 2cf05fa commit e682542

File tree

7 files changed

+305
-13
lines changed

7 files changed

+305
-13
lines changed

boards.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,61 @@ feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
112112
feather52840.menu.debug.l3=Level 3 (Segger SystemView)
113113
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
114114

115+
116+
# ----------------------------------
117+
# Bluefruit Circuit Playground nRF52840 Express
118+
# ----------------------------------
119+
cplaynrf52840.name=Adafruit Circuit Playground Bluefruit
120+
121+
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
122+
cplaynrf52840.vid.0=0x239A
123+
cplaynrf52840.pid.0=0x8045
124+
cplaynrf52840.vid.1=0x239A
125+
cplaynrf52840.pid.1=0x0045
126+
cplaynrf52840.vid.2=0x239A
127+
cplaynrf52840.pid.2=0x0046
128+
cplaynrf52840.vid.3=0x239A
129+
cplaynrf52840.pid.3=0x8046
130+
131+
# Upload
132+
cplaynrf52840.bootloader.tool=bootburn
133+
cplaynrf52840.upload.tool=nrfutil
134+
cplaynrf52840.upload.protocol=nrfutil
135+
cplaynrf52840.upload.use_1200bps_touch=true
136+
cplaynrf52840.upload.wait_for_upload_port=true
137+
cplaynrf52840.upload.maximum_size=815104
138+
cplaynrf52840.upload.maximum_data_size=248832
139+
140+
# Build
141+
cplaynrf52840.build.mcu=cortex-m4
142+
cplaynrf52840.build.f_cpu=64000000
143+
cplaynrf52840.build.board=CIRCUITPLAY_NRF52840
144+
cplaynrf52840.build.core=nRF5
145+
cplaynrf52840.build.variant=circuitplayground_nrf52840
146+
cplaynrf52840.build.usb_manufacturer="Adafruit LLC"
147+
cplaynrf52840.build.usb_product="Adafruit Circuit Playground Bluefruit"
148+
cplaynrf52840.build.extra_flags=-DNRF52840_XXAA -DARDUINO_NRF52840_CIRCUITPLAY {build.flags.usb}
149+
cplaynrf52840.build.ldscript=nrf52840_s140_v6.ld
150+
cplaynrf52840.build.vid=0x239A
151+
cplaynrf52840.build.pid=0x8045
152+
153+
# SofDevice Menu
154+
cplaynrf52840.menu.softdevice.s140v6=0.2.11 SoftDevice s140 6.1.1
155+
cplaynrf52840.menu.softdevice.s140v6.build.sd_name=s140
156+
cplaynrf52840.menu.softdevice.s140v6.build.sd_version=6.1.1
157+
cplaynrf52840.menu.softdevice.s140v6.build.sd_fwid=0x00B6
158+
159+
# Debug Menu
160+
cplaynrf52840.menu.debug.l0=Level 0 (Release)
161+
cplaynrf52840.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
162+
cplaynrf52840.menu.debug.l1=Level 1 (Error Message)
163+
cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
164+
cplaynrf52840.menu.debug.l2=Level 2 (Full Debug)
165+
cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
166+
cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView)
167+
cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
168+
169+
115170
# ----------------------------------
116171
# Bluefruit Metro nRF52840 Express
117172
# ----------------------------------

libraries/Bluefruit52Lib/examples/Hardware/adc_vbat/adc_vbat.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <Arduino.h>
22

3+
#if defined ARDUINO_NRF52840_CIRCUITPLAY
4+
#define PIN_VBAT A8 // this is just a mock read, we'll use the light sensor, so we can run the test
5+
#endif
6+
37
uint32_t vbat_pin = PIN_VBAT; // A7 for feather nRF52832, A6 for nRF52840
48

59
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
@@ -77,4 +81,4 @@ void loop() {
7781
Serial.println("%)");
7882

7983
delay(1000);
80-
}
84+
}

libraries/Bluefruit52Lib/examples/Peripheral/ancs_oled/ancs_oled.ino

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@
3939
#define BUTTON_B 6
4040
#define BUTTON_C 5
4141

42+
#elif defined ARDUINO_NRF52840_CIRCUITPLAY
43+
// Circuit Playground nRF52840 - FYI doesnt work probably because of button polarity!
44+
#define BUTTON_A 4 // left button
45+
#define BUTTON_B 7 // center switch
46+
#define BUTTON_C 5 // right button
47+
4248
#else
4349
#error board not supported
4450
#endif
4551

46-
47-
#define OLED_RESET 4 // TODO remove ?
48-
Adafruit_SSD1306 oled(OLED_RESET);
49-
52+
Adafruit_SSD1306 oled(-1);
5053

5154
/*------------- Notification List -------------*/
5255
#define MAX_COUNT 20
@@ -453,4 +456,4 @@ uint32_t readPressedButtons(void)
453456
lastDebounced = debounced;
454457

455458
return result;
456-
}
459+
}

libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ BLEUart bleuart; // uart over ble
2626

2727
/* The Image Transfer module sends the image of your choice to Bluefruit LE over UART.
2828
* Each image sent begins with
29-
* - A single byte char “!” (0x21)
29+
* - A single byte char “!” (0x21)
3030
* - Image width (uint16 little endian, 2 bytes)
3131
* - Image height (uint16 little endian, 2 bytes)
3232
* - Pixel data encoded as RGB 24-bit and suffixed by a single byte CRC.
3333
*
34-
* Format: [ ‘!’ ] [ uint16 width ] [ uint16 height ] [ r g b ] [ r g b ] [ r g b ] … [ CRC ]
34+
* Format: [ ‘!’ ] [ uint16 width ] [ uint16 height ] [ r g b ] [ r g b ] [ r g b ] … [ CRC ]
3535
*/
3636

3737
uint16_t imageWidth = 0;
@@ -45,17 +45,19 @@ uint32_t rxLastTime = 0;
4545
#ifdef ARDUINO_NRF52832_FEATHER
4646
#define TFT_DC 11
4747
#define TFT_CS 31
48-
#define STMPE_CS 30
49-
#define SD_CS 27
5048
#endif
5149

5250
#ifdef ARDUINO_NRF52840_FEATHER
5351
#define TFT_DC 10
5452
#define TFT_CS 9
55-
#define STMPE_CS 6
56-
#define SD_CS 5
5753
#endif
5854

55+
#ifdef ARDUINO_NRF52840_CIRCUITPLAY
56+
#define TFT_DC A7
57+
#define TFT_CS A6
58+
#endif
59+
60+
5961
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
6062

6163
void setup()
@@ -199,4 +201,4 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
199201
tft.fillScreen(ILI9341_BLACK);
200202
tft.setCursor(0, 0);
201203
tft.println("Advertising ...");
202-
}
204+
}

tools/build_all.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ def build_examples(variant):
6565
subprocess.run("arduino --board adafruit:nrf52:feather52832:softdevice=s132v6,debug=l0 --save-prefs", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
6666
build_examples('feather52832')
6767

68+
print('\r\n')
69+
print(build_separator)
70+
print('| {:^73} |'.format('Circuit Playground Bluefruit Express'))
71+
print(build_separator)
72+
print((build_format + '| {:5} |').format('Library', 'Example', 'Result', 'Time'))
73+
print(build_separator)
74+
subprocess.run("arduino --board adafruit:nrf52:cplaynrf52840:softdevice=s140v6,debug=l0 --save-prefs", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
75+
build_examples('cplaynrf52840')
76+
77+
6878
print(build_separator)
6979
build_time = time.monotonic() - build_time
7080
print("Build Sumamary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, build_time))
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
Copyright (c) 2018, Adafruit Industries (adafruit.com)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
See the GNU Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
#include "variant.h"
22+
#include "wiring_constants.h"
23+
#include "wiring_digital.h"
24+
#include "nrf.h"
25+
26+
const uint32_t g_ADigitalPinMap[] =
27+
{
28+
// D0 .. D13
29+
30, // D0 is P0.30 (GPIO D0 / A6 / UART RX)
30+
14, // D1 is P0.14 (GPIO D1 / UART TX)
31+
5, // D2 is P0.05 (GPIO D2 / A5 / SDA)
32+
4, // D3 is P0.04 (GPIO D3 / A4 / SCL)
33+
34, // D4 is P1.02 (GPIO D4 / Left Button)
34+
47, // D5 is P1.15 (GPIO D5 / Right button)
35+
2, // D6 is P0.02 (GPIO D6 / A1)
36+
38, // D7 is P1.06 (GPIO D7 / Slide Switch)
37+
13, // D8 is P0.13 (GPIO D8 / NeoPixels)
38+
29, // D9 is P0.29 (GPIO D9 / A2)
39+
3, // D10 is P0.03 (GPIO D10 / A3)
40+
36, // D11 is P1.04 (GPIO D11 / Speaker Shutdown)
41+
26, // D12 is P0.26 (GPIO D12 / Audio Out)
42+
46, // D13 is P1.14 (GPIO D13 / Red LED)
43+
44+
// D14 .. D23
45+
26, // NOT REALLY ANALOG, A PLACEHODER SINCE D12 is not analog
46+
2, // D6 is P0.02 (GPIO D6 / A1)
47+
29, // D9 is P0.29 (GPIO D9 / A2)
48+
3, // D10 is P0.03 (GPIO D10 / A3)
49+
4, // D3 is P0.04 (GPIO D3 / A4 / SCL)
50+
5, // D2 is P0.05 (GPIO D2 / A5 / SDA)
51+
30, // D0 is P0.30 (GPIO D0 / A6 / UART RX)
52+
14, // NOT REALLY ANALOG, A PLACEHODER SINCE D1 is not analog
53+
28, // A8 - Light sensor
54+
31, // A9 - Thermistor sensor
55+
56+
45, // D24 is P1.13 (LIS IRQ)
57+
44, // D25 is P1.12 (LIS SCL)
58+
42, // D26 is P1.10 (LIS SDA)
59+
60+
// QSPI pins (not exposed via any header / test point)
61+
19, // D27 is P0.19 (QSPI CLK)
62+
15, // D28 is P0.15 (QSPI CS)
63+
21, // D29 is P0.21 (QSPI Data 0)
64+
23, // D30 is P0.23 (QSPI Data 1)
65+
32, // D31 is P1.00 (QSPI Data 2)
66+
22, // D32 is P0.22 (QSPI Data 3)
67+
68+
// D33 & D34 PDM pins
69+
16, // D33 is P0.16 (PDM DAT)
70+
17, // D34 is P0.17 (PDM CLK)
71+
72+
};
73+
74+
void initVariant()
75+
{
76+
// LED1
77+
pinMode(PIN_LED1, OUTPUT);
78+
ledOff(PIN_LED1);
79+
}
80+
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
3+
Copyright (c) 2016 Sandeep Mistry All right reserved.
4+
Copyright (c) 2018, Adafruit Industries (adafruit.com)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
See the GNU Lesser General Public License for more details.
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef _VARIANT_CIRCUITPLAY52840_
20+
#define _VARIANT_CIRCUITPLAY52840_
21+
22+
/** Master clock frequency */
23+
#define VARIANT_MCK (64000000ul)
24+
25+
//#define USE_LFXO // Board uses 32khz crystal for LF
26+
#define USE_LFRC // Board uses RC for LF
27+
28+
/*----------------------------------------------------------------------------
29+
* Headers
30+
*----------------------------------------------------------------------------*/
31+
32+
#include "WVariant.h"
33+
34+
#ifdef __cplusplus
35+
extern "C"
36+
{
37+
#endif // __cplusplus
38+
39+
// Number of pins defined in PinDescription array
40+
#define PINS_COUNT (35)
41+
#define NUM_DIGITAL_PINS (35)
42+
#define NUM_ANALOG_INPUTS (8)
43+
#define NUM_ANALOG_OUTPUTS (0)
44+
45+
// LEDs
46+
#define PIN_LED1 (13)
47+
#define PIN_NEOPIXEL (8)
48+
49+
#define LED_BUILTIN PIN_LED1
50+
51+
#define LED_RED PIN_LED1
52+
#define LED_BLUE PIN_LED1
53+
54+
#define LED_STATE_ON 1 // State when LED is litted
55+
56+
// Buttons
57+
58+
#define PIN_BUTTON1 (4)
59+
#define PIN_BUTTON2 (5)
60+
61+
/*
62+
* Analog pins
63+
*/
64+
#define PIN_A0 (14) // not really analog!
65+
#define PIN_A1 (15)
66+
#define PIN_A2 (16)
67+
#define PIN_A3 (17)
68+
#define PIN_A4 (18)
69+
#define PIN_A5 (19)
70+
#define PIN_A6 (20)
71+
#define PIN_A7 (21) // not really analog!
72+
#define PIN_A8 (22)
73+
#define PIN_A9 (23)
74+
75+
static const uint8_t A0 = PIN_A0 ;
76+
static const uint8_t A1 = PIN_A1 ;
77+
static const uint8_t A2 = PIN_A2 ;
78+
static const uint8_t A3 = PIN_A3 ;
79+
static const uint8_t A4 = PIN_A4 ;
80+
static const uint8_t A5 = PIN_A5 ;
81+
static const uint8_t A6 = PIN_A6 ;
82+
static const uint8_t A7 = PIN_A7 ;
83+
static const uint8_t A8 = PIN_A8 ;
84+
static const uint8_t A9 = PIN_A9 ;
85+
#define ADC_RESOLUTION 14
86+
87+
/*
88+
* Serial interfaces
89+
*/
90+
// Serial
91+
#define PIN_SERIAL_RX (0)
92+
#define PIN_SERIAL_TX (1)
93+
94+
/*
95+
* SPI Interfaces
96+
*/
97+
#define SPI_INTERFACES_COUNT 1
98+
99+
#define PIN_SPI_MISO (6)
100+
#define PIN_SPI_MOSI (9)
101+
#define PIN_SPI_SCK (10)
102+
103+
static const uint8_t SS = (5);
104+
static const uint8_t MOSI = PIN_SPI_MOSI ;
105+
static const uint8_t MISO = PIN_SPI_MISO ;
106+
static const uint8_t SCK = PIN_SPI_SCK ;
107+
108+
/*
109+
* Wire Interfaces
110+
*/
111+
#define WIRE_INTERFACES_COUNT 1
112+
113+
#define PIN_WIRE_SDA (26)
114+
#define PIN_WIRE_SCL (25)
115+
116+
// QSPI Pins
117+
#define PIN_QSPI_SCK 27
118+
#define PIN_QSPI_CS 28
119+
#define PIN_QSPI_IO0 29
120+
#define PIN_QSPI_IO1 30
121+
#define PIN_QSPI_IO2 31
122+
#define PIN_QSPI_IO3 32
123+
124+
// On-board QSPI Flash
125+
#define EXTERNAL_FLASH_DEVICES GD25Q16C
126+
127+
#define USB_MSC_BLOCK_SIZE 512
128+
#define USB_MSC_BLOCK_COUNT ((2*1024*1024) / USB_MSC_BLOCK_SIZE)
129+
130+
#ifdef __cplusplus
131+
}
132+
#endif
133+
134+
/*----------------------------------------------------------------------------
135+
* Arduino objects - C++ only
136+
*----------------------------------------------------------------------------*/
137+
138+
#endif

0 commit comments

Comments
 (0)