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

📄 main.c

📁 周立功2103开发板CD资料
💻 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 "UART.h"
#include "ISR.h"
#pragma import(__use_no_semihosting_swi)        //don't delete this line

#define		UARTn		0		//使用UART0接口
#define		UART_datab	8		//8位数据位
#define		UART_stopb	1		//1位停止位	
#define		UART_parity	0		//无奇偶校验位	
#define		INT_En		0x101	//自动波特率完成中断使能、接收中断使能
#define		UARTn_Mode	0x01	//自动波特率模式1
#define		FIFO_Data	8		//FIFO缓冲区8字节

#define		UARTn_slot	0		//UART中断使用通道0

uint8	data[16] = {0};		//数据缓冲区
volatile	uint8	AutoBaud = 0;
/*********************************************************************************************************
** 函数名称:IRQ_UART()
** 函数功能:UART接收中断服务程序
********************************************************************************************************/
void  IRQ_UART(void)
{
	uint8	i;
	if((U0IIR & 0x100) != 0)	
	{
		AutoBaud = 1;		
		U0ACR = (U0ACR | 0x100);	//清除自动波特率完成中断	
	}	
	if(((U0IIR & 0x0f) == 0x04) && (AutoBaud == 1))
	{
		for(i=0;i<8;i++)	data[i] = U0RBR;
		UARTn_SendData(UARTn,data,8);	//将接收到的数据回发出去
	}
	VICVectAddr = 0x00;
}
/*********************************************************************************************************
** 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)
{
}
/*********************************************************************************************************
** 函数功能:main()
** 函数功能:UART自动波特率适应。
** 说明:跳线JP5短接。
********************************************************************************************************/
void Main(void)
{
    TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA);      // don't delete 
    while((PLLSTAT & (1 << 10)) == 0);                      // can delete
    
	UARTn_AutoInit(UARTn,UART_datab,UART_stopb,UART_parity,INT_En,UARTn_Mode);	//自动进行波特率测量
	Set_FIFO(UARTn,FIFO_Data);							//8字节FIFO

	SetISR(UART0_INT, UARTn_slot, (uint32)IRQ_UART);	//UART初始化为IRQ中断
	IRQEnable();
	while(1);
}
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/

⌨️ 快捷键说明

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