source: rtems/c/src/lib/libbsp/arm/nds/clock/clock.c @ 6a118f18

4.104.115
Last change on this file since 6a118f18 was 6a118f18, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/30/08 at 05:39:04

2008-09-30 Ralf Corsépius <ralf.corsepius@…>

  • clock/clock.c: include "../../../shared/clockdrv_shell.h".
  • Makefile.am: Reflect changes above.
  • Property mode set to 100644
File size: 1.6 KB
Line 
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
25rtems_isr Clock_isr (rtems_vector_number vector);
26
27/*
28 * isr registration variables.
29 */
30
31static 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
41void 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
55void
56Clock_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
65void
66Clock_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
76void
77Clock_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"
Note: See TracBrowser for help on using the repository browser.