source: rtems/c/src/lib/libbsp/shared/clockdrv_shell.h @ a36094f

4.115
Last change on this file since a36094f was 56c6888, checked in by Joel Sherrill <joel.sherrill@…>, on 10/07/14 at 15:01:39

libbsp/shared/clockdrv_shell.h: Fix warning

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup bsp_clock
5 *
6 * @brief Clock Tick Device Driver Shell
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2012.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#include <stdlib.h>
19
20#include <bsp.h>
21
22/**
23 * @defgroup bsp_clock Clock Support
24 *
25 * @ingroup bsp_shared
26 *
27 * @brief Clock support
28 *
29 */
30#if CLOCK_DRIVER_USE_FAST_IDLE && CLOCK_DRIVER_ISRS_PER_TICK
31#error "clockdrv_shell.h: Fast Idle PLUS n ISRs per tick is not supported"
32#endif
33
34/**
35 * @brief This method is rarely used so default it.
36 */
37#ifndef Clock_driver_support_find_timer
38  #define Clock_driver_support_find_timer()
39#endif
40
41/**
42 * @brief ISRs until next clock tick
43 */
44#if CLOCK_DRIVER_ISRS_PER_TICK
45  volatile uint32_t  Clock_driver_isrs;
46#endif
47
48/**
49 * @brief Clock ticks since initialization
50 */
51volatile uint32_t    Clock_driver_ticks;
52
53void Clock_exit( void );
54
55/**
56 *  @brief Clock_isr
57 *
58 *  This is the clock tick interrupt handler.
59 *
60 *  @param vector Vector number.
61 *
62 *  Output parameters:  NONE
63 *
64 *  Return values:      NONE
65 */
66#if defined(BSP_FEATURE_IRQ_EXTENSION) || \
67    (CPU_SIMPLE_VECTORED_INTERRUPTS != TRUE)
68void Clock_isr(void *arg);
69void Clock_isr(void *arg)
70{
71#else
72rtems_isr Clock_isr(rtems_vector_number vector);
73rtems_isr Clock_isr(
74  rtems_vector_number vector
75)
76{
77#endif
78  /*
79   *  Accurate count of ISRs
80   */
81  Clock_driver_ticks += 1;
82
83  #if CLOCK_DRIVER_USE_FAST_IDLE
84    do {
85      rtems_clock_tick();
86    } while (
87      _Thread_Heir == _Thread_Executing
88        && _Thread_Executing->Start.entry_point
89          == (Thread_Entry) rtems_configuration_get_idle_task()
90    );
91
92    Clock_driver_support_at_tick();
93    return;
94  #else
95    /*
96     *  Do the hardware specific per-tick action.
97     *
98     *  The counter/timer may or may not be set to automatically reload.
99     */
100    Clock_driver_support_at_tick();
101
102    #if CLOCK_DRIVER_ISRS_PER_TICK
103      /*
104       *  The driver is multiple ISRs per clock tick.
105       */
106      if ( !Clock_driver_isrs ) {
107        rtems_clock_tick();
108
109        Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK;
110      }
111      Clock_driver_isrs--;
112    #else
113      /*
114       *  The driver is one ISR per clock tick.
115       */
116      rtems_clock_tick();
117    #endif
118  #endif
119}
120
121/**
122 *  @brief Clock_exit
123 *
124 *  This routine allows the clock driver to exit by masking the interrupt and
125 *  disabling the clock's counter.
126 *
127 *  Input parameters:   NONE
128 *
129 *  Output parameters:  NONE
130 *
131 *  Return values:      NONE
132 *
133 */
134
135void Clock_exit( void )
136{
137  Clock_driver_support_shutdown_hardware();
138
139  /* do not restore old vector */
140}
141
142/**
143 * @brief Clock_initialize
144 *
145 * This routine initializes the clock driver.
146 *
147 * @param[in] major Clock device major number.
148 * @param[in] minor Clock device minor number.
149 * @param[in] parg  Pointer to optional device driver arguments
150 *
151 * @retval rtems_device_driver status code
152 */
153
154rtems_device_driver Clock_initialize(
155  rtems_device_major_number major,
156  rtems_device_minor_number minor,
157  void *pargp
158)
159{
160  rtems_isr_entry  Old_ticker;
161
162  Clock_driver_ticks = 0;
163
164  /*
165   *  Find timer -- some BSPs search buses for hardware timer
166   */
167  Clock_driver_support_find_timer();
168
169  /*
170   *  Install vector
171   */
172  (void) Old_ticker;
173  Clock_driver_support_install_isr( Clock_isr, Old_ticker );
174
175  #if defined(Clock_driver_nanoseconds_since_last_tick)
176    rtems_clock_set_nanoseconds_extension(
177      Clock_driver_nanoseconds_since_last_tick
178    );
179  #endif
180
181  /*
182   *  Now initialize the hardware that is the source of the tick ISR.
183   */
184  Clock_driver_support_initialize_hardware();
185
186  atexit( Clock_exit );
187
188  /*
189   *  If we are counting ISRs per tick, then initialize the counter.
190   */
191  #if CLOCK_DRIVER_ISRS_PER_TICK
192    Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
193  #endif
194
195  return RTEMS_SUCCESSFUL;
196}
Note: See TracBrowser for help on using the repository browser.