1 | /* |
---|
2 | * Clock device driver for Lattice Mico32 (lm32). |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * http://www.rtems.org/license/LICENSE. |
---|
9 | * |
---|
10 | * COPYRIGHT (c) Yann Sionneau <yann.sionneau@telecom-sudparis.eu> (GSoC 2010) |
---|
11 | * Telecom SudParis |
---|
12 | */ |
---|
13 | |
---|
14 | #include <bsp.h> |
---|
15 | #include <bsp/irq-generic.h> |
---|
16 | #include "../include/system_conf.h" |
---|
17 | #include "clock.h" |
---|
18 | #include "bspopts.h" |
---|
19 | |
---|
20 | #if ON_SIMULATOR |
---|
21 | #define CLOCK_DRIVER_USE_FAST_IDLE 1 |
---|
22 | #endif |
---|
23 | |
---|
24 | #define Clock_driver_support_at_tick() \ |
---|
25 | do { \ |
---|
26 | lm32_interrupt_ack(1 << MM_IRQ_TIMER0); \ |
---|
27 | } while (0) |
---|
28 | |
---|
29 | #define Clock_driver_support_install_isr(_new ) \ |
---|
30 | do { \ |
---|
31 | rtems_isr_entry _old; \ |
---|
32 | rtems_interrupt_catch(_new, MM_IRQ_TIMER0, &_old); \ |
---|
33 | } while (0) |
---|
34 | |
---|
35 | static void Clock_driver_support_initialize_hardware(void) |
---|
36 | { |
---|
37 | MM_WRITE(MM_TIMER0_COMPARE, |
---|
38 | (MM_READ(MM_FREQUENCY)/(1000000/rtems_configuration_get_microseconds_per_tick()))); |
---|
39 | MM_WRITE(MM_TIMER0_COUNTER, 0); |
---|
40 | MM_WRITE(MM_TIMER0_CONTROL, TIMER_ENABLE | TIMER_AUTORESTART); |
---|
41 | bsp_interrupt_vector_enable(MM_IRQ_TIMER0); |
---|
42 | } |
---|
43 | |
---|
44 | #define Clock_driver_support_shutdown_hardware() \ |
---|
45 | do { \ |
---|
46 | bsp_interrupt_vector_disable(MM_IRQ_TIMER0); \ |
---|
47 | MM_WRITE(MM_TIMER0_CONTROL, 0); \ |
---|
48 | } while (0) |
---|
49 | |
---|
50 | #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER |
---|
51 | |
---|
52 | #include "../../../shared/dev/clock/clockimpl.h" |
---|