rtd handler compiled

This commit is contained in:
Jakob Meier 2021-03-13 14:42:30 +01:00
parent d1eaa88772
commit a2044d38bc
18 changed files with 431 additions and 70 deletions

View File

@ -25,7 +25,31 @@ namespace gpioIds {
MGM_3_RM3100_CS,
TEST_ID_0,
TEST_ID_1
TEST_ID_1,
RTD_IC3,
RTD_IC4,
RTD_IC5,
RTD_IC6,
RTD_IC7,
RTD_IC8,
RTD_IC9,
RTD_IC10,
RTD_IC11,
RTD_IC12,
RTD_IC13,
RTD_IC14,
RTD_IC15,
RTD_IC16,
RTD_IC17,
RTD_IC18,
SPI_MUX_BIT_1,
SPI_MUX_BIT_2,
SPI_MUX_BIT_3,
SPI_MUX_BIT_4,
SPI_MUX_BIT_5,
SPI_MUX_BIT_6
};
}

View File

@ -8,6 +8,7 @@ add_subdirectory(boardconfig)
add_subdirectory(comIF)
add_subdirectory(devices)
add_subdirectory(boardtest)
add_subdirectory(gpio)

View File

@ -8,6 +8,7 @@
#include <bsp_q7s/devices/HeaterHandler.h>
#include <bsp_q7s/devices/SolarArrayDeploymentHandler.h>
#include <bsp_q7s/gpio/gpioCallbacks.h>
#include <mission/core/GenericFactory.h>
#include <mission/devices/PDU1Handler.h>
@ -16,6 +17,8 @@
#include <mission/devices/PCDUHandler.h>
#include <mission/devices/P60DockHandler.h>
#include <mission/devices/Tmp1075Handler.h>
#include <mission/devices/Max31865PT1000Handler.h>
#include <mission/devices/devicedefinitions/Max31865Definitions.h>
#include <mission/devices/SyrlinksHkHandler.h>
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
@ -31,6 +34,8 @@
#include <linux/gpio/GpioCookie.h>
#include <linux/uart/UartComIF.h>
#include <linux/uart/UartCookie.h>
#include <linux/spi/SpiComIF.h>
#include <linux/spi/SpiCookie.h>
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h>
@ -77,10 +82,13 @@ void ObjectFactory::produce(){
I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2,
TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-1"));
#endif
LinuxLibgpioIF* gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF);
/* Communication interfaces */
new CspComIF(objects::CSP_COM_IF);
new I2cComIF(objects::I2C_COM_IF);
new UartComIF(objects::UART_COM_IF);
new SpiComIF(objects::SPI_COM_IF, gpioComIF);
#if TE0720 == 0
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH,
@ -123,42 +131,41 @@ void ObjectFactory::produce(){
tmp1075Handler_2->setStartUpImmediately();
GpioCookie* heaterGpiosCookie = new GpioCookie;
new LinuxLibgpioIF(objects::GPIO_IF);
#if TE0720 == 0
/* Pin H2-11 on stack connector */
GpiodRegular gpioConfigHeater0(std::string("gpiochip7"), 16, std::string("Heater0"), gpio::OUT,
0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpioConfigHeater0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_0, &gpioConfigHeater0);
/* Pin H2-12 on stack connector */
GpiodRegular gpioConfigHeater1(std::string("gpiochip7"), 12,
std::string("Heater1"), gpio::OUT, 0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpioConfigHeater1);
heaterGpiosCookie->addGpio(gpioIds::HEATER_1, &gpioConfigHeater1);
/* Pin H2-13 on stack connector */
GpiodRegular gpioConfigHeater2(std::string("gpiochip7"), 7,
std::string("Heater2"), gpio::OUT, 0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpioConfigHeater2);
heaterGpiosCookie->addGpio(gpioIds::HEATER_2, &gpioConfigHeater2);
GpiodRegular gpioConfigHeater3(std::string("gpiochip7"), 5, std::string("Heater3"), gpio::OUT,
0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpioConfigHeater3);
heaterGpiosCookie->addGpio(gpioIds::HEATER_3, &gpioConfigHeater3);
GpiodRegular gpioConfigHeater4(std::string("gpiochip7"), 3, std::string("Heater4"), gpio::OUT,
0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpioConfigHeater4);
heaterGpiosCookie->addGpio(gpioIds::HEATER_4, &gpioConfigHeater4);
GpiodRegular gpioConfigHeater5(std::string("gpiochip7"), 0, std::string("Heater5"), gpio::OUT,
0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpioConfigHeater5);
heaterGpiosCookie->addGpio(gpioIds::HEATER_5, &gpioConfigHeater5);
GpiodRegular gpioConfigHeater6(std::string("gpiochip7"), 1, std::string("Heater6"), gpio::OUT,
0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpioConfigHeater6);
heaterGpiosCookie->addGpio(gpioIds::HEATER_6, &gpioConfigHeater6);
GpiodRegular gpioConfigHeater7(std::string("gpiochip7"), 11, std::string("Heater7"), gpio::OUT,
0);
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpioConfigHeater7);
heaterGpiosCookie->addGpio(gpioIds::HEATER_7, &gpioConfigHeater7);
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, objects::PCDU_HANDLER,
pcduSwitches::TCS_BOARD_8V_HEATER_IN);
@ -167,10 +174,10 @@ void ObjectFactory::produce(){
GpiodRegular gpioConfigDeplSA0(std::string("gpiochip7"), 4,
std::string("DeplSA1"), gpio::OUT, 0);
solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpioConfigDeplSA0);
solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, &gpioConfigDeplSA0);
GpiodRegular gpioConfigDeplSA1(std::string("gpiochip7"), 2,
std::string("DeplSA2"), gpio::OUT, 0);
solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpioConfigDeplSA1);
solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, &gpioConfigDeplSA1);
//TODO: Find out burn time. For now set to 1000 ms.
new SolarArrayDeploymentHandler(objects::SOLAR_ARRAY_DEPL_HANDLER, objects::GPIO_IF,
@ -185,6 +192,25 @@ void ObjectFactory::produce(){
objects::UART_COM_IF, syrlinksUartCookie);
syrlinksHkHandler->setModeNormal();
GpioCookie* rtdGpioCookie = new GpioCookie;
gpioCallbacks::initTcsBoardDecoder(gpioComIF);
GpioCallback gpioRtdIc3(std::string("Chip select RTD IC3"), gpio::OUT, 1,
&gpioCallbacks::tcsBoardDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC3, &gpioRtdIc3);
GpioCallback gpioRtdIc4(std::string("Chip select RTD IC4"), gpio::OUT, 1,
&gpioCallbacks::tcsBoardDecoderCallback, gpioComIF);
rtdGpioCookie->addGpio(gpioIds::RTD_IC4, &gpioRtdIc4);
SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC3, gpioIds::RTD_IC3,
std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE,
spi::SpiMode::MODE_1, 2000000);
SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC4, gpioIds::RTD_IC4,
std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE,
spi::SpiMode::MODE_1, 2000000);
new Max31865PT1000Handler(objects::RTD_IC3, objects::SPI_COM_IF, spiRtdIc3, 0); // 0 is switchId
new Max31865PT1000Handler(objects::RTD_IC4, objects::SPI_COM_IF, spiRtdIc4, 0);
#endif
new TmTcUnixUdpBridge(objects::UDP_BRIDGE,

View File

@ -0,0 +1,3 @@
target_sources(${TARGET_NAME} PRIVATE
gpioCallbacks.cpp
)

View File

@ -0,0 +1,220 @@
#include <bsp_q7s/gpio/gpioCallbacks.h>
#include <fsfwconfig/devices/gpioIds.h>
#include <linux/gpio/LinuxLibgpioIF.h>
#include <linux/gpio/GpioCookie.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
namespace gpioCallbacks {
GpioIF* gpioComInterface;
void initTcsBoardDecoder(GpioIF* gpioComIF) {
ReturnValue_t result;
if (gpioComIF == nullptr) {
sif::debug << "initTcsBoardDecoder: Invalid gpioComIF" << std::endl;
return;
}
gpioComInterface = gpioComIF;
GpioCookie* spiMuxGpios = new GpioCookie;
/**
* Initial values of the spi mux gpios can all be set to an arbitrary value expect for spi mux
* bit 1. Setting spi mux bit 1 to high will pull all decoder outputs to high voltage level.
*/
GpiodRegular spiMuxBit1(std::string("gpiochip7"), 13, std::string("SPI Mux Bit 1"), gpio::OUT,
1);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, &spiMuxBit1);
GpiodRegular spiMuxBit2(std::string("gpiochip7"), 14, std::string("SPI Mux Bit 2"), gpio::OUT,
0);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, &spiMuxBit2);
GpiodRegular spiMuxBit3(std::string("gpiochip7"), 15, std::string("SPI Mux Bit 3"), gpio::OUT,
0);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, &spiMuxBit3);
GpiodRegular spiMuxBit4(std::string("gpiochip7"), 16, std::string("SPI Mux Bit 4"), gpio::OUT,
0);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, &spiMuxBit4);
GpiodRegular spiMuxBit5(std::string("gpiochip7"), 17, std::string("SPI Mux Bit 5"), gpio::OUT,
0);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, &spiMuxBit5);
GpiodRegular spiMuxBit6(std::string("gpiochip7"), 18, std::string("SPI Mux Bit 6"), gpio::OUT,
0);
spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, &spiMuxBit6);
result = gpioComInterface->addGpios(spiMuxGpios);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "initTcsBoardDecoder: Failed to add mux bit gpios to gpioComIF"
<< std::endl;
return;
}
}
void tcsBoardDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value,
void* args) {
if (gpioComInterface == nullptr) {
sif::debug << "tcsBoardDecoderCallback: No gpioComIF specified. Call initTcsBoardDecoder "
<< "to specify gpioComIF" << std::endl;
return;
}
/* Read is not supported by the callback function */
if (gpioOp == gpio::GpioOperation::READ) {
return;
}
if (value == 1) {
/* This will pull all 16 decoder outputs to high */
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1);
}
else if (value == 0) {
switch (gpioId) {
case(gpioIds::RTD_IC3): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC4): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC5): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC6): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC7): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC8): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC9): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC10): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC11): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC12): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC13): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC14): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC15): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC16): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC17): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
case(gpioIds::RTD_IC18): {
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1);
gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5);
gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6);
break;
}
default:
sif::debug << "tcsBoardDecoderCallback: Invalid gpioid " << gpioId << std::endl;
}
}
else {
sif::debug << "tcsBoardDecoderCallback: Invalid value. Must be 0 or 1" << std::endl;
}
}
}

