Files
OldPeopleHome/zigbee/ZStack-CC2530-r200/Components/hal/target/CC2530EB/uart_rx.c
LitterDryFish 0657e3a6a9 组网
2019-08-23 09:32:51 +08:00

48 lines
1.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "uart_rx.h"
static uchar temp;
/****************************************************************
*函数功能 初始化串口1
*入口参数 :无
*返 回 值 :无
*说 明 57600-8-n-1
****************************************************************/
void initUARTrx(void)
{
CLKCONCMD &= ~0x40; //晶振
while(!(SLEEPSTA & 0x40)); //等待晶振稳定
CLKCONCMD &= ~0x47; //TICHSPD128分频CLKSPD不分频
SLEEPCMD |= 0x04; //关闭不用的RC振荡器
PERCFG = 0x00; //位置1 P0口
P0SEL = 0x3c; //P0用作串口
U0CSR |= 0x80; //UART方式
U0GCR |= 10; //baud_e
U0BAUD |= 59; //波特率设为57600
UTX0IF = 1;
U0CSR |= 0X40; //允许接收
IEN0 |= 0x84; //开总中断,接收中断
}
uchar ReceiveData(void){
return(temp);
}
/****************************************************************
*函数功能 :串口接收一个字符
*入口参数 : 无
*返 回 值 :无
*说 明 :接收完成后打开接收
****************************************************************/
#pragma vector = URX0_VECTOR
__interrupt void UART0_ISR(void)
{
URX0IF = 0; //清中断标志
temp = U0DBUF;
}