Skip to content

Commit 62d5bd6

Browse files
committed
Adding S340 to nrf52840 Feather BSP
* Adding readme to s340 dir * Create and update nrf52840_s340_v6.ld from nrf52840_s140_v6.ld * Update bluefruit.cpp to be better behaving citizen in multiprotocol setup, e.g. for S340 SoftDevice ** Handling alternative sd_softdevice_enable() call depending on the presence of ANT license key, while preserving bwd compat. ** Addig optional taskhandler and a semaphore for ANT+ task * Update .gitignore ** Ignoring s340 binaries, since they are not allowed to be distributed. * See http://orrmany.hu/wiki/doku.php?id=s340:arduino_ide_integration_for_the_nrf52840_feather_express_with_s340
1 parent 2a34e2a commit 62d5bd6

File tree

6 files changed

+136
-4
lines changed

6 files changed

+136
-4
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
# Ignore local overrides of platform.txt and boards.txt,
2121
/boards.local.txt
2222
/platform.local.txt
23+
24+
# Ignore S340 SoftDevice due to license restrictions
25+
bootloader/feather_nrf52840_express/feather_nrf52840_express_bootloader-*s340*
26+
cores/nRF5/nordic/softdevice/s340_nrf52_6.1.1_API/*

boards.txt

+54
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,60 @@ feather52840.menu.debug.l3=Level 3 (Segger SystemView)
116116
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
117117
feather52840.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1
118118

119+
# ----------------------------------
120+
# Bluefruit Feather nRF52840 Express s340
121+
# ----------------------------------
122+
feather52840_s340.name=Adafruit Bluefruit Feather nRF52840 Express S340
123+
124+
# VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
125+
feather52840_s340.vid.0=0x239A
126+
feather52840_s340.pid.0=0x8029
127+
feather52840_s340.vid.1=0x239A
128+
feather52840_s340.pid.1=0x0029
129+
feather52840_s340.vid.2=0x239A
130+
feather52840_s340.pid.2=0x002A
131+
feather52840_s340.vid.3=0x239A
132+
feather52840_s340.pid.3=0x802A
133+
134+
# Upload
135+
feather52840_s340.bootloader.tool=bootburn
136+
feather52840_s340.upload.tool=nrfutil
137+
feather52840_s340.upload.protocol=nrfutil
138+
feather52840_s340.upload.use_1200bps_touch=true
139+
feather52840_s340.upload.wait_for_upload_port=true
140+
feather52840_s340.upload.maximum_size=815104
141+
feather52840_s340.upload.maximum_data_size=237568
142+
#TODO: fix sizes above
143+
144+
# Build
145+
feather52840_s340.build.mcu=cortex-m4
146+
feather52840_s340.build.f_cpu=64000000
147+
feather52840_s340.build.board=NRF52840_FEATHER
148+
feather52840_s340.build.core=nRF5
149+
feather52840_s340.build.variant=feather_nrf52840_express
150+
feather52840_s340.build.usb_manufacturer="Adafruit LLC"
151+
feather52840_s340.build.usb_product="Feather nRF52840 Express"
152+
feather52840_s340.build.extra_flags=-DNRF52840_XXAA {build.flags.usb}
153+
feather52840_s340.build.ldscript=nrf52840_s340_v6.ld
154+
feather52840_s340.build.vid=0x239A
155+
feather52840_s340.build.pid=0x8029
156+
157+
# SofDevice Menu
158+
feather52840_s340.menu.softdevice.s340v6=0.3.0 SoftDevice s340 6.1.1
159+
feather52840_s340.menu.softdevice.s340v6.build.sd_name=s340
160+
feather52840_s340.menu.softdevice.s340v6.build.sd_version=6.1.1
161+
feather52840_s340.menu.softdevice.s340v6.build.sd_fwid=0x00B9
162+
163+
# Debug Menu
164+
feather52840_s340.menu.debug.l0=Level 0 (Release)
165+
feather52840_s340.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0
166+
feather52840_s340.menu.debug.l1=Level 1 (Error Message)
167+
feather52840_s340.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
168+
feather52840_s340.menu.debug.l2=Level 2 (Full Debug)
169+
feather52840_s340.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
170+
feather52840_s340.menu.debug.l3=Level 3 (Segger SystemView)
171+
feather52840_s340.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
172+
119173

120174
# ----------------------------------
121175
# Feather nRF52840 sense

cores/nRF5/linker/nrf52840_s340_v6.ld

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Linker script to configure memory regions. */
2+
3+
SEARCH_DIR(.)
4+
GROUP(-lgcc -lc -lnosys)
5+
6+
MEMORY
7+
{
8+
FLASH (rx) : ORIGIN = 0x31000, LENGTH = 0xF4000 - 0x31000
9+
10+
/* SRAM required by S132 depend on
11+
* - Attribute Table Size (Number of Services and Characteristics)
12+
* - Vendor UUID count
13+
* - Max ATT MTU
14+
* - Concurrent connection peripheral + central + secure links
15+
* - Event Len, HVN queue, Write CMD queue
16+
*/
17+
/*RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000*/
18+
RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
19+
}
20+
21+
SECTIONS
22+
{
23+
. = ALIGN(4);
24+
.svc_data :
25+
{
26+
PROVIDE(__start_svc_data = .);
27+
KEEP(*(.svc_data))
28+
PROVIDE(__stop_svc_data = .);
29+
} > RAM
30+
31+
.fs_data :
32+
{
33+
PROVIDE(__start_fs_data = .);
34+
KEEP(*(.fs_data))
35+
PROVIDE(__stop_fs_data = .);
36+
} > RAM
37+
} INSERT AFTER .data;
38+
39+
INCLUDE "nrf52_common.ld"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
This directory needs to store the v6.1.1 version of the BLE+ANT combinded S340 softdevice headers
2+
The way you can get that is described here: https://www.nordicsemi.com/Software-and-tools/Software/S340-ANT
3+
4+
IMPORTANT: You should put the S340 library headers under: s340_nrf52_6.1.1_API
5+
6+
That is, your library tree should look like this:
7+
8+
s340_nrf52_6.1.1_API
9+
└── include
10+
├── ant_error.h
11+
├── ant_interface.h
12+
├── ant_parameters.h
13+
├── ble.h
14+
├── ble_err.h
15+
├── ble_gap.h
16+
├── ble_gatt.h
17+
├── ble_gattc.h
18+
├── ble_gatts.h
19+
├── ble_hci.h
20+
├── ble_l2cap.h
21+
├── ble_ranges.h
22+
├── ble_types.h
23+
├── nrf52
24+
│   └── nrf_mbr.h
25+
├── nrf_error.h
26+
├── nrf_error_sdm.h
27+
├── nrf_error_soc.h
28+
├── nrf_nvic.h
29+
├── nrf_sd_def.h
30+
├── nrf_sdm.h
31+
├── nrf_soc.h
32+
└── nrf_svc.h

