eive-obsw/linux/gpio/GpioCookie.cpp

35 lines
1018 B
C++
Raw Normal View History

2021-02-14 12:35:08 +01:00
#include "GpioCookie.h"
2021-03-04 18:29:28 +01:00
#include <fsfw/serviceinterface/ServiceInterface.h>
2021-01-16 12:22:17 +01:00
GpioCookie::GpioCookie() {
}
2021-03-13 14:42:30 +01:00
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;
}
2021-03-04 18:29:28 +01:00
auto gpioMapIter = gpioMap.find(gpioId);
2021-01-16 12:22:17 +01:00
if(gpioMapIter == gpioMap.end()) {
2021-03-13 14:42:30 +01:00
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
2021-03-04 18:29:28 +01:00
if (statusPair.second == false) {
#if FSFW_VERBOSE_LEVEL >= 1
sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId <<
2021-03-24 12:53:25 +01:00
" to GPIO map" << std::endl;
2021-03-04 18:29:28 +01:00
#endif
return HasReturnvaluesIF::RETURN_FAILED;
2021-01-16 12:22:17 +01:00
}
2021-03-04 18:29:28 +01:00
return HasReturnvaluesIF::RETURN_OK;
2021-01-16 12:22:17 +01:00
}
2021-03-04 18:29:28 +01:00
#if FSFW_VERBOSE_LEVEL >= 1
sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
2021-01-16 12:22:17 +01:00
}
2021-03-04 18:29:28 +01:00
GpioMap GpioCookie::getGpioMap() const {
2021-01-16 12:22:17 +01:00
return gpioMap;
}
GpioCookie::~GpioCookie() {}