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

Last change on this file since f3b29236 was f3b29236, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 18, 2017 at 6:22:38 AM

bsps: Clock_driver_support_install_isr()

Remove old ISR parameter since is not used by the clock driver shell.
Make an implementation optional.

Update #3139.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon2
4 * @brief Clock Tick Device Driver
5 *
6 *  This routine initializes LEON timer 1 which used for the clock tick.
7 *
8 *  The tick frequency is directly programmed to the configured number of
9 *  microseconds per tick.
10 */
11
12/*
13 *  COPYRIGHT (c) 1989-2008.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  Modified for LEON BSP
17 *  COPYRIGHT (c) 2004.
18 *  Gaisler Research.
19 *
20 *  The license and distribution terms for this file may be
21 *  found in the file LICENSE in this distribution or at
22 *  http://www.rtems.org/license/LICENSE.
23 */
24
25#include <bsp.h>
26#include <bspopts.h>
27#include <rtems/timecounter.h>
28#include <rtems/score/sparcimpl.h>
29
30static rtems_timecounter_simple leon2_tc;
31
32static uint32_t leon2_tc_get( rtems_timecounter_simple *tc )
33{
34  return LEON_REG.Timer_Counter_1;
35}
36
37static bool leon2_tc_is_pending( rtems_timecounter_simple *tc )
38{
39  return LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 );
40}
41
42static uint32_t leon2_tc_get_timecount( struct timecounter *tc )
43{
44  return rtems_timecounter_simple_downcounter_get(
45    tc,
46    leon2_tc_get,
47    leon2_tc_is_pending
48  );
49}
50
51static void leon2_tc_at_tick( rtems_timecounter_simple *tc )
52{
53  /* Nothing to do */
54}
55
56static void leon2_tc_tick( void )
57{
58  rtems_timecounter_simple_downcounter_tick(
59    &leon2_tc,
60    leon2_tc_get,
61    leon2_tc_at_tick
62  );
63}
64
65/*
66 *  The Real Time Clock Counter Timer uses this trap type.
67 */
68
69#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
70
71#define Clock_driver_support_install_isr( _new ) \
72  set_vector( _new, CLOCK_VECTOR, 1 )
73
74extern int CLOCK_SPEED;
75
76#define Clock_driver_support_initialize_hardware() \
77  do { \
78    LEON_REG.Timer_Reload_1 = \
79        rtems_configuration_get_microseconds_per_tick() - 1; \
80    \
81    LEON_REG.Timer_Control_1 = ( \
82      LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |  \
83        LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \
84        LEON_REG_TIMER_COUNTER_LOAD_COUNTER  \
85    ); \
86    rtems_timecounter_simple_install( \
87      &leon2_tc, \
88      1000000, \
89      rtems_configuration_get_microseconds_per_tick(), \
90      leon2_tc_get_timecount \
91    ); \
92  } while (0)
93
94#define Clock_driver_support_shutdown_hardware() \
95  do { \
96    LEON_Mask_interrupt( LEON_INTERRUPT_TIMER1 ); \
97    LEON_REG.Timer_Control_1 = 0; \
98  } while (0)
99
100#define Clock_driver_timecounter_tick() leon2_tc_tick()
101
102#include "../../../shared/clockdrv_shell.h"
103
104SPARC_COUNTER_DEFINITION;
Note: See TracBrowser for help on using the repository browser.