File indexing completed on 2025-05-11 08:23:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <stdlib.h>
0023
0024 #include <bsp.h>
0025 #include <rtems/clockdrv.h>
0026
0027 #define MS_COUNT 1000
0028 #define CLOCK_INT_LEVEL 6
0029
0030 uint32_t Clock_isrs;
0031 volatile uint32_t Clock_driver_ticks;
0032 rtems_isr_entry Old_ticker;
0033
0034 static void Clock_exit( void );
0035
0036 #define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
0037
0038
0039
0040
0041 static rtems_isr Clock_isr(rtems_vector_number vector)
0042 {
0043 Clock_driver_ticks += 1;
0044 lcsr->timer_cnt_2 = 0;
0045 lcsr->intr_clear |= 0x02000000;
0046
0047 if ( Clock_isrs == 1 ) {
0048 rtems_clock_tick();
0049 Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
0050 }
0051 else
0052 Clock_isrs -= 1;
0053 }
0054
0055 static void Install_clock(rtems_isr_entry clock_isr )
0056 {
0057
0058 Clock_driver_ticks = 0;
0059 Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
0060
0061 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
0062 lcsr->vector_base |= MASK_INT;
0063 lcsr->to_ctl = 0xE7;
0064 lcsr->timer_cmp_2 = MS_COUNT;
0065 lcsr->timer_cnt_2 = 0;
0066 lcsr->board_ctl |= 0x700;
0067
0068
0069 lcsr->intr_level[0] |= CLOCK_INT_LEVEL * 0x10;
0070 lcsr->intr_ena |= 0x02000000;
0071
0072 atexit( Clock_exit );
0073 }
0074
0075 void Clock_exit( void )
0076 {
0077
0078 }
0079
0080 void _Clock_Initialize( void )
0081 {
0082 Install_clock( Clock_isr );
0083 }