📄 main.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: Chenmingji
** Created date: 2004-09-16
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#define UART_BPS 115200
void Delay(uint32 dly)
{
uint32 i;
for(; dly > 0 ; dly--)
for(i=0;i<50000;i++) ;
}
void UART0_Init()
{
uint16 Fdiv;
U0LCR = 0x83;
Fdiv = (Fpclk / 16) / UART_BPS;
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03;
}
uint8 UART0_GetByte()
{
uint8 rec_da;
while((U0LSR & 0x01)==0);
rec_da = U0RBR;
return(rec_da);
}
void UART0_GetStr(uint8 *s,uint32 n)
{
for(; n > 0 ; n--)
{
*s++ = UART0_GetByte();
}
}
void UART0_SendByte(uint8 send_da)
{
U0THR = send_da;
while((U0LSR & 0x40)==0);
}
void UART0_SendStr(uint8 const *s)
{
while(1)
{
if(*s != '\0')
UART0_SendByte(*s++);
else
break;
}
}
int main (void)
{// add user source code
uint8 send[32]={'\0'};
uint8 temp;
PINSEL0 = 0x00000005 ;
UART0_Init();
while(1)
{
temp = U0RBR;
temp = U0THR;
UART0_GetStr(send , 2);
Delay(10);
UART0_SendStr(send);
Delay(10);
}
return 0;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -