refactored utility namespace
This commit is contained in:
47
FlippR-Driver/src/utility/GPIOInterface.cpp
Normal file
47
FlippR-Driver/src/utility/GPIOInterface.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* GPIOInterface.cpp
|
||||
*
|
||||
* Created on: Jun 15, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#include "GPIOInterface.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "wiringPi/wiringPi.h"
|
||||
#include "json/json.hpp"
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
std::once_flag GPIOInterface::GPIO_LIB_INITIALIZED;
|
||||
|
||||
void GPIOInterface::initialize_input_pin(char address)
|
||||
{
|
||||
pinMode(address, INPUT);
|
||||
}
|
||||
|
||||
void GPIOInterface::write_pin(char address, char data)
|
||||
{
|
||||
digitalWrite(address, data);
|
||||
}
|
||||
|
||||
bool GPIOInterface::read_pin(char address)
|
||||
{
|
||||
return PULLDOWN == digitalRead(address);
|
||||
}
|
||||
|
||||
void GPIOInterface::initialize_output_pin(char address)
|
||||
{
|
||||
pinMode(address, OUTPUT);
|
||||
}
|
||||
|
||||
GPIOInterface::GPIOInterface()
|
||||
{
|
||||
std::call_once(GPIO_LIB_INITIALIZED, wiringPiSetup);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user