corrected include guards, changed GpioIF prototype
This commit is contained in:
parent
41b70efcb9
commit
5c9b5627c6
@ -3,6 +3,7 @@
|
|||||||
#include <fsfwconfig/devices/powerSwitcherList.h>
|
#include <fsfwconfig/devices/powerSwitcherList.h>
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
#include <devices/gpioIds.h>
|
#include <devices/gpioIds.h>
|
||||||
|
#include <linux/gpio/GpioCookie.h>
|
||||||
|
|
||||||
HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_,
|
HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_,
|
||||||
CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) :
|
CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) :
|
||||||
@ -43,7 +44,7 @@ ReturnValue_t HeaterHandler::initialize() {
|
|||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = gpioInterface->initialize(gpioCookie);
|
result = gpioInterface->initialize(dynamic_cast<GpioCookie*>(gpioCookie));
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl;
|
sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl;
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BSP_LINUX_COMIF_COOKIES_CSPCOMIF_H_
|
#ifndef LINUX_CSP_CSPCOMIF_H_
|
||||||
#define BSP_LINUX_COMIF_COOKIES_CSPCOMIF_H_
|
#define LINUX_CSP_CSPCOMIF_H_
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
@ -86,4 +86,4 @@ private:
|
|||||||
void initiatePingRequest(uint8_t cspAddress, uint16_t querySize);
|
void initiatePingRequest(uint8_t cspAddress, uint16_t querySize);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_LINUX_COMIF_COOKIES_CSPCOMIF_H_ */
|
#endif /* LINUX_CSP_CSPCOMIF_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BSP_Q7S_COMIF_COOKIES_CSPCOOKIE_H_
|
#ifndef LINUX_CSP_CSPCOOKIE_H_
|
||||||
#define BSP_Q7S_COMIF_COOKIES_CSPCOOKIE_H_
|
#define LINUX_CSP_CSPCOOKIE_H_
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/CookieIF.h>
|
#include <fsfw/devicehandlers/CookieIF.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -24,4 +24,4 @@ private:
|
|||||||
uint8_t cspAddress;
|
uint8_t cspAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_COMIF_COOKIES_CSPCOOKIE_H_ */
|
#endif /* LINUX_CSP_CSPCOOKIE_H_ */
|
||||||
|
@ -1,48 +1,10 @@
|
|||||||
#ifndef SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_
|
#ifndef LINUX_GPIO_GPIOCOOKIE_H_
|
||||||
#define SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_
|
#define LINUX_GPIO_GPIOCOOKIE_H_
|
||||||
|
|
||||||
#include "GpioIF.h"
|
#include "GpioIF.h"
|
||||||
|
#include "gpioDefinitions.h"
|
||||||
#include <fsfw/devicehandlers/CookieIF.h>
|
#include <fsfw/devicehandlers/CookieIF.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace gpio {
|
|
||||||
enum Direction {
|
|
||||||
IN = 0,
|
|
||||||
OUT = 1
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Struct containing information about the GPIO to use. This is
|
|
||||||
* required by the libgpiod to access and drive a GPIO.
|
|
||||||
* @param chipname String of the chipname specifying the group which contains the GPIO to
|
|
||||||
* access. E.g. gpiochip0. To detect names of GPIO groups run gpiodetect on
|
|
||||||
* the linux command line.
|
|
||||||
* @param lineNum The offset of the GPIO within the GPIO group.
|
|
||||||
* @param consumer Name of the consumer. Simply a description of the GPIO configuration.
|
|
||||||
* @param direction Specifies whether the GPIO should be used as in- or output.
|
|
||||||
* @param initValue Defines the initial state of the GPIO when configured as output.
|
|
||||||
* Only required for output GPIOs.
|
|
||||||
* @param lineHandle The handle returned by gpiod_chip_get_line will be later written to this
|
|
||||||
* pointer.
|
|
||||||
*/
|
|
||||||
typedef struct GpioConfig {
|
|
||||||
GpioConfig(std::string chipname_, int lineNum_, std::string consumer_,
|
|
||||||
gpio::Direction direction_, int initValue_):
|
|
||||||
chipname(chipname_), lineNum(lineNum_), consumer(consumer_),
|
|
||||||
direction(direction_), initValue(initValue_) {}
|
|
||||||
std::string chipname;
|
|
||||||
int lineNum;
|
|
||||||
std::string consumer;
|
|
||||||
gpio::Direction direction;
|
|
||||||
int initValue;
|
|
||||||
struct gpiod_line* lineHandle = nullptr;
|
|
||||||
} GpioConfig_t;
|
|
||||||
|
|
||||||
using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>;
|
|
||||||
using GpioMapIter = GpioMap::iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cookie for the GpioIF. Allows the GpioIF to determine which
|
* @brief Cookie for the GpioIF. Allows the GpioIF to determine which
|
||||||
@ -74,4 +36,4 @@ private:
|
|||||||
GpioMap gpioMap;
|
GpioMap gpioMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif /* LINUX_GPIO_GPIOCOOKIE_H_ */
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#ifndef BSP_Q7S_GPIO_GPIOIF_H_
|
#ifndef LINUX_GPIO_GPIOIF_H_
|
||||||
#define BSP_Q7S_GPIO_GPIOIF_H_
|
#define LINUX_GPIO_GPIOIF_H_
|
||||||
|
|
||||||
|
#include "gpioDefinitions.h"
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <fsfw/devicehandlers/CookieIF.h>
|
#include <fsfw/devicehandlers/CookieIF.h>
|
||||||
|
|
||||||
typedef uint16_t gpioId_t;
|
class GpioCookie;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class defines the interface for objects requiring the control
|
* @brief This class defines the interface for objects requiring the control
|
||||||
@ -17,11 +18,11 @@ public:
|
|||||||
virtual ~GpioIF() {};
|
virtual ~GpioIF() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called by the GPIO using object.
|
* @brief Called by the GPIO using object.
|
||||||
* @param cookie Cookie specifying informations of the GPIOs required
|
* @param cookie Cookie specifying informations of the GPIOs required
|
||||||
* by a object.
|
* by a object.
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t initialize(CookieIF* cookie) = 0;
|
virtual ReturnValue_t initialize(GpioCookie* cookie) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief By implementing this function a child must provide the
|
* @brief By implementing this function a child must provide the
|
||||||
@ -49,4 +50,4 @@ public:
|
|||||||
virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0;
|
virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_GPIO_GPIOIF_H_ */
|
#endif /* LINUX_GPIO_GPIOIF_H_ */
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#include "LinuxLibgpioIF.h"
|
#include "LinuxLibgpioIF.h"
|
||||||
|
#include "GpioCookie.h"
|
||||||
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -11,22 +13,14 @@ LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) {
|
|||||||
LinuxLibgpioIF::~LinuxLibgpioIF() {
|
LinuxLibgpioIF::~LinuxLibgpioIF() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::initialize(CookieIF * cookie){
|
ReturnValue_t LinuxLibgpioIF::initialize(GpioCookie* gpioCookie){
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
GpioMap mapToAdd;
|
if(gpioCookie == nullptr) {
|
||||||
|
|
||||||
if(cookie == nullptr) {
|
|
||||||
sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl;
|
sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl;
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
GpioCookie* gpioCookie = dynamic_cast<GpioCookie*>(cookie);
|
|
||||||
if(gpioCookie == nullptr) {
|
|
||||||
sif::error << "LinuxLibgpioIF: Invalid Gpio Cookie!"
|
|
||||||
<< std::endl;
|
|
||||||
return RETURN_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
mapToAdd = gpioCookie->getGpioMap();
|
GpioMap mapToAdd = gpioCookie->getGpioMap();
|
||||||
|
|
||||||
result = checkForConflicts(mapToAdd);
|
result = checkForConflicts(mapToAdd);
|
||||||
if (result != RETURN_OK){
|
if (result != RETURN_OK){
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_
|
#ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_
|
||||||
#define BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_
|
#define LINUX_GPIO_LINUXLIBGPIOIF_H_
|
||||||
|
|
||||||
#include <linux/gpio/GpioIF.h>
|
#include <linux/gpio/GpioIF.h>
|
||||||
#include <linux/gpio/GpioCookie.h>
|
|
||||||
#include <fsfwconfig/returnvalues/classIds.h>
|
#include <fsfwconfig/returnvalues/classIds.h>
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
|
|
||||||
|
class GpioCookie;
|
||||||
/**
|
/**
|
||||||
* @brief This class implements the GpioIF for a linux based system. The
|
* @brief This class implements the GpioIF for a linux based system. The
|
||||||
* implementation is based on the libgpiod lib which requires linux 4.8
|
* implementation is based on the libgpiod lib which requires linux 4.8
|
||||||
@ -23,7 +23,7 @@ public:
|
|||||||
LinuxLibgpioIF(object_id_t objectId);
|
LinuxLibgpioIF(object_id_t objectId);
|
||||||
virtual ~LinuxLibgpioIF();
|
virtual ~LinuxLibgpioIF();
|
||||||
|
|
||||||
ReturnValue_t initialize(CookieIF* gpioCookie) override;
|
ReturnValue_t initialize(GpioCookie* gpioCookie) override;
|
||||||
ReturnValue_t pullHigh(gpioId_t gpioId) override;
|
ReturnValue_t pullHigh(gpioId_t gpioId) override;
|
||||||
ReturnValue_t pullLow(gpioId_t gpioId) override;
|
ReturnValue_t pullLow(gpioId_t gpioId) override;
|
||||||
ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override;
|
ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override;
|
||||||
@ -58,4 +58,4 @@ private:
|
|||||||
ReturnValue_t configureGpios(GpioMap& mapToAdd);
|
ReturnValue_t configureGpios(GpioMap& mapToAdd);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_ */
|
#endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */
|
||||||
|
46
linux/gpio/gpioDefinitions.h
Normal file
46
linux/gpio/gpioDefinitions.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef LINUX_GPIO_GPIODEFINITIONS_H_
|
||||||
|
#define LINUX_GPIO_GPIODEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
using gpioId_t = uint16_t;
|
||||||
|
|
||||||
|
namespace gpio {
|
||||||
|
enum Direction {
|
||||||
|
IN = 0,
|
||||||
|
OUT = 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Struct containing information about the GPIO to use. This is
|
||||||
|
* required by the libgpiod to access and drive a GPIO.
|
||||||
|
* @param chipname String of the chipname specifying the group which contains the GPIO to
|
||||||
|
* access. E.g. gpiochip0. To detect names of GPIO groups run gpiodetect on
|
||||||
|
* the linux command line.
|
||||||
|
* @param lineNum The offset of the GPIO within the GPIO group.
|
||||||
|
* @param consumer Name of the consumer. Simply a description of the GPIO configuration.
|
||||||
|
* @param direction Specifies whether the GPIO should be used as in- or output.
|
||||||
|
* @param initValue Defines the initial state of the GPIO when configured as output.
|
||||||
|
* Only required for output GPIOs.
|
||||||
|
* @param lineHandle The handle returned by gpiod_chip_get_line will be later written to this
|
||||||
|
* pointer.
|
||||||
|
*/
|
||||||
|
typedef struct GpioConfig {
|
||||||
|
GpioConfig(std::string chipname_, int lineNum_, std::string consumer_,
|
||||||
|
gpio::Direction direction_, int initValue_):
|
||||||
|
chipname(chipname_), lineNum(lineNum_), consumer(consumer_),
|
||||||
|
direction(direction_), initValue(initValue_) {}
|
||||||
|
std::string chipname;
|
||||||
|
int lineNum;
|
||||||
|
std::string consumer;
|
||||||
|
gpio::Direction direction;
|
||||||
|
int initValue;
|
||||||
|
struct gpiod_line* lineHandle = nullptr;
|
||||||
|
} GpioConfig_t;
|
||||||
|
|
||||||
|
using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>;
|
||||||
|
using GpioMapIter = GpioMap::iterator;
|
||||||
|
|
||||||
|
#endif /* LINUX_GPIO_GPIODEFINITIONS_H_ */
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef BSP_Q7S_COMIF_I2COMIF_H_
|
#ifndef LINUX_I2C_I2COMIF_H_
|
||||||
#define BSP_Q7S_COMIF_I2COMIF_H_
|
#define LINUX_I2C_I2COMIF_H_
|
||||||
|
|
||||||
#include "I2cCookie.h"
|
#include "I2cCookie.h"
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
@ -56,4 +56,4 @@ private:
|
|||||||
address_t i2cAddress, int* fileDescriptor);
|
address_t i2cAddress, int* fileDescriptor);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_COMIF_I2COMIF_H_ */
|
#endif /* LINUX_I2C_I2COMIF_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef SAM9G20_COMIF_COOKIES_I2C_COOKIE_H_
|
#ifndef LINUX_I2C_I2CCOOKIE_H_
|
||||||
#define SAM9G20_COMIF_COOKIES_I2C_COOKIE_H_
|
#define LINUX_I2C_I2CCOOKIE_H_
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/CookieIF.h>
|
#include <fsfw/devicehandlers/CookieIF.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -34,4 +34,4 @@ private:
|
|||||||
std::string deviceFile;
|
std::string deviceFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif /* LINUX_I2C_I2CCOOKIE_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user