source: rtems/c/src/lib/libbsp/arm/gba/clock/clockdrv.c @ 81d86a0

4.104.11
Last change on this file since 81d86a0 was 81d86a0, checked in by Ralf Corsepius <ralf.corsepius@…>, on Sep 30, 2008 at 5:35:13 AM

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

  • clock/clockdrv.c: include "../../../shared/clockdrv_shell.h".
  • Makefile.am: Reflect changes above.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/**
2 *  @file clockdrv.c
3 *
4 *  Game Boy Advance Clock driver.
5 */
6/*
7 *  RTEMS GBA BSP
8 *
9 *  Copyright (c) 2004  Markku Puro <markku.puro@kopteri.net>
10 *
11 *  The license and distribution terms for this file may be
12 *  found in found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#include <rtems.h>
19#include <bsp.h>
20#include <irq.h>
21#include <gba.h>
22
23
24/*-------------------------------------------------------------------------+
25| Clock isr variables
26+--------------------------------------------------------------------------*/
27rtems_isr Clock_isr(rtems_vector_number vector);
28static void clock_isr_on(const rtems_irq_connect_data *unused);
29static void clock_isr_off(const rtems_irq_connect_data *unused);
30static int clock_isr_is_on(const rtems_irq_connect_data *irq);
31
32rtems_irq_connect_data clock_isr_data = {BSP_IRQ_TIMER3,
33                                        (rtems_irq_hdl)Clock_isr,
34                                         clock_isr_on,
35                                         clock_isr_off,
36                                         clock_isr_is_on,
37                                         0,
38                                         0 };
39
40#define CLOCK_VECTOR  0
41
42#define Clock_driver_support_at_tick()
43
44#define Clock_driver_support_install_isr( _new, _old )  \
45  do {                                                  \
46        BSP_install_rtems_irq_handler(&clock_isr_data); \
47     } while(0)
48
49#define Clock_driver_support_shutdown_hardware()        \
50  do {                                                  \
51        BSP_remove_rtems_irq_handler(&clock_isr_data);  \
52     } while (0)
53
54
55/*-------------------------------------------------------------------------+
56| Calculate Tick Times
57|    1 / 16.78Mhz  => 59.595 ns
58|   64 / 16.78Mhz  =>  3.814 us
59|  256 / 16.78Mhz  => 15.256 us
60| 1024 / 16.78Mhz  => 61.025 us
61+--------------------------------------------------------------------------*/
62#define  __TimTickTime_us   ((1000000L/__ClockFrequency)*__TimPreScaler)
63#define  __TimTickTime_ns   ((1000000000L/__ClockFrequency)*__TimPreScaler)
64
65#if (__TimPreScaler==1)
66 #define GBA_TMCNT_PS    0x0000
67#elif (__TimPreScaler==64)
68 #define GBA_TMCNT_PS    0x0001
69#elif (__TimPreScaler==256)
70 #define GBA_TMCNT_PS    0x0002
71#elif (__TimPreScaler==1024)
72 #define GBA_TMCNT_PS    0x0003
73#else
74 #define GBA_TMCNT_PS    0x0003
75#endif
76
77/**
78 *  @brief This function set up the clock hardware
79 *
80 *  @param  None
81 *  @return None
82 */
83void Clock_driver_support_initialize_hardware(void)
84{
85  int tmreload = ((rtems_configuration_get_microseconds_per_tick()*1000)/__TimTickTime_ns);
86
87  if (tmreload>0xFFFF) tmreload = 0xFFFF;
88  GBA_REG_TM3CNT = (GBA_TMCNT_PS);
89  GBA_REG_TM3D   = (0x0000-tmreload);
90  GBA_REG_TM3CNT = (0x00c0|GBA_TMCNT_PS);
91}
92
93/**
94 *  @brief This function is empty
95 *
96 *  @param  unused an unused parameter
97 *  @return None
98 */
99static void clock_isr_on(const rtems_irq_connect_data *unused)
100{
101    return;
102}
103
104/**
105 *  @brief This function is empty
106 *
107 *  @param  unused an unused parameter
108 *  @return None
109 */
110static void clock_isr_off(const rtems_irq_connect_data *unused)
111{
112    return;
113}
114
115/**
116 *  @brief This function is empty
117 *
118 *  @param  irq unused
119 *  @return constant 1
120 */
121static int clock_isr_is_on(const rtems_irq_connect_data *irq)
122{
123    return 1;
124}
125
126
127#include "../../../shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.