2 /***************************** Include Files *******************************/
3 #include "servo_led_ps2.h"
4 #include "xparameters.h"
8 /************************** Constant Definitions ***************************/
9 #define READ_WRITE_MUL_FACTOR 0x10
11 /************************** Function Definitions ***************************/
14 * Run a self-test on the driver/device. Note this may be a destructive test if
15 * resets of the device are performed.
17 * If the hardware system is not built correctly, this function may never
18 * return to the caller.
20 * @param baseaddr_p is the base address of the SERVO_LED_PS2instance to be worked on.
24 * - XST_SUCCESS if all self-test code passed
25 * - XST_FAILURE if any self-test code failed
27 * @note Caching must be turned off for this function to work.
28 * @note Self test may fail if data memory and device are not on the same bus.
31 XStatus SERVO_LED_PS2_Reg_SelfTest(void * baseaddr_p)
38 baseaddr = (u32) baseaddr_p;
40 xil_printf("******************************\n\r");
41 xil_printf("* User Peripheral Self Test\n\r");
42 xil_printf("******************************\n\n\r");
45 * Write to user logic slave module register(s) and read back
47 xil_printf("User logic slave module test...\n\r");
49 for (write_loop_index = 0 ; write_loop_index < 4; write_loop_index++)
50 SERVO_LED_PS2_mWriteReg (baseaddr, write_loop_index*4, (write_loop_index+1)*READ_WRITE_MUL_FACTOR);
51 for (read_loop_index = 0 ; read_loop_index < 4; read_loop_index++)
52 if ( SERVO_LED_PS2_mReadReg (baseaddr, read_loop_index*4) != (read_loop_index+1)*READ_WRITE_MUL_FACTOR){
53 xil_printf ("Error reading register value at address %x\n", (int)baseaddr + read_loop_index*4);
57 xil_printf(" - slave register write/read passed\n\n\r");