File indexing completed on 2025-05-11 08:22:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <rtems.h>
0015 #include <bsp.h>
0016 #include <bsp/irq.h>
0017 #include <mc9328mxl.h>
0018 #include <rtems/bspIo.h> /* for printk */
0019
0020
0021 void Clock_isr(rtems_irq_hdl_param arg);
0022 static void clock_isr_on(const rtems_irq_connect_data *unused);
0023 static void clock_isr_off(const rtems_irq_connect_data *unused);
0024 static int clock_isr_is_on(const rtems_irq_connect_data *irq);
0025
0026
0027 rtems_irq_connect_data clock_isr_data = {
0028 .name = BSP_INT_TIMER1,
0029 .hdl = Clock_isr,
0030 .handle = (void *)BSP_INT_TIMER1,
0031 .on = clock_isr_on,
0032 .off = clock_isr_off,
0033 .isOn = clock_isr_is_on,
0034 };
0035
0036
0037
0038
0039
0040
0041 #define Clock_driver_support_at_tick(arg) \
0042 do { \
0043 uint32_t reg; \
0044 \
0045 reg = MC9328MXL_TMR1_TSTAT; \
0046 (void) reg; \
0047 MC9328MXL_TMR1_TSTAT = 0; \
0048 } while(0)
0049
0050
0051
0052
0053 #define Clock_driver_support_install_isr( _new ) \
0054 BSP_install_rtems_irq_handler(&clock_isr_data)
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 #define Clock_driver_support_initialize_hardware() \
0068 do { \
0069 int freq; \
0070 int cnt; \
0071 freq = get_perclk1_freq(); \
0072 printk("perclk1 freq is %d\n", freq); \
0073 cnt = ((long long)freq * rtems_configuration_get_microseconds_per_tick() + 500000) / 1000000;\
0074 printk("cnt freq is %d\n", cnt); \
0075 MC9328MXL_TMR1_TCMP = cnt; \
0076 \
0077 MC9328MXL_TMR1_TCTL = (MC9328MXL_TMR_TCTL_CLKSRC_PCLK1 | \
0078 MC9328MXL_TMR_TCTL_TEN | \
0079 MC9328MXL_TMR_TCTL_IRQEN); \
0080 \
0081 MC9328MXL_TMR1_TPRER = 0; \
0082 } while (0)
0083
0084
0085
0086
0087
0088
0089 static void clock_isr_on(const rtems_irq_connect_data *unused)
0090 {
0091 MC9328MXL_TMR1_TCTL |= MC9328MXL_TMR_TCTL_IRQEN;
0092 MC9328MXL_AITC_INTENNUM = MC9328MXL_INT_TIMER1;
0093 }
0094
0095
0096
0097
0098
0099
0100 static void clock_isr_off(const rtems_irq_connect_data *unused)
0101 {
0102 MC9328MXL_TMR1_TCTL &= ~MC9328MXL_TMR_TCTL_IRQEN;
0103 MC9328MXL_AITC_INTDISNUM = MC9328MXL_INT_TIMER1;
0104 }
0105
0106
0107
0108
0109
0110
0111
0112 static int clock_isr_is_on(const rtems_irq_connect_data *irq)
0113 {
0114 return MC9328MXL_TMR1_TCTL & MC9328MXL_TMR_TCTL_IRQEN;
0115 }
0116
0117 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
0118
0119
0120
0121 #include "../../../shared/dev/clock/clockimpl.h"