1 | /* |
---|
2 | * RTEMS for Nintendo DS clock driver. |
---|
3 | * |
---|
4 | * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * |
---|
9 | * http://www.rtems.com/license/LICENSE |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems.h> |
---|
15 | #include <bsp.h> |
---|
16 | #include "../irq/irq.h" |
---|
17 | #include <nds.h> |
---|
18 | |
---|
19 | #define CLOCK_VECTOR IRQ_TIMER0 |
---|
20 | |
---|
21 | /* |
---|
22 | * forward declaration for clock isr in clockdrv_shell.h |
---|
23 | */ |
---|
24 | |
---|
25 | rtems_isr Clock_isr (rtems_vector_number vector); |
---|
26 | |
---|
27 | /* |
---|
28 | * isr registration variables. |
---|
29 | */ |
---|
30 | |
---|
31 | static rtems_irq_connect_data clock_isr_data = { |
---|
32 | IRQ_TIMER0, |
---|
33 | (rtems_irq_hdl) Clock_isr, |
---|
34 | NULL, |
---|
35 | NULL, |
---|
36 | NULL, |
---|
37 | 0, |
---|
38 | 0 |
---|
39 | }; |
---|
40 | |
---|
41 | void update_touchscreen (void); |
---|
42 | |
---|
43 | /* |
---|
44 | * function called on every ticks. |
---|
45 | * NOTE: replaced by macro to avoid empty function call. |
---|
46 | */ |
---|
47 | |
---|
48 | #define Clock_driver_support_at_tick() \ |
---|
49 | update_touchscreen(); |
---|
50 | |
---|
51 | /* |
---|
52 | * install isr for clock driver. |
---|
53 | */ |
---|
54 | |
---|
55 | void |
---|
56 | Clock_driver_support_install_isr (rtems_isr_entry new, rtems_isr_entry old) |
---|
57 | { |
---|
58 | BSP_install_rtems_irq_handler (&clock_isr_data); |
---|
59 | } |
---|
60 | |
---|
61 | /* |
---|
62 | * disable clock. |
---|
63 | */ |
---|
64 | |
---|
65 | void |
---|
66 | Clock_driver_support_shutdown_hardware (void) |
---|
67 | { |
---|
68 | BSP_remove_rtems_irq_handler (&clock_isr_data); |
---|
69 | TIMER_CR (0) &= ~(TIMER_ENABLE); |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | * initialize clock on timer 0. |
---|
74 | */ |
---|
75 | |
---|
76 | void |
---|
77 | Clock_driver_support_initialize_hardware (void) |
---|
78 | { |
---|
79 | uint32_t freq = |
---|
80 | 1000 / (rtems_configuration_get_microseconds_per_tick () / 1000); |
---|
81 | |
---|
82 | printk ("[+] clock started\n"); |
---|
83 | TIMER_CR (0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_64; |
---|
84 | printk ("[#] setting clock to %u hz\n", freq); |
---|
85 | TIMER_DATA (0) = TIMER_FREQ_64 ((uint16_t) freq); |
---|
86 | } |
---|
87 | |
---|
88 | #include "../../../shared/clockdrv_shell.h" |
---|