?? uart.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: Chen Mingji
** Created date: 2004-09-16
** Version: 1.0
** Descriptions: The original version
**
**-------------------------------------------------------------------------------------------------------
** Modified by: Li Baihua
** Modified date: 2008-04-02
** Version: 1.1
** Descriptions: 串口0通信-查詢方式實驗
**
*********************************************************************************************************/
#include "config.h"
#include "stdio.h"
# define UART_BPS 9600 /* 串口通信波特率 */
/*********************************************************************************************************
** Function name: UARTInit
** Descriptions: 串口初始化,設置為8位數據位,1位停止位,無奇偶校驗,波特率為9600
** input parameters: uiDly 值越大,延時時間越長
** output parameters: 無
** Returned value: 無
*********************************************************************************************************/
void UARTInit (void)
{
uint16 uiFdiv;
PINSEL0 = (PINSEL0 & 0xFFFFFFF0) | 0x00000005;
U0LCR = 0x83; /* 允許設置波特率 */
uiFdiv = (Fpclk / 16) / UART_BPS; /* 設置波特率 */
U0DLM = uiFdiv / 256;
U0DLL = uiFdiv % 256;
U0LCR = 0x03; /* 鎖定波特率 */
}
/*********************************************************************************************************
** Function name: UART0SendByte
** Descriptions: 向串口發送子節數據,并等待數據發送完成,使用查詢方式
** input parameters: uiDat 要發送的數據
** output parameters: 無
** Returned value: 無
*********************************************************************************************************/
void UART0SendByte (uint8 uiDat)
{
U0THR = uiDat; /* 寫入數據 */
while ((U0LSR & 0x40) == 0); /* 等待數據發送完畢 */
}
/*********************************************************************************************************
** Function name: PC_DispChar
** Descriptions: 向PC機發送數據,LED數碼顯示
** input parameters: uiDat 要發送的數據
** output parameters: 無
** Returned value: 無
*********************************************************************************************************/
/*******************************************************************************************************
** 函數名稱 :()
** 函數功能 :。
** 入口參數 :x 顯示字符的橫坐標
** y 顯示字符的縱坐標
** chr 顯示的字符,不能為ff
** color 顯示的狀態,包括前景色、背景色、閃爍位。
** 與DOS字符顯示一樣:0~3,前景色,4~6,背景色,7,閃爍位。
** 出口參數 :無
*******************************************************************************************************
*/
void PCDispChar (uint8 uiX, uint8 uiChr)
{
UART0SendByte(0xFF); // 起始字符
UART0SendByte(0x80);
UART0SendByte(uiX);
UART0SendByte(uiChr);
UART0SendByte(0x00);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -