source: rtems/c/src/lib/libbsp/lm32/shared/clock/ckinit.c @ c030edd

5
Last change on this file since c030edd was 30be024a, checked in by Sebastian Huber <sebastian.huber@…>, on 08/03/17 at 12:48:04

Optional Clock_driver_support_shutdown_hardware()

Make Clock_driver_support_shutdown_hardware() optional. This avoids
the atexit() support on memory constrained targets.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  Clock device driver for Lattice Mico32 (lm32).
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2009.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 *
13 *  Jukka Pietarinen <jukka.pietarinen@mrf.fi>, 2008,
14 *  Micro-Research Finland Oy
15 */
16
17#include <bsp.h>
18#include "../include/system_conf.h"
19#include "clock.h"
20#include "bspopts.h"
21
22#if LM32_ON_SIMULATOR
23#define CLOCK_DRIVER_USE_FAST_IDLE 1
24#endif
25
26static inline int clockread(unsigned int reg)
27{
28  return *((int*)(TIMER0_BASE_ADDRESS + reg));
29}
30
31static inline void clockwrite(unsigned int reg, int value)
32{
33  *((int*)(TIMER0_BASE_ADDRESS + reg)) = value;
34}
35
36/*
37 *  The interrupt vector number associated with the clock tick device
38 *  driver.
39 */
40#define CLOCK_VECTOR    ( TIMER0_IRQ )
41#define CLOCK_IRQMASK   ( 1 << CLOCK_VECTOR )
42
43#define Clock_driver_support_at_tick() \
44  do { \
45    /* Clear overflow flag */ \
46    clockwrite(LM32_CLOCK_SR, 0); \
47    lm32_interrupt_ack(CLOCK_IRQMASK); \
48  } while (0)
49
50#define Clock_driver_support_install_isr(_new, _old ) \
51  do { \
52    _old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \
53  } while (0)
54
55static void Clock_driver_support_initialize_hardware(void)
56{
57  /* Set clock period */
58  clockwrite(LM32_CLOCK_PERIOD,
59             (CPU_FREQUENCY /
60              (1000000 / rtems_configuration_get_microseconds_per_tick())));
61
62  /* Enable clock interrupts and start in continuous mode */
63  clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_ITO |
64             LM32_CLOCK_CR_CONT |
65             LM32_CLOCK_CR_START);
66
67  lm32_interrupt_unmask(CLOCK_IRQMASK);
68}
69
70#define Clock_driver_support_shutdown_hardware() \
71  do { \
72    /* Disable clock interrupts and stop */ \
73    lm32_interrupt_unmask(CLOCK_IRQMASK); \
74    clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP); \
75  } while (0)
76
77#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
78
79#include "../../../shared/clockdrv_shell.h"
80
Note: See TracBrowser for help on using the repository browser.