1 /******************************************************************************
3 * Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /*****************************************************************************/
37 * This file contains the implementation of the XSpiPs driver. It works for
38 * both the master and slave mode. User documentation for the driver functions
39 * is contained in this file in the form of comment blocks at the front of each
42 * An SPI device connects to an SPI bus through a 4-wire serial interface.
43 * The SPI bus is a full-duplex, synchronous bus that facilitates communication
44 * between one master and one slave. The device is always full-duplex,
45 * which means that for every byte sent, one is received, and vice-versa.
46 * The master controls the clock, so it can regulate when it wants to
47 * send or receive data. The slave is under control of the master, it must
48 * respond quickly since it has no control of the clock and must send/receive
49 * data as fast or as slow as the master does.
51 * <b>Initialization & Configuration</b>
53 * The XSpiPs_Config structure is used by the driver to configure itself. This
54 * configuration structure is typically created by the tool-chain based on HW
57 * To support multiple runtime loading and initialization strategies employed by
58 * various operating systems, the driver instance can be initialized in the
60 * - XSpiPs_LookupConfig(DeviceId) - Use the devide identifier to find the
61 * static configuration structure defined in xspips_g.c. This is setup by
62 * the tools. For some operating systems the config structure will be
63 * initialized by the software and this call is not needed.
64 * - XSpiPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddr) - Uses a
65 * configuration structure provided by the caller. If running in a system
66 * with address translation, the provided virtual memory base address
67 * replaces the physical address present in the configuration structure.
69 * <b>Multiple Masters</b>
71 * More than one master can exist, but arbitration is the responsibility of
72 * the higher layer software. The device driver does not perform any type of
75 * <b>Multiple Slaves</b>
77 * Contention between multiple masters is detected by the hardware, in which
78 * case a mode fault occurs on the device. The device is disabled immediately
79 * by hardware, and the current word transfer is stopped. The Aborted word
80 * transfer due to the mode fault is resumed once the devie is enabled again.
82 * <b>Modes of Operation</b>
84 * There are four modes to perform a data transfer and the selection of a mode
85 * is based on Chip Select(CS) and Start. These two options individually, can
86 * be controlled either by software(Manual) or hardware(Auto).
87 * - Auto CS: Chip select is automatically asserted as soon as the first word
88 * is written into the TXFIFO and deasserted when the TXFIFO becomes
90 * - Manual CS: Software must assert and deassert CS.
91 * - Auto Start: Data transmission starts as soon as there is data in the
92 * TXFIFO and stalls when the TXFIFO is empty
93 * - Manual Start: Software must start data transmission at the beginning of
94 * the transaction or whenever the TXFIFO has become empty
96 * The preferred combination is Manual CS and Auto Start.
97 * In this combination, the software asserts CS before loading any data into
98 * TXFIFO. In Auto Start mode, whenever data is in TXFIFO, controller sends it
99 * out until TXFIFO becomes empty. The software reads the RXFIFO whenever the
100 * data is available. If no further data, software disables CS.
102 * Risks/challenges of other combinations:
103 * - Manual CS and Manual Start: Manual Start bit should be set after each
104 * TXFIFO write otherwise there could be a race condition where the TXFIFO
105 * becomes empty before the new word is written. In that case the
106 * transmission stops.
107 * - Auto CS with Manual or Auto Start: It is very difficult for software to
108 * keep the TXFIFO filled. Whenever the TXFIFO runs empty, CS is deasserted.
109 * This results in a single transaction to be split into multiple pieces each
110 * with its own chip select. This will result in garbage data to be sent.
114 * The user must connect the interrupt handler of the driver,
115 * XSpiPs_InterruptHandler, to an interrupt system such that it will be
116 * called when an interrupt occurs. This function does not save and restore
117 * the processor context such that the user must provide this processing.
119 * The driver handles the following interrupts:
120 * - Data Transmit Register/FIFO Underflow
121 * - Data Receive Register/FIFO Full
122 * - Data Receive Register/FIFO Not Empty
123 * - Data Transmit Register/FIFO Full
124 * - Data Transmit Register/FIFO Overwater
126 * - Data Receive Register/FIFO Overrun
128 * The Data Transmit Register/FIFO Overwater interrupt -- indicates that the
129 * SPI device has transmitted the data available to transmit, and now its data
130 * register and FIFO is ready to accept more data. The driver uses this
131 * interrupt to indicate progress while sending data. The driver may have
132 * more data to send, in which case the data transmit register and FIFO is
133 * filled for subsequent transmission. When this interrupt arrives and all
134 * the data has been sent, the driver invokes the status callback with a
135 * value of XST_SPI_TRANSFER_DONE to inform the upper layer software that
136 * all data has been sent.
138 * The Data Transmit Register/FIFO Underflow interrupt -- indicates that,
139 * as slave, the SPI device was required to transmit but there was no data
140 * available to transmit in the transmit register (or FIFO). This may not
141 * be an error if the master is not expecting data. But in the case where
142 * the master is expecting data, this serves as a notification of such a
143 * condition. The driver reports this condition to the upper layer
144 * software through the status handler.
146 * The Data Receive Register/FIFO Overrun interrupt -- indicates that the SPI
147 * device received data and subsequently dropped the data because the data
148 * receive register and FIFO was full. The interrupt applies to both master
149 * and slave operation. The driver reports this condition to the upper layer
150 * software through the status handler. This likely indicates a problem with
151 * the higher layer protocol, or a problem with the slave performance.
153 * The Mode Fault Error interrupt -- indicates that while configured as a
154 * master, the device was selected as a slave by another master. This can be
155 * used by the application for arbitration in a multimaster environment or to
156 * indicate a problem with arbitration. When this interrupt occurs, the
157 * driver invokes the status callback with a status value of
158 * XST_SPI_MODE_FAULT. It is up to the application to resolve the conflict.
159 * When configured as a slave, Mode Fault Error interrupt indicates that a slave
160 * device was selected as a slave by a master, but the slave device was
161 * disabled. When configured as a master, Mode Fault Error interrupt indicates
162 * that another SPI device is acting as a master on the bus.
165 * <b>Polled Operation</b>
167 * Transfer in polled mode is supported through a separate interface function
168 * XSpiPs_PolledTransfer(). Unlike the transfer function in the interrupt mode,
169 * this function blocks until all data has been sent/received.
173 * Some operations are disallowed when the device is busy. The driver tracks
174 * whether a device is busy. The device is considered busy when a data transfer
175 * request is outstanding, and is considered not busy only when that transfer
176 * completes (or is aborted with a mode fault error). This applies to both
177 * master and slave devices.
179 * <b>Device Configuration</b>
181 * The device can be configured in various ways during the FPGA implementation
182 * process. Configuration parameters are stored in the xspips_g.c file or
183 * passed in via XSpiPs_CfgInitialize(). A table is defined where each entry
184 * contains configuration information for an SPI device, including the base
185 * address for the device.
187 * <b>RTOS Independence</b>
189 * This driver is intended to be RTOS and processor independent. It works with
190 * physical addresses only. Any needs for dynamic memory management, threads or
191 * thread mutual exclusion, virtual memory, or cache control must be satisfied
192 * by the layer above this driver.
195 * MODIFICATION HISTORY:
197 * Ver Who Date Changes
198 * ----- ------ -------- -----------------------------------------------
199 * 1.00 drg/jz 01/25/10 First release
200 * 1.00 sdm 10/25/11 Removed the Divide by 2 in the SPI Clock Prescaler
201 * options as this is not supported in the device.
202 * 1.01 sg 03/07/12 Updated the code to always clear the relevant bits
203 * before writing to config register.
204 * Always clear the slave select bits before write and
205 * clear the bits to no slave at the end of transfer
206 * Modified the Polled transfer transmit/receive logic.
207 * Tx should wait on TXOW Interrupt and Rx on RXNEMTY.
208 * 1.02 sg 05/31/12 Updated XSPIPS_FIFO_DEPTH to 128 from 32 to match HW
210 * 1.03 sg 09/21/12 Added memory barrier dmb in polled transfer and
211 * interrupt handler to overcome the clock domain
212 * crossing issue in the controller. For CR #679252.
213 * 1.04a sg 01/30/13 Created XSPIPS_MANUAL_START_OPTION. Created macros
214 * XSpiPs_IsMaster, XSpiPs_IsManualStart and
215 * XSpiPs_IsManualChipSelect. Changed SPI
216 * Enable/Disable macro argument from BaseAddress to
217 * Instance Pointer. Added DelayNss argument to SetDelays
218 * and GetDelays API's. Added macros to set/get the
219 * RX Watermark value.Created macros XSpiPs_IsMaster,
220 * XSpiPs_IsManualStart and XSpiPs_IsManualChipSelect.
221 * Changed SPI transfer logic for polled and interrupt
222 * modes to be based on filled tx fifo count and receive
223 * based on it. RXNEMPTY interrupt is not used.
224 * SetSlaveSelect API logic is modified to drive the bit
225 * position low based on the slave select value
226 * requested. GetSlaveSelect API will return the value
227 * based on bit position that is low.
228 * Created XSPIPS_CR_MODF_GEN_EN_MASK macro and added it
229 * to XSPIPS_CR_RESET_STATE. Created
230 * XSPIPS_IXR_WR_TO_CLR_MASK for interrupts which need
231 * write-to-clear. Added shift and mask macros for d_nss
232 * parameter. Added Rx Watermark mask.
233 * 1.05a hk 26/04/13 Added disable and enable in XSpiPs_SetOptions when
234 * CPOL/CPHA bits are set/reset. Fix for CR#707669.
235 * 1.06a hk 08/22/13 Changed GetSlaveSelect function. CR# 727866.
236 * Added masking ConfigReg before writing in SetSlaveSel
237 * Added extended slave select support - CR#722569.
238 * Added prototypes of reset API and related constant
240 * Added check for MODF in polled transfer function.
241 * 3.0 vm 12/09/14 Modified driver source code for MISRA-C:2012 compliance.
242 * Support for Zynq Ultrascale Mp added.
246 ******************************************************************************/
247 #ifndef XSPIPS_H /* prevent circular inclusions */
248 #define XSPIPS_H /* by using protection macros */
254 /***************************** Include Files *********************************/
257 #include "xspips_hw.h"
259 /************************** Constant Definitions *****************************/
261 /** @name Configuration options
263 * The following options are supported to enable/disable certain features of
264 * an SPI device. Each of the options is a bit mask, so more than one may be
267 * <b>The Master option</b> configures the SPI device as a master.
268 * By default, the device is a slave.
270 * The <b>Active Low Clock option</b> configures the device's clock polarity.
271 * Setting this option means the clock is active low and the SCK signal idles
272 * high. By default, the clock is active high and SCK idles low.
274 * The <b>Clock Phase option</b> configures the SPI device for one of two
275 * transfer formats. A clock phase of 0, the default, means data is valid on
276 * the first SCK edge (rising or falling) after the slave select (SS) signal
277 * has been asserted. A clock phase of 1 means data is valid on the second SCK
278 * edge (rising or falling) after SS has been asserted.
280 * The <b>Slave Select Decode Enable option</b> selects how the SPI_SS_outN are
281 * controlled by the SPI Slave Select Decode bits.
282 * 0: Use this setting for the standard configuration of up to three slave
283 * select outputs. Only one of the three slave select outputs will be low.
285 * 1: Use this setting for the optional configuration of an additional decoder
286 * to support 8 slave select outputs. SPI_SS_outN reflects the value in the
289 * The <b>SPI Force Slave Select option</b> is used to enable manual control of
290 * the signals SPI_SS_outN.
291 * 0: The SPI_SS_outN signals are controlled by the SPI controller during
292 * transfers. (Default)
293 * 1: The SPI_SS_outN signal indicated by the Slave Select Control bit is
294 * forced active (driven low) regardless of any transfers in progress.
296 * NOTE: The driver will handle setting and clearing the Slave Select when
297 * the user sets the "FORCE_SSELECT_OPTION". Using this option will allow the
298 * SPI clock to be set to a faster speed. If the SPI clock is too fast, the
299 * processor cannot empty and refill the FIFOs before the TX FIFO is empty
300 * When the SPI hardware is controlling the Slave Select signals, this
301 * will cause slave to be de-selected and terminate the transfer.
303 * The <b>Manual Start option</b> is used to enable manual control of
304 * the Start command to perform data transfer.
305 * 0: The Start command is controlled by the SPI controller during
306 * transfers(Default). Data transmission starts as soon as there is data in
307 * the TXFIFO and stalls when the TXFIFO is empty
308 * 1: The Start command must be issued by software to perform data transfer.
309 * Bit 15 of Configuration register is used to issue Start command. This bit
310 * must be set whenever TXFIFO is filled with new data.
312 * NOTE: The driver will set the Manual Start Enable bit in Configuration
313 * Register, if Manual Start option is selected. Software will issue
314 * Manual Start command whenever TXFIFO is filled with data. When there is
315 * no further data, driver will clear the Manual Start Enable bit.
319 #define XSPIPS_MASTER_OPTION 0x00000001U /**< Master mode option */
320 #define XSPIPS_CLK_ACTIVE_LOW_OPTION 0x00000002U /**< Active Low Clock option */
321 #define XSPIPS_CLK_PHASE_1_OPTION 0x00000004U /**< Clock Phase one option */
322 #define XSPIPS_DECODE_SSELECT_OPTION 0x00000008U /**< Select 16 slaves Option */
323 #define XSPIPS_FORCE_SSELECT_OPTION 0x00000010U /**< Force Slave Select */
324 #define XSPIPS_MANUAL_START_OPTION 0x00000020U /**< Manual Start mode option */
328 /** @name SPI Clock Prescaler options
329 * The SPI Clock Prescaler Configuration bits are used to program master mode
330 * bit rate. The bit rate can be programmed in divide-by-two decrements from
331 * pclk/4 to pclk/256.
336 #define XSPIPS_CLK_PRESCALE_4 0x01U /**< PCLK/4 Prescaler */
337 #define XSPIPS_CLK_PRESCALE_8 0x02U /**< PCLK/8 Prescaler */
338 #define XSPIPS_CLK_PRESCALE_16 0x03U /**< PCLK/16 Prescaler */
339 #define XSPIPS_CLK_PRESCALE_32 0x04U /**< PCLK/32 Prescaler */
340 #define XSPIPS_CLK_PRESCALE_64 0x05U /**< PCLK/64 Prescaler */
341 #define XSPIPS_CLK_PRESCALE_128 0x06U /**< PCLK/128 Prescaler */
342 #define XSPIPS_CLK_PRESCALE_256 0x07U /**< PCLK/256 Prescaler */
346 /** @name Callback events
348 * These constants specify the handler events that are passed to
349 * a handler from the driver. These constants are not bit masks such that
350 * only one will be passed at a time to the handler.
354 #define XSPIPS_EVENT_MODE_FAULT 1U /**< Mode fault error */
355 #define XSPIPS_EVENT_TRANSFER_DONE 2U /**< Transfer done */
356 #define XSPIPS_EVENT_TRANSMIT_UNDERRUN 3U /**< TX FIFO empty */
357 #define XSPIPS_EVENT_RECEIVE_OVERRUN 4U /**< Receive data loss because
362 /**************************** Type Definitions *******************************/
364 * The handler data type allows the user to define a callback function to
365 * handle the asynchronous processing for the SPI device. The application
366 * using this driver is expected to define a handler of this type to support
367 * interrupt driven mode. The handler executes in an interrupt context, so
368 * only minimal processing should be performed.
370 * @param CallBackRef is the callback reference passed in by the upper
371 * layer when setting the callback functions, and passed back to
372 * the upper layer when the callback is invoked. Its type is
373 * not important to the driver, so it is a void pointer.
374 * @param StatusEvent holds one or more status events that have occurred.
375 * See the XSpiPs_SetStatusHandler() for details on the status
376 * events that can be passed in the callback.
377 * @param ByteCount indicates how many bytes of data were successfully
378 * transferred. This may be less than the number of bytes
379 * requested if the status event indicates an error.
381 typedef void (*XSpiPs_StatusHandler) (void *CallBackRef, u32 StatusEvent,
385 * This typedef contains configuration information for the device.
388 u16 DeviceId; /**< Unique ID of device */
389 u32 BaseAddress; /**< Base address of the device */
390 u32 InputClockHz; /**< Input clock frequency */
394 * The XSpiPs driver instance data. The user is required to allocate a
395 * variable of this type for every SPI device in the system. A pointer
396 * to a variable of this type is then passed to the driver API functions.
399 XSpiPs_Config Config; /**< Configuration structure */
400 u32 IsReady; /**< Device is initialized and ready */
402 u8 *SendBufferPtr; /**< Buffer to send (state) */
403 u8 *RecvBufferPtr; /**< Buffer to receive (state) */
404 u32 RequestedBytes; /**< Number of bytes to transfer (state) */
405 u32 RemainingBytes; /**< Number of bytes left to transfer(state) */
406 u32 IsBusy; /**< A transfer is in progress (state) */
407 u32 SlaveSelect; /**< The slave select value when
408 XSPIPS_FORCE_SSELECT_OPTION is set */
410 XSpiPs_StatusHandler StatusHandler;
411 void *StatusRef; /**< Callback reference for status handler */
415 /***************** Macros (Inline Functions) Definitions *********************/
416 /****************************************************************************/
419 * Check in OptionsTable if Manual Start Option is enabled or disabled.
421 * @param InstancePtr is a pointer to the XSpiPs instance.
424 * - TRUE if option is set
425 * - FALSE if option is not set
427 * @note C-Style signature:
428 * u8 XSpiPs_IsManualStart(XSpiPs *InstancePtr);
430 *****************************************************************************/
431 #define XSpiPs_IsManualStart(InstancePtr) \
432 (((XSpiPs_GetOptions(InstancePtr) & \
433 XSPIPS_MANUAL_START_OPTION) != (u32)0U) ? TRUE : FALSE)
435 /****************************************************************************/
438 * Check in OptionsTable if Manual Chip Select Option is enabled or disabled.
440 * @param InstancePtr is a pointer to the XSpiPs instance.
443 * - TRUE if option is set
444 * - FALSE if option is not set
446 * @note C-Style signature:
447 * u8 XSpiPs_IsManualChipSelect(XSpiPs *InstancePtr);
449 *****************************************************************************/
450 #define XSpiPs_IsManualChipSelect(InstancePtr) \
451 (((XSpiPs_GetOptions(InstancePtr) & \
452 XSPIPS_FORCE_SSELECT_OPTION) != (u32)0U) ? TRUE : FALSE)
454 /****************************************************************************/
457 * Check in OptionsTable if Decode Slave Select option is enabled or disabled.
459 * @param InstancePtr is a pointer to the XSpiPs instance.
462 * - TRUE if option is set
463 * - FALSE if option is not set
465 * @note C-Style signature:
466 * u8 XSpiPs_IsDecodeSSelect(XSpiPs *InstancePtr);
468 *****************************************************************************/
469 #define XSpiPs_IsDecodeSSelect(InstancePtr) \
470 (((XSpiPs_GetOptions(InstancePtr) & \
471 XSPIPS_DECODE_SSELECT_OPTION) != (u32)0U) ? TRUE : FALSE)
473 /****************************************************************************/
476 * Check in OptionsTable if Master Option is enabled or disabled.
478 * @param InstancePtr is a pointer to the XSpiPs instance.
481 * - TRUE if option is set
482 * - FALSE if option is not set
484 * @note C-Style signature:
485 * u8 XSpiPs_IsMaster(XSpiPs *InstancePtr);
487 *****************************************************************************/
488 #define XSpiPs_IsMaster(InstancePtr) \
489 (((XSpiPs_GetOptions(InstancePtr) & \
490 XSPIPS_MASTER_OPTION) != (u32)0U) ? TRUE : FALSE)
492 /****************************************************************************/
495 * Set the contents of the slave idle count register.
497 * @param InstancePtr is a pointer to the XSpiPs instance.
498 * @param RegisterValue is the value to be writen, valid values are
505 * void XSpiPs_SetSlaveIdle(XSpiPs *InstancePtr, u32 RegisterValue)
507 *****************************************************************************/
508 #define XSpiPs_SetSlaveIdle(InstancePtr, RegisterValue) \
509 XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
510 XSPIPS_SICR_OFFSET, (RegisterValue))
512 /****************************************************************************/
515 * Get the contents of the slave idle count register. Use the XSPIPS_SICR_*
516 * constants defined in xspips_hw.h to interpret the bit-mask returned.
518 * @param InstancePtr is a pointer to the XSpiPs instance.
520 * @return 8-bit value representing the contents of the SIC register.
522 * @note C-Style signature:
523 * u32 XSpiPs_GetSlaveIdle(XSpiPs *InstancePtr)
525 *****************************************************************************/
526 #define XSpiPs_GetSlaveIdle(InstancePtr) \
527 XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + \
530 /****************************************************************************/
533 * Set the contents of the transmit FIFO watermark register.
535 * @param InstancePtr is a pointer to the XSpiPs instance.
536 * @param RegisterValue is the value to be written, valid values
543 * void XSpiPs_SetTXWatermark(XSpiPs *InstancePtr, u32 RegisterValue)
545 *****************************************************************************/
546 #define XSpiPs_SetTXWatermark(InstancePtr, RegisterValue) \
547 XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
548 XSPIPS_TXWR_OFFSET, (RegisterValue))
550 /****************************************************************************/
553 * Get the contents of the transmit FIFO watermark register.
554 * Use the XSPIPS_TXWR_* constants defined xspips_hw.h to interpret
555 * the bit-mask returned.
557 * @param InstancePtr is a pointer to the XSpiPs instance.
559 * @return 8-bit value representing the contents of the TXWR register.
561 * @note C-Style signature:
562 * u32 XSpiPs_GetTXWatermark(u32 *InstancePtr)
564 *****************************************************************************/
565 #define XSpiPs_GetTXWatermark(InstancePtr) \
566 XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + XSPIPS_TXWR_OFFSET)
568 /****************************************************************************/
571 * Set the contents of the receive FIFO watermark register.
573 * @param InstancePtr is a pointer to the XSpiPs instance.
574 * @param RegisterValue is the value to be written, valid values
581 * void XSpiPs_SetRXWatermark(XSpiPs *InstancePtr, u32 RegisterValue)
583 *****************************************************************************/
584 #define XSpiPs_SetRXWatermark(InstancePtr, RegisterValue) \
585 XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + \
586 XSPIPS_RXWR_OFFSET, (RegisterValue))
588 /****************************************************************************/
591 * Get the contents of the receive FIFO watermark register.
592 * Use the XSPIPS_RXWR_* constants defined xspips_hw.h to interpret
593 * the bit-mask returned.
595 * @param InstancePtr is a pointer to the XSpiPs instance.
597 * @return A 8-bit value representing the contents of the RXWR register.
599 * @note C-Style signature:
600 * u32 XSpiPs_GetRXWatermark(u32 *InstancePtr)
602 *****************************************************************************/
603 #define XSpiPs_GetRXWatermark(InstancePtr) \
604 XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + XSPIPS_RXWR_OFFSET)
606 /****************************************************************************/
609 * Enable the device and uninhibit master transactions.
611 * @param InstancePtr is a pointer to the XSpiPs instance.
615 * @note C-Style signature:
616 * void XSpiPs_Enable(u32 *InstancePtr)
618 *****************************************************************************/
619 #define XSpiPs_Enable(InstancePtr) \
620 XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + XSPIPS_ER_OFFSET, \
621 XSPIPS_ER_ENABLE_MASK)
623 /****************************************************************************/
626 * Disable the device.
628 * @param InstancePtr is a pointer to the XSpiPs instance.
632 * @note C-Style signature:
633 * void XSpiPs_Disable(u32 *InstancePtr)
635 *****************************************************************************/
636 #define XSpiPs_Disable(InstancePtr) \
637 XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + XSPIPS_ER_OFFSET, 0U)
639 /************************** Function Prototypes ******************************/
642 * Initialization function, implemented in xspips_sinit.c
644 XSpiPs_Config *XSpiPs_LookupConfig(u16 DeviceId);
647 * Functions implemented in xspips.c
649 s32 XSpiPs_CfgInitialize(XSpiPs *InstancePtr, XSpiPs_Config * ConfigPtr,
652 void XSpiPs_Reset(XSpiPs *InstancePtr);
654 s32 XSpiPs_Transfer(XSpiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr,
657 s32 XSpiPs_PolledTransfer(XSpiPs *InstancePtr, u8 *SendBufPtr,
658 u8 *RecvBufPtr, u32 ByteCount);
660 void XSpiPs_SetStatusHandler(XSpiPs *InstancePtr, void *CallBackRef,
661 XSpiPs_StatusHandler FunctionPtr);
662 void XSpiPs_InterruptHandler(XSpiPs *InstancePtr);
664 void XSpiPs_Abort(XSpiPs *InstancePtr);
666 s32 XSpiPs_SetSlaveSelect(XSpiPs *InstancePtr, u8 SlaveSel);
667 u8 XSpiPs_GetSlaveSelect(XSpiPs *InstancePtr);
670 * Functions for selftest, in xspips_selftest.c
672 s32 XSpiPs_SelfTest(XSpiPs *InstancePtr);
675 * Functions for options, in xspips_options.c
677 s32 XSpiPs_SetOptions(XSpiPs *InstancePtr, u32 Options);
678 u32 XSpiPs_GetOptions(XSpiPs *InstancePtr);
680 s32 XSpiPs_SetClkPrescaler(XSpiPs *InstancePtr, u8 Prescaler);
681 u8 XSpiPs_GetClkPrescaler(XSpiPs *InstancePtr);
683 s32 XSpiPs_SetDelays(XSpiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn,
684 u8 DelayAfter, u8 DelayInit);
685 void XSpiPs_GetDelays(XSpiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn,
686 u8 *DelayAfter, u8 *DelayInit);
691 #endif /* end of protection macro */