#ifndef UART_H__
#define UART_H__
/*-----------------use for RH850_D1M1A --------------------*/
#include "r_typedefs.h"

/***************************************************************/
/***************************************************************/

typedef enum
{
    UART_RLIN30 = 0U,
    UART_RLIN31,
    UART_RLIN32,
    UART_RLIN33,
    UART_RLIN_MAX,
} UART_Channel_en_t;

typedef void (*UART_Confirm)(void);
typedef void (*UART_Read_Msg)(uint16_t u16UARTData);

typedef struct
{
    uint32_t u32UARTChEn; /*通道是否使能*/
    uint32_t u32UARTbps;  /*通道实际波特率*/
    UART_Confirm pfnUARTConfirmCallBack;
    UART_Read_Msg pfnUARTReadMsgCallBack;

} UART_Channel_Config_st_t;

/****************************************************************/

extern void UART_CH0_TX_ISR(void);
extern void UART_CH1_TX_ISR(void);
extern void UART_CH2_TX_ISR(void);
extern void UART_CH3_TX_ISR(void);
extern void UART_CH0_RX_ISR(void);
extern void UART_CH1_RX_ISR(void);
extern void UART_CH2_RX_ISR(void);
extern void UART_CH3_RX_ISR(void);

extern uint8_t UART_Ch0_Get_TX_Busy_Flag(void);
extern uint8_t UART_Ch1_Get_TX_Busy_Flag(void);
extern uint8_t UART_Ch2_Get_TX_Busy_Flag(void);
extern uint8_t UART_Ch3_Get_TX_Busy_Flag(void);

extern void UART_Ch0_Send_Multiple_Byte(uint8_t *Data, uint8_t Len);
extern void UART_Ch1_Send_Multiple_Byte(uint8_t *Data, uint8_t Len);
extern void UART_Ch2_Send_Multiple_Byte(uint8_t *Data, uint8_t Len);
extern void UART_Ch3_Send_Multiple_Byte(uint8_t *Data, uint8_t Len);

/*首次上30和每次唤醒时调用*/
extern uint32_t UART_Init(UART_Channel_en_t enUARTCh, UART_Channel_Config_st_t *penUARTCfg);
/*休眠时调用*/
//extern void UART_Sleep_Init(UART_Channel_en_t enUARTCh);
extern void UART_Sleep_Init(void);
/******************************************************/
/******************************************************/
/******************************************************/


extern void Uart_ConfigOperationMode(void);
extern unsigned char Uart_GetRxLevel(void);
extern void Uart_ClearRxFullFlag(void);
extern void Uart_SetBaudrate(unsigned long xBaudrate_u32);
extern void Uart_SetRxGpio(void);
extern void Uart_SetTxGpio(void);
extern void Uart_EnableRx(void);
extern void Uart_DisableRx(void);
extern void TJA1021_Enable(unsigned char state);
extern void Uart_EnableTx(void);
extern void Uart_ClearAllErrorFlag(void);
extern void Uart_SetData(unsigned char xBuffer_pu8);
extern unsigned short Uart_GetData(void);
extern void Uart_DisableReceiveIsrReq(void);
extern void Uart_EnableReceiveIsrReq(void);
extern void Uart_DisableTxInterrupt(void);

#endif

