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

Last change on this file since f3b29236 was f3b29236, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 18, 2017 at 6:22:38 AM

bsps: Clock_driver_support_install_isr()

Remove old ISR parameter since is not used by the clock driver shell.
Make an implementation optional.

Update #3139.

  • 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 ) \
51  set_vector( _new, CLOCK_VECTOR, 1 )
52
53static void Clock_driver_support_initialize_hardware(void)
54{
55  /* Set clock period */
56  clockwrite(LM32_CLOCK_PERIOD,
57             (CPU_FREQUENCY /
58              (1000000 / rtems_configuration_get_microseconds_per_tick())));
59
60  /* Enable clock interrupts and start in continuous mode */
61  clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_ITO |
62             LM32_CLOCK_CR_CONT |
63             LM32_CLOCK_CR_START);
64
65  lm32_interrupt_unmask(CLOCK_IRQMASK);
66}
67
68#define Clock_driver_support_shutdown_hardware() \
69  do { \
70    /* Disable clock interrupts and stop */ \
71    lm32_interrupt_unmask(CLOCK_IRQMASK); \
72    clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP); \
73  } while (0)
74
75#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
76
77#include "../../../shared/clockdrv_shell.h"
78
Note: See TracBrowser for help on using the repository browser.