source: rtems/c/src/lib/libbsp/arm/gba/clock/clockdrv.c @ 3c7ed6b

4.104.114.84.95
Last change on this file since 3c7ed6b was 3c7ed6b, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/05 at 18:46:04

2005-07-06 Markku Puro <markku.puro@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, clock/clockdrv.c, console/conio.c, console/console.c, console/defaultfont.c, include/arm_mode_bits.h, include/asm_macros.h, include/bsp.h, include/bspopts.h.in, include/conio.h, include/gba.h, include/gba_registers.h, include/tm27.h, irq/bsp_irq_asm.S, irq/bsp_irq_init.c, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, start/logo.S, start/start.S, startup/bspstart.c, startup/cpu.c, startup/cpu_asm.S, startup/exit.c, startup/linkcmds, timer/timer.c: New files.
  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[3c7ed6b]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
78extern rtems_configuration_table BSP_Configuration;
79
80/**
81 *  @brief This function set up the clock hardware
82 *
83 *  @param  None
84 *  @return None
85 */
86void Clock_driver_support_initialize_hardware()
87{
88  int tmreload = ((BSP_Configuration.microseconds_per_tick*1000)/__TimTickTime_ns);
89
90  if (tmreload>0xFFFF) tmreload = 0xFFFF;
91  GBA_REG_TM3CNT = (GBA_TMCNT_PS);
92  GBA_REG_TM3D   = (0x0000-tmreload);
93  GBA_REG_TM3CNT = (0x00c0|GBA_TMCNT_PS);
94}
95
96/**
97 *  @brief This function is empty
98 *
99 *  @param  unused an unused parameter
100 *  @return None
101 */
102static void clock_isr_on(const rtems_irq_connect_data *unused)
103{
104    return;
105}
106
107/**
108 *  @brief This function is empty
109 *
110 *  @param  unused an unused parameter
111 *  @return None
112 */
113static void clock_isr_off(const rtems_irq_connect_data *unused)
114{
115    return;
116}
117
118/**
119 *  @brief This function is empty
120 *
121 *  @param  irq unused
122 *  @return constant 1
123 */
124static int clock_isr_is_on(const rtems_irq_connect_data *irq)
125{
126    return 1;
127}
128
129
130#include "../../../shared/clockdrv_shell.c"
Note: See TracBrowser for help on using the repository browser.