Intel® Quark™ Microcontroller Software Interface
1.4.0
Intel® Quark™ Microcontroller BSP
|
SPI peripheral driver for Sensor Subsystem. More...
Data Structures | |
struct | qm_ss_spi_config_t |
SPI configuration type. More... | |
struct | qm_ss_spi_async_transfer_t |
SPI asynchronous transfer type. More... | |
struct | qm_ss_spi_transfer_t |
SPI synchronous transfer type. More... | |
Functions | |
int | qm_ss_spi_set_config (const qm_ss_spi_t spi, const qm_ss_spi_config_t *const cfg) |
Set SPI configuration. More... | |
int | qm_ss_spi_slave_select (const qm_ss_spi_t spi, const qm_ss_spi_slave_select_t ss) |
Set Slave Select lines. More... | |
int | qm_ss_spi_get_status (const qm_ss_spi_t spi, qm_ss_spi_status_t *const status) |
Get SPI bus status. More... | |
int | qm_ss_spi_transfer (const qm_ss_spi_t spi, const qm_ss_spi_transfer_t *const xfer, qm_ss_spi_status_t *const status) |
Perform a blocking SPI transfer. More... | |
int | qm_ss_spi_irq_transfer (const qm_ss_spi_t spi, const qm_ss_spi_async_transfer_t *const xfer) |
Initiate an interrupt based SPI transfer. More... | |
int | qm_ss_spi_irq_transfer_terminate (const qm_ss_spi_t spi) |
Terminate SPI IRQ transfer. More... | |
int | qm_ss_spi_save_context (const qm_ss_spi_t spi, qm_ss_spi_context_t *const ctx) |
Save SS SPI context. More... | |
int | qm_ss_spi_restore_context (const qm_ss_spi_t spi, const qm_ss_spi_context_t *const ctx) |
Restore SS SPI context. More... | |
SPI peripheral driver for Sensor Subsystem.
enum qm_ss_spi_bmode_t |
SPI Bus Mode Type.
Definition at line 95 of file qm_ss_spi.h.
QM Sensor SPI frame size type.
Definition at line 20 of file qm_ss_spi.h.
SPI Slave select type.
Slave selects can be combined by logical OR.
Enumerator | |
---|---|
QM_SS_SPI_SS_DISABLED |
Slave select disable. |
QM_SS_SPI_SS_0 |
Slave select 0. |
QM_SS_SPI_SS_1 |
Slave select 1. |
QM_SS_SPI_SS_2 |
Slave select 2. |
QM_SS_SPI_SS_3 |
Slave select 3. |
Definition at line 107 of file qm_ss_spi.h.
enum qm_ss_spi_status_t |
SPI status.
Definition at line 118 of file qm_ss_spi.h.
enum qm_ss_spi_tmode_t |
SPI transfer mode type.
Definition at line 57 of file qm_ss_spi.h.
int qm_ss_spi_get_status | ( | const qm_ss_spi_t | spi, |
qm_ss_spi_status_t *const | status | ||
) |
Get SPI bus status.
[in] | spi | SPI module identifier. |
[out] | status | Reference to the variable where to store the current SPI bus status (QM_SS_SPI_BUSY if a transfer is in progress or QM_SS_SPI_IDLE if SPI device is IDLE). This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 111 of file qm_ss_spi.c.
References QM_SS_SPI_BUSY, QM_SS_SPI_IDLE, and QM_SS_SPI_SR.
int qm_ss_spi_irq_transfer | ( | const qm_ss_spi_t | spi, |
const qm_ss_spi_async_transfer_t *const | xfer | ||
) |
Initiate an interrupt based SPI transfer.
Perform an interrupt based SPI transfer. If transfer mode is full duplex (QM_SS_SPI_TMOD_TX_RX), then tx_len and rx_len must be equal. Similarly, for transmit-only transfers (QM_SS_SPI_TMOD_TX) rx_len must be 0, while for receive-only transfers (QM_SS_SPI_TMOD_RX) tx_len must be 0. This function is non blocking.
[in] | spi | SPI module identifier. |
[in] | xfer | Structure containing transfer information. The structure must not be NULL and must be kept valid until the transfer is complete. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 206 of file qm_ss_spi.c.
References QM_SS_SPI_SPIEN, QM_SS_SPI_TMOD_EEPROM_READ, QM_SS_SPI_TMOD_RX, QM_SS_SPI_TMOD_TX_RX, qm_ss_spi_async_transfer_t::rx_len, and qm_ss_spi_async_transfer_t::tx_len.
int qm_ss_spi_irq_transfer_terminate | ( | const qm_ss_spi_t | spi | ) |
Terminate SPI IRQ transfer.
Terminate the current IRQ SPI transfer. This function will trigger complete callbacks even if the transfer is not completed.
[in] | spi | SPI module identifier. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 257 of file qm_ss_spi.c.
References qm_ss_spi_async_transfer_t::callback, qm_ss_spi_async_transfer_t::callback_data, QM_SS_SPI_IDLE, QM_SS_SPI_TMOD_TX, QM_SS_SPI_TMOD_TX_RX, qm_ss_spi_async_transfer_t::rx_len, and qm_ss_spi_async_transfer_t::tx_len.
int qm_ss_spi_restore_context | ( | const qm_ss_spi_t | spi, |
const qm_ss_spi_context_t *const | ctx | ||
) |
Restore SS SPI context.
Restore the configuration of the specified SS SPI peripheral after exiting sleep.
[in] | spi | SPI controller identifier. |
[in] | ctx | SPI context structure. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 478 of file qm_ss_spi.c.
References QM_SS_SPI_CTRL, QM_SS_SPI_SPIEN, QM_SS_SPI_TIMING, qm_ss_spi_context_t::spi_ctrl, qm_ss_spi_context_t::spi_spien, and qm_ss_spi_context_t::spi_timing.
int qm_ss_spi_save_context | ( | const qm_ss_spi_t | spi, |
qm_ss_spi_context_t *const | ctx | ||
) |
Save SS SPI context.
Saves the configuration of the specified SS SPI peripheral before entering sleep.
[in] | spi | SPI controller identifier. |
[out] | ctx | SPI context structure. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 469 of file qm_ss_spi.c.
References QM_SS_SPI_CTRL, QM_SS_SPI_SPIEN, QM_SS_SPI_TIMING, qm_ss_spi_context_t::spi_ctrl, qm_ss_spi_context_t::spi_spien, and qm_ss_spi_context_t::spi_timing.
int qm_ss_spi_set_config | ( | const qm_ss_spi_t | spi, |
const qm_ss_spi_config_t *const | cfg | ||
) |
Set SPI configuration.
Change the configuration of a SPI module. This includes transfer mode, bus mode, clock divider and data frame size.
This operation is permitted only when the SPI module is disabled.
[in] | spi | SPI module identifier. |
[in] | cfg | New configuration for SPI. This must not be NULL. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 65 of file qm_ss_spi.c.
References qm_ss_spi_config_t::bus_mode, qm_ss_spi_config_t::clk_divider, qm_ss_spi_config_t::frame_size, QM_SS_SPI_SPIEN, and qm_ss_spi_config_t::transfer_mode.
int qm_ss_spi_slave_select | ( | const qm_ss_spi_t | spi, |
const qm_ss_spi_slave_select_t | ss | ||
) |
Set Slave Select lines.
Select which slaves to perform SPI transmissions on. Select lines can be combined using the | operator. It is only suggested to use this functionality in TX only mode. This operation is permitted only when a SPI transfer is not already in progress; the caller should check that by retrieving the device status.
[in] | spi | SPI module identifier. |
[in] | ss | Select lines to enable when performing transfers. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 96 of file qm_ss_spi.c.
References QM_SS_SPI_SR.
int qm_ss_spi_transfer | ( | const qm_ss_spi_t | spi, |
const qm_ss_spi_transfer_t *const | xfer, | ||
qm_ss_spi_status_t *const | status | ||
) |
Perform a blocking SPI transfer.
This is a blocking synchronous call. If transfer mode is full duplex (QM_SS_SPI_TMOD_TX_RX) tx_len and rx_len must be equal. Similarly, for transmit-only transfers (QM_SS_SPI_TMOD_TX) rx_len must be 0, while for receive-only transfers (QM_SS_SPI_TMOD_RX) tx_len must be 0.
[in] | spi | SPI module identifier. |
[in] | xfer | Structure containing transfer information. This must not be NULL. |
[out] | status | Reference to the variable where to store the SPI status at the end of the transfer. |
0 | on success. |
Negative | errno for possible error codes. |
Definition at line 126 of file qm_ss_spi.c.
References QM_SS_SPI_RX_OVERFLOW, QM_SS_SPI_SPIEN, QM_SS_SPI_SR, QM_SS_SPI_TMOD_EEPROM_READ, QM_SS_SPI_TMOD_RX, QM_SS_SPI_TMOD_TX, QM_SS_SPI_TMOD_TX_RX, qm_ss_spi_transfer_t::rx, qm_ss_spi_transfer_t::rx_len, qm_ss_spi_transfer_t::tx, and qm_ss_spi_transfer_t::tx_len.