#ifndef __DEBUG_H__
#define __DEBUG_H__ 

#include "stdio.h"	
#include "type.h"
#include "sys.h"
#include "drv_reg.h"

#define DEBUG

#define UART_CR2_TE_MASK            0x08
#define UART_SR1_TDRE_MASK          0x80
#define UART_SR1_TC_MASK            0x40
#define UART_CR2_RE_MASK						0x04		
#define UART_SR1_RDRF_MASK					0x20

#define UART_RECV_MAX_LEN  									512
typedef struct uart_recv_buf
{
	UINT16 rp;//read pointer
	UINT16 wp;//write pointer
	UINT8  dat[UART_RECV_MAX_LEN];//buffer
}RecvBufStruct;

extern RecvBufStruct gUartRev;

extern UINT8 Frame_AA_OK;
extern UINT16 Frame_count;

extern UINT8 Rx_Buffer_short[256];
extern UINT8 Rx_Buffer_long[2048+2];
extern UINT16  Rx_Count_short;
extern UINT16 Rx_Count_long;
extern UINT16 Rx_Num;
extern UINT16 Respond_Num ;
extern UINT16 Respond_Count;

extern UINT8 Respond_AA_OK;

void LT_ClearRxBuf(void);
void LT_DataToPc(UINT8 *buf,UINT8 len);
void LT_DataToPc_NoFrame(UINT8 *buf,UINT8 len);

#define MSG   printf

/* Exported macro ------------------------------------------------------------*/
#ifdef  DEBUG
/*******************************************************************************
* Macro Name     : assert_param
* Description    : The assert_param macro is used for function's parameters check.
*                  It is used only if the library is compiled in DEBUG mode.
* Input          : - expr: If expr is false, it calls assert_failed function
*                    which reports the name of the source file and the source
*                    line number of the call that failed.
*                    If expr is true, it returns no value.
* Return         : None
*******************************************************************************/
  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
extern void assert_failed(uint8_t* file, uint32_t line);
extern void UART_Debug_Init(UART_TypeDef *UARTx,uint32_t pclk,uint32_t bound);  
#else
  #define assert_param(expr) ((void)0)
#endif /* DEBUG */

void configRtc(void);
extern u16 uartCountDown;
extern void UART1_IRQHandlerEvent(void);
extern void HandleUartEvent(void);
  
void UART1_Init(uint32_t pclk,uint32_t bound);  
#endif	   
















