Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:51

0001 /*
0002  * Use SYS_CLK as system clock
0003  *
0004  * Copyright (c) 2005-2006 Kolja Waschk, rtemsdev/ixo.de
0005  */
0006 
0007 #include <rtems.h>
0008 #include <bsp.h>
0009 
0010 #define CLOCK_REGS ((altera_avalon_timer_regs*)NIOS2_IO_BASE(CLOCK_BASE))
0011 
0012 /*
0013  * Periodic interval timer interrupt handler
0014  */
0015 #define Clock_driver_support_at_tick(arg) \
0016   do { CLOCK_REGS->status = 0; } while(0)
0017 
0018 /*
0019  * Attach clock interrupt handler
0020  */
0021 #define Clock_driver_support_install_isr(_new) \
0022   set_vector(_new, CLOCK_VECTOR, 1)
0023 
0024 /*
0025  * Set up the clock hardware
0026  */
0027 static void Clock_driver_support_initialize_hardware(void)
0028 {
0029   uint32_t period;
0030 
0031   CLOCK_REGS->control = ALTERA_AVALON_TIMER_CONTROL_STOP_MSK;
0032 
0033   period = (CLOCK_FREQ/1000000L)*rtems_configuration_get_microseconds_per_tick() - 1;
0034   CLOCK_REGS->period_hi = period >> 16;
0035   CLOCK_REGS->period_lo = period & 0xFFFF;
0036 
0037   CLOCK_REGS->control = ALTERA_AVALON_TIMER_CONTROL_ITO_MSK  |
0038                         ALTERA_AVALON_TIMER_CONTROL_CONT_MSK |
0039                         ALTERA_AVALON_TIMER_CONTROL_START_MSK;
0040 
0041   NIOS2_IENABLE(1 << CLOCK_VECTOR);
0042 }
0043 
0044 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
0045 
0046 #include "../../../shared/dev/clock/clockimpl.h"
0047