spips
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
xspips_eeprom_intr_example.c File Reference

Overview

Implements a design example using the SPI driver (XSpiPs) in interrupt mode 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.

MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.00 sdm 02/27/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. 3.14 vlt 12/18/25 Update Doxygen comments to include SDT flow details. 3.15 vn 08/26/26 Fix Doxygen warnings. 3.15 tb 09/30/26 Align Doxygen comments with AMD documentation standards

#include "xparameters.h"
#include "xspips.h"
#include "xscugic.h"
#include "xil_exception.h"
#include "xil_printf.h"
#include "xinterrupt_wrap.h"

Macros

#define WRITE_STATUS_CMD   1
 Write status register command. More...
 
#define WRITE_CMD   2
 Write data command. More...
 
#define READ_CMD   3
 Read data command. More...
 
#define WRITE_DISABLE_CMD   4
 Write disable command. More...
 
#define READ_STATUS_CMD   5
 Read status register command. More...
 
#define WRITE_ENABLE_CMD   6
 Write enable command. More...
 
#define COMMAND_OFFSET   0
 EEPROM instruction. More...
 
#define ADDRESS_MSB_OFFSET   1
 MSB of address to read or write. More...
 
#define ADDRESS_LSB_OFFSET   2
 LSB of address to read or write. More...
 
#define DATA_OFFSET   3
 Start of data in the buffer. More...
 
#define WRITE_DATA_OFFSET   3
 Start of data to write to the EEPROM. More...
 
#define READ_DATA_OFFSET   6
 Start of data read from the EEPROM. More...
 
#define OVERHEAD_SIZE   3
 Command and address bytes. More...
 
#define PAGE_SIZE   16
 EEPROM page size in bytes. More...
 
#define PAGE_COUNT   128
 Number of EEPROM pages. More...
 
#define MAX_DATA   PAGE_COUNT * PAGE_SIZE
 Max data size. More...
 
#define BUFFER_SIZE   MAX_DATA + READ_DATA_OFFSET
 Size of the buffer holding the data and the overhead bytes. More...
 
#define EEPROM_SPI_SELECT   0x01
 EEPROM slave select. More...
 

Typedefs

typedef u8 EepromBuffer [BUFFER_SIZE]
 Holds the data sent to and received from the serial EEPROM device. More...
 

Functions

void SpiHandler (void *CallBackRef, u32 StatusEvent, unsigned int ByteCount)
 Handles the status events of the SPI driver. More...
 
void EepromRead (XSpiPs *SpiPtr, u16 Address, int ByteCount, EepromBuffer Buffer)
 Reads from the serial EEPROM connected to the SPI interface. More...
 
void EepromWrite (XSpiPs *SpiPtr, u16 Address, u8 ByteCount, EepromBuffer Buffer)
 Writes to the serial EEPROM connected to the SPI interface. More...
 
int SpiPsEepromIntrExample (XSpiPs *SpiInstancePtr, UINTPTR BaseAddress)
 Illustrates how to use the XSpiPs device driver in interrupt mode. More...
 
int main (void)
 Calls the SPI EEPROM interrupt example. More...
 

Variables

volatile int TransferInProgress
 Indicates that an SPI transfer is in progress. More...
 
int Error
 Tracks any errors that occur during interrupt processing. More...
 
int Test
 Holds a test value added to the values written to the EEPROM. More...
 
EepromBuffer ReadBuffer
 Data read from the EEPROM. More...
 
EepromBuffer WriteBuffer
 Data to write to the EEPROM. More...