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

Overview

Implements the interface functions of the XSpiPs driver.

See xspips.h for a detailed description of the device and driver.

MODIFICATION HISTORY:
Ver   Who    Date     Changes


1.00 drg/jz 01/25/10 First release 1.01 sg 03/07/12 Updated the code to always clear the relevant bits before writing to config register. Always clear the slave select bits before write and clear the bits to no slave at the end of transfer Modified the Polled transfer transmit/receive logic. Tx should wait on TXOW Interrupt and Rx on RXNEMTY. 1.03 sg 09/21/12 Added memory barrier dmb in polled transfer and interrupt handler to overcome the clock domain crossing issue in the controller. For CR #679252. 1.04a sg 01/30/13 Changed SPI transfer logic for polled and interrupt modes to be based on filled tx fifo count and receive based on it. RXNEMPTY interrupt is not used. SetSlaveSelect API logic is modified to drive the bit position low based on the slave select value requested. GetSlaveSelect API will return the value based on bit position that is low. 1.06a hk 08/22/13 Changed GetSlaveSelect function. CR# 727866. Added masking ConfigReg before writing in SetSlaveSel Added extended slave select support - CR#722569. Added check for MODF in polled transfer function. 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance. 3.02 raw 11/23/15 Updated XSpiPs_Abort() to read all RXFIFO entries. This change is to tackle CR#910231. 3.1 tjs 04/12/18 InputClockHz parameter copied in instance for use in application. CR#998910 3.1 tjs 11/23/18 Added a check for A72 and R5 processor to avoid changes made for the workaround DT#842463. 3.2 aru 01/20/19 Fixes violations according to MISRAC-2012 in safety mode and done changes such as Declared the pointer param as Pointer to const, added goto statements. 3.3 akm 08/06/19 Initialized DeviceID in XSpiPs_CfgInitialize function. 3.8 sg 08/16/22 Updated SPI enable and chip selection sequence for manual mode. 3.9 sb 07/05/23 Added support for system device-tree flow. 3.9 sb 07/27/23 Fix the issue of driver giving junk values when its running at low clock speed in slave mode. 3.12 sb 02/24/25 Use delay in interrupt handler for slave mode only. 3.13 sb 09/09/25 Fix chip selection issues 3.14 sb 04/01/26 Fix TX/RX FIFO byte-order handling. 3.15 vn 08/26/26 Fix Doxygen warnings. 3.15 tb 09/30/26 Align Doxygen comments with AMD documentation standards 3.15 tb 10/12/26 Bound the master mode TX wait in XSpiPs_PolledTransfer() and the RX FIFO drain in XSpiPs_Abort(), and clean up the transfer state on mode fault and timeout.

#include "xspips.h"
#include "sleep.h"

Macros

#define XSPIPS_POLL_TIMEOUT_US   1000000U
 Master mode TX FIFO wait limit in microseconds. More...
 
#define XSpiPs_SendByte(BaseAddress, Data)   XSpiPs_Out32((BaseAddress) + (u32)XSPIPS_TXD_OFFSET, (u32)(Data))
 Sends one byte to the currently selected slave. More...
 
#define XSpiPs_RecvByte(BaseAddress)   XSpiPs_In32((u32)((BaseAddress) + (u32)XSPIPS_RXD_OFFSET))
 Receives one byte from the device's receive FIFO/register. More...
 

Functions

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...
 
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...
 
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...