?? uart_api.h
字號:
/****************************************************************************
* Copyright (C), 2010 安富萊電子 www.armfly.com
*
* 文件名: usart_api.h
* 內(nèi)容簡述: 串口模塊頭文件。
*
* 文件歷史:
* 版本號 日期 作者 說明
* v0.1 2010-08-21 armfly 創(chuàng)建該文件
*
*/
#ifndef _USART_API_H_
#define _USART_API_H_
#define CPU_IntDis() { __set_PRIMASK(1); } /* 關(guān)中斷 */
#define CPU_IntEn() { __set_PRIMASK(0); } /* 開中斷 */
/* 全局參數(shù) */
typedef struct
{
USART_TypeDef *uart; /* */
uint8_t *pTxBuf; /* 發(fā)送緩沖區(qū) */
uint8_t *pRxBuf; /* 接收緩沖區(qū) */
uint16_t usTxBufSize; /* 發(fā)送緩沖區(qū)大小 */
uint16_t usRxBufSize; /* 接收緩沖區(qū)大小 */
uint16_t usTxWrite; /* 發(fā)送緩沖區(qū)寫指針 */
uint16_t usTxRead; /* 發(fā)送緩沖區(qū)讀指針 */
uint16_t usRxWrite; /* 接收緩沖區(qū)寫指針 */
uint16_t usRxRead; /* 接收緩沖區(qū)讀指針 */
void (*SendOver)(void); /* 發(fā)送完畢的回調(diào)函數(shù)指針 */
void (*ReciveNew)(void); /* 串口收到數(shù)據(jù)的回調(diào)函數(shù)指針 */
}UART_T;
/* 定義端口號 */
typedef enum
{
COM1 = 0, /* COM1口, RS232 */
COM2 = 1, /* COM2口, RS232 */
COM3 = 2 /* COM3口, RS485 */
}PORT_NO_E;
#define UART1_TX_BUF_SIZE 2*1024
#define UART1_RX_BUF_SIZE 2*1024
#define UART2_TX_BUF_SIZE 2*1024
#define UART2_RX_BUF_SIZE 2*1024
#define UART3_TX_BUF_SIZE 1024
#define UART3_RX_BUF_SIZE 1024
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void USART3_IRQHandler(void);
void comInit(void);
void comSendBuf(uint8_t _ucPort, uint8_t *_ucaBuf, uint16_t _usLen);
void comSendChar(uint8_t _ucPort, uint8_t _ucByte);
uint8_t comGetChar(uint8_t _ucPort, uint8_t *_pByte);
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -