Skip to content

Commit c758168

Browse files
authored
Merge pull request #3937 from chenyingchun0312/master
同步nrf52840相关修改到nrf52832中,测试了ble 相关sample,同时测试了RTC设备,可以正常工作
2 parents e3d1ed4 + 0051092 commit c758168

File tree

3 files changed

+57
-80
lines changed

3 files changed

+57
-80
lines changed

bsp/nrf5x/nrf52832/board/Kconfig

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ config SOC_NRF52832
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
18+
919

1020
config SOC_NORDIC
1121
bool
@@ -26,6 +36,11 @@ menu "On-chip Peripheral Drivers"
2636
bool "Enable GPIO"
2737
select RT_USING_PIN
2838
default y
39+
if BSP_USING_GPIO
40+
config NRFX_GPIOTE_ENABLED
41+
int
42+
default 1
43+
endif
2944
config BSP_USING_SAADC
3045
bool "Enable SAADC"
3146
select RT_USING_ADC
@@ -140,47 +155,25 @@ menu "On-chip Peripheral Drivers"
140155
default 16
141156
endif
142157
endif
143-
menuconfig BSP_USING_SOFTDEVICE
144-
bool "Enable NRF SOFTDEVICE"
145-
select PKG_USING_NRF5X_SDK
146-
select NRFX_CLOCK_ENABLED
147-
default n
148-
if BSP_USING_SOFTDEVICE
149-
config NRFX_CLOCK_ENABLED
150-
int
151-
default 1
152-
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
153-
int
154-
default 7
155-
config NRFX_RTC_ENABLED
156-
int
157-
default 1
158-
config NRFX_RTC1_ENABLED
159-
int
160-
default 1
161-
config NRF_CLOCK_ENABLED
162-
int
163-
default 1
164-
config NRF_SDH_BLE_ENABLED
165-
int
166-
default 1
167-
config NRF_SDH_ENABLED
168-
int
169-
default 1
170-
config NRF_SDH_SOC_ENABLED
171-
int
172-
default 1
173-
endif
158+
159+
174160
menuconfig BSP_USING_UART
175161
bool "Enable UART"
176162
default y
177163
select RT_USING_SERIAL
178164

179165
if BSP_USING_UART
166+
config NRFX_UART_ENABLED
167+
int
168+
default 1
169+
180170
config BSP_USING_UART0
181171
bool "Enable UART0"
182172
default y
183173
if BSP_USING_UART0
174+
config NRFX_UART0_ENABLED
175+
int
176+
default 1
184177
config BSP_UART0_RX_PIN
185178
int "uart0 rx pin number"
186179
range 0 31
@@ -201,6 +194,9 @@ endif
201194
default y
202195

203196
if BSP_USING_SPI
197+
config NRFX_SPI_ENABLED
198+
int
199+
default 1
204200
config BSP_USING_SPI0
205201
bool "Enable SPI0 bus"
206202
default y
@@ -348,4 +344,24 @@ endif
348344
endif
349345
endmenu
350346

347+
choice
348+
prompt "BLE STACK"
349+
default BLE_STACK_USING_NULL
350+
help
351+
Select the ble stack
352+
353+
config BLE_STACK_USING_NULL
354+
bool "not use the ble stack"
355+
356+
config BSP_USING_SOFTDEVICE
357+
select PKG_USING_NRF5X_SDK
358+
bool "Nordic softdevice(perpheral)"
359+
360+
config BSP_USING_NIMBLE
361+
select PKG_USING_NIMBLE
362+
select PKG_NIMBLE_BSP_NRF52840
363+
bool "use nimble stack(iot)"
364+
endchoice
365+
366+
351367
endmenu

bsp/nrf5x/nrf52832/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/nrf52832/board/sdk_config.h

Lines changed: 3 additions & 3 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
@@ -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)