eive-obsw/linux/gpio/GpioCookie.cpp

25 lines
653 B
C++
Raw Normal View History

2021-02-14 12:35:08 +01:00
#include "GpioCookie.h"
2021-02-14 18:21:59 +01:00
#include <fsfw/serviceinterface/ServiceInterface.h>
2021-01-16 12:22:17 +01:00
GpioCookie::GpioCookie() {
}
void GpioCookie::addGpio(gpioId_t gpioId, GpioConfig_t gpioConfig){
2021-02-14 18:21:59 +01:00
auto gpioMapIter = gpioMap.find(gpioId);
2021-01-16 12:22:17 +01:00
if(gpioMapIter == gpioMap.end()) {
2021-02-14 18:21:59 +01:00
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
if (statusPair.second == false) {
sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId <<
"to GPIO map" << std::endl;
2021-01-16 12:22:17 +01:00
}
2021-02-14 18:21:59 +01:00
return;
2021-01-16 12:22:17 +01:00
}
2021-02-14 18:21:59 +01:00
sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl;
2021-01-16 12:22:17 +01:00
}
2021-02-14 18:21:59 +01:00
GpioMap GpioCookie::getGpioMap() const {
2021-01-16 12:22:17 +01:00
return gpioMap;
}
GpioCookie::~GpioCookie() {}