48 lines
900 B
C++
48 lines
900 B
C++
/*
|
|
* PinController.hpp
|
|
*
|
|
* Responsible for communicating with the actual GPIO hardware.
|
|
*
|
|
* Created on: May 6, 2018
|
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
*/
|
|
|
|
#ifndef SRC_UTILITIES_GPIOINTERFACE_H_
|
|
#define SRC_UTILITIES_GPIOINTERFACE_H_
|
|
|
|
#include <mutex>
|
|
#include <fstream>
|
|
#include <map>
|
|
|
|
namespace flippR_driver
|
|
{
|
|
|
|
class PinController
|
|
{
|
|
public:
|
|
PinController();
|
|
virtual ~PinController() = default;
|
|
|
|
void initialize_port_expander(const uint8_t i2c_address, const uint8_t pin_base);
|
|
|
|
protected:
|
|
static void initialize_output_pin(const uint8_t address);
|
|
static void initialize_input_pin(uint8_t address);
|
|
|
|
static void write_pin(uint8_t address, bool value);
|
|
|
|
static bool read_pin(uint8_t address);
|
|
|
|
public:
|
|
static std::once_flag GPIO_LIB_INITIALIZED;
|
|
|
|
static std::mutex lock;
|
|
|
|
std::map<uint8_t, uint8_t> initialized_port_extenders;
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif
|