📄 ep9312.c
字号:
/*
* $Revision: 1.3.26.1 $
*/
#include <intrinsics.h>
#include <ioep9312.h>
#define TC3OI_bit (1 << VIC2_TC3OI)
static void (*timer_function)();
//
// Interrupt handlers.
//
void TimerInterrupt()
{
(*timer_function)(); // Call timer callback function.
Timer3Clear = 0x0; // Clear timer 3 interrupt line.
}
// IRQ interrupt handler.
// Only the timer interrupt is used by this example.
__irq __arm void irq_handler(void)
{
void (*interrupt_function)();
unsigned int vector;
// Called at 1000 Hz rate.
vector = VIC2VectAddr; // Get interrupt vector.
interrupt_function = (void(*)())vector;
(*interrupt_function)(); // Call vectored interrupt function.
VIC2VectAddr = 0; // Clear interrupt in VIC.
}
//
// Interrupt functions.
//
void EP9312InitInterrupt(void(*timer_func)())
{
// Setup timer callback function.
timer_function = timer_func;
// Setup interrupt controller.
VIC1Protection = 0;
VIC2Protection = 0;
// Disable all interrupts
VIC1IntEnClear = 0xffffffff;
VIC2IntEnClear = 0xffffffff;
VIC2IntSelect &= ~TC3OI_bit; // IRQ on timer 3 line.
VIC2VectAddr0 = (unsigned int)&TimerInterrupt;
VIC2VectCntl0 = 0x20 | VIC2_TC3OI; // Enable vector interrupt for timer 3.
VIC2IntEnable |= TC3OI_bit; // Enable timer 3 interrupt.
}
//
// Timer functions.
//
void EP9312InitTimer()
{
Timer3Load = 508; // Set interrupt rate to 1000 Hz.
}
void EP9312StartTimer()
{
Timer3Control = 0xc8; // Enable timer 3, periodic mode, 508 kHz clock.
}
//
// Parallel I/O functions.
//
void EP9312InitPIO()
{
// Rely on setup done by boot program.
}
//
// LED output drivers.
//
void EP9312LedSet(unsigned int value)
{
PEDR &= ~3; // Turn off both LED's.
PEDR |= (value & 3); // Set LED's.
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -