added new linux folder

This commit is contained in:
Robin Müller 2021-02-14 12:35:08 +01:00
parent ae47acdbbb
commit 56c89a0751
11 changed files with 62 additions and 53 deletions

View File

@ -44,8 +44,10 @@ set(FSFW_PATH fsfw)
set(MISSION_PATH mission) set(MISSION_PATH mission)
set(CSPLIB_PATH libcsp) set(CSPLIB_PATH libcsp)
set(TEST_PATH test/testtasks) set(TEST_PATH test/testtasks)
set(LINUX_PATH linux)
set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF)
set(ADD_LINUX_FILES FALSE)
# Analyse different OS and architecture/target options, determine BSP_PATH, # Analyse different OS and architecture/target options, determine BSP_PATH,
# display information about compiler etc. # display information about compiler etc.
@ -61,6 +63,7 @@ if(TGT_BSP)
if(${TGT_BSP} MATCHES "arm/q7s") if(${TGT_BSP} MATCHES "arm/q7s")
set(ADD_CSP_LIB TRUE) set(ADD_CSP_LIB TRUE)
endif() endif()
set(ADD_LINUX_FILES TRUE)
else() else()
# Required by FSFW library # Required by FSFW library
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig") set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
@ -82,6 +85,10 @@ if(ADD_CSP_LIB)
add_subdirectory(${CSPLIB_PATH}) add_subdirectory(${CSPLIB_PATH})
endif() endif()
if(ADD_LINUX_FILES)
add_subdirectory(${LINUX_PATH})
endif()
add_subdirectory(${BSP_PATH}) add_subdirectory(${BSP_PATH})
add_subdirectory(${FSFW_PATH}) add_subdirectory(${FSFW_PATH})
add_subdirectory(${MISSION_PATH}) add_subdirectory(${MISSION_PATH})

View File

