Skip to content

Commit dddb437

Browse files
committed
Merge branch 'master' into develop
libraries/Bluefruit52Lib/examples/Peripheral/image_upload/image_upload.ino
2 parents aa55beb + 8628008 commit dddb437

File tree

10 files changed

+321
-22
lines changed

10 files changed

+321
-22
lines changed

boards.txt

Lines changed: 56 additions & 1 deletion
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
# ----------------------------------
@@ -168,7 +223,7 @@ metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
168223
# ----------------------------------
169224
# Nordic nRF52840DK (PCA10056)
170225
# ----------------------------------
171-
pca10056.name=Noridc nRF52840DK (PCA10056)
226+
pca10056.name=Nordic nRF52840DK (PCA10056)
172227
pca10056.bootloader.tool=bootburn
173228

174229
# Upload

cores/nRF5/Adafruit_TinyUSB_Core/tinyusb/src/device/usbd.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
166166

167167
// CDC Descriptor Template
168168
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
169+
// NOTE: This returns an list of byte (uint_8) values
170+
// NOTE: Unwritten & unverified assumption: _itfnum is in range [0..254] (else overflows below adding 1)
169171
#define TUD_CDC_DESCRIPTOR(_itfnum, _stridx, _ep_notif, _ep_notif_size, _epout, _epin, _epsize) \
170172
/* Interface Associate */\
171173
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
174176
/* CDC Header */\
175177
5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_HEADER, U16_TO_U8S_LE(0x0120),\
176178
/* CDC Call */\
177-
5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_CALL_MANAGEMENT, 0, (_itfnum) + 1,\
179+
5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_CALL_MANAGEMENT, 0, (uint8_t)((_itfnum) + 1),\
178180
/* CDC ACM: support line request */\
179181
4, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, 2,\
180182
/* CDC Union */\
181-
5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_UNION, _itfnum, (_itfnum) + 1,\
183+
5, TUSB_DESC_CS_INTERFACE, CDC_FUNC_DESC_UNION, _itfnum, (uint8_t)((_itfnum) + 1),\
182184
/* Endpoint Notification */\
183185
7, TUSB_DESC_ENDPOINT, _ep_notif, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_notif_size), 16,\
184186
/* CDC Data Interface */\
185-
9, TUSB_DESC_INTERFACE, (_itfnum)+1, 0, 2, TUSB_CLASS_CDC_DATA, 0, 0, 0,\
187+
9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), 0, 2, TUSB_CLASS_CDC_DATA, 0, 0, 0,\
186188
/* Endpoint Out */\
187189
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\
188190
/* Endpoint In */\
@@ -240,13 +242,15 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
240242
// MIDI simple descriptor
241243
// - 1 Embedded Jack In connected to 1 External Jack Out
242244
// - 1 Embedded Jack out connected to 1 External Jack In
245+
// NOTE: This returns an list of byte (uint_8) values
246+
// NOTE: Unwritten & unverified assumption: _itfnum is in range [0..254] (else overflows below adding 1)
243247
#define TUD_MIDI_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \
244248
/* Audio Control (AC) Interface */\
245249
9, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_CONTROL, AUDIO_PROTOCOL_V1, _stridx,\
246250
/* AC Header */\
247-
9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, _itfnum+1,\
251+
9, TUSB_DESC_CS_INTERFACE, AUDIO_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0009), 1, (uint8_t)((_itfnum)+1),\
248252
/* MIDI Streaming (MS) Interface */\
249-
9, TUSB_DESC_INTERFACE, _itfnum+1, 0, 2, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_MIDI_STREAMING, AUDIO_PROTOCOL_V1, 0,\
253+
9, TUSB_DESC_INTERFACE, (uint8_t)((_itfnum)+1), 0, 2, TUSB_CLASS_AUDIO, AUDIO_SUBCLASS_MIDI_STREAMING, AUDIO_PROTOCOL_V1, 0,\
250254
/* MS Header */\
251255
7, TUSB_DESC_CS_INTERFACE, MIDI_CS_INTERFACE_HEADER, U16_TO_U8S_LE(0x0100), U16_TO_U8S_LE(0x0025),\
252256
/* MS In Jack (Embedded) */\

cores/nRF5/utility/debug.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,13 @@ lookup_table_t const _strerr_table =
425425

426426
const char* dbg_err_str(int32_t err_id)
427427
{
428+
// TODO: verify it would be safe to change to int16_t
428429
const char * str = (const char *) lookup_find(&_strerr_table, err_id);
429430
static char unknown_str[7] = {0};
430431

431432
if ( str == NULL )
432433
{
433-
sprintf(unknown_str, "0x%04X", err_id);
434+
sprintf(unknown_str, "0x%04lX", (uint32_t)err_id);
434435
str = unknown_str;
435436
}
436437

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: 11 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;
@@ -49,15 +49,19 @@ uint32_t rxLastTime = 0;
4949
#ifdef ARDUINO_NRF52832_FEATHER
5050
#define TFT_DC 11
5151
#define TFT_CS 31
52-
#define STMPE_CS 30
53-
#define SD_CS 27
54-
#else
52+
#endif
53+
54+
#ifdef ARDUINO_NRF52840_FEATHER
5555
#define TFT_DC 10
5656
#define TFT_CS 9
57-
#define STMPE_CS 6
58-
#define SD_CS 5
5957
#endif
6058

59+
#ifdef ARDUINO_NRF52840_CIRCUITPLAY
60+
#define TFT_DC A7
61+
#define TFT_CS A6
62+
#endif
63+
64+
6165
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
6266

6367
void setup()

platform.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
3232
compiler.c.cmd=arm-none-eabi-gcc
3333
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
3434
compiler.c.elf.cmd=arm-none-eabi-gcc
35-
compiler.c.elf.flags=-Os -Wl,--gc-sections -save-temps
35+
compiler.c.elf.flags=-Ofast -Wl,--gc-sections -save-temps
3636
compiler.S.cmd=arm-none-eabi-gcc
3737
compiler.S.flags=-c -g -x assembler-with-cpp
3838
compiler.cpp.cmd=arm-none-eabi-g++
@@ -59,7 +59,7 @@ nordic.path={build.core.path}/nordic
5959
# ARDUINO_FEATHER52 is defined for backward compatiable with other lib only
6060
# should be replaced by ARDUINO_NRF52_ADAFRUIT in the future
6161

62-
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"
62+
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"
6363

6464
# usb flags
6565
build.flags.usb= -DUSBCON -DUSE_TINYUSB -DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'

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+

0 commit comments

Comments
 (0)