?? uart.h
字號:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: uart.h
** Latest modified Date: 2008-8-20
** Latest Version: 1.0
** Descriptions: 串口外設的頭文件
**
**--------------------------------------------------------------------------------------------------------
** Created by: CaiWenqi
** Created date: 2008-8-20
** Version: 1.0
** Descriptions: The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
#ifndef __uart_h
#define __uart_h
/*********************************************************************************************************
Config for UART_LCR Register
*********************************************************************************************************/
#define LEN_5BIT 0 /* 配置數據長度 */
#define LEN_6BIT 1
#define LEN_7BIT 2
#define LEN_8BIT 3
#define STOP_2BIT (1 << 2) /* 配置停止位2bit */
#define PARITY_EN (1 << 3) /* 是否校驗 */
#define PARITY_E (1 << 4) /* 偶校驗 */
#define BREAK_EN (1 << 6) /* 強制TX為0 */
/*********************************************************************************************************
Config for UART_MCR Register
*********************************************************************************************************/
#define LOOP_EN (1 << 4) /* 接收脫離RX,連接TX(自發自收) */
/*********************************************************************************************************
Config for UART_LSR Register
*********************************************************************************************************/
#define RBR_NEW 1 /* RBR寄存器接收到新數據 */
#define RBR_OE (1 << 1) /* RBR數據未讀出就被新數據覆蓋 */
#define PARITY_ERR (1 << 2) /* 校驗錯誤 */
#define FRAME_ERR (1 << 3) /* 幀錯誤(停止位無效) */
#define BREAK_INT (1 << 4) /* 檢測到間隔中斷 */
#define THR_EMPTY (1 << 5) /* 發送保持寄存器為空 */
#define TSR_THR_EMPTY (1 << 6) /* 發送保持和移位寄存器均空 */
/*********************************************************************************************************
Config for UART_IER Register
*********************************************************************************************************/
#define RBFI_EN 1 /* 允許接收到新數據到RBR時中斷 */
#define TBEI_EN (1 << 1) /* 允許發送保持寄存器為空時中斷 */
#define LSI_EN (1 << 2) /* 允許接收線狀態中斷 */
/*********************************************************************************************************
Config for UART_IIR Register
*********************************************************************************************************/
#define HAVE_INT 1 /* 有中斷發生 */
#define HAVE_THRE_INT (1 << 1) /* 有THRE中斷 */
#define HAVE_RBR_INT (2 << 1) /* 有RBR中斷 */
#define HAVE_LSR_INT (3 << 1) /* 有LSR中斷 */
/*********************************************************************************************************
define for function
*********************************************************************************************************/
#define PARITY_DIS 0
#define PARITY_ODD 1
#define PARITY_EVEN 2
/*********************************************************************************************************
** Function name: uartConfig
** Descriptions: 設置UART基本通訊參數
** Input parameters: usBaud : 設置的波特率
** usByteLength : 可取 5, 6 ,7 ,8
** usStopbit : 可取 1, 2
** usParityCheck : PARITY_DIS -- 不進行校驗
PARITY_ODD -- 進行奇校驗
PARITY_EVEN-- 進行偶校驗
** Output parameters: NONE
** Returned value: true -- 成功設置,false -- 設置失敗
*********************************************************************************************************/
extern uint16 uartConfig (uint16 usBaud,
uint16 usByteLength,
uint16 usStopbit,
uint16 usParityCheck);
/*********************************************************************************************************
** Function name: uartSendChar
** Descriptions: 發送單個字符
** Input parameters: cChar : 發送字符
** Output parameters: NONE
** Returned value: NONE
*********************************************************************************************************/
extern void uartSendChar(char cChar);
/*********************************************************************************************************
** Function name: uartSendStr
** Descriptions: 發送字符串
** Input parameters: cStr : 字符串指針
** Output parameters: NONE
** Returned value: NONE
*********************************************************************************************************/
extern void uartSendStr(char *cStr);
#endif
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -