跳转到内容

bsp::GPIO_Driver API

文档稀疏
符号
67
已记录
35
类型
6
继承关系
2
源码分支
main

32 / 67 个公开 API 符号没有说明。

继承关系总览

继承图尚未加载。

全部继承关系

共 6 个类型

类型目录
结构体

GPIO_t

查看源码

上游未提供类型说明。

成员变量

2

port

变量公开
        GPIO_TypeDef* GPIO_t::port
      

GPIO 句柄。 这里把端口和引脚打包成一个轻量结构体,便于在中断回调和普通业务函数之间传递。 Deprecated 新代码请使用 bsp::gpio::GpioPin。

bsp/gpio_driver/gpio_driver.h:51
结构体

PWM_t

查看源码

上游未提供类型说明。

成员变量

2

htim

变量公开
        TIM_HandleTypeDef* PWM_t::htim
      

PWM 句柄。 PWM_t 一个对应一个定时器通道,上层只需要传这个结构体即可操作输出。

bsp/gpio_driver/pwm.h:47
结构体

bsp::gpio::GpioPin

查看源码

上游未提供类型说明。

继承关系

成员函数

2

成员变量

2
结构体

bsp::gpio::GpioPinInput

查看源码

上游未提供类型说明。

继承关系

基类

构造与析构

1

GpioPinInput

函数公开
        bsp::gpio::GpioPinInput::GpioPinInput (GPIO_TypeDef *port, const uint16_t pin, void *user_data=nullptr)
      

上游未提供说明。

bsp/gpio_driver/gpio_driver.hpp:69

成员函数

2

成员变量

1
结构体

bsp::gpio::GpioPinOutput

查看源码

面向对象的 GPIO 引脚句柄。 轻量值类型,可复制,public 成员兼容 brace 初始化。 推荐使用此类型替代 GPIO_t。

继承关系

基类

成员函数

3
结构体

bsp::gpio::anonymous_namespace{gpio_driver.cpp}::ExtiSlot

查看源码

上游未提供类型说明。

成员变量

3

其他公开符号

函数

21

GPIO_EXTI_Callback

函数
        void GPIO_EXTI_Callback (const uint16_t GPIO_Pin)
      

统一的 EXTI 中断分发入口。 HAL_GPIO_EXTI_Callback 应在中调用,把 HAL 回调转发到本库。

bsp/gpio_driver/gpio_driver.c:82

GPIO_EXTI_RegisterCallback

函数
        void GPIO_EXTI_RegisterCallback (const GPIO_t *gpio, const EXTI_Callback callback, void *data)
      

注册某个 GPIO 的 EXTI 回调。 这里按 pin 位序号直接索引数组,速度比 map 查找更适合中断上下文。

bsp/gpio_driver/gpio_driver.c:57

PWM_SetCompare

函数静态
        static void PWM_SetCompare (PWM_t *hpwm, const uint32_t compare)
      

直接设置比较值。 compare 超过 ARR 时不生效,避免写入非法值。

bsp/gpio_driver/pwm.h:72

PWM_SetDutyCircle

函数静态
        static void PWM_SetDutyCircle (PWM_t *hpwm, const float duty_circle)
      

按占空比设置 PWM 输出。 duty_circle 的有效范围是 [0, 1];越界时会钳位到边界值。

bsp/gpio_driver/pwm.h:84

__attribute__

函数const
        __attribute__ ((deprecated("Use bsp::gpio::DispatchExtiInterrupt() instead"))) void GPIO_EXTI_Callback(const uint16_t GPIO_Pin)
      

上游未提供说明。

bsp/gpio_driver/gpio_driver.h:125

__attribute__

函数
        __attribute__ ((deprecated("Use bsp::gpio::GpioPin::read() instead"))) static inline GPIO_PinState GPIO_ReadPin(GPIO_t *hgpio)
      

读取 GPIO 输入状态。 直接转发到底层 HAL 接口。 Deprecated bsp::gpio::GpioPin::read() 请使用。

bsp/gpio_driver/gpio_driver.h:62

__attribute__

函数
        __attribute__ ((deprecated("Use bsp::gpio::GpioPin::reset() instead"))) static inline void GPIO_ResetPin(GPIO_t *hgpio)
      

输出低电平。 Deprecated 请使用 bsp::gpio::GpioPin::reset()。

bsp/gpio_driver/gpio_driver.h:95

__attribute__

函数
        __attribute__ ((deprecated("Use bsp::gpio::GpioPin::set() instead"))) static inline void GPIO_SetPin(GPIO_t *hgpio)
      

输出高电平。 Deprecated 请使用 bsp::gpio::GpioPin::set()。

bsp/gpio_driver/gpio_driver.h:84

__attribute__

函数
        __attribute__ ((deprecated("Use bsp::gpio::GpioPin::toggle() instead"))) static inline void GPIO_TogglePin(GPIO_t *hgpio)
      

翻转 GPIO 输出状态。 Deprecated 请使用 bsp::gpio::GpioPin::toggle()。

bsp/gpio_driver/gpio_driver.h:106

__attribute__

