📄 main.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
** http://www.zyinside.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2006-02-22
** Last Version: 1.0
** Descriptions: header file of the specific codes for LPC2200 target boards
** Every project should include a copy of this file, user may modify it as needed
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#define IN_MAIN
#include "config.h"
#include "ExtInterrupt.h"
#define BEEP 1<<7 //P0.7控制BEEP
#define EXTINT1_NO 15 //外部中断1的中断号
#pragma import(__use_no_semihosting_swi) //don't delete this line
/*********************************************************************************************************
** Function name: IRQ_Exception
**
** Descriptions: interrupt exceptional handler , change it as needed
** don't delete this function
** input parameters: None
** Returned value: None
**
**
** Created by: Chenmingji
** Created Date: 2006/02/22
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void IRQ_Exception(void)
{
}
void Delay_NS(uint32 dly)
{
uint32 i;
for(; dly > 0; dly--)
{
for(i = 0; i < 50000; i++);
}
}
/******************************************************************************************
**函数名称:ExtInt1_ISR
**功能描述:外部中断1中断服务函数
******************************************************************************************/
void ExtInt1_ISR(void)
{
IO0CLR = BEEP; //蜂鸣器鸣叫
Delay_NS(20);
while(IsExtInt(1))
{
CleanExtIntFlg(1); //清零EXTINT1中断标志
}
IO0SET = BEEP; //蜂鸣器关闭
VICVectAddr = 0; //退出中断服务函数
}
/*********************************************************************************************************
** Function name: Main
**
** Descriptions: 外部中断1电平或者边沿触发实验
**
** input parameters: None
** Returned value: None
**
**
** Created by: Chenmingji
** Created Date: 2006/02/22
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void Main(void)
{
TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA); // don't delete
while((PLLSTAT & (1 << 10)) == 0); // can delete
PINSEL0 = 0;
PINSEL1 = 0;
IO0DIR = BEEP;
IO0SET = BEEP;
SetExtInt(1, 0, 0); //使能外部中断1,低电平触发,禁止唤醒CPU功能
//测试其他情况
// SetExtInt(1, 1, 0); //使能外部中断1,高电平触发,禁止唤醒CPU功能
// SetExtInt(1, 2, 0); //使能外部中断1,下降沿触发,禁止唤醒CPU功能
// SetExtInt(1, 3, 0); //使能外部中断1,上升沿触发,禁止唤醒CPU功能
SetISR(EXTINT1_NO, 0, (unsigned int)ExtInt1_ISR);//调用SetISR函数使能外部中断1
IRQEnable(); //打开中断
while(1);
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -