source: rtems/c/src/lib/libbsp/nios2/nios2_iss/clock/clock.c @ adf81e9

4.104.115
Last change on this file since adf81e9 was adf81e9, checked in by Ralf Corsepius <ralf.corsepius@…>, on Sep 30, 2008 at 6:19:21 AM

2008-09-30 Ralf Corsépius <ralf.corsepius@…>

  • clock/clock.c: include "../../../shared/clockdrv_shell.h".
  • Makefile.am: Reflect changes above.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 * Use SYS_CLK as system clock
3 *
4 * Copyright (c) 2005-2006 Kolja Waschk, rtemsdev/ixo.de
5 *
6 *  $Id$
7 */
8
9#include <rtems.h>
10#include <bsp.h>
11
12#define CLOCK_REGS ((altera_avalon_timer_regs*)NIOS2_IO_BASE(CLOCK_BASE))
13
14/*
15 * Periodic interval timer interrupt handler
16 */
17#define Clock_driver_support_at_tick() \
18  do { CLOCK_REGS->status = 0; } while(0)
19
20/*
21 * Attach clock interrupt handler
22 */
23#define Clock_driver_support_install_isr(_new, _old) \
24  do { _old = (rtems_isr_entry)set_vector(_new, CLOCK_VECTOR, 1); } while(0)
25
26
27/*
28 * Turn off the clock
29 */
30#define Clock_driver_support_shutdown_hardware() \
31  do { CLOCK_REGS->control = ALTERA_AVALON_TIMER_CONTROL_STOP_MSK; } while(0)
32
33/*
34 * Set up the clock hardware
35 */
36void Clock_driver_support_initialize_hardware(void)
37{
38  uint32_t period;
39
40  CLOCK_REGS->control = ALTERA_AVALON_TIMER_CONTROL_STOP_MSK;
41
42  period = (CLOCK_FREQ/1000000L)*rtems_configuration_get_microseconds_per_tick() - 1;
43  CLOCK_REGS->period_hi = period >> 16;
44  CLOCK_REGS->period_lo = period & 0xFFFF;
45
46  CLOCK_REGS->control = ALTERA_AVALON_TIMER_CONTROL_ITO_MSK  |
47                        ALTERA_AVALON_TIMER_CONTROL_CONT_MSK |
48                        ALTERA_AVALON_TIMER_CONTROL_START_MSK;
49
50  NIOS2_IENABLE(1 << CLOCK_VECTOR);
51}
52
53#include "../../../shared/clockdrv_shell.h"
54
Note: See TracBrowser for help on using the repository browser.