Software controlled SPI Slave driver. More...
Data Structures |
|
| struct | spi_slave_config_t |
|
SPI peripheral device configuration data.
More...
|
|
| struct | spi_slave_evt_t |
|
Struct containing event context from the SPI slave driver.
More...
|
|
Typedefs |
|
| typedef void(* | spi_slave_event_handler_t )( spi_slave_evt_t event) |
|
SPI slave event callback function type.
More...
|
|
Enumerations |
|
| enum |
spi_slave_endian_t
{
SPIM_LSB_FIRST , SPIM_MSB_FIRST } |
|
SPI transaction bit order definitions.
More...
|
|
| enum |
spi_slave_mode_t
{
SPI_MODE_0 , SPI_MODE_1 , SPI_MODE_2 , SPI_MODE_3 } |
|
SPI mode definitions for clock polarity and phase.
More...
|
|
| enum |
spi_slave_evt_type_t
{
SPI_SLAVE_BUFFERS_SET_DONE , SPI_SLAVE_XFER_DONE , SPI_SLAVE_EVT_TYPE_MAX } |
|
Event callback function event definitions.
More...
|
|
Functions |
|
| uint32_t | spi_slave_evt_handler_register ( spi_slave_event_handler_t event_handler) |
|
Function for registering a handler for SPI slave driver event.
More...
|
|
| uint32_t | spi_slave_init (const spi_slave_config_t *p_spi_slave_config) |
|
Function for initializing the SPI slave device.
More...
|
|
| 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.
More...
|
|
| uint32_t | spi_slave_set_cs_pull_up_config (uint32_t alternate_config) |
|
Function for changing defult pull-up configuration for CSN pin.
More...
|
|
| uint32_t | spi_slave_set_drive_config (uint32_t alternate_config) |
|
Function for changing defult drive for MISO pin.
More...
|
|
Detailed Description
Software controlled SPI Slave driver.
Typedef Documentation
| typedef void(* spi_slave_event_handler_t)( spi_slave_evt_t event) |
SPI slave event callback function type.
- Parameters
-
[in] event SPI slave driver event.
Enumeration Type Documentation
| enum spi_slave_endian_t |
| enum spi_slave_evt_type_t |
Event callback function event definitions.
| enum spi_slave_mode_t |
Function Documentation
| 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.
| uint32_t spi_slave_evt_handler_register | ( | spi_slave_event_handler_t | event_handler | ) |
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.
| uint32_t spi_slave_init | ( | const spi_slave_config_t * | p_spi_slave_config | ) |
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.
| uint32_t spi_slave_set_cs_pull_up_config | ( | uint32_t | alternate_config | ) |
Function for changing defult pull-up configuration for CSN pin.
In the default configuration, pull-up on the CSN pin is disabled. If alternate configuration is required this function can be called before spi_slave_init() to change default settings for CSN pin.
- Parameters
-
[in] alternate_config Pull-up configuration for the CSN pin.
- Return values
-
NRF_SUCCESS Operation success.
| uint32_t spi_slave_set_drive_config | ( | uint32_t | alternate_config | ) |
Function for changing defult drive for MISO pin.
In the default configuration, pin drive for the MISO pin is set to S0S1. If alternate configuration is required this function can be called before spi_slave_init() to change default settings for MISO pin.
- Parameters
-
[in] alternate_config Drive configuration for the MISO pin.
- Return values
-
NRF_SUCCESS Operation success.