newtx/sdk/uart/Gpio.h

51 lines
916 B
C++

#pragma once
#include <string>
class Gpio
{
public:
enum GpioLevel
{
Low,
High
};
Gpio(int port);
int getPort();
void setValue(GpioLevel level);
GpioLevel getValue();
std::string getDirection();
void setDirection(std::string direction);
void setActive(GpioLevel level);
GpioLevel getActive();
void setEdge(std::string edge);
std::string getEdge();
std::string getValuePath()
{
return path_value;
}
static const std::string falling;
static const std::string rising;
static const std::string both;
static const std::string none;
static const std::string in;
static const std::string out;
private:
int port;
const std::string path_gpiobase = "/sys/class/gpio";
std::string path_value = "value";
std::string path_edge = "edge";
std::string path_direction = "direction";
std::string path_active_low = "active_low";
};
class GpioOut : public Gpio
{
public:
GpioOut(int port);
};