mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 00:36:00 +00:00
62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#ifndef STA_CORE_RASPI_GPIO_PIN_HPP
|
|
#define STA_CORE_RASPI_GPIO_PIN_HPP
|
|
|
|
// Only enable module on Raspi platform w/ HAL GPIO module enabled
|
|
#include <sta/config.hpp>
|
|
#ifdef STA_PLATFORM_RASPI
|
|
# include <sta/devices/raspi/hal.hpp>
|
|
# define STA_RASPI_GPIO_ENABLED
|
|
#endif // STA_PLATFORM_RASPI
|
|
|
|
#if defined(STA_RASPI_GPIO_ENABLED) || defined(DOXYGEN)
|
|
|
|
#include <sta/gpio_pin.hpp>
|
|
#include <cstdint>
|
|
|
|
namespace sta
|
|
{
|
|
enum class GpioMode {
|
|
GPIO_OUTPUT,
|
|
GPIO_INPUT
|
|
};
|
|
|
|
/**
|
|
* @brief A wrapper class for Raspi GPIO pins.
|
|
*
|
|
* @ingroup sta_core_raspi
|
|
*/
|
|
class RaspiGpioPin : public GpioPin
|
|
{
|
|
public:
|
|
/**
|
|
* @param pin Pin index
|
|
* @param mode The mode of the GPIO pin. Either INPUT or OUTPUT
|
|
*/
|
|
RaspiGpioPin(uint8_t pin, GpioMode mode);
|
|
|
|
/**
|
|
* @brief Set the state of the GPIO pin.
|
|
*
|
|
* @param state The state of the GPIO pin. Either HIGH or LOW
|
|
*/
|
|
void setState(GpioPinState state) override;
|
|
|
|
/**
|
|
* @brief Get the state of the GPIO pin.
|
|
*
|
|
* @return The state of the GPIO pin. Either HIGH or LOW
|
|
*/
|
|
GpioPinState getState() override;
|
|
|
|
/// @brief Dummy GPIO pin
|
|
static RaspiGpioPin * DUMMY_GPIO;
|
|
|
|
private:
|
|
uint8_t pin_;
|
|
GpioMode mode_;
|
|
};
|
|
} // namespace sta
|
|
|
|
#endif // STA_RASPI_GPIO_ENABLED
|
|
|
|
#endif // STA_CORE_RASPI_GPIO_PIN_HPP
|