uart isolator switch handling

This commit is contained in:
Jakob Meier 2022-03-28 09:08:11 +02:00
parent e2c9bece05
commit 758c4e6f4f
11 changed files with 75 additions and 45 deletions

View File

@ -74,7 +74,7 @@ set(LIB_JSON_NAME nlohmann_json::nlohmann_json)
# Set path names # Set path names
set(FSFW_PATH fsfw) set(FSFW_PATH fsfw)
set(TEST_PATH test/testtasks) set(TEST_PATH test)
set(UNITTEST_PATH unittest) set(UNITTEST_PATH unittest)
set(LINUX_PATH linux) set(LINUX_PATH linux)
set(COMMON_PATH common) set(COMMON_PATH common)
@ -210,7 +210,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(COMPILER_FLAGS "/permissive-") set(COMPILER_FLAGS "/permissive-")
endif() endif()
if (NOT(TGT_BSP MATCHES "arm/te0720-1cfa")) if (NOT(TGT_BSP MATCHES "arm/te0720-1cfa") AND NOT(TGT_BSP MATCHES "arm/q7s"))
# Not installed, so use FetchContent to download and provide Catch2 # Not installed, so use FetchContent to download and provide Catch2
if(NOT Catch2_FOUND) if(NOT Catch2_FOUND)
message(STATUS "Did not find a valid Catch2 installation. Using FetchContent to install it") message(STATUS "Did not find a valid Catch2 installation. Using FetchContent to install it")

View File

@ -94,6 +94,9 @@ static constexpr char PL_PCDU_ENABLE_HPA[] = "enable_plpcdu_hpa";
static constexpr char PL_PCDU_ENABLE_MPA[] = "enable_plpcdu_mpa"; static constexpr char PL_PCDU_ENABLE_MPA[] = "enable_plpcdu_mpa";
static constexpr char PL_PCDU_ADC_CS[] = "plpcdu_adc_chip_select"; static constexpr char PL_PCDU_ADC_CS[] = "plpcdu_adc_chip_select";
static constexpr char ENABLE_SUPV_UART[] = "enable_supv_uart";
static constexpr char ENABLE_MPSOC_UART[] = "enable_mpsoc_uart";
} // namespace gpioNames } // namespace gpioNames
} // namespace q7s } // namespace q7s

View File

@ -153,6 +153,7 @@ void ObjectFactory::produce(void* args) {
createSyrlinksComponents(); createSyrlinksComponents();
#endif /* OBSW_ADD_SYRLINKS == 1 */ #endif /* OBSW_ADD_SYRLINKS == 1 */
createRtdComponents(gpioComIF, pwrSwitcher); createRtdComponents(gpioComIF, pwrSwitcher);
createPayloadComponents(gpioComIF);
#if OBSW_ADD_MGT == 1 #if OBSW_ADD_MGT == 1
I2cCookie* imtqI2cCookie = I2cCookie* imtqI2cCookie =
@ -180,27 +181,6 @@ void ObjectFactory::produce(void* args) {
#endif #endif
#endif #endif
#if OBSW_ADD_PLOC_MPSOC == 1
UartCookie* plocMpsocCookie =
new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV,
UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE);
PlocMPSoCHelper* plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
PlocMPSoCHandler* plocMPSoCHandler =
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie,
plocMpsocHelper, gpioComIF);
plocMPSoCHandler->setStartUpImmediately();
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1
UartCookie* plocSupervisorCookie = new UartCookie(
objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL,
uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20);
plocSupervisorCookie->setNoFixedSizeReply();
PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler(
objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie);
plocSupervisor->setStartUpImmediately();
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); new FileSystemHandler(objects::FILE_SYSTEM_HANDLER);
#if OBSW_ADD_STAR_TRACKER == 1 #if OBSW_ADD_STAR_TRACKER == 1
@ -929,6 +909,45 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF
#endif // OBSW_ADD_RTD_DEVICES == 1 #endif // OBSW_ADD_RTD_DEVICES == 1
} }
void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) {
auto gpioCookie = new GpioCookie;
std::stringstream consumer;
#if OBSW_ADD_PLOC_MPSOC == 1
consumer << "0x" << std::hex << objects::PLOC_MPSOC_HANDLER;
auto gpioConfig = new GpiodRegularByLineName(q7s::gpioNames::ENABLE_MPSOC_UART, consumer.str(),
Direction::OUT, Levels::HIGH);
gpioCookie->addGpio(gpioIds::ENABLE_MPSOC_UART, gpioConfig);
gpioComIF->addGpios(gpioCookie);
auto mpsocCookie =
new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV,
UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE);
mpsocCookie->setNoFixedSizeReply();
auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
auto plocMPSoC =
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie,
plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF));
plocMPSoC->setStartUpImmediately();
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1
consumer << "0x" << std::hex << objects::PLOC_SUPERVISOR_HANDLER;
auto gpioConfig = new GpiodRegularByLineName(q7s::gpioNames::ENABLE_SUPV_UART, consumer.str(),
Direction::OUT, Levels::HIGH);
gpioCookie->addGpio(gpioIds::ENABLE_SUPV_UART, gpioConfig);
gpioComIF->addGpios(gpioCookie);
auto supervisorCookie = new UartCookie(
objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL,
uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20);
supervisorCookie->setNoFixedSizeReply();
PlocSupervisorHandler* plocSupervisor =
new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF,
supervisorCookie, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF));
plocSupervisor->setStartUpImmediately();
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
static_cast<void>(gpioCookie);
static_cast<void>(consumer);
}
void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) {
using namespace gpio; using namespace gpio;
GpioCookie* gpioCookieRw = new GpioCookie; GpioCookie* gpioCookieRw = new GpioCookie;

View File

@ -26,6 +26,7 @@ void createHeaterComponents();
void createSolarArrayDeploymentComponents(); void createSolarArrayDeploymentComponents();
void createSyrlinksComponents(); void createSyrlinksComponents();
void createRtdComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher); void createRtdComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher);
void createPayloadComponents(LinuxLibgpioIF* gpioComIF);
void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF);
void createCcsdsComponents(LinuxLibgpioIF* gpioComIF); void createCcsdsComponents(LinuxLibgpioIF* gpioComIF);
void createTestComponents(LinuxLibgpioIF* gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF);

