Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:44

0001 /*
0002  * Use the last periodic interval timer (PIT3) as the system clock.
0003  */
0004 
0005 #include <rtems.h>
0006 #include <bsp.h>
0007 #include <mcf5282/mcf5282.h>
0008 
0009 /*
0010  * Use INTC0 base
0011  */
0012 #define CLOCK_VECTOR (64+58)
0013 
0014 /*
0015  * Periodic interval timer interrupt handler
0016  */
0017 #define Clock_driver_support_at_tick(arg)          \
0018     do {                                           \
0019         MCF5282_PIT3_PCSR |= MCF5282_PIT_PCSR_PIF; \
0020     } while (0)                                    \
0021 
0022 /*
0023  * Attach clock interrupt handler
0024  */
0025 #define Clock_driver_support_install_isr( _new ) \
0026     set_vector(_new, CLOCK_VECTOR, 1)
0027 
0028 /*
0029  * Set up the clock hardware
0030  *
0031  * We need to have 1 interrupt every 10,000 microseconds
0032  * so we need to set prescaler to 64 and the PMR register to 0x23FE
0033  */
0034 #define Clock_driver_support_initialize_hardware()                       \
0035     do {                                                                 \
0036         int level;                                                       \
0037         int preScaleCode = 5;                                             \
0038         MCF5282_INTC0_ICR58 = MCF5282_INTC_ICR_IL(PIT3_IRQ_LEVEL) |      \
0039                               MCF5282_INTC_ICR_IP(PIT3_IRQ_PRIORITY);    \
0040         rtems_interrupt_disable( level );                                \
0041         MCF5282_INTC0_IMRH &= ~MCF5282_INTC_IMRH_INT58;                  \
0042         MCF5282_PIT3_PCSR &= ~MCF5282_PIT_PCSR_EN;                       \
0043         rtems_interrupt_enable( level );                                 \
0044         MCF5282_PIT3_PMR = 0x23FE;  \
0045         MCF5282_PIT3_PCSR = MCF5282_PIT_PCSR_PRE(preScaleCode) |         \
0046                             MCF5282_PIT_PCSR_PIE |                       \
0047                             MCF5282_PIT_PCSR_RLD |                       \
0048                             MCF5282_PIT_PCSR_EN;                         \
0049     } while (0)
0050 
0051 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
0052 
0053 #include "../../../shared/dev/clock/clockimpl.h"