/****************************************************************************** * * Copyright (C) 2005 - 2014 Xilinx, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * Use of the Software is limited solely to applications: * (a) running on a Xilinx device, or * (b) that interact with a Xilinx device through a bus or interconnect. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of the Xilinx shall not be used * in advertising or otherwise to promote the sale, use or other dealings in * this Software without prior written authorization from Xilinx. * ******************************************************************************/ /*****************************************************************************/ /** * * @file xcan_selftest.c * * This file contains a diagnostic self-test function for the XCan driver. * * Please see xcan.h for more information. * *
* MODIFICATION HISTORY: * * Ver Who Date Changes * ----- ---- -------- ------------------------------------------------------ * 1.00a xd 04/12/05 First release * 1.10a mta 05/13/07 Updated to new coding style * 2.00a ktn 10/22/09 Updated to use the HAL APIs/macros. * The macros have been renamed to remove _m from the name. ** *****************************************************************************/ /***************************** Include Files ********************************/ #include "xstatus.h" #include "xcan.h" /************************** Constant Definitions ****************************/ #define XCAN_MAX_FRAME_SIZE_IN_WORDS (XCAN_MAX_FRAME_SIZE / sizeof(u32)) /**************************** Type Definitions ******************************/ /***************** Macros (Inline Functions) Definitions ********************/ /************************** Variable Definitions ****************************/ /* Buffers to hold frames to send and receive. */ static u32 TxFrame[XCAN_MAX_FRAME_SIZE_IN_WORDS]; static u32 RxFrame[XCAN_MAX_FRAME_SIZE_IN_WORDS]; /************************** Function Prototypes *****************************/ /*****************************************************************************/ /** * * This function runs a self-test on the CAN driver/device. The test resets * the device, sets up the Loop Back mode, sends a standard frame, receives the * frame, verifies the contents, and resets the device again. * * Note that this is a destructive test in that resets of the device are * performed. Refer to the device specification for the device status * after the reset operation. * * * @param InstancePtr is a pointer to the XCan instance to be worked on. * * @return * - XST_SUCCESS if the self-test passed. i.e., the frame * received via the internal loop back has the same contents as the * sent frame. * - XST_FAILURE Otherwise. * * @note * * If the CAN device does not work properly, this function may enter an * infinite loop and will never return to the caller. *