tx-gxx-linux/device/gxx-linux/motor_run/Gpio.h

54 lines
945 B
C
Raw Normal View History

#pragma once
#include <string>
class Gpio {
public:
enum GpioLevel {
Low,
High
};
public:
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;
public:
Gpio(int port);
~Gpio();
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;
}
private:
const std::string path_gpiobase = "/sys/class/gpio";
int port;
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);
};