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 04/19/18 at 04:35:52

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
RevLine 
[88867e89]1/*
[ac7d5ef0]2 *  This routine initializes the Tick Timer 2 on the MVME162 board.
3 *  The tick frequency is 1 millisecond.
[88867e89]4 */
5
6/*
[08311cc3]7 *  COPYRIGHT (c) 1989-1999.
[ac7d5ef0]8 *  On-Line Applications Research Corporation (OAR).
9 *
[98e4ebf5]10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
[c499856]12 *  http://www.rtems.org/license/LICENSE.
[ac7d5ef0]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>
[f6c92120]25#include <rtems/clockdrv.h>
[ac7d5ef0]26
27#define MS_COUNT          1000            /* T2's countdown constant (1 ms) */
[c6fb8e90]28#define CLOCK_INT_LEVEL   6               /* T2's interrupt level */
[ac7d5ef0]29
[629e12a]30uint32_t         Clock_isrs;                  /* ISRs until next tick */
31volatile uint32_t         Clock_driver_ticks; /* ticks since initialization */
[ac7d5ef0]32rtems_isr_entry  Old_ticker;
33
[3a4ae6c]34void Clock_exit( void );
[6128a4a]35
[3a4ae6c]36#define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
[6128a4a]37
[3a4ae6c]38/*
39 *  ISR Handler
40 */
[88867e89]41static rtems_isr Clock_isr(rtems_vector_number vector)
[ac7d5ef0]42{
[3a4ae6c]43  Clock_driver_ticks += 1;
44  lcsr->timer_cnt_2 = 0;            /* clear counter */
45  lcsr->intr_clear |= 0x02000000;
[ac7d5ef0]46
[3a4ae6c]47  if ( Clock_isrs == 1 ) {
48    rtems_clock_tick();
[12bd47e]49    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
[3a4ae6c]50  }
[6128a4a]51  else
[3a4ae6c]52    Clock_isrs -= 1;
[ac7d5ef0]53}
54
[88867e89]55static void Install_clock(rtems_isr_entry clock_isr )
[ac7d5ef0]56{
57
58  Clock_driver_ticks = 0;
[12bd47e]59  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
[ac7d5ef0]60
[0dd1d44]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 */
[ac7d5ef0]68
[0dd1d44]69  lcsr->intr_level[0] |= CLOCK_INT_LEVEL * 0x10;      /* set int level */
70  lcsr->intr_ena |= 0x02000000;       /* enable tick timer 2 interrupt */
[ac7d5ef0]71
[0dd1d44]72  atexit( Clock_exit );
[3a4ae6c]73}
[ac7d5ef0]74
75void Clock_exit( void )
76{
77/* Dummy for now. See other m68k BSP's for code examples */
78}
[3a4ae6c]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 );
[6128a4a]87
[3a4ae6c]88  return RTEMS_SUCCESSFUL;
89}
Note: See TracBrowser for help on using the repository browser.