Skip to content

Commit 31c3081

Browse files
committed
update makefile/cmake for softdevice macro. Remove the _s340 filter in ci
1 parent d475f25 commit 31c3081

File tree

5 files changed

+29
-50
lines changed

5 files changed

+29
-50
lines changed

.github/workflows/githubci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
id: set-matrix
2222
working-directory: src/boards
2323
run: |
24-
MATRIX_JSON=$(ls -d */ | sed 's/\/$//' | grep -vE '_s340$' | jq -R -s -c 'split("\n")[:-1]')
24+
MATRIX_JSON=$(ls -d */ | sed 's/\/$//' | jq -R -s -c 'split("\n")[:-1]')
2525
echo "matrix=$MATRIX_JSON"
2626
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
2727

CMakeLists.txt

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -225,47 +225,29 @@ if (MCU_VARIANT STREQUAL "nrf52")
225225
set(SD_NAME s132)
226226
set(DFU_DEV_REV 0xADAF)
227227
set(DFU_APP_DATA_RESERVED 7*4096)
228-
target_compile_definitions(bootloader PUBLIC
229-
NRF52
230-
NRF52832_XXAA
231-
S132
232-
)
228+
target_compile_definitions(bootloader PUBLIC NRF52 NRF52832_XXAA)
233229
elseif (MCU_VARIANT STREQUAL "nrf52833")
234230
set(DFU_DEV_REV 52833)
235231
set(DFU_APP_DATA_RESERVED 7*4096)
236-
if (SD_NAME STREQUAL "s340")
237-
target_compile_definitions(bootloader PUBLIC
238-
NRF52833_XXAA
239-
S340
240-
)
241-
else ()
232+
target_compile_definitions(bootloader PUBLIC NRF52833_XXAA)
233+
if (NOT DEFINED SD_NAME)
242234
set(SD_NAME s140)
243-
target_compile_definitions(bootloader PUBLIC
244-
NRF52833_XXAA
245-
S140
246-
)
247235
endif ()
248236
elseif (MCU_VARIANT STREQUAL "nrf52840")
249237
set(DFU_DEV_REV 52840)
250238
# App reserved 40KB (8+32) to match circuitpython for 840
251239
set(DFU_APP_DATA_RESERVED 10*4096)
252-
if (SD_NAME STREQUAL "s340")
253-
target_compile_definitions(bootloader PUBLIC
254-
NRF52840_XXAA
255-
S340
256-
)
257-
else ()
240+
target_compile_definitions(bootloader PUBLIC NRF52840_XXAA)
241+
if (NOT DEFINED SD_NAME)
258242
set(SD_NAME s140)
259-
target_compile_definitions(bootloader PUBLIC
260-
NRF52840_XXAA
261-
S140
262-
)
263243
endif ()
264-
265244
else ()
266245
message(FATAL_ERROR "MCU_VARIANT ${MCU_VARIANT} is unknown")
267246
endif ()
268247

248+
string(TOUPPER ${SD_NAME} SD_NAME_UPPER)
249+
target_compile_definitions(bootloader PUBLIC ${SD_NAME_UPPER})
250+
269251
set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION})
270252
set(SD_HEX ${SOFTDEVICE_DIR}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex)
271253

Makefile

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,33 +104,32 @@ BIN = _bin/$(BOARD)
104104

105105
# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
106106
ifeq ($(MCU_SUB_VARIANT),nrf52)
107+
CFLAGS += -DNRF52 -DNRF52832_XXAA
107108
SD_NAME = s132
108109
DFU_DEV_REV = 0xADAF
109-
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
110110
DFU_APP_DATA_RESERVED=7*4096
111111
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
112-
ifeq ($(SD_NAME),s340)
113-
CFLAGS += -DNRF52833_XXAA -DS340
114-
else
115-
SD_NAME = s140
116-
CFLAGS += -DNRF52833_XXAA -DS140
117-
endif
112+
CFLAGS += -DNRF52833_XXAA
118113
DFU_DEV_REV = 52833
119114
DFU_APP_DATA_RESERVED=7*4096
115+
ifndef SD_NAME
116+
SD_NAME = s140
117+
endif
120118
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
121-
ifeq ($(SD_NAME),s340)
122-
CFLAGS += -DNRF52840_XXAA -DS340
123-
else
124-
SD_NAME = s140
125-
CFLAGS += -DNRF52840_XXAA -DS140
126-
endif
119+
CFLAGS += -DNRF52840_XXAA
127120
DFU_DEV_REV = 52840
128121
# App reserved 40KB (8+32) to match circuitpython for 840
129122
DFU_APP_DATA_RESERVED=10*4096
123+
ifndef SD_NAME
124+
SD_NAME = s140
125+
endif
130126
else
131127
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
132128
endif
133129

130+
SD_NAME_UPPER = $(subst s,S,${SD_NAME})
131+
CFLAGS += -D$(SD_NAME_UPPER)
132+
134133
#------------------------------------------------------------------------------
135134
# SOURCE FILES
136135
#------------------------------------------------------------------------------

lib/softdevice/s340_nrf52_7.0.1/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ To add or modify a board with an ANT+ capable SoftDevice S340 the `SD_VERSION` a
1515
```
1616
SD_VERSION = 7.0.1
1717
SD_NAME = s340
18-
```
19-
**Important:** When adding a new board you must add the suffix `_s340` to the folder name to exclude it from automatic builds.
18+
```

src/main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,8 @@ static void mbr_init_sd(void) {
157157
sd_mbr_command(&com);
158158
}
159159

160-
// Helper function to disable the SoftDevice with upfront check if it is enabled.
161-
// Especially SoftDevice S340 locks up when calling sd_softdevice_disable() and it's not enabled.
162-
static void sd_disable(void) {
160+
// Disable the SoftDevice if it is enabled.
161+
static void disable_softdevice(void) {
163162
uint8_t sd_enabled = 0;
164163
sd_softdevice_is_enabled(&sd_enabled);
165164
if (sd_enabled == 1) {
@@ -216,7 +215,7 @@ int main(void) {
216215
if (!_sd_inited) mbr_init_sd();
217216

218217
// Make sure SD is disabled
219-
sd_disable();
218+
disable_softdevice();
220219
}
221220

222221
// clear in case we kept DFU_DBL_RESET_APP there
@@ -317,7 +316,7 @@ static void check_dfu_mode(void) {
317316
}
318317

319318
if (_ota_dfu) {
320-
sd_disable();
319+
disable_softdevice();
321320
} else {
322321
usb_teardown();
323322
}
@@ -337,10 +336,10 @@ static uint32_t ble_stack_init(void) {
337336
.rc_temp_ctiv = 2,
338337
.accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM
339338
};
340-
#ifndef ANT_LICENSE_KEY
341-
sd_softdevice_enable(&clock_cfg, app_error_fault_handler);
342-
#else
339+
#ifdef ANT_LICENSE_KEY
343340
sd_softdevice_enable(&clock_cfg, app_error_fault_handler, ANT_LICENSE_KEY);
341+
#else
342+
sd_softdevice_enable(&clock_cfg, app_error_fault_handler);
344343
#endif
345344
sd_nvic_EnableIRQ(SD_EVT_IRQn);
346345

0 commit comments

Comments
 (0)