Skip to content

Commit a5ab12c

Browse files
authored
Merge pull request #3905 from supperthomas/supperthomas
[bsp_nrf5x] rebuild the menuconfig and ble stack config
2 parents 0908df3 + c47d9f1 commit a5ab12c

File tree

3 files changed

+59
-149
lines changed

3 files changed

+59
-149
lines changed

bsp/nrf5x/nrf52840/board/Kconfig

Lines changed: 48 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ config SOC_NRF52840
66
select RT_USING_COMPONENTS_INIT
77
select RT_USING_USER_MAIN
88
default y
9+
config NRFX_CLOCK_ENABLED
10+
int
11+
default 1
12+
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
13+
int
14+
default 7
15+
config NRFX_CLOCK_CONFIG_LF_SRC
16+
int
17+
default 1
918

19+
1020
config SOC_NORDIC
1121
bool
1222
config SOC_NORDIC
@@ -63,6 +73,11 @@ menu "On-chip Peripheral Drivers"
6373
bool "Enable GPIO"
6474
select RT_USING_PIN
6575
default y
76+
if BSP_USING_GPIO
77+
config NRFX_GPIOTE_ENABLED
78+
int
79+
default 1
80+
endif
6681
config BSP_USING_SAADC
6782
bool "Enable SAADC"
6883
select RT_USING_ADC
@@ -177,117 +192,25 @@ menu "On-chip Peripheral Drivers"
177192
default 16
178193
endif
179194
endif
180-
menuconfig BSP_USING_SOFTDEVICE
181-
bool "Enable NRF SOFTDEVICE"
182-
select PKG_USING_NRF5X_SDK
183-
select NRFX_CLOCK_ENABLED
184-
default n
185-
if BSP_USING_SOFTDEVICE
186-
config NRFX_CLOCK_ENABLED
187-
int
188-
default 1
189-
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
190-
int
191-
default 7
192-
config NRFX_RTC_ENABLED
193-
int
194-
default 1
195-
config NRFX_RTC1_ENABLED
196-
int
197-
default 1
198-
config NRF_CLOCK_ENABLED
199-
int
200-
default 1
201-
config NRF_SDH_BLE_ENABLED
202-
int
203-
default 1
204-
config NRF_SDH_ENABLED
205-
int
206-
default 1
207-
config NRF_SDH_SOC_ENABLED
208-
int
209-
default 1
210-
config NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
211-
int
212-
default 1
213-
config BLE_ADVERTISING_ENABLED
214-
int
215-
default 1
216-
config NRF_BLE_QWR_ENABLED
217-
int
218-
default 1
219-
config NRF_SDH_BLE_VS_UUID_COUNT
220-
int
221-
default 1
222-
config NRF_BLE_CONN_PARAMS_ENABLED
223-
int
224-
default 1
225-
config NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION
226-
int
227-
default 499
228-
config NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION
229-
int
230-
default 65535
231-
config NRF_BLE_GATT_ENABLED
232-
int
233-
default 1
234-
235-
choice
236-
prompt "sample(softdevice)"
237-
default SD_BLE_APP_BEACON
238-
239-
config SD_BLE_APP_BEACON
240-
bool "ble_app_beacon"
241-
default n
242-
243-
config SD_BLE_APP_BLINKY
244-
bool "ble_app_blinky"
245-
default n
246-
if SD_BLE_APP_BLINKY
247-
config BLE_LBS_ENABLED
248-
int
249-
default 1
250-
endif
251195

252-
config SD_BLE_APP_UART
253-
bool "ble_app_uart"
254-
default n
255-
if SD_BLE_APP_UART
256-
config BLE_NUS_ENABLED
257-
int
258-
default 1
259-
config NRF_SDH_BLE_GATT_MAX_MTU_SIZE
260-
int
261-
default 247
262-
endif
263-
264-
config SD_BLE_APP_HRS
265-
bool "ble_app_hrs"
266-
default n
267-
if SD_BLE_APP_HRS
268-
config BLE_HRS_ENABLED
269-
int
270-
default 1
271-
config NRF_SDH_BLE_GATT_MAX_MTU_SIZE
272-
int
273-
default 247
274-
endif
275-
config SD_BLE_APP_HIDS_MOUSE
276-
bool "ble_app_hids_mouse"
277-
default n
278-
endchoice
279-
endif
280196

281197
menuconfig BSP_USING_UART
282198
bool "Enable UART"
283199
default y
284200
select RT_USING_SERIAL
285201

286202
if BSP_USING_UART
203+
config NRFX_UART_ENABLED
204+
int
205+
default 1
206+
287207
config BSP_USING_UART0
288208
bool "Enable UART0"
289209
default y
290210
if BSP_USING_UART0
211+
config NRFX_UART0_ENABLED
212+
int
213+
default 1
291214
config BSP_UART0_RX_PIN
292215
int "uart0 rx pin number"
293216
range 0 31
@@ -308,6 +231,9 @@ endif
308231
default y
309232

310233
if BSP_USING_SPI
234+
config NRFX_SPI_ENABLED
235+
int
236+
default 1
311237
config BSP_USING_SPI0
312238
bool "Enable SPI0 bus"
313239
default y
@@ -422,4 +348,27 @@ endif
422348
endif
423349
endmenu
424350

