63 #define OLED_VBAT 0x20
64 #define OLED_VDD 0x10;
65 #define OLED_RESET_B 0x08
66 #define OLED_DATA_COMMAND_B 0x04
67 #define OLED_SDIN 0x02
68 #define OLED_SCLK 0x01
86 XUartLite_SendByte(unUartAddress, uchByte);
99 u32 unUartStatusRegisterAddress;
100 u32 unStatusRegisterValue;
101 if(unUartAddress==XPAR_PS7_UART_1_BASEADDR)
103 unUartStatusRegisterAddress = unUartAddress + 0x0000002C;
104 unStatusRegisterValue = Xil_In32(unUartStatusRegisterAddress);
107 if((unStatusRegisterValue & 0x00000002)==0x00000002)
114 if(XUartLite_IsReceiveEmpty(unUartAddress)==TRUE)
119 return(uchReturnVal);
136 if(nUartAddress==XPAR_PS7_UART_1_BASEADDR)
137 read(1, (
char*)&uchInput, 1);
139 uchInput = XUartLite_RecvByte(nUartAddress);
153 for(i=0;i<nQuantity;i++)
157 int SpiRW( u32 unPeripheralAddressSPI,
unsigned int unCPHA,
unsigned int unCPOL,
158 u8* auchWriteBuf, u8* auchReadBuf,
int unNumBytes, u8 uchCsActiveHigh, u32 unSpiSS)
183 unsigned int unControlData = 0x00000186;
186 unControlData = unControlData | (unCPHA << 4);
187 unControlData = unControlData | (unCPOL << 3);
190 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);
193 if( uchCsActiveHigh )
194 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, unSpiSS == 0x1? 0xFFFFFFFE : 0xFFFFFFD);
196 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
198 for( i = 0; i < unNumBytes; i++)
200 if( auchWriteBuf != 0 )
203 XSpi_WriteReg(unPeripheralAddressSPI, 0x68, auchWriteBuf[ i ]);
209 XSpi_WriteReg(unPeripheralAddressSPI, 0x68, 0x00);
213 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);
216 if( uchCsActiveHigh )
217 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
219 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, unSpiSS == 0x1? 0xFFFFFFFE : 0xFFFFFFFD);
222 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData & 0xFFFFFEFF);
225 while( !(XSpi_ReadReg( unPeripheralAddressSPI, 0x64 ) & 0x00000004) )
229 XSpi_WriteReg(unPeripheralAddressSPI, 0x60, unControlData);
232 if( (auchReadBuf != 0) )
234 auchReadBuf[ i ] = XSpi_ReadReg(unPeripheralAddressSPI, 0x6C);
238 if( uchCsActiveHigh )
239 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, unSpiSS == 0x1? 0xFFFFFFFE : 0xFFFFFFFD);
241 XSpi_WriteReg(unPeripheralAddressSPI, 0x70, 0xFFFFFFFF);
260 for(i=0;i<nStopValue;i++)
283 for(i=0;i<nNumberOfTimes;i++)
287 uchLedStatus = 1 << j;
288 XGpio_DiscreteWrite(pLED_GPIO, 1, uchLedStatus);
294 uchLedStatus = 8 >> j;
295 XGpio_DiscreteWrite(pLED_GPIO, 1, uchLedStatus);
317 if(nPortNumber>=0 && nPortNumber<=3)
345 u8 uchPmodPortSelectBits=0;
357 uchPmodPortSelectBits = (uchPmodPortD << 6) + (uchPmodPortC << 4) + (uchPmodPortB << 2) + uchPmodPortA;
381 for(i=1;i<nExponent;i++)
383 nValue = nValue * nBase;
401 int nReturnVal = TRUE;
406 while(
checkUartEmpty(unUartAddress) && (j < nTimeoutInTenthsOfSeconds))
439 *uchRxData = uchInput;
445 int GetLine(
char* sInputString,
unsigned int unMaxSize )
458 unsigned int unInputStringIndex = 0;
461 while( (uchInputChar !=
'\r') && (uchInputChar !=
'\n') && (unInputStringIndex < unMaxSize-1) )
463 sInputString[ unInputStringIndex ] = (char)uchInputChar;
464 unInputStringIndex++;
467 sInputString[ unInputStringIndex ] =
'\0';
469 return (unInputStringIndex < unMaxSize) ? unInputStringIndex : -1;
487 if(((uchDataToWrite >> i) & 0x01)==0x01)
646 pauchBuffer[i] = 0x00;
684 for(page=0;page<4;page++)
699 for(column=0;column<128;column++)
726 int nDisplayBufferIndex=0;
730 nDisplayBufferIndex = (x * 8) + (y * 16 * 8);
733 if(chCharacter >=0 && chCharacter<128)
735 nFontIndex = chCharacter * 8;
737 for(i=nDisplayBufferIndex;i<nDisplayBufferIndex+8;i++)
758 int nInitialDisplayLocation;
759 int nRemainingDisplayLength;
763 nStringLength = strlen(chString);
766 nInitialDisplayLocation = y*16 + x;
767 nRemainingDisplayLength = 64 - nInitialDisplayLocation;
768 if(nStringLength > nRemainingDisplayLength)
769 nStringLength = nRemainingDisplayLength;
773 for(i=0;i<nStringLength;i++)
825 uchTempWord1 = pauchSourceBuffer[511-((y*128)+x)];
829 uchTempWord2 = (uchTempWord1 >> (7-i)) & 0x01;
830 uchTempWord2 = uchTempWord2 << i;
831 uchTempWord3 += uchTempWord2;
833 pauchDestinationBuffer[((y*128)+x)] = uchTempWord3;