File indexing completed on 2025-05-11 08:23:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <rtems.h>
0015 #include <stdlib.h>
0016 #include <rtems/libio.h>
0017 #include <rtems/score/percpu.h>
0018 #include <rtems/score/thread.h>
0019 #include <bsp.h>
0020 #include <rtems/clockdrv.h>
0021
0022
0023 #include <libcpu/cecRegs.h>
0024 #include <libcpu/coreTimerRegs.h>
0025
0026 #if (BFIN_ON_SKYEYE)
0027 #define CLOCK_DRIVER_USE_FAST_IDLE 1
0028 #endif
0029
0030 volatile uint32_t Clock_driver_ticks;
0031
0032 static rtems_isr clockISR(rtems_vector_number vector) {
0033
0034 Clock_driver_ticks += 1;
0035
0036 #if CLOCK_DRIVER_USE_FAST_IDLE
0037 do {
0038 rtems_clock_tick();
0039 } while ( _Thread_Heir == _Thread_Executing && _Thread_Executing->is_idle );
0040 #else
0041 rtems_clock_tick();
0042 #endif
0043 }
0044
0045
0046
0047
0048
0049
0050
0051 static void Clock_exit(void)
0052 {
0053 *(uint32_t volatile *) TCNTL = 0;
0054 }
0055
0056 void _Clock_Initialize( void )
0057 {
0058 Clock_driver_ticks = 0;
0059
0060 set_vector(clockISR, CEC_CORE_TIMER_VECTOR, 1);
0061
0062 *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD;
0063 *(uint32_t volatile *) TSCALE = 0;
0064 *(uint32_t volatile *) TPERIOD = CCLK / 1000000 *
0065 rtems_configuration_get_microseconds_per_tick();
0066 *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
0067
0068 atexit(Clock_exit);
0069 }