# SPI - [Overview](#section652650751165623) - [Summary](#section1949059107165623) - [Files](#files) - [Data Structures](#nested-classes) - [Macros](#define-members) - [Enumerations](#enum-members) - [Functions](#func-members) - [Details](#section1765579536165623) - [Macro Definition](#section1272510252165623) - [SPI\_CLK\_PHASE](#ga430ad9ccffd42f4427ba22fcc8167c64) - [SPI\_CLK\_POLARITY](#ga4cafe948918622f80c27db640c6c23c6) - [SPI\_MODE\_3WIRE](#ga11113e647ddd2101c1c693632f63aa7c) - [SPI\_MODE\_CS\_HIGH](#ga33d89d81eb33b7a5de1a03e88279163d) - [SPI\_MODE\_LOOP](#ga8619b297de563eca6852af34c79daa62) - [SPI\_MODE\_LSBFE](#ga4da8777b0d2d7dd96d6038411791c36e) - [SPI\_MODE\_NOCS](#ga361195644b8e753d5469dd492c66217b) - [SPI\_MODE\_READY](#ga42f3ef9ad5429ac10662448fe1f5a746) - [Enumeration Type](#section1553762052165623) - [SpiTransferMode](#ga55946d1d895fc2b7b33007019de1668f) - [Function](#section496230935165623) - [SpiClose\(\)](#ga4c961307ea89008ba0f064c92eb1617d) - [SpiGetCfg\(\)](#ga77d533d55c550c4478185a02a4e12fb1) - [SpiOpen\(\)](#ga193e808f7e68a5b4c6b71ca2db47a11f) - [SpiRead\(\)](#gaa860e42dac8b2caabefda6e82ba1a541) - [SpiSetCfg\(\)](#gafbca6de683781921a8d1cb41ead0030e) - [SpiTransfer\(\)](#gaf9226a2ce4ff75c7dc76279b3bbd7af4) - [SpiWrite\(\)](#ga0073b24fba24fb37b3ea451a0c7d911f) ## **Overview** **Description:** Defines standard APIs of the Serial Peripheral Interface \(SPI\) capabilities. The SPI module abstracts the SPI capabilities of different system platforms to provide stable APIs for driver development. This module can create and destroy SPI device handles, read and write SPI data, and obtain and set configuration parameters. **Since:** 1.0 ## **Summary** ## Files
Defines standard SPI-specific interfaces for driver development. |
Defines the general SPI device descriptor, which can be used as the unique identifier of an SPI device. When operating an SPI device, you need to specify a descriptor of the SpiDevInfo type, and obtain the handle of the SPI device by calling SpiOpen. |
|
SPI_CLK_PHASE (1 << 0) |
Indicates the SPI clock phase. The value 0 indicates that data will be sampled on the first clock edge, and 1 indicates that data will be sampled on the second clock edge. |
SPI_CLK_POLARITY (1 << 1) |
Indicates the SPI clock polarity. The value 0 indicates a low-level clock signal in the idle state, and 1 indicates a high-level clock signal in the idle state. |
SPI_MODE_3WIRE (1 << 2) |
Indicates that a single data line is used for both input and output. |
SPI_MODE_LOOP (1 << 3) |
|
SPI_MODE_LSBFE (1 << 4) |
Indicates the SPI data transfer order. The value 0 indicates that data is transferred from the most significant bit (MSB) to the least significant bit (LSB), and 1 indicates the opposite. |
SPI_MODE_NOCS (1 << 5) |
Indicates that there is only one SPI device, and no chip select (CS) is required. |
SPI_MODE_CS_HIGH (1 << 6) |
Indicates that the CS level is high when an SPI device is selected. |
SPI_MODE_READY (1 << 7) |
Indicates that the SPI device is set to low for pausing data transfer. |
SpiTransferMode { SPI_INTERRUPT_TRANSFER = 0, SPI_POLLING_TRANSFER, SPI_DMA_TRANSFER } |
SpiOpen (const struct SpiDevInfo *info) |
|
SpiTransfer (DevHandle handle, struct SpiMsg *msgs, uint32_t count) |
|
| SPI_INTERRUPT_TRANSFER | |
| SPI_POLLING_TRANSFER | |
| SPI_DMA_TRANSFER |
| handle | Indicates the pointer to the SPI device handle obtained via SpiOpen. |
| handle | Indicates the pointer to the SPI device handle obtained via SpiOpen. |
| cfg | Indicates the pointer to the configuration parameters. |
| info | Indicates the pointer to the SPI device information. |
| handle | Indicates the pointer to the SPI device handle obtained via SpiOpen. |
| buf | Indicates the pointer to the buffer for receiving the data. |
| len | Indicates the length of the data to read. |
| handle | Indicates the pointer to the SPI device handle obtained via SpiOpen. |
| cfg | Indicates the pointer to the configuration parameters. |
| handle | Indicates the pointer to the SPI device handle obtained via SpiOpen. |
| msgs | Indicates the pointer to the data to transfer. |
| count | Indicates the length of the message structure array. |
| handle | Indicates the pointer to the SPI device handle obtained via SpiOpen. |
| buf | Indicates the pointer to the data to write. |
| len | Indicates the length of the data to write. |