mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
28 lines
585 B
C++
28 lines
585 B
C++
#include <sta/devices/arduino/gpio_pin.hpp>
|
|
|
|
#ifdef STA_PLATFORM_ARDUINO
|
|
|
|
#include <sta/devices/arduino/hal.hpp>
|
|
|
|
namespace sta
|
|
{
|
|
ArduinoGpioPin::ArduinoGpioPin(uint16_t pin) : pin_{pin} { }
|
|
|
|
void ArduinoGpioPin::setState(GpioPinState state)
|
|
{
|
|
digitalWrite(pin_, (state == GpioPinState::GPIO_LOW) ? LOW : HIGH);
|
|
}
|
|
|
|
GpioPinState ArduinoGpioPin::getState()
|
|
{
|
|
return digitalRead(pin_) == HIGH ? GpioPinState::GPIO_HIGH : GpioPinState::GPIO_LOW;
|
|
}
|
|
|
|
uint16_t ArduinoGpioPin::getPin() const
|
|
{
|
|
return pin_;
|
|
}
|
|
|
|
} // namespace sta
|
|
|
|
#endif // STA_PLATFORM_ARDUINO
|