Skip to content

Commit c5b0a84

Browse files
support RTC0, RTC1, RTC2 select
1 parent 797ce29 commit c5b0a84

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

bsp/nrf5x/libraries/drivers/drv_rtc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifdef BSP_USING_ONCHIP_RTC
1919

2020
#define LOG_TAG "drv.rtc"
21-
#define DBG_LVL DBG_LOG
21+
#define DBG_LVL DBG_LOG
2222
#include <rtdbg.h>
2323

2424
/* 2018-01-30 14:44:50 = RTC_TIME_INIT(2018, 1, 30, 14, 44, 50) */
@@ -29,6 +29,10 @@
2929
#define ONCHIP_RTC_TIME_DEFAULT RTC_TIME_INIT(2018, 1, 1, 0, 0 ,0)
3030
#endif
3131

32+
#ifndef RTC_INSTANCE_ID
33+
#define RTC_INSTANCE_ID (2)
34+
#endif
35+
3236
#define TICK_FREQUENCE_HZ (RT_TICK_PER_SECOND) // RTC tick frequence, in HZ
3337

3438
static struct rt_device rtc;
@@ -54,7 +58,7 @@ static rt_err_t rt_rtc_config(struct rt_device *dev)
5458
#define SYSTICK_CLOCK_HZ (32768UL)
5559
#define RTC_PRESCALER ((uint32_t) (NRFX_ROUNDED_DIV(SYSTICK_CLOCK_HZ, TICK_FREQUENCE_HZ) - 1))
5660

57-
const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(2);
61+
const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(RTC_INSTANCE_ID);
5862
nrf_clock_lf_src_set(NRF_CLOCK, (nrf_clock_lfclk_t)NRFX_CLOCK_CONFIG_LF_SRC);
5963
nrfx_clock_lfclk_start();
6064

bsp/nrf5x/nrf52832/board/Kconfig

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,33 @@ endif
318318
bool "Enable RTC"
319319
select RT_USING_RTC
320320
select RT_USING_LIBC
321-
select NRFX_CLOCK_ENABLED
322321
default n
323322
if BSP_USING_ONCHIP_RTC
324323
config NRFX_CLOCK_ENABLED
325324
int
326325
default 1
326+
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
327+
int
328+
default 7
327329
config NRFX_RTC_ENABLED
328330
int
329331
default 1
330-
config NRFX_RTC2_ENABLED
331-
int
332+
config NRFX_RTC0_ENABLED
333+
int
332334
default 1
333-
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
335+
config NRFX_RTC1_ENABLED
334336
int
335-
default 7
337+
default 1
338+
config NRFX_RTC2_ENABLED
339+
int
340+
default 1
341+
config RTC_INSTANCE_ID
342+
int
343+
default 2
344+
config RTC_INSTANCE_ID
345+
int "select RTC instance id, must be 0, 1, 2"
346+
range 0 2
347+
default 2
336348
endif
337349
endmenu
338350

bsp/nrf5x/nrf52840/board/Kconfig

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,41 @@ menu "On-chip Peripheral Drivers"
346346
int
347347
default 1
348348
endif
349-
endmenu
350349

350+
menuconfig BSP_USING_ONCHIP_RTC
351+
bool "Enable RTC"
352+
select RT_USING_RTC
353+
select RT_USING_LIBC
354+
default n
355+
if BSP_USING_ONCHIP_RTC
356+
config NRFX_CLOCK_ENABLED
357+
int
358+
default 1
359+
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
360+
int
361+
default 7
362+
config NRFX_RTC_ENABLED
363+
int
364+
default 1
365+
config NRFX_RTC0_ENABLED
366+
int
367+
default 1
368+
config NRFX_RTC1_ENABLED
369+
int
370+
default 1
371+
config NRFX_RTC2_ENABLED
372+
int
373+
default 1
374+
config RTC_INSTANCE_ID
375+
int
376+
default 2
377+
config RTC_INSTANCE_ID
378+
int "select RTC instance id, must be 0, 1, 2"
379+
range 0 2
380+
default 2
381+
endif
382+
383+
endmenu
351384

352385
choice
353386
prompt "BLE STACK"

0 commit comments

Comments
 (0)