ChibiOS 21.11.4
hal_spi_v2.h File Reference

SPI (v2) Driver macros and structures. More...

#include "hal_spi_v2_lld.h"

Go to the source code of this file.

Data Structures

struct  hal_spi_config
 Driver configuration structure. More...
struct  hal_spi_driver
 Structure representing an SPI driver. More...

Macros

Chip Select modes
#define SPI_SELECT_MODE_NONE
#define SPI_SELECT_MODE_PAD   1 /** @brief Legacy mode. */
#define SPI_SELECT_MODE_PORT   2 /** @brief Fastest mode. */
#define SPI_SELECT_MODE_LINE   3 /** @brief Packed mode. */
#define SPI_SELECT_MODE_LLD   4 /** @brief LLD-defined mode.*/
SPI configuration options
#define SPI_USE_SYNCHRONIZATION   FALSE
 Support for thread synchronization API.
#define SPI_USE_ASSERT_ON_ERROR   TRUE
 Inserts an assertion on function errors before returning.
#define SPI_USE_MUTUAL_EXCLUSION   TRUE
 Enables the spiAcquireBus() and spiReleaseBus() APIs.
#define SPI_SELECT_MODE   SPI_SELECT_MODE_PAD
 Handling method for SPI CS line.
Macro Functions
#define spiIsBufferComplete(spip)
 Buffer state.
#define spiSelectI(spip)
 Asserts the slave select signal and prepares for transfers.
#define spiUnselectI(spip)
 Deasserts the slave select signal.
#define spiPolledExchange(spip, frame)
 Exchanges one frame using a polled wait.
#define spiAbortI(spip)
 Compatibility API with SPI driver v1.
#define spiAbort(spip)
 Compatibility API with SPI driver v1.
Low level driver helper macros
#define __spi_wakeup_isr(spip, msg)
 Wakes up the waiting thread.
#define __spi_isr_complete_code(spip)
 Common ISR code in linear mode.
#define __spi_isr_half_code(spip)
 Half buffer filled ISR code in circular mode.
#define __spi_isr_full_code(spip)
 Full buffer filled ISR code in circular mode.
#define __spi_isr_error_code(spip, msg)
 ISR error reporting code..

Typedefs

typedef struct hal_spi_driver SPIDriver
 Type of a structure representing an SPI driver.
typedef struct hal_spi_config SPIConfig
 Type of a SPI driver configuration structure.
typedef void(* spicb_t) (SPIDriver *spip)
 SPI notification callback type.

Enumerations

enum  spistate_t {
  SPI_UNINIT = 0 , SPI_STOP = 1 , SPI_READY = 2 , SPI_ACTIVE = 3 ,
  SPI_COMPLETE = 4
}
 Driver state machine possible states. More...

Functions

void spiInit (void)
 SPI Driver initialization.
void spiObjectInit (SPIDriver *spip)
 Initializes the standard part of a SPIDriver structure.
msg_t spiStart (SPIDriver *spip, const SPIConfig *config)
 Configures and activates the SPI peripheral.
void spiStop (SPIDriver *spip)
 Deactivates the SPI peripheral.
void spiSelect (SPIDriver *spip)
 Asserts the slave select signal and prepares for transfers.
void spiUnselect (SPIDriver *spip)
 Deasserts the slave select signal.
msg_t spiStartIgnoreI (SPIDriver *spip, size_t n)
 Ignores data on the SPI bus.
msg_t spiStartIgnore (SPIDriver *spip, size_t n)
 Ignores data on the SPI bus.
msg_t spiStartExchangeI (SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf)
 Exchanges data on the SPI bus.
msg_t spiStartExchange (SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf)
 Exchanges data on the SPI bus.
msg_t spiStartSendI (SPIDriver *spip, size_t n, const void *txbuf)
 Sends data over the SPI bus.
msg_t spiStartSend (SPIDriver *spip, size_t n, const void *txbuf)
 Sends data over the SPI bus.
msg_t spiStartReceiveI (SPIDriver *spip, size_t n, void *rxbuf)
 Receives data from the SPI bus.
msg_t spiStartReceive (SPIDriver *spip, size_t n, void *rxbuf)
 Receives data from the SPI bus.
msg_t spiStopTransferI (SPIDriver *spip, size_t *sizep)
 Stops the ongoing SPI operation.
msg_t spiStopTransfer (SPIDriver *spip, size_t *sizep)
 Stops the ongoing SPI operation, if any.
msg_t spiSynchronizeS (SPIDriver *spip, sysinterval_t timeout)
 Synchronizes with current transfer completion.
msg_t spiSynchronize (SPIDriver *spip, sysinterval_t timeout)
 Synchronizes with current transfer completion.
msg_t spiIgnore (SPIDriver *spip, size_t n)
 Ignores data on the SPI bus.
msg_t spiExchange (SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf)
 Exchanges data on the SPI bus.
msg_t spiSend (SPIDriver *spip, size_t n, const void *txbuf)
 Sends data over the SPI bus.
msg_t spiReceive (SPIDriver *spip, size_t n, void *rxbuf)
 Receives data from the SPI bus.
void spiAcquireBus (SPIDriver *spip)
 Gains exclusive access to the SPI bus.
void spiReleaseBus (SPIDriver *spip)
 Releases exclusive access to the SPI bus.

Detailed Description

SPI (v2) Driver macros and structures.

Definition in file hal_spi_v2.h.