View File

@ -18,8 +18,10 @@
#include "mission/devices/Tmp1075Handler.h" #include "mission/devices/Tmp1075Handler.h"
#include "mission/core/GenericFactory.h" #include "mission/core/GenericFactory.h"
#include "mission/utility/TmFunnel.h" #include "mission/utility/TmFunnel.h"
#include "test/gpio/DummyGpioIF.h"
#include "objects/systemObjectList.h" #include "objects/systemObjectList.h"
#include "devices/addresses.h" #include "devices/addresses.h"
#include "devices/gpioIds.h"
#include "tmtc/apid.h" #include "tmtc/apid.h"
#include "tmtc/pusIds.h" #include "tmtc/pusIds.h"
@ -48,8 +50,10 @@ void ObjectFactory::produce(void* args) {
mpsocUartCookie->setNoFixedSizeReply(); mpsocUartCookie->setNoFixedSizeReply();
PlocMPSoCHelper* plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); PlocMPSoCHelper* plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
new UartComIF(objects::UART_COM_IF); new UartComIF(objects::UART_COM_IF);
PlocMPSoCHandler* plocMPSoCHandler = new PlocMPSoCHandler( auto dummyGpioIF = new DummyGpioIF();
objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocUartCookie, plocMpsocHelper); PlocMPSoCHandler* plocMPSoCHandler =
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocUartCookie,
plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, dummyGpioIF));
plocMPSoCHandler->setStartUpImmediately(); plocMPSoCHandler->setStartUpImmediately();
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #endif /* OBSW_ADD_PLOC_MPSOC == 1 */

View File

@ -119,7 +119,11 @@ enum gpioId_t {
PLPCDU_ENB_TX, PLPCDU_ENB_TX,
PLPCDU_ENB_HPA, PLPCDU_ENB_HPA,
PLPCDU_ENB_MPA, PLPCDU_ENB_MPA,
PLPCDU_ADC_CS PLPCDU_ADC_CS,
ENABLE_MPSOC_UART,
ENABLE_SUPV_UART
}; };
} }

View File

@ -6,17 +6,13 @@
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
LinuxLibgpioIF* gpioComIF, gpioId_t uartIsolatorSwitch) Gpio uartIsolatorSwitch)
: DeviceHandlerBase(objectId, uartComIFid, comCookie), : DeviceHandlerBase(objectId, uartComIFid, comCookie),
plocMPSoCHelper(plocMPSoCHelper), plocMPSoCHelper(plocMPSoCHelper),
gpioComIF(gpioComIF),
uartIsolatorSwitch(uartIsolatorSwitch) { uartIsolatorSwitch(uartIsolatorSwitch) {
if (comCookie == nullptr) { if (comCookie == nullptr) {
sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl; sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl;
} }
if (gpioComIF == nullptr) {
sif::error << "PlocMPSoCHandler: Invalid gpio communication interface" << std::endl;
}
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
} }
@ -125,11 +121,11 @@ void PlocMPSoCHandler::doStartUp() {
#else #else
setMode(_MODE_TO_ON); setMode(_MODE_TO_ON);
#endif #endif
gpioComIF->pullHigh(uartIsolatorSwitch); uartIsolatorSwitch.pullHigh();
} }
void PlocMPSoCHandler::doShutDown() { void PlocMPSoCHandler::doShutDown() {
gpioComIF->pullLow(uartIsolatorSwitch); uartIsolatorSwitch.pullLow();
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
} }

