eive-obsw/bsp_rpi/boardtest/RPiGPIO.h

42 lines
903 B
C
Raw Normal View History

2021-01-14 00:40:30 +01:00
#ifndef BSP_RPI_BOARDTEST_RPIGPIO_H_
#define BSP_RPI_BOARDTEST_RPIGPIO_H_
#include <cstdint>
/**
* @brief Really simple C++ GPIO wrapper for the Raspberry Pi, using the sysfs interface.
* Use BCM pins notation (https://pinout.xyz/#)
*
*/
class RPiGPIO {
public:
enum Directions {
IN = 0,
OUT = 1
};
enum States {
LOW = 0,
HIGH = 1
};
static int enablePin(int pin);
static int disablePin(int pin);
static int pinDirection(int pin, Directions dir);
static int readPin(int pin);
static int writePin(int pin, States state);
private:
static constexpr uint8_t BUFFER_MAX = 3;
static constexpr uint8_t DIRECTION_MAX = 35;
static constexpr uint8_t VALUE_MAX = 30;
static constexpr uint8_t IN_WRITE_SIZE = 3;
static constexpr uint8_t OUT_WRITE_SIZE = 4;
};
#endif /* BSP_RPI_BOARDTEST_RPIGPIO_H_ */