1 Star 0 Fork 5.1K

JayWang / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
spi_if-h.md 14.99 KB
一键复制 编辑 原始数据 按行查看 历史
wenjun 提交于 2020-09-08 10:08 . add OpenHarmony 1.0 baseline

spi_if.h

Overview

Related Modules:

SPI

Description:

Defines standard SPI-specific interfaces for driver development.

A driver needs to use the SPI-specific interfaces for data writing and reading before performing any operations on an SPI-compliant device.

Since:

1.0

Summary

Data Structures

Data Structure Name

Description

SpiDevInfo

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.

SpiMsg

Defines the custom SPI transfer message.

SpiCfg

Defines the configuration of an SPI device.

Macros

Macro Name and Value

Description

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)

Indicates the SPI loopback mode.

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.

Enumerations

Enumeration Name

Description

SpiTransferMode { SPI_INTERRUPT_TRANSFER = 0, SPI_POLLING_TRANSFER, SPI_DMA_TRANSFER }

Enumerates transfer modes of SPI data.

Functions

Function Name

Description

SpiOpen (const struct SpiDevInfo *info)

struct DevHandle

Obtains the handle of an SPI device.

SpiClose (struct DevHandle *handle)

void 

Releases the handle of an SPI device.

SpiTransfer (struct DevHandle *handle, struct SpiMsg *msgs, uint32_t count)

int32_t 

Launches a custom transfer to an SPI device.

SpiRead (struct DevHandle *handle, uint8_t *buf, uint32_t len)

int32_t 

Reads data of a specified length from an SPI device.

SpiWrite (struct DevHandle *handle, uint8_t *buf, uint32_t len)

int32_t 

Writes data of a specified length to an SPI device.

SpiSetCfg (struct DevHandle *handle, struct SpiCfg *cfg)

int32_t 

Sets configuration parameters for an SPI device.

SpiGetCfg (struct DevHandle *handle, struct SpiCfg *cfg)

int32_t 

Obtains the configuration parameters of an SPI device.

1
https://gitee.com/mole1/docs.git
git@gitee.com:mole1/docs.git
mole1
docs
docs
master

搜索帮助