mirror of https://github.com/rusefi/openblt.git
Refs #460. Added length parameter to the XCP packet reception functions.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@424 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
817212b60f
commit
6f80eb072f
|
@ -246,12 +246,14 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId;
|
||||
blt_int8u rxMsgDlc;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
||||
/* check if a new message was received */
|
||||
|
@ -268,6 +270,13 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
/* see if this is the message identifier that we are interested in */
|
||||
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
|
||||
{
|
||||
/* store the message data length */
|
||||
rxMsgDlc = ((blt_int8u)(CAN1RFS >> 16)) & 0x0Fu;
|
||||
if (rxMsgDlc > 8)
|
||||
{
|
||||
rxMsgDlc = 8;
|
||||
}
|
||||
*len = rxMsgDlc;
|
||||
/* store the message data */
|
||||
data[0] = (blt_int8u)CAN1RDA;
|
||||
data[1] = (blt_int8u)(CAN1RDA >> 8);
|
||||
|
|
|
@ -165,10 +165,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -208,6 +209,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -222,10 +222,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
CanRxMsg rxMsg;
|
||||
blt_int8u byteIdx;
|
||||
|
@ -252,6 +253,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
/* is the identifier a match to the bootloader reception message identifier? */
|
||||
if (canIdMatched == BLT_TRUE)
|
||||
{
|
||||
*len = rxMsg.DLC;
|
||||
for (byteIdx=0; byteIdx<rxMsg.DLC; byteIdx++)
|
||||
{
|
||||
data[byteIdx] = rxMsg.Data[byteIdx];
|
||||
|
|
|
@ -145,10 +145,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -188,6 +189,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -241,10 +241,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int8u byteIdx;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -255,6 +256,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
/* read out and process the newly received data */
|
||||
if (XMC_CAN_MO_ReceiveData(&receiveMsgObj) == XMC_CAN_STATUS_SUCCESS)
|
||||
{
|
||||
*len = receiveMsgObj.can_data_length;
|
||||
for (byteIdx=0; byteIdx<receiveMsgObj.can_data_length; byteIdx++)
|
||||
{
|
||||
data[byteIdx] = receiveMsgObj.can_data_byte[byteIdx];
|
||||
|
|
|
@ -135,10 +135,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -178,6 +179,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -126,10 +126,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -169,6 +170,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -198,10 +198,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u status;
|
||||
tCANMsgObject msgObject;
|
||||
|
@ -217,6 +218,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
/* read the message data */
|
||||
msgObject.pucMsgData = data;
|
||||
CANMessageGet(CAN0_BASE, CAN_RX_MSGOBJECT_IDX+1, &msgObject, true);
|
||||
*len = msgObject.ulMsgLen;
|
||||
/* message was successfully received */
|
||||
return BLT_TRUE;
|
||||
} /*** end of CanReceivePacket ***/
|
||||
|
|
|
@ -109,10 +109,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -152,6 +153,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -334,10 +334,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -361,6 +362,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
|
||||
{
|
||||
result = BLT_TRUE;
|
||||
*len = ((blt_int8u)(CANx->sFIFOMailBox[0].RDTR)) & 0x0fu;
|
||||
/* store the received packet data */
|
||||
data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR;
|
||||
data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8);
|
||||
|
|
|
@ -159,10 +159,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -202,6 +203,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -171,10 +171,11 @@ void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UsbReceivePacket(blt_int8u *data)
|
||||
blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -214,7 +215,8 @@ blt_bool UsbReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -365,10 +365,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -392,6 +393,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
|
||||
{
|
||||
result = BLT_TRUE;
|
||||
*len = ((blt_int8u)(CANx->sFIFOMailBox[0].RDTR)) & 0x0fu;
|
||||
/* store the received packet data */
|
||||
data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR;
|
||||
data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8);
|
||||
|
|
|
@ -135,10 +135,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -178,6 +179,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -269,10 +269,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId = BOOT_COM_CAN_RX_MSG_ID;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -314,6 +315,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
{
|
||||
data[byteIdx] = canHandle.pRxMsg->Data[byteIdx];
|
||||
}
|
||||
*len = canHandle.pRxMsg->DLC;
|
||||
/* update the return value to indicate that new packet data was received. */
|
||||
result = BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -125,10 +125,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -168,6 +169,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -365,10 +365,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -392,6 +393,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
|
||||
{
|
||||
result = BLT_TRUE;
|
||||
*len = ((blt_int8u)(CANx->sFIFOMailBox[0].RDTR)) & 0x0fu;
|
||||
/* store the received packet data */
|
||||
data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR;
|
||||
data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8);
|
||||
|
|
|
@ -136,10 +136,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -179,6 +180,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -172,10 +172,11 @@ void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UsbReceivePacket(blt_int8u *data)
|
||||
blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -215,7 +216,8 @@ blt_bool UsbReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -278,10 +278,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId = BOOT_COM_CAN_RX_MSG_ID;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -302,7 +303,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* negate the ID-type bit */
|
||||
/* negate the ID-type bit. */
|
||||
rxMsgId &= ~0x80000000;
|
||||
/* was an 29-bit CAN message received that matches? */
|
||||
if ( (rxMsgHeader.ExtId == rxMsgId) &&
|
||||
|
@ -313,6 +314,11 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
}
|
||||
}
|
||||
}
|
||||
/* store the data length. */
|
||||
if (result == BLT_TRUE)
|
||||
{
|
||||
*len = rxMsgHeader.DLC;
|
||||
}
|
||||
/* Give the result back to the caller. */
|
||||
return result;
|
||||
} /*** end of CanReceivePacket ***/
|
||||
|
|
|
@ -133,10 +133,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -176,6 +177,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -111,10 +111,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -154,6 +155,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -186,10 +186,11 @@ void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UsbReceivePacket(blt_int8u *data)
|
||||
blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -229,7 +230,8 @@ blt_bool UsbReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -245,10 +245,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int8u byteIdx;
|
||||
blt_bool result = BLT_FALSE;
|
||||
|
@ -259,6 +260,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
/* read out and process the newly received data */
|
||||
if (XMC_CAN_MO_ReceiveData(&receiveMsgObj) == XMC_CAN_STATUS_SUCCESS)
|
||||
{
|
||||
*len = receiveMsgObj.can_data_length;
|
||||
for (byteIdx=0; byteIdx<receiveMsgObj.can_data_length; byteIdx++)
|
||||
{
|
||||
data[byteIdx] = receiveMsgObj.can_data_byte[byteIdx];
|
||||
|
|
|
@ -137,10 +137,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -180,6 +181,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -354,10 +354,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool CanReceivePacket(blt_int8u *data)
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
blt_int32u rxMsgId;
|
||||
blt_int8u rxMsgLen;
|
||||
|
@ -391,6 +392,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
{
|
||||
data[byte_idx] = CAN->rxSlot.dsr[byte_idx];
|
||||
}
|
||||
*len = rxMsgLen;
|
||||
}
|
||||
/* release the receive object by clearing the rx flag */
|
||||
CAN->crflg &= RXF_BIT;
|
||||
|
|
|
@ -154,10 +154,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -197,6 +198,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -163,10 +163,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool UartReceivePacket(blt_int8u *data)
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
|
||||
static blt_int8u xcpCtoRxLength;
|
||||
|
@ -206,6 +207,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
|
||||
/* done with cto packet reception */
|
||||
xcpCtoRxInProgress = BLT_FALSE;
|
||||
/* set the packet length */
|
||||
*len = xcpCtoRxLength;
|
||||
/* packet reception complete */
|
||||
return BLT_TRUE;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
****************************************************************************************/
|
||||
void CanInit(void);
|
||||
void CanTransmitPacket(blt_int8u *data, blt_int8u len);
|
||||
blt_bool CanReceivePacket(blt_int8u *data);
|
||||
blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len);
|
||||
#endif /* BOOT_COM_CAN_ENABLE > 0 */
|
||||
|
||||
|
||||
|
|
|
@ -97,43 +97,44 @@ void ComInit(void)
|
|||
****************************************************************************************/
|
||||
void ComTask(void)
|
||||
{
|
||||
blt_int8u xcpPacketLen;
|
||||
/* make xcpCtoReqPacket static for runtime efficiency */
|
||||
static blt_int8u xcpCtoReqPacket[BOOT_COM_RX_MAX_DATA];
|
||||
|
||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
||||
if (CanReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE)
|
||||
if (CanReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
|
||||
{
|
||||
/* make this the active interface */
|
||||
comActiveInterface = COM_IF_CAN;
|
||||
/* process packet */
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0]);
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_UART_ENABLE > 0)
|
||||
if (UartReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE)
|
||||
if (UartReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
|
||||
{
|
||||
/* make this the active interface */
|
||||
comActiveInterface = COM_IF_UART;
|
||||
/* process packet */
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0]);
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
if (UsbReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE)
|
||||
if (UsbReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
|
||||
{
|
||||
/* make this the active interface */
|
||||
comActiveInterface = COM_IF_USB;
|
||||
/* process packet */
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0]);
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_NET_ENABLE > 0)
|
||||
if (NetReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE)
|
||||
if (NetReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
|
||||
{
|
||||
/* make this the active interface */
|
||||
comActiveInterface = COM_IF_NET;
|
||||
/* process packet */
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0]);
|
||||
XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
|
||||
}
|
||||
#endif
|
||||
} /*** end of ComTask ***/
|
||||
|
|
|
@ -171,10 +171,11 @@ void NetTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
/************************************************************************************//**
|
||||
** \brief Receives a communication interface packet if one is present.
|
||||
** \param data Pointer to byte array where the data is to be stored.
|
||||
** \param len Pointer where the length of the packet is to be stored.
|
||||
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
blt_bool NetReceivePacket(blt_int8u *data)
|
||||
blt_bool NetReceivePacket(blt_int8u *data, blt_int8u *len)
|
||||
{
|
||||
/* run the TCP/IP server task function, which will handle the reception and
|
||||
* transmission of XCP packets
|
||||
|
@ -238,7 +239,7 @@ void NetApp(void)
|
|||
s->dto_len = 0;
|
||||
/* the first 4 bytes contain a counter value in which we are not really interested */
|
||||
newDataPtr = uip_appdata;
|
||||
XcpPacketReceived(&newDataPtr[4]);
|
||||
XcpPacketReceived(&newDataPtr[4], (blt_int8u)(uip_datalen() - 4));
|
||||
}
|
||||
} /*** end of NetApp ***/
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ typedef struct net_state
|
|||
void NetInit(void);
|
||||
void NetApp(void);
|
||||
void NetTransmitPacket(blt_int8u *data, blt_int8u len);
|
||||
blt_bool NetReceivePacket(blt_int8u *data);
|
||||
blt_bool NetReceivePacket(blt_int8u *data, blt_int8u *len);
|
||||
#else /* BOOT_COM_NET_ENABLE > 0 */
|
||||
|
||||
typedef struct net_state
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
****************************************************************************************/
|
||||
void UartInit(void);
|
||||
void UartTransmitPacket(blt_int8u *data, blt_int8u len);
|
||||
blt_bool UartReceivePacket(blt_int8u *data);
|
||||
blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len);
|
||||
#endif /* BOOT_COM_UART_ENABLE > 0 */
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
void UsbInit(void);
|
||||
void UsbFree(void);
|
||||
void UsbTransmitPacket(blt_int8u *data, blt_int8u len);
|
||||
blt_bool UsbReceivePacket(blt_int8u *data);
|
||||
blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len);
|
||||
|
||||
/****************************************************************************************
|
||||
* Hook functions
|
||||
|
|
|
@ -104,7 +104,7 @@ static void XcpCmdProgramPrepare(blt_int8u *data);
|
|||
* Hook functions
|
||||
****************************************************************************************/
|
||||
#if (XCP_PACKET_RECEIVED_HOOK_EN == 1)
|
||||
extern blt_bool XcpPacketReceivedHook(blt_int8u *data);
|
||||
extern blt_bool XcpPacketReceivedHook(blt_int8u *data, blt_int8u len);
|
||||
#endif
|
||||
|
||||
#if (XCP_RES_PAGING_EN == 1)
|
||||
|
@ -193,17 +193,22 @@ void XcpPacketTransmitted(void)
|
|||
/************************************************************************************//**
|
||||
** \brief Informs the core that a new packet was received by the transport layer.
|
||||
** \param data Pointer to byte buffer with packet data.
|
||||
** \param len Number of bytes in the packet.
|
||||
** \return none
|
||||
**
|
||||
****************************************************************************************/
|
||||
void XcpPacketReceived(blt_int8u *data)
|
||||
void XcpPacketReceived(blt_int8u *data, blt_int8u len)
|
||||
{
|
||||
#if (XCP_PACKET_RECEIVED_HOOK_EN == 1)
|
||||
|
||||
#if (XCP_PACKET_RECEIVED_HOOK_EN == 0)
|
||||
/* suppress compiler warning due to unused parameter. */
|
||||
(void)len;
|
||||
#else
|
||||
/* give the hook function a chance to process this packet. A return value of BLT_TRUE
|
||||
* indicates that the hook function processed the packet and that no further processing
|
||||
* is required.
|
||||
*/
|
||||
if (XcpPacketReceivedHook(data) == BLT_TRUE)
|
||||
if (XcpPacketReceivedHook(data, len) == BLT_TRUE)
|
||||
{
|
||||
/* packet processed by hook function so no need to continue. */
|
||||
return;
|
||||
|
|
|
@ -235,7 +235,7 @@
|
|||
void XcpInit(void);
|
||||
blt_bool XcpIsConnected(void);
|
||||
void XcpPacketTransmitted(void);
|
||||
void XcpPacketReceived(blt_int8u *data);
|
||||
void XcpPacketReceived(blt_int8u *data, blt_int8u len);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
|
Loading…
Reference in New Issue