moved some files

This commit is contained in:
Robin Müller 2021-02-14 12:57:09 +01:00 committed by Robin Mueller
parent cb9e9d3ec0
commit 377c4d1ad2
5 changed files with 59 additions and 62 deletions

View File

@ -2,8 +2,8 @@
#define TEST_TESTTASKS_LIBGPIODTEST_H_
#include "TestTask.h"
#include <bsp_q7s/gpio/GpioIF.h>
#include <bsp_q7s/gpio/cookies/GpioCookie.h>
#include <linux/gpio/GpioIF.h>
#include <linux/gpio/GpioCookie.h>
#include <fsfw/objectmanager/SystemObject.h>
/**

View File

@ -1,4 +0,0 @@
target_sources(${TARGET_NAME} PUBLIC
LinuxLibgpioIF.cpp
)

View File

@ -1,5 +1,6 @@
target_sources(${TARGET_NAME} PUBLIC
GpioCookie.cpp
LinuxLibgpioIF.cpp
)

View File

@ -12,36 +12,36 @@ LinuxLibgpioIF::~LinuxLibgpioIF() {
}
ReturnValue_t LinuxLibgpioIF::initialize(CookieIF * cookie){
ReturnValue_t result;
GpioMap mapToAdd;
ReturnValue_t result;
GpioMap mapToAdd;
if(cookie == nullptr) {
sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl;
return RETURN_FAILED;
}
GpioCookie* gpioCookie = dynamic_cast<GpioCookie*>(cookie);
if(gpioCookie == nullptr) {
sif::error << "LinuxLibgpioIF: Invalid Gpio Cookie!"
<< std::endl;
return RETURN_FAILED;
}
if(cookie == nullptr) {
sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl;
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();
mapToAdd = gpioCookie->getGpioMap();
result = checkForConflicts(mapToAdd);
if (result != RETURN_OK){
return result;
}
result = checkForConflicts(mapToAdd);
if (result != RETURN_OK){
return result;
}
result = configureGpios(&mapToAdd);
if (result != RETURN_OK) {
return RETURN_FAILED;
}
result = configureGpios(&mapToAdd);
if (result != RETURN_OK) {
return RETURN_FAILED;
}
/* Register new GPIOs in gpioMap*/
gpioMap.insert(mapToAdd.begin(), mapToAdd.end());
/* Register new GPIOs in gpioMap*/
gpioMap.insert(mapToAdd.begin(), mapToAdd.end());
return RETURN_OK;
return RETURN_OK;
}
ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
@ -100,7 +100,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
break;
default:
sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified"
<< std::endl;
<< std::endl;
return RETURN_FAILED;
}
/**
@ -113,33 +113,33 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
}
ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId){
return driveGpio(gpioId, 1);
return driveGpio(gpioId, 1);
}
ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId){
return driveGpio(gpioId, 0);
return driveGpio(gpioId, 0);
}
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
unsigned int logiclevel) {
unsigned int logiclevel) {
int result;
struct gpiod_line *lineHandle;
struct gpiod_line *lineHandle;
gpioMapIter = gpioMap.find(gpioId);
gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()){
sif::debug << "LinuxLibgpioIF::driveGpio: Unknown gpio id " << gpioId << std::endl;
return RETURN_FAILED;
}
lineHandle = gpioMapIter->second.lineHandle;
result = gpiod_line_set_value(lineHandle, logiclevel);
if (result < 0) {
sif::error << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID "
<< gpioId << " to logic level " << logiclevel << std::endl;
return DRIVE_GPIO_FAILURE;
}
result = gpiod_line_set_value(lineHandle, logiclevel);
if (result < 0) {
sif::error << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID "
<< gpioId << " to logic level " << logiclevel << std::endl;
return DRIVE_GPIO_FAILURE;
}
return RETURN_OK;
return RETURN_OK;
}
ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
@ -158,23 +158,23 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
}
ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap mapToAdd){
gpioId_t gpioId;
GpioMapIter mapToAddIter = mapToAdd.begin();
for(; mapToAddIter != mapToAdd.end(); mapToAddIter++){
gpioId = mapToAddIter->first;
gpioMapIter = gpioMap.find(gpioId);
if(gpioMapIter != mapToAdd.end()){
/* An entry for this GPIO already exists. Check if configuration
* of direction is equivalent */
if (mapToAddIter->second.direction != gpioMapIter->second.direction){
sif::error << "LinuxLibgpioIF::checkForConflicts: Detected conflict "
<< "for GPIO " << mapToAddIter->first << std::endl;
return RETURN_OK;
}
/* Remove element from map to add because a entry for this GPIO
* already exists */
mapToAdd.erase(mapToAddIter);
}
}
return RETURN_OK;
gpioId_t gpioId;
GpioMapIter mapToAddIter = mapToAdd.begin();
for(; mapToAddIter != mapToAdd.end(); mapToAddIter++){
gpioId = mapToAddIter->first;
gpioMapIter = gpioMap.find(gpioId);
if(gpioMapIter != mapToAdd.end()){
/* An entry for this GPIO already exists. Check if configuration
* of direction is equivalent */
if (mapToAddIter->second.direction != gpioMapIter->second.direction){
sif::error << "LinuxLibgpioIF::checkForConflicts: Detected conflict "
<< "for GPIO " << mapToAddIter->first << std::endl;
return RETURN_OK;
}
/* Remove element from map to add because a entry for this GPIO
* already exists */
mapToAdd.erase(mapToAddIter);
}
}
return RETURN_OK;
}