semf
stm32gpio.h
Go to the documentation of this file.
1
10#ifndef SEMF_HARDWAREABSTRACTION_STM32_STM32GPIO_H_
11#define SEMF_HARDWAREABSTRACTION_STM32_STM32GPIO_H_
12
14
15#if defined(STM32)
16#include <semf/system/gpio.h>
17namespace semf
18{
22class Stm32Gpio : public Gpio
23{
24public:
30 Stm32Gpio(GPIO_TypeDef* port, uint16_t pin);
31 explicit Stm32Gpio(const Stm32Gpio& other) = delete;
32 virtual ~Stm32Gpio() = default;
33
34 void set() override;
35 void reset() override;
36 bool state() const override;
37#ifndef STM32F1
38 Direction direction() const override;
39 void setDirection(Direction direction) override;
40 PullUpPullDown pullUpPullDown() const override;
42#endif
43
44protected:
49 GPIO_TypeDef* port() const;
54 GPIO_TypeDef* port();
59 uint16_t pin() const;
65 uint16_t pinNumberToIOPosition(uint16_t pin) const;
66
67private:
69 GPIO_TypeDef* m_port;
71 uint16_t m_pin;
72};
73} /* namespace semf */
74#endif
75#endif /* SEMF_HARDWAREABSTRACTION_STM32_STM32GPIO_H_ */
Interface class for using a GPIO pin of the microcontroller.
Definition: gpio.h:23
Direction
Definition: gpio.h:27
PullUpPullDown
Definition: gpio.h:35
Gpio implementation for STM32.
Definition: stm32gpio.h:23
GPIO_TypeDef * port() const
Returns the GPIO handler.
Definition: stm32gpio.cpp:138
uint16_t pinNumberToIOPosition(uint16_t pin) const
Returns the io position based on the pin number.
Definition: stm32gpio.cpp:153
void reset() override
Definition: stm32gpio.cpp:28
Stm32Gpio(GPIO_TypeDef *port, uint16_t pin)
Constructor.
Definition: stm32gpio.cpp:16
virtual ~Stm32Gpio()=default
void setPullUpPullDown(PullUpPullDown pullUpPullDown) override
Sets the pullup or pulldown setting of a GPIO.
Definition: stm32gpio.cpp:113
PullUpPullDown pullUpPullDown() const override
Returns the pullup or pulldown setting of a GPIO.
Definition: stm32gpio.cpp:93
uint16_t pin() const
Returns pin number.
Definition: stm32gpio.cpp:148
Stm32Gpio(const Stm32Gpio &other)=delete
void set() override
Definition: stm32gpio.cpp:22
bool state() const override
Returns the current state of the pin.
Definition: stm32gpio.cpp:34
Direction direction() const override
Returns the direction setting of a GPIO.
Definition: stm32gpio.cpp:50
void setDirection(Direction direction) override
Sets the direction of a GPIO.
Definition: stm32gpio.cpp:63