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

📄 main.c

📁 这是LPC2300的例程 ZLG的ARM2300开发板带的
💻 C
字号:
/****************************************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:			李仲生
** Created date:		2006-03-26
** Version:				1.00
** Descriptions:		多中断优先级实验
**
**------------------------------------------------------------------------------------------------------
** Modified by:			
** Modified date:		
** Version:				
** Descriptions:		
**
********************************************************************************************************/
#include "config.h"

#define softindex0  1 << 14					// 0号软中断	
#define softindex1  1 << 15					// 1号软中断	
#define softindex2  1 << 16					// 2号软中断	
#define softindex3  1 << 17					// 3号软中断	

#define key1		1 << 6					// key1由P0.6控制
#define BEEP  		1 << 27					// P1.27控制BEEP,低电平蜂鸣	
/*
*********************************************************************************************************
** 函数名称 :DelayNS()
** 函数功能 :长软件延时
** 入口参数 :dly	延时参数,值越大,延时越久
** 出口参数 :无
*********************************************************************************************************
*/
void DelayNS (uint32 dly)
{
	uint32 i;
	
	for ( ; dly>0; dly--)
		for (i=0; i<50000; i++);
}


/*
*********************************************************************************************************
** 函数名称 :IRQ_index0()
** 函数功能 :中断服务程序。
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************
*/
void __irq IRQ_index0 (void)
{
	IO1CLR = BEEP;
	DelayNS(20);
	IO1SET = BEEP;					// 关闭BEEP	
	DelayNS(100);
	
	DelayNS(300);
	
	VICVectAddr = 0x00;					// 通知VIC中断处理结束
	VICSoftIntClr = softindex0;
}
/*
*********************************************************************************************************
** 函数名称 :IRQ_index1()
** 函数功能 :中断服务程序。
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************
*/
void __irq IRQ_index1 (void)
{
	int x;
	for(x = 0;x<2;x++)
	{
		IO1CLR = BEEP;
		DelayNS(20);
		IO1SET = BEEP;					// 关闭BEEP	
		DelayNS(100);
	}
	
	DelayNS(300);
	VICVectAddr = 0x00;					// 通知VIC中断处理结束
	VICSoftIntClr = softindex1;
}
/*
*********************************************************************************************************
** 函数名称 :IRQ_index2()
** 函数功能 :中断服务程序。
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************
*/
void __irq IRQ_index2 (void)
{
	int x;
	for(x = 0;x<3;x++)
	{
		IO1CLR = BEEP;
		DelayNS(20);
		IO1SET = BEEP;					// 关闭BEEP	
		DelayNS(100);
	}
	
	DelayNS(300);
	VICVectAddr = 0x00;					// 通知VIC中断处理结束
	VICSoftIntClr = softindex2;
}
/*
*********************************************************************************************************
** 函数名称 :IRQ_index3()
** 函数功能 :中断服务程序。
** 入口参数 :无
** 出口参数 :无
*********************************************************************************************************
*/
void __irq IRQ_index3 (void)
{
	int x;
	for(x = 0;x<4;x++)
	{
		IO1CLR = BEEP;
		DelayNS(20);
		IO1SET = BEEP;					// 关闭BEEP	
		DelayNS(100);
	}
	
	DelayNS(300);
	VICVectAddr = 0x00;					// 通知VIC中断处理结束
	VICSoftIntClr = softindex3;
}

int main (void)
{	
	PINSEL0 = 0x00000000;				
	PINSEL3 = 0x00000000;				// 设置管脚连接GPIO							
	IO1DIR  = BEEP;						// 设置BEEP控制口输出	
						
    IRQEnable();						// IRQ中断使能								
	

	/* 设置中断IRQ */
	VICIntSelect = 0x00;					// 所有中断通道设置为IRQ中断		
	
	VICVectPri14 = 3;						// 设置中断优先级3	
	VICVectAddr14 = (uint32)IRQ_index0;		// 设置中断服务程序地址					
	VICIntEnable = softindex0;				// 使能中断		
	
	VICVectPri15 = 2;						// 设置中断优先级2	
	VICVectAddr15 = (uint32)IRQ_index1;		// 设置中断服务程序地址					
	VICIntEnable = softindex1;				// 使能中断		

	VICVectPri16 = 1;						// 设置中断优先级1	
	VICVectAddr16 = (uint32)IRQ_index2;		// 设置中断服务程序地址					
	VICIntEnable = softindex2;				// 使能中断		

	VICVectPri17 = 0;						// 设置中断优先级0	
	VICVectAddr17 = (uint32)IRQ_index3;		// 设置中断服务程序地址					
	VICIntEnable = softindex3;				// 使能中断		
	while(1)
	{
		if((IO0PIN&key1) == 0x00000000)
		{
			VICSoftInt = (0x0000000f<<14);		// 产生软件中断
			while((IO0PIN&key1) == 0x00000000);
		}
		DelayNS(10);
	}
	return 0;
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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