RTLib
|
STM32F4xx-specific HAL implementation for GPIO pins. More...
#include <gpio.h>
Classes | |
struct | Config |
Configuration for GPIO. More... | |
Public Types | |
enum | Mode : uint8_t { Mode::kInput = 0x0, Mode::kOutput, Mode::kAF, Mode::kAnalog } |
Enumeration for different GPIO modes. More... | |
enum | Speed : uint8_t { Speed::k2MHz = 0x0, Speed::k25MHz, Speed::k50MHz, Speed::k100MHz } |
Enumeration for different GPIO output speeds. More... | |
enum | Pullup : uint8_t { Pullup::kNone = 0x0, Pullup::kPullup, Pullup::kPulldown } |
Enumeration for different internal pull-up states. More... | |
enum | DriverType : uint8_t { DriverType::kPushPull = 0x0, DriverType::kOpenDrain } |
Enumeration for GPIO output driver modes. More... | |
using | AltFn = uint8_t |
Type definition for GPIO alternate function selection. More... | |
Public Member Functions | |
GPIO (const Config &config) | |
Conversion constructor. More... | |
GPIO (Pinout pin, Mode mode, Pullup pullup, Speed speed=Speed::k2MHz, DriverType driver=DriverType::kPushPull, AltFn altfn=0x0) | |
Constructor for internal API use. More... | |
~GPIO ()=default | |
GPIO (GPIO &&other) noexcept=default | |
Move constructor. More... | |
GPIO & | operator= (GPIO &&other) noexcept=default |
Move assignment operator. More... | |
GPIO (const GPIO &)=delete | |
Copy constructor. More... | |
GPIO & | operator= (const GPIO &)=delete |
Copy assignment operator. More... | |
bool | Read () const |
Reads the current logic state of the managed GPIO. More... | |
void | Set (bool state) const |
Sets new GPIO state. More... | |
void | Toggle () const |
Toggles GPIO state. Logic High -> Logic Low and vice versa. More... | |
void | Reset () const |
Resets the GPIO to its original configuration, i.e. when the RESET button is first pushed. More... | |
STM32F4xx-specific HAL implementation for GPIO pins.
This abstraction layer provides simple Read/Write operations on GPIO pins. One GPIO object will correspond and manage one GPIO pinout from the MCU.
using core::stm32f4::GPIO::AltFn = uint8_t |
Type definition for GPIO alternate function selection.
See http://libopencm3.org/docs/latest/stm32f4/html/group__gpio__af__num.html.
|
strong |
Enumeration for GPIO output driver modes.
This enum is intended to replace equivalent macros used in libopencm3.
See http://libopencm3.org/docs/latest/stm32f4/html/group__gpio__output__type.html.
Enumerator | |
---|---|
kPushPull |
Drive GPIO output using push-pull (i.e. actively pushed to VCC/pulled to GND). |
kOpenDrain |
Drive GPIO output using open-drain (i.e. only pull to GND). |
|
strong |
Enumeration for different GPIO modes.
This enum is intended to replace equivalent macros used in libopencm3.
See http://libopencm3.org/docs/latest/stm32f4/html/group__gpio__mode.html.
Enumerator | |
---|---|
kInput |
Use this GPIO as digital input. Equivalent to libopencm3 macro |
kOutput |
Use this GPIO as digital output. Equivalent to libopencm3 macro |
kAF |
Use this GPIO as an alternate function. Equivalent to libopencm3 macro |
kAnalog |
Use this GPIO as analog I/O. Equivalent to libopencm3 macro |
|
strong |
Enumeration for different internal pull-up states.
This enum is intended to replace equivalent macros used in libopencm3.
See http://libopencm3.org/docs/latest/stm32f4/html/group__gpio__pup.html.
|
strong |
Enumeration for different GPIO output speeds.
This enum is intended to replace equivalent macros used in libopencm3.
See http://libopencm3.org/docs/latest/stm32f4/html/group__gpio__speed.html.
Enumerator | |
---|---|
k2MHz |
Output GPIO at 2MHz. Equivalent to libopencm3 macro |
k25MHz |
Output GPIO at 25MHz. Equivalent to libopencm3 macro |
k50MHz |
Output GPIO at 50MHz. Equivalent to libopencm3 macro |
k100MHz |
Output GPIO at 100MHz. Equivalent to libopencm3 macro |
|
explicit |
Conversion constructor.
config | Configuration for the GPIO. See GPIO::Config. |
core::stm32f4::GPIO::GPIO | ( | Pinout | pin, |
Mode | mode, | ||
Pullup | pullup, | ||
Speed | speed = Speed::k2MHz , |
||
DriverType | driver = DriverType::kPushPull , |
||
AltFn | altfn = 0x0 |
||
) |
Constructor for internal API use.
This constructor is equivalent to
. However, it is suggested to use that constructor instead for code readability.
|
default |
Default trivial destructor.
|
defaultnoexcept |
Move constructor.
other | GPIO object to move from |
|
delete |
Copy constructor.
This constructor is deleted because there should only be one object managing each GPIO pin, similar to std::unique_ptr
.
Copy assignment operator.
This constructor is deleted because there should only be one object managing each GPIO pin, similar to std::unique_ptr
.
bool core::stm32f4::GPIO::Read | ( | ) | const |
Reads the current logic state of the managed GPIO.
true
if high value, otherwise false
void core::stm32f4::GPIO::Reset | ( | ) | const |
Resets the GPIO to its original configuration, i.e. when the RESET button is first pushed.
void core::stm32f4::GPIO::Set | ( | bool | state | ) | const |
void core::stm32f4::GPIO::Toggle | ( | ) | const |
Toggles GPIO state. Logic High -> Logic Low and vice versa.