@@ -64,16 +64,6 @@ STATIC_ASSERT(RTC1_IRQ_PRI == SWI_IRQ_PRI);
64
64
65
65
#define MAX_RTC_TASKS_DELAY 47 /**< Maximum delay until an RTC task is executed. */
66
66
67
- #if (APP_TIMER_CONFIG_SWI_NUMBER == 0 )
68
- #define SWI_IRQn SWI0_IRQn
69
- #define SWI_IRQHandler SWI0_IRQHandler
70
- #elif (APP_TIMER_CONFIG_SWI_NUMBER == 1 )
71
- #define SWI_IRQn SWI1_IRQn
72
- #define SWI_IRQHandler SWI1_IRQHandler
73
- #else
74
- #error "Unsupported SWI number."
75
- #endif
76
-
77
67
#define MODULE_INITIALIZED (m_op_queue.size != 0) /**< Macro designating whether the module has been initialized properly. */
78
68
79
69
/**@brief Timer node type. The nodes will be used form a linked list of running timers. */
@@ -151,6 +141,10 @@ static bool m_rtc1_reset;
151
141
static uint8_t m_max_user_op_queue_utilization ; /**< Maximum observed timer user operations queue utilization. */
152
142
#endif
153
143
144
+ /**@brief Function for handling changes to the timer list.
145
+ */
146
+ static void timer_list_handler (void );
147
+
154
148
/**@brief Function for initializing the RTC1 counter.
155
149
*
156
150
* @param[in] prescaler Value of the RTC1 PRESCALER register. Set to 0 for no prescaling.
@@ -198,6 +192,25 @@ static void rtc1_stop(void)
198
192
m_rtc1_running = false;
199
193
}
200
194
195
+ /**@brief Function suspends RTC1 timer.
196
+ */
197
+ static void rtc1_suspend (void )
198
+ {
199
+ if (m_rtc1_running == true)
200
+ {
201
+ NRF_RTC1 -> TASKS_STOP = 1 ;
202
+ }
203
+ }
204
+
205
+ /**@brief Function resumes RTC1 timer.
206
+ */
207
+ static void rtc1_resume (void )
208
+ {
209
+ if (m_rtc1_running == true)
210
+ {
211
+ NRF_RTC1 -> TASKS_START = 1 ;
212
+ }
213
+ }
201
214
202
215
/**@brief Function for returning the current value of the RTC1 counter.
203
216
*
@@ -352,14 +365,6 @@ static void timer_timeouts_check_sched(void)
352
365
NVIC_SetPendingIRQ (RTC1_IRQn );
353
366
}
354
367
355
-
356
- /**@brief Function for scheduling a timer list update by generating a SWI interrupt.
357
- */
358
- static void timer_list_handler_sched (void )
359
- {
360
- NVIC_SetPendingIRQ (SWI_IRQn );
361
- }
362
-
363
368
#if APP_TIMER_CONFIG_USE_SCHEDULER
364
369
static void timeout_handler_scheduled_exec (void * p_event_data , uint16_t event_size )
365
370
{
@@ -455,7 +460,7 @@ static void timer_timeouts_check(void)
455
460
// Queue the ticks expired.
456
461
m_ticks_elapsed [m_ticks_elapsed_q_write_ind ] = ticks_expired ;
457
462
458
- timer_list_handler_sched ();
463
+ timer_list_handler ();
459
464
}
460
465
}
461
466
@@ -727,6 +732,8 @@ static void timer_list_handler(void)
727
732
bool compare_update = false;
728
733
timer_node_t * p_timer_id_head_old ;
729
734
735
+ rtc1_suspend ();
736
+
730
737
#if APP_TIMER_WITH_PROFILER
731
738
{
732
739
uint8_t size = m_op_queue .size ;
@@ -768,6 +775,8 @@ static void timer_list_handler(void)
768
775
compare_reg_update (p_timer_id_head_old );
769
776
}
770
777
m_rtc1_reset = false;
778
+
779
+ rtc1_resume ();
771
780
}
772
781
773
782
@@ -850,7 +859,7 @@ static uint32_t timer_start_op_schedule(timer_node_t * p_node,
850
859
851
860
if (err_code == NRF_SUCCESS )
852
861
{
853
- timer_list_handler_sched ();
862
+ timer_list_handler ();
854
863
}
855
864
856
865
return err_code ;
@@ -888,7 +897,7 @@ static uint32_t timer_stop_op_schedule(timer_node_t * p_node,
888
897
889
898
if (err_code == NRF_SUCCESS )
890
899
{
891
- timer_list_handler_sched ();
900
+ timer_list_handler ();
892
901
}
893
902
894
903
return err_code ;
@@ -941,10 +950,6 @@ ret_code_t app_timer_init(void)
941
950
m_max_user_op_queue_utilization = 0 ;
942
951
#endif
943
952
944
- NVIC_ClearPendingIRQ (SWI_IRQn );
945
- NVIC_SetPriority (SWI_IRQn , SWI_IRQ_PRI );
946
- NVIC_EnableIRQ (SWI_IRQn );
947
-
948
953
rtc1_init (APP_TIMER_CONFIG_RTC_FREQUENCY );
949
954
950
955
m_ticks_latest = rtc1_counter_get ();
0 commit comments