source: rtems/c/src/lib/libbsp/sparc/leon2/clock/ckinit.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  Clock Tick Device Driver
3 *
4 *  This routine initializes LEON timer 1 which used for the clock tick.
5 *
6 *  The tick frequency is directly programmed to the configured number of
7 *  microseconds per tick.
8 *
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  Modified for LEON BSP
13 *  COPYRIGHT (c) 2004.
14 *  Gaisler Research.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 */
20
21#include <bsp.h>
22#include <bspopts.h>
23
24#if SIMSPARC_FAST_IDLE==1
25#define CLOCK_DRIVER_USE_FAST_IDLE
26#endif
27
28/*
29 *  The Real Time Clock Counter Timer uses this trap type.
30 */
31
32#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
33
34#define Clock_driver_support_at_tick()
35
36#define Clock_driver_support_install_isr( _new, _old ) \
37  do { \
38    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
39  } while(0)
40
41extern int CLOCK_SPEED;
42
43#define Clock_driver_support_initialize_hardware() \
44  do { \
45    LEON_REG.Timer_Reload_1 = rtems_configuration_get_microseconds_per_tick() - 1; \
46    \
47    LEON_REG.Timer_Control_1 = ( \
48      LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |  \
49        LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \
50        LEON_REG_TIMER_COUNTER_LOAD_COUNTER  \
51    ); \
52  } while (0)
53
54#define Clock_driver_support_shutdown_hardware() \
55  do { \
56    LEON_Mask_interrupt( LEON_INTERRUPT_TIMER1 ); \
57    LEON_REG.Timer_Control_1 = 0; \
58  } while (0)
59
60uint32_t bsp_clock_nanoseconds_since_last_tick(void)
61{
62  uint32_t clicks;
63  uint32_t usecs;
64
65  clicks = LEON_REG.Timer_Counter_1;
66
67  if ( LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 ) ) {
68    clicks = LEON_REG.Timer_Counter_1;
69    usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
70  } else {
71    usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
72  }
73  return usecs * 1000;
74}
75
76#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
77
78#include "../../../shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.