73 lines
2.7 KiB
C
73 lines
2.7 KiB
C
#ifndef IVEC_ECU_UART_H
|
|
#define IVEC_ECU_UART_H
|
|
|
|
//#include "ivec_mcal_uart.h"
|
|
#include "../Core/Include/ivec_mcal_uart.h"
|
|
#include "../ivec_ECU/ivec_ecu_common/inc/ivec_ecu_common.h"
|
|
//#include "ivec_ecu_common.h"
|
|
|
|
|
|
#include "stdint.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define MAX_PACKET_LENGTH 32/*!<Maximum length of packet that can be received*/
|
|
|
|
#define PKT_HEADER 7/*!<Protocol headers*/
|
|
#define PKT_HEADER_FOOTER 9/*!<Protocol headers+footers*/
|
|
|
|
#endif
|
|
|
|
#define GET_PACKET_SIZE(x) (x + PKT_HEADER_FOOTER)/*!<Complete packet size*/
|
|
|
|
#define PACKET_SUCCESS 0/*!<Success*/
|
|
#define PACKET_FAIL -1/*!<Error*/
|
|
|
|
/*Private Variables*/
|
|
typedef int PacketRetCode_t;/*SERVICE_SUCESS or SERVICE_FAIL*/
|
|
|
|
|
|
|
|
typedef enum
|
|
{
|
|
ecuUART_PORT1 = 0,
|
|
ecuUART_PORT2,
|
|
ecuUART_PORT3,
|
|
ecuUART_PORT_MAX
|
|
}EcuUartPortNumber_e;
|
|
|
|
typedef enum
|
|
{
|
|
IVEC_ECU_UART_EVENT_RX_ARRIVED = 1,//(1 << 0), ///< Received new data
|
|
IVEC_ECU_UART_EVENT_RX_OVERFLOW =2 ,//(1 << 1), ///< Rx fifo overflowed
|
|
IVEC_ECU_UART_EVENT_TX_COMPLETE = 3//(1 << 2) ///< All data had been sent
|
|
}IVEC_EcuUartEvents_e;
|
|
|
|
typedef struct
|
|
{
|
|
McalUartHandle_s __xUartHandle;
|
|
EcuUartPortNumber_e eUartPortNumber;
|
|
volatile uint8_t* u8Qbuffer;
|
|
uint16_t u16QbufSize;
|
|
uint16_t u16len;
|
|
void (*pvUartRecvCallback)(EcuUartPortNumber_e, IVEC_EcuUartEvents_e , char *,uint32_t);
|
|
}EcuUartHandle_s;
|
|
|
|
/*===========================================================================
|
|
* Functions declaration
|
|
===========================================================================*/
|
|
IVEC_EcuCommonErr_e xECU_UARTInit(EcuUartHandle_s* prvUartHandle, uint32_t speed);
|
|
IVEC_EcuCommonErr_e xECU_UARTDeInit(EcuUartHandle_s *prvUartHandle);
|
|
IVEC_EcuCommonErr_e xECU_UARTReInit(EcuUartHandle_s *prvUartHandle, uint32_t speed);
|
|
IVEC_EcuCommonErr_e xECU_UARTTransmit(EcuUartHandle_s *prvUartHandle, uint8_t* pucBuffer, uint16_t len);
|
|
//Uart_Typedef_e xUartWrite(Uart_PortHandle_s *xportHandle, uint8_t* pucBuffer, uint16_t len, uint16_t timeout);
|
|
IVEC_EcuCommonErr_e xECU_UARTGetData(EcuUartHandle_s *prvUartHandle, uint8_t* pucBuffer, uint16_t len, uint16_t timeout);
|
|
//Uart_Typedef_e xUartReceive(Uart_PortHandle_s *xportHandle, uint8_t* pucBuffer, uint16_t len, uint16_t timeout);
|
|
|
|
PacketRetCode_t xECU_FormatUartPacket(EcuUartHandle_s *prvUartHandle, uint8_t* pucData, uint8_t ucDlc, uint32_t ulId);
|
|
PacketRetCode_t xECU_ReadCANDataLenOverUART(EcuUartHandle_s *prvUartHandle, uint8_t* pucBuf, uint32_t *ulId);
|
|
|
|
PacketRetCode_t xECU_ReadCANDataOverUART(EcuUartHandle_s* prvUartHandle, uint8_t* pucBuf, uint32_t *ulId);
|
|
int vECU_InitiateUartToCanTransmit(EcuUartHandle_s* prvUartHandle, uint32_t id, uint8_t *pucData, uint8_t ucLen);
|