source: rtems/c/src/lib/libbsp/arm/gba/clock/clockdrv.c @ 15ca4e7

4.115
Last change on this file since 15ca4e7 was 15ca4e7, checked in by Joel Sherrill <joel.sherrill@…>, on 01/28/11 at 20:29:35

2011-01-28 Joel Sherrill <joel.sherrilL@…>

  • gba/clock/clockdrv.c, gba/console/conio.c, gba/console/console.c, gba/console/defaultfont.h, gba/include/arm_mode_bits.h, gba/include/asm_macros.h, gba/include/bsp.h, gba/include/conio.h, gba/include/gba.h, gba/include/gba_registers.h, gba/irq/irq.c, gba/irq/irq.h, gba/startup/bspstart.c, gba/timer/timer.c, gp32/include/bsp.h, gp32/startup/bspreset.c, gp32/startup/bspstart.c, nds/tools/runtest, shared/comm/uart.c, shared/comm/uart.h, smdk2410/include/bsp.h: Fix typo where license said found in found in.
  • Property mode set to 100644
File size: 3.2 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 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 <bsp/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                                         NULL,
35                                         clock_isr_on,
36                                         clock_isr_off,
37                                         clock_isr_is_on};
38
39#define CLOCK_VECTOR  0
40
41#define Clock_driver_support_at_tick()
42
43#define Clock_driver_support_install_isr( _new, _old )  \
44  do {                                                  \
45        BSP_install_rtems_irq_handler(&clock_isr_data); \
46        _old = NULL;                                    \
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.