37 lines
692 B
C
37 lines
692 B
C
|
//
|
||
|
// Created by robtor on 10.01.23.
|
||
|
//
|
||
|
|
||
|
#ifndef FLOATPUMP_GPICHANNEL_H
|
||
|
#define FLOATPUMP_GPICHANNEL_H
|
||
|
|
||
|
#include "stm32f4xx_hal.h"
|
||
|
|
||
|
namespace floatpump::io {
|
||
|
|
||
|
class GPIChannel {
|
||
|
public:
|
||
|
enum state {
|
||
|
ON, OFF
|
||
|
};
|
||
|
|
||
|
GPIChannel(GPIO_TypeDef *gpio, uint16_t pin, bool inverted = false);
|
||
|
|
||
|
void poll();
|
||
|
|
||
|
[[nodiscard]] state getState() const;
|
||
|
|
||
|
[[nodiscard]] bool getStateBool() const;
|
||
|
|
||
|
private:
|
||
|
GPIO_TypeDef *m_gpio;
|
||
|
uint16_t m_gpio_pin;
|
||
|
bool m_inverted;
|
||
|
|
||
|
state m_state = state::OFF;
|
||
|
};
|
||
|
|
||
|
} // io
|
||
|
|
||
|
#endif //FLOATPUMP_GPICHANNEL_H
|