XilinxProcessorIPLib/drivers/canfd/examples/xcanfd_polled_example.c
static int RecvFrame(XCanFd *InstancePtr)
{
	int Status;
	int Dlc;
	u8 *FramePtr;
	u32 Index;

	/* Receive a frame and verify its contents */
	if (XCANFD_GET_RX_MODE(InstancePtr) == 1) {
		Status = XCanFd_Recv_Mailbox(InstancePtr, RxFrame);
	}
	else {
		Status = XCanFd_Recv_Sequential(InstancePtr, RxFrame);
	}
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Get Dlc value */
	Dlc = XCanFd_GetDlc2len(RxFrame[1] & XCANFD_DLCR_DLC_MASK,
		EDL_CANFD);

	/* Verify Identifier and Data Length Code */
	if (RxFrame[0] != XCanFd_CreateIdValue(TEST_MESSAGE_ID, 0, 0, 0, 0)) {
		return XST_FAILURE;
	}
	if (TESTMSG_DLC != XCanFd_GetLen2Dlc(Dlc)) {
		return XST_FAILURE;
	}

	/* Verify Data field contents */
	FramePtr = (u8 *)(&RxFrame[2]);
	for (Index = 0; Index < Dlc; Index++) {
		if (*FramePtr++ != (u8)Index) {
			return XST_FAILURE;
		}
	}
	return Status;
}
/*****************************************************************************/
/**
*
* This function receives a frame and verifies its contents.
*
* @param	InstancePtr is a pointer to the driver instance.
*
* @return	XST_SUCCESS if successful, a driver-specific return code if not.
*
* @note	 	This function waits until RX FIFO becomes not empty before
*		reading a frame	from it. So this function may block if the
*		hardware is not built correctly.
*
******************************************************************************/
This function receives a frame and verifies its contents.
This function receives a frame and verifies its contents .
static int RecvFrame(XCanFd *InstancePtr)
{
	int Status;
	int Dlc;
	u8 *FramePtr;
	u32 Index;
	if (XCANFD_GET_RX_MODE(InstancePtr) == 1) {
		Status = XCanFd_Recv_Mailbox(InstancePtr, RxFrame);
	}
	else {
		Status = XCanFd_Recv_Sequential(InstancePtr, RxFrame);
	}
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Dlc = XCanFd_GetDlc2len(RxFrame[1] & XCANFD_DLCR_DLC_MASK,
		EDL_CANFD);
	if (RxFrame[0] != XCanFd_CreateIdValue(TEST_MESSAGE_ID, 0, 0, 0, 0)) {
		return XST_FAILURE;
	}
	if (TESTMSG_DLC != XCanFd_GetLen2Dlc(Dlc)) {
		return XST_FAILURE;
	}
	FramePtr = (u8 *)(&RxFrame[2]);
	for (Index = 0; Index < Dlc; Index++) {
		if (*FramePtr++ != (u8)Index) {
			return XST_FAILURE;
		}
	}
	return Status;
}
static int RecvFrame ( XCanFd * InstancePtr ) { int Status ; int Dlc ; u8 * FramePtr ; u32 Index ; if ( XCANFD_GET_RX_MODE ( InstancePtr ) == 1 ) { Status = XCanFd_Recv_Mailbox ( InstancePtr , RxFrame ) ; } else { Status = XCanFd_Recv_Sequential ( InstancePtr , RxFrame ) ; } if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Dlc = XCanFd_GetDlc2len ( RxFrame [ 1 ] & XCANFD_DLCR_DLC_MASK , EDL_CANFD ) ; if ( RxFrame [ 0 ] != XCanFd_CreateIdValue ( TEST_MESSAGE_ID , 0 , 0 , 0 , 0 ) ) { return XST_FAILURE ; } if ( TESTMSG_DLC != XCanFd_GetLen2Dlc ( Dlc ) ) { return XST_FAILURE ; } FramePtr = ( u8 * ) ( & RxFrame [ 2 ] ) ; for ( Index = 0 ; Index < Dlc ; Index ++ ) { if ( * FramePtr ++ != ( u8 ) Index ) { return XST_FAILURE ; } } return Status ; }
This function receives a frame and verifies its contents.
This function receives a frame and verifies its contents .
/* Receive a frame and verify its contents */ /* Get Dlc value */ /* Verify Identifier and Data Length Code */ /* Verify Data field contents */