source: rtems/bsps/m68k/mvme162/clock/ckinit.c @ d7d66d7

5
Last change on this file since d7d66d7 was 7632906, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 19, 2018 at 4:35:52 AM

bsps: Move clock drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  This routine initializes the Tick Timer 2 on the MVME162 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 *  Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
15 *  EISCAT Scientific Association. M.Savitski
16 *
17 *  This material is a part of the MVME162 Board Support Package
18 *  for the RTEMS executive. Its licensing policies are those of the
19 *  RTEMS above.
20 */
21
22#include <stdlib.h>
23
24#include <bsp.h>
25#include <rtems/clockdrv.h>
26
27#define MS_COUNT          1000            /* T2's countdown constant (1 ms) */
28#define CLOCK_INT_LEVEL   6               /* T2's interrupt level */
29
30uint32_t         Clock_isrs;                  /* ISRs until next tick */
31volatile uint32_t         Clock_driver_ticks; /* ticks since initialization */
32rtems_isr_entry  Old_ticker;
33
34void Clock_exit( void );
35
36#define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
37
38/*
39 *  ISR Handler
40 */
41static rtems_isr Clock_isr(rtems_vector_number vector)
42{
43  Clock_driver_ticks += 1;
44  lcsr->timer_cnt_2 = 0;            /* clear counter */
45  lcsr->intr_clear |= 0x02000000;
46
47  if ( Clock_isrs == 1 ) {
48    rtems_clock_tick();
49    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
50  }
51  else
52    Clock_isrs -= 1;
53}
54
55static void Install_clock(rtems_isr_entry clock_isr )
56{
57
58  Clock_driver_ticks = 0;
59  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
60
61  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
62  lcsr->vector_base |= MASK_INT;   /* unmask VMEchip2 interrupts */
63  lcsr->to_ctl = 0xE7;             /* prescaler to 1 MHz (see Appendix A1) */
64  lcsr->timer_cmp_2 = MS_COUNT;
65  lcsr->timer_cnt_2 = 0;           /* clear counter */
66  lcsr->board_ctl |= 0x700;        /* increment, reset-on-compare, and */
67                                   /*   clear-overflow-cnt */
68
69  lcsr->intr_level[0] |= CLOCK_INT_LEVEL * 0x10;      /* set int level */
70  lcsr->intr_ena |= 0x02000000;       /* enable tick timer 2 interrupt */
71
72  atexit( Clock_exit );
73}
74
75void Clock_exit( void )
76{
77/* Dummy for now. See other m68k BSP's for code examples */
78}
79
80rtems_device_driver Clock_initialize(
81  rtems_device_major_number major,
82  rtems_device_minor_number minor,
83  void *pargp
84)
85{
86  Install_clock( Clock_isr );
87
88  return RTEMS_SUCCESSFUL;
89}
Note: See TracBrowser for help on using the repository browser.