nRF51 SDK - S210 SoftDevice
|
SPI master driver. More...
Data Structures | |
struct | spi_master_config_t |
A structure containing configuration parameters of the SPI master driver. More... | |
struct | spi_master_evt_t |
Struct containing parameters of the SPI MASTER event. More... | |
Macros | |
#define | SPI_PIN_DISCONNECTED 0xFFFFFFFF |
#define | SPI_DEFAULT_TX_BYTE 0x00 |
#define | SPI_MASTER_INIT_DEFAULT |
Macro for initializing SPI master by default values. More... | |
Typedefs | |
typedef enum spi_master_evt_type_t | spi_master_evt_type_t |
SPI master driver events types. | |
typedef void(* | spi_master_event_handler_t )(spi_master_evt_t spi_master_evt) |
Type of generic callback function handler to be used by all SPI MASTER driver events. More... | |
Enumerations | |
enum | spi_master_evt_type_t { SPI_MASTER_EVT_TRANSFER_STARTED = 0, SPI_MASTER_EVT_TRANSFER_COMPLETED, SPI_MASTER_EVT_TYPE_MAX } |
SPI master driver events types. More... | |
enum | spi_master_state_t { SPI_MASTER_STATE_DISABLED, SPI_MASTER_STATE_BUSY, SPI_MASTER_STATE_IDLE } |
Types of the SPI master internal states. More... | |
enum | spi_master_hw_instance_t { SPI_MASTER_0, SPI_MASTER_1, SPI_MASTER_HW_ENABLED_COUNT } |
Enum containing instances of the SPI master driver. More... | |
Functions | |
uint32_t | spi_master_open (const spi_master_hw_instance_t spi_master_hw_instance, spi_master_config_t const *const p_spi_master_config) |
Function for opening and initializing a SPI master driver. More... | |
void | spi_master_close (const spi_master_hw_instance_t spi_master_hw_instance) |
Function for closing a SPI MASTER driver. More... | |
uint32_t | spi_master_send_recv (const spi_master_hw_instance_t spi_master_hw_instance, uint8_t *const p_tx_buf, const uint16_t tx_buf_len, uint8_t *const p_rx_buf, const uint16_t rx_buf_len) |
Function for transferring data between SPI master and SPI slave. More... | |
void | spi_master_evt_handler_reg (const spi_master_hw_instance_t spi_master_hw_instance, spi_master_event_handler_t event_handler) |
Function for registration event handler. More... | |
spi_master_state_t | spi_master_get_state (const spi_master_hw_instance_t spi_master_hw_instance) |
Function for getting current state of the SPI master driver. More... | |
SPI master driver.
This file contains declarations of functions and typedefs used as API of the SPI master driver.
#define SPI_DEFAULT_TX_BYTE 0x00 |
Default byte (used to clock transmission from slave to the master)
#define SPI_MASTER_INIT_DEFAULT |
Macro for initializing SPI master by default values.
#define SPI_PIN_DISCONNECTED 0xFFFFFFFF |
A value used to the PIN deinitialization.
typedef void(* spi_master_event_handler_t)(spi_master_evt_t spi_master_evt) |
Type of generic callback function handler to be used by all SPI MASTER driver events.
[in] | spi_master_evt | SPI MASTER driver event. |
enum spi_master_state_t |
void spi_master_close | ( | const spi_master_hw_instance_t | spi_master_hw_instance | ) |
Function for closing a SPI MASTER driver.
[in] | spi_master_hw_instance | A instance of SPI master. |
void spi_master_evt_handler_reg | ( | const spi_master_hw_instance_t | spi_master_hw_instance, |
spi_master_event_handler_t | event_handler | ||
) |
Function for registration event handler.
[in] | spi_master_hw_instance | Instance of SPI master module. |
[in] | event_handler | Generic callback function handler to be used by all SPI master driver events. |
spi_master_state_t spi_master_get_state | ( | const spi_master_hw_instance_t | spi_master_hw_instance | ) |
Function for getting current state of the SPI master driver.
[in] | spi_master_hw_instance | Instance of SPI master module. |
SPI_MASTER_STATE_DISABLED | SPI MASTER is disabled. |
SPI_MASTER_STATE_BUSY | SPI_MASTER is sending now. |
SPI_MASTER_STATE_IDLE | SPI_MASTER is idle now. |
uint32_t spi_master_open | ( | const spi_master_hw_instance_t | spi_master_hw_instance, |
spi_master_config_t const *const | p_spi_master_config | ||
) |
Function for opening and initializing a SPI master driver.
[in] | spi_master_hw_instance | Instance of SPI master module. |
[in] | p_spi_master_config | Pointer to configuration structure which will be used to initialize SPI MASTER hardware. |
NRF_SUCCESS | Operation success. |
NRF_ERROR_INVALID_STATE | Operation failure. The function has been already called. To call it again the function spi_master_close has to be called previously. |
NRF_ERROR_NULL | Operation failure. NULL pointer supplied. |
uint32_t spi_master_send_recv | ( | const spi_master_hw_instance_t | spi_master_hw_instance, |
uint8_t *const | p_tx_buf, | ||
const uint16_t | tx_buf_len, | ||
uint8_t *const | p_rx_buf, | ||
const uint16_t | rx_buf_len | ||
) |
Function for transferring data between SPI master and SPI slave.
[in] | spi_master_hw_instance | Instance of SPI master module. |
[in] | p_tx_buf | Pointer to a transmit buffer. |
[in] | tx_buf_len | Number of octets to the transfer. |
[out] | p_rx_buf | Pointer to a receive buffer. |
[in] | rx_buf_len | Number of octets to be received. |
NRF_SUCCESS | Operation success. Packet was registered to the transmission and event will be send upon transmission completion. |
NRF_ERROR_BUSY | Operation failure. Transmitting of a data is in progress. |