diff options
Diffstat (limited to 'firmware/target/arm/as3525/kernel-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/kernel-as3525.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/firmware/target/arm/as3525/kernel-as3525.c b/firmware/target/arm/as3525/kernel-as3525.c index d8f0e23d30..966d3bf349 100644 --- a/firmware/target/arm/as3525/kernel-as3525.c +++ b/firmware/target/arm/as3525/kernel-as3525.c | |||
@@ -61,26 +61,18 @@ void INT_TIMER2(void) | |||
61 | 61 | ||
62 | void tick_start(unsigned int interval_in_ms) | 62 | void tick_start(unsigned int interval_in_ms) |
63 | { | 63 | { |
64 | int phi = 0; /* prescaler bits */ | ||
65 | int prescale = 1; | ||
66 | int cycles = KERNEL_TIMER_FREQ / 1000 * interval_in_ms; | 64 | int cycles = KERNEL_TIMER_FREQ / 1000 * interval_in_ms; |
67 | 65 | ||
68 | while(cycles > 0x10000) | ||
69 | { | ||
70 | phi++; | ||
71 | prescale <<= 4; | ||
72 | cycles >>= 4; | ||
73 | } | ||
74 | |||
75 | if(prescale > 256) | ||
76 | panicf("%s : interval too big", __func__); | ||
77 | |||
78 | CGU_PERI |= CGU_TIMER2_CLOCK_ENABLE; /* enable peripheral */ | 66 | CGU_PERI |= CGU_TIMER2_CLOCK_ENABLE; /* enable peripheral */ |
79 | VIC_INT_ENABLE |= INTERRUPT_TIMER2; /* enable interrupt */ | 67 | VIC_INT_ENABLE |= INTERRUPT_TIMER2; /* enable interrupt */ |
80 | 68 | ||
81 | TIMER2_LOAD = TIMER2_BGLOAD = cycles; /* timer period */ | 69 | TIMER2_LOAD = TIMER2_BGLOAD = cycles; /* timer period */ |
82 | 70 | ||
83 | /* /!\ bit 4 (reserved) must not be modified | 71 | /* /!\ bit 4 (reserved) must not be modified |
84 | * periodic mode, interrupt enabled, 16 bits counter */ | 72 | * periodic mode, interrupt enabled, no prescale, 32 bits counter */ |
85 | TIMER2_CONTROL = (TIMER2_CONTROL & (1<<4)) | 0xe0 | (phi<<2); | 73 | TIMER2_CONTROL = (TIMER2_CONTROL & (1<<4)) | |
74 | TIMER_ENABLE | | ||
75 | TIMER_PERIODIC | | ||
76 | TIMER_INT_ENABLE | | ||
77 | TIMER_32_BIT; | ||
86 | } | 78 | } |