XilinxProcessorIPLib/drivers/can/src/xcan.c
int XCan_Recv(XCan *InstancePtr, u32 *FramePtr)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	/*
	 * Check if RX FIFO has frame(s) sitting in it. If not, return error
	 * code
	 */
	if (XCan_IsRxEmpty(InstancePtr) == TRUE) {
		return XST_NO_DATA;
	}

	/* Read IDR */
	FramePtr[0] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_ID_OFFSET);

	/* Read DLC */
	FramePtr[1] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_DLC_OFFSET);

	/* Read Data Word 1 */
	FramePtr[2] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_DW1_OFFSET);

	/* Read Data Word 2 */
	FramePtr[3] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_DW2_OFFSET);

	/*
	 * Clear RXNEMP bit in ISR. This allows future XCan_IsRxEmpty() call
	 * returns correct RX FIFO occupancy/empty condition.
	 */
	XCan_InterruptClear(InstancePtr, XCAN_IXR_RXNEMP_MASK);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function receives a CAN Frame. This function first checks if RX FIFO is
* empty, if not, it then reads a frame from the RX FIFO into the given buffer.
* This function returns error code immediately if there is no frame in the RX
* FIFO.
*
* @param	InstancePtr is a pointer to the XCan instance to be worked on.
* @param	FramePtr is a pointer to a 32-bit aligned buffer where the CAN
*		frame to be written.
*
* @return
*		- XST_SUCCESS if RX FIFO was not empty and a frame was read from
*		RX FIFO successfully and written into the given buffer;
*		- XST_NO_DATA if there is no frame to be received from the FIFO
*
* @note		None.
*
******************************************************************************/
This function receives a CAN Frame. This function first checks if RX FIFO is
empty, if not, it then reads a frame from the RX FIFO into the given buffer.
This function returns error code immediately if there is no frame in the RX
FIFO.
This function receives a CAN Frame . This function first checks if RX FIFO is empty if not it then reads a frame from the RX FIFO into the given buffer . This function returns error code immediately if there is no frame in the RX FIFO .
int XCan_Recv(XCan *InstancePtr, u32 *FramePtr)
{
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	if (XCan_IsRxEmpty(InstancePtr) == TRUE) {
		return XST_NO_DATA;
	}
	FramePtr[0] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_ID_OFFSET);
	FramePtr[1] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_DLC_OFFSET);
	FramePtr[2] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_DW1_OFFSET);
	FramePtr[3] =
		XCan_ReadReg(InstancePtr->BaseAddress, XCAN_RXFIFO_DW2_OFFSET);
	XCan_InterruptClear(InstancePtr, XCAN_IXR_RXNEMP_MASK);
	return XST_SUCCESS;
}
int XCan_Recv ( XCan * InstancePtr , u32 * FramePtr ) { Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( InstancePtr -> IsReady == XIL_COMPONENT_IS_READY ) ; if ( XCan_IsRxEmpty ( InstancePtr ) == TRUE ) { return XST_NO_DATA ; } FramePtr [ 0 ] = XCan_ReadReg ( InstancePtr -> BaseAddress , XCAN_RXFIFO_ID_OFFSET ) ; FramePtr [ 1 ] = XCan_ReadReg ( InstancePtr -> BaseAddress , XCAN_RXFIFO_DLC_OFFSET ) ; FramePtr [ 2 ] = XCan_ReadReg ( InstancePtr -> BaseAddress , XCAN_RXFIFO_DW1_OFFSET ) ; FramePtr [ 3 ] = XCan_ReadReg ( InstancePtr -> BaseAddress , XCAN_RXFIFO_DW2_OFFSET ) ; XCan_InterruptClear ( InstancePtr , XCAN_IXR_RXNEMP_MASK ) ; return XST_SUCCESS ; }
This function receives a CAN Frame.
This function receives a CAN Frame .
/*
	 * Check if RX FIFO has frame(s) sitting in it. If not, return error
	 * code
	 */ /* Read IDR */ /* Read DLC */ /* Read Data Word 1 */ /* Read Data Word 2 */ /*
	 * Clear RXNEMP bit in ISR. This allows future XCan_IsRxEmpty() call
	 * returns correct RX FIFO occupancy/empty condition.
	 */