SCI0_UART.h 2.32 KB
Newer Older
崔立宝's avatar
崔立宝 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
/******************************************************************************
文 件 名:SCI0_UART.h
功能描述:UART模式SCI0驱动库头文件
作    者:张暄
版    本:V1.0
日    期:2016.11.17
******************************************************************************/

#ifndef _SCI0_UART_H_
#define _SCI0_UART_H_

#include "GPIO.h"
#include "CRG.h"
#include "comdef.h"

/******************************************************************************
UART 配置
******************************************************************************/
#define   SCI0_BAUD_RATE                    19200
#define   SCI0_FORMAT                       SCI0_8BIT_1STOP
#define   SCI0_PARITY_FUNC                  SCI0_PARITY_FUNC_ENABLE
#define   SCI0_PARITY_TYPE                  SCI0_EVEN_PARITY

#define   SCI0_Tx_BUFFER_SIZE               32

/******************************************************************************
UART 配置选项
******************************************************************************/
/*** UART格式 ***/
#define   SCI0_8BIT_1STOP                   0x00
#define   SCI0_9BIT_1STOP                   0x10

/*** 奇偶校验使能 ***/
#define   SCI0_PARITY_FUNC_DISABLE          0x00
#define   SCI0_PARITY_FUNC_ENABLE           0x02

/*** 奇偶校验选择 ***/
#define   SCI0_EVEN_PARITY                  0x00
#define   SCI0_ODD_PARITY                   0x01

/******************************************************************************
寄存器值预定义
******************************************************************************/
#define   SCI0_BAUD_RATE_REG                ((uint16_t)(BUSCLK / 16 / SCI0_BAUD_RATE) & 0x1FFF)
#define   SCI0_CFG_REG                      (SCI0_FORMAT | SCI0_PARITY_FUNC | SCI0_PARITY_TYPE)

/******************************************************************************
发送缓存结构
******************************************************************************/
typedef struct
{
  uint8_t Data[SCI0_Tx_BUFFER_SIZE];
  uint8_t Len;
} SCI0TxBufferStruct;

/******************************************************************************
函数声明
******************************************************************************/
void SCI0_UART_Byte_Rx(uint8_t Data);
void SCI0_UART_Byte_Tx(uint8_t Data);
void SCI0_UART_Block_Tx(uint8_t *Data, uint8_t Len);
uint8_t SCI0_UART_Get_Tx_Buffer_Status(void);
void SCI0_UART_Init(void);

#endif