Added gpio pin implementation for raspi

This commit is contained in:
dvdb97
2023-05-09 21:24:55 +01:00
parent b2a92ea87e
commit d2806f1651
5 changed files with 87 additions and 10 deletions

21
src/raspi/gpio_pin.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include <sta/raspi/gpio_pin.hpp>
#ifdef STA_RASPI_GPIO_ENABLED
#include <sta/assert.hpp>
#include <sta/lang.hpp>
namespace sta
{
RaspiGpioPin::RaspiGpioPin(uint8_t pin, GpioMode mode) : pin_{pin}, mode_{mode}
{
pinMode(pin, mode == GpioMode::GPIO_INPUT ? INPUT : OUTPUT);
}
void RaspiGpioPin::setState(GpioPinState state)
{
digitalWrite(pin_, state == GpioPinState::GPIO_LOW ? LOW : HIGH);
}
} // namespace sta
#endif // STA_ARDUINO_GPIO_ENABLED