nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Software controlled SPI Slave driver.

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]eventSPI slave driver event.

Enumeration Type Documentation

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).

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_bufPointer to the TX buffer.
[in]p_rx_bufPointer to the RX buffer.
[in]tx_buf_lengthLength of the TX buffer in bytes.
[in]rx_buf_lengthLength of the RX buffer in bytes.
Return values
NRF_SUCCESSOperation success.
NRF_ERROR_NULLOperation failure. NULL pointer supplied.
NRF_ERROR_INVALID_STATEOperation failure. SPI slave device in incorrect state.
NRF_ERROR_INTERNALOperation 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_handlerThe function to be called by the SPI slave driver upon event.
Return values
NRF_SUCCESSOperation success.
NRF_ERROR_NULLOperation 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_configSPI peripheral device configuration data.
Return values
NRF_SUCCESSOperation success.
NRF_ERROR_NULLOperation failure. NULL pointer supplied.
NRF_ERROR_INVALID_PARAMOperation 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_configPull-up configuration for the CSN pin.
Return values
NRF_SUCCESSOperation 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_configDrive configuration for the MISO pin.
Return values
NRF_SUCCESSOperation success.