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+
5136void 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
0 commit comments