|
| void | ltrx_spi_close (uint16_t zeroBasedSPI) |
| | Relinquish a Serial Peripheral Interface previously opened.
|
| |
| bool | ltrx_spi_open (uint16_t zeroBasedSPI, uint32_t blockTimeMsec) |
| | Open a Serial Peripheral Interface for exclusive use.
|
| |
| void | ltrx_spi_register_protocol (const struct ltrx_spi_protocol *lsp) |
| | Register a SPI protocol.
|
| |
| bool | ltrx_spi_transfer (uint16_t zeroBasedSPI, const struct ltrx_spi_descriptor *descriptor) |
| | Transfer data.
|
| |
| wiced_result_t | wiced_spi_deinit (const wiced_spi_device_t *spi) |
| |
| wiced_result_t | wiced_spi_init (const wiced_spi_device_t *spi) |
| |
| wiced_result_t | wiced_spi_slave_deinit (wiced_spi_t spi) |
| |
| wiced_result_t | wiced_spi_slave_generate_interrupt (wiced_spi_t spi, uint32_t pulse_duration_ms) |
| |
| wiced_result_t | wiced_spi_slave_init (wiced_spi_t spi, const wiced_spi_slave_config_t *config) |
| |
| wiced_result_t | wiced_spi_slave_receive_command (wiced_spi_t spi, wiced_spi_slave_command_t *command, uint32_t timeout_ms) |
| |
| wiced_result_t | wiced_spi_slave_send_error_status (wiced_spi_t spi, wiced_spi_slave_transfer_status_t error_status) |
| |
| wiced_result_t | wiced_spi_slave_transfer_data (wiced_spi_t spi, wiced_spi_slave_transfer_direction_t direction, wiced_spi_slave_data_buffer_t *buffer, uint32_t timeout_ms) |
| |
| wiced_result_t | wiced_spi_transfer (const wiced_spi_device_t *spi, const wiced_spi_message_segment_t *segments, uint16_t number_of_segments) |
| |
| wiced_result_t | wiced_spi_transmit (const wiced_spi_device_t *spi, const wiced_spi_message_segment_t *segments, uint16_t number_of_segments) |
| |
The Serial Peripheral Interface (SPI) refers to a clocked serial interface. These definitions relate to operation of the interface.
Serial Peripheral Interface (SPI) Functions
For SPI specification and configuration for the underlying platform, please refer to <WICED_SDK>/platforms/<platform_name>/platform.c and <WICED_SDK>/platforms/<platform_name>/platform.h
Example usage: (Check for return values in actual implementation)
// <WICED_SDK>/platforms/<platform_name>/platform.h
// wiced_spi_device_t defines a SPI slave device connected to the MCU
wiced_spi_init( &wiced_spi_device );
// Define SPI message segment
// wiced_spi_message_segment_t spi_segment[NUM_SPI_MSG_SEGMENTS];
// spi_message_segment structure consists of
// {
// const void* tx_buffer;
// void* rx_buffer;
// uint32_t length; //Length of data to be sent
// }
// Initialize all the spi_message segments
spi_segment[0].tx_buffer = tx_buffer;
spi_segment[0].rx_buffer = rx_buffer;
spi_segment[0].length = message_length; //Length of data in tx_buffer
//Continue to add spi_segment[1], spi_segment[2] ...
// Transfer the segments
wiced_spi_transfer( &wiced_spi_device, spi_segment, number_of_segments);
// if wiced_spi_transfer returns WICED_SUCCESS, rx_buffer(If non-NULL) should be populated
WICED SPI Functions can be divided into SPI Master Functions For platforms where MCU is used as SPI master
wiced_spi_init() wiced_spi_transmit() wiced_spi_transfer() wiced_spi_deinit()
SPI Slave Functions For platforms where MCU can be used as SPI Slave Please refer to <WICED_SDK>/apps/snip/spi_slave For example usage
wiced_spi_slave_init() wiced_spi_slave_deinit() wiced_spi_slave_receive_command() wiced_spi_slave_transfer_data() wiced_spi_slave_send_error_status() wiced_spi_slave_generate_interrupt()
◆ ltrx_spi_close()
| void ltrx_spi_close |
( |
uint16_t | zeroBasedSPI | ) |
|
Relinquish a Serial Peripheral Interface previously opened.
Previously you would have called ltrx_spi_open() and saw it return true. This will allow other threads to open the SPI.
- Parameters
-
| [in] | zeroBasedSPI | 0 for SPI 1, 1 for SPI 2, and so on. |
◆ ltrx_spi_open()
| bool ltrx_spi_open |
( |
uint16_t | zeroBasedSPI, |
|
|
uint32_t | blockTimeMsec ) |
Open a Serial Peripheral Interface for exclusive use.
Warning: Check the return value even if you specify TIME_WAIT_FOREVER because your thread can return early if another thread calls ltrx_thread_wake().
- Return values
-
| true | Success. |
| false | Failed. |
- Parameters
-
| [in] | zeroBasedSPI | 0 for SPI 1, 1 for SPI 2, and so on. |
| [in] | blockTimeMsec | How long to wait if line is in use. To wait indefinitely, use TIME_WAIT_FOREVER. |
◆ ltrx_spi_register_protocol()
Register a SPI protocol.
Registers procedures into the system for supporting another protocol on Serial Peripheral Interfaces.
Registration must be done in early module initialization.
- Parameters
-
| [in] | lsp | Designates the procedures to start and stop this protocol. |
◆ ltrx_spi_transfer()
| bool ltrx_spi_transfer |
( |
uint16_t | zeroBasedSPI, |
|
|
const struct ltrx_spi_descriptor * | descriptor ) |
Transfer data.
- Return values
-
| true | Success. |
| false | Failure. |
- Parameters
-
| [in] | zeroBasedSPI | 0 for SPI 1, 1 for SPI 2, and so on. |
| [in] | descriptor | Provides input and output buffer information. |
◆ wiced_spi_deinit()
De-initializes a SPI interface
Turns off a SPI hardware interface
- Parameters
-
| [in] | spi | : The SPI device to be de-initialized |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if an error occurred
◆ wiced_spi_init()
initializes the SPI interface for a given SPI device
Prepares a SPI hardware interface for communication as a master
- Parameters
-
| [in] | spi | : The SPI device to be initialized |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if the SPI device could not be initialized
◆ wiced_spi_slave_deinit()
De-initializes a SPI slave interface
- Parameters
-
| [in] | spi | : The SPI slave interface to be de-initialized |
- Returns
- wiced_result_t
◆ wiced_spi_slave_generate_interrupt()
| wiced_result_t wiced_spi_slave_generate_interrupt |
( |
wiced_spi_t | spi, |
|
|
uint32_t | pulse_duration_ms ) |
Generate an interrupt on the SPI slave interface
- Parameters
-
| [in] | spi | : The SPI slave interface |
| [in] | pulse_duration_ms | : Interrupt pulse duration in milliseconds |
- Returns
- wiced_result_t
◆ wiced_spi_slave_init()
initializes a SPI slave interface
- Parameters
-
| [in] | spi | : The SPI slave interface to be initialized |
| [in] | config | : SPI slave configuration |
- Returns
- wiced_result_t
◆ wiced_spi_slave_receive_command()
Receive command from the remote SPI master
- Parameters
-
| [in] | spi | : The SPI slave interface |
| [out] | command | : Pointer to the variable which will contained the received command |
| [in] | timeout_ms | : Timeout in milliseconds |
- Returns
- wiced_result_t
◆ wiced_spi_slave_send_error_status()
Send an error status over the SPI slave interface
- Parameters
-
| [in] | spi | : The SPI slave interface |
| [in] | error_status | : SPI slave error status |
- Returns
- wiced_result_t
◆ wiced_spi_slave_transfer_data()
Transfer data to/from the remote SPI master
- Parameters
-
| [in] | spi | : The SPI slave interface |
| [in] | direction | : Transfer direction |
| [in] | buffer | : The buffer which contain the data to transfer |
| [in] | timeout_ms | : timeout in milliseconds |
- Returns
- wiced_result_t
◆ wiced_spi_transfer()
Transmits and/or receives data from a SPI device
- Parameters
-
| [in] | spi | : The SPI device to be initialized |
| [in] | segments | : A pointer to an array of segments |
| [in] | number_of_segments | : The number of segments to transfer |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if an error occurred
◆ wiced_spi_transmit()
Transmits data to a SPI device
- Parameters
-
| [in] | spi | : The SPI device to be initialized |
| [in] | segments | : A pointer to an array of segments |
| [in] | number_of_segments | : The number of segments to transfer |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if an error occurred