libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::GPIO Class Referenceabstract

通用输入输出(GPIO)接口类。General Purpose Input/Output (GPIO) interface class. More...

#include <gpio.hpp>

Inheritance diagram for LibXR::GPIO:
Collaboration diagram for LibXR::GPIO:

Data Structures

struct  Configuration
 存储 GPIO 配置参数的结构体。Structure storing GPIO configuration parameters. More...
 

Public Types

enum class  Direction : uint8_t {
  INPUT , OUTPUT_PUSH_PULL , OUTPUT_OPEN_DRAIN , FALL_INTERRUPT ,
  RISING_INTERRUPT , FALL_RISING_INTERRUPT
}
 定义 GPIO 引脚的方向类型。Defines the direction types for GPIO pins. More...
 
enum class  Pull : uint8_t { NONE , UP , DOWN }
 定义 GPIO 引脚的上拉/下拉模式。Defines the pull-up/pull-down configurations for GPIO pins. More...
 

Public Member Functions

 GPIO ()
 默认构造函数。Default constructor.
 
virtual bool Read ()=0
 读取 GPIO 引脚状态。Reads the GPIO pin state.
 
virtual ErrorCode Write (bool value)=0
 写入 GPIO 引脚状态。Writes the GPIO pin state.
 
virtual ErrorCode EnableInterrupt ()=0
 使能 GPIO 引脚中断。Enables the GPIO pin interrupt.
 
virtual ErrorCode DisableInterrupt ()=0
 禁用 GPIO 引脚中断。Disables the GPIO pin interrupt.
 
virtual ErrorCode SetConfig (Configuration config)=0
 配置 GPIO 引脚参数。Configures the GPIO pin settings.
 
ErrorCode RegisterCallback (Callback<> callback)
 注册 GPIO 事件回调函数。Registers a callback function for GPIO events.
 

Data Fields

Callback callback_
 GPIO 事件的回调函数。Callback function for GPIO events.
 

Detailed Description

通用输入输出(GPIO)接口类。General Purpose Input/Output (GPIO) interface class.

Definition at line 12 of file gpio.hpp.

Member Enumeration Documentation

◆ Direction

定义 GPIO 引脚的方向类型。Defines the direction types for GPIO pins.

Enumerator
INPUT 

输入模式。Input mode.

OUTPUT_PUSH_PULL 

推挽输出模式。Push-pull output mode.

OUTPUT_OPEN_DRAIN 

开漏输出模式。Open-drain output mode.

FALL_INTERRUPT 

下降沿中断模式。Falling edge interrupt mode.

RISING_INTERRUPT 

上升沿中断模式。Rising edge interrupt mode.

FALL_RISING_INTERRUPT 

双沿触发中断模式。Both edge interrupt mode.

Definition at line 19 of file gpio.hpp.

20 {
21 INPUT,
27 };
@ OUTPUT_PUSH_PULL
推挽输出模式。Push-pull output mode.
@ RISING_INTERRUPT
上升沿中断模式。Rising edge interrupt mode.
@ FALL_RISING_INTERRUPT
双沿触发中断模式。Both edge interrupt mode.
@ OUTPUT_OPEN_DRAIN
开漏输出模式。Open-drain output mode.
@ INPUT
输入模式。Input mode.
@ FALL_INTERRUPT
下降沿中断模式。Falling edge interrupt mode.

◆ Pull

定义 GPIO 引脚的上拉/下拉模式。Defines the pull-up/pull-down configurations for GPIO pins.

Enumerator
NONE 

无上拉或下拉。No pull-up or pull-down.

UP 

上拉模式。Pull-up mode.

DOWN 

下拉模式。Pull-down mode.

Definition at line 34 of file gpio.hpp.

35 {
36 NONE,
37 UP,
38 DOWN
39 };
@ NONE
无上拉或下拉。No pull-up or pull-down.
@ DOWN
下拉模式。Pull-down mode.
@ UP
上拉模式。Pull-up mode.

Constructor & Destructor Documentation

◆ GPIO()

LibXR::GPIO::GPIO ( )
inline

默认构造函数。Default constructor.

Definition at line 59 of file gpio.hpp.

59{}

Member Function Documentation

◆ DisableInterrupt()

virtual ErrorCode LibXR::GPIO::DisableInterrupt ( )
pure virtual

禁用 GPIO 引脚中断。Disables the GPIO pin interrupt.

Returns
操作结果的错误码。Error code indicating the result of the operation.

Implemented in LibXR::STM32GPIO.

◆ EnableInterrupt()

virtual ErrorCode LibXR::GPIO::EnableInterrupt ( )
pure virtual

使能 GPIO 引脚中断。Enables the GPIO pin interrupt.

Returns
操作结果的错误码。Error code indicating the result of the operation.

Implemented in LibXR::STM32GPIO.

◆ Read()

virtual bool LibXR::GPIO::Read ( )
pure virtual

读取 GPIO 引脚状态。Reads the GPIO pin state.

Returns
返回引脚状态,true 表示高电平,false 表示低电平。Returns the pin state, true for high, false for low.

Implemented in LibXR::STM32GPIO.

◆ RegisterCallback()

ErrorCode LibXR::GPIO::RegisterCallback ( Callback<>  callback)
inline

注册 GPIO 事件回调函数。Registers a callback function for GPIO events.

Parameters
callback要注册的回调函数。The callback function to register.
Returns
操作结果的错误码。Error code indicating the result of the operation.

Definition at line 100 of file gpio.hpp.

101 {
102 callback_ = callback;
103 return ErrorCode::OK;
104 }
Callback callback_
GPIO 事件的回调函数。Callback function for GPIO events.
Definition gpio.hpp:54

◆ SetConfig()

virtual ErrorCode LibXR::GPIO::SetConfig ( Configuration  config)
pure virtual

配置 GPIO 引脚参数。Configures the GPIO pin settings.

Parameters
config需要应用的 GPIO 配置。The GPIO configuration to apply.
Returns
操作结果的错误码。Error code indicating the result of the operation.

Implemented in LibXR::STM32GPIO.

◆ Write()

virtual ErrorCode LibXR::GPIO::Write ( bool  value)
pure virtual

写入 GPIO 引脚状态。Writes the GPIO pin state.

Parameters
value要写入的状态,true 表示高电平,false 表示低电平。The value to write, true for high, false for low.
Returns
操作结果的错误码。Error code indicating the result of the operation.

Implemented in LibXR::STM32GPIO.

Field Documentation

◆ callback_

Callback LibXR::GPIO::callback_

GPIO 事件的回调函数。Callback function for GPIO events.

Definition at line 54 of file gpio.hpp.


The documentation for this class was generated from the following file: