level 1
cheneh123
楼主
/*************************************************************************
**
** **
**************************************************************************/
#include <intrinsics.h>
#include <stdio.h>
#include <nxp/iolpc2103.h>
// OSC [Hz]
#define FOSC 11059200UL
// Core clk [Hz]
#define FCCLK FOSC
// Per clk [Hz]
#define PCCLK (FOSC/4)
#define LED1CON 1
#define LED2CON 1<<1
typedef unsigned char uint8;
typedef unsigned int uint32;
/*************************************************************************
* 函数名称:irq_handler
* 入口参数:无
*
* 返回参数:无
*
* 描 述:IRQ handler
*
*************************************************************************/
//uint32 IRQV= 0x18;
#pragma vector=IRQV
__irq void irq_handler (void)
{
void (*interrupt_function)();
unsigned int vector;
vector = VICVectAddr; //获得中断向量
interrupt_function = (void(*)())vector;
if(interrupt_function != NULL)
{
interrupt_function(); //调用中断指向的函数
}
else
{
VICVectAddr = 0; //清除在VIC中的中断
}
}
/*************************************************************************
* 函数名称: VicInit
* 入口参数: 无
*
* 返回参数: 无
*
* 说 明: Init VIC module
*
*************************************************************************/
void VicInit (void)
{
// Assign all interrupt chanels to IRQ
VICIntSelect = 0;
// Diasable all interrupts
VICIntEnClear = 0xFFFFFFFF;
// Clear all software interrutps
VICSoftIntClear = 0xFFFFFFFF;
// VIC registers can be accessed in User or privileged mode
VICProtection = 0;
// Clear interrupt
VICVectAddr = 0;
// Clear address of the Interrupt Service routine (ISR) for non-vectored IRQs.
VICDefVectAddr = 0;
// Clear address of the Interrupt Service routine (ISR) for vectored IRQs.
VICVectAddr0 = VICVectAddr1 = VICVectAddr2 = VICVectAddr3 =\
VICVectAddr4 = VICVectAddr5 = VICVectAddr6 = VICVectAddr7 =\
2011年02月06日 10点02分
1
**
** **
**************************************************************************/
#include <intrinsics.h>
#include <stdio.h>
#include <nxp/iolpc2103.h>
// OSC [Hz]
#define FOSC 11059200UL
// Core clk [Hz]
#define FCCLK FOSC
// Per clk [Hz]
#define PCCLK (FOSC/4)
#define LED1CON 1
#define LED2CON 1<<1
typedef unsigned char uint8;
typedef unsigned int uint32;
/*************************************************************************
* 函数名称:irq_handler
* 入口参数:无
*
* 返回参数:无
*
* 描 述:IRQ handler
*
*************************************************************************/
//uint32 IRQV= 0x18;
#pragma vector=IRQV
__irq void irq_handler (void)
{
void (*interrupt_function)();
unsigned int vector;
vector = VICVectAddr; //获得中断向量
interrupt_function = (void(*)())vector;
if(interrupt_function != NULL)
{
interrupt_function(); //调用中断指向的函数
}
else
{
VICVectAddr = 0; //清除在VIC中的中断
}
}
/*************************************************************************
* 函数名称: VicInit
* 入口参数: 无
*
* 返回参数: 无
*
* 说 明: Init VIC module
*
*************************************************************************/
void VicInit (void)
{
// Assign all interrupt chanels to IRQ
VICIntSelect = 0;
// Diasable all interrupts
VICIntEnClear = 0xFFFFFFFF;
// Clear all software interrutps
VICSoftIntClear = 0xFFFFFFFF;
// VIC registers can be accessed in User or privileged mode
VICProtection = 0;
// Clear interrupt
VICVectAddr = 0;
// Clear address of the Interrupt Service routine (ISR) for non-vectored IRQs.
VICDefVectAddr = 0;
// Clear address of the Interrupt Service routine (ISR) for vectored IRQs.
VICVectAddr0 = VICVectAddr1 = VICVectAddr2 = VICVectAddr3 =\
VICVectAddr4 = VICVectAddr5 = VICVectAddr6 = VICVectAddr7 =\