Skip to content

Commit a3eacfd

Browse files
committed
[BEETLE] Update disable dualtimer irq function
This patch updates DualTimer_DisableInterrupt to disable the interrupt timers individually. In addition, it updates lp_ticker accordingly. Signed-off-by: Marc Moreno <[email protected]>
1 parent e2efb35 commit a3eacfd

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

targets/TARGET_ARM_SSG/TARGET_BEETLE/device/apb_dualtimer.c

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,38 @@ void DualTimer_SetInterrupt_2(uint32_t timer, uint32_t time_us,
297297
}
298298

299299
/*
300-
* DualTimer_DisableInterrupt(): disables timer interrupt
301-
* timer: timer on which interrupt is disabled
300+
* DualTimer_DisableInterrupt(): disables timer interrupts
301+
* dualimer: dualtimer on which interrupt is disabled
302+
* single_timer: single timer in the dualtimer on which
303+
* interrupt is disabled
302304
*/
303-
void DualTimer_DisableInterrupt(uint32_t timer)
305+
void DualTimer_DisableInterrupt(uint32_t dualtimer,
306+
uint32_t single_timer)
304307
{
305308
/* Verify if the Timer is enabled */
306-
if (DualTimer_isEnabled(timer) == 1) {
307-
/* Disable Interrupt */
308-
(DualTimers[timer].dualtimer1)->TimerControl &=
309-
CMSDK_DUALTIMER_CTRL_EN_Msk;
310-
(DualTimers[timer].dualtimer2)->TimerControl &=
311-
CMSDK_DUALTIMER_CTRL_EN_Msk;
309+
if (DualTimer_isEnabled(dualtimer) == 1) {
310+
switch(single_timer) {
311+
case SINGLETIMER1:
312+
/* Disable Interrupt for single timer 1 */
313+
(DualTimers[dualtimer].dualtimer1)->TimerControl &=
314+
CMSDK_DUALTIMER_CTRL_EN_Msk;
315+
break;
316+
case SINGLETIMER2:
317+
/* Disable Interrupt for single timer 2 */
318+
(DualTimers[dualtimer].dualtimer2)->TimerControl &=
319+
CMSDK_DUALTIMER_CTRL_EN_Msk;
320+
break;
321+
case ALL_SINGLETIMERS:
322+
/* Disable Interrupt for single timer 1 */
323+
(DualTimers[dualtimer].dualtimer1)->TimerControl &=
324+
CMSDK_DUALTIMER_CTRL_EN_Msk;
325+
/* Disable Interrupt for single timer 2 */
326+
(DualTimers[dualtimer].dualtimer2)->TimerControl &=
327+
CMSDK_DUALTIMER_CTRL_EN_Msk;
328+
break;
329+
default:
330+
break;
331+
}
312332
}
313333
}
314334

targets/TARGET_ARM_SSG/TARGET_BEETLE/device/apb_dualtimer.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ extern "C" {
2222
#endif
2323

2424
/* Supported Number of Dual Timers */
25-
#define NUM_DUALTIMERS 1
26-
#define DUALTIMER0 0
27-
#define SINGLETIMER1 1
28-
#define SINGLETIMER2 2
25+
#define NUM_DUALTIMERS 1
26+
#define DUALTIMER0 0
27+
#define SINGLETIMER1 1
28+
#define SINGLETIMER2 2
29+
#define ALL_SINGLETIMERS 3
2930

3031
/*
3132
* DualTimer_Initialize(): Initializes a hardware timer
@@ -107,10 +108,13 @@ void DualTimer_SetInterrupt_2(uint32_t timer, uint32_t time_us,
107108
timerenable_t mode);
108109

109110
/*
110-
* DualTimer_DisableInterrupt(): disables timer interrupt
111-
* timer: timer on which interrupt is disabled
111+
* DualTimer_DisableInterrupt(): disables timer interrupts
112+
* dualimer: dualtimer on which interrupt is disabled
113+
* single_timer: single timer in the dualtimer on which
114+
* interrupt is disabled
112115
*/
113-
void DualTimer_DisableInterrupt(uint32_t timer);
116+
void DualTimer_DisableInterrupt(uint32_t dualtimer,
117+
uint32_t single_timer);
114118

115119
/*
116120
* DualTimer_ClearInterrupt(): clear timer interrupt

targets/TARGET_ARM_SSG/TARGET_BEETLE/lp_ticker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
142142
void lp_ticker_disable_interrupt(void)
143143
{
144144
/* Disable Interrupt */
145-
DualTimer_DisableInterrupt(DUALTIMER0);
145+
DualTimer_DisableInterrupt(DUALTIMER0,
146+
SINGLETIMER1);
146147
}
147148

148149
/**

0 commit comments

Comments
 (0)