View File

@ -0,0 +1,23 @@
#ifndef LINUX_GPIO_GPIOCALLBACKS_H_
#define LINUX_GPIO_GPIOCALLBACKS_H_
#include <linux/gpio/gpioDefinitions.h>
#include <linux/gpio/GpioIF.h>
namespace gpioCallbacks {
/**
* @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on
* the TCS Board.
*/
void initTcsBoardDecoder(GpioIF* gpioComIF);
/**
* @brief This function implements the decoding to multiply gpios by using the two decoder
* chips SN74LVC138APWR on the TCS board.
*/
void tcsBoardDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args);
}
#endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */

View File

@ -30,6 +30,25 @@ namespace addresses {
TMP1075_TCS_2 = 73,
};
enum spiAddresses: address_t {
RTD_IC3,
RTD_IC4,
RTD_IC5,
RTD_IC6,
RTD_IC7,
RTD_IC8,
RTD_IC9,
RTD_IC10,
RTD_IC11,
RTD_IC12,
RTD_IC13,
RTD_IC14,
RTD_IC15,
RTD_IC16,
RTD_IC17,
RTD_IC18
};
/* Addresses of devices supporting the CSP protocol */
enum cspAddresses: uint8_t {
P60DOCK = 4,

View File

@ -25,7 +25,31 @@ namespace gpioIds {
MGM_3_RM3100_CS,
TEST_ID_0,
TEST_ID_1
TEST_ID_1,
RTD_IC3,
RTD_IC4,
RTD_IC5,
RTD_IC6,
RTD_IC7,
RTD_IC8,
RTD_IC9,
RTD_IC10,
RTD_IC11,
RTD_IC12,
RTD_IC13,
RTD_IC14,
RTD_IC15,
RTD_IC16,
RTD_IC17,
RTD_IC18,
SPI_MUX_BIT_1,
SPI_MUX_BIT_2,
SPI_MUX_BIT_3,
SPI_MUX_BIT_4,
SPI_MUX_BIT_5,
SPI_MUX_BIT_6
};
}

