source: rtems/c/src/lib/libbsp/m68k/mrm332/clock/ckinit.c @ 51995b69

4.115
Last change on this file since 51995b69 was 51995b69, checked in by Joel Sherrill <joel.sherrill@…>, on 10/19/14 at 22:14:07

m68k/mrm332: Move include of <rtems/m68k/sim.h>

This file defines at least the POW() macro which pollutes the
public name space and causes warnings in at least the paranoia
sample application.

  • Property mode set to 100644
File size: 1.8 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/m68k/sim.h>
19
20#define CLOCK_VECTOR   MRM_PIV
21
22uint32_t                Clock_isrs;         /* ISRs until next tick */
23volatile uint32_t       Clock_driver_ticks; /* ticks since initialization */
24static rtems_isr_entry  Old_ticker;
25
26void Clock_exit( void );
27
28static rtems_isr Clock_isr(rtems_vector_number vector)
29{
30  Clock_driver_ticks += 1;
31
32  if ( Clock_isrs == 1 ) {
33    rtems_clock_tick();
34    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
35  }
36  else
37    Clock_isrs -= 1;
38}
39
40static void Install_clock(rtems_isr_entry clock_isr)
41{
42  Clock_driver_ticks = 0;
43  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
44
45  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
46
47  /* enable 1mS interrupts */
48  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );/* load counter */
49  *PICR = (unsigned short int)                     /* enable interrupt */
50    ( SAM(ISRL_PIT,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
51
52  atexit( Clock_exit );
53}
54
55void Clock_exit( void )
56{
57  /* shutdown the periodic interrupt */
58  *PICR = (unsigned short int)
59    ( SAM(0,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
60  /*     ^^ zero disables interrupt */
61
62  /* do not restore old vector */
63}
64
65rtems_device_driver Clock_initialize(
66  rtems_device_major_number major,
67  rtems_device_minor_number minor,
68  void *pargp
69)
70{
71  Install_clock( Clock_isr );
72
73  return RTEMS_SUCCESSFUL;
74}
Note: See TracBrowser for help on using the repository browser.