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

📄 irqserver.c

📁 串口数据与文件传输程序
💻 C
字号:
#include "IRQServer.h"

S8	tempcount = 0;
int c;
unsigned int b;

//***************************************************************************  
// 函数名称: Irq_uart0				                                   		*
// 函数入口: 无																*
// 函数出口: 无							      	                       		*
// 函数描述: 串口0中断接收函数												*
//***************************************************************************
void __irq Irq_uart0(void)
{
	Uart_Printf("说明------------------------------------是程序!");

	//tempcount++;
	rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    if(rSUBSRCPND&BIT_SUB_RXD0) 
    {
    	tempcount++;
    	c = Uart_Getch();    	
    	if(c == 'A')
    	{
    		c = Uart_Getch();
    		if(c == 'A')  //说明是程序
    		{
    			Uart_Printf("说明是程序!");

    		}
    		else if(c == 'B')   //说明是波特率数据
    		{
    		   b=Uart_GetIntNum();     		  
    		   if(b>=4800 && b<=38400)
    		   { 
    		   
    		   		flag = 1;
    		   		
    		     //rUCON1  = 0x240;    //关闭串口
    		     //rUBRDIV1=( (int)(PCLK/16./b+0.5) -1 ); // 设置UATR1波特率
    		     //rUCON1  = 0x245;    //打开串口
    		   }
    		   else 
    		   Uart_Printf("the data is error!");
    		}
    		else if(c=='C')  //说明是其它数据
    		{
    		    
    		}    		
    	}
    	Uart_Printf("Uart0 receive interrupt handler has been called!!! %xh\n", tempcount);
    }
    ClearPending(BIT_UART0); 
    rSUBSRCPND=(BIT_SUB_RXD0|BIT_SUB_ERR0);	// Clear Sub int pending    
    rINTSUBMSK&=~(BIT_SUB_RXD0|BIT_SUB_ERR0);
}

//***************************************************************************  
// 函数名称: Irq_uart1				                                   		*
// 函数入口: 无																*
// 函数出口: 无							      	                       		*
// 函数描述: 串口1中断接收函数												*
//***************************************************************************
void __irq Irq_uart1(void)
{
	//tempcount++;
	rINTSUBMSK|=(BIT_SUB_RXD1|BIT_SUB_TXD1|BIT_SUB_ERR1);
    if(rSUBSRCPND&BIT_SUB_RXD1) 
    {
    	tempcount++;
    	c = Uart_Getch();
    	Uart_Printf("Uart1 receive interrupt handler has been called!!! %xh\n", tempcount);
    }
    ClearPending(BIT_UART1); 
    rSUBSRCPND=(BIT_SUB_RXD1|BIT_SUB_ERR1);	// Clear Sub int pending    
    rINTSUBMSK&=~(BIT_SUB_RXD1|BIT_SUB_ERR1);
}

//***************************************************************************  
// 函数名称: Irq_extern0			                                   		*
// 函数入口: 无																*
// 函数出口: 无							      	                       		*
// 函数描述: 外部中断0处理函数												*
//***************************************************************************
void __irq Irq_extern0(void)
{ 
	
	Uart_Printf("Extern interrupt 0 handler has been called!!!\n");
	
	/////////////////////////////////////
	ClearPending(BIT_EINT0);
	/////////////////////////////////////
}

//***************************************************************************  
// 函数名称: Irq_extern2			                                   		*
// 函数入口: 无																*
// 函数出口: 无							      	                       		*
// 函数描述: 外部中断2处理函数												*
//***************************************************************************
void __irq Irq_extern2(void)
{ 
	
	Uart_Printf("Extern interrupt 2 handler has been called!!!\n");
	
	/////////////////////////////////////
	ClearPending(BIT_EINT2);
	/////////////////////////////////////
}

⌨️ 快捷键说明

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