74 for(i=0;i<nQuantity;i++)
78 int SpiRW( u32 unPeripheralAddressSPI,
unsigned int unCPHA,
unsigned int unCPOL,
79 u8* auchWriteBuf, u8* auchReadBuf,
int unNumBytes, u8 uchCsActiveHigh, u32 unSpiSS)
104 unsigned int unControlData = 0x00000186;
107 unControlData = unControlData | (unCPHA << 4);
108 unControlData = unControlData | (unCPOL << 3);
111 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);
114 if( uchCsActiveHigh )
115 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, unSpiSS == 0x1? 0xFFFFFFFE : 0xFFFFFFD);
117 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
119 for( i = 0; i < unNumBytes; i++)
121 if( auchWriteBuf != 0 )
124 XSpi_WriteReg(unPeripheralAddressSPI, 0x68, auchWriteBuf[ i ]);
130 XSpi_WriteReg(unPeripheralAddressSPI, 0x68, 0x00);
134 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);
137 if( uchCsActiveHigh )
138 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
140 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, unSpiSS == 0x1? 0xFFFFFFFE : 0xFFFFFFFD);
143 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData & 0xFFFFFEFF);
146 while( !(XSpi_ReadReg( unPeripheralAddressSPI, 0x64 ) & 0x00000004) )
150 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);
153 if( (auchReadBuf != 0) )
155 auchReadBuf[ i ] = XSpi_ReadReg(unPeripheralAddressSPI, 0x6C);
159 if( uchCsActiveHigh )
160 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, unSpiSS == 0x1? 0xFFFFFFFE : 0xFFFFFFFD);
162 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
181 for(i=0;i<nStopValue;i++)
204 for(i=0;i<nNumberOfTimes;i++)
208 uchLedStatus = 1 << j;
209 XGpio_DiscreteWrite(pLED_GPIO, 1, uchLedStatus);
215 uchLedStatus = 8 >> j;
216 XGpio_DiscreteWrite(pLED_GPIO, 1, uchLedStatus);
242 XGpio xGpioPmodPortMuxIO;
243 u8 uchPmodPortSelectBits=0;
255 uchPmodPortSelectBits = (uchPmodPortD << 6) + (uchPmodPortC << 4) + (uchPmodPortB << 2) + uchPmodPortA;
257 XGpio_Initialize(&xGpioPmodPortMuxIO, XPAR_AXI_GPIO_2_DEVICE_ID);
258 XGpio_SetDataDirection(&xGpioPmodPortMuxIO, 1, 0x00);
259 XGpio_DiscreteWrite(&xGpioPmodPortMuxIO, 1, uchPmodPortSelectBits);
283 for(i=1;i<nExponent;i++)
285 nValue = nValue * nBase;
303 int nReturnVal = TRUE;
308 while(XUartLite_IsReceiveEmpty(unUartAddress) && (j < nTimeoutInTenthsOfSeconds))
314 if(XUartLite_IsReceiveEmpty(unUartAddress))
318 uchInput = XUartLite_RecvByte(unUartAddress);
322 if(XUartLite_IsReceiveEmpty(unUartAddress))
326 uchInput = XUartLite_RecvByte(unUartAddress);
329 if(XUartLite_IsReceiveEmpty(unUartAddress))
333 uchInput = XUartLite_RecvByte(unUartAddress);
341 *uchRxData = uchInput;
347 int GetLine(
char* sInputString,
unsigned int unMaxSize )
360 unsigned int unInputStringIndex = 0;
363 while( (uchInputChar !=
'\r') && (uchInputChar !=
'\n') && (unInputStringIndex < unMaxSize-1) )
365 sInputString[ unInputStringIndex ] = (char)uchInputChar;
366 unInputStringIndex++;
369 sInputString[ unInputStringIndex ] =
'\0';
371 return (unInputStringIndex < unMaxSize) ? unInputStringIndex : -1;