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

4.9
Last change on this file since 9ec55e63 was 9ec55e63, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 4, 2011 at 2:07:17 PM

2011-03-04 Joel Sherrill <joel.sherrilL@…>

PR 1748/bsps

  • clock/ckinit.c: When the clock tick generates an interrupt WHILE we have interrupts disabled doing a get TOD or uptime, the get nanoseconds handler was returning a bogusly large number.
  • 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 *  $Id$
21 */
22
23#include <bsp.h>
24#include <bspopts.h>
25
26#if SIMSPARC_FAST_IDLE==1
27#define CLOCK_DRIVER_USE_FAST_IDLE
28#endif
29
30/*
31 *  The Real Time Clock Counter Timer uses this trap type.
32 */
33
34#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
35
36#define Clock_driver_support_at_tick()
37
38#define Clock_driver_support_install_isr( _new, _old ) \
39  do { \
40    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
41  } while(0)
42
43extern int CLOCK_SPEED;
44
45#define Clock_driver_support_initialize_hardware() \
46  do { \
47    LEON_REG.Timer_Reload_1 = rtems_configuration_get_microseconds_per_tick() - 1; \
48    \
49    LEON_REG.Timer_Control_1 = ( \
50      LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |  \
51        LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \
52        LEON_REG_TIMER_COUNTER_LOAD_COUNTER  \
53    ); \
54  } while (0)
55
56#define Clock_driver_support_shutdown_hardware() \
57  do { \
58    LEON_Mask_interrupt( LEON_INTERRUPT_TIMER1 ); \
59    LEON_REG.Timer_Control_1 = 0; \
60  } while (0)
61
62
63uint32_t bsp_clock_nanoseconds_since_last_tick(void)
64{
65  uint32_t clicks;
66  uint32_t usecs;
67
68  if ( LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 ) ) {
69    clicks = LEON_REG.Timer_Counter_1;
70    usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
71  } else {
72    usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
73  }
74  return usecs * 1000;
75}
76
77#define Clock_driver_nanoseconds_since_last_tick \
78        bsp_clock_nanoseconds_since_last_tick
79
80#include "../../../shared/clockdrv_shell.c"
Note: See TracBrowser for help on using the repository browser.