Update for Assembly Base #38

Merged
meierj merged 13 commits from mueller/master into eive/develop 2022-03-08 07:53:07 +01:00
2 changed files with 18 additions and 17 deletions
Showing only changes of commit fa73ad6731 - Show all commits

View File

@ -9,9 +9,9 @@ using gpioId_t = uint16_t;
namespace gpio {
enum class Levels : uint8_t { LOW = 0, HIGH = 1, NONE = 99 };
enum class Levels : int { LOW = 0, HIGH = 1, NONE = 99 };
enum class Direction : uint8_t { DIR_IN = 0, DIR_OUT = 1 };
enum class Direction : int { IN = 0, OUT = 1 };
enum class GpioOperation { READ, WRITE };
@ -20,7 +20,7 @@ enum class GpioTypes {
GPIO_REGULAR_BY_CHIP,
GPIO_REGULAR_BY_LABEL,
GPIO_REGULAR_BY_LINE_NAME,
TYPE_CALLBACK
CALLBACK
};
static constexpr gpioId_t NO_GPIO = -1;
@ -57,7 +57,7 @@ class GpioBase {
// Can be used to cast GpioBase to a concrete child implementation
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
std::string consumer;
gpio::Direction direction = gpio::Direction::DIR_IN;
gpio::Direction direction = gpio::Direction::IN;
gpio::Levels initValue = gpio::Levels::NONE;
};
@ -80,7 +80,7 @@ class GpiodRegularByChip : public GpiodRegularBase {
public:
GpiodRegularByChip()
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, std::string(),
gpio::Direction::DIR_IN, gpio::LOW, 0) {}
gpio::Direction::IN, gpio::Levels::LOW, 0) {}
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
gpio::Direction direction_, gpio::Levels initValue_)
@ -89,8 +89,8 @@ class GpiodRegularByChip : public GpiodRegularBase {
chipname(chipname_) {}
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_)
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_, gpio::Direction::DIR_IN,
gpio::LOW, lineNum_),
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_, gpio::Direction::IN,
gpio::Levels::LOW, lineNum_),
chipname(chipname_) {}
std::string chipname;
@ -105,8 +105,8 @@ class GpiodRegularByLabel : public GpiodRegularBase {
label(label_) {}
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_)
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_, gpio::Direction::DIR_IN,
gpio::LOW, lineNum_),
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_, gpio::Direction::IN,
gpio::Levels::LOW, lineNum_),
label(label_) {}
std::string label;
@ -127,7 +127,7 @@ class GpiodRegularByLineName : public GpiodRegularBase {
GpiodRegularByLineName(std::string lineName_, std::string consumer_)
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_,
gpio::Direction::DIR_IN, gpio::LOW),
gpio::Direction::IN, gpio::Levels::LOW),
lineName(lineName_) {}
std::string lineName;
@ -137,7 +137,7 @@ class GpioCallback : public GpioBase {
public:
GpioCallback(std::string consumer, gpio::Direction direction_, gpio::Levels initValue_,
gpio::gpio_cb_t callback, void* callbackArgs)
: GpioBase(gpio::GpioTypes::TYPE_CALLBACK, consumer, direction_, initValue_),
: GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
callback(callback),
callbackArgs(callbackArgs) {}

View File

@ -74,7 +74,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
configureGpioByLineName(gpioConfig.first, *regularGpio);
break;
}
case (gpio::GpioTypes::TYPE_CALLBACK): {
case (gpio::GpioTypes::CALLBACK): {
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioConfig.second);
if (gpioCallback->callback == nullptr) {
return GPIO_INVALID_INSTANCE;
@ -161,11 +161,12 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
consumer = regularGpio.consumer;
/* Configure direction and add a description to the GPIO */
switch (direction) {
case (gpio::DIR_OUT): {
result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio.initValue);
case (gpio::Direction::OUT): {
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
static_cast<int>(regularGpio.initValue));
break;
}
case (gpio::DIR_IN): {
case (gpio::Direction::IN): {
result = gpiod_line_request_input(lineHandle, consumer.c_str());
break;
}
@ -243,7 +244,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
if (regularGpio == nullptr) {
return GPIO_TYPE_FAILURE;
}
return driveGpio(gpioId, *regularGpio, gpio::LOW);
return driveGpio(gpioId, *regularGpio, gpio::Levels::LOW);
} else {
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioMapIter->second);
if (gpioCallback->callback == nullptr) {
@ -258,7 +259,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio,
gpio::Levels logicLevel) {
int result = gpiod_line_set_value(regularGpio.lineHandle, logicLevel);
int result = gpiod_line_set_value(regularGpio.lineHandle, static_cast<int>(logicLevel));
if (result < 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID " << gpioId