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

4.115
Last change on this file since 296c74e6 was 296c74e6, checked in by Daniel Ramirez <javamonn@…>, on 12/09/13 at 19:37:48

doxygen: refactored doxygen in libbsp to illustrate new rule set

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