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

4.104.11
Last change on this file since c193baad was c193baad, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Apr 9, 2010 at 8:24:57 PM

unify irq data types and code, merge s3c2400/s3c2410 support

  • Property mode set to 100644
File size: 1.7 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 <rtems/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  NULL
38};
39
40void update_touchscreen (void);
41
42/*
43 * function called on every ticks.
44 * NOTE: replaced by macro to avoid empty function call.
45 */
46
47#define Clock_driver_support_at_tick()                                  \
48  update_touchscreen();
49
50/*
51 * install isr for clock driver.
52 */
53
54#define Clock_driver_support_install_isr( _new, _old ) \
55  do {                                                 \
56    _old = NULL;                                       \
57    BSP_install_rtems_irq_handler(&clock_isr_data);    \
58  } while (0)
59/*
60 * disable clock.
61 */
62
63void
64Clock_driver_support_shutdown_hardware (void)
65{
66  BSP_remove_rtems_irq_handler (&clock_isr_data);
67  TIMER_CR (0) &= ~(TIMER_ENABLE);
68}
69
70/*
71 * initialize clock on timer 0.
72 */
73
74void
75Clock_driver_support_initialize_hardware (void)
76{
77  uint32_t freq =
78    1000 / (rtems_configuration_get_microseconds_per_tick () / 1000);
79
80  printk ("[+] clock started\n");
81  TIMER_CR (0) = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_64;
82  printk ("[#] setting clock to %u hz\n", freq);
83  TIMER_DATA (0) = TIMER_FREQ_64 ((uint16_t) freq);
84}
85
86#include "../../../shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.