XilinxProcessorIPLib/drivers/canps/examples/xcanps_watermark_intr_example.c
static int ReceiveData(XCanPs *InstancePtr)
{
	int Status;
	int Index;
	u8 *FramePtr;
	u8 NumRxFrames;

	/*
	 * Initialize the number of received frames to Zero.
	 */
	NumRxFrames = 0;

	/*
	 * Read the received CAN Frames from the FIFO till the FIFO is Empty.
	 */
	while (XCanPs_IntrGetStatus(InstancePtr) & XCANPS_IXR_RXNEMP_MASK) {

		Status = XCanPs_Recv(InstancePtr, RxFrame);
		if (Status != XST_SUCCESS) {
			LoopbackError = TRUE;
			return XST_FAILURE;
		}

		/*
		 * Verify Identifier and Data Length Code.
		 */
		if (RxFrame[0] !=
			(u32)XCanPs_CreateIdValue((u32)TEST_MESSAGE_ID, 0, 0, 0, 0)) {

			LoopbackError = TRUE;
			return XST_FAILURE;
		}
		if ((RxFrame[1] & ~XCANPS_DLCR_TIMESTAMP_MASK) != TxFrame[1]) {
			LoopbackError = TRUE;
			return XST_FAILURE;
		}

		/*
		 * Verify Data field contents.
		 */
		FramePtr = (u8 *)(&RxFrame[2]);
		for (Index = 0; Index < FRAME_DATA_LENGTH; Index++) {
			if (*FramePtr++ != ((u8)Index + TestDataOffset)) {
				LoopbackError = TRUE;
				return XST_FAILURE;
			}
		}

		/*
		 * Increment the number of frames received.
		 */
		TestDataOffset++;
		NumRxFrames++;

	}

	if (NumRxFrames == TEST_THRESHOLD) {
		LoopbackError = FALSE;
		return XST_SUCCESS;
	}
	return XST_FAILURE;
}
/*****************************************************************************/
/**
*
* Read the Received CAN frames from the FIFO.
*
* @param	InstancePtr is a pointer to the driver instance.
*
* @return
*		- XST_SUCCESS if all the CAN Frames are received and the
*		data is the same as that was sent.
*		- XST_FAILURE if the required number of CAN frames have not
*		been received or if the Received Data is not the same as the
*		data that was sent.
*
* @note		None.
*
******************************************************************************/
Read the Received CAN frames from the FIFO.
Read the Received CAN frames from the FIFO .
static int ReceiveData(XCanPs *InstancePtr)
{
	int Status;
	int Index;
	u8 *FramePtr;
	u8 NumRxFrames;
	NumRxFrames = 0;
	while (XCanPs_IntrGetStatus(InstancePtr) & XCANPS_IXR_RXNEMP_MASK) {
		Status = XCanPs_Recv(InstancePtr, RxFrame);
		if (Status != XST_SUCCESS) {
			LoopbackError = TRUE;
			return XST_FAILURE;
		}
		if (RxFrame[0] !=
			(u32)XCanPs_CreateIdValue((u32)TEST_MESSAGE_ID, 0, 0, 0, 0)) {
			LoopbackError = TRUE;
			return XST_FAILURE;
		}
		if ((RxFrame[1] & ~XCANPS_DLCR_TIMESTAMP_MASK) != TxFrame[1]) {
			LoopbackError = TRUE;
			return XST_FAILURE;
		}
		FramePtr = (u8 *)(&RxFrame[2]);
		for (Index = 0; Index < FRAME_DATA_LENGTH; Index++) {
			if (*FramePtr++ != ((u8)Index + TestDataOffset)) {
				LoopbackError = TRUE;
				return XST_FAILURE;
			}
		}
		TestDataOffset++;
		NumRxFrames++;
	}
	if (NumRxFrames == TEST_THRESHOLD) {
		LoopbackError = FALSE;
		return XST_SUCCESS;
	}
	return XST_FAILURE;
}
static int ReceiveData ( XCanPs * InstancePtr ) { int Status ; int Index ; u8 * FramePtr ; u8 NumRxFrames ; NumRxFrames = 0 ; while ( XCanPs_IntrGetStatus ( InstancePtr ) & XCANPS_IXR_RXNEMP_MASK ) { Status = XCanPs_Recv ( InstancePtr , RxFrame ) ; if ( Status != XST_SUCCESS ) { LoopbackError = TRUE ; return XST_FAILURE ; } if ( RxFrame [ 0 ] != ( u32 ) XCanPs_CreateIdValue ( ( u32 ) TEST_MESSAGE_ID , 0 , 0 , 0 , 0 ) ) { LoopbackError = TRUE ; return XST_FAILURE ; } if ( ( RxFrame [ 1 ] & ~ XCANPS_DLCR_TIMESTAMP_MASK ) != TxFrame [ 1 ] ) { LoopbackError = TRUE ; return XST_FAILURE ; } FramePtr = ( u8 * ) ( & RxFrame [ 2 ] ) ; for ( Index = 0 ; Index < FRAME_DATA_LENGTH ; Index ++ ) { if ( * FramePtr ++ != ( ( u8 ) Index + TestDataOffset ) ) { LoopbackError = TRUE ; return XST_FAILURE ; } } TestDataOffset ++ ; NumRxFrames ++ ; } if ( NumRxFrames == TEST_THRESHOLD ) { LoopbackError = FALSE ; return XST_SUCCESS ; } return XST_FAILURE ; }
Read the Received CAN frames from the FIFO.
Read the Received CAN frames from the FIFO .
/*
	 * Initialize the number of received frames to Zero.
	 */ /*
	 * Read the received CAN Frames from the FIFO till the FIFO is Empty.
	 */ /*
		 * Verify Identifier and Data Length Code.
		 */ /*
		 * Verify Data field contents.
		 */ /*
		 * Increment the number of frames received.
		 */