mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
38 lines
631 B
C++
38 lines
631 B
C++
#include <sta/hal/gpio_pin.hpp>
|
|
#ifdef STA_HAL_GPIO_ENABLE
|
|
|
|
#include <sta/assert.hpp>
|
|
|
|
|
|
namespace sta
|
|
{
|
|
HalGpioPin::HalGpioPin(GPIO_TypeDef * port, uint16_t pin)
|
|
: port_{port}, pin_{pin}
|
|
{
|
|
STA_ASSERT(port != nullptr);
|
|
}
|
|
|
|
void HalGpioPin::setState(GpioPinState state)
|
|
{
|
|
HAL_GPIO_WritePin(port_, pin_, (state == GpioPinState::LOW) ? GPIO_PIN_RESET : GPIO_PIN_SET);
|
|
}
|
|
|
|
GPIO_TypeDef * HalGpioPin::getPort() const
|
|
{
|
|
return port_;
|
|
}
|
|
|
|
uint16_t HalGpioPin::getPin() const
|
|
{
|
|
return pin_;
|
|
}
|
|
|
|
uint8_t HalGpioPin::getIndex() const
|
|
{
|
|
return GPIO_GET_INDEX(port_);
|
|
}
|
|
} // namespace sta
|
|
|
|
|
|
#endif // STA_HAL_GPIO_ENABLE
|