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

5
Last change on this file since bb99cd0d was bb99cd0d, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 5, 2019 at 6:22:33 PM

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.7 KB
Line 
1/*
2 *  This routine initailizes the periodic interrupt timer on
3 *  the Motorola 68332.
4 */
5
6/*
7 *  COPYRIGHT (c) 1989-2014.
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
15#include <stdlib.h>
16#include <bsp.h>
17#include <mrm332.h>
18#include <rtems/clockdrv.h>
19#include <rtems/m68k/sim.h>
20
21#define CLOCK_VECTOR   MRM_PIV
22
23uint32_t                Clock_isrs;         /* ISRs until next tick */
24volatile uint32_t       Clock_driver_ticks; /* ticks since initialization */
25static rtems_isr_entry  Old_ticker;
26
27static void Clock_exit( void );
28
29static rtems_isr Clock_isr(rtems_vector_number vector)
30{
31  Clock_driver_ticks += 1;
32
33  if ( Clock_isrs == 1 ) {
34    rtems_clock_tick();
35    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
36  }
37  else
38    Clock_isrs -= 1;
39}
40
41static void Install_clock(rtems_isr_entry clock_isr)
42{
43  Clock_driver_ticks = 0;
44  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
45
46  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
47
48  /* enable 1mS interrupts */
49  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );/* load counter */
50  *PICR = (unsigned short int)                     /* enable interrupt */
51    ( SAM(ISRL_PIT,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
52
53  atexit( Clock_exit );
54}
55
56void Clock_exit( void )
57{
58  /* shutdown the periodic interrupt */
59  *PICR = (unsigned short int)
60    ( SAM(0,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
61  /*     ^^ zero disables interrupt */
62
63  /* do not restore old vector */
64}
65
66void _Clock_Initialize( void )
67{
68  Install_clock( Clock_isr );
69}
Note: See TracBrowser for help on using the repository browser.