spips
Vitis Drivers API Documentation
xspips.h File Reference

Data Structures

struct  XSpiPs_Config
 This typedef contains configuration information for the device. More...
 
struct  XSpiPs
 The XSpiPs driver instance data. More...
 

Macros

#define XSpiPs_SetSlaveIdle(InstancePtr, RegisterValue)
 Set the contents of the slave idle count register. More...
 
#define XSpiPs_GetSlaveIdle(InstancePtr)
 Get the contents of the slave idle count register. More...
 
#define XSpiPs_SetTXWatermark(InstancePtr, RegisterValue)
 Set the contents of the transmit FIFO watermark register. More...
 
#define XSpiPs_GetTXWatermark(InstancePtr)   XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + XSPIPS_TXWR_OFFSET)
 Get the contents of the transmit FIFO watermark register. More...
 
#define XSpiPs_SetRXWatermark(InstancePtr, RegisterValue)
 Set the contents of the receive FIFO watermark register. More...
 
#define XSpiPs_GetRXWatermark(InstancePtr)   XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + XSPIPS_RXWR_OFFSET)
 Get the contents of the receive FIFO watermark register. More...
 
#define XSpiPs_Enable(InstancePtr)
 Enable the device and uninhibit master transactions. More...
 
#define XSpiPs_Disable(InstancePtr)   XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + XSPIPS_ER_OFFSET, 0U)
 Disable the device. More...
 
Configuration options

The following options are supported to enable/disable certain features of an SPI device.

Each of the options is a bit mask, so more than one may be specified.

The Master option configures the SPI device as a master. By default, the device is a slave.

The Active Low Clock option configures the device's clock polarity. Setting this option means the clock is active low and the SCK signal idles high. By default, the clock is active high and SCK idles low.

The Clock Phase option configures the SPI device for one of two transfer formats. A clock phase of 0, the default, means data is valid on the first SCK edge (rising or falling) after the slave select (SS) signal has been asserted. A clock phase of 1 means data is valid on the second SCK edge (rising or falling) after SS has been asserted.

The Slave Select Decode Enable option selects how the SPI_SS_outN are controlled by the SPI Slave Select Decode bits. 0: Use this setting for the standard configuration of up to three slave select outputs. Only one of the three slave select outputs will be low. (Default) 1: Use this setting for the optional configuration of an additional decoder to support 8 slave select outputs. SPI_SS_outN reflects the value in the register.

The SPI Force Slave Select option is used to enable manual control of the signals SPI_SS_outN. 0: The SPI_SS_outN signals are controlled by the SPI controller during transfers. (Default) 1: The SPI_SS_outN signal indicated by the Slave Select Control bit is forced active (driven low) regardless of any transfers in progress.

NOTE: The driver will handle setting and clearing the Slave Select when the user sets the "FORCE_SSELECT_OPTION". Using this option will allow the SPI clock to be set to a faster speed. If the SPI clock is too fast, the processor cannot empty and refill the FIFOs before the TX FIFO is empty When the SPI hardware is controlling the Slave Select signals, this will cause slave to be de-selected and terminate the transfer.

The Manual Start option is used to enable manual control of the Start command to perform data transfer. 0: The Start command is controlled by the SPI controller during transfers(Default). Data transmission starts as soon as there is data in the TXFIFO and stalls when the TXFIFO is empty 1: The Start command must be issued by software to perform data transfer. Bit 15 of Configuration register is used to issue Start command. This bit must be set whenever TXFIFO is filled with new data.

NOTE: The driver will set the Manual Start Enable bit in Configuration Register, if Manual Start option is selected. Software will issue Manual Start command whenever TXFIFO is filled with data. When there is no further data, driver will clear the Manual Start Enable bit.

#define XSPIPS_MASTER_OPTION   0x00000001U
 Master mode option. More...
 
#define XSPIPS_CLK_ACTIVE_LOW_OPTION   0x00000002U
 Active Low Clock option. More...
 
#define XSPIPS_CLK_PHASE_1_OPTION   0x00000004U
 Clock Phase one option. More...
 
#define XSPIPS_DECODE_SSELECT_OPTION   0x00000008U
 Select 16 slaves Option. More...
 
#define XSPIPS_FORCE_SSELECT_OPTION   0x00000010U
 Force Slave Select. More...
 
#define XSPIPS_MANUAL_START_OPTION   0x00000020U
 Manual Start mode option. More...
 
SPI Clock Prescaler options

The SPI Clock Prescaler Configuration bits are used to program master mode bit rate.

The bit rate can be programmed in divide-by-two decrements from pclk/4 to pclk/256.

#define XSPIPS_CLK_PRESCALE_4   0x01U
 PCLK/4 Prescaler. More...
 
#define XSPIPS_CLK_PRESCALE_8   0x02U
 PCLK/8 Prescaler. More...
 
#define XSPIPS_CLK_PRESCALE_16   0x03U
 PCLK/16 Prescaler. More...
 
#define XSPIPS_CLK_PRESCALE_32   0x04U
 PCLK/32 Prescaler. More...
 
#define XSPIPS_CLK_PRESCALE_64   0x05U
 PCLK/64 Prescaler. More...
 
#define XSPIPS_CLK_PRESCALE_128   0x06U
 PCLK/128 Prescaler. More...
 
#define XSPIPS_CLK_PRESCALE_256   0x07U
 PCLK/256 Prescaler. More...
 
Callback events

These constants specify the handler events that are passed to a handler from the driver.

These constants are not bit masks such that only one will be passed at a time to the handler.

#define XSPIPS_EVENT_MODE_FAULT   1U
 Mode fault error. More...
 
#define XSPIPS_EVENT_TRANSFER_DONE   2U
 Transfer done. More...
 
#define XSPIPS_EVENT_TRANSMIT_UNDERRUN   3U
 TX FIFO empty. More...
 
#define XSPIPS_EVENT_RECEIVE_OVERRUN   4U
 Receive data loss because RX FIFO full. More...
 

Typedefs

typedef void(* XSpiPs_StatusHandler )(const void *CallBackRef, u32 StatusEvent, u32 ByteCount)
 The handler data type allows the user to define a callback function to handle the asynchronous processing for the SPI device. More...
 

Functions

XSpiPs_ConfigXSpiPs_LookupConfig (u16 DeviceId)
 Looks up the device configuration based on the unique device ID. More...
 
s32 XSpiPs_CfgInitialize (XSpiPs *InstancePtr, const XSpiPs_Config *ConfigPtr, u32 EffectiveAddr)
 Initializes a specific XSpiPs instance such that the driver is ready to use. More...
 
void XSpiPs_Reset (XSpiPs *InstancePtr)
 Resets the SPI device. More...
 
s32 XSpiPs_Transfer (XSpiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, u32 ByteCount)
 Transfers specified data on the SPI bus. More...
 
s32 XSpiPs_PolledTransfer (XSpiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, u32 ByteCount)
 Transfers specified data on the SPI bus in polled mode. More...
 
void XSpiPs_SetStatusHandler (XSpiPs *InstancePtr, void *CallBackRef, XSpiPs_StatusHandler FunctionPtr)
 Sets the status callback function, the status handler, which the driver calls when it encounters conditions that should be reported to upper layer software. More...
 
void XSpiPs_InterruptHandler (XSpiPs *InstancePtr)
 The interrupt handler for SPI interrupts. More...
 
void XSpiPs_Abort (XSpiPs *InstancePtr)
 Aborts a transfer in progress by disabling the device and resetting the FIFOs if present. More...
 
s32 XSpiPs_SetSlaveSelect (XSpiPs *InstancePtr, u8 SlaveSel)
 Selects or deselect the slave with which the master communicates. More...
 
u8 XSpiPs_GetSlaveSelect (const XSpiPs *InstancePtr)
 Gets the current slave select setting for the SPI device. More...
 
s32 XSpiPs_SelfTest (XSpiPs *InstancePtr)
 Runs a self-test on the driver/device. More...
 
s32 XSpiPs_SetOptions (const XSpiPs *InstancePtr, u32 Options)
 This function sets the options for the SPI device driver. More...
 
u32 XSpiPs_GetOptions (const XSpiPs *InstancePtr)
 This function gets the options for the SPI device. More...
 
s32 XSpiPs_SetClkPrescaler (const XSpiPs *InstancePtr, u8 Prescaler)
 This function sets the clock prescaler for an SPI device. More...
 
u8 XSpiPs_GetClkPrescaler (const XSpiPs *InstancePtr)
 This function gets the clock prescaler of an SPI device. More...
 
s32 XSpiPs_SetDelays (const XSpiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, u8 DelayAfter, u8 DelayInit)
 This function sets the delay register for the SPI device driver. More...
 
void XSpiPs_GetDelays (const XSpiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, u8 *DelayAfter, u8 *DelayInit)
 This function gets the delay settings for an SPI device. More...