/*
 * 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;

  static void initialize_output_pin(const uint8_t address);
  void initialize_port_expander(const uint8_t i2c_address, const uint8_t pin_base);

protected:
  static void initialize_input_pin(uint8_t address);

  static void write_pin(uint8_t address, bool value);

  static bool read_pin(uint8_t address);

  static void initialize_pins_output(const uint8_t pin_base, std::map<std::string, uint8_t>::iterator begin, std::map<std::string, uint8_t>::iterator end);

public:
  static std::once_flag GPIO_LIB_INITIALIZED;
};

}


#endif
