Update Package #94

Merged
meierj merged 19 commits from mueller/update-package into develop 2021-09-17 08:01:18 +02:00
26 changed files with 196 additions and 770 deletions

View File

@ -5,7 +5,7 @@
namespace pcduSwitches { namespace pcduSwitches {
/* Switches are uint8_t datatype and go from 0 to 255 */ /* Switches are uint8_t datatype and go from 0 to 255 */
enum switcherList { enum SwitcherList {
Q7S, Q7S,
PAYLOAD_PCDU_CH1, PAYLOAD_PCDU_CH1,
RW, RW,
@ -22,7 +22,7 @@ namespace pcduSwitches {
SUS_NOMINAL, SUS_NOMINAL,
SOLAR_CELL_EXP, SOLAR_CELL_EXP,
PLOC, PLOC,
ACS_BORAD_SIDE_A, ACS_BOARD_SIDE_A,
NUMBER_OF_SWITCHES NUMBER_OF_SWITCHES
}; };

View File

@ -33,17 +33,21 @@ static const char* const GPIO_RW_DEFAULT_CHIP = GPIO_FLEX_OBC1F_B0;
static const char* const GPIO_RAD_SENSOR_CHIP = GPIO_FLEX_OBC1F_B0; static const char* const GPIO_RAD_SENSOR_CHIP = GPIO_FLEX_OBC1F_B0;
static constexpr uint32_t GPIO_RW_0_CS = 7; // B20 static constexpr uint32_t GPIO_RW_0_CS = 7; // B20
static constexpr uint32_t GPIO_RW_1_CS = 3; static constexpr uint32_t GPIO_RW_1_CS = 3; // G22
static constexpr uint32_t GPIO_RW_2_CS = 11; static constexpr uint32_t GPIO_RW_2_CS = 11; // E18
static constexpr uint32_t GPIO_RW_3_CS = 6; static constexpr uint32_t GPIO_RW_3_CS = 6; // B19
static constexpr uint32_t GPIO_GYRO_1_L3G_CS = 18; static constexpr uint32_t GPIO_GYRO_1_L3G_CS = 18; // N22
static constexpr uint32_t GPIO_GYRO_3_L3G_CS = 1; static constexpr uint32_t GPIO_GYRO_3_L3G_CS = 1; // M21
static constexpr uint32_t GPIO_MGM_0_LIS3_CS = 5; static constexpr uint32_t GPIO_MGM_0_LIS3_CS = 5; // C18
static constexpr uint32_t GPIO_MGM_1_RM3100_CS = 16; // MGM_2 is part of gpiochip6
static constexpr uint32_t GPIO_MGM_1_RM3100_CS = 16; // A16
static constexpr uint32_t GPIO_MGM_3_RM3100_CS = 10; // C17
static constexpr uint32_t GPIO_MGM_3_RM3100_CS = 10; // Active low enable pin (needs to be driven low for regular operations)
// Active low reset pin static constexpr uint32_t GPIO_GYRO_0_ENABLE = 2; // H22
// Active low reset pin (needs to be driven high for regular operations)
static constexpr uint32_t GPIO_RESET_GNSS_0 = 9; // C22 static constexpr uint32_t GPIO_RESET_GNSS_0 = 9; // C22
static constexpr uint32_t GPIO_RESET_GNSS_1 = 12; // B21 static constexpr uint32_t GPIO_RESET_GNSS_1 = 12; // B21
@ -54,7 +58,7 @@ static constexpr uint32_t GPIO_RAD_SENSOR_CS = 19; // R18
/**************************************************************/ /**************************************************************/
static constexpr char GPIO_FLEX_OBC1F_B1[] = "gpiochip6"; static constexpr char GPIO_FLEX_OBC1F_B1[] = "gpiochip6";
static const char* const GPIO_MGM2_LIS3_CHIP = GPIO_FLEX_OBC1F_B1; static const char* const GPIO_MGM2_LIS3_CHIP = GPIO_FLEX_OBC1F_B1;
static constexpr uint32_t GPIO_MGM_2_LIS3_CS = 0; static constexpr uint32_t GPIO_MGM_2_LIS3_CS = 0; // D18
/**************************************************************/ /**************************************************************/
/** OBC1C */ /** OBC1C */
@ -70,12 +74,14 @@ static constexpr uint32_t GPIO_HEATER_4_PIN = 3;
static constexpr uint32_t GPIO_HEATER_5_PIN = 0; static constexpr uint32_t GPIO_HEATER_5_PIN = 0;
static constexpr uint32_t GPIO_HEATER_6_PIN = 1; static constexpr uint32_t GPIO_HEATER_6_PIN = 1;
static constexpr uint32_t GPIO_HEATER_7_PIN = 11; static constexpr uint32_t GPIO_HEATER_7_PIN = 11;
static constexpr uint32_t GPIO_GYRO_2_ENABLE = 18; // F22
static constexpr uint32_t GPIO_SOL_DEPL_SA_0_PIN = 4; static constexpr uint32_t GPIO_SOL_DEPL_SA_0_PIN = 4;
static constexpr uint32_t GPIO_SOL_DEPL_SA_1_PIN = 2; static constexpr uint32_t GPIO_SOL_DEPL_SA_1_PIN = 2;
static constexpr char GPIO_RW_SPI_MUX_CHIP[] = "gpiochip11"; static constexpr char GPIO_RW_SPI_MUX_CHIP[] = "gpiochip11";
static constexpr uint32_t GPIO_RW_SPI_MUX_CS = 57; // Uses EMIO interface to PL, starts at 54
static constexpr uint32_t GPIO_RW_SPI_MUX_CS = 54;
} }

View File

@ -30,11 +30,6 @@
#define Q7S_CHECK_FOR_ALREADY_RUNNING_IMG 1 #define Q7S_CHECK_FOR_ALREADY_RUNNING_IMG 1
#define Q7S_ADD_RTD_DEVICES 0 #define Q7S_ADD_RTD_DEVICES 0
// Only one of those 2 should be enabled!
#if OBSW_ADD_ACS_BOARD == 0
#define Q7S_ADD_SPI_TEST 0
#endif
#define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0 #define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0
namespace config { namespace config {

View File

@ -212,7 +212,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen
result = HasReturnvaluesIF::RETURN_OK; result = HasReturnvaluesIF::RETURN_OK;
} }
cookie->assignTransferSize(decodedFrameLen); cookie->setTransferSize(decodedFrameLen);
closeSpi(gpioId, gpioIF, mutex); closeSpi(gpioId, gpioIF, mutex);

View File

@ -121,7 +121,7 @@ void initmission::initTasks() {
std::vector<PeriodicTaskIF*> pstTasks; std::vector<PeriodicTaskIF*> pstTasks;
createPstTasks(*factory, missedDeadlineFunc, pstTasks); createPstTasks(*factory, missedDeadlineFunc, pstTasks);
#if OBSW_ADD_TEST_TASK == 1 #if OBSW_ADD_TEST_CODE == 1
std::vector<PeriodicTaskIF*> testTasks; std::vector<PeriodicTaskIF*> testTasks;
createTestTasks(*factory, missedDeadlineFunc, testTasks); createTestTasks(*factory, missedDeadlineFunc, testTasks);
#endif #endif
@ -147,7 +147,7 @@ void initmission::initTasks() {
taskStarter(pstTasks, "PST task vector"); taskStarter(pstTasks, "PST task vector");
taskStarter(pusTasks, "PUS task vector"); taskStarter(pusTasks, "PUS task vector");
#if OBSW_ADD_TEST_TASK == 1 #if OBSW_ADD_TEST_CODE == 1
taskStarter(testTasks, "Test task vector"); taskStarter(testTasks, "Test task vector");
#endif #endif
@ -167,7 +167,7 @@ void initmission::createPstTasks(TaskFactory& factory,
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
#if BOARD_TE0720 == 0 #if BOARD_TE0720 == 0
/* Polling Sequence Table Default */ /* Polling Sequence Table Default */
#if Q7S_ADD_SPI_TEST == 0 #if OBSW_ADD_SPI_TEST_CODE == 0
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
"PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0,
missedDeadlineFunc); missedDeadlineFunc);
@ -297,7 +297,7 @@ void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFuncti
initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
} }
#if Q7S_ADD_SPI_TEST == 1 #if OBSW_ADD_SPI_TEST_CODE == 1
result = testTask->addComponent(objects::SPI_TEST); result = testTask->addComponent(objects::SPI_TEST);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);

