summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/timer-as3525.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/timer-as3525.c')
-rw-r--r--firmware/target/arm/as3525/timer-as3525.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/timer-as3525.c b/firmware/target/arm/as3525/timer-as3525.c
index f5ff60e0f8..420eb489fb 100644
--- a/firmware/target/arm/as3525/timer-as3525.c
+++ b/firmware/target/arm/as3525/timer-as3525.c
@@ -19,7 +19,8 @@
19* 19*
20****************************************************************************/ 20****************************************************************************/
21 21
22#include "as3525.h" 22#include "config.h"
23#include "system.h"
23#include "timer.h" 24#include "timer.h"
24#include "stdlib.h" 25#include "stdlib.h"
25 26
@@ -33,6 +34,8 @@ void INT_TIMER1(void)
33 34
34bool timer_set(long cycles, bool start) 35bool timer_set(long cycles, bool start)
35{ 36{
37 int oldstatus = disable_irq_save();
38
36 if (start) 39 if (start)
37 { 40 {
38 if (pfn_unregister != NULL) 41 if (pfn_unregister != NULL)
@@ -50,19 +53,26 @@ bool timer_set(long cycles, bool start)
50 TIMER_PERIODIC | 53 TIMER_PERIODIC |
51 TIMER_INT_ENABLE | 54 TIMER_INT_ENABLE |
52 TIMER_32_BIT; 55 TIMER_32_BIT;
56
57 restore_irq(oldstatus);
58
53 return true; 59 return true;
54} 60}
55 61
56bool timer_start(void) 62bool timer_start(void)
57{ 63{
58 CGU_PERI |= CGU_TIMER1_CLOCK_ENABLE; /* enable peripheral */ 64 int oldstatus = disable_irq_save();
65 CGU_PERI |= CGU_TIMER1_CLOCK_ENABLE; /* enable peripheral */
59 VIC_INT_ENABLE = INTERRUPT_TIMER1; 66 VIC_INT_ENABLE = INTERRUPT_TIMER1;
67 restore_irq(oldstatus);
60 return true; 68 return true;
61} 69}
62 70
63void timer_stop(void) 71void timer_stop(void)
64{ 72{
73 int oldstatus = disable_irq_save();
65 TIMER1_CONTROL &= 0x10; /* disable timer 1 (don't modify bit 4) */ 74 TIMER1_CONTROL &= 0x10; /* disable timer 1 (don't modify bit 4) */
66 VIC_INT_EN_CLEAR = INTERRUPT_TIMER1; /* disable interrupt */ 75 VIC_INT_EN_CLEAR = INTERRUPT_TIMER1; /* disable interrupt */
67 CGU_PERI &= ~CGU_TIMER1_CLOCK_ENABLE; /* disable peripheral */ 76 CGU_PERI &= ~CGU_TIMER1_CLOCK_ENABLE; /* disable peripheral */
77 restore_irq(oldstatus);
68} 78}