added more spi test code, preprocessor defines
and various bugfixes
This commit is contained in:
parent
fca78108a2
commit
08351bcda2
@ -137,6 +137,7 @@ void initmission::initTasks() {
|
||||
|
||||
//TODO: Add handling of missed deadlines
|
||||
/* Polling Sequence Table Default */
|
||||
#if Q7S_ADD_SPI_TEST == 0
|
||||
FixedTimeslotTaskIF * pollingSequenceTableTaskDefault = factory->createFixedTimeslotTask(
|
||||
"PST_TASK_DEFAULT", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0,
|
||||
missedDeadlineFunc);
|
||||
@ -144,6 +145,7 @@ void initmission::initTasks() {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TE0720 == 0
|
||||
FixedTimeslotTaskIF* gomSpacePstTask = factory->
|
||||
@ -155,13 +157,20 @@ void initmission::initTasks() {
|
||||
}
|
||||
#endif
|
||||
|
||||
PeriodicTaskIF* testTask = factory->createPeriodicTask(
|
||||
"GPIOD_TEST", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc);
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
PeriodicTaskIF* testTask = factory->createPeriodicTask(
|
||||
"TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc);
|
||||
result = testTask->addComponent(objects::TEST_TASK);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
||||
}
|
||||
|
||||
#if Q7S_ADD_SPI_TEST == 1
|
||||
result = testTask->addComponent(objects::SPI_TEST);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
||||
}
|
||||
#endif
|
||||
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
||||
#if TE0720 == 1 && TEST_LIBGPIOD == 1
|
||||
result = testTask->addComponent(objects::LIBGPIOD_TEST);
|
||||
@ -178,7 +187,10 @@ void initmission::initTasks() {
|
||||
#if TE0720 == 0
|
||||
gomSpacePstTask->startTask();
|
||||
#endif
|
||||
|
||||
#if Q7S_ADD_SPI_TEST == 0
|
||||
pollingSequenceTableTaskDefault->startTask();
|
||||
#endif
|
||||
|
||||
pusVerification->startTask();
|
||||
pusEvents->startTask();
|
||||
@ -186,6 +198,8 @@ void initmission::initTasks() {
|
||||
pusMedPrio->startTask();
|
||||
pusLowPrio->startTask();
|
||||
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
testTask->startTask();
|
||||
#endif
|
||||
sif::info << "Tasks started.." << std::endl;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
/* UDP server includes */
|
||||
#include <fsfw/osal/common/UdpTmTcBridge.h>
|
||||
#include <fsfw/osal/common/UdpTcPollingTask.h>
|
||||
#include <linux/boardtest/SpiTestClass.h>
|
||||
|
||||
#if TEST_LIBGPIOD == 1
|
||||
#include <linux/boardtest/LibgpiodTest.h>
|
||||
@ -96,7 +97,9 @@ void ObjectFactory::produce(){
|
||||
new CspComIF(objects::CSP_COM_IF);
|
||||
new I2cComIF(objects::I2C_COM_IF);
|
||||
new UartComIF(objects::UART_COM_IF);
|
||||
#if Q7S_ADD_SPI_TEST == 0
|
||||
new SpiComIF(objects::SPI_COM_IF, gpioComIF);
|
||||
#endif
|
||||
|
||||
/* Temperature sensors */
|
||||
Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler(
|
||||
@ -184,7 +187,7 @@ void ObjectFactory::produce(){
|
||||
|
||||
spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev,
|
||||
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
|
||||
auto mgmLis3Handler2 = new MGMHandlerLIS3MDL(objects::MGM_0_LIS3_HANDLER,
|
||||
auto mgmLis3Handler2 = new MGMHandlerLIS3MDL(objects::MGM_2_LIS3_HANDLER,
|
||||
objects::SPI_COM_IF, spiCookie);
|
||||
mgmLis3Handler2->setStartUpImmediately();
|
||||
|
||||
@ -261,6 +264,7 @@ void ObjectFactory::produce(){
|
||||
objects::UART_COM_IF, syrlinksUartCookie);
|
||||
syrlinksHkHandler->setModeNormal();
|
||||
|
||||
#if Q7S_ADD_SPI_TEST == 0
|
||||
GpioCookie* rtdGpioCookie = new GpioCookie;
|
||||
|
||||
gpioCallbacks::initTcsBoardDecoder(gpioComIF);
|
||||
@ -382,6 +386,8 @@ void ObjectFactory::produce(){
|
||||
Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18, objects::SPI_COM_IF, spiRtdIc18, 0);
|
||||
// rtdIc10->setStartUpImmediately();
|
||||
// rtdIc4->setStartUpImmediately();
|
||||
#endif /* Q7S_ADD_SPI_TEST == 0 */
|
||||
|
||||
#endif /* TE0720 == 0 */
|
||||
|
||||
new UdpTmTcBridge(objects::UDP_BRIDGE,
|
||||
@ -404,4 +410,8 @@ void ObjectFactory::produce(){
|
||||
new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie,
|
||||
objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN);
|
||||
#endif
|
||||
|
||||
#if Q7S_ADD_SPI_TEST == 1
|
||||
new SpiTestClass(objects::SPI_TEST, gpioComIF);
|
||||
#endif
|
||||
}
|
||||
|
11
bsp_q7s/boardconfig/q7s_config.h
Normal file
11
bsp_q7s/boardconfig/q7s_config.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_
|
||||
#define BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_
|
||||
|
||||
/* Only one of those 2 should be enabled! */
|
||||
/* Add code for ACS board */
|
||||
#define OBSW_ADD_ACS_BOARD 0
|
||||
#define Q7S_ADD_SPI_TEST 1
|
||||
|
||||
|
||||
|
||||
#endif /* BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ */
|
2
fsfw_hal
2
fsfw_hal
@ -1 +1 @@
|
||||
Subproject commit 2fb50360ef8910ed785d31cc4da098a77c26fd81
|
||||
Subproject commit 94fcbd587ea9eac76fbe6cbd85e1559c42235ce9
|
@ -8,6 +8,8 @@
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
#include <rpi_config.h>
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
#include <q7s_config.h>
|
||||
#endif
|
||||
#include "commonConfig.h"
|
||||
#include "OBSWVersion.h"
|
||||
@ -20,8 +22,6 @@ debugging. */
|
||||
#define TEST_LIBGPIOD 0
|
||||
|
||||
#define TE0720 0
|
||||
/* Add code for ACS board */
|
||||
#define OBSW_ADD_ACS_BOARD 1
|
||||
|
||||
#define P60DOCK_DEBUG 0
|
||||
#define PDU1_DEBUG 0
|
||||
|
@ -54,7 +54,7 @@ namespace objects {
|
||||
/* Custom device handler */
|
||||
PCDU_HANDLER = 0x44001000,
|
||||
SOLAR_ARRAY_DEPL_HANDLER = 0x44001001,
|
||||
SYRLINKS_HK_HANDLER = 0x44000009,
|
||||
SYRLINKS_HK_HANDLER = 0x44001002,
|
||||
|
||||
/* 0x54 ('T') for thermal objects */
|
||||
HEATER_HANDLER = 0x54000003,
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
|
||||
SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId),
|
||||
gpioIF(gpioIF) {
|
||||
gpioIF(gpioIF) {
|
||||
if(gpioIF == nullptr) {
|
||||
sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl;
|
||||
}
|
||||
testMode = TestModes::GYRO_L3GD20H;
|
||||
testMode = TestModes::MGM_LIS3MDL;
|
||||
spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data());
|
||||
spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data());
|
||||
}
|
||||
@ -36,11 +36,11 @@ ReturnValue_t SpiTestClass::performOneShotAction() {
|
||||
break;
|
||||
}
|
||||
case(TestModes::MGM_LIS3MDL): {
|
||||
performLis3MdlTest(mgm0Lis3ChipSelect);
|
||||
performLis3MdlTest(mgm2Lis3mdlChipSelect);
|
||||
break;
|
||||
}
|
||||
case(TestModes::MGM_RM3100): {
|
||||
performRm3100Test(mgm1Rm3100ChipSelect);
|
||||
performRm3100Test(mgm3Rm3100ChipSelect);
|
||||
break;
|
||||
}
|
||||
case(TestModes::GYRO_L3GD20H): {
|
||||
@ -78,7 +78,7 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) {
|
||||
#ifdef RASPBERRY_PI
|
||||
std::string deviceName = "/dev/spidev0.0";
|
||||
#else
|
||||
std::string deviceName = "placeholder";
|
||||
std::string deviceName = "/dev/spidev2.0";
|
||||
#endif
|
||||
int fileDescriptor = 0;
|
||||
|
||||
@ -160,13 +160,14 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
|
||||
acsInit();
|
||||
|
||||
/* Adapt accordingly */
|
||||
if(lis3Id != mgm0Lis3ChipSelect and lis3Id != mgm2Lis3mdlChipSelect) {
|
||||
if(lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) {
|
||||
sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl;
|
||||
}
|
||||
gpioId_t currentGpioId = 0;
|
||||
uint8_t chipSelectPin = lis3Id;
|
||||
uint8_t whoAmIReg = 0b0000'1111;
|
||||
if(chipSelectPin == mgm0Lis3ChipSelect) {
|
||||
uint8_t whoAmIRegExpectedVal = 0b0011'1101;
|
||||
if(chipSelectPin == mgm0Lis3mdlChipSelect) {
|
||||
currentGpioId = gpioIds::MGM_0_LIS3_CS;
|
||||
}
|
||||
else {
|
||||
@ -177,7 +178,7 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
|
||||
#ifdef RASPBERRY_PI
|
||||
std::string deviceName = "/dev/spidev0.0";
|
||||
#else
|
||||
std::string deviceName = "placeholder";
|
||||
std::string deviceName = "/dev/spidev2.0";
|
||||
#endif
|
||||
int fileDescriptor = 0;
|
||||
|
||||
@ -189,10 +190,15 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) {
|
||||
return;
|
||||
}
|
||||
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
||||
spiTransferStruct.delay_usecs = 0;
|
||||
|
||||
uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false);
|
||||
sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" <<
|
||||
std::bitset<8>(whoAmIRegVal) << std::endl;
|
||||
if(whoAmIRegVal != whoAmIRegExpectedVal) {
|
||||
sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -223,7 +229,7 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
#ifdef RASPBERRY_PI
|
||||
std::string deviceName = "/dev/spidev0.0";
|
||||
#else
|
||||
std::string deviceName = "placeholder";
|
||||
std::string deviceName = "/dev/spidev2.0";
|
||||
#endif
|
||||
int fileDescriptor = 0;
|
||||
|
||||
@ -293,46 +299,73 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) {
|
||||
|
||||
void SpiTestClass::acsInit() {
|
||||
GpioCookie* gpioCookie = new GpioCookie();
|
||||
std::string rpiGpioName = "gpiochip0";
|
||||
GpiodRegular* gpio = nullptr;
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm0Lis3ChipSelect, "MGM_0_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
|
||||
}
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
|
||||
}
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
|
||||
}
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
|
||||
}
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, gyro2L3gd20ChipSelect, "GYRO_2_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_2_L3G_CS, gpio);
|
||||
}
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
|
||||
}
|
||||
{
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
|
||||
}
|
||||
if(gpioIF != nullptr) {
|
||||
gpioIF->addGpios(gpioCookie);
|
||||
}
|
||||
#ifdef RASPBERRY_PI
|
||||
std::string rpiGpioName = "gpiochip0";
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(rpiGpioName, gyro2L3gd20ChipSelect, "GYRO_2_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_2_L3G_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
|
||||
}
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
std::string q7sGpioName5 = "gpiochip5";
|
||||
std::string q7sGpioName6 = "gpiochip6";
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName5, mgm0Lis3mdlChipSelect, "MGM_0_LIS3",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName5, mgm1Rm3100ChipSelect, "MGM_1_RM3100",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName5, gyro0AdisChipSelect, "GYRO_0_ADIS",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName5, gyro1L3gd20ChipSelect, "GYRO_1_L3G",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName5, gyro2L3gd20ChipSelect, "GYRO_2_L3G",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::GYRO_2_L3G_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName6, mgm2Lis3mdlChipSelect, "MGM_2_LIS3",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio);
|
||||
|
||||
gpio = new GpiodRegular(q7sGpioName5, mgm3Rm3100ChipSelect, "MGM_3_RM3100",
|
||||
gpio::Direction::OUT, gpio::HIGH);
|
||||
gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio);
|
||||
#endif
|
||||
if(gpioIF != nullptr) {
|
||||
gpioIF->addGpios(gpioCookie);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) {
|
||||
|
@ -38,6 +38,7 @@ private:
|
||||
void acsInit();
|
||||
|
||||
/* ACS board specific variables */
|
||||
#ifdef RASPBERRY_PI
|
||||
uint8_t mgm0Lis3ChipSelect = 0;
|
||||
uint8_t mgm1Rm3100ChipSelect = 1;
|
||||
uint8_t gyro0AdisChipSelect = 5;
|
||||
@ -45,6 +46,16 @@ private:
|
||||
uint8_t gyro2L3gd20ChipSelect = 4;
|
||||
uint8_t mgm2Lis3mdlChipSelect = 17;
|
||||
uint8_t mgm3Rm3100ChipSelect = 27;
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
uint8_t mgm0Lis3mdlChipSelect = 5;
|
||||
uint8_t mgm1Rm3100ChipSelect = 17;
|
||||
uint8_t gyro0AdisResetLin = 20;
|
||||
uint8_t gyro0AdisChipSelect = 21;
|
||||
uint8_t gyro1L3gd20ChipSelect = 7;
|
||||
uint8_t gyro2L3gd20ChipSelect = 3;
|
||||
uint8_t mgm2Lis3mdlChipSelect = 0;
|
||||
uint8_t mgm3Rm3100ChipSelect = 23;
|
||||
#endif
|
||||
|
||||
static constexpr uint8_t STM_READ_MASK = 0b1000'0000;
|
||||
static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK;
|
||||
|
@ -33,8 +33,8 @@ void MGMHandlerLIS3MDL::doStartUp() {
|
||||
/* Will be set by checking device ID (WHO AM I register) */
|
||||
if(commandExecuted) {
|
||||
commandExecuted = false;
|
||||
internalState = InternalState::STATE_SETUP;
|
||||
}
|
||||
internalState = InternalState::STATE_SETUP;
|
||||
break;
|
||||
}
|
||||
case(InternalState::STATE_SETUP): {
|
||||
@ -463,7 +463,7 @@ void MGMHandlerLIS3MDL::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
}
|
||||
|
||||
uint32_t MGMHandlerLIS3MDL::getTransitionDelayMs(Mode_t from, Mode_t to) {
|
||||
return 10000;
|
||||
return 20000;
|
||||
}
|
||||
|
||||
void MGMHandlerLIS3MDL::modeChanged(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user