Software controlled SPI Slave driver.
More...
Software controlled SPI Slave driver.
SPI slave event callback function type.
- Parameters
-
[in] | event | SPI slave driver event. |
SPI transaction bit order definitions.
Enumerator |
---|
SPIM_LSB_FIRST |
Least significant bit shifted out first.
|
SPIM_MSB_FIRST |
Most significant bit shifted out first.
|
Event callback function event definitions.
Enumerator |
---|
SPI_SLAVE_BUFFERS_SET_DONE |
Memory buffer set event. Memory buffers have been set successfully to the SPI slave device and SPI transactions can be done.
|
SPI_SLAVE_XFER_DONE |
SPI transaction event. SPI transaction has been completed.
|
SPI_SLAVE_EVT_TYPE_MAX |
Enumeration upper bound.
|
SPI mode definitions for clock polarity and phase.
Enumerator |
---|
SPI_MODE_0 |
(CPOL = 0, CPHA = 0).
|
SPI_MODE_1 |
(CPOL = 0, CPHA = 1).
|
SPI_MODE_2 |
(CPOL = 1, CPHA = 0).
|
SPI_MODE_3 |
(CPOL = 1, CPHA = 1).
|
uint32_t spi_slave_buffers_set |
( |
uint8_t * |
p_tx_buf, |
|
|
uint8_t * |
p_rx_buf, |
|
|
uint8_t |
tx_buf_length, |
|
|
uint8_t |
rx_buf_length |
|
) |
| |
Function for preparing the SPI slave device ready for a single SPI transaction.
Function prepares the SPI slave device to be ready for a single SPI transaction. It configures the SPI slave device to use the memory, supplied with the function call, in SPI transactions.
The spi_slave_event_handler_t will be called with appropriate event spi_slave_evt_type_t when either the memory buffer configuration or SPI transaction has been completed.
- Note
- The callback function spi_slave_event_handler_t can be called before returning from this function, since it is called from the SPI slave interrupt context.
-
This function can be called from the callback function spi_slave_event_handler_t context.
-
Client application must call this function after every SPI_SLAVE_XFER_DONE event if it wants the SPI slave driver to be ready for possible new SPI transaction.
- Parameters
-
[in] | p_tx_buf | Pointer to the TX buffer. |
[in] | p_rx_buf | Pointer to the RX buffer. |
[in] | tx_buf_length | Length of the TX buffer in bytes. |
[in] | rx_buf_length | Length of the RX buffer in bytes. |
- Return values
-
NRF_SUCCESS | Operation success. |
NRF_ERROR_NULL | Operation failure. NULL pointer supplied. |
NRF_ERROR_INVALID_STATE | Operation failure. SPI slave device in incorrect state. |
NRF_ERROR_INTERNAL | Operation failure. Internal error ocurred. |
Function for registering a handler for SPI slave driver event.
- Note
- Multiple registration requests will overwrite any possible existing registration.
- Parameters
-
[in] | event_handler | The function to be called by the SPI slave driver upon event. |
- Return values
-
NRF_SUCCESS | Operation success. |
NRF_ERROR_NULL | Operation success. NULL handler registered. |
Function for initializing the SPI slave device.
- Parameters
-
[in] | p_spi_slave_config | SPI peripheral device configuration data. |
- Return values
-
NRF_SUCCESS | Operation success. |
NRF_ERROR_NULL | Operation failure. NULL pointer supplied. |
NRF_ERROR_INVALID_PARAM | Operation failure. Invalid parameter supplied. |