moved some files
This commit is contained in:
parent
56c89a0751
commit
f006188814
@ -2,8 +2,8 @@
|
|||||||
#define TEST_TESTTASKS_LIBGPIODTEST_H_
|
#define TEST_TESTTASKS_LIBGPIODTEST_H_
|
||||||
|
|
||||||
#include "TestTask.h"
|
#include "TestTask.h"
|
||||||
#include <bsp_q7s/gpio/GpioIF.h>
|
#include <linux/gpio/GpioIF.h>
|
||||||
#include <bsp_q7s/gpio/cookies/GpioCookie.h>
|
#include <linux/gpio/GpioCookie.h>
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
target_sources(${TARGET_NAME} PUBLIC
|
|
||||||
LinuxLibgpioIF.cpp
|
|
||||||
)
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
|||||||
target_sources(${TARGET_NAME} PUBLIC
|
target_sources(${TARGET_NAME} PUBLIC
|
||||||
GpioCookie.cpp
|
GpioCookie.cpp
|
||||||
|
LinuxLibgpioIF.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,36 +12,36 @@ LinuxLibgpioIF::~LinuxLibgpioIF() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::initialize(CookieIF * cookie){
|
ReturnValue_t LinuxLibgpioIF::initialize(CookieIF * cookie){
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
GpioMap mapToAdd;
|
GpioMap mapToAdd;
|
||||||
|
|
||||||
if(cookie == 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);
|
GpioCookie* gpioCookie = dynamic_cast<GpioCookie*>(cookie);
|
||||||
if(gpioCookie == nullptr) {
|
if(gpioCookie == nullptr) {
|
||||||
sif::error << "LinuxLibgpioIF: Invalid Gpio Cookie!"
|
sif::error << "LinuxLibgpioIF: Invalid Gpio Cookie!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapToAdd = gpioCookie->getGpioMap();
|
mapToAdd = gpioCookie->getGpioMap();
|
||||||
|
|
||||||
result = checkForConflicts(mapToAdd);
|
result = checkForConflicts(mapToAdd);
|
||||||
if (result != RETURN_OK){
|
if (result != RETURN_OK){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = configureGpios(&mapToAdd);
|
result = configureGpios(&mapToAdd);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register new GPIOs in gpioMap*/
|
/* Register new GPIOs in gpioMap*/
|
||||||
gpioMap.insert(mapToAdd.begin(), mapToAdd.end());
|
gpioMap.insert(mapToAdd.begin(), mapToAdd.end());
|
||||||
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
||||||
@ -100,7 +100,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified"
|
sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -113,33 +113,33 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId){
|
ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId){
|
||||||
return driveGpio(gpioId, 1);
|
return driveGpio(gpioId, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId){
|
ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId){
|
||||||
return driveGpio(gpioId, 0);
|
return driveGpio(gpioId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
|
ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId,
|
||||||
unsigned int logiclevel) {
|
unsigned int logiclevel) {
|
||||||
int result;
|
int result;
|
||||||
struct gpiod_line *lineHandle;
|
struct gpiod_line *lineHandle;
|
||||||
|
|
||||||
gpioMapIter = gpioMap.find(gpioId);
|
gpioMapIter = gpioMap.find(gpioId);
|
||||||
if (gpioMapIter == gpioMap.end()){
|
if (gpioMapIter == gpioMap.end()){
|
||||||
sif::debug << "LinuxLibgpioIF::driveGpio: Unknown gpio id " << gpioId << std::endl;
|
sif::debug << "LinuxLibgpioIF::driveGpio: Unknown gpio id " << gpioId << std::endl;
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
lineHandle = gpioMapIter->second.lineHandle;
|
lineHandle = gpioMapIter->second.lineHandle;
|
||||||
result = gpiod_line_set_value(lineHandle, logiclevel);
|
result = gpiod_line_set_value(lineHandle, logiclevel);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
sif::error << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID "
|
sif::error << "LinuxLibgpioIF::driveGpio: Failed to pull GPIO with ID "
|
||||||
<< gpioId << " to logic level " << logiclevel << std::endl;
|
<< gpioId << " to logic level " << logiclevel << std::endl;
|
||||||
return DRIVE_GPIO_FAILURE;
|
return DRIVE_GPIO_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) {
|
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){
|
ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap mapToAdd){
|
||||||
gpioId_t gpioId;
|
gpioId_t gpioId;
|
||||||
GpioMapIter mapToAddIter = mapToAdd.begin();
|
GpioMapIter mapToAddIter = mapToAdd.begin();
|
||||||
for(; mapToAddIter != mapToAdd.end(); mapToAddIter++){
|
for(; mapToAddIter != mapToAdd.end(); mapToAddIter++){
|
||||||
gpioId = mapToAddIter->first;
|
gpioId = mapToAddIter->first;
|
||||||
gpioMapIter = gpioMap.find(gpioId);
|
gpioMapIter = gpioMap.find(gpioId);
|
||||||
if(gpioMapIter != mapToAdd.end()){
|
if(gpioMapIter != mapToAdd.end()){
|
||||||
/* An entry for this GPIO already exists. Check if configuration
|
/* An entry for this GPIO already exists. Check if configuration
|
||||||
* of direction is equivalent */
|
* of direction is equivalent */
|
||||||
if (mapToAddIter->second.direction != gpioMapIter->second.direction){
|
if (mapToAddIter->second.direction != gpioMapIter->second.direction){
|
||||||
sif::error << "LinuxLibgpioIF::checkForConflicts: Detected conflict "
|
sif::error << "LinuxLibgpioIF::checkForConflicts: Detected conflict "
|
||||||
<< "for GPIO " << mapToAddIter->first << std::endl;
|
<< "for GPIO " << mapToAddIter->first << std::endl;
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
/* Remove element from map to add because a entry for this GPIO
|
/* Remove element from map to add because a entry for this GPIO
|
||||||
* already exists */
|
* already exists */
|
||||||
mapToAdd.erase(mapToAddIter);
|
mapToAdd.erase(mapToAddIter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user