351+
352+
choice
353+
prompt "BLE STACK"
354+
default BLE_STACK_USING_NULL
355+
help
356+
Select the ble stack
357+
358+
config BLE_STACK_USING_NULL
359+
bool "not use the ble stack"
360+
361+
config BSP_USING_SOFTDEVICE
362+
select PKG_USING_NRF5X_SDK
363+
bool "Nordic softdevice(perpheral)"
364+
365+
config BSP_USING_NIMBLE
366+
select PKG_USING_NIMBLE
367+
select PKG_NIMBLE_BSP_NRF52840
368+
bool "use nimble stack(iot)"
369+
endchoice
370+
371+
425372
endmenu
373+
374+

bsp/nrf5x/nrf52840/board/board.c

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,8 @@
1414

1515
#include "board.h"
1616
#include "drv_uart.h"
17-
#ifdef BSP_USING_SOFTDEVICE
18-
#include <nrfx_rtc.h>
1917
#include <nrfx_clock.h>
20-
#include "app_error.h"
21-
#include "nrf_drv_clock.h"
22-
const nrfx_rtc_t rtc = NRFX_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC0. */
23-
24-
static void rtc_handler(nrfx_rtc_int_type_t int_type)
25-
{
26-
if (int_type == NRFX_RTC_INT_TICK)
27-
{
28-
rt_interrupt_enter();
2918

30-
rt_tick_increase();
31-
32-
rt_interrupt_leave();
33-
}
34-
}
35-
#else
3619
/**
3720
* This is the timer interrupt service routine.
3821
*
@@ -47,36 +30,14 @@ void SysTick_Handler(void)
4730
/* leave interrupt */
4831
rt_interrupt_leave();
4932
}
50-
#endif
33+
34+
static void clk_event_handler(nrfx_clock_evt_type_t event){}
35+
5136
void SysTick_Configuration(void)
5237
{
53-
#ifdef BSP_USING_SOFTDEVICE
54-
nrf_drv_clock_init();
55-
nrf_drv_clock_lfclk_request(NULL);
56-
57-
uint32_t err_code;
58-
#define TICK_RATE_HZ RT_TICK_PER_SECOND
59-
#define SYSTICK_CLOCK_HZ ( 32768UL )
60-
61-
#define NRF_RTC_REG NRF_RTC1
62-
/* IRQn used by the selected RTC */
63-
#define NRF_RTC_IRQn RTC1_IRQn
64-
/* Constants required to manipulate the NVIC. */
65-
#define NRF_RTC_PRESCALER ( (uint32_t) (NRFX_ROUNDED_DIV(SYSTICK_CLOCK_HZ, TICK_RATE_HZ) - 1) )
66-
nrfx_rtc_config_t config = NRFX_RTC_DEFAULT_CONFIG;
67-
config.prescaler = NRF_RTC_PRESCALER;
68-
69-
err_code = nrfx_rtc_init(&rtc, &config, rtc_handler);
70-
// APP_ERROR_CHECK(err_code);
71-
nrfx_rtc_tick_enable(&rtc, true);
72-
#define COMPARE_COUNTERTIME (3UL) /**< Get Compare event COMPARE_TIME seconds after the counter starts from 0. */
73-
//Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
74-
err_code = nrfx_rtc_cc_set(&rtc, 0, COMPARE_COUNTERTIME * 8, true);
75-
// APP_ERROR_CHECK(err_code);
76-
77-
//Power on RTC instance
78-
nrfx_rtc_enable(&rtc);
79-
#else
38+
nrfx_clock_init(clk_event_handler);
39+
nrfx_clock_enable();
40+
nrfx_clock_lfclk_start();
8041
/* Set interrupt priority */
8142
NVIC_SetPriority(SysTick_IRQn, 0xf);
8243

@@ -85,7 +46,7 @@ void SysTick_Configuration(void)
8546
nrf_systick_val_clear();
8647
nrf_systick_csr_set(NRF_SYSTICK_CSR_CLKSOURCE_CPU | NRF_SYSTICK_CSR_TICKINT_ENABLE
8748
| NRF_SYSTICK_CSR_ENABLE);
88-
#endif
49+
8950
}
9051

9152

bsp/nrf5x/nrf52840/board/sdk_config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@
18991899
// <e> NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver
19001900
//==========================================================
19011901
#ifndef NRFX_GPIOTE_ENABLED
1902-
#define NRFX_GPIOTE_ENABLED 1
1902+
#define NRFX_GPIOTE_ENABLED 0
19031903
#endif
19041904
// <o> NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins
19051905
#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
@@ -2903,7 +2903,7 @@
29032903
// <e> NRFX_QSPI_ENABLED - nrfx_qspi - QSPI peripheral driver
29042904
//==========================================================
29052905
#ifndef NRFX_QSPI_ENABLED
2906-
#define NRFX_QSPI_ENABLED 1
2906+
#define NRFX_QSPI_ENABLED 0
29072907
#endif
29082908
// <o> NRFX_QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255>
29092909

@@ -4382,11 +4382,11 @@
43824382
// <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver
43834383
//==========================================================
43844384
#ifndef NRFX_UART_ENABLED
4385-
#define NRFX_UART_ENABLED 1
4385+
#define NRFX_UART_ENABLED 0
43864386
#endif
43874387
// <o> NRFX_UART0_ENABLED - Enable UART0 instance
43884388
#ifndef NRFX_UART0_ENABLED
4389-
#define NRFX_UART0_ENABLED 1
4389+
#define NRFX_UART0_ENABLED 0
43904390
#endif
43914391

43924392
// <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control

0 commit comments

Comments
 (0)