diff --git a/include/sta/hal/gpio_pin.hpp b/include/sta/hal/gpio_pin.hpp index 03ea594..d4cdf9b 100644 --- a/include/sta/hal/gpio_pin.hpp +++ b/include/sta/hal/gpio_pin.hpp @@ -26,6 +26,10 @@ namespace sta void setState(GpioPinState state) override; + GPIO_TypeDef * getPort() const; + uint16_t getPin() const; + uint8_t getIndex() const; + private: GPIO_TypeDef * port_; /**< GPIO port */ uint16_t pin_; /**< GPIO pin */ diff --git a/src/hal/gpio_pin.cpp b/src/hal/gpio_pin.cpp index d8fd93e..678b936 100644 --- a/src/hal/gpio_pin.cpp +++ b/src/hal/gpio_pin.cpp @@ -17,6 +17,21 @@ namespace sta { HAL_GPIO_WritePin(port_, pin_, (state == GpioPinState::LOW) ? GPIO_PIN_RESET : GPIO_PIN_SET); } + + GPIO_TypeDef * HalGpioPin::getPort() const + { + return port_; + } + + uint16_t HalGpioPin::getPin() const + { + return pin_; + } + + uint8_t HalGpioPin::getIndex() const + { + return GPIO_GET_INDEX(port_); + } } // namespace sta