source: rtems/c/src/lib/libbsp/m68k/idp/clock/ckinit.c @ 88d594a

4.104.114.84.95
Last change on this file since 88d594a was 88d594a, checked in by Joel Sherrill <joel.sherrill@…>, on May 24, 1995 at 9:39:42 PM

Fully tested on all in-house targets

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*  Clock_init()
2 *
3 *
4 *  This is modified by Doug McBride to get it to work for the MC68EC040
5 *  IDP board.  The below comments are kept to show that some prior work
6 *  was done in the area and the modifications performed was application
7 *  specific for the IDP board to port it to.
8 *
9 *  This routine initializes the mc68230 on the MC68EC040 board.
10 *  The tick frequency is 40 milliseconds.
11 *
12 *  Input parameters:  NONE
13 *
14 *  Output parameters:  NONE
15 *
16 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
17 *  On-Line Applications Research Corporation (OAR).
18 *  All rights assigned to U.S. Government, 1994.
19 *
20 *  This material may be reproduced by or for the U.S. Government pursuant
21 *  to the copyright license under the clause at DFARS 252.227-7013.  This
22 *  notice must appear in all copies of this file and its derivatives.
23 *
24 *  $Id$
25 */
26
27#include <stdlib.h>
28
29#include <rtems.h>
30#include <clockdrv.h>
31#include <bsp.h>
32
33rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
34volatile rtems_unsigned32 Clock_driver_ticks;
35                                    /* ticks since initialization */
36rtems_isr_entry  Old_ticker;
37
38extern rtems_configuration_table Configuration;
39extern void led_putnum();
40void Disable_clock();
41
42#define TIMER_VECTOR 0x4D
43
44rtems_device_driver Clock_initialize( 
45  rtems_device_major_number major,
46  rtems_device_minor_number minor,
47  void *pargp,
48  rtems_id tid,
49  rtems_unsigned32 *rval
50)
51{
52  Install_clock( Clock_isr );
53}
54
55void ReInstall_clock( clock_isr )
56rtems_isr_entry clock_isr;
57{
58  rtems_unsigned32 isrlevel = 0 ;
59
60  rtems_interrupt_disable( isrlevel );
61   (void) set_vector( clock_isr, TIMER_VECTOR, 1 );
62  rtems_interrupt_enable( isrlevel );
63}
64
65/* The following was added for debugging purposes */
66void Disable_clock()
67{
68        /* Disable timer */
69        MC68230_WRITE (TCR, 0x00);
70}
71
72void Install_clock( clock_isr )
73rtems_isr_entry clock_isr;
74{
75  Clock_driver_ticks = 0;
76  Clock_isrs = (int)(Configuration.microseconds_per_tick / 1000);
77
78  if ( Configuration.ticks_per_timeslice ) {
79/*    led_putnum('c'); * for debugging purposes */
80    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );
81
82        /* Disable timer for initialization */
83        MC68230_WRITE (TCR, 0x00);
84
85        /* some PI/T initialization stuff here -- see comment in the ckisr.c
86           file in this directory to understand why I use the values that I do */
87        /* Set up the interrupt vector on the MC68230 chip:
88                TIVR = TIMER_VECTOR; */
89        MC68230_WRITE (TIVR, TIMER_VECTOR);
90
91        /* Set CPRH through CPRL to 193 (not 203) decimal for countdown--see ckisr.c
92                CPRH = 0x00;
93                CPRM = 0x00;
94                CPRL = 0xC1; */
95        MC68230_WRITE (CPRH, 0x00);
96        MC68230_WRITE (CPRM, 0x00);
97        MC68230_WRITE (CPRL, 0xC1);
98
99        /* Enable timer and use it as an external periodic interrupt generator
100                TCR = 0xA1; */
101/*    led_putnum('a'); * for debugging purposes */
102        MC68230_WRITE (TCR, 0xA1);
103
104        /*
105         *  Schedule the clock cleanup routine to execute if the application exits.
106         */
107    atexit( Clock_exit );
108  } 
109}
110
111void Clock_exit( void )
112{
113  rtems_unsigned8 data;
114
115  if ( Configuration.ticks_per_timeslice ) {
116
117        /* disable timer
118                data = TCR;
119                TCR = (data & 0xFE); */
120        MC68230_READ (TCR, data);
121        MC68230_WRITE (TCR, (data & 0xFE));
122
123    /* do not restore old vector */
124  }
125}
Note: See TracBrowser for help on using the repository browser.