eive-obsw/linux/archive/gpio/GpioCookie.cpp
Robin Mueller 77c45c0de9
Some checks failed
EIVE/eive-obsw/pipeline/head Build queued...
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
applied formatting
2022-01-17 15:58:27 +01:00

33 lines
1.0 KiB
C++

#include "GpioCookie.h"
#include <fsfw/serviceinterface/ServiceInterface.h>
GpioCookie::GpioCookie() {}
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
if (gpioConfig == nullptr) {
sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
auto gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()) {
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
if (statusPair.second == false) {
#if FSFW_VERBOSE_LEVEL >= 1
sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
#if FSFW_VERBOSE_LEVEL >= 1
sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
GpioMap GpioCookie::getGpioMap() const { return gpioMap; }
GpioCookie::~GpioCookie() {}