47 lines
788 B
C++
47 lines
788 B
C++
/*
|
|
* GPIOInterface.cpp
|
|
*
|
|
* Created on: Jun 15, 2018
|
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
*/
|
|
|
|
#include "GPIOInterface.h"
|
|
|
|
#include "utility/config.h"
|
|
|
|
#include "wiringPi/wiringPi.h"
|
|
#include "json/json.hpp"
|
|
|
|
namespace flippR_driver
|
|
{
|
|
|
|
std::once_flag GPIOInterface::GPIO_LIB_INITIALIZED;
|
|
|
|
GPIOInterface::GPIOInterface()
|
|
{
|
|
std::call_once(GPIO_LIB_INITIALIZED, wiringPiSetup);
|
|
}
|
|
|
|
void GPIOInterface::initialize_input_pin(uint8_t address)
|
|
{
|
|
pinMode(address, INPUT);
|
|
}
|
|
|
|
void GPIOInterface::initialize_output_pin(uint8_t address)
|
|
{
|
|
pinMode(address, OUTPUT);
|
|
}
|
|
|
|
void GPIOInterface::write_pin(uint8_t address, uint8_t data)
|
|
{
|
|
digitalWrite(address, data);
|
|
}
|
|
|
|
bool GPIOInterface::read_pin(uint8_t address)
|
|
{
|
|
return PULLDOWN == digitalRead(address);
|
|
}
|
|
|
|
|
|
}
|