⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 周立功2103开发板CD资料
💻 C
字号:
#define IN_MAIN
#include "config.h"
#include "ExtInterrupt.h"
#pragma import(__use_no_semihosting_swi)        //don't delete this line

#define BEEP         (1 << 7)		//P0.7控制BEEP
#define EXTINT0_NO   15				//外部中断1的中断号
/******************************************************************************************
** 函数名称:Delay_NS()
** 功能描述:延时函数。
******************************************************************************************/
void Delay_NS(uint32 dly)
{
    uint32 i;
    for(; dly > 0; dly--)
    {
        for(i = 0; i < 50000; i++);
    }
}
/******************************************************************************************
** Function name:			IRQ_Exception
**
** Descriptions:			interrupt exceptional handler , change it as needed
**                          don't delete this function 
******************************************************************************************/
void  IRQ_Exception(void)
{
}
/******************************************************************************************
**函数名称:ExtInt0_ISR
**功能描述:外部中断0中断服务函数。
******************************************************************************************/
void ExtInt0_ISR(void)
{ 
    IO0CLR = BEEP;		   //蜂鸣器鸣叫
    Delay_NS(20);
    while(IsExtInt(1))     
    {    
        CleanExtIntFlg(1); //清零EXTINT1中断标志
    }
    IO0SET = BEEP;		   //蜂鸣器停止鸣叫

    
    VICVectAddr = 0;      //退出外部中断1              
}

/******************************************************************************************
** 函数名称:Main()
** 函数功能:测试向量IRQ。
** 说明:芯片复位时,JP1跳线不能短接。JP9跳线断开。
******************************************************************************************/
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功能
    
	SetISR(EXTINT0_NO,0,(uint32)ExtInt0_ISR);	//设置IRQ中断
	VICIntEnable = (1 << EXTINT0_NO);			//对应的中断使能
	IRQEnable();             					//打开中断   
    while(1);      
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -