s32 Xil_TestIO16(u16 *Addr, s32 Length, u16 Value, s32 Kind, s32 Swap) { u16 *TempAddr16; u16 ValueIn = 0U; s32 Index; TempAddr16 = Addr; Xil_AssertNonvoid(TempAddr16 != NULL); for (Index = 0; Index < Length; Index++) { switch (Kind) { case XIL_TESTIO_LE: Xil_Out16LE((INTPTR)TempAddr16, Value); break; case XIL_TESTIO_BE: Xil_Out16BE((INTPTR)TempAddr16, Value); break; default: Xil_Out16((INTPTR)TempAddr16, Value); break; } ValueIn = Xil_In16((INTPTR)TempAddr16); if ((Kind != 0) && (Swap != 0)) { ValueIn = Swap16(ValueIn); } if (Value != ValueIn) { return -1; } /* second round */ Xil_Out16((INTPTR)TempAddr16, Value); switch (Kind) { case XIL_TESTIO_LE: ValueIn = Xil_In16LE((INTPTR)TempAddr16); break; case XIL_TESTIO_BE: ValueIn = Xil_In16BE((INTPTR)TempAddr16); break; default: ValueIn = Xil_In16((INTPTR)TempAddr16); break; } if ((Kind != 0) && (Swap != 0)) { ValueIn = Swap16(ValueIn); } if (Value != ValueIn) { return -1; } TempAddr16 += sizeof(u16); } return 0; }
int Xil_TestIO16(u16 *Addr, int Len, u16 Value, int Kind, int Swap) { u16 ValueIn; int Index; for (Index = 0; Index < Len; Index++) { switch (Kind) { case XIL_TESTIO_LE: Xil_Out16LE((u32)Addr, Value); break; case XIL_TESTIO_BE: Xil_Out16BE((u32)Addr, Value); break; default: Xil_Out16((u32)Addr, Value); break; } ValueIn = Xil_In16((u32)Addr); if (Kind && Swap) ValueIn = Swap16(ValueIn); if (Value != ValueIn) { return -1; } /* second round */ Xil_Out16((u32)Addr, Value); switch (Kind) { case XIL_TESTIO_LE: ValueIn = Xil_In16LE((u32)Addr); break; case XIL_TESTIO_BE: ValueIn = Xil_In16BE((u32)Addr); break; default: ValueIn = Xil_In16((u32)Addr); break; } if (Kind && Swap) ValueIn = Swap16(ValueIn); if (Value != ValueIn) { return -1; } Addr++; } return 0; }
uint16_t axi_read16(uint32_t addr) { return Xil_In16(offset + addr); }
int main(void) { u8 c; while(1) { c=XUartLite_RecvByte(uartReadReg); switch(c) { //------------------------------------------------- // Reply with the help menu //------------------------------------------------- case '?': xil_printf("--------------------------\r\n"); xil_printf(" count Q = %x\r\n",Xil_In16(countQReg)); xil_printf("--------------------------\r\n"); xil_printf("?: help menu\r\n"); xil_printf("o: k\r\n"); xil_printf("c: COUNTER count up LEDs (by 9)\r\n"); xil_printf("l: COUNTER load counter\r\n"); xil_printf("r: COUNTER reset counter\r\n"); xil_printf("f: flush terminal\r\n"); break; //------------------------------------------------- // Basic I/O loopback //------------------------------------------------- case 'o': xil_printf("k \r\n"); break; //------------------------------------------------- // Tell the counter to count up //------------------------------------------------- case 'c': Xil_Out8(countCtrlReg,count_COUNT); Xil_Out8(countCtrlReg,count_HOLD); break; //------------------------------------------------- // Tell the counter to load a value //------------------------------------------------- case 'l': xil_printf("Enter a 0-9 value to store in the counter: "); c=XUartLite_RecvByte(uartReadReg) - 0x30; Xil_Out8(countQReg,c); // put value into slv_reg1 Xil_Out8(countCtrlReg,count_LOAD); // load command xil_printf("%c\r\n",c+0x30); break; //------------------------------------------------- // Reset the counter //------------------------------------------------- case 'r': Xil_Out8(countCtrlReg,count_RESET); // reset command break; //------------------------------------------------- // Clear the terminal window //------------------------------------------------- case 'f': for (c=0; c<40; c++) xil_printf("\r\n"); break; //------------------------------------------------- // Unknown character was //------------------------------------------------- default: xil_printf("unrecognized character: %c\r\n",c); break; } // end case } // end while 1 return 0; } // end main