source: rtems/c/src/lib/libcpu/arm/at91rm9200/clock/clock.c @ 30be024a

5
Last change on this file since 30be024a 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: 2.8 KB
Line 
1/*
2 *  AT91RM9200 clock specific using the System Timer
3 */
4
5/*
6 *  Copyright (c) 2003 by Cogent Computer Systems
7 *  Written by Mike Kelly <mike@cogcomp.com>
8 *         and Jay Monkman <jtm@lopingdog.com>
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
15#include <rtems.h>
16#include <rtems/clockdrv.h>
17#include <rtems/libio.h>
18
19#include <stdlib.h>
20#include <bsp.h>
21#include <bsp/irq.h>
22#include <at91rm9200.h>
23#include <at91rm9200_pmc.h>
24
25/**
26 * Enables clock interrupt.
27 *
28 * If the interrupt is always on, this can be a NOP.
29 */
30static void clock_isr_on(const rtems_irq_connect_data *unused)
31{
32  /* enable timer interrupt */
33  ST_REG(ST_IER) = ST_SR_PITS;
34}
35
36/**
37 * Disables clock interrupts
38 *
39 * If the interrupt is always on, this can be a NOP.
40 */
41static void clock_isr_off(const rtems_irq_connect_data *unused)
42{
43  /* disable timer interrupt */
44  ST_REG(ST_IDR) = ST_SR_PITS;
45}
46
47/**
48 * Tests to see if clock interrupt is enabled, and returns 1 if so.
49 * If interrupt is not enabled, returns 0.
50 *
51 * If the interrupt is always on, this always returns 1.
52 */
53static int clock_isr_is_on(const rtems_irq_connect_data *irq)
54{
55  /* check timer interrupt */
56  return ST_REG(ST_IMR) & ST_SR_PITS;
57}
58
59void Clock_isr(rtems_irq_hdl_param arg);
60
61/* Replace the first value with the clock's interrupt name. */
62rtems_irq_connect_data clock_isr_data = {
63  .name   = AT91RM9200_INT_SYSIRQ,
64  .hdl    = Clock_isr,
65  .handle = NULL,
66  .on     = clock_isr_on,
67  .off    = clock_isr_off,
68  .isOn   = clock_isr_is_on,
69};
70
71
72#define Clock_driver_support_install_isr( _new, _old ) \
73  do {                                                 \
74      (_old) = NULL;                                   \
75      BSP_install_rtems_irq_handler(&clock_isr_data);  \
76  } while(0)
77
78static void Clock_driver_support_initialize_hardware(void)
79{
80  uint32_t st_str;
81  int slck;
82  unsigned long value;
83
84  /* the system timer is driven from SLCK */
85  slck = at91rm9200_get_slck();
86  value = (((rtems_configuration_get_microseconds_per_tick() * slck) +
87                      (1000000/2))/ 1000000);
88
89  /* read the status to clear the int */
90  st_str = ST_REG(ST_SR);
91  (void) st_str; /* avoid set but not used warning */ \
92
93  /* set priority */
94  AIC_SMR_REG(AIC_SMR_SYSIRQ) = AIC_SMR_PRIOR(0x7);
95
96  /* set the timer value */
97  ST_REG(ST_PIMR) = value;
98}
99
100#define Clock_driver_support_at_tick() \
101  do { \
102    uint32_t st_str; \
103    \
104    /* read the status to clear the int */ \
105    st_str = ST_REG(ST_SR); \
106    (void) st_str; /* avoid set but not used warning */ \
107  } while (0)
108
109#define Clock_driver_support_shutdown_hardware() \
110  do { \
111    BSP_remove_rtems_irq_handler(&clock_isr_data); \
112  } while (0)
113
114#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
115
116#include "../../../../libbsp/shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.