File indexing completed on 2025-05-11 08:22:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <rtems.h>
0016 #include <rtems/clockdrv.h>
0017 #include <rtems/libio.h>
0018
0019 #include <stdlib.h>
0020 #include <bsp.h>
0021 #include <bspopts.h>
0022 #include <bsp/irq.h>
0023 #include <pxa255.h>
0024
0025 #if ON_SKYEYE==1
0026 #define CLOCK_DRIVER_USE_FAST_IDLE 1
0027 #endif
0028
0029 static unsigned long period_num;
0030
0031
0032
0033
0034
0035
0036 static void clock_isr_on(const rtems_irq_connect_data *unused)
0037 {
0038
0039 XSCALE_OS_TIMER_TSR = 0x1;
0040
0041
0042 XSCALE_OS_TIMER_IER |= 0x1;
0043
0044 #if ON_SKYEYE==1
0045 period_num = (TIMER_RATE* rtems_configuration_get_microseconds_per_tick())/100000;
0046 #else
0047 period_num = (TIMER_RATE* rtems_configuration_get_microseconds_per_tick())/10000;
0048 #endif
0049
0050 XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num;
0051 }
0052
0053
0054
0055
0056
0057
0058 static void clock_isr_off(const rtems_irq_connect_data *unused)
0059 {
0060
0061 XSCALE_OS_TIMER_TSR = 0x1;
0062
0063 XSCALE_OS_TIMER_IER &= ~0x1;
0064 }
0065
0066
0067
0068
0069
0070
0071
0072 static int clock_isr_is_on(const rtems_irq_connect_data *irq)
0073 {
0074
0075 return XSCALE_OS_TIMER_IER & 0x1;
0076 }
0077
0078 void Clock_isr(rtems_irq_hdl_param arg);
0079
0080 rtems_irq_connect_data clock_isr_data = {
0081 .name = XSCALE_IRQ_OS_TIMER,
0082 .hdl = Clock_isr,
0083 .handle = NULL,
0084 .on = clock_isr_on,
0085 .off = clock_isr_off,
0086 .isOn = clock_isr_is_on,
0087 };
0088
0089 #define Clock_driver_support_install_isr( _new ) \
0090 BSP_install_rtems_irq_handler(&clock_isr_data)
0091
0092 static void Clock_driver_support_initialize_hardware(void)
0093 {
0094 period_num = TIMER_RATE* rtems_configuration_get_microseconds_per_tick();
0095 #if ON_SKYEYE==1
0096 period_num /= 100000;
0097 #else
0098 period_num /= 10000;
0099 #endif
0100 }
0101
0102 #define Clock_driver_support_at_tick(arg) \
0103 do { \
0104 \
0105 XSCALE_OS_TIMER_TSR = 0x1; \
0106 \
0107 \
0108 XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num; \
0109 } while (0)
0110
0111 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
0112
0113 #include "../../../shared/dev/clock/clockimpl.h"