Module for scheduling SPI transactions.
More...
|
#define | NRF_SPI_MNGR_TRANSFER(_p_tx_data, _tx_length, _p_rx_data, _rx_length) |
| Macro for creating a simple SPI transfer. More...
|
|
#define | NRF_SPI_MNGR_DEF(_nrf_spi_mngr_name, _queue_size, _spi_idx) |
| Macro for simplifying the defining of an SPI transaction manager instance. More...
|
|
Module for scheduling SPI transactions.
#define NRF_SPI_MNGR_DEF |
( |
|
_nrf_spi_mngr_name, |
|
|
|
_queue_size, |
|
|
|
_spi_idx |
|
) |
| |
Value:
_nrf_spi_mngr_name##_queue, \
(_queue_size), \
{ \
.p_queue = &_nrf_spi_mngr_name##_queue, \
}
Macro for simplifying the defining of an SPI transaction manager instance.
This macro allocates a static buffer for the transaction queue. Therefore, it should be used in only one place in the code for a given instance.
- Note
- The queue size is the maximum number of pending transactions not counting the one that is currently realized. This means that for an empty queue with size of for example 4 elements, it is possible to schedule up to 5 transactions.
- Parameters
-
[in] | _nrf_spi_mngr_name | Name of instance to be created. |
[in] | _queue_size | Size of the transaction queue (maximum number of pending transactions). |
[in] | _spi_idx | Index of hardware SPI instance to be used. |
#define NRF_SPI_MNGR_TRANSFER |
( |
|
_p_tx_data, |
|
|
|
_tx_length, |
|
|
|
_p_rx_data, |
|
|
|
_rx_length |
|
) |
| |
Value:{ \
.p_tx_data = (uint8_t const *)_p_tx_data, \
.tx_length = (uint8_t) _tx_length, \
.p_rx_data = (uint8_t *) _p_rx_data, \
.rx_length = (uint8_t) _rx_length, \
}
Macro for creating a simple SPI transfer.
- Parameters
-
[in] | _p_tx_data | Pointer to the data to be sent. |
[in] | _tx_length | Number of bytes to send. |
[in] | _p_rx_data | Pointer to a buffer for received data. |
[in] | _rx_length | Number of bytes to receive. |
typedef void(* nrf_spi_mngr_callback_begin_t)(void *p_user_data) |
SPI transaction begin callback prototype.
- Parameters
-
[in] | p_user_data | Pointer to user data defined in transaction descriptor. |
typedef void(* nrf_spi_mngr_callback_end_t)(ret_code_t result, void *p_user_data) |
SPI transaction end callback prototype.
- Parameters
-
| result | Result of operation (NRF_SUCCESS on success, otherwise a relevant error code). |
[in] | p_user_data | Pointer to user data defined in transaction descriptor. |
Function for initializing an SPI transaction manager instance.
- Parameters
-
[in] | p_nrf_spi_mngr | Pointer to the instance to be initialized. |
[in] | p_default_spi_config | Pointer to the SPI driver configuration. This configuration will be used whenever the scheduled transaction will have p_spi_config set to NULL value. |
- Returns
- Values returned by the nrf_drv_spi_init function.
__STATIC_INLINE bool nrf_spi_mngr_is_idle |
( |
nrf_spi_mngr_t const * |
p_nrf_spi_mngr | ) |
|
Function for getting the current state of an SPI transaction manager instance.
- Parameters
-
[in] | p_nrf_spi_mngr | Pointer to the SPI transaction manager instance. |
- Return values
-
true | If all scheduled transactions have been finished. |
false | Otherwise. |
Function for scheduling a transaction and waiting until it is finished.
This function schedules a transaction that consists of one or more transfers and waits until it is finished.
- Parameters
-
[in] | p_nrf_spi_mngr | Pointer to the SPI transaction manager instance. |
[in] | p_config | Required SPI configuration. |
[in] | p_transfers | Pointer to an array of transfers to be performed. |
| number_of_transfers | Number of transfers to be performed. |
| user_function | User-specified function to be called while waiting. NULL if such functionality is not needed. |
- Return values
-
NRF_SUCCESS | If the transfers have been successfully realized. |
NRF_ERROR_BUSY | If some transfers are already being performed. |
- | Other error codes mean that the transaction has failed with the error reported by nrf_drv_spi_transfer(). |
Function for uninitializing an SPI transaction manager instance.
- Parameters
-
[in] | p_nrf_spi_mngr | Pointer to the instance to be uninitialized. |