View File

@ -37,7 +37,6 @@
#include "mission/devices/IMTQHandler.h" #include "mission/devices/IMTQHandler.h"
#include "mission/devices/SyrlinksHkHandler.h" #include "mission/devices/SyrlinksHkHandler.h"
#include "mission/devices/MGMHandlerLIS3MDL.h" #include "mission/devices/MGMHandlerLIS3MDL.h"
#include "mission/devices/MGMHandlerRM3100.h"
#include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/PlocMPSoCHandler.h"
#include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RadiationSensorHandler.h"
#include "mission/devices/RwHandler.h" #include "mission/devices/RwHandler.h"
@ -55,6 +54,7 @@
#include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw_hal/linux/uart/UartComIF.h"
#include "fsfw_hal/linux/uart/UartCookie.h" #include "fsfw_hal/linux/uart/UartCookie.h"
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" #include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
#include "fsfw_hal/linux/i2c/I2cCookie.h" #include "fsfw_hal/linux/i2c/I2cCookie.h"
#include "fsfw_hal/linux/i2c/I2cComIF.h" #include "fsfw_hal/linux/i2c/I2cComIF.h"
#include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiCookie.h"
@ -97,6 +97,8 @@ void Factory::setStaticFrameworkObjectIds() {
CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
//DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER;
DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; TmFunnel::downlinkDestination = objects::TMTC_BRIDGE;
// No storage object for now. // No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT; TmFunnel::storageDestination = objects::NO_OBJECT;
@ -121,6 +123,7 @@ void ObjectFactory::produce(void* args){
createPcduComponents(); createPcduComponents();
createRadSensorComponent(gpioComIF); createRadSensorComponent(gpioComIF);
createSunSensorComponents(gpioComIF, spiComIF); createSunSensorComponents(gpioComIF, spiComIF);
#if OBSW_ADD_ACS_BOARD == 1 #if OBSW_ADD_ACS_BOARD == 1
createAcsBoardComponents(gpioComIF, uartComIF); createAcsBoardComponents(gpioComIF, uartComIF);
#endif /* OBSW_ADD_ACS_BOARD == 1 */ #endif /* OBSW_ADD_ACS_BOARD == 1 */
@ -183,7 +186,7 @@ void ObjectFactory::produce(void* args){
/* Test Task */ /* Test Task */
#if OBSW_ADD_TEST_CODE == 1 #if OBSW_ADD_TEST_CODE == 1
createTestComponents(); createTestComponents(gpioComIF);
#endif /* OBSW_ADD_TEST_CODE == 1 */ #endif /* OBSW_ADD_TEST_CODE == 1 */
new PlocUpdater(objects::PLOC_UPDATER); new PlocUpdater(objects::PLOC_UPDATER);
@ -226,9 +229,9 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF,
new CspComIF(objects::CSP_COM_IF); new CspComIF(objects::CSP_COM_IF);
new I2cComIF(objects::I2C_COM_IF); new I2cComIF(objects::I2C_COM_IF);
*uartComIF = new UartComIF(objects::UART_COM_IF); *uartComIF = new UartComIF(objects::UART_COM_IF);
#if Q7S_ADD_SPI_TEST == 0 #if OBSW_ADD_SPI_TEST_CODE == 0
*spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF);
#endif /* Q7S_ADD_SPI_TEST == 0 */ #endif /* Q7S_ADD_SPI_TEST_CODE == 0 */
#if BOARD_TE0720 == 0 #if BOARD_TE0720 == 0
/* Adding gpios for chip select decoding to the gpioComIf */ /* Adding gpios for chip select decoding to the gpioComIf */
@ -431,10 +434,15 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
"GNSS_1_NRESET", gpio::OUT, gpio::HIGH); "GNSS_1_NRESET", gpio::OUT, gpio::HIGH);
gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio);
// Enable pins must be pulled low for regular operations
gpio = new GpiodRegular(q7s::GPIO_FLEX_OBC1F_B0, q7s::GPIO_GYRO_0_ENABLE,
"GYRO_0_ENABLE", gpio::OUT, gpio::LOW);
gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio);
gpio = new GpiodRegular(q7s::GPIO_3V3_OBC1C, q7s::GPIO_GYRO_2_ENABLE,
"GYRO_2_ENABLE", gpio::OUT, gpio::LOW);
gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio);
// TODO: Add enable pins for GPS as soon as new interface board design is finished
// GNSS enable pins must be pulled high
gpioComIF->addGpios(gpioCookieAcsBoard); gpioComIF->addGpios(gpioCookieAcsBoard);
std::string spiDev = q7s::SPI_DEFAULT_DEV; std::string spiDev = q7s::SPI_DEFAULT_DEV;
@ -446,8 +454,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev,
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
auto mgmRm3100Handler = new MGMHandlerRM3100(objects::MGM_1_RM3100_HANDLER, auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER,
objects::SPI_COM_IF, spiCookie); objects::SPI_COM_IF, spiCookie, pcduSwitches::SwitcherList::ACS_BOARD_SIDE_A);
mgmRm3100Handler->setStartUpImmediately(); mgmRm3100Handler->setStartUpImmediately();
spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev,
@ -458,11 +466,10 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev,
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
mgmRm3100Handler = new MGMHandlerRM3100(objects::MGM_3_RM3100_HANDLER, mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER,
objects::SPI_COM_IF, spiCookie); objects::SPI_COM_IF, spiCookie, pcduSwitches::SwitcherList::ACS_BOARD_SIDE_B);
mgmRm3100Handler->setStartUpImmediately(); mgmRm3100Handler->setStartUpImmediately();
// Commented until ACS board V2 in in clean room again // Commented until ACS board V2 in in clean room again
// Gyro 0 Side A // Gyro 0 Side A
spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev,
@ -475,8 +482,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev,
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER,
objects::SPI_COM_IF, spiCookie); objects::SPI_COM_IF, spiCookie, 0);
gyroL3gHandler->setStartUpImmediately(); gyroL3gHandler->setStartUpImmediately();
//gyroL3gHandler->setGoNormalModeAtStartup();
// Gyro 2 Side B // Gyro 2 Side B
spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev,
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE,
@ -488,8 +496,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI
spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev,
L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER,
objects::SPI_COM_IF, spiCookie); objects::SPI_COM_IF, spiCookie, 0);
gyroL3gHandler->setStartUpImmediately(); gyroL3gHandler->setStartUpImmediately();
//gyroL3gHandler->setGoNormalModeAtStartup();
resetArgsGnss1.gnss1 = true; resetArgsGnss1.gnss1 = true;
resetArgsGnss1.gpioComIF = gpioComIF; resetArgsGnss1.gpioComIF = gpioComIF;
@ -806,7 +815,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) {
rw4SpiCookie->setCallbackArgs(rwHandler4); rw4SpiCookie->setCallbackArgs(rwHandler4);
} }
void ObjectFactory::createTestComponents() { void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
#if BOARD_TE0720 == 0 #if BOARD_TE0720 == 0
new Q7STestTask(objects::TEST_TASK); new Q7STestTask(objects::TEST_TASK);
@ -894,7 +903,7 @@ void ObjectFactory::createTestComponents() {
plocSupervisor->setStartUpImmediately(); plocSupervisor->setStartUpImmediately();
#endif #endif
#if Q7S_ADD_SPI_TEST == 1 #if OBSW_ADD_SPI_TEST_CODE == 1
new SpiTestClass(objects::SPI_TEST, gpioComIF); new SpiTestClass(objects::SPI_TEST, gpioComIF);
#endif #endif

View File

@ -22,7 +22,7 @@ void createSolarArrayDeploymentComponents();
void createSyrlinksComponents(); void createSyrlinksComponents();
void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createRtdComponents(LinuxLibgpioIF* gpioComIF);
void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF);
void createTestComponents(); void createTestComponents(LinuxLibgpioIF* gpioComIF);
}; };

