rk3399_arm_lvds/small_lcd/app_spi_lcd/Gpio.h

59 lines
1.1 KiB
C
Raw Permalink Normal View History

2024-03-05 03:46:18 +00:00
//
// Created by yingluo907 on 2019/4/11.
//
#ifndef HGSCANSERVICE_GPIO_H
#define HGSCANSERVICE_GPIO_H
#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);
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";
int gpio_fd;
char fname[128];
};
class GpioOut : public Gpio
{
public:
GpioOut(int port);
};
#endif //HGSCANSERVICE_GPIO_H