View File

@ -59,6 +59,26 @@ namespace objects {
/* 0x54 ('T') for thermal objects */
HEATER_HANDLER = 0x54000003,
/**
* Not yet specified which pt1000 will measure which device/location in the satellite.
* Therefore object ids are named according to the IC naming of the RTDs in the schematic.
*/
RTD_IC3 = 0x54000004,
RTD_IC4 = 0x54000005,
RTD_IC5 = 0x54000006,
RTD_IC6 = 0x54000007,
RTD_IC7 = 0x54000008,
RTD_IC8 = 0x54000009,
RTD_IC9 = 0x5400000A,
RTD_IC10 = 0x5400000B,
RTD_IC11 = 0x5400000C,
RTD_IC12 = 0x5400000D,
RTD_IC13 = 0x5400000E,
RTD_IC14 = 0x5400000F,
RTD_IC15 = 0x5400001F,
RTD_IC16 = 0x5400002F,
RTD_IC17 = 0x5400003F,
RTD_IC18 = 0x5400004F,
/* 0x54 ('T') for test handlers */
TEST_TASK = 0x54694269,

View File

@ -137,37 +137,37 @@ void SpiTestClass::acsInit() {
{
GpiodRegular gpio(rpiGpioName, mgm0Lis3ChipSelect, "MGM_0_LIS3",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, &gpio);
}
{
GpiodRegular gpio(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, &gpio);
}
{
GpiodRegular gpio(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, &gpio);
}
{
GpiodRegular gpio(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, &gpio);
}
{
GpiodRegular gpio(rpiGpioName, gyro2L3gd20ChipSelect, "GYRO_2_L3G",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::GYRO_2_L3G_CS, gpio);
gpioCookie->addGpio(gpioIds::GYRO_2_L3G_CS, &gpio);
}
{
GpiodRegular gpio(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, &gpio);
}
{
GpiodRegular gpio(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100",
gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, &gpio);
}
if(gpioIF != nullptr) {
gpioIF->addGpios(gpioCookie);

View File

@ -4,10 +4,14 @@
GpioCookie::GpioCookie() {
}
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpiodRegular& gpioConfig){
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){
if (gpioConfig == nullptr) {
sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
auto gpioMapIter = gpioMap.find(gpioId);
if(gpioMapIter == gpioMap.end()) {
auto statusPair = gpioMap.emplace(gpioId, new GpiodRegular(gpioConfig));
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
if (statusPair.second == false) {
#if FSFW_VERBOSE_LEVEL >= 1
sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId <<

View File

@ -23,7 +23,7 @@ public:
virtual ~GpioCookie();
ReturnValue_t addGpio(gpioId_t gpioId, GpiodRegular& gpioConfig);
ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig);
/**
* @brief Get map with registered GPIOs.
*/

View File

@ -60,7 +60,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) {
if(gpioCallback->callback == nullptr) {
return GPIO_INVALID_INSTANCE;
}
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::READ,
gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE,
gpioCallback->initValue, gpioCallback->callbackArgs);
}
}

View File

@ -17,6 +17,7 @@ public:
* @param chipSelect Chip select. gpio::NO_GPIO can be used for hardware slave selects.
* @param spiDev
* @param maxSize
* @param spieSpeed SPI clock frequency in Hz.
*/
SpiCookie(address_t spiAddress, gpioId_t chipSelect, std::string spiDev,
const size_t maxReplySize, spi::SpiMode spiMode, uint32_t spiSpeed);

View File

@ -11,6 +11,7 @@ target_sources(${TARGET_NAME} PUBLIC
PDU2Handler.cpp
ACUHandler.cpp
SyrlinksHkHandler.cpp
Max31865PT1000Handler.cpp
)

View File

@ -1,6 +1,7 @@
#include "Max31865PT1000Handler.h"
#include <bitset>
#include <cmath>
#include "Max31865PT100Handler.h"
Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId,
object_id_t comIF, CookieIF *comCookie, uint8_t switchId):
@ -53,11 +54,11 @@ void Max31865PT1000Handler::doShutDown() {
ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(
DeviceCommandId_t *id) {
if(internalState == InternalState::RUNNING) {
*id = TSensorDefinitions::REQUEST_RTD;
*id = Max31865Definitions::REQUEST_RTD;
return buildCommandFromCommand(*id, nullptr, 0);
}
else if(internalState == InternalState::REQUEST_FAULT_BYTE) {
*id = TSensorDefinitions::REQUEST_FAULT_BYTE;
*id = Max31865Definitions::REQUEST_FAULT_BYTE;
return buildCommandFromCommand(*id, nullptr, 0);
}
else {
@ -73,12 +74,12 @@ ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(
case(InternalState::RUNNING):
return DeviceHandlerBase::NOTHING_TO_SEND;
case(InternalState::CONFIGURE): {
*id = TSensorDefinitions::CONFIG_CMD;
*id = Max31865Definitions::CONFIG_CMD;
uint8_t config[1] = {DEFAULT_CONFIG};
return buildCommandFromCommand(*id, config, 1);
}
case(InternalState::REQUEST_CONFIG): {
*id = TSensorDefinitions::REQUEST_CONFIG;
*id = Max31865Definitions::REQUEST_CONFIG;
return buildCommandFromCommand(*id, nullptr, 0);
}
@ -96,8 +97,8 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(TSensorDefinitions::CONFIG_CMD) : {
commandBuffer[0] = static_cast<uint8_t>(TSensorDefinitions::CONFIG_CMD);
case(Max31865Definitions::CONFIG_CMD) : {
commandBuffer[0] = static_cast<uint8_t>(Max31865Definitions::CONFIG_CMD);
if(commandDataLen == 1) {
commandBuffer[1] = commandData[0];
DeviceHandlerBase::rawPacketLen = 2;
@ -108,17 +109,17 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
return DeviceHandlerIF::NO_COMMAND_DATA;
}
}
case(TSensorDefinitions::REQUEST_CONFIG): {
case(Max31865Definitions::REQUEST_CONFIG): {
commandBuffer[0] = 0x00; // dummy byte
commandBuffer[1] = static_cast<uint8_t>(
TSensorDefinitions::REQUEST_CONFIG);
Max31865Definitions::REQUEST_CONFIG);
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(TSensorDefinitions::REQUEST_RTD): {
case(Max31865Definitions::REQUEST_RTD): {
commandBuffer[0] = static_cast<uint8_t>(
TSensorDefinitions::REQUEST_RTD);
Max31865Definitions::REQUEST_RTD);
// two dummy bytes
commandBuffer[1] = 0x00;
commandBuffer[2] = 0x00;
@ -126,9 +127,9 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
DeviceHandlerBase::rawPacket = commandBuffer.data();
return HasReturnvaluesIF::RETURN_OK;
}
case(TSensorDefinitions::REQUEST_FAULT_BYTE): {
case(Max31865Definitions::REQUEST_FAULT_BYTE): {
commandBuffer[0] = static_cast<uint8_t>(
TSensorDefinitions::REQUEST_FAULT_BYTE);
Max31865Definitions::REQUEST_FAULT_BYTE);
commandBuffer[1] = 0x00;
DeviceHandlerBase::rawPacketLen = 2;
DeviceHandlerBase::rawPacket = commandBuffer.data();
@ -141,11 +142,11 @@ ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(
}
void Max31865PT1000Handler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(TSensorDefinitions::CONFIG_CMD, 3);
insertInCommandAndReplyMap(TSensorDefinitions::REQUEST_CONFIG, 3);
insertInCommandAndReplyMap(TSensorDefinitions::REQUEST_RTD, 3,
insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3,
&sensorDataset);
insertInCommandAndReplyMap(TSensorDefinitions::REQUEST_FAULT_BYTE, 3);
insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3);
}
ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
@ -155,7 +156,7 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
if(remainingSize == rtdReplySize and
internalState == InternalState::RUNNING) {
*foundId = TSensorDefinitions::REQUEST_RTD;
*foundId = Max31865Definitions::REQUEST_RTD;
*foundLen = rtdReplySize;
}
@ -163,15 +164,15 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
if(internalState == InternalState::CONFIGURE) {
commandExecuted = true;
*foundLen = configReplySize;
*foundId = TSensorDefinitions::CONFIG_CMD;
*foundId = Max31865Definitions::CONFIG_CMD;
}
else if(internalState == InternalState::REQUEST_FAULT_BYTE) {
*foundId = TSensorDefinitions::REQUEST_FAULT_BYTE;
*foundId = Max31865Definitions::REQUEST_FAULT_BYTE;
*foundLen = 2;
internalState = InternalState::RUNNING;
}
else {
*foundId = TSensorDefinitions::REQUEST_CONFIG;
*foundId = Max31865Definitions::REQUEST_CONFIG;
*foundLen = configReplySize;
}
}
@ -182,7 +183,7 @@ ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start,
ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
DeviceCommandId_t id, const uint8_t *packet) {
switch(id) {
case(TSensorDefinitions::REQUEST_CONFIG): {
case(Max31865Definitions::REQUEST_CONFIG): {
if(packet[1] != DEFAULT_CONFIG) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
// it propably would be better if we at least try one restart..
@ -202,7 +203,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
}
break;
}
case(TSensorDefinitions::REQUEST_RTD): {
case(Max31865Definitions::REQUEST_RTD): {
// first bit of LSB reply byte is the fault bit
uint8_t faultBit = packet[2] & 0b0000'0001;
if(faultBit == 1) {
@ -272,7 +273,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(
break;
}
case(TSensorDefinitions::REQUEST_FAULT_BYTE): {
case(Max31865Definitions::REQUEST_FAULT_BYTE): {
faultByte = packet[1];
#if OBSW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -343,9 +344,9 @@ void Max31865PT1000Handler::doTransition(Mode_t modeFrom,
ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(TSensorDefinitions::PoolIds::TEMPERATURE_C,
localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C,
new PoolEntry<float>({0}, 1, true));
localDataPoolMap.emplace(TSensorDefinitions::PoolIds::FAULT_BYTE,
localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE,
new PoolEntry<uint8_t>({0}));
poolManager.subscribeForPeriodicPacket(sensorDatasetSid,
false, 4.0, false);

View File

@ -1,7 +1,6 @@
#ifndef MISSION_DEVICES_MAX31865PT100HANDLER_H_
#define MISSION_DEVICES_MAX31865PT100HANDLER_H_
#ifndef MISSION_DEVICES_MAX31865PT1000HANDLER_H_
#define MISSION_DEVICES_MAX31865PT1000HANDLER_H_
#include "devicedefinitions/ThermalSensorPacket.h"
#include <OBSWConfig.h>
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
@ -9,6 +8,7 @@
#include <array>
#include <cstdint>
#include "devicedefinitions/Max31865Definitions.h"
/**
* @brief Device Handler for the thermal sensors
@ -92,7 +92,7 @@ private:
uint8_t faultByte = 0;
std::array<uint8_t, 3> commandBuffer { 0 };
TSensorDefinitions::ThermalSensorDataset sensorDataset;
Max31865Definitions::Max31865Set sensorDataset;
sid_t sensorDatasetSid;
#if OBSW_VERBOSE_LEVEL >= 1
@ -100,5 +100,5 @@ private:
#endif
};
#endif /* MISSION_DEVICES_MAX31865PT100HANDLER_H_ */
#endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */

View File

@ -6,15 +6,7 @@
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfwconfig/objects/systemObjectList.h>
namespace TSensorDefinitions {
enum ObjIds: object_id_t {
TEST_HKB_HANDLER = objects::SPI_Test_PT1000,
SYRLINKS_HANDLER = objects::PT1000_Syrlinks_DEC1_O1,
MGT_1_HANDLER = objects::PT1000_MGT1_DEC2,
PLOC_HANDLER = objects::PT1000_PLOC_DEC4,
MESHCAM_HANDLER = objects::PT1000_Camera_DEC1_O2
};
namespace Max31865Definitions {
enum PoolIds: lp_id_t {
TEMPERATURE_C,
@ -26,9 +18,11 @@ static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00;
static constexpr DeviceCommandId_t REQUEST_RTD = 0x01;
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07;
static constexpr uint32_t THERMAL_SENSOR_SET_ID = REQUEST_RTD;
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
class ThermalSensorDataset:
static constexpr size_t MAX_REPLY_SIZE = 5;
class Max31865Set:
public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
public:
/**
@ -36,16 +30,16 @@ public:
* @param owner
* @param setId
*/
ThermalSensorDataset(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, THERMAL_SENSOR_SET_ID) {
Max31865Set(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, MAX31865_SET_ID) {
}
/**
* Constructor used by data users like controllers.
* @param sid
*/
ThermalSensorDataset(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, THERMAL_SENSOR_SET_ID)) {
Max31865Set(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {
}
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId,