![]() |
spips
Vitis Drivers API Documentation
|
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... | |
| #define | XSpiPs_In32 Xil_In32 |
| Reads a 32-bit register. More... | |
| #define | XSpiPs_Out32 Xil_Out32 |
| Writes a 32-bit register. More... | |
| #define | XSpiPs_ReadReg(BaseAddress, RegOffset) XSpiPs_In32((BaseAddress) + (RegOffset)) |
| Reads a register. More... | |
| #define | XSpiPs_WriteReg(BaseAddress, RegOffset, RegisterValue) XSpiPs_Out32((BaseAddress) + (RegOffset), (RegisterValue)) |
| Writes to a register. More... | |
| #define | XSPIPS_NUM_OPTIONS (sizeof(OptionsTable) / sizeof(OptionsMap)) |
| Number of entries in the options table. 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... | |
| void | XSpiPs_ResetHw (u32 BaseAddress) |
| Resets the SPI module. 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... | |
| s32 | XSpiPs_SelfTest (XSpiPs *InstancePtr) |
| Runs a self-test on the driver/device. More... | |
| XSpiPs_Config * | XSpiPs_LookupConfig (UINTPTR BaseAddress) |
| Looks up the device configuration based on the unique device ID/BaseAddress. More... | |
Variables | |
| XSpiPs_Config | XSpiPs_ConfigTable [XPAR_XSPIPS_NUM_INSTANCES] |
| Holds the configuration information for each SPI device in the system. More... | |
| XSpiPs_Config | XSpiPs_ConfigTable [] |
| Holds the configuration information for each SPI device in the system. More... | |
Register Map | |
| #define | XSPIPS_CR_OFFSET 0x00U |
| Configuration. More... | |
| #define | XSPIPS_SR_OFFSET 0x04U |
| Interrupt Status. More... | |
| #define | XSPIPS_IER_OFFSET 0x08U |
| Interrupt Enable. More... | |
| #define | XSPIPS_IDR_OFFSET 0x0CU |
| Interrupt Disable. More... | |
| #define | XSPIPS_IMR_OFFSET 0x10U |
| Interrupt Enabled Mask. More... | |
| #define | XSPIPS_ER_OFFSET 0x14U |
| Enable/Disable Register. More... | |
| #define | XSPIPS_DR_OFFSET 0x18U |
| Delay Register. More... | |
| #define | XSPIPS_TXD_OFFSET 0x1CU |
| Data Transmit Register. More... | |
| #define | XSPIPS_RXD_OFFSET 0x20U |
| Data Receive Register. More... | |
| #define | XSPIPS_SICR_OFFSET 0x24U |
| Slave Idle Count. More... | |
| #define | XSPIPS_TXWR_OFFSET 0x28U |
| Transmit FIFO Watermark. More... | |
| #define | XSPIPS_RXWR_OFFSET 0x2CU |
| Receive FIFO Watermark. More... | |
Configuration Register | |
This register contains various control bits that affects the operation of an SPI device. Read/Write. | |
| #define | XSPIPS_CR_MODF_GEN_EN_MASK 0x00020000U |
| Modefail Generation Enable. More... | |
| #define | XSPIPS_CR_MANSTRT_MASK 0x00010000U |
| Manual Transmission Start. More... | |
| #define | XSPIPS_CR_MANSTRTEN_MASK 0x00008000U |
| Manual Transmission Start Enable. More... | |
| #define | XSPIPS_CR_SSFORCE_MASK 0x00004000U |
| Force Slave Select. More... | |
| #define | XSPIPS_CR_SSCTRL_MASK 0x00003C00U |
| Slave Select Decode. More... | |
| #define | XSPIPS_CR_SSCTRL_SHIFT 10U |
| Slave Select Decode shift. More... | |
| #define | XSPIPS_CR_SSCTRL_MAXIMUM 0xFU |
| Slave Select maximum value. More... | |
| #define | XSPIPS_CR_SSDECEN_MASK 0x00000200U |
| Slave Select Decode Enable. More... | |
| #define | XSPIPS_CR_PRESC_MASK 0x00000038U |
| Prescaler Setting. More... | |
| #define | XSPIPS_CR_PRESC_SHIFT 3U |
| Prescaler shift. More... | |
| #define | XSPIPS_CR_PRESC_MAXIMUM 0x07U |
| Prescaler maximum value. More... | |
| #define | XSPIPS_CR_CPHA_MASK 0x00000004U |
| Phase Configuration. More... | |
| #define | XSPIPS_CR_CPOL_MASK 0x00000002U |
| Polarity Configuration. More... | |
| #define | XSPIPS_CR_MSTREN_MASK 0x00000001U |
| Master Mode Enable. More... | |
| #define | XSPIPS_CR_RESET_STATE 0x00020000U |
| Mode Fail Generation Enable. More... | |
SPI Interrupt Registers | |
|
This register holds the interrupt status flags for an SPI device. Some of the flags are level triggered, which means that they are set as long as the interrupt condition exists. Other flags are edge triggered, which means they are set once the interrupt condition occurs and remain set until they are cleared by software. The interrupts are cleared by writing a '1' to the interrupt bit position in the Status Register. Read/Write. SPI Interrupt Enable Register This register enables chosen interrupts for an SPI device. Writing a '1' to a bit in this register sets the corresponding bit in the SPI Interrupt Mask register. Write only. SPI Interrupt Disable Register This register disables chosen interrupts for an SPI device. Writing a '1' to a bit in this register clears the corresponding bit in the SPI Interrupt Mask register. Write only. SPI Interrupt Mask Register This register shows the enabled/disabled interrupts of an SPI device. Read only. All four registers have the same bit definitions. They are only defined once for each of the Interrupt Enable Register, Interrupt Disable Register, Interrupt Mask Register, and Channel Interrupt Status Register | |
| #define | XSPIPS_IXR_TXUF_MASK 0x00000040U |
| Tx FIFO Underflow. More... | |
| #define | XSPIPS_IXR_RXFULL_MASK 0x00000020U |
| Rx FIFO Full. More... | |
| #define | XSPIPS_IXR_RXNEMPTY_MASK 0x00000010U |
| Rx FIFO Not Empty. More... | |
| #define | XSPIPS_IXR_TXFULL_MASK 0x00000008U |
| Tx FIFO Full. More... | |
| #define | XSPIPS_IXR_TXOW_MASK 0x00000004U |
| Tx FIFO Overwater. More... | |
| #define | XSPIPS_IXR_MODF_MASK 0x00000002U |
| Mode Fault. More... | |
| #define | XSPIPS_IXR_RXOVR_MASK 0x00000001U |
| Rx FIFO Overrun. More... | |
| #define | XSPIPS_IXR_DFLT_MASK 0x00000027U |
| Default interrupts mask. More... | |
| #define | XSPIPS_IXR_WR_TO_CLR_MASK 0x00000043U |
| Interrupts which need write to clear. More... | |
| #define | XSPIPS_ISR_RESET_STATE 0x04U |
| Default to tx/rx reg empty. More... | |
| #define | XSPIPS_IXR_DISABLE_ALL_MASK 0x00000043U |
| Disable all interrupts. More... | |
Enable Register | |
This register enables or disables an SPI device. Read/Write | |
| #define | XSPIPS_ER_ENABLE_MASK 0x00000001U |
| SPI Enable Bit Mask. More... | |
Delay Register | |
This register programs timing delays in slave mode. Read/Write | |
| #define | XSPIPS_DR_NSS_MASK 0xFF000000U |
| Delay for slave select de-assertion between word transfers mask. More... | |
| #define | XSPIPS_DR_NSS_SHIFT 24U |
| Delay for slave select de-assertion between word transfers shift. More... | |
| #define | XSPIPS_DR_BTWN_MASK 0x00FF0000U |
| Delay Between Transfers mask. More... | |
| #define | XSPIPS_DR_BTWN_SHIFT 16U |
| Delay Between Transfers shift. More... | |
| #define | XSPIPS_DR_AFTER_MASK 0x0000FF00U |
| Delay After Transfers mask. More... | |
| #define | XSPIPS_DR_AFTER_SHIFT 8U |
| Delay After Transfers shift. More... | |
| #define | XSPIPS_DR_INIT_MASK 0x000000FFU |
| Delay Initially mask. More... | |
Slave Idle Count Registers | |
This register defines the number of pclk cycles the slave waits for a the SPI clock to become stable in quiescent state before it can detect the start of the next transfer in CPHA = 1 mode. Read/Write | |
| #define | XSPIPS_SICR_MASK 0x000000FFU |
| Slave Idle Count Mask. More... | |
Transmit FIFO Watermark Register | |
This register defines the watermark setting for the Transmit FIFO. The transmit FIFO is 128 bytes deep, so the register is 7 bits. Valid values are 1 to 128. | |
| #define | XSPIPS_TXWR_MASK 0x0000007FU |
| Transmit Watermark Mask. More... | |
| #define | XSPIPS_TXWR_RESET_VALUE 0x00000001U |
| Transmit Watermark register reset value. More... | |
Receive FIFO Watermark Register | |
This register defines the watermark setting for the Receive FIFO. The receive FIFO is 128 bytes deep, so the register is 7 bits. Valid values are 1 to 128. | |
| #define | XSPIPS_RXWR_MASK 0x0000007FU |
| Receive Watermark Mask. More... | |
| #define | XSPIPS_RXWR_RESET_VALUE 0x00000001U |
| Receive Watermark register reset value. More... | |
FIFO Depth | |
| #define | XSPIPS_FIFO_DEPTH 128U |
| FIFO depth of Tx and Rx. More... | |
| #define | XSPIPS_MAX_FIFO_DEPTH 256U |
| Largest supported FIFO depth. More... | |
| #define XSPIPS_CR_CPHA_MASK 0x00000004U |
Phase Configuration.
Referenced by XSpiPs_SetOptions().
| #define XSPIPS_CR_CPOL_MASK 0x00000002U |
Polarity Configuration.
Referenced by XSpiPs_SetOptions().
| #define XSPIPS_CR_MANSTRT_MASK 0x00010000U |
Manual Transmission Start.
Referenced by XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), and XSpiPs_Transfer().
| #define XSPIPS_CR_MANSTRTEN_MASK 0x00008000U |
Manual Transmission Start Enable.
| #define XSPIPS_CR_MODF_GEN_EN_MASK 0x00020000U |
Modefail Generation Enable.
| #define XSPIPS_CR_MSTREN_MASK 0x00000001U |
Master Mode Enable.
| #define XSPIPS_CR_OFFSET 0x00U |
| #define XSPIPS_CR_PRESC_MASK 0x00000038U |
Prescaler Setting.
Referenced by XSpiPs_GetClkPrescaler(), and XSpiPs_SetClkPrescaler().
| #define XSPIPS_CR_PRESC_MAXIMUM 0x07U |
Prescaler maximum value.
Referenced by XSpiPs_SetClkPrescaler().
| #define XSPIPS_CR_PRESC_SHIFT 3U |
Prescaler shift.
Referenced by XSpiPs_GetClkPrescaler(), and XSpiPs_SetClkPrescaler().
| #define XSPIPS_CR_RESET_STATE 0x00020000U |
Mode Fail Generation Enable.
Referenced by XSpiPs_Reset(), XSpiPs_ResetHw(), and XSpiPs_SelfTest().
| #define XSPIPS_CR_SSCTRL_MASK 0x00003C00U |
Slave Select Decode.
Referenced by XSpiPs_GetSlaveSelect(), XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), XSpiPs_Reset(), XSpiPs_ResetHw(), XSpiPs_SelfTest(), XSpiPs_SetSlaveSelect(), and XSpiPs_Transfer().
| #define XSPIPS_CR_SSCTRL_MAXIMUM 0xFU |
Slave Select maximum value.
Referenced by XSpiPs_GetSlaveSelect(), and XSpiPs_SetSlaveSelect().
| #define XSPIPS_CR_SSCTRL_SHIFT 10U |
Slave Select Decode shift.
Referenced by XSpiPs_GetSlaveSelect(), and XSpiPs_SetSlaveSelect().
| #define XSPIPS_CR_SSDECEN_MASK 0x00000200U |
Slave Select Decode Enable.
| #define XSPIPS_CR_SSFORCE_MASK 0x00004000U |
Force Slave Select.
| #define XSPIPS_DR_AFTER_MASK 0x0000FF00U |
Delay After Transfers mask.
Referenced by XSpiPs_GetDelays().
| #define XSPIPS_DR_AFTER_SHIFT 8U |
Delay After Transfers shift.
Referenced by XSpiPs_GetDelays(), and XSpiPs_SetDelays().
| #define XSPIPS_DR_BTWN_MASK 0x00FF0000U |
Delay Between Transfers mask.
Referenced by XSpiPs_GetDelays().
| #define XSPIPS_DR_BTWN_SHIFT 16U |
Delay Between Transfers shift.
Referenced by XSpiPs_GetDelays(), and XSpiPs_SetDelays().
| #define XSPIPS_DR_INIT_MASK 0x000000FFU |
Delay Initially mask.
Referenced by XSpiPs_GetDelays().
| #define XSPIPS_DR_NSS_MASK 0xFF000000U |
Delay for slave select de-assertion between word transfers mask.
Referenced by XSpiPs_GetDelays().
| #define XSPIPS_DR_NSS_SHIFT 24U |
Delay for slave select de-assertion between word transfers shift.
Referenced by XSpiPs_GetDelays(), and XSpiPs_SetDelays().
| #define XSPIPS_DR_OFFSET 0x18U |
Delay Register.
Referenced by XSpiPs_GetDelays(), and XSpiPs_SetDelays().
| #define XSPIPS_ER_ENABLE_MASK 0x00000001U |
SPI Enable Bit Mask.
| #define XSPIPS_ER_OFFSET 0x14U |
Enable/Disable Register.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_FIFO_DEPTH 128U |
FIFO depth of Tx and Rx.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_IDR_OFFSET 0x0CU |
Interrupt Disable.
Referenced by XSpiPs_InterruptHandler(), and XSpiPs_ResetHw().
| #define XSPIPS_IER_OFFSET 0x08U |
Interrupt Enable.
Referenced by XSpiPs_InterruptHandler(), and XSpiPs_Transfer().
| #define XSPIPS_IMR_OFFSET 0x10U |
Interrupt Enabled Mask.
| #define XSpiPs_In32 Xil_In32 |
Reads a 32-bit register.
| #define XSPIPS_ISR_RESET_STATE 0x04U |
Default to tx/rx reg empty.
Referenced by XSpiPs_SelfTest().
| #define XSPIPS_IXR_DFLT_MASK 0x00000027U |
Default interrupts mask.
Referenced by XSpiPs_InterruptHandler(), and XSpiPs_Transfer().
| #define XSPIPS_IXR_DISABLE_ALL_MASK 0x00000043U |
Disable all interrupts.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_IXR_MODF_MASK 0x00000002U |
Mode Fault.
Referenced by XSpiPs_Abort(), XSpiPs_InterruptHandler(), and XSpiPs_PolledTransfer().
| #define XSPIPS_IXR_RXFULL_MASK 0x00000020U |
Rx FIFO Full.
| #define XSPIPS_IXR_RXNEMPTY_MASK 0x00000010U |
Rx FIFO Not Empty.
Referenced by XSpiPs_Abort(), and XSpiPs_ResetHw().
| #define XSPIPS_IXR_RXOVR_MASK 0x00000001U |
Rx FIFO Overrun.
Referenced by XSpiPs_InterruptHandler().
| #define XSPIPS_IXR_TXFULL_MASK 0x00000008U |
Tx FIFO Full.
| #define XSPIPS_IXR_TXOW_MASK 0x00000004U |
Tx FIFO Overwater.
Referenced by XSpiPs_InterruptHandler(), and XSpiPs_PolledTransfer().
| #define XSPIPS_IXR_TXUF_MASK 0x00000040U |
Tx FIFO Underflow.
Referenced by XSpiPs_InterruptHandler().
| #define XSPIPS_IXR_WR_TO_CLR_MASK 0x00000043U |
Interrupts which need write to clear.
Referenced by XSpiPs_InterruptHandler(), and XSpiPs_ResetHw().
| #define XSPIPS_MAX_FIFO_DEPTH 256U |
Largest supported FIFO depth.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_NUM_OPTIONS (sizeof(OptionsTable) / sizeof(OptionsMap)) |
Number of entries in the options table.
Referenced by XSpiPs_GetOptions(), and XSpiPs_SetOptions().
| #define XSpiPs_Out32 Xil_Out32 |
Writes a 32-bit register.
| #define XSPIPS_POLL_TIMEOUT_US 1000000U |
Master mode TX FIFO wait limit in microseconds.
Referenced by XSpiPs_PolledTransfer().
| #define XSpiPs_ReadReg | ( | BaseAddress, | |
| RegOffset | |||
| ) | XSpiPs_In32((BaseAddress) + (RegOffset)) |
Reads a register.
| [in] | BaseAddress | The base address of the device. |
| [in] | RegOffset | The offset from the 1st register of the device to the target register. |
Referenced by XSpiPs_Abort(), XSpiPs_GetClkPrescaler(), XSpiPs_GetDelays(), XSpiPs_GetOptions(), XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), XSpiPs_ResetHw(), XSpiPs_SelfTest(), XSpiPs_SetClkPrescaler(), XSpiPs_SetOptions(), XSpiPs_SetSlaveSelect(), and XSpiPs_Transfer().
| #define XSpiPs_RecvByte | ( | BaseAddress | ) | XSpiPs_In32((u32)((BaseAddress) + (u32)XSPIPS_RXD_OFFSET)) |
Receives one byte from the device's receive FIFO/register.
It is assumed that the byte is already available.
| [in] | BaseAddress | The base address of the device. |
Referenced by XSpiPs_Abort(), XSpiPs_InterruptHandler(), and XSpiPs_PolledTransfer().
| #define XSPIPS_RXD_OFFSET 0x20U |
Data Receive Register.
Referenced by XSpiPs_Abort(), and XSpiPs_ResetHw().
| #define XSPIPS_RXWR_MASK 0x0000007FU |
Receive Watermark Mask.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_RXWR_OFFSET 0x2CU |
Receive FIFO Watermark.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_RXWR_RESET_VALUE 0x00000001U |
Receive Watermark register reset value.
Referenced by XSpiPs_ResetHw().
| #define XSpiPs_SendByte | ( | BaseAddress, | |
| Data | |||
| ) | XSpiPs_Out32((BaseAddress) + (u32)XSPIPS_TXD_OFFSET, (u32)(Data)) |
Sends one byte to the currently selected slave.
A byte of data is written to transmit FIFO/register.
| [in] | BaseAddress | The base address of the device. |
| [in] | Data | The data to be written to the transmit FIFO/register. |
Referenced by XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), and XSpiPs_Transfer().
| #define XSPIPS_SICR_MASK 0x000000FFU |
Slave Idle Count Mask.
| #define XSPIPS_SICR_OFFSET 0x24U |
Slave Idle Count.
| #define XSPIPS_SR_OFFSET 0x04U |
Interrupt Status.
Referenced by XSpiPs_Abort(), XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), XSpiPs_ResetHw(), XSpiPs_SelfTest(), and XSpiPs_Transfer().
| #define XSPIPS_TXD_OFFSET 0x1CU |
Data Transmit Register.
| #define XSPIPS_TXWR_MASK 0x0000007FU |
Transmit Watermark Mask.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_TXWR_OFFSET 0x28U |
Transmit FIFO Watermark.
Referenced by XSpiPs_ResetHw().
| #define XSPIPS_TXWR_RESET_VALUE 0x00000001U |
Transmit Watermark register reset value.
Referenced by XSpiPs_ResetHw().
| #define XSpiPs_WriteReg | ( | BaseAddress, | |
| RegOffset, | |||
| RegisterValue | |||
| ) | XSpiPs_Out32((BaseAddress) + (RegOffset), (RegisterValue)) |
Writes to a register.
| [in] | BaseAddress | The base address of the device. |
| [in] | RegOffset | The offset from the 1st register of the device to target register. |
| [in] | RegisterValue | The value to be written to the register. |
Referenced by XSpiPs_Abort(), XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), XSpiPs_Reset(), XSpiPs_ResetHw(), XSpiPs_SetClkPrescaler(), XSpiPs_SetDelays(), XSpiPs_SetOptions(), XSpiPs_SetSlaveSelect(), and XSpiPs_Transfer().
| 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.
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::FifoDepth, XSpiPs::IsBusy, XSpiPs::RemainingBytes, XSpiPs::RequestedBytes, XSpiPs_Disable, XSPIPS_IXR_MODF_MASK, XSPIPS_IXR_RXNEMPTY_MASK, XSpiPs_ReadReg, XSpiPs_RecvByte, XSPIPS_RXD_OFFSET, XSPIPS_SR_OFFSET, and XSpiPs_WriteReg.
Referenced by XSpiPs_InterruptHandler(), XSpiPs_PolledTransfer(), and XSpiPs_Reset().
| s32 XSpiPs_CfgInitialize | ( | XSpiPs * | InstancePtr, |
| const 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:
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. Must be zero-initialized before calling this function. |
| [in] | ConfigPtr | Reference to a structure containing information about a specific SPI device. The function initializes an InstancePtr object for a specific device specified by the contents of Config. The function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call. |
| [in] | EffectiveAddr | 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. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs_Config::FifoDepth, XSpiPs::FifoDepth, XSpiPs::FifoWidth, XSpiPs_Config::InputClockHz, XSpiPs::IsBusy, XSpiPs::IsReady, XSpiPs::RecvBufferPtr, XSpiPs::RemainingBytes, XSpiPs::RequestedBytes, XSpiPs::SendBufferPtr, XSpiPs::StatusHandler, and XSpiPs_Reset().
Referenced by SpiPsEepromIntrExample(), SpiPsEepromPolledExample(), SpiPsFlashIntrExample(), SpiPsFlashPolledExample(), SpiPsSelfTestExample(), SpiPsSlavePolledExample(), and SpiPsTpmPolledExample().
| u8 XSpiPs_GetClkPrescaler | ( | const XSpiPs * | InstancePtr | ) |
Gets the clock prescaler of an SPI device.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsReady, XSPIPS_CR_OFFSET, XSPIPS_CR_PRESC_MASK, XSPIPS_CR_PRESC_SHIFT, and XSpiPs_ReadReg.
| void XSpiPs_GetDelays | ( | const XSpiPs * | InstancePtr, |
| u8 * | DelayNss, | ||
| u8 * | DelayBtwn, | ||
| u8 * | DelayAfter, | ||
| u8 * | DelayInit | ||
| ) |
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.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
| [out] | DelayNss | Pointer to the delay for which the chip select outputs are de-asserted between words when CPHA=0. |
| [out] | DelayBtwn | Pointer to the Delay Between transfers value. |
| [out] | DelayAfter | Pointer to the Delay After transfer value. |
| [out] | DelayInit | Pointer to the Delay Initially value. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsReady, XSPIPS_DR_AFTER_MASK, XSPIPS_DR_AFTER_SHIFT, XSPIPS_DR_BTWN_MASK, XSPIPS_DR_BTWN_SHIFT, XSPIPS_DR_INIT_MASK, XSPIPS_DR_NSS_MASK, XSPIPS_DR_NSS_SHIFT, XSPIPS_DR_OFFSET, and XSpiPs_ReadReg.
Referenced by XSpiPs_SelfTest().
| u32 XSpiPs_GetOptions | ( | const XSpiPs * | InstancePtr | ) |
Gets the options for the SPI device.
The options control how the device behaves relative to the SPI bus.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsReady, XSPIPS_CR_OFFSET, XSPIPS_NUM_OPTIONS, and XSpiPs_ReadReg.
| u8 XSpiPs_GetSlaveSelect | ( | const XSpiPs * | InstancePtr | ) |
Gets the current slave select setting for the SPI device.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs::IsReady, XSpiPs::SlaveSelect, XSPIPS_CR_SSCTRL_MASK, XSPIPS_CR_SSCTRL_MAXIMUM, XSPIPS_CR_SSCTRL_SHIFT, and XSpiPs_IsDecodeSSelect.
| void XSpiPs_InterruptHandler | ( | XSpiPs * | InstancePtr | ) |
Handles the SPI interrupts.
The interrupt handler must be connected by the user to an interrupt controller.
The interrupts that are handled are:
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::FifoDepth, XSpiPs::FifoWidth, XSpiPs::IsBusy, XSpiPs::IsReady, XSpiPs::RecvBufferPtr, XSpiPs::RemainingBytes, XSpiPs::RequestedBytes, XSpiPs::SendBufferPtr, XSpiPs::StatusHandler, XSpiPs::StatusRef, XSpiPs_Abort(), XSPIPS_CR_MANSTRT_MASK, XSPIPS_CR_OFFSET, XSPIPS_CR_SSCTRL_MASK, XSpiPs_Disable, XSPIPS_IDR_OFFSET, XSPIPS_IER_OFFSET, XSpiPs_IsManualChipSelect, XSpiPs_IsManualStart, XSpiPs_IsMaster, XSPIPS_IXR_DFLT_MASK, XSPIPS_IXR_MODF_MASK, XSPIPS_IXR_RXOVR_MASK, XSPIPS_IXR_TXOW_MASK, XSPIPS_IXR_TXUF_MASK, XSPIPS_IXR_WR_TO_CLR_MASK, XSpiPs_ReadReg, XSpiPs_RecvByte, XSpiPs_SendByte, XSPIPS_SR_OFFSET, and XSpiPs_WriteReg.
Referenced by SpiPsEepromIntrExample(), and SpiPsFlashIntrExample().
| XSpiPs_Config* XSpiPs_LookupConfig | ( | UINTPTR | BaseAddress | ) |
Looks up the device configuration based on the unique device ID/BaseAddress.
The XSpiPs_ConfigTable[] contains the configuration info for each device in the system.
| [in] | BaseAddress | The base address of the device. |
References XSpiPs_Config::Name.
Referenced by SpiPsEepromIntrExample(), SpiPsEepromPolledExample(), SpiPsFlashIntrExample(), SpiPsFlashPolledExample(), SpiPsSelfTestExample(), SpiPsSlavePolledExample(), and SpiPsTpmPolledExample().
| s32 XSpiPs_PolledTransfer | ( | XSpiPs * | InstancePtr, |
| u8 * | SendBufPtr, | ||
| u8 * | RecvBufPtr, | ||
| u32 | 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.| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | SendBufPtr | Pointer to a buffer of data for sending. This buffer must not be NULL. |
| [out] | RecvBufPtr | Pointer to a buffer for received data. This argument can be NULL if do not care about receiving. |
| [in] | ByteCount | The number of bytes to send/receive. The number of bytes received always equals the number of bytes sent. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::FifoDepth, XSpiPs::FifoWidth, XSpiPs::IsBusy, XSpiPs::IsReady, XSpiPs::RecvBufferPtr, XSpiPs::RemainingBytes, XSpiPs::RequestedBytes, XSpiPs::SendBufferPtr, XSpiPs::SlaveSelect, XSpiPs_Abort(), XSPIPS_CR_MANSTRT_MASK, XSPIPS_CR_OFFSET, XSPIPS_CR_SSCTRL_MASK, XSpiPs_Disable, XSpiPs_Enable, XSpiPs_IsManualChipSelect, XSpiPs_IsManualStart, XSpiPs_IsMaster, XSPIPS_IXR_MODF_MASK, XSPIPS_IXR_TXOW_MASK, XSPIPS_POLL_TIMEOUT_US, XSpiPs_ReadReg, XSpiPs_RecvByte, XSpiPs_SendByte, XSPIPS_SR_OFFSET, and XSpiPs_WriteReg.
Referenced by SpiPsSlavePolledExample(), and SpiPsTpmTransfer().
| 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.
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsReady, XSpiPs_Abort(), XSPIPS_CR_OFFSET, XSPIPS_CR_RESET_STATE, XSPIPS_CR_SSCTRL_MASK, and XSpiPs_WriteReg.
Referenced by XSpiPs_CfgInitialize(), and XSpiPs_SelfTest().
| void XSpiPs_ResetHw | ( | u32 | BaseAddress | ) |
Resets the SPI module.
| [in] | BaseAddress | The base address of the device. |
References XSPIPS_CR_OFFSET, XSPIPS_CR_RESET_STATE, XSPIPS_CR_SSCTRL_MASK, XSPIPS_ER_OFFSET, XSPIPS_FIFO_DEPTH, XSPIPS_IDR_OFFSET, XSPIPS_IXR_DISABLE_ALL_MASK, XSPIPS_IXR_RXNEMPTY_MASK, XSPIPS_IXR_WR_TO_CLR_MASK, XSPIPS_MAX_FIFO_DEPTH, XSpiPs_ReadReg, XSPIPS_RXD_OFFSET, XSPIPS_RXWR_MASK, XSPIPS_RXWR_OFFSET, XSPIPS_RXWR_RESET_VALUE, XSPIPS_SR_OFFSET, XSPIPS_TXWR_MASK, XSPIPS_TXWR_OFFSET, XSPIPS_TXWR_RESET_VALUE, and XSpiPs_WriteReg.
| s32 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.
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsReady, XSPIPS_CR_OFFSET, XSPIPS_CR_RESET_STATE, XSPIPS_CR_SSCTRL_MASK, XSpiPs_GetDelays(), XSPIPS_ISR_RESET_STATE, XSpiPs_ReadReg, XSpiPs_Reset(), XSpiPs_SetDelays(), and XSPIPS_SR_OFFSET.
Referenced by SpiPsEepromIntrExample(), SpiPsEepromPolledExample(), SpiPsFlashIntrExample(), SpiPsFlashPolledExample(), SpiPsSelfTestExample(), and SpiPsTpmPolledExample().
| s32 XSpiPs_SetClkPrescaler | ( | const XSpiPs * | InstancePtr, |
| u8 | Prescaler | ||
| ) |
Sets the clock prescaler for an SPI device.
The device must be idle rather than busy transferring data before setting these device options.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | Prescaler | 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. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsBusy, XSpiPs::IsReady, XSPIPS_CR_OFFSET, XSPIPS_CR_PRESC_MASK, XSPIPS_CR_PRESC_MAXIMUM, XSPIPS_CR_PRESC_SHIFT, XSpiPs_ReadReg, and XSpiPs_WriteReg.
Referenced by SpiPsEepromIntrExample(), SpiPsEepromPolledExample(), SpiPsFlashIntrExample(), SpiPsFlashPolledExample(), and SpiPsTpmPolledExample().
| s32 XSpiPs_SetDelays | ( | const XSpiPs * | InstancePtr, |
| u8 | DelayNss, | ||
| u8 | DelayBtwn, | ||
| u8 | DelayAfter, | ||
| u8 | DelayInit | ||
| ) |
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.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | DelayNss | The delay for which the chip select outputs are de-asserted between words when CPHA=0. |
| [in] | DelayBtwn | 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. |
| [in] | 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 |
| [in] | DelayInit | The delay between asserting the slave select signal and the first bit transfer. The delay int number of master clock periods is DelayInit+1. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsBusy, XSpiPs::IsReady, XSPIPS_DR_AFTER_SHIFT, XSPIPS_DR_BTWN_SHIFT, XSPIPS_DR_NSS_SHIFT, XSPIPS_DR_OFFSET, and XSpiPs_WriteReg.
Referenced by XSpiPs_SelfTest().
| s32 XSpiPs_SetOptions | ( | const XSpiPs * | InstancePtr, |
| u32 | Options | ||
| ) |
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.
| [in] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | Options | 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. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsBusy, XSpiPs::IsReady, XSPIPS_CR_CPHA_MASK, XSPIPS_CR_CPOL_MASK, XSPIPS_CR_OFFSET, XSpiPs_Disable, XSpiPs_Enable, XSPIPS_NUM_OPTIONS, XSpiPs_ReadReg, and XSpiPs_WriteReg.
Referenced by SpiPsEepromIntrExample(), SpiPsEepromPolledExample(), SpiPsFlashIntrExample(), SpiPsFlashPolledExample(), and SpiPsTpmPolledExample().
| s32 XSpiPs_SetSlaveSelect | ( | XSpiPs * | InstancePtr, |
| u8 | SlaveSel | ||
| ) |
Selects or deselects 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 are output with a single signal low. If CR_SSDECEN is 1, the SPI_ss_outN bits 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.
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | SlaveSel | 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 up to 8 slaves can be selected. Only one slave can be selected at a time. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::IsBusy, XSpiPs::IsReady, XSpiPs::SlaveSelect, XSPIPS_CR_OFFSET, XSPIPS_CR_SSCTRL_MASK, XSPIPS_CR_SSCTRL_MAXIMUM, XSPIPS_CR_SSCTRL_SHIFT, XSpiPs_IsDecodeSSelect, XSpiPs_IsManualChipSelect, XSpiPs_ReadReg, and XSpiPs_WriteReg.
Referenced by SpiPsEepromIntrExample(), SpiPsEepromPolledExample(), SpiPsFlashIntrExample(), SpiPsFlashPolledExample(), and SpiPsTpmPolledExample().
| void XSpiPs_SetStatusHandler | ( | XSpiPs * | InstancePtr, |
| void * | CallBackRef, | ||
| XSpiPs_StatusHandler | FunctionPtr | ||
| ) |
Sets the status callback function for the driver.
The status handler is called by the driver 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).
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | CallBackRef | The upper layer callback reference passed back when the callback function is invoked. |
| [in] | FunctionPtr | Pointer to the callback function. |
References XSpiPs::IsReady, XSpiPs::StatusHandler, and XSpiPs::StatusRef.
Referenced by SpiPsEepromIntrExample(), and SpiPsFlashIntrExample().
| s32 XSpiPs_Transfer | ( | XSpiPs * | InstancePtr, |
| u8 * | SendBufPtr, | ||
| u8 * | RecvBufPtr, | ||
| u32 | 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. The function performs 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.
The function is non-blocking. As a master, the SetSlaveSelect function must be called prior to this function.
| [in,out] | InstancePtr | Pointer to the XSpiPs instance. |
| [in] | SendBufPtr | Pointer to a buffer of data for sending. This buffer must not be NULL. |
| [out] | RecvBufPtr | Pointer to a buffer for received data. This argument can be NULL if do not care about receiving. |
| [in] | ByteCount | The number of bytes to send/receive. The number of bytes received always equals the number of bytes sent. |
References XSpiPs_Config::BaseAddress, XSpiPs::Config, XSpiPs::FifoDepth, XSpiPs::FifoWidth, XSpiPs::IsBusy, XSpiPs::IsReady, XSpiPs::RecvBufferPtr, XSpiPs::RemainingBytes, XSpiPs::RequestedBytes, XSpiPs::SendBufferPtr, XSpiPs::SlaveSelect, XSPIPS_CR_MANSTRT_MASK, XSPIPS_CR_OFFSET, XSPIPS_CR_SSCTRL_MASK, XSpiPs_Enable, XSPIPS_IER_OFFSET, XSpiPs_IsManualChipSelect, XSpiPs_IsManualStart, XSpiPs_IsMaster, XSPIPS_IXR_DFLT_MASK, XSpiPs_ReadReg, XSpiPs_SendByte, XSPIPS_SR_OFFSET, and XSpiPs_WriteReg.
Referenced by EepromRead(), and EepromWrite().
| XSpiPs_Config XSpiPs_ConfigTable[] |
Holds the configuration information for each SPI device in the system.
| XSpiPs_Config XSpiPs_ConfigTable[XPAR_XSPIPS_NUM_INSTANCES] |
Holds the configuration information for each SPI device in the system.