void Install_clock( rtems_isr_entry clock_isr ) { /* * Initialize the clock tick device driver variables */ Clock_driver_ticks = 0; Clock_isrs = rtems_configuration_get_milliseconds_per_tick(); mips_timer_rate = rtems_configuration_get_microseconds_per_tick() * bsp_clicks_per_microsecond; /* * Hardware specific initialize goes here */ /* Set up USC heartbeat timer to generate interrupts */ disable_hbi(); /* Disable heartbeat interrupt in USC */ /* Install interrupt handler */ rtems_interrupt_handler_install( CLOCK_VECTOR, "clock", 0, USC_isr, NULL ); init_hbt(); /* Initialize heartbeat timer */ reset_wdt(); /* Reset watchdog timer */ enable_wdi(); /* Enable watchdog interrupt in USC */ enable_hbi(); /* Enable heartbeat interrupt in USC */ /* Enable USC interrupt in MIPS processor */ mips_enable_in_interrupt_mask(CLOCK_VECTOR_MASK); /* * Schedule the clock cleanup routine to execute if the application exits. */ atexit( Clock_exit ); }
uint32_t TOD_MILLISECONDS_TO_TICKS( uint32_t milliseconds ) { uint32_t ticks; uint32_t milliseconds_per_tick; /** * We should ensure the ticks not be truncated by integer division. We * need to have it be greater than or equal to the requested time. It * should not be shorter. */ milliseconds_per_tick = rtems_configuration_get_milliseconds_per_tick(); ticks = milliseconds / milliseconds_per_tick; if ( (milliseconds % milliseconds_per_tick) != 0 ) ticks += 1; return ticks; }
uint32_t TOD_MILLISECONDS_TO_TICKS( uint32_t milliseconds ) { return (milliseconds / rtems_configuration_get_milliseconds_per_tick()); }