support RTC0, RTC1, RTC2 select

This commit is contained in:
chenyingchun0312 2020-09-23 23:32:47 +08:00
parent 797ce29ae0
commit c5b0a848dc
3 changed files with 59 additions and 10 deletions

View File

@ -29,6 +29,10 @@
#define ONCHIP_RTC_TIME_DEFAULT RTC_TIME_INIT(2018, 1, 1, 0, 0 ,0)
#endif
#ifndef RTC_INSTANCE_ID
#define RTC_INSTANCE_ID (2)
#endif
#define TICK_FREQUENCE_HZ (RT_TICK_PER_SECOND) // RTC tick frequence, in HZ
static struct rt_device rtc;
@ -54,7 +58,7 @@ static rt_err_t rt_rtc_config(struct rt_device *dev)
#define SYSTICK_CLOCK_HZ (32768UL)
#define RTC_PRESCALER ((uint32_t) (NRFX_ROUNDED_DIV(SYSTICK_CLOCK_HZ, TICK_FREQUENCE_HZ) - 1))
const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(2);
const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(RTC_INSTANCE_ID);
nrf_clock_lf_src_set(NRF_CLOCK, (nrf_clock_lfclk_t)NRFX_CLOCK_CONFIG_LF_SRC);
nrfx_clock_lfclk_start();

View File

@ -318,21 +318,33 @@ endif
bool "Enable RTC"
select RT_USING_RTC
select RT_USING_LIBC
select NRFX_CLOCK_ENABLED
default n
if BSP_USING_ONCHIP_RTC
config NRFX_CLOCK_ENABLED
int
default 1
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
int
default 7
config NRFX_RTC_ENABLED
int
default 1
config NRFX_RTC0_ENABLED
int
default 1
config NRFX_RTC1_ENABLED
int
default 1
config NRFX_RTC2_ENABLED
int
default 1
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
config RTC_INSTANCE_ID
int
default 7
default 2
config RTC_INSTANCE_ID
int "select RTC instance id, must be 0, 1, 2"
range 0 2
default 2
endif
endmenu

View File

@ -346,8 +346,41 @@ menu "On-chip Peripheral Drivers"
int
default 1
endif
endmenu
menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC"
select RT_USING_RTC
select RT_USING_LIBC
default n
if BSP_USING_ONCHIP_RTC
config NRFX_CLOCK_ENABLED
int
default 1
config NRFX_CLOCK_DEFAULT_CONFIG_IRQ_PRIORITY
int
default 7
config NRFX_RTC_ENABLED
int
default 1
config NRFX_RTC0_ENABLED
int
default 1
config NRFX_RTC1_ENABLED
int
default 1
config NRFX_RTC2_ENABLED
int
default 1
config RTC_INSTANCE_ID
int
default 2
config RTC_INSTANCE_ID
int "select RTC instance id, must be 0, 1, 2"
range 0 2
default 2
endif
endmenu
choice
prompt "BLE STACK"