libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
stm32_gpio.hpp
1#pragma once
2
3#include "gpio.hpp"
4#include "main.h"
5
6#ifdef HAL_GPIO_MODULE_ENABLED
7
8typedef enum
9{
10#if defined(STM32F0) || defined(STM32G0) || defined(STM32L0)
11 STM32_GPIO_EXTI_0_1,
12 STM32_GPIO_EXTI_2_3,
13 STM32_GPIO_EXTI_4_15,
14#elif defined(STM32WB0)
15 STM32_GPIO_EXTI_GPIOA,
16 STM32_GPIO_EXTI_GPIOB,
17#else
18 STM32_GPIO_EXTI_0,
19 STM32_GPIO_EXTI_1,
20 STM32_GPIO_EXTI_2,
21 STM32_GPIO_EXTI_3,
22 STM32_GPIO_EXTI_4,
23 STM32_GPIO_EXTI_5_9,
24 STM32_GPIO_EXTI_10_15,
25#endif
26 STM32_GPIO_EXTI_NUMBER
27} stm32_gpio_exti_t;
28
29stm32_gpio_exti_t STM32_GPIO_EXTI_GetID(uint16_t pin); // NOLINT
30
31namespace LibXR
32{
33class STM32GPIO : public GPIO
34{
35 public:
36 STM32GPIO(GPIO_TypeDef* port, uint16_t pin, IRQn_Type irq = NonMaskableInt_IRQn);
37
38 bool Read();
39
40 ErrorCode Write(bool value);
41
42 ErrorCode EnableInterrupt();
43
44 ErrorCode DisableInterrupt();
45
46 ErrorCode SetConfig(Configuration config);
47
48 static STM32GPIO* map[STM32_GPIO_EXTI_NUMBER]; // NOLINT
49
50 private:
51 GPIO_TypeDef* port_;
52 uint16_t pin_;
53 IRQn_Type irq_;
54};
55
56} // namespace LibXR
57
58#endif
通用输入输出(GPIO)接口类。General Purpose Input/Output (GPIO) interface class.
Definition gpio.hpp:13
ErrorCode Write(bool value)
写入 GPIO 引脚状态。Writes the GPIO pin state.
bool Read()
读取 GPIO 引脚状态。Reads the GPIO pin state.
ErrorCode DisableInterrupt()
禁用 GPIO 引脚中断。Disables the GPIO pin interrupt.
ErrorCode SetConfig(Configuration config)
配置 GPIO 引脚参数。Configures the GPIO pin settings.
ErrorCode EnableInterrupt()
使能 GPIO 引脚中断。Enables the GPIO pin interrupt.
LibXR 命名空间
Definition ch32_gpio.hpp:9
存储 GPIO 配置参数的结构体。Structure storing GPIO configuration parameters.
Definition gpio.hpp:46