source: rtems/bsps/m68k/mvme147/clock/ckinit.c @ bb99cd0d

5
Last change on this file since bb99cd0d was bb99cd0d, checked in by Sebastian Huber <sebastian.huber@…>, on 12/05/19 at 18:22:33

clock: Simplify driver initialization

Use a system initialization handler instead of a legacy IO driver.

Update #3834.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  This routine initializes the Tick Timer 2 on the MVME147 board.
3 *  The tick frequency is 1 millisecond.
4 */
5
6/*
7 *  COPYRIGHT (c) 1989-1999.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.org/license/LICENSE.
13 *
14 *  MVME147 port for TNI - Telecom Bretagne
15 *  by Dominique LE CAMPION (Dominique.LECAMPION@enst-bretagne.fr)
16 *  May 1996
17 */
18
19#include <stdlib.h>
20
21#include <bsp.h>
22#include <rtems/clockdrv.h>
23
24#define MS_COUNT          65376    /* 1ms */
25/* MS_COUNT = 0x10000 - 1e-3/6.25e-6 */
26#define CLOCK_INT_LEVEL   6               /* T2's interrupt level */
27
28uint32_t         Clock_isrs;                  /* ISRs until next tick */
29volatile uint32_t         Clock_driver_ticks; /* ticks since initialization */
30rtems_isr_entry  Old_ticker;
31
32static void Clock_exit( void );
33
34/*
35 *  ISR Handler
36 */
37static rtems_isr Clock_isr(rtems_vector_number vector)
38{
39  Clock_driver_ticks += 1;
40  pcc->timer2_int_control |= 0x80; /* Acknowledge interr. */
41
42  if (Clock_isrs == 1) {
43    rtems_clock_tick();
44    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
45  }
46  else
47    Clock_isrs -= 1;
48}
49
50static void Install_clock(rtems_isr_entry clock_isr )
51{
52
53  Clock_driver_ticks = 0;
54  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
55
56  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_2_VECTOR, 1 );
57
58  pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
59  pcc->timer2_preload = MS_COUNT;
60  /* write preload value */
61  pcc->timer2_control = 0x07; /* clear T2 overflow counter, enable counter */
62  pcc->timer2_int_control = CLOCK_INT_LEVEL|0x08;
63  /* Enable Timer 2 and set its int. level */
64
65  atexit( Clock_exit );
66}
67
68void Clock_exit( void )
69{
70  pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
71}
72
73void _Clock_Initialize( void )
74{
75  Install_clock( Clock_isr );
76}
Note: See TracBrowser for help on using the repository browser.