sta-core/include/sta/gpio_pin.hpp
2024-04-18 00:01:14 +02:00

73 lines
1.2 KiB
C++

/**
* @file
* @brief GPIO pin interface definitions.
*/
#ifndef STA_CORE_GPIO_PIN_HPP
#define STA_CORE_GPIO_PIN_HPP
namespace sta
{
/**
* @defgroup sta_core_gpio GPIO
* @ingroup sta_core
* @brief GPIO pins.
* @{
*/
/**
* @brief GPIO pin state.
*/
enum class GpioPinState
{
GPIO_LOW,
GPIO_HIGH
};
/**
* @brief Interface for GPIO pins.
*/
class GpioPin
{
public:
/**
* @brief Set pin output state.
*
* @param state Output state
*/
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.
*
* @param state Input state
*/
virtual GpioPinState getState() = 0;
};
/** @} */
} // namespace sta
#endif // STA_CORE_GPIO_PIN_HPP