函数
        __attribute__ ((deprecated("Use bsp::gpio::GpioPin::write() instead"))) static inline void GPIO_WritePin(GPIO_t *hgpio
      

写入 GPIO 输出状态。 Deprecated bsp::gpio::GpioPin::write() 请使用。

bsp/gpio_driver/gpio_driver.h:73

__attribute__

函数const
        __attribute__ ((deprecated("Use bsp::gpio::RegisterExtiCallback() instead"))) void GPIO_EXTI_RegisterCallback(const GPIO_t *gpio
      

上游未提供说明。

bsp/gpio_driver/gpio_driver.h:121

__attribute__

函数const
        __attribute__ ((deprecated("Use bsp::gpio::UnregisterExtiCallback() instead"))) void GPIO_EXTI_UnregisterCallback(const GPIO_t *gpio)
      

上游未提供说明。

bsp/gpio_driver/gpio_driver.h:123

bsp::gpio::DispatchExtiInterrupt

函数
        void bsp::gpio::DispatchExtiInterrupt (uint16_t GPIO_Pin)
      

统一的 EXTI 中断分发入口,应在 HAL_GPIO_EXTI_Callback 中调用。

bsp/gpio_driver/gpio_driver.cpp:61

bsp::gpio::RegisterExtiCallback

函数
        void bsp::gpio::RegisterExtiCallback (const GpioPinInput *gpio, ExtiCallback callback)
      

注册某个 GPIO 的 EXTI 回调。回调上下文从 gpio->user_data 读取。

bsp/gpio_driver/gpio_driver.cpp:45

bsp::gpio::anonymous_namespace{gpio_driver.cpp}::pin_to_index

函数
        size_t bsp::gpio::anonymous_namespace{gpio_driver.cpp}::pin_to_index (const uint16_t pin)
      

把 GPIO pin 转成索引。 pin 必须是单 bit 值,例如 GPIO_PIN_0、GPIO_PIN_1。

bsp/gpio_driver/gpio_driver.cpp:35

gpio_pin_to_index

函数
        size_t gpio_pin_to_index (uint16_t pin)
      

把 GPIO pin 转成索引。 pin 必须是单 bit 值,例如 GPIO_PIN_0、GPIO_PIN_1。

bsp/gpio_driver/gpio_driver.c:32

类型定义

2

EXTI_Callback

类型定义
        typedef void(* EXTI_Callback) (const GPIO_t *gpio, uint32_t counter, void *data) )(const GPIO_t *gpio, uint32_t counter, void *data)
      

EXTI 回调函数签名。 回调里带上触发计数和用户数据,通常用于去抖、边沿累计或者事件分发。 Deprecated 新代码请使用 bsp::gpio::ExtiCallback。

bsp/gpio_driver/gpio_driver.h:120

bsp::gpio::ExtiCallback

类型定义
        using bsp::gpio::ExtiCallback = void (*)(const GpioPinInput* gpio, uint32_t counter)
      

EXTI 回调签名。上下文通过 gpio->user_data 获取。

bsp/gpio_driver/gpio_driver.hpp:86

变量

9

EXTI_CallbackMap

变量静态
        struct @207332141164316154333347014116235364164056303010 EXTI_CallbackMap[16] [16]
      

上游未提供说明。

bsp/gpio_driver/gpio_driver.c:25

bsp::gpio::anonymous_namespace{gpio_driver.cpp}::g_exti_callback_map

变量
        ExtiSlot bsp::gpio::anonymous_namespace{gpio_driver.cpp}::g_exti_callback_map[16] [16]
      

上游未提供说明。

bsp/gpio_driver/gpio_driver.cpp:28

宏定义

3

文件

5

bsp/gpio_driver/gpio_driver.c

文件

GPIO / EXTI 封装实现 syhanjin 2026-01-24 这里主要负责把 HAL 的 EXTI 回调变成可注册、可计数、可携带用户数据的形式。

bsp/gpio_driver/gpio_driver.c

bsp/gpio_driver/gpio_driver.cpp

文件

GPIO 面向对象封装 — EXTI 实现 syhanjin 2026-06-30 bsp::gpio gpio_driver.c 独立的 EXTI 回调系统实现,使用新类型, 与中的旧实现互不依赖。

bsp/gpio_driver/gpio_driver.cpp

bsp/gpio_driver/gpio_driver.h

文件

GPIO / EXTI / PWM 的基础封装 syhanjin 2025-09-10 GPIO_t PWM_t 这个模块把 HAL 的 GPIO、外部中断和 PWM 接口做了一层很薄的封装,核心目标是统一句柄形式, 让上层代码只需要围绕和这类结构体操作,而不必反复处理底层 HAL 句柄细节。 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/ You should have received a copy of the GNU General Public License along with this program. If not, see. https://github.com/HITSZ-WTRobot-Packages/BasicComponents Project repository:

bsp/gpio_driver/gpio_driver.h

bsp/gpio_driver/gpio_driver.hpp

文件

GPIO 面向对象封装(C++) syhanjin 2026-06-30 gpio_driver.h 此头文件提供面向对象的 GPIO 操作 API,推荐用于所有新代码。 旧 C 风格 API 在中保留但已标记为弃用。 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/ You should have received a copy of the GNU General Public License along with this program. If not, see. https://github.com/HITSZ-WTRobot-Packages/BasicComponents Project repository:

bsp/gpio_driver/gpio_driver.hpp

bsp/gpio_driver/pwm.h

文件

TIM PWM 的基础封装 syhanjin 2025-09-10 这个头文件只做最常见的 PWM 启停和占空比换算,目的是让上层代码不用反复接触 __HAL_TIM_* 宏。 这样做的好处是调用方式统一,也更容易在代码里看出“这是一个 PWM 句柄,而不是裸 TIM 句柄”。 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/ You should have received a copy of the GNU General Public License along with this program. If not, see. https://github.com/HITSZ-WTRobot-Packages/BasicComponents Project repository:

bsp/gpio_driver/pwm.h