app_uart.h 1.47 KB
#ifndef _APP_UART_H_
#define _APP_UART_H_


#if 1
#define UART_TX_MAX_LEN    128
#define UART_RX_MAX_LEN    256
#else
#define UART_TX_MAX_LEN    512
#define UART_RX_MAX_LEN    1024
#endif


enum
{
    HCI_UART_STATE_RX_TYPE,
		HCI_UART_STATE_RX_HEADER,
		//HCI_UART_STATE_RX_COMM_HEADER, 
		//HCI_UART_STATE_RX_ACL_HEADER,
		//HCI_UART_STATE_RX_SCO_HEADER,
		//HCI_UART_STATE_RX_EVENT_HEADER, 
		HCI_UART_CHECK_DATA,
		HCI_UART_BCSP_C0_START,
		HCI_UART_BCSP_C0_END,
		HCI_UART_H4_SYNC_ERR
};


/* 
   We use the structure defined below to realize UART interrupt transfer
   the buffer in this structure is split to two parts, the two parts interface with
   MCF5249_uart_write() function and interrupt service routine respectively and alternately
   they can not both interface with MCF5249_uart_write() and ISR at the same time.
*/
/*
typedef struct _UART_DATA {
	U8		Buf [UART_TX_MAX_LEN];
	U16		ReadLen;             
	U16		WriteLen;
	U8		*pWrite;					//use this pointer to write data in
	U8		*pRead;						//use this pointer to send data out
} UART_DATA;

extern volatile UART_DATA uart_data;*/

//extern FIFO UartRxFifo;

void app_uart_init(void);
void app_uart_open(void);
void app_uart_close(void);
void app_uart_fini(void);
void app_uart_write(const char *pBuf);
void app_uart_baudrate(U16 baudrate);

void app_uart0_init(void);
void app_uart1_init(void);
void app_uart2_init(void);

void Uart0_IsrHandler(void);
void Uart1_IsrHandler(void);
void Uart2_IsrHandler(void);

#endif //_APP_UART_H_