old approach gpio lib
This commit is contained in:
26
bsp_q7s/comIF/cookies/GpioCookie.cpp
Normal file
26
bsp_q7s/comIF/cookies/GpioCookie.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bsp_q7s/comIF/cookies/GpioCookie.h>
|
||||
|
||||
GpioCookie::GpioCookie() {
|
||||
}
|
||||
|
||||
void GpioCookie::addGpio(gpioMap newEntry){
|
||||
gpioMapIter = gpioMap.find(newEntry);
|
||||
if(gpioMapIter == gpioMap.end()) {
|
||||
std::pair status = i2cDeviceMap.emplace(newEntry);
|
||||
if (status.second == false) {
|
||||
sif::error << "GpioCookie::addGpio: Failed to add GPIO "
|
||||
<< newEntry.first << "to GPIO map" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map "
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
GpioMap getGpioMap() const{
|
||||
return gpioMap;
|
||||
}
|
||||
|
||||
GpioCookie::~GpioCookie() {}
|
48
bsp_q7s/comIF/cookies/GpioCookie.h
Normal file
48
bsp_q7s/comIF/cookies/GpioCookie.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef SAM9G20_COMIF_COOKIES_I2C_COOKIE_H_
|
||||
#define SAM9G20_COMIF_COOKIES_I2C_COOKIE_H_
|
||||
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <string>
|
||||
|
||||
namespace Gpio {
|
||||
enum Direction {
|
||||
IN = 0,
|
||||
OUT = 1
|
||||
};
|
||||
}
|
||||
|
||||
using gpio_t = uint32_t;
|
||||
using direction_t = bool;
|
||||
using GpioMap = std::unordered_map<gpio_t, direction_t>;
|
||||
using GpioMapIter = GpioMap::iterator;
|
||||
|
||||
/**
|
||||
* @brief Cookie for the GpioComIF. Allows the GpioComIF to determine which
|
||||
* GPIOs to initialize and whether they should be configured as in- or
|
||||
* output.
|
||||
* @details One GpioCookie can hold multiple GPIO configurations. To add a new
|
||||
* GPIO configuration to a GpioCookie use the GpioCookie::addGpio
|
||||
* function.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class GpioCookie: public CookieIF {
|
||||
public:
|
||||
|
||||
GpioCookie();
|
||||
|
||||
virtual ~GpioCookie();
|
||||
|
||||
void addGpio(gpioMap newEntry);
|
||||
/**
|
||||
* @brief Get map with register GPIOs.
|
||||
*/
|
||||
GpioMap getGpioMap() const;
|
||||
|
||||
private:
|
||||
|
||||
GpioMap gpioMap;
|
||||
GpioMapIter gpioMapIter;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user