View File

@ -11,13 +11,13 @@
namespace spi { namespace spi {
/* Default values, changing them is not supported for now */ /* Default values, changing them is not supported for now */
static constexpr uint32_t DEFAULT_LIS3_SPEED = 3'900'000; static constexpr uint32_t DEFAULT_LIS3_SPEED = 976'000;
static constexpr spi::SpiModes DEFAULT_LIS3_MODE = spi::SpiModes::MODE_3; static constexpr spi::SpiModes DEFAULT_LIS3_MODE = spi::SpiModes::MODE_3;
static constexpr uint32_t DEFAULT_RM3100_SPEED = 976'000; static constexpr uint32_t DEFAULT_RM3100_SPEED = 976'000;
static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3; static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3;
static constexpr uint32_t DEFAULT_L3G_SPEED = 3'900'000; static constexpr uint32_t DEFAULT_L3G_SPEED = 976'000;
static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3; static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3;
static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000; static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000;

2
fsfw

@ -1 +1 @@
Subproject commit 40adca5f1d13ef8d6c712842ebc37e37fe449446 Subproject commit 8f3edc90ba844b9a4551bb77a71e6dcbdae6e9ee

View File

@ -1,5 +1,4 @@
#include "SpiTestClass.h" #include "SpiTestClass.h"
#include "OBSWConfig.h"
#include "devices/gpioIds.h" #include "devices/gpioIds.h"
@ -20,13 +19,12 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <bitset> #include <bitset>
SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId), SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId),
gpioIF(gpioIF) { gpioIF(gpioIF) {
if(gpioIF == nullptr) { if(gpioIF == nullptr) {
sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl;
} }
testMode = TestModes::GYRO_L3GD20H; testMode = TestModes::MGM_RM3100;
spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data());
spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data());
} }
@ -37,11 +35,11 @@ ReturnValue_t SpiTestClass::performOneShotAction() {
break; break;
} }
case(TestModes::MGM_LIS3MDL): { case(TestModes::MGM_LIS3MDL): {
performLis3MdlTest(mgm2Lis3mdlChipSelect); performLis3MdlTest(mgm0Lis3mdlChipSelect);
break; break;
} }
case(TestModes::MGM_RM3100): { case(TestModes::MGM_RM3100): {
performRm3100Test(mgm3Rm3100ChipSelect); performRm3100Test(mgm1Rm3100ChipSelect);
break; break;
} }
case(TestModes::GYRO_L3GD20H): { case(TestModes::GYRO_L3GD20H): {
@ -115,7 +113,7 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
sif::info << "Cycle count Y: " << cycleCountY << std::endl; sif::info << "Cycle count Y: " << cycleCountY << std::endl;
sif::info << "Cycle count z: " << cycleCountZ << std::endl; sif::info << "Cycle count z: " << cycleCountZ << std::endl;
writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x95); writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96);
uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B);
sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " <<
std::hex << "0x" << static_cast<int>(tmrcReg) << std::dec << std::endl; std::hex << "0x" << static_cast<int>(tmrcReg) << std::dec << std::endl;
@ -150,10 +148,10 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
float fieldStrengthY = rawY * scaleFactor; float fieldStrengthY = rawY * scaleFactor;
float fieldStrengthZ = rawZ * scaleFactor; float fieldStrengthZ = rawZ * scaleFactor;
sif::info << "RM3100 measured field strenghts in microtesla:" << std::endl; sif::info << "RM3100 measured field strengths in microtesla:" << std::endl;
sif::info << "Field Strength X: " << fieldStrengthX << " \xC2\xB5T" << std::endl; sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl;
sif::info << "Field Strength Y: " << fieldStrengthY << " \xC2\xB5T" << std::endl; sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl;
sif::info << "Field Strength Z: " << fieldStrengthZ << " \xC2\xB5T" << std::endl; sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl;
} }
void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
@ -174,8 +172,8 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
else { else {
currentGpioId = gpioIds::MGM_2_LIS3_CS; currentGpioId = gpioIds::MGM_2_LIS3_CS;
} }
uint32_t spiSpeed = 3'900'000; uint32_t spiSpeed = 10'000'000;
spi::SpiModes spiMode = spi::SpiModes::MODE_3; spi::SpiModes spiMode = spi::SpiModes::MODE_0;
#ifdef RASPBERRY_PI #ifdef RASPBERRY_PI
std::string deviceName = "/dev/spidev0.0"; std::string deviceName = "/dev/spidev0.0";
#else #else
@ -208,10 +206,10 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
/* Configure all SPI chip selects and pull them high */ /* Configure all SPI chip selects and pull them high */
acsInit(); acsInit();
l3gId = gyro2L3gd20ChipSelect; l3gId = gyro3L3gd20ChipSelect;
/* Adapt accordingly */ /* Adapt accordingly */
if(l3gId != gyro1L3gd20ChipSelect and l3gId != gyro2L3gd20ChipSelect) { if(l3gId != gyro1L3gd20ChipSelect and l3gId != gyro3L3gd20ChipSelect) {
sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl;
} }
gpioId_t currentGpioId = 0; gpioId_t currentGpioId = 0;
@ -331,36 +329,40 @@ void SpiTestClass::acsInit() {
gpio::Direction::OUT, 1); gpio::Direction::OUT, 1);
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
#elif defined(XIPHOS_Q7S) #elif defined(XIPHOS_Q7S)
std::string q7sGpioName5 = "gpiochip5";
std::string q7sGpioName6 = "gpiochip6";
gpio = new GpiodRegular(q7sGpioName5, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, mgm0Lis3mdlChipSelect,
gpio::Direction::OUT, gpio::HIGH); "MGM_0_LIS3", gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, mgm1Rm3100ChipSelect,
gpio = new GpiodRegular(q7sGpioName5, mgm1Rm3100ChipSelect, "MGM_1_RM3100", "MGM_1_RM3100", gpio::Direction::OUT, gpio::HIGH);
gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
gpio = new GpiodRegular(q7s::GPIO_MGM2_LIS3_CHIP, mgm2Lis3mdlChipSelect,
"MGM_2_LIS3", gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, mgm3Rm3100ChipSelect,
"MGM_3_RM3100", gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
gpio = new GpiodRegular(q7sGpioName5, gyro0AdisChipSelect, "GYRO_0_ADIS", gpio = new GpiodRegular(q7s::GPIO_GYRO_ADIS_CHIP, gyro0AdisChipSelect,
gpio::Direction::OUT, gpio::HIGH); "GYRO_0_ADIS", gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, gyro1L3gd20ChipSelect,
gpio = new GpiodRegular(q7sGpioName5, gyro1L3gd20ChipSelect, "GYRO_1_L3G", "GYRO_1_L3G", gpio::Direction::OUT, gpio::HIGH);
gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
gpio = new GpiodRegular(q7s::GPIO_GYRO_ADIS_CHIP, gyro2AdisChipSelect,
gpio = new GpiodRegular(q7sGpioName5, gyro2L3gd20ChipSelect, "GYRO_2_L3G", "GYRO_2_ADIS", gpio::Direction::OUT, gpio::HIGH);
gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio);
gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, gyro3L3gd20ChipSelect,
"GYRO_3_L3G", gpio::Direction::OUT, gpio::HIGH);
gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio);
gpio = new GpiodRegular(q7sGpioName6, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", // Enable pins must be pulled low for regular operations
gpio::Direction::OUT, gpio::HIGH); gpio = new GpiodRegular(q7s::GPIO_FLEX_OBC1F_B0, q7s::GPIO_GYRO_0_ENABLE,
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); "GYRO_0_ENABLE", gpio::OUT, gpio::LOW);
gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio);
gpio = new GpiodRegular(q7sGpioName5, mgm3Rm3100ChipSelect, "MGM_3_RM3100", gpio = new GpiodRegular(q7s::GPIO_3V3_OBC1C, q7s::GPIO_GYRO_2_ENABLE,
gpio::Direction::OUT, gpio::HIGH); "GYRO_2_ENABLE", gpio::OUT, gpio::LOW);
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio);
#endif #endif
if(gpioIF != nullptr) { if(gpioIF != nullptr) {
gpioIF->addGpios(gpioCookie); gpioIF->addGpios(gpioCookie);

View File

@ -1,6 +1,12 @@
#ifndef LINUX_BOARDTEST_SPITESTCLASS_H_ #ifndef LINUX_BOARDTEST_SPITESTCLASS_H_
#define LINUX_BOARDTEST_SPITESTCLASS_H_ #define LINUX_BOARDTEST_SPITESTCLASS_H_
#include "OBSWConfig.h"
#if defined(XIPHOS_Q7S)
#include "busConf.h"
#endif
#include <fsfw_hal/common/gpio/GpioIF.h> #include <fsfw_hal/common/gpio/GpioIF.h>
#include <fsfw_hal/linux/spi/SpiCookie.h> #include <fsfw_hal/linux/spi/SpiCookie.h>
#include <test/testtasks/TestTask.h> #include <test/testtasks/TestTask.h>
@ -47,14 +53,14 @@ private:
uint8_t mgm2Lis3mdlChipSelect = 17; uint8_t mgm2Lis3mdlChipSelect = 17;
uint8_t mgm3Rm3100ChipSelect = 27; uint8_t mgm3Rm3100ChipSelect = 27;
#elif defined(XIPHOS_Q7S) #elif defined(XIPHOS_Q7S)
uint8_t mgm0Lis3mdlChipSelect = 5; uint8_t mgm0Lis3mdlChipSelect = q7s::GPIO_MGM_0_LIS3_CS;
uint8_t mgm1Rm3100ChipSelect = 17; uint8_t mgm1Rm3100ChipSelect = q7s::GPIO_MGM_1_RM3100_CS;
uint8_t gyro0AdisResetLine = 20; uint8_t gyro0AdisChipSelect = q7s::GPIO_GYRO_0_ADIS_CS;
uint8_t gyro0AdisChipSelect = 21; uint8_t gyro2AdisChipSelect = q7s::GPIO_GYRO_2_ADIS_CS;
uint8_t gyro1L3gd20ChipSelect = 10; uint8_t gyro1L3gd20ChipSelect = q7s::GPIO_GYRO_1_L3G_CS;
uint8_t gyro2L3gd20ChipSelect = 3; uint8_t gyro3L3gd20ChipSelect = q7s::GPIO_GYRO_3_L3G_CS;
uint8_t mgm2Lis3mdlChipSelect = 0; uint8_t mgm2Lis3mdlChipSelect = q7s::GPIO_MGM_2_LIS3_CS;
uint8_t mgm3Rm3100ChipSelect = 23; uint8_t mgm3Rm3100ChipSelect = q7s::GPIO_MGM_3_RM3100_CS;
#else #else
uint8_t mgm0Lis3mdlChipSelect = 0; uint8_t mgm0Lis3mdlChipSelect = 0;
uint8_t mgm1Rm3100ChipSelect = 0; uint8_t mgm1Rm3100ChipSelect = 0;

View File

@ -74,5 +74,6 @@ static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0 #define FSFW_HAL_LINUX_SPI_WIRETAPPING 0
#define FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV 0 #define FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV 0
#define FSFW_HAL_L3GD20_GYRO_DEBUG 0
#endif /* CONFIG_FSFWCONFIG_H_ */ #endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -47,7 +47,9 @@ debugging. */
//! /* Can be used to switch device to NORMAL mode immediately */ //! /* Can be used to switch device to NORMAL mode immediately */
#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 #define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1
#define OBSW_PRINT_MISSED_DEADLINES 1 #define OBSW_PRINT_MISSED_DEADLINES 1
#define OBSW_ADD_TEST_CODE 0 // If this is enabled, all other SPI code should be disabled
#define OBSW_ADD_TEST_CODE 1
#define OBSW_ADD_SPI_TEST_CODE 0
#define OBSW_ADD_TEST_PST 0 #define OBSW_ADD_TEST_PST 0
#define OBSW_ADD_TEST_TASK 0 #define OBSW_ADD_TEST_TASK 0
#define OBSW_TEST_LIBGPIOD 0 #define OBSW_TEST_LIBGPIOD 0

View File

@ -28,6 +28,9 @@ enum gpioId_t {
GNSS_0_NRESET, GNSS_0_NRESET,
GNSS_1_NRESET, GNSS_1_NRESET,
GYRO_0_ENABLE,
GYRO_2_ENABLE,
TEST_ID_0, TEST_ID_0,
TEST_ID_1, TEST_ID_1,

View File

@ -5,7 +5,7 @@
namespace pcduSwitches { namespace pcduSwitches {
/* Switches are uint8_t datatype and go from 0 to 255 */ /* Switches are uint8_t datatype and go from 0 to 255 */
enum switcherList { enum SwitcherList: uint8_t {
Q7S, Q7S,
PAYLOAD_PCDU_CH1, PAYLOAD_PCDU_CH1,
RW, RW,
@ -22,7 +22,7 @@ namespace pcduSwitches {
SUS_NOMINAL, SUS_NOMINAL,
SOLAR_CELL_EXP, SOLAR_CELL_EXP,
PLOC, PLOC,
ACS_BORAD_SIDE_A, ACS_BOARD_SIDE_A,
NUMBER_OF_SWITCHES NUMBER_OF_SWITCHES
}; };

View File

@ -425,49 +425,49 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ);
#if OBSW_ADD_ACS_BOARD == 1 #if OBSW_ADD_ACS_BOARD == 1
// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2,
// DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4,
// DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6,
// DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.8, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
//
// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.2,
// DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.4, thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.4,
// DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6,
// DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8, thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
//
// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2,
// DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4,
// DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6,
// DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
//
// thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.2,
// DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.4, thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.4,
// DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6,
// DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, // thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); // DeviceHandlerIF::PERFORM_OPERATION);
@ -480,16 +480,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, // thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); // DeviceHandlerIF::GET_READ);
// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2,
// DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4,
// DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6,
// DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, // thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); // DeviceHandlerIF::PERFORM_OPERATION);
@ -502,16 +502,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
// thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.8, // thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); // DeviceHandlerIF::GET_READ);
// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0,
// DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.2, thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.2,
// DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.4, thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.4,
// DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6,
// DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.8, thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.8,
// DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
#endif /* OBSW_ADD_ACS_BOARD == 1 */ #endif /* OBSW_ADD_ACS_BOARD == 1 */
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {

View File

@ -36,22 +36,22 @@ void ObjectFactory::produceGenericObjects() {
{ {
PoolManager::LocalPoolConfig poolCfg = { PoolManager::LocalPoolConfig poolCfg = {
{100, 16}, {50, 32}, {25, 64}, {15, 128}, {10, 1024}, {5, 2048} {300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048}
}; };
new PoolManager(objects::TC_STORE, poolCfg); new PoolManager(objects::TC_STORE, poolCfg);
} }
{ {
PoolManager::LocalPoolConfig poolCfg = { PoolManager::LocalPoolConfig poolCfg = {
{100, 16}, {50, 32}, {25, 64}, {15, 128}, {10, 1024}, {5, 2048} {300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048}
}; };
new PoolManager(objects::TM_STORE, poolCfg); new PoolManager(objects::TM_STORE, poolCfg);
} }
{ {
PoolManager::LocalPoolConfig poolCfg = { PoolManager::LocalPoolConfig poolCfg = {
{ 100, 16 }, { 100, 32 }, { 100, 64 }, { 300, 16 }, { 200, 32 }, { 150, 64 },
{ 100, 128 }, { 50, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } { 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 }
}; };
new PoolManager(objects::IPC_STORE, poolCfg); new PoolManager(objects::IPC_STORE, poolCfg);
} }

View File

@ -1,7 +1,6 @@
target_sources(${TARGET_NAME} PUBLIC target_sources(${TARGET_NAME} PUBLIC
GPSHyperionHandler.cpp GPSHyperionHandler.cpp
MGMHandlerLIS3MDL.cpp MGMHandlerLIS3MDL.cpp
MGMHandlerRM3100.cpp
GomspaceDeviceHandler.cpp GomspaceDeviceHandler.cpp
Tmp1075Handler.cpp Tmp1075Handler.cpp
PCDUHandler.cpp PCDUHandler.cpp

View File

@ -23,6 +23,7 @@ GPSHyperionHandler::~GPSHyperionHandler() {}
void GPSHyperionHandler::doStartUp() { void GPSHyperionHandler::doStartUp() {
if(internalState == InternalStates::NONE) { if(internalState == InternalStates::NONE) {
commandExecuted = false; commandExecuted = false;
updatePeriodicReply(true, GpsHyperion::GPS_REPLY);
internalState = InternalStates::WAIT_FIRST_MESSAGE; internalState = InternalStates::WAIT_FIRST_MESSAGE;
} }
@ -144,6 +145,7 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len,
gpsFile.open(filename, std::ofstream::out); gpsFile.open(filename, std::ofstream::out);
} }
gpsFile.open(filename, std::ofstream::out | std::ofstream::app); gpsFile.open(filename, std::ofstream::out | std::ofstream::app);
gpsFile.write("\n", 1);
gpsFile.write(reinterpret_cast<const char*>(start), len); gpsFile.write(reinterpret_cast<const char*>(start), len);
#endif #endif
} }

View File

@ -201,7 +201,7 @@ ReturnValue_t GyroADIS16507Handler::interpretDeviceReply(DeviceCommandId_t id,
uint16_t readProdId = packet[10] << 8 | packet[11]; uint16_t readProdId = packet[10] << 8 | packet[11];
if (readProdId != ADIS16507::PROD_ID) { if (readProdId != ADIS16507::PROD_ID) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::debug << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID!" sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID!"
<< std::endl; << std::endl;
#endif #endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
@ -403,7 +403,7 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie *
cookie->getSpiParameters(spiMode, spiSpeed, nullptr); cookie->getSpiParameters(spiMode, spiSpeed, nullptr);
comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
cookie->assignWriteBuffer(sendData); cookie->assignWriteBuffer(sendData);
cookie->assignTransferSize(2); cookie->setTransferSize(2);
gpioId_t gpioId = cookie->getChipSelectPin(); gpioId_t gpioId = cookie->getChipSelectPin();
GpioIF* gpioIF = comIf->getGpioInterface(); GpioIF* gpioIF = comIf->getGpioInterface();

View File

@ -292,14 +292,14 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "MGMHandlerLIS3: Magnetic field strength in" sif::info << "MGMHandlerLIS3: Magnetic field strength in"
" microtesla:" << std::endl; " microtesla:" << std::endl;
sif::info << "X: " << mgmX << " \xC2\xB5T" << std::endl; sif::info << "X: " << mgmX << " uT" << std::endl;
sif::info << "Y: " << mgmY << " \xC2\xB5T" << std::endl; sif::info << "Y: " << mgmY << " uT" << std::endl;
sif::info << "Z: " << mgmZ << " \xC2\xB5T" << std::endl; sif::info << "Z: " << mgmZ << " uT" << std::endl;
#else #else
sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n"); sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n");
sif::printInfo("X: %f " "\xC2\xB5" "T\n", mgmX); sif::printInfo("X: %f uT\n", mgmX);
sif::printInfo("Y: %f " "\xC2\xB5" "T\n", mgmY); sif::printInfo("Y: %f uT\n", mgmY);
sif::printInfo("Z: %f " "\xC2\xB5" "T\n", mgmZ); sif::printInfo("Z: %f uT\n", mgmZ);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
} }
#endif /* OBSW_VERBOSE_LEVEL >= 1 */ #endif /* OBSW_VERBOSE_LEVEL >= 1 */
@ -320,10 +320,10 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
if(debugDivider->check()) { if(debugDivider->check()) {
/* Set terminal to utf-8 if there is an issue with micro printout. */ /* Set terminal to utf-8 if there is an issue with micro printout. */
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " \xC2\xB0" << "C" << sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" <<
std::endl; std::endl;
#else #else
sif::printInfo("MGMHandlerLIS3: Temperature: %f" "\xC2\xB0" "C\n"); sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n");
#endif #endif
} }
#endif #endif

View File

@ -1,363 +0,0 @@
#include "MGMHandlerRM3100.h"
#include "fsfw/datapool/PoolReadGuard.h"
#include "fsfw/globalfunctions/bitutility.h"
#include "fsfw/devicehandlers/DeviceHandlerMessage.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
MGMHandlerRM3100::MGMHandlerRM3100(object_id_t objectId,
object_id_t deviceCommunication, CookieIF* comCookie):
DeviceHandlerBase(objectId, deviceCommunication, comCookie),
primaryDataset(this) {
#if OBSW_VERBOSE_LEVEL >= 1
debugDivider = new PeriodicOperationDivider(5);
#endif
}
MGMHandlerRM3100::~MGMHandlerRM3100() {}
void MGMHandlerRM3100::doStartUp() {
switch(internalState) {
case(InternalState::NONE): {
internalState = InternalState::CONFIGURE_CMM;
break;
}
case(InternalState::CONFIGURE_CMM): {
internalState = InternalState::READ_CMM;
break;
}
case(InternalState::READ_CMM): {
if(commandExecuted) {
internalState = InternalState::STATE_CONFIGURE_TMRC;
}
break;
}
case(InternalState::STATE_CONFIGURE_TMRC): {
if(commandExecuted) {
internalState = InternalState::STATE_READ_TMRC;
}
break;
}
case(InternalState::STATE_READ_TMRC): {
if(commandExecuted) {
internalState = InternalState::NORMAL;
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
#else
setMode(_MODE_TO_ON);
#endif
}
break;
}
default: {
break;
}
}
}
void MGMHandlerRM3100::doShutDown() {
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t MGMHandlerRM3100::buildTransitionDeviceCommand(
DeviceCommandId_t *id) {
switch(internalState) {
case(InternalState::NONE):
case(InternalState::NORMAL): {
return HasReturnvaluesIF::RETURN_OK;
}
case(InternalState::CONFIGURE_CMM): {
*id = RM3100::CONFIGURE_CMM;
break;
}
case(InternalState::READ_CMM): {
*id = RM3100::READ_CMM;
break;
}
case(InternalState::STATE_CONFIGURE_TMRC): {
*id = RM3100::CONFIGURE_TMRC;
break;
}
case(InternalState::STATE_READ_TMRC): {
*id = RM3100::READ_TMRC;
break;
}
default:
/* Might be a configuration error. */
sif::debug << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" <<
std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
return buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t MGMHandlerRM3100::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) {
switch(deviceCommand) {
case(RM3100::CONFIGURE_CMM): {
commandBuffer[0] = RM3100::CMM_REGISTER;
commandBuffer[1] = RM3100::CMM_VALUE;
rawPacket = commandBuffer;
rawPacketLen = 2;
break;
}
case(RM3100::READ_CMM): {
commandBuffer[0] = RM3100::CMM_REGISTER | RM3100::READ_MASK;
commandBuffer[1] = 0;
rawPacket = commandBuffer;
rawPacketLen = 2;
break;
}
case(RM3100::CONFIGURE_TMRC): {
return handleTmrcConfigCommand(deviceCommand, commandData,
commandDataLen);
}
case(RM3100::READ_TMRC): {
commandBuffer[0] = RM3100::TMRC_REGISTER | RM3100::READ_MASK;
commandBuffer[1] = 0;
rawPacket = commandBuffer;
rawPacketLen = 2;
break;
}
case(RM3100::CONFIGURE_CYCLE_COUNT): {
return handleCycleCountConfigCommand(deviceCommand, commandData,
commandDataLen);
}
case(RM3100::READ_CYCLE_COUNT): {
commandBuffer[0] = RM3100::CYCLE_COUNT_START_REGISTER | RM3100::READ_MASK;
std::memset(commandBuffer + 1, 0, 6);
rawPacket = commandBuffer;
rawPacketLen = 7;
break;
}
case(RM3100::READ_DATA): {
commandBuffer[0] = RM3100::MEASUREMENT_REG_START | RM3100::READ_MASK;
std::memset(commandBuffer + 1, 0, 9);
rawPacketLen = 10;
break;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
return RETURN_OK;
}
ReturnValue_t MGMHandlerRM3100::buildNormalDeviceCommand(
DeviceCommandId_t *id) {
*id = RM3100::READ_DATA;
return buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t MGMHandlerRM3100::scanForReply(const uint8_t *start,
size_t len, DeviceCommandId_t *foundId,
size_t *foundLen) {
/* For SPI, ID will always be the one of the last sent command. */
*foundId = this->getPendingCommand();
*foundLen = len;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(
DeviceCommandId_t id, const uint8_t *packet) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
switch(id) {
case(RM3100::CONFIGURE_CMM):
case(RM3100::CONFIGURE_CYCLE_COUNT):
case(RM3100::CONFIGURE_TMRC): {
/* We can only check whether write was successful with read operation. */
if(mode == _MODE_START_UP) {
commandExecuted = true;
}
break;
}
case(RM3100::READ_CMM): {
uint8_t cmmValue = packet[1];
/* We clear the seventh bit in any case
* because this one is zero sometimes for some reason */
bitutil::bitClear(&cmmValue, 6);
if(cmmValue == cmmRegValue and internalState == InternalState::READ_CMM) {
commandExecuted = true;
}
else {
/* Attempt reconfiguration. */
internalState = InternalState::CONFIGURE_CMM;
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
break;
}
case(RM3100::READ_TMRC): {
if(packet[1] == tmrcRegValue) {
commandExecuted = true;
/* Reading TMRC was commanded. Trigger event to inform ground. */
if(mode != _MODE_START_UP) {
triggerEvent(tmrcSet, tmrcRegValue, 0);
}
}
else {
/* Attempt reconfiguration. */
internalState = InternalState::STATE_CONFIGURE_TMRC;
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
break;
}
case(RM3100::READ_CYCLE_COUNT): {
uint16_t cycleCountX = packet[1] << 8 | packet[2];
uint16_t cycleCountY = packet[3] << 8 | packet[4];
uint16_t cycleCountZ = packet[5] << 8 | packet[6];
if(cycleCountX != cycleCountRegValueX or cycleCountY != cycleCountRegValueY or
cycleCountZ != cycleCountRegValueZ) {
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
}
/* Reading TMRC was commanded. Trigger event to inform ground. */
if(mode != _MODE_START_UP) {
uint32_t eventParam1 = (cycleCountX << 16) | cycleCountY;
triggerEvent(cycleCountersSet, eventParam1, cycleCountZ);
}
break;
}
case(RM3100::READ_DATA): {
result = handleDataReadout(packet);
break;
}
default:
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
return result;
}
ReturnValue_t MGMHandlerRM3100::handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData, size_t commandDataLen) {
if(commandData == nullptr) {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
// Set cycle count
if(commandDataLen == 2) {
handleCycleCommand(true, commandData, commandDataLen);
}
else if(commandDataLen == 6) {
handleCycleCommand(false, commandData, commandDataLen);
}
else {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
commandBuffer[0] = RM3100::CYCLE_COUNT_VALUE;
std::memcpy(commandBuffer + 1, &cycleCountRegValueX, 2);
std::memcpy(commandBuffer + 3, &cycleCountRegValueY, 2);
std::memcpy(commandBuffer + 5, &cycleCountRegValueZ, 2);
rawPacketLen = 7;
rawPacket = commandBuffer;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t MGMHandlerRM3100::handleCycleCommand(bool oneCycleValue,
const uint8_t *commandData, size_t commandDataLen) {
RM3100::CycleCountCommand command(oneCycleValue);
ReturnValue_t result = command.deSerialize(&commandData, &commandDataLen,
SerializeIF::Endianness::BIG);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
/* Data sheet p.30 "while noise limits the useful upper range to ~400 cycle counts." */
if(command.cycleCountX > 450 ) {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
if(not oneCycleValue and (command.cycleCountY > 450 or command.cycleCountZ > 450)) {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
cycleCountRegValueX = command.cycleCountX;
cycleCountRegValueY = command.cycleCountY;
cycleCountRegValueZ = command.cycleCountZ;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) {
if(commandData == nullptr) {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
if(commandDataLen != 1) {
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
}
commandBuffer[0] = RM3100::TMRC_REGISTER;
commandBuffer[1] = commandData[1];
rawPacketLen = 2;
rawPacket = commandBuffer;
return HasReturnvaluesIF::RETURN_OK;
}
void MGMHandlerRM3100::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(RM3100::CONFIGURE_CMM, 1);
insertInCommandAndReplyMap(RM3100::READ_CMM, 1);
insertInCommandAndReplyMap(RM3100::CONFIGURE_TMRC, 1);
insertInCommandAndReplyMap(RM3100::READ_TMRC, 1);
insertInCommandAndReplyMap(RM3100::CONFIGURE_CYCLE_COUNT, 1);
insertInCommandAndReplyMap(RM3100::READ_CYCLE_COUNT, 1);
insertInCommandAndReplyMap(RM3100::READ_DATA, 1, &primaryDataset);
}
void MGMHandlerRM3100::modeChanged(void) {
internalState = InternalState::NONE;
}
ReturnValue_t MGMHandlerRM3100::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z, new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t MGMHandlerRM3100::getTransitionDelayMs(Mode_t from, Mode_t to) {
return 10000;
}
ReturnValue_t MGMHandlerRM3100::handleDataReadout(const uint8_t *packet) {
/* Analyze data here. The sensor generates 24 bit signed values so we need to do some bitshift
* trickery here to calculate the raw values first */
int32_t fieldStrengthRawX = ((packet[1] << 24) | (packet[2] << 16) | (packet[3] << 8)) >> 8;
int32_t fieldStrengthRawY = ((packet[4] << 24) | (packet[5] << 16) | (packet[6] << 8)) >> 8;
int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8;
/* Now scale to physical value in microtesla */
float fieldStrengthX = fieldStrengthRawX * scaleFactorX;
float fieldStrengthY = fieldStrengthRawY * scaleFactorX;
float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX;
#if OBSW_VERBOSE_LEVEL >= 1
if(debugDivider->checkAndIncrement()) {
sif::info << "MGMHandlerRM3100: Magnetic field strength in"
" microtesla:" << std::endl;
/* Set terminal to utf-8 if there is an issue with micro printout. */
sif::info << "X: " << fieldStrengthX << " \xC2\xB5T" << std::endl;
sif::info << "Y: " << fieldStrengthY << " \xC2\xB5T" << std::endl;
sif::info << "Z: " << fieldStrengthZ << " \xC2\xB5T" << std::endl;
}
#endif
/* TODO: Sanity check on values */
PoolReadGuard readGuard(&primaryDataset);
if(readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) {
primaryDataset.fieldStrengthX = fieldStrengthX;
primaryDataset.fieldStrengthY = fieldStrengthY;
primaryDataset.fieldStrengthZ = fieldStrengthZ;
primaryDataset.setValidity(true, true);
}
return RETURN_OK;
}

View File

@ -1,104 +0,0 @@
#ifndef MISSION_DEVICES_MGMRM3100HANDLER_H_
#define MISSION_DEVICES_MGMRM3100HANDLER_H_
#include "OBSWConfig.h"
#include "devicedefinitions/MGMHandlerRM3100Definitions.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#if OBSW_VERBOSE_LEVEL >= 1
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
#endif
/**
* @brief Device Handler for the RM3100 geomagnetic magnetometer sensor
* (https://www.pnicorp.com/rm3100/)
* @details
* Flight manual:
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/RM3100_MGM
*/
class MGMHandlerRM3100: public DeviceHandlerBase {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::MGM_RM3100;
//! [EXPORT] : [COMMENT] P1: TMRC value which was set, P2: 0
static constexpr Event tmrcSet = event::makeEvent(SUBSYSTEM_ID::MGM_RM3100,
0x00, severity::INFO);
//! [EXPORT] : [COMMENT] Cycle counter set. P1: First two bytes new Cycle Count X
//! P1: Second two bytes new Cycle Count Y
//! P2: New cycle count Z
static constexpr Event cycleCountersSet = event::makeEvent(
SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO);
MGMHandlerRM3100(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie);
virtual ~MGMHandlerRM3100();
protected:
/* DeviceHandlerBase overrides */
ReturnValue_t buildTransitionDeviceCommand(
DeviceCommandId_t *id) override;
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(
DeviceCommandId_t *id) override;
ReturnValue_t buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void fillCommandAndReplyMap() override;
void modeChanged(void) override;
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
private:
enum class InternalState {
NONE,
CONFIGURE_CMM,
READ_CMM,
// The cycle count states are propably not going to be used because
// the default cycle count will be used.
STATE_CONFIGURE_CYCLE_COUNT,
STATE_READ_CYCLE_COUNT,
STATE_CONFIGURE_TMRC,
STATE_READ_TMRC,
NORMAL
};
InternalState internalState = InternalState::NONE;
bool commandExecuted = false;
RM3100::Rm3100PrimaryDataset primaryDataset;
uint8_t commandBuffer[10];
uint8_t commandBufferLen = 0;
uint8_t cmmRegValue = RM3100::CMM_VALUE;
uint8_t tmrcRegValue = RM3100::TMRC_DEFAULT_VALUE;
uint16_t cycleCountRegValueX = RM3100::CYCLE_COUNT_VALUE;
uint16_t cycleCountRegValueY = RM3100::CYCLE_COUNT_VALUE;
uint16_t cycleCountRegValueZ = RM3100::CYCLE_COUNT_VALUE;
float scaleFactorX = 1 / RM3100::DEFAULT_GAIN;
float scaleFactorY = 1 / RM3100::DEFAULT_GAIN;
float scaleFactorZ = 1 / RM3100::DEFAULT_GAIN;
ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,size_t commandDataLen);
ReturnValue_t handleCycleCommand(bool oneCycleValue,
const uint8_t *commandData, size_t commandDataLen);
ReturnValue_t handleTmrcConfigCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData,size_t commandDataLen);
ReturnValue_t handleDataReadout(const uint8_t* packet);
#if OBSW_VERBOSE_LEVEL >= 1
PeriodicOperationDivider* debugDivider;
#endif
};
#endif /* MISSION_DEVICEHANDLING_MGMRM3100HANDLER_H_ */

View File

@ -93,7 +93,7 @@ void PCDUHandler::initializeSwitchStates() {
switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL;
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP;
switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC;
switchStates[pcduSwitches::ACS_BORAD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A;
} }
void PCDUHandler::readCommandQueue() { void PCDUHandler::readCommandQueue() {
@ -186,7 +186,7 @@ void PCDUHandler::updatePdu1SwitchStates() {
switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value;
switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value;
switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value;
switchStates[pcduSwitches::ACS_BORAD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value;
} }
else { else {
sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl;

View File

@ -1,132 +0,0 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h>
#include <cstdint>
namespace RM3100 {
/* Actually 10, we round up a little bit */
static constexpr size_t MAX_BUFFER_SIZE = 12;
static constexpr uint8_t READ_MASK = 0x80;
/*----------------------------------------------------------------------------*/
/* CMM Register */
/*----------------------------------------------------------------------------*/
static constexpr uint8_t SET_CMM_CMZ = 1 << 6;
static constexpr uint8_t SET_CMM_CMY = 1 << 5;
static constexpr uint8_t SET_CMM_CMX = 1 << 4;
static constexpr uint8_t SET_CMM_DRDM = 1 << 2;
static constexpr uint8_t SET_CMM_START = 1;
static constexpr uint8_t CMM_REGISTER = 0x01;
static constexpr uint8_t CMM_VALUE = SET_CMM_CMZ | SET_CMM_CMY | SET_CMM_CMX |
SET_CMM_DRDM | SET_CMM_START;
/*----------------------------------------------------------------------------*/
/* Cycle count register */
/*----------------------------------------------------------------------------*/
// Default value (200)
static constexpr uint8_t CYCLE_COUNT_VALUE = 0xC8;
static constexpr float DEFAULT_GAIN = static_cast<float>(CYCLE_COUNT_VALUE) /
100 * 38;
static constexpr uint8_t CYCLE_COUNT_START_REGISTER = 0x04;
/*----------------------------------------------------------------------------*/
/* TMRC register */
/*----------------------------------------------------------------------------*/
static constexpr uint8_t TMRC_150HZ_VALUE = 0x94;
static constexpr uint8_t TMRC_75HZ_VALUE = 0x95;
static constexpr uint8_t TMRC_DEFAULT_37HZ_VALUE = 0x96;
static constexpr uint8_t TMRC_REGISTER = 0x0B;
static constexpr uint8_t TMRC_DEFAULT_VALUE = TMRC_DEFAULT_37HZ_VALUE;
static constexpr uint8_t MEASUREMENT_REG_START = 0x24;
static constexpr uint8_t BIST_REGISTER = 0x33;
static constexpr uint8_t DATA_READY_VAL = 0b1000'0000;
static constexpr uint8_t STATUS_REGISTER = 0x34;
static constexpr uint8_t REVID_REGISTER = 0x36;
// Range in Microtesla. 1 T equals 10000 Gauss (for comparison with LIS3 MGM)
static constexpr uint16_t RANGE = 800;
static constexpr DeviceCommandId_t READ_DATA = 0;
static constexpr DeviceCommandId_t CONFIGURE_CMM = 1;
static constexpr DeviceCommandId_t READ_CMM = 2;
static constexpr DeviceCommandId_t CONFIGURE_TMRC = 3;
static constexpr DeviceCommandId_t READ_TMRC = 4;
static constexpr DeviceCommandId_t CONFIGURE_CYCLE_COUNT = 5;
static constexpr DeviceCommandId_t READ_CYCLE_COUNT = 6;
class CycleCountCommand: public SerialLinkedListAdapter<SerializeIF> {
public:
CycleCountCommand(bool oneCycleCount = true): oneCycleCount(oneCycleCount) {
setLinks(oneCycleCount);
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override {
ReturnValue_t result = SerialLinkedListAdapter::deSerialize(buffer,
size, streamEndianness);
if(oneCycleCount) {
cycleCountY = cycleCountX;
cycleCountZ = cycleCountX;
}
return result;
}
SerializeElement<uint16_t> cycleCountX;
SerializeElement<uint16_t> cycleCountY;
SerializeElement<uint16_t> cycleCountZ;
private:
void setLinks(bool oneCycleCount) {
setStart(&cycleCountX);
if(not oneCycleCount) {
cycleCountX.setNext(&cycleCountY);
cycleCountY.setNext(&cycleCountZ);
}
}
bool oneCycleCount;
};
static constexpr uint32_t MGM_DATASET_ID = READ_DATA;
enum MgmPoolIds: lp_id_t {
FIELD_STRENGTH_X,
FIELD_STRENGTH_Y,
FIELD_STRENGTH_Z,
};
class Rm3100PrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> {
public:
Rm3100PrimaryDataset(HasLocalDataPoolIF* hkOwner):
StaticLocalDataSet(hkOwner, MGM_DATASET_ID) {}
Rm3100PrimaryDataset(object_id_t mgmId):
StaticLocalDataSet(sid_t(mgmId, MGM_DATASET_ID)) {}
// Field strengths in micro Tesla.
lp_var_t<float> fieldStrengthX = lp_var_t<float>(sid.objectId,
FIELD_STRENGTH_X, this);
lp_var_t<float> fieldStrengthY = lp_var_t<float>(sid.objectId,
FIELD_STRENGTH_Y, this);
lp_var_t<float> fieldStrengthZ = lp_var_t<float>(sid.objectId,
FIELD_STRENGTH_Z, this);
};
}
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_ */

2
tmtc

@ -1 +1 @@
Subproject commit 90f85b7dae63e93a3c5686fab9dd0d4a8147e96b Subproject commit b3bc1fe28c73d51f0b8319cf67705807596e5518