View File

@ -8,7 +8,7 @@
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw_hal/linux/uart/UartComIF.h"
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "fsfw_hal/linux/gpio/Gpio.h"
#include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h" #include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
@ -29,8 +29,7 @@
class PlocMPSoCHandler : public DeviceHandlerBase { class PlocMPSoCHandler : public DeviceHandlerBase {
public: public:
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
PlocMPSoCHelper* plocMPSoCHelper, LinuxLibgpioIF* gpioComIF, PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch);
gpioId_t uartIsolatorSwitch);
virtual ~PlocMPSoCHandler(); virtual ~PlocMPSoCHandler();
virtual ReturnValue_t initialize() override; virtual ReturnValue_t initialize() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
@ -99,8 +98,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase {
UartComIF* uartComIf = nullptr; UartComIF* uartComIf = nullptr;
PlocMPSoCHelper* plocMPSoCHelper = nullptr; PlocMPSoCHelper* plocMPSoCHelper = nullptr;
LinuxLibgpioIF* gpioComIF = nullptr; Gpio uartIsolatorSwitch;
gpioId_t uartIsolatorSwitch = gpio::NO_GPIO;
// Used to block incoming commands when MPSoC helper class is currently executing a command // Used to block incoming commands when MPSoC helper class is currently executing a command
bool plocMPSoCHelperExecuting = false; bool plocMPSoCHelperExecuting = false;

View File

@ -12,10 +12,9 @@
#include "OBSWConfig.h" #include "OBSWConfig.h"
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, CookieIF* comCookie,
gpioId_t uartIsolatorSwitch) Gpio uartIsolatorSwitch)
: DeviceHandlerBase(objectId, uartComIFid, comCookie), : DeviceHandlerBase(objectId, uartComIFid, comCookie),
gpioComIF(gpioComIF),
uartIsolatorSwitch(uartIsolatorSwitch), uartIsolatorSwitch(uartIsolatorSwitch),
hkset(this), hkset(this),
bootStatusReport(this), bootStatusReport(this),
@ -50,9 +49,13 @@ void PlocSupervisorHandler::doStartUp() {
#else #else
setMode(_MODE_TO_ON); setMode(_MODE_TO_ON);
#endif #endif
uartIsolatorSwitch.pullHigh();
} }
void PlocSupervisorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } void PlocSupervisorHandler::doShutDown() {
setMode(_MODE_POWER_DOWN);
uartIsolatorSwitch.pullLow();
}
ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
return NOTHING_TO_SEND; return NOTHING_TO_SEND;

View File

@ -5,7 +5,8 @@
#include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw_hal/linux/uart/UartComIF.h"
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
#include "inux/devices/devicedefinitions/PlocSupervisorDefinitions.h" #include "fsfw_hal/linux/gpio/Gpio.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
#include "OBSWConfig.h" #include "OBSWConfig.h"
@ -24,7 +25,7 @@
class PlocSupervisorHandler : public DeviceHandlerBase { class PlocSupervisorHandler : public DeviceHandlerBase {
public: public:
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
LinuxLibgpioIF* gpioComIF, gpioId_t uartIsolatorSwitch); Gpio uartIsolatorSwitch);
virtual ~PlocSupervisorHandler(); virtual ~PlocSupervisorHandler();
virtual ReturnValue_t initialize() override; virtual ReturnValue_t initialize() override;
@ -115,7 +116,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
UartComIF* uartComIf = nullptr; UartComIF* uartComIf = nullptr;
LinuxLibgpioIF* gpioComIF = nullptr; LinuxLibgpioIF* gpioComIF = nullptr;
gpioId_t uartIsolatorSwitch = gpio::NO_GPIO; Gpio uartIsolatorSwitch;
PLOC_SPV::HkSet hkset; PLOC_SPV::HkSet hkset;
PLOC_SPV::BootStatusReport bootStatusReport; PLOC_SPV::BootStatusReport bootStatusReport;

View File

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