libraries/Bluefruit52Lib/src/bluefruit.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,15 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
312312
#error Clock Source is not configured, define USE_LFXO or USE_LFRC according to your board in variant.h
313313
#endif
314314

315-
// Enable SoftDevice
315+
/*------------------------------------------------------------------*/
316+
// BLE only Softdevices have 2-args sd_softdevice_enable()
317+
// BLE & ANT+ Softdevices have 3-args sd_softdevice_enable()
318+
/*------------------------------------------------------------------*/
316319
#ifdef ANT_LICENSE_KEY
317320
VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb, ANT_LICENSE_KEY), false );
318-
#else
321+
#else //#ifdef ANT_LICENSE_KEY
319322
VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb), false );
320-
#endif
323+
#endif //#ifdef ANT_LICENSE_KEY
321324

322325
#ifdef USE_TINYUSB
323326
usb_softdevice_post_enable();
@@ -658,7 +661,6 @@ extern "C" void SD_EVT_IRQHandler(void)
658661
// Notify both BLE & SOC & MultiProtocol (if any) Task
659662
xSemaphoreGiveFromISR(Bluefruit._soc_event_sem, NULL);
660663
xSemaphoreGiveFromISR(Bluefruit._ble_event_sem, NULL);
661-
662664
#ifdef ANT_LICENSE_KEY
663665
if (Bluefruit._mprot_event_sem) xSemaphoreGiveFromISR(Bluefruit._mprot_event_sem, NULL);
664666
#endif

libraries/Bluefruit52Lib/src/bluefruit.h

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class AdafruitBluefruit
225225

226226
SemaphoreHandle_t _ble_event_sem;
227227
SemaphoreHandle_t _soc_event_sem;
228+
228229
#ifdef ANT_LICENSE_KEY
229230
/* Optional semaphore for additional event handlers for SD event.
230231
* It can be used for handling non-BLE SD events

0 commit comments

Comments
 (0)