📄 gps_cpu_port.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: GPS_CPU_PORT.c
** Last modified Date: 2005-06-17
** Last Version: 1.0
** Descriptions: cpu port function of GPS
**
**------------------------------------------------------------------------------------------------------
** Created by: Yehaoben
** Created date: 2005-06-17
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.H"
/*********************************************************************************************************
** Function name: UART_Ini
**
** Descriptions: Initial uart
**
** input parameters: baud bandrate
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: Yehaoben
** Created Date: 2005/06/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void IRQ_UART(void);
uint8 UART_Ini(uint32 baud)
{ uint8 i;
VICVectAddr[23] = (uint32) IRQ_UART;
// Clear Int Pending and Unmask
// rPRIORITY = 0x00000000; // 使用默认的固定的优先级
//rINTMOD = 0x00000000; // 所有中断均为IRQ中断
rINTMSK &=~(BIT_UART1);
rINTSUBMSK &=~(BIT_SUB_RXD1|BIT_SUB_ERR1);
// IO口设置 (GPH5,GPH4)
rGPHUP = rGPHUP | (0x03<<4);
rGPHCON = (rGPHCON & (~0x00000F00)) | (0x00000A00);
// 串口模式设置
rUFCON1 = 0x97; // 8tx,8rx,reset fifo ,enable fifo
rUMCON1 = 0x01; // AFC(流控制)禁能
rULCON1 = 0x03; // 禁止IRDA,无奇偶校验,1位停止位,8位数据位
rUCON1 = 0x3c5; // 使用PCLK来生成波特率,发送中断为电平触发模式,接收中断为边沿触发模式,
// 禁止接收超时中断,使能接收错误中断,正常工作模式,中断或查询方式(非DMA)
// 串口波特率设置
rUBRDIV1=(int)(PCLK/16.0/baud + 0.5) -1;
for(i=0;i<100;i++);
return 1;
}
/*********************************************************************************************************
** Function name: IRQ_UART
**
** Descriptions: UART interrupt server function
**
** input parameters: None
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: Yehaoben
** Created Date: 2005/06/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
extern void ZLG_GPS_RVC_HANDLE(uint8 i);
void IRQ_UART(void)
{
uint16 temp16;
temp16 = rUFSTAT1;
if(temp16 & (1<<9))//Tx FIFO FULL
{
//ERR
}
else if((temp16 & 0x00f0) == 0 )//Tx FIFO == 0
{
//SEND DATA
}
if(temp16 & (1<<8))//Rx FIFO FULL
{
//REVICE DATA
}
else if(temp16 & 0x000f)//Rx FIFO > 0
{
//REVICE DATA
do
{
ZLG_GPS_RVC_HANDLE(rURXH1);
} while(rUFSTAT1 & 0x000f);
}
temp16 = rUERSTAT1;//READ ERR STATUS
rSRCPND = BIT_UART1;
rSUBSRCPND = BIT_SUB_RXD1|BIT_SUB_ERR1;
rINTPND = rINTPND;
}
/*********************************************************************************************************
** Function name: ZLG_GPS_Send_String
**
** Descriptions: Send string
**
** input parameters: char *:string pointer
** Returned value: None
**
** Used global variables: None
** Calling modules: None
**
** Created by: Yehaoben
** Created Date: 2005/06/02
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void ZLG_GPS_Send_String(char * strptr)
{
uint8 i,j,k,l;
k = strlen(strptr);
l = 0;
do
{
j = (k > 8) ? 8 : k;
for(i=0; i<j; i++)
rUTXH1 = strptr[i + (l * 8)];
l++;
k = k - j;
while( (rUTRSTAT1 & 0X02) == 0 );
}while(k > 0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -