spips
Vitis Drivers API Documentation
xspips_eeprom_polled_example.c File Reference

Overview

This file contains a design example using the SPI driver (XSpiPs) in polled mode and hardware device with a serial EEPROM device.

The hardware which this example runs on must have a serial EEPROM (Microchip 25XX320 or 25XX160) for it to run. This example has been tested with the SPI EEPROM on the EP4.5 ARM processor.

Note

None.

 MODIFICATION HISTORY:
 Ver   Who  Date     Changes


1.00 sdm 03/09/10 First release 1.00 sdm 10/25/11 Updated the chip select to be used to second chip select ms 04/05/17 Modified Comment lines in functions to recognize it as documentation block for doxygen generation and also modified filename tag to include the file in doxygen examples. 3.9 sb 07/05/23 Added support for system device-tree flow.

Functions

void EepromRead (XSpiPs *SpiPtr, u16 Address, int ByteCount, EepromBuffer Buffer)
 This function reads from the serial EEPROM connected to the SPI interface. More...
 
void EepromWrite (XSpiPs *SpiPtr, u16 Address, u8 ByteCount, EepromBuffer Buffer)
 This function writes to the serial EEPROM connected to the SPI interface. More...
 
int SpiPsEepromPolledExample (XSpiPs *SpiInstancePtr, u16 SpiDeviceId)
 The purpose of this function is to illustrate how to use the XSpiPs device driver in polled mode. More...
 
int main (void)
 Main function to call the Spi Eeprom example. More...
 

Function Documentation

void EepromRead ( XSpiPs SpiPtr,
u16  Address,
int  ByteCount,
EepromBuffer  Buffer 
)

This function reads from the serial EEPROM connected to the SPI interface.

Parameters
SpiPtris a pointer to the SPI driver component to use.
Addresscontains the address to read data from in the EEPROM.
ByteCountcontains the number of bytes to read.
Bufferis a buffer to read the data into.
Returns
None.
Note
None.
void EepromWrite ( XSpiPs SpiPtr,
u16  Address,
u8  ByteCount,
EepromBuffer  Buffer 
)

This function writes to the serial EEPROM connected to the SPI interface.

This function is not designed to be a driver to handle all the conditions of the EEPROM device. The EEPROM contains a 32 byte write buffer which can be filled and then a write is automatically performed by the device. All the data put into the buffer must be in the same page of the device with page boundaries being on 32 byte boundaries.

Parameters
SpiPtris a pointer to the SPI driver instance to use.
Addresscontains the address to write data to in the EEPROM.
ByteCountcontains the number of bytes to write.
Bufferis a buffer of data to write from.
Returns
None.
Note
None.
int main ( void  )

Main function to call the Spi Eeprom example.

Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
Note
None

References SpiPsEepromPolledExample().

int SpiPsEepromPolledExample ( XSpiPs SpiInstancePtr,
u16  SpiDeviceId 
)

The purpose of this function is to illustrate how to use the XSpiPs device driver in polled mode.

This test writes and reads data from a serial EEPROM. The serial EEPROM part must be present in the hardware to use this example.

Parameters
SpiInstancePtris a pointer to the Spi Instance.
SpiDeviceIdis the Device Id of Spi.
Returns
XST_SUCCESS if successful else XST_FAILURE.
Note

This function calls functions which contain loops that may be infinite if interrupts are not working such that it may not return. If the device slave select is not correct and the device is not responding on bus it will read a status of 0xFF for the status register as the bus is pulled up.

References XSpiPs_Config::BaseAddress, EepromRead(), EepromWrite(), XSpiPs_CfgInitialize(), XSPIPS_CLK_PRESCALE_64, XSPIPS_FORCE_SSELECT_OPTION, XSpiPs_LookupConfig(), XSPIPS_MASTER_OPTION, XSpiPs_SelfTest(), XSpiPs_SetClkPrescaler(), XSpiPs_SetOptions(), and XSpiPs_SetSlaveSelect().

Referenced by main().