EIVE upstream #29
@ -11,7 +11,7 @@ namespace gpio {
|
|||||||
|
|
||||||
enum Levels : uint8_t { LOW = 0, HIGH = 1, NONE = 99 };
|
enum Levels : uint8_t { LOW = 0, HIGH = 1, NONE = 99 };
|
||||||
|
|
||||||
enum Direction : uint8_t { IN = 0, OUT = 1 };
|
enum Direction : uint8_t { DIR_IN = 0, DIR_OUT = 1 };
|
||||||
|
|
||||||
enum GpioOperation { READ, WRITE };
|
enum GpioOperation { READ, WRITE };
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ enum class GpioTypes {
|
|||||||
GPIO_REGULAR_BY_CHIP,
|
GPIO_REGULAR_BY_CHIP,
|
||||||
GPIO_REGULAR_BY_LABEL,
|
GPIO_REGULAR_BY_LABEL,
|
||||||
GPIO_REGULAR_BY_LINE_NAME,
|
GPIO_REGULAR_BY_LINE_NAME,
|
||||||
CALLBACK
|
TYPE_CALLBACK
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr gpioId_t NO_GPIO = -1;
|
static constexpr gpioId_t NO_GPIO = -1;
|
||||||
@ -57,7 +57,7 @@ class GpioBase {
|
|||||||
// Can be used to cast GpioBase to a concrete child implementation
|
// Can be used to cast GpioBase to a concrete child implementation
|
||||||
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
|
gpio::GpioTypes gpioType = gpio::GpioTypes::NONE;
|
||||||
std::string consumer;
|
std::string consumer;
|
||||||
gpio::Direction direction = gpio::Direction::IN;
|
gpio::Direction direction = gpio::Direction::DIR_IN;
|
||||||
gpio::Levels initValue = gpio::Levels::NONE;
|
gpio::Levels initValue = gpio::Levels::NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ class GpiodRegularBase : public GpioBase {
|
|||||||
class GpiodRegularByChip : public GpiodRegularBase {
|
class GpiodRegularByChip : public GpiodRegularBase {
|
||||||
public:
|
public:
|
||||||
GpiodRegularByChip()
|
GpiodRegularByChip()
|
||||||
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, std::string(), gpio::Direction::IN,
|
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, std::string(),
|
||||||
gpio::LOW, 0) {}
|
gpio::Direction::DIR_IN, gpio::LOW, 0) {}
|
||||||
|
|
||||||
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
|
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_,
|
||||||
gpio::Direction direction_, gpio::Levels initValue_)
|
gpio::Direction direction_, gpio::Levels initValue_)
|
||||||
@ -89,7 +89,7 @@ class GpiodRegularByChip : public GpiodRegularBase {
|
|||||||
chipname(chipname_) {}
|
chipname(chipname_) {}
|
||||||
|
|
||||||
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_)
|
GpiodRegularByChip(std::string chipname_, int lineNum_, std::string consumer_)
|
||||||
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_, gpio::Direction::IN,
|
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_CHIP, consumer_, gpio::Direction::DIR_IN,
|
||||||
gpio::LOW, lineNum_),
|
gpio::LOW, lineNum_),
|
||||||
chipname(chipname_) {}
|
chipname(chipname_) {}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class GpiodRegularByLabel : public GpiodRegularBase {
|
|||||||
label(label_) {}
|
label(label_) {}
|
||||||
|
|
||||||
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_)
|
GpiodRegularByLabel(std::string label_, int lineNum_, std::string consumer_)
|
||||||
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_, gpio::Direction::IN,
|
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LABEL, consumer_, gpio::Direction::DIR_IN,
|
||||||
gpio::LOW, lineNum_),
|
gpio::LOW, lineNum_),
|
||||||
label(label_) {}
|
label(label_) {}
|
||||||
|
|
||||||
@ -126,8 +126,8 @@ class GpiodRegularByLineName : public GpiodRegularBase {
|
|||||||
lineName(lineName_) {}
|
lineName(lineName_) {}
|
||||||
|
|
||||||
GpiodRegularByLineName(std::string lineName_, std::string consumer_)
|
GpiodRegularByLineName(std::string lineName_, std::string consumer_)
|
||||||
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_, gpio::Direction::IN,
|
: GpiodRegularBase(gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME, consumer_,
|
||||||
gpio::LOW),
|
gpio::Direction::DIR_IN, gpio::LOW),
|
||||||
lineName(lineName_) {}
|
lineName(lineName_) {}
|
||||||
|
|
||||||
std::string lineName;
|
std::string lineName;
|
||||||
@ -137,7 +137,7 @@ class GpioCallback : public GpioBase {
|
|||||||
public:
|
public:
|
||||||
GpioCallback(std::string consumer, gpio::Direction direction_, gpio::Levels initValue_,
|
GpioCallback(std::string consumer, gpio::Direction direction_, gpio::Levels initValue_,
|
||||||
gpio::gpio_cb_t callback, void* callbackArgs)
|
gpio::gpio_cb_t callback, void* callbackArgs)
|
||||||
: GpioBase(gpio::GpioTypes::CALLBACK, consumer, direction_, initValue_),
|
: GpioBase(gpio::GpioTypes::TYPE_CALLBACK, consumer, direction_, initValue_),
|
||||||
callback(callback),
|
callback(callback),
|
||||||
callbackArgs(callbackArgs) {}
|
callbackArgs(callbackArgs) {}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
|
|||||||
configureGpioByLineName(gpioConfig.first, *regularGpio);
|
configureGpioByLineName(gpioConfig.first, *regularGpio);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (gpio::GpioTypes::CALLBACK): {
|
case (gpio::GpioTypes::TYPE_CALLBACK): {
|
||||||
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
auto gpioCallback = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
||||||
if (gpioCallback->callback == nullptr) {
|
if (gpioCallback->callback == nullptr) {
|
||||||
return GPIO_INVALID_INSTANCE;
|
return GPIO_INVALID_INSTANCE;
|
||||||
@ -161,11 +161,11 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
|
|||||||
consumer = regularGpio.consumer;
|
consumer = regularGpio.consumer;
|
||||||
/* Configure direction and add a description to the GPIO */
|
/* Configure direction and add a description to the GPIO */
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case (gpio::OUT): {
|
case (gpio::DIR_OUT): {
|
||||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio.initValue);
|
result = gpiod_line_request_output(lineHandle, consumer.c_str(), regularGpio.initValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (gpio::IN): {
|
case (gpio::DIR_IN): {
|
||||||
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (gpio::GpioTypes::CALLBACK): {
|
case (gpio::GpioTypes::TYPE_CALLBACK): {
|
||||||
auto callbackGpio = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
auto callbackGpio = dynamic_cast<GpioCallback*>(gpioConfig.second);
|
||||||
if (callbackGpio == nullptr) {
|
if (callbackGpio == nullptr) {
|
||||||
return GPIO_TYPE_FAILURE;
|
return GPIO_TYPE_FAILURE;
|
||||||
@ -366,13 +366,13 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
|
|||||||
case (gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
case (gpio::GpioTypes::GPIO_REGULAR_BY_CHIP):
|
||||||
case (gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):
|
case (gpio::GpioTypes::GPIO_REGULAR_BY_LABEL):
|
||||||
case (gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME): {
|
case (gpio::GpioTypes::GPIO_REGULAR_BY_LINE_NAME): {
|
||||||
if (gpioType == gpio::GpioTypes::NONE or gpioType == gpio::GpioTypes::CALLBACK) {
|
if (gpioType == gpio::GpioTypes::NONE or gpioType == gpio::GpioTypes::TYPE_CALLBACK) {
|
||||||
eraseDuplicateDifferentType = true;
|
eraseDuplicateDifferentType = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (gpio::GpioTypes::CALLBACK): {
|
case (gpio::GpioTypes::TYPE_CALLBACK): {
|
||||||
if (gpioType != gpio::GpioTypes::CALLBACK) {
|
if (gpioType != gpio::GpioTypes::TYPE_CALLBACK) {
|
||||||
eraseDuplicateDifferentType = true;
|
eraseDuplicateDifferentType = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
||||||
std::string consumer, gpio::Direction direction,
|
std::string consumer, gpio::Direction direction,
|
||||||
int initValue) {
|
gpio::Levels initValue) {
|
||||||
if (cookie == nullptr) {
|
if (cookie == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@ namespace gpio {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
ReturnValue_t createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
||||||
std::string consumer, gpio::Direction direction, int initValue);
|
std::string consumer, gpio::Direction direction,
|
||||||
|
gpio::Levels initValue);
|
||||||
} // namespace gpio
|
} // namespace gpio
|
||||||
|
|
||||||
#endif /* BSP_RPI_GPIO_GPIORPI_H_ */
|
#endif /* BSP_RPI_GPIO_GPIORPI_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user