Improved structure #17
@ -44,8 +44,10 @@ set(FSFW_PATH fsfw)
|
||||
set(MISSION_PATH mission)
|
||||
set(CSPLIB_PATH libcsp)
|
||||
set(TEST_PATH test/testtasks)
|
||||
set(LINUX_PATH linux)
|
||||
|
||||
set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF)
|
||||
set(ADD_LINUX_FILES FALSE)
|
||||
|
||||
# Analyse different OS and architecture/target options, determine BSP_PATH,
|
||||
# display information about compiler etc.
|
||||
@ -61,6 +63,7 @@ if(TGT_BSP)
|
||||
if(${TGT_BSP} MATCHES "arm/q7s")
|
||||
set(ADD_CSP_LIB TRUE)
|
||||
endif()
|
||||
set(ADD_LINUX_FILES TRUE)
|
||||
else()
|
||||
# Required by FSFW library
|
||||
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
|
||||
@ -82,6 +85,10 @@ if(ADD_CSP_LIB)
|
||||
add_subdirectory(${CSPLIB_PATH})
|
||||
endif()
|
||||
|
||||
if(ADD_LINUX_FILES)
|
||||
add_subdirectory(${LINUX_PATH})
|
||||
endif()
|
||||
|
||||
add_subdirectory(${BSP_PATH})
|
||||
add_subdirectory(${FSFW_PATH})
|
||||
add_subdirectory(${MISSION_PATH})
|
||||
|
@ -115,37 +115,37 @@ void ObjectFactory::produce(){
|
||||
#if TE0720 == 0
|
||||
/* Pin H2-11 on stack connector */
|
||||
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);
|
||||
|
||||
/* Pin H2-12 on stack connector */
|
||||
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);
|
||||
|
||||
/* Pin H2-13 on stack connector */
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
/* Configure MIO0 as input */
|
||||
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);
|
||||
new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie);
|
||||
#elif TE0720 == 1
|
||||
// Configuration for MIO0 on TE0720-03-1CFA
|
||||
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);
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER,
|
||||
pcduSwitches::TCS_BOARD_8V_HEATER_IN);
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define TEST_TESTTASKS_LIBGPIODTEST_H_
|
||||
|
||||
#include "TestTask.h"
|
||||
#include "GpioIF.h"
|
||||
#include "GpioCookie.h"
|
||||
#include <bsp_q7s/gpio/GpioIF.h>
|
||||
#include <bsp_q7s/gpio/cookies/GpioCookie.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,4 @@
|
||||
target_sources(${TARGET_NAME} PUBLIC
|
||||
cookies/GpioCookie.cpp
|
||||
LinuxLibgpioIF.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cookies
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <bsp_q7s/gpio/LinuxLibgpioIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "LinuxLibgpioIF.h"
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
|
||||
#include <utility>
|
||||
#include <unistd.h>
|
||||
@ -49,7 +49,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
||||
std::string chipname;
|
||||
unsigned int lineNum;
|
||||
struct gpiod_chip *chip;
|
||||
Gpio::Direction direction;
|
||||
gpio::Direction direction;
|
||||
std::string consumer;
|
||||
struct gpiod_line *lineHandle;
|
||||
int result;
|
||||
@ -77,7 +77,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
||||
consumer = mapToAddIter->second.consumer;
|
||||
/* Configure direction and add a description to the GPIO */
|
||||
switch (direction) {
|
||||
case Gpio::OUT:
|
||||
case gpio::OUT:
|
||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
||||
mapToAddIter->second.initValue);
|
||||
if (result < 0) {
|
||||
@ -88,7 +88,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap* mapToAdd) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
break;
|
||||
case Gpio::IN:
|
||||
case gpio::IN:
|
||||
result = gpiod_line_request_input(lineHandle, consumer.c_str());
|
||||
if (result < 0) {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line "
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef 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 <bsp_q7s/gpio/cookies/GpioCookie.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
/**
|
||||
|
2
linux/CMakeLists.txt
Normal file
2
linux/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_subdirectory(gpio)
|
||||
|
7
linux/gpio/CMakeLists.txt
Normal file
7
linux/gpio/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
target_sources(${TARGET_NAME} PUBLIC
|
||||
GpioCookie.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <bsp_q7s/gpio/cookies/GpioCookie.h>
|
||||
#include "GpioCookie.h"
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
GpioCookie::GpioCookie() {
|
@ -1,17 +1,17 @@
|
||||
#ifndef SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_
|
||||
#define SAM9G20_COMIF_COOKIES_GPIO_COOKIE_H_
|
||||
|
||||
#include "GpioIF.h"
|
||||
#include <fsfw/devicehandlers/CookieIF.h>
|
||||
#include <bsp_q7s/gpio/GpioIF.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Gpio {
|
||||
enum Direction {
|
||||
IN = 0,
|
||||
OUT = 1
|
||||
};
|
||||
namespace gpio {
|
||||
enum Direction {
|
||||
IN = 0,
|
||||
OUT = 1
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,17 +29,17 @@ namespace Gpio {
|
||||
* pointer.
|
||||
*/
|
||||
typedef struct GpioConfig {
|
||||
GpioConfig(std::string chipname_, int lineNum_, std::string consumer_,
|
||||
Gpio::Direction direction_, int initValue_) :
|
||||
chipname(chipname_), lineNum(lineNum_), consumer(consumer_), direction(
|
||||
direction_), initValue(initValue_) {
|
||||
}
|
||||
std::string chipname;
|
||||
int lineNum;
|
||||
std::string consumer;
|
||||
Gpio::Direction direction;
|
||||
int initValue;
|
||||
struct gpiod_line* lineHandle;
|
||||
GpioConfig(std::string chipname_, int lineNum_, std::string consumer_,
|
||||
gpio::Direction direction_, int initValue_) :
|
||||
chipname(chipname_), lineNum(lineNum_), consumer(consumer_), direction(direction_),
|
||||
initValue(initValue_) {
|
||||
}
|
||||
std::string chipname;
|
||||
int lineNum;
|
||||
std::string consumer;
|
||||
gpio::Direction direction;
|
||||
int initValue;
|
||||
struct gpiod_line* lineHandle = nullptr;
|
||||
} GpioConfig_t;
|
||||
using GpioMap = std::unordered_map<gpioId_t, GpioConfig_t>;
|
||||
using GpioMapIter = GpioMap::iterator;
|
||||
@ -57,20 +57,20 @@ using GpioMapIter = GpioMap::iterator;
|
||||
class GpioCookie: public CookieIF {
|
||||
public:
|
||||
|
||||
GpioCookie();
|
||||
GpioCookie();
|
||||
|
||||
virtual ~GpioCookie();
|
||||
virtual ~GpioCookie();
|
||||
|
||||
void addGpio(gpioId_t gpioId, GpioConfig_t gpioConfig);
|
||||
/**
|
||||
* @brief Get map with registered GPIOs.
|
||||
*/
|
||||
GpioMap getGpioMap() const;
|
||||
void addGpio(gpioId_t gpioId, GpioConfig_t gpioConfig);
|
||||
/**
|
||||
* @brief Get map with registered GPIOs.
|
||||
*/
|
||||
GpioMap getGpioMap() const;
|
||||
|
||||
private:
|
||||
|
||||
GpioMap gpioMap;
|
||||
GpioMapIter gpioMapIter;
|
||||
GpioMap gpioMap;
|
||||
GpioMapIter gpioMapIter;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user