Defines an SPI driver to facilitate communication with other devices on an SPI bus (such as a temperature sensor, etc).
More...
|
void | wiced_hal_pspi_init (spi_interface_t spi, UINT8 devRole, UINT16 spiPinPullConfig, UINT32 spiGpioCfg, UINT32 clkSpeed, SPI_ENDIAN endian, SPI_SS_POLARITY polarity, SPI_MODE mode, UINT8 csPin) |
| Initialize the SPI driver with the given parameters. More...
|
|
void | wiced_hal_pspi_tx_data (spi_interface_t spi, UINT32 txLen, const UINT8 *txBuf) |
| Send/transmit data over SPI as the master. More...
|
|
void | wiced_hal_pspi_rx_data (spi_interface_t spi, UINT32 rxLen, UINT8 *rxBuf) |
| Receive data over SPI as the master. More...
|
|
void | wiced_hal_pspi_reset (spi_interface_t spi) |
| Reset and bring the SPI driver to a known good state with default configuration. More...
|
|
void | wiced_hal_pspi_exchange_data (spi_interface_t spi, UINT32 len, const UINT8 *txBuf, UINT8 *rxBuf) |
| Transmit one buffer of data while simultaneously receiving data (as the master). More...
|
|
void | wiced_hal_pspi_slave_enable_tx (spi_interface_t spi) |
| Enable the tx fifo so any data in it will be transmitted when the SPI master clocks it out. More...
|
|
void | wiced_hal_pspi_slave_disable_tx (spi_interface_t spi) |
| Disable the tx fifo. More...
|
|
void | wiced_hal_pspi_slave_enable_rx (spi_interface_t spi) |
| Enable the rx fifo. More...
|
|
void | wiced_hal_pspi_slave_disable_rx (spi_interface_t spi) |
| Disable the rx fifo. More...
|
|
void | wiced_hal_pspi_slave_tx_data (spi_interface_t spi, UINT32 txLen, const UINT8 *txBuf) |
| Send/transmit data over SPI as a slave. More...
|
|
SPIFFY_STATUS | wiced_hal_pspi_slave_rx_data (spi_interface_t spi, UINT32 rxLen, UINT8 *rxBuf) |
| Receive data over SPI as a slave. More...
|
|
UINT32 | wiced_hal_pspi_slave_get_tx_fifo_count (spi_interface_t spi) |
| Get the number of bytes in the slave tx fifo. More...
|
|
UINT32 | wiced_hal_pspi_slave_get_rx_fifo_count (spi_interface_t spi) |
| Get the number of bytes in the slave rx fifo. More...
|
|
Defines an SPI driver to facilitate communication with other devices on an SPI bus (such as a temperature sensor, etc).
The driver is capable of assuming either a master or a slave role on said bus. Applications use this driver to obtain the status from and control the behavior of the SPI hardware. This driver only offers services for clock control, mode control and data transfer operations. The application is responsible for generating the slave/chip select signals (if it's in a master role). This could be done by mapping a GPIO pin for each slave the application wants to control (See wiced_hal_gpio.h for more information on driving a GPIO pin).
All master data transfer operations (half/full duplex) provided by this driver assume that the desired slave has already been selected and will remain selected throughout the duration of the transaction.
Please note that this driver cannot access supplied off-chip memory (if installed; serial flash, etc). Please use the drivers found in wiced_hal_sflash.h or wiced_hal_seeprom.h to access those modules, as those drivers deal with a separate SPI bus and include checks to ensure safe data handling operations. This driver is intended only to interface with other devices on the peripheral SPI bus, such as a motion sensor. Of course, this restriction does not preclude the user from adding their own memory module to the peripheral bus, and using this driver with it.
void wiced_hal_pspi_exchange_data |
( |
spi_interface_t |
spi, |
|
|
UINT32 |
len, |
|
|
const UINT8 * |
txBuf, |
|
|
UINT8 * |
rxBuf |
|
) |
| |
Transmit one buffer of data while simultaneously receiving data (as the master).
Assumes that the slave/chip select line will be active throughout this transaction.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
len | - The number of bytes to transmit and receive. |
txBuf | - Pointer to the data buffer to transmit. |
rxBuf | - Pointer to the buffer where the read data will be stored. |
- Returns
- none
Initialize the SPI driver with the given parameters.
Please reference the various parameters above.
In this function, the hardware block will be reset. The driver will be configured before the first transaction with a device.
For the chip select (CS) line, define the Port/Pin you want to use. There could be up to 40 GPIO pins on a board so the numbering is P0 - P39.
Remember that P# is the physical pin number on the board minus 1. Ex: Board Pin 4 = P3.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
devRole | - SPI HW to play either master (1) or slave (2). |
spiPinPullConfig | - Pin pull-up or pull-down. |
spiGpioCfg | - Pins to use for the data and clk lines (see User Documentation for specific values which vary by platform). |
clkSpeed | - Clock speed (non-zero for master, zero for slave). |
endian | - Direction of bit data flow (MSB or LSB first). |
polarity | - Active high or active low for chip select line. |
mode,- | SPI mode (0-3). |
csPin | - GPIO pin of chip select line (see above). |
- Returns
- none
- Parameters
-
clkSpeed | - Clock speed (in Hz) (non-zero for master, zero for slave). |
Reset and bring the SPI driver to a known good state with default configuration.
Note that the hardware block will be reset.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- none
void wiced_hal_pspi_rx_data |
( |
spi_interface_t |
spi, |
|
|
UINT32 |
rxLen, |
|
|
UINT8 * |
rxBuf |
|
) |
| |
Receive data over SPI as the master.
Assumes that the slave/chip select line will be active throughout the transaction.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
txLen | - Length of the data buffer to receive. |
txBuf | - Pointer to the data buffer which will receive data. |
- Returns
- none
Disable the rx fifo.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- none
Disable the tx fifo.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- none
Enable the rx fifo.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- none
Enable the tx fifo so any data in it will be transmitted when the SPI master clocks it out.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- none
Get the number of bytes in the slave rx fifo.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- Number of bytes in the rx fifo.
Get the number of bytes in the slave tx fifo.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
- Returns
- Number of bytes in the tx fifo.
Receive data over SPI as a slave.
If the rx fifo is enabled, pull data from the rx fifo if there are at least rxLen bytes in the rx fifo.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
txLen | - Length of the data buffer to receive. |
txBuf | - Pointer to the data buffer which will receive data. |
- Returns
- SUCCESS if bytes were received or NOT_ENOUGH_RX_FIFO_BYTES if fail.
void wiced_hal_pspi_slave_tx_data |
( |
spi_interface_t |
spi, |
|
|
UINT32 |
txLen, |
|
|
const UINT8 * |
txBuf |
|
) |
| |
Send/transmit data over SPI as a slave.
If the tx fifo is enabled, the data in the tx fifo will be transmitted when the SPI master clocks it out.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
txLen | - The number of bytes-to-send that this buffer contains. |
txBuf | - Pointer to the data buffer to transmit. |
- Returns
- none
void wiced_hal_pspi_tx_data |
( |
spi_interface_t |
spi, |
|
|
UINT32 |
txLen, |
|
|
const UINT8 * |
txBuf |
|
) |
| |
Send/transmit data over SPI as the master.
Assumes that the slave/chip select line will be active throughout the transaction.
- Parameters
-
spi | - SPI interface.( SPI1 or SPI2 ). |
txLen | - The number of bytes-to-send that this buffer contains. |
txBuf | - Pointer to the data buffer to transmit. |
- Returns
- none