串行外设接口(SPI)抽象类。Abstract class for Serial Peripheral Interface (SPI).
More...
#include <spi.hpp>
串行外设接口(SPI)抽象类。Abstract class for Serial Peripheral Interface (SPI).
Definition at line 12 of file spi.hpp.
◆ OperationRW
定义读写操作类型的别名。Defines an alias for the read/write operation type.
Definition at line 39 of file spi.hpp.
◆ ClockPhase
定义 SPI 时钟相位。Defines the SPI clock phase.
Enumerator |
---|
EDGE_1 | 在第一个时钟边沿采样数据。Data sampled on the first clock edge.
|
EDGE_2 | 在第二个时钟边沿采样数据。Data sampled on the second clock edge.
|
Definition at line 29 of file spi.hpp.
30 {
33 };
@ EDGE_2
在第二个时钟边沿采样数据。Data sampled on the second clock edge.
@ EDGE_1
在第一个时钟边沿采样数据。Data sampled on the first clock edge.
◆ ClockPolarity
定义 SPI 时钟极性。Defines the SPI clock polarity.
Enumerator |
---|
LOW | 时钟空闲时为低电平。Clock idle low.
|
HIGH | 时钟空闲时为高电平。Clock idle high.
|
Definition at line 19 of file spi.hpp.
20 {
23 };
@ LOW
时钟空闲时为低电平。Clock idle low.
@ HIGH
时钟空闲时为高电平。Clock idle high.
◆ SPI()
默认构造函数。Default constructor.
Definition at line 66 of file spi.hpp.
◆ MemRead()
virtual ErrorCode LibXR::SPI::MemRead |
( |
uint16_t | reg, |
|
|
RawData | read_data, |
|
|
OperationRW & | op ) |
|
pure virtual |
从 SPI 设备的寄存器读取数据。 Reads data from a specific register of the SPI device.
- Parameters
-
reg | 寄存器地址。Register address. |
read_data | 读取的数据缓冲区。Buffer to store read data. |
op | 操作类型(同步/异步)。Operation mode (sync/async). |
- Returns
- 操作结果的错误码。Error code indicating success or failure.
Implemented in LibXR::STM32SPI.
◆ MemWrite()
向 SPI 设备的寄存器写入数据。 Writes data to a specific register of the SPI device.
- Parameters
-
reg | 寄存器地址。Register address. |
write_data | 写入的数据缓冲区。Buffer containing data to write. |
op | 操作类型(同步/异步)。Operation mode (sync/async). |
- Returns
- 操作结果的错误码。Error code indicating success or failure.
Implemented in LibXR::STM32SPI.
◆ Read()
进行 SPI 读取操作。Performs SPI read operation.
- Parameters
-
read_data | 存储读取数据的缓冲区。Buffer to store the read data. |
op | 读写操作类型。Type of read/write operation. |
- Returns
- 操作结果的错误码。Error code indicating the result of the operation.
Definition at line 84 of file spi.hpp.
85 {
86 return ReadAndWrite(read_data, ConstRawData(
nullptr, 0), op);
87 }
virtual ErrorCode ReadAndWrite(RawData read_data, ConstRawData write_data, OperationRW &op)=0
进行 SPI 读写操作。Performs SPI read and write operations.
◆ ReadAndWrite()
进行 SPI 读写操作。Performs SPI read and write operations.
- Parameters
-
read_data | 存储读取数据的缓冲区。Buffer to store the read data. |
write_data | 需要写入的数据缓冲区。Buffer containing the data to be written. |
op | 读写操作类型。Type of read/write operation. |
- Returns
- 操作结果的错误码。Error code indicating the result of the operation.
Implemented in LibXR::STM32SPI.
◆ SetConfig()
设置 SPI 配置参数。Sets SPI configuration parameters.
- Parameters
-
config | 需要应用的 SPI 配置。The SPI configuration to apply. |
- Returns
- 操作结果的错误码。Error code indicating the result of the operation.
Implemented in LibXR::STM32SPI.
◆ Write()
进行 SPI 写入操作。Performs SPI write operation.
- Parameters
-
write_data | 需要写入的数据缓冲区。Buffer containing the data to be written. |
op | 读写操作类型。Type of read/write operation. |
- Returns
- 操作结果的错误码。Error code indicating the result of the operation.
Definition at line 95 of file spi.hpp.
96 {
97 return ReadAndWrite(RawData(
nullptr, 0), write_data, op);
98 }
The documentation for this class was generated from the following file: