mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 00:36:00 +00:00
Merge pull request 'Added easier GPIO pin API' (#25) from feature/simpler-gpio into main
Reviewed-on: https://git.intern.spaceteamaachen.de/ALPAKA/sta-core/pulls/25 Reviewed-by: carlwachter <carlwachter@noreply.git.intern.spaceteamaachen.de>
This commit is contained in:
commit
7f5d918c96
@ -38,6 +38,24 @@ namespace sta
|
||||
*/
|
||||
virtual void setState(GpioPinState state) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the GPIO pin to high.
|
||||
*
|
||||
*/
|
||||
void setHigh();
|
||||
|
||||
/**
|
||||
* @brief Set the GPIO pin to low.
|
||||
*
|
||||
*/
|
||||
void setLow();
|
||||
|
||||
/**
|
||||
* @brief Set the GPIO pin to the opposite of the current state.
|
||||
*
|
||||
*/
|
||||
void toggle();
|
||||
|
||||
/**
|
||||
* @brief Get pin input state.
|
||||
*
|
||||
|
20
src/gpio_pin.cpp
Normal file
20
src/gpio_pin.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <sta/gpio_pin.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void GpioPin::setHigh()
|
||||
{
|
||||
setState(GpioPinState::GPIO_HIGH);
|
||||
}
|
||||
|
||||
void GpioPin::setLow()
|
||||
{
|
||||
setState(GpioPinState::GPIO_LOW);
|
||||
}
|
||||
|
||||
void GpioPin::toggle()
|
||||
{
|
||||
setState(getState() == GpioPinState::GPIO_HIGH ? GpioPinState::GPIO_LOW : GpioPinState::GPIO_HIGH);
|
||||
}
|
||||
} // namespace sta
|
Loading…
x
Reference in New Issue
Block a user