source: rtems/c/src/lib/libbsp/m68k/gen68302/clock/ckinit.c @ 9e86dd7d

4.104.114.84.95
Last change on this file since 9e86dd7d was 9e86dd7d, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 7, 1995 at 1:27:28 AM

incorporated mc68302 support

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes Timer 1 for an MC68302.
4 *  The tick frequency is 1 millisecond.
5 *
6 *  Input parameters:  NONE
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#include <stdlib.h>                     /* for atexit() */
22
23#include <rtems.h>
24#include <bsp.h>
25#include <clockdrv.h>
26#include "m68302.h"
27
28
29#define TMR1_VAL (  RBIT_TMR_RST        /* software reset the timer */\
30                  | RBIT_TMR_ICLK_MASTER16 /* master clock divided by 16 */\
31                  | RBIT_TMR_FRR        /* restart timer after ref reached */\
32                  | RBIT_TMR_ORI)       /* enable interrupt when ref reached */
33#define TRR1_VAL 1000                   /* 1000 ticks @ 16MHz/16
34                                         *    = 1 millisecond tick.
35                                         */
36
37/*
38 *  Clock_driver_ticks is a monotonically increasing counter of the
39 *  number of clock ticks since the driver was initialized.
40 */
41volatile rtems_unsigned32 Clock_driver_ticks;
42
43/*
44 *  Clock_isrs is the number of clock ISRs until the next invocation of
45 *  the RTEMS clock tick routine.  The clock tick device driver
46 *  gets an interrupt once a millisecond and counts down until the
47 *  length of time between the user configured microseconds per tick
48 *  has passed.
49 */
50rtems_unsigned32 Clock_isrs;
51
52
53rtems_device_driver Clock_initialize( 
54  rtems_device_major_number major,
55  rtems_device_minor_number minor,
56  void *pargp,
57  rtems_id tid,
58  rtems_unsigned32 *rval
59)
60{
61  Install_clock( Clock_isr );
62}
63
64
65void Install_clock(
66  rtems_isr_entry clock_isr
67)
68{
69
70  Clock_driver_ticks = 0;
71  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
72
73  if ( BSP_Configuration.ticks_per_timeslice ) {
74/*  set_vector( clock_isr, 137, 1 );*/
75
76    m302.reg.trr1 = TRR1_VAL;           /* set timer reference register */
77    m302.reg.tmr1 = TMR1_VAL;           /* set timer mode register & enable */
78    /*
79     * Enable TIMER1 interrupts only.
80     */
81    m302.reg.imr  = RBIT_IMR_TIMER1;    /* set 68302 int-mask to allow ints */
82
83    atexit( Clock_exit );
84  }
85}
86
87
88void Clock_exit( void )
89{
90  if ( BSP_Configuration.ticks_per_timeslice ) {
91    /* TODO: figure out what to do here */
92    /* do not restore old vector */
93  }
94}
Note: See TracBrowser for help on using the repository browser.