source: rtems/c/src/lib/libcpu/arm/pxa255/clock/clock.c @ 389afd9

4.104.115
Last change on this file since 389afd9 was 389afd9, checked in by Joel Sherrill <joel.sherrill@…>, on 08/04/09 at 11:59:20

2009-08-04 Xi Yang <hiyangxi@…>

  • pxa255/clock/clock.c: Move parentheses to improve math. More tests run.
  • Property mode set to 100755
File size: 2.5 KB
Line 
1/*
2 *  By Yang Xi <hiyangxi@gmail.com>
3 *  PXA255 clock specific using the System Timer
4 *
5 *  RTEMS uses IRQ 26 as Clock Source
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#include <rtems.h>
15#include <rtems/clockdrv.h>
16#include <rtems/libio.h>
17
18#include <stdlib.h>
19#include <bsp.h>
20#include <bspopts.h>
21#include <irq.h>
22#include <pxa255.h>
23
24#if ON_SKYEYE==1
25  #define CLOCK_DRIVER_USE_FAST_IDLE
26#endif
27
28static unsigned long period_num;
29
30/**
31 * Enables clock interrupt.
32 *
33 * If the interrupt is always on, this can be a NOP.
34 */
35static void clock_isr_on(const rtems_irq_connect_data *unused)
36{
37  /*Clear the interrupt bit */
38  XSCALE_OS_TIMER_TSR = 0x1;
39
40  /* enable timer interrupt */
41  XSCALE_OS_TIMER_IER |= 0x1;
42
43  period_num = (TIMER_RATE* Configuration.microseconds_per_tick)/10000;
44
45  XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num;
46}
47
48/**
49 * Disables clock interrupts
50 *
51 * If the interrupt is always on, this can be a NOP.
52 */
53static void clock_isr_off(const rtems_irq_connect_data *unused)
54{
55  /*Clear the interrupt bit */
56  XSCALE_OS_TIMER_TSR = 0x1;
57  /* disable timer interrupt*/
58  XSCALE_OS_TIMER_IER &= ~0x1;
59  return;
60}
61
62/**
63 * Tests to see if clock interrupt is enabled, and returns 1 if so.
64 * If interrupt is not enabled, returns 0.
65 *
66 * If the interrupt is always on, this always returns 1.
67 */
68static int clock_isr_is_on(const rtems_irq_connect_data *irq)
69{
70    /* check timer interrupt */
71  return XSCALE_OS_TIMER_IER & 0x1;
72}
73
74rtems_isr Clock_isr(rtems_vector_number vector);
75
76/* Replace the first value with the clock's interrupt name. */
77rtems_irq_connect_data clock_isr_data = {
78  XSCALE_IRQ_OS_TIMER,
79  (rtems_irq_hdl)Clock_isr,
80  clock_isr_on,
81  clock_isr_off,
82  clock_isr_is_on,
83  3,     /* unused for ARM cpus */
84  0      /* unused for ARM cpus */
85};
86
87
88#define Clock_driver_support_install_isr( _new, _old ) \
89  BSP_install_rtems_irq_handler(&clock_isr_data)
90
91void Clock_driver_support_initialize_hardware(void)
92{
93  period_num = (TIMER_RATE* Configuration.microseconds_per_tick)/10000;
94}
95
96
97#define CLOCK_VECTOR 0
98
99#define Clock_driver_support_at_tick() \
100  do { \
101    /* read the status to clear the int */ \
102    XSCALE_OS_TIMER_TSR = 0x1; \
103    \
104    /*Add the match register*/ \
105    XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num; \
106  } while (0)
107
108void Clock_driver_support_shutdown_hardware( void )
109{
110  BSP_remove_rtems_irq_handler(&clock_isr_data);
111}
112
113#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.