@ -115,37 +115,37 @@ void ObjectFactory::produce(){
#if TE0720 == 0 #if TE0720 == 0
/* Pin H2-11 on stack connector */ /* Pin H2-11 on stack connector */
GpioConfig_t gpioConfigHeater0(std::string("gpiochip7"), 18, GpioConfig_t gpioConfigHeater0(std::string("gpiochip7"), 18,
std::string("Heater0"), Gpio::OUT, 0); std::string("Heater0"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_0, gpioConfigHeater0); gpioCookie->addGpio(gpioIds::HEATER_0, gpioConfigHeater0);
/* Pin H2-12 on stack connector */ /* Pin H2-12 on stack connector */
GpioConfig_t gpioConfigHeater1(std::string("gpiochip7"), 14, GpioConfig_t gpioConfigHeater1(std::string("gpiochip7"), 14,
std::string("Heater1"), Gpio::OUT, 0); std::string("Heater1"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_1, gpioConfigHeater1); gpioCookie->addGpio(gpioIds::HEATER_1, gpioConfigHeater1);
/* Pin H2-13 on stack connector */ /* Pin H2-13 on stack connector */
GpioConfig_t gpioConfigHeater2(std::string("gpiochip7"), 20, GpioConfig_t gpioConfigHeater2(std::string("gpiochip7"), 20,
std::string("Heater2"), Gpio::OUT, 0); std::string("Heater2"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_2, gpioConfigHeater2); gpioCookie->addGpio(gpioIds::HEATER_2, gpioConfigHeater2);
GpioConfig_t gpioConfigHeater3(std::string("gpiochip7"), 16, GpioConfig_t gpioConfigHeater3(std::string("gpiochip7"), 16,
std::string("Heater3"), Gpio::OUT, 0); std::string("Heater3"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_3, gpioConfigHeater3); gpioCookie->addGpio(gpioIds::HEATER_3, gpioConfigHeater3);
GpioConfig_t gpioConfigHeater4(std::string("gpiochip7"), 24, GpioConfig_t gpioConfigHeater4(std::string("gpiochip7"), 24,
std::string("Heater4"), Gpio::OUT, 0); std::string("Heater4"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_4, gpioConfigHeater4); gpioCookie->addGpio(gpioIds::HEATER_4, gpioConfigHeater4);
GpioConfig_t gpioConfigHeater5(std::string("gpiochip7"), 26, GpioConfig_t gpioConfigHeater5(std::string("gpiochip7"), 26,
std::string("Heater5"), Gpio::OUT, 0); std::string("Heater5"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_5, gpioConfigHeater5); gpioCookie->addGpio(gpioIds::HEATER_5, gpioConfigHeater5);
GpioConfig_t gpioConfigHeater6(std::string("gpiochip7"), 22, GpioConfig_t gpioConfigHeater6(std::string("gpiochip7"), 22,
std::string("Heater6"), Gpio::OUT, 0); std::string("Heater6"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_6, gpioConfigHeater6); gpioCookie->addGpio(gpioIds::HEATER_6, gpioConfigHeater6);
GpioConfig_t gpioConfigHeater7(std::string("gpiochip7"), 28, GpioConfig_t gpioConfigHeater7(std::string("gpiochip7"), 28,
std::string("Heater7"), Gpio::OUT, 0); std::string("Heater7"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_7, gpioConfigHeater7); gpioCookie->addGpio(gpioIds::HEATER_7, gpioConfigHeater7);
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER,
@ -160,13 +160,13 @@ void ObjectFactory::produce(){
#if TE0720 == 1 && TEST_LIBGPIOD == 1 #if TE0720 == 1 && TEST_LIBGPIOD == 1
/* Configure MIO0 as input */ /* Configure MIO0 as input */
GpioConfig_t gpioConfigMio0(std::string("gpiochip0"), 0, GpioConfig_t gpioConfigMio0(std::string("gpiochip0"), 0,
std::string("MIO0"), Gpio::IN, 0); std::string("MIO0"), gpio::IN, 0);
gpioCookie->addGpio(gpioIds::Test_ID, gpioConfigMio0); gpioCookie->addGpio(gpioIds::Test_ID, gpioConfigMio0);
new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie);
#elif TE0720 == 1 #elif TE0720 == 1
// Configuration for MIO0 on TE0720-03-1CFA // Configuration for MIO0 on TE0720-03-1CFA
GpioConfig_t gpioConfigForDummyHeater(std::string("gpiochip0"), 0, GpioConfig_t gpioConfigForDummyHeater(std::string("gpiochip0"), 0,
std::string("Heater0"), Gpio::OUT, 0); std::string("Heater0"), gpio::OUT, 0);
gpioCookie->addGpio(gpioIds::HEATER_0, gpioConfigForDummyHeater); gpioCookie->addGpio(gpioIds::HEATER_0, gpioConfigForDummyHeater);
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER,
pcduSwitches::TCS_BOARD_8V_HEATER_IN); pcduSwitches::TCS_BOARD_8V_HEATER_IN);

View File

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

View File

@ -1,11 +1,4 @@
target_sources(${TARGET_NAME} PUBLIC target_sources(${TARGET_NAME} PUBLIC
cookies/GpioCookie.cpp
LinuxLibgpioIF.cpp LinuxLibgpioIF.cpp
) )
target_include_directories(${TARGET_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cookies
)

View File

@ -1,5 +1,5 @@
#include <bsp_q7s/gpio/LinuxLibgpioIF.h> #include "LinuxLibgpioIF.h"
#include <fsfw/serviceinterface/ServiceInterfaceStream.h> #include <fsfw/serviceinterface/ServiceInterface.h>
#include <utility> #include <utility>
#include <unistd.h> #include <unistd.h>
@ -49,7 +49,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
std::string chipname; std::string chipname;
unsigned int lineNum; unsigned int lineNum;
struct gpiod_chip *chip; struct gpiod_chip *chip;
Gpio::Direction direction; gpio::Direction direction;
std::string consumer; std::string consumer;
struct gpiod_line *lineHandle; struct gpiod_line *lineHandle;
int result; int result;
@ -77,7 +77,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
consumer = mapToAddIter->second.consumer; consumer = mapToAddIter->second.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::OUT:
result = gpiod_line_request_output(lineHandle, consumer.c_str(), result = gpiod_line_request_output(lineHandle, consumer.c_str(),
mapToAddIter->second.initValue); mapToAddIter->second.initValue);
if (result < 0) { if (result < 0) {
@ -88,7 +88,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
return RETURN_FAILED; return RETURN_FAILED;
} }
break; break;
case Gpio::IN: case gpio::IN:
result = gpiod_line_request_input(lineHandle, consumer.c_str()); result = gpiod_line_request_input(lineHandle, consumer.c_str());
if (result < 0) { if (result < 0) {
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line "

View File

@ -1,9 +1,9 @@
#ifndef BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_ #ifndef BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_
#define BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_ #define BSP_Q7S_GPIO_LINUXLIBGPIOIF_H_
#include <bsp_q7s/gpio/GpioIF.h> #include <linux/gpio/GpioIF.h>
#include <linux/gpio/GpioCookie.h>
#include <fsfwconfig/returnvalues/classIds.h> #include <fsfwconfig/returnvalues/classIds.h>
#include <bsp_q7s/gpio/cookies/GpioCookie.h>
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
/** /**

2
linux/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_subdirectory(gpio)

View File

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

View File

@ -1,4 +1,4 @@
#include <bsp_q7s/gpio/cookies/GpioCookie.h> #include "GpioCookie.h"
#include <fsfw/serviceinterface/ServiceInterfaceStream.h> #include <fsfw/serviceinterface/ServiceInterfaceStream.h>
GpioCookie::GpioCookie() { GpioCookie::GpioCookie() {

View File

@ -1,17 +1,17 @@
#ifndef SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_ #ifndef SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_
#define SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_ #define SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_
#include "GpioIF.h"
#include <fsfw/devicehandlers/CookieIF.h> #include <fsfw/devicehandlers/CookieIF.h>
#include <bsp_q7s/gpio/GpioIF.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
namespace Gpio { namespace gpio {
enum Direction { enum Direction {
IN = 0, IN = 0,
OUT = 1 OUT = 1
}; };
} }
/** /**
@ -30,16 +30,16 @@ namespace Gpio {
*/ */
typedef struct GpioConfig { typedef struct GpioConfig {
GpioConfig(std::string chipname_, int lineNum_, std::string consumer_, GpioConfig(std::string chipname_, int lineNum_, std::string consumer_,
Gpio::Direction direction_, int initValue_) : gpio::Direction direction_, int initValue_) :
chipname(chipname_), lineNum(lineNum_), consumer(consumer_), direction( chipname(chipname_), lineNum(lineNum_), consumer(consumer_), direction(direction_),
direction_), initValue(initValue_) { initValue(initValue_) {
} }
std::string chipname; std::string chipname;
int lineNum; int lineNum;
std::string consumer; std::string consumer;
Gpio::Direction direction; gpio::Direction direction;
int initValue; int initValue;
struct gpiod_line* lineHandle; struct gpiod_line* lineHandle = nullptr;
} GpioConfig_t; } GpioConfig_t;
using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>; using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>;
using GpioMapIter = GpioMap::iterator; using GpioMapIter = GpioMap::iterator;