source: rtems/c/src/lib/libbsp/sparc/erc32/clock/ckinit.c @ ba737a9

4.104.114.95
Last change on this file since ba737a9 was 0e58c4f, checked in by Joel Sherrill <joel.sherrill@…>, on 05/07/08 at 17:40:52

2008-05-07 Joel Sherrill <joel.sherrill@…>

  • clock/ckinit.c: Add nanoseconds clock tick granularity support.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  Clock Tick Device Driver
3 *
4 *  This routine initializes the Real Time Clock Counter Timer which is
5 *  part of the MEC on the ERC32 CPU.
6 *
7 *  The tick frequency is directly programmed to the configured number of
8 *  microseconds per tick.
9 *
10 *  COPYRIGHT (c) 1989-2008.
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 *  Ported to ERC32 implementation of the SPARC by On-Line Applications
18 *  Research Corporation (OAR) under contract to the European Space
19 *  Agency (ESA).
20 *
21 *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
22 *  European Space Agency.
23 *
24 *  $Id$
25 */
26
27#include <bsp.h>
28#include <bspopts.h>
29
30#if SIMSPARC_FAST_IDLE==1
31#define CLOCK_DRIVER_USE_FAST_IDLE
32#endif
33
34/*
35 *  The Real Time Clock Counter Timer uses this trap type.
36 */
37
38#define CLOCK_VECTOR ERC32_TRAP_TYPE( ERC32_INTERRUPT_REAL_TIME_CLOCK )
39
40#define Clock_driver_support_at_tick()
41
42#define Clock_driver_support_install_isr( _new, _old ) \
43  do { \
44    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
45  } while(0)
46
47extern int CLOCK_SPEED;
48
49uint32_t bsp_clock_nanoseconds_since_last_tick(void)
50{
51  uint32_t clicks;
52
53  clicks = ERC32_MEC.Real_Time_Clock_Counter;
54
55  return (uint32_t)
56    (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000;
57}
58
59#define Clock_driver_nanoseconds_since_last_tick \
60  bsp_clock_nanoseconds_since_last_tick
61
62#define Clock_driver_support_initialize_hardware() \
63  do { \
64    /* approximately 1 us per countdown */ \
65    ERC32_MEC.Real_Time_Clock_Scalar  = CLOCK_SPEED - 1; \
66    ERC32_MEC.Real_Time_Clock_Counter = \
67      rtems_configuration_get_microseconds_per_tick(); \
68    \
69    ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
70      ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
71        ERC32_MEC_TIMER_COUNTER_LOAD_SCALER | \
72            ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER \
73    ); \
74    \
75    ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
76      ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
77            ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO \
78    ); \
79  } while (0)
80
81#define Clock_driver_support_shutdown_hardware() \
82  do { \
83    ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK ); \
84     \
85    ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
86      ERC32_MEC_TIMER_COUNTER_DISABLE_COUNTING \
87    ); \
88  } while (0)
89
90#include "../../../shared/clockdrv_shell.c"
91
Note: See TracBrowser for help on using the repository browser.