#include "xstatus.h"
#include "xspips_hw.h"
Classes | |
struct | XSpiPs_Config |
struct | XSpiPs |
Defines | |
#define | XSPIPS_H |
#define | XSpiPs_IsManualStart(InstancePtr) |
#define | XSpiPs_IsManualChipSelect(InstancePtr) |
#define | XSpiPs_IsDecodeSSelect(InstancePtr) |
#define | XSpiPs_IsMaster(InstancePtr) |
#define | XSpiPs_SetSlaveIdle(InstancePtr, RegisterValue) |
#define | XSpiPs_GetSlaveIdle(InstancePtr) |
#define | XSpiPs_SetTXWatermark(InstancePtr, RegisterValue) |
#define | XSpiPs_GetTXWatermark(InstancePtr) XSpiPs_In32((InstancePtr->Config.BaseAddress) + XSPIPS_TXWR_OFFSET) |
#define | XSpiPs_SetRXWatermark(InstancePtr, RegisterValue) |
#define | XSpiPs_GetRXWatermark(InstancePtr) XSpiPs_In32((InstancePtr->Config.BaseAddress) + XSPIPS_RXWR_OFFSET) |
#define | XSpiPs_Enable(InstancePtr) |
#define | XSpiPs_Disable(InstancePtr) XSpiPs_Out32((InstancePtr->Config.BaseAddress) + XSPIPS_ER_OFFSET, 0) |
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 0x1 |
#define | XSPIPS_CLK_ACTIVE_LOW_OPTION 0x2 |
#define | XSPIPS_CLK_PHASE_1_OPTION 0x4 |
#define | XSPIPS_DECODE_SSELECT_OPTION 0x8 |
#define | XSPIPS_FORCE_SSELECT_OPTION 0x10 |
#define | XSPIPS_MANUAL_START_OPTION 0x20 |
SPI Clock Prescaler options | |
#define | XSPIPS_CLK_PRESCALE_4 0x01 |
#define | XSPIPS_CLK_PRESCALE_8 0x02 |
#define | XSPIPS_CLK_PRESCALE_16 0x03 |
#define | XSPIPS_CLK_PRESCALE_32 0x04 |
#define | XSPIPS_CLK_PRESCALE_64 0x05 |
#define | XSPIPS_CLK_PRESCALE_128 0x06 |
#define | XSPIPS_CLK_PRESCALE_256 0x07 |
Callback events | |
#define | XSPIPS_EVENT_MODE_FAULT 1 |
#define | XSPIPS_EVENT_TRANSFER_DONE 2 |
#define | XSPIPS_EVENT_TRANSMIT_UNDERRUN 3 |
#define | XSPIPS_EVENT_RECEIVE_OVERRUN 4 |
Typedefs | |
typedef void(* | XSpiPs_StatusHandler )(void *CallBackRef, u32 StatusEvent, unsigned ByteCount) |
Functions | |
XSpiPs_Config * | XSpiPs_LookupConfig (u16 DeviceId) |
int | XSpiPs_CfgInitialize (XSpiPs *InstancePtr, XSpiPs_Config *Config, u32 EffectiveAddr) |
void | XSpiPs_Reset (XSpiPs *InstancePtr) |
int | XSpiPs_Transfer (XSpiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, unsigned ByteCount) |
int | XSpiPs_PolledTransfer (XSpiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, unsigned ByteCount) |
void | XSpiPs_SetStatusHandler (XSpiPs *InstancePtr, void *CallBackRef, XSpiPs_StatusHandler FuncPtr) |
void | XSpiPs_InterruptHandler (void *InstancePtr) |
void | XSpiPs_Abort (XSpiPs *InstancePtr) |
int | XSpiPs_SetSlaveSelect (XSpiPs *InstancePtr, u8 SelectValue) |
u8 | XSpiPs_GetSlaveSelect (XSpiPs *InstancePtr) |
int | XSpiPs_SelfTest (XSpiPs *InstancePtr) |
int | XSpiPs_SetOptions (XSpiPs *InstancePtr, u32 Options) |
u32 | XSpiPs_GetOptions (XSpiPs *InstancePtr) |
int | XSpiPs_SetClkPrescaler (XSpiPs *InstancePtr, u8 Prescaler) |
u8 | XSpiPs_GetClkPrescaler (XSpiPs *InstancePtr) |
int | XSpiPs_SetDelays (XSpiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, u8 DelayAfter, u8 DelayInit) |
void | XSpiPs_GetDelays (XSpiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, u8 *DelayAfter, u8 *DelayInit) |
#define XSPIPS_CLK_ACTIVE_LOW_OPTION 0x2 |
Active Low Clock option
#define XSPIPS_CLK_PHASE_1_OPTION 0x4 |
Clock Phase one option
#define XSPIPS_CLK_PRESCALE_128 0x06 |
PCLK/128 Prescaler
#define XSPIPS_CLK_PRESCALE_16 0x03 |
PCLK/16 Prescaler
#define XSPIPS_CLK_PRESCALE_256 0x07 |
PCLK/256 Prescaler
#define XSPIPS_CLK_PRESCALE_32 0x04 |
PCLK/32 Prescaler
#define XSPIPS_CLK_PRESCALE_4 0x01 |
PCLK/4 Prescaler
#define XSPIPS_CLK_PRESCALE_64 0x05 |
PCLK/64 Prescaler
#define XSPIPS_CLK_PRESCALE_8 0x02 |
PCLK/8 Prescaler
#define XSPIPS_DECODE_SSELECT_OPTION 0x8 |
Select 16 slaves Option
#define XSpiPs_Disable | ( | InstancePtr | ) | XSpiPs_Out32((InstancePtr->Config.BaseAddress) + XSPIPS_ER_OFFSET, 0) |
Disable the device.
InstancePtr | is a pointer to the XSpiPs instance. |
#define XSpiPs_Enable | ( | InstancePtr | ) |
XSpiPs_Out32((InstancePtr->Config.BaseAddress) + XSPIPS_ER_OFFSET, \ XSPIPS_ER_ENABLE_MASK)
Enable the device and uninhibit master transactions.
InstancePtr | is a pointer to the XSpiPs instance. |
#define XSPIPS_EVENT_MODE_FAULT 1 |
Mode fault error
#define XSPIPS_EVENT_RECEIVE_OVERRUN 4 |
Receive data loss because RX FIFO full
#define XSPIPS_EVENT_TRANSFER_DONE 2 |
Transfer done
#define XSPIPS_EVENT_TRANSMIT_UNDERRUN 3 |
TX FIFO empty
#define XSPIPS_FORCE_SSELECT_OPTION 0x10 |
Force Slave Select
#define XSpiPs_GetRXWatermark | ( | InstancePtr | ) | XSpiPs_In32((InstancePtr->Config.BaseAddress) + XSPIPS_RXWR_OFFSET) |
Get the contents of the receive FIFO watermark register. Use the XSPIPS_RXWR_* constants defined xspips_hw.h to interpret the bit-mask returned.
InstancePtr | is a pointer to the XSpiPs instance. |
#define XSpiPs_GetSlaveIdle | ( | InstancePtr | ) |
XSpiPs_In32(((InstancePtr)->Config.BaseAddress) + \ XSPIPS_SICR_OFFSET)
Get the contents of the slave idle count register. Use the XSPIPS_SICR_* constants defined in xspips_hw.h to interpret the bit-mask returned.
InstancePtr | is a pointer to the XSpiPs instance. |
#define XSpiPs_GetTXWatermark | ( | InstancePtr | ) | XSpiPs_In32((InstancePtr->Config.BaseAddress) + XSPIPS_TXWR_OFFSET) |
Get the contents of the transmit FIFO watermark register. Use the XSPIPS_TXWR_* constants defined xspips_hw.h to interpret the bit-mask returned.
InstancePtr | is a pointer to the XSpiPs instance. |
#define XSPIPS_H |
#define XSpiPs_IsDecodeSSelect | ( | InstancePtr | ) |
((XSpiPs_GetOptions(InstancePtr) & \ XSPIPS_DECODE_SSELECT_OPTION) ? TRUE : FALSE)
#define XSpiPs_IsManualChipSelect | ( | InstancePtr | ) |
((XSpiPs_GetOptions(InstancePtr) & \ XSPIPS_FORCE_SSELECT_OPTION) ? TRUE : FALSE)
#define XSpiPs_IsManualStart | ( | InstancePtr | ) |
((XSpiPs_GetOptions(InstancePtr) & \ XSPIPS_MANUAL_START_OPTION) ? TRUE : FALSE)
#define XSpiPs_IsMaster | ( | InstancePtr | ) |
((XSpiPs_GetOptions(InstancePtr) & \ XSPIPS_MASTER_OPTION) ? TRUE : FALSE)
#define XSPIPS_MANUAL_START_OPTION 0x20 |
Manual Start mode option
#define XSPIPS_MASTER_OPTION 0x1 |
Master mode option
#define XSpiPs_SetRXWatermark | ( | InstancePtr, | |||
RegisterValue | ) |
XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ XSPIPS_RXWR_OFFSET, (RegisterValue))
Set the contents of the receive FIFO watermark register.
InstancePtr | is a pointer to the XSpiPs instance. | |
RegisterValue | is the value to be written, valid values are 1-128. |
#define XSpiPs_SetSlaveIdle | ( | InstancePtr, | |||
RegisterValue | ) |
XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ XSPIPS_SICR_OFFSET, (RegisterValue))
Set the contents of the slave idle count register.
InstancePtr | is a pointer to the XSpiPs instance. | |
RegisterValue | is the value to be writen, valid values are 0-255. |
#define XSpiPs_SetTXWatermark | ( | InstancePtr, | |||
RegisterValue | ) |
XSpiPs_Out32(((InstancePtr)->Config.BaseAddress) + \ XSPIPS_TXWR_OFFSET, (RegisterValue))
Set the contents of the transmit FIFO watermark register.
InstancePtr | is a pointer to the XSpiPs instance. | |
RegisterValue | is the value to be written, valid values are 1-128. |
typedef void(* XSpiPs_StatusHandler)(void *CallBackRef, u32 StatusEvent, unsigned ByteCount) |
The handler data type allows the user to define a callback function to handle the asynchronous processing for the SPI device. The application using this driver is expected to define a handler of this type to support interrupt driven mode. The handler executes in an interrupt context, so only minimal processing should be performed.
CallBackRef | is the callback reference passed in by the upper layer when setting the callback functions, and passed back to the upper layer when the callback is invoked. Its type is not important to the driver, so it is a void pointer. | |
StatusEvent | holds one or more status events that have occurred. See the XSpiPs_SetStatusHandler() for details on the status events that can be passed in the callback. | |
ByteCount | indicates how many bytes of data were successfully transferred. This may be less than the number of bytes requested if the status event indicates an error. |
void XSpiPs_Abort | ( | XSpiPs * | InstancePtr | ) |
Aborts a transfer in progress by disabling the device and resetting the FIFOs if present. The byte counts are cleared, the busy flag is cleared, and mode fault is cleared.
InstancePtr | is a pointer to the XSpiPs instance. |
This function does a read/modify/write of the Config register. The user of this function needs to take care of critical sections.
int XSpiPs_CfgInitialize | ( | XSpiPs * | InstancePtr, | |
XSpiPs_Config * | ConfigPtr, | |||
u32 | EffectiveAddr | |||
) |
Initializes a specific XSpiPs instance such that the driver is ready to use.
The state of the device after initialization is:
InstancePtr | is a pointer to the XSpiPs instance. | |
ConfigPtr | is a reference to a structure containing information about a specific SPI device. This function initializes an InstancePtr object for a specific device specified by the contents of Config. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call. | |
EffectiveAddr | is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use ConfigPtr->Config.BaseAddress for this device. |
u8 XSpiPs_GetClkPrescaler | ( | XSpiPs * | InstancePtr | ) |
This function gets the clock prescaler of an SPI device.
InstancePtr | is a pointer to the XSpiPs instance. |
void XSpiPs_GetDelays | ( | XSpiPs * | InstancePtr, | |
u8 * | DelayNss, | |||
u8 * | DelayBtwn, | |||
u8 * | DelayAfter, | |||
u8 * | DelayInit | |||
) |
This function gets the delay settings for an SPI device. The delay register controls the Delay Between Transfers, Delay After Transfers, and the Delay Initially. The default value is 0x0.
InstancePtr | is a pointer to the XSpiPs instance. | |
DelayNss | is a pointer to the delay for which the chip select outputs will be de-asserted between words when CPHA=0. | |
DelayBtwn | is a pointer to the Delay Between transfers value. This is a return parameter. | |
DelayAfter | is a pointer to the Delay After transfer value. This is a return parameter. | |
DelayInit | is a pointer to the Delay Initially value. This is a return parameter. |
u32 XSpiPs_GetOptions | ( | XSpiPs * | InstancePtr | ) |
This function gets the options for the SPI device. The options control how the device behaves relative to the SPI bus.
InstancePtr | is a pointer to the XSpiPs instance. |
Options contains the specified options currently set. This is a bit value where a 1 means the option is on, and a 0 means the option is off. See the bit definitions named XSPIPS_*_OPTIONS in file xspips.h.
u8 XSpiPs_GetSlaveSelect | ( | XSpiPs * | InstancePtr | ) |
Gets the current slave select setting for the SPI device.
InstancePtr | is a pointer to the XSpiPs instance. |
void XSpiPs_InterruptHandler | ( | void * | InstancePtr | ) |
The interrupt handler for SPI interrupts. This function must be connected by the user to an interrupt controller.
The interrupts that are handled are:
InstancePtr | is a pointer to the XSpiPs instance. |
The slave select register is being set to deselect the slave when a transfer is complete. This is being done regardless of whether it is a slave or a master since the hardware does not drive the slave select as a slave.
XSpiPs_Config* XSpiPs_LookupConfig | ( | u16 | DeviceId | ) |
Looks up the device configuration based on the unique device ID. A table contains the configuration info for each device in the system.
DeviceId | contains the ID of the device to look up the configuration for. |
A pointer to the configuration found or NULL if the specified device ID was not found. See xspips.h for the definition of XSpiPs_Config.
int XSpiPs_PolledTransfer | ( | XSpiPs * | InstancePtr, | |
u8 * | SendBufPtr, | |||
u8 * | RecvBufPtr, | |||
unsigned | ByteCount | |||
) |
Transfers specified data on the SPI bus in polled mode.
The caller has the option of providing two different buffers for send and receive, or one buffer for both send and receive, or no buffer for receive. The receive buffer must be at least as big as the send buffer to prevent unwanted memory writes. This implies that the byte count passed in as an argument must be the smaller of the two buffers if they differ in size. Here are some sample usages:
XSpiPs_PolledTransfer(InstancePtr, SendBuf, RecvBuf, ByteCount) The caller wishes to send and receive, and provides two different buffers for send and receive.
XSpiPs_PolledTransfer(InstancePtr, SendBuf, NULL, ByteCount) The caller wishes only to send and does not care about the received data. The driver ignores the received data in this case.
XSpiPs_PolledTransfer(InstancePtr, SendBuf, SendBuf, ByteCount) The caller wishes to send and receive, but provides the same buffer for doing both. The driver sends the data and overwrites the send buffer with received data as it transfers the data.
XSpiPs_PolledTransfer(InstancePtr, RecvBuf, RecvBuf, ByteCount) The caller wishes to only receive and does not care about sending data. In this case, the caller must still provide a send buffer, but it can be the same as the receive buffer if the caller does not care what it sends. The device must send N bytes of data if it wishes to receive N bytes of data.
InstancePtr | is a pointer to the XSpiPs instance. | |
SendBufPtr | is a pointer to a buffer of data for sending. This buffer must not be NULL. | |
RecvBufPtr | is a pointer to a buffer for received data. This argument can be NULL if do not care about receiving. | |
ByteCount | contains the number of bytes to send/receive. The number of bytes received always equals the number of bytes sent. |
This function is not thread-safe. The higher layer software must ensure that no two threads are transferring data on the SPI bus at the same time.
void XSpiPs_Reset | ( | XSpiPs * | InstancePtr | ) |
Resets the SPI device. Reset must only be called after the driver has been initialized. The configuration of the device after reset is the same as its configuration after initialization. Any data transfer that is in progress is aborted.
The upper layer software is responsible for re-configuring (if necessary) and restarting the SPI device after the reset.
InstancePtr | is a pointer to the XSpiPs instance. |
int XSpiPs_SelfTest | ( | XSpiPs * | InstancePtr | ) |
Runs a self-test on the driver/device. The self-test is destructive in that a reset of the device is performed in order to check the reset values of the registers and to get the device into a known state.
Upon successful return from the self-test, the device is reset.
InstancePtr | is a pointer to the XSpiPs instance. |
int XSpiPs_SetClkPrescaler | ( | XSpiPs * | InstancePtr, | |
u8 | Prescaler | |||
) |
This function sets the clock prescaler for an SPI device. The device must be idle rather than busy transferring data before setting these device options.
InstancePtr | is a pointer to the XSpiPs instance. | |
Prescaler | is the value that determine how much the clock should be divided by. Use the XSPIPS_CLK_PRESCALE_* constants defined in xspips.h for this setting. |
int XSpiPs_SetDelays | ( | XSpiPs * | InstancePtr, | |
u8 | DelayNss, | |||
u8 | DelayBtwn, | |||
u8 | DelayAfter, | |||
u8 | DelayInit | |||
) |
This function sets the delay register for the SPI device driver. The delay register controls the Delay Between Transfers, Delay After Transfers, and the Delay Initially. The default value is 0x0. The range of each delay value is 0-255.
InstancePtr | is a pointer to the XSpiPs instance. | |
DelayNss | is the delay for which the chip select outputs will be de-asserted between words when CPHA=0. | |
DelayBtwn | is the delay between one Slave Select being de-activated and the activation of another slave. The delay is the number of master clock periods given by DelayBtwn + 2. | |
DelayAfter | define the delay between the last bit of the current byte transfer and the first bit of the next byte transfer. The delay in number of master clock periods is given as: CPHA=0:DelayInit+DelayAfter+3 CPHA=1:DelayAfter+1 | |
DelayInit | is the delay between asserting the slave select signal and the first bit transfer. The delay int number of master clock periods is DelayInit+1. |
int XSpiPs_SetOptions | ( | XSpiPs * | InstancePtr, | |
u32 | Options | |||
) |
This function sets the options for the SPI device driver. The options control how the device behaves relative to the SPI bus. The device must be idle rather than busy transferring data before setting these device options.
InstancePtr | is a pointer to the XSpiPs instance. | |
Options | contains the specified options to be set. This is a bit mask where a 1 means to turn the option on, and a 0 means to turn the option off. One or more bit values may be contained in the mask. See the bit definitions named XSPIPS_*_OPTIONS in the file xspips.h. |
int XSpiPs_SetSlaveSelect | ( | XSpiPs * | InstancePtr, | |
u8 | SlaveSel | |||
) |
Selects or deselect the slave with which the master communicates. This setting affects the SPI_ss_outN signals. The behavior depends on the setting of the CR_SSDECEN bit. If CR_SSDECEN is 0, the SPI_ss_outN bits will be output with a single signal low. If CR_SSDECEN is 1, the SPI_ss_outN bits will reflect the value set.
The user is not allowed to deselect the slave while a transfer is in progress. If no transfer is in progress, the user can select a new slave, which implicitly deselects the current slave. In order to explicitly deselect the current slave, a value of all 1's, 0x0F can be passed in as the argument to the function.
InstancePtr | is a pointer to the XSpiPs instance. | |
SlaveSel | is the slave number to be selected. Normally, 3 slaves can be selected with values 0-2. In case, 3-8 decode option is set, then upto 8 slaves can be selected. Only one slave can be selected at a time. |
This function only sets the slave which will be selected when a transfer occurs. The slave is not selected when the SPI is idle. The slave select has no affect when the device is configured as a slave.
void XSpiPs_SetStatusHandler | ( | XSpiPs * | InstancePtr, | |
void * | CallBackRef, | |||
XSpiPs_StatusHandler | FuncPtr | |||
) |
Sets the status callback function, the status handler, which the driver calls when it encounters conditions that should be reported to upper layer software. The handler executes in an interrupt context, so it must minimize the amount of processing performed. One of the following status events is passed to the status handler.
XST_SPI_MODE_FAULT A mode fault error occurred, meaning the device is selected as slave while being a master.
XST_SPI_TRANSFER_DONE The requested data transfer is done
XST_SPI_TRANSMIT_UNDERRUN As a slave device, the master clocked data but there were none available in the transmit register/FIFO. This typically means the slave application did not issue a transfer request fast enough, or the processor/driver could not fill the transmit register/FIFO fast enough.
XST_SPI_RECEIVE_OVERRUN The SPI device lost data. Data was received but the receive data register/FIFO was full.
XST_SPI_SLAVE_MODE_FAULT A slave SPI device was selected as a slave while it was disabled. This indicates the master is already transferring data (which is being dropped until the slave application issues a transfer).
InstancePtr | is a pointer to the XSpiPs instance. | |
CallBackRef | is the upper layer callback reference passed back when the callback function is invoked. | |
FuncPtr | is the pointer to the callback function. |
The handler is called within interrupt context, so it should do its work quickly and queue potentially time-consuming work to a task-level thread.
int XSpiPs_Transfer | ( | XSpiPs * | InstancePtr, | |
u8 * | SendBufPtr, | |||
u8 * | RecvBufPtr, | |||
unsigned | ByteCount | |||
) |
Transfers specified data on the SPI bus. If the SPI device is configured as a master, this function initiates bus communication and sends/receives the data to/from the selected SPI slave. If the SPI device is configured as a slave, this function prepares the buffers to be sent/received when selected by a master. For every byte sent, a byte is received. This function should be used to perform interrupt based transfers.
The caller has the option of providing two different buffers for send and receive, or one buffer for both send and receive, or no buffer for receive. The receive buffer must be at least as big as the send buffer to prevent unwanted memory writes. This implies that the byte count passed in as an argument must be the smaller of the two buffers if they differ in size. Here are some sample usages:
XSpiPs_Transfer(InstancePtr, SendBuf, RecvBuf, ByteCount) The caller wishes to send and receive, and provides two different buffers for send and receive.
XSpiPs_Transfer(InstancePtr, SendBuf, NULL, ByteCount) The caller wishes only to send and does not care about the received data. The driver ignores the received data in this case.
XSpiPs_Transfer(InstancePtr, SendBuf, SendBuf, ByteCount) The caller wishes to send and receive, but provides the same buffer for doing both. The driver sends the data and overwrites the send buffer with received data as it transfers the data.
XSpiPs_Transfer(InstancePtr, RecvBuf, RecvBuf, ByteCount) The caller wishes to only receive and does not care about sending data. In this case, the caller must still provide a send buffer, but it can be the same as the receive buffer if the caller does not care what it sends. The device must send N bytes of data if it wishes to receive N bytes of data.
Although this function takes entire buffers as arguments, the driver can only transfer a limited number of bytes at a time, limited by the size of the FIFO. A call to this function only starts the transfer, then subsequent transfers of the data is performed by the interrupt service routine until the entire buffer has been transferred. The status callback function is called when the entire buffer has been sent/received.
This function is non-blocking. As a master, the SetSlaveSelect function must be called prior to this function.
InstancePtr | is a pointer to the XSpiPs instance. | |
SendBufPtr | is a pointer to a buffer of data for sending. This buffer must not be NULL. | |
RecvBufPtr | is a pointer to a buffer for received data. This argument can be NULL if do not care about receiving. | |
ByteCount | contains the number of bytes to send/receive. The number of bytes received always equals the number of bytes sent. |
This function is not thread-safe. The higher layer software must ensure that no two threads are transferring data on the SPI bus at the same time.
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.