📄 main.cpp
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2004-09-16
** Last Version: 1.0
** Descriptions: The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by: Chenmingji
** Created date: 2004-09-16
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#include "Pin_LPC2138.h"
#include "Timer_LPC2138.h"
#include "PinDevice_LPC2138.h"
//#include "Pin_Vcl.h"
Timer_Lpc2138 TimerDevice0;
Pin_LPC2138 PIN006;
//Pin_Vcl PinLedVCL;
class PinSubDevice:public PinDevice_Virtual_Device
{
public:
void OnTimer()
{
if (PinDevice->PinValue() == 0)
PinDevice->Set();
else
PinDevice->Clear();
}
};
PinSubDevice PinLed;
/************定时器相应函数************/
void __irq IRQ_Timer()
{
*( TimerDevice0.BasePointer+Timer_IR_Offset)=0x01;
TimerDevice0.HardInt();
VICVectAddr = 0x00;
};
void Ini_Pin()
{
PIN006.SetPinTag("P020");
PIN006.Function=0;
PIN006.Dirction = 1;
PIN006.Ini();
PIN006.Set();
};
int main (void)
{// add user source code
Ini_Pin();
PinLed.PinDevice = &PIN006;
// PinLedVCL.SupportPin = &PinLed;
/*初始化定时器*/
TimerDevice0.SubDeviceName=Timer0;
TimerDevice0.WorkFreq=Fpclk;
TimerDevice0.OutFreq=2000;
TimerDevice0.TimerRegister(&PinLed);
TimerDevice0.Ini();
/*定时器中断设置*/
VICIntSelect = 0x00;
VICVectCntl3 = 0x20 |(TimerIrqBase+TimerDevice0.SubDeviceName);
VICVectAddr3 = (uint32)IRQ_Timer;
VICIntEnable=1<<(TimerIrqBase+ TimerDevice0.SubDeviceName);
IRQEnable();
while(1)
{
};
return 0;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -