spips
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
xspips.h File Reference
#include "xstatus.h"
#include "xil_mem.h"
#include "xspips_hw.h"

Data Structures

struct  XSpiPs_Config
 Holds the configuration information for the device. More...
 
struct  XSpiPs
 Holds the XSpiPs driver instance data. More...
 

Macros

#define XSpiPs_IsManualStart(InstancePtr)
 Checks whether the Manual Start option is enabled. More...
 
#define XSpiPs_IsManualChipSelect(InstancePtr)
 Checks whether the Manual Chip Select option is enabled. More...
 
#define XSpiPs_IsDecodeSSelect(InstancePtr)
 Checks whether the Decode Slave Select option is enabled. More...
 
#define XSpiPs_IsMaster(InstancePtr)
 Checks whether the Master option is enabled. More...
 
#define XSpiPs_SetSlaveIdle(InstancePtr, RegisterValue)
 Sets the contents of the slave idle count register. More...
 
#define XSpiPs_GetSlaveIdle(InstancePtr)
 Gets the contents of the slave idle count register. More...
 
#define XSpiPs_SetTXWatermark(InstancePtr, RegisterValue)
 Sets the contents of the transmit FIFO watermark register. More...
 
#define XSpiPs_GetTXWatermark(InstancePtr)   XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + XSPIPS_TXWR_OFFSET)
 Gets the contents of the transmit FIFO watermark register. More...
 
#define XSpiPs_SetRXWatermark(InstancePtr, RegisterValue)
 Sets the contents of the receive FIFO watermark register. More...
 
#define XSpiPs_GetRXWatermark(InstancePtr)   XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + XSPIPS_RXWR_OFFSET)
 Gets the contents of the receive FIFO watermark register. More...
 
#define XSpiPs_Enable(InstancePtr)
 Enables the device and uninhibits master transactions. More...
 
#define XSpiPs_Disable(InstancePtr)   XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + XSPIPS_ER_OFFSET, 0U)
 Disables 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 is 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 enables 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 handles setting and clearing the Slave Select when the user sets the "FORCE_SSELECT_OPTION". Using this option allows 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 causes the slave to be de-selected and terminates the transfer.

The Manual Start option enables 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 issues the Start command. This bit must be set whenever TXFIFO is filled with new data.

NOTE: The driver sets the Manual Start Enable bit in Configuration Register, if Manual Start option is selected. Software issues Manual Start command whenever TXFIFO is filled with data. When there is no further data, driver clears 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 is 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)
 Describes the status callback function type of the SPIPS driver. More...
 

Functions

XSpiPs_Config * XSpiPs_LookupConfig (UINTPTR BaseAddress)
 Looks up the device configuration based on the unique device ID/BaseAddress. 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 for the driver. More...
 
void XSpiPs_InterruptHandler (XSpiPs *InstancePtr)
 Handles the 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 deselects 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)
 Sets the options for the SPI device driver. More...
 
u32 XSpiPs_GetOptions (const XSpiPs *InstancePtr)
 Gets the options for the SPI device. More...
 
s32 XSpiPs_SetClkPrescaler (const XSpiPs *InstancePtr, u8 Prescaler)
 Sets the clock prescaler for an SPI device. More...
 
u8 XSpiPs_GetClkPrescaler (const XSpiPs *InstancePtr)
 Gets the clock prescaler of an SPI device. More...
 
s32 XSpiPs_SetDelays (const XSpiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, u8 DelayAfter, u8 DelayInit)
 Sets the delay register for the SPI device driver. More...
 
void XSpiPs_GetDelays (const XSpiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, u8 *DelayAfter, u8 *DelayInit)
 Gets the delay settings for an SPI device. More...