uart.h 784 Bytes
#ifndef __UART_H
#define __UART_H
#include "stdint.h"	
#define RX_END_BYTE_LEN		2
#define RX_END_BYTE_1		0x0D
#define RX_END_BYTE_2		0x0A

typedef enum
{
  RX_STA_RST = 0x00,
  RX_RECEIVING =0x01,
	RX_FINISHED =0x02,
}UART_RX_STATUS;

typedef enum
{
  TX_MODE = 0x00,
  RX_MODE = 0x01,
}UART_TX_STATUS;

typedef enum
{
	BAUDRATE_4800 = 4800,
	BAUDRATE_9600 = 9600,
	BAUDRATE_19200 = 19200,
	BAUDRATE_38400 = 38400,
	BAUDRATE_57600 = 57600,
	BAUDRATE_115200 = 115200,	
}BaudRate_Value;
typedef struct uart_timer{
	void (* start)();
	void (* stop)();
	void (* timeclear)();
	void (* callback)();
} Uart_Timer;

typedef struct uart_type{

	uint8_t	* rx_buf;
	uint16_t 	rx_len;
	uint8_t	* tx_buf;
	uint16_t 	tx_len;
	UART_RX_STATUS	rx_status;
	Uart_Timer *rxtimer;
} Uart_Type;

#endif