diff --git a/CMakeLists.txt b/CMakeLists.txt index a3dd1d7c..c75e2af3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") option(EIVE_BUILD_UNITTESTS "Build Catch2 unittests" OFF) option(EIVE_ADD_ETL_LIB "Add ETL library" ON) option(EIVE_ADD_JSON_LIB "Add JSON library" ON) + option(EIVE_SYSROOT_MAGIC "Perform sysroot magic which might not be necessary" OFF) if(NOT FSFW_OSAL) @@ -24,6 +25,9 @@ endif() if(TGT_BSP MATCHES "arm/raspberrypi" OR TGT_BSP MATCHES "arm/beagleboneblack") option(LINUX_CROSS_COMPILE ON) + option(EIVE_BUILD_GPSD_GPS_HANDLER "Build GPSD dependent GPS Handler" OFF) +else() + option(EIVE_BUILD_GPSD_GPS_HANDLER "Build GPSD dependent GPS Handler" ON) endif() # Perform steps like loading toolchain files where applicable. diff --git a/bsp_linux_board/CMakeLists.txt b/bsp_linux_board/CMakeLists.txt index 5963d48c..0272f476 100644 --- a/bsp_linux_board/CMakeLists.txt +++ b/bsp_linux_board/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PUBLIC +target_sources(${OBSW_NAME} PUBLIC InitMission.cpp main.cpp ObjectFactory.cpp diff --git a/bsp_linux_board/boardconfig/CMakeLists.txt b/bsp_linux_board/boardconfig/CMakeLists.txt index 67fbaf88..f9136e3e 100644 --- a/bsp_linux_board/boardconfig/CMakeLists.txt +++ b/bsp_linux_board/boardconfig/CMakeLists.txt @@ -1,7 +1,7 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${OBSW_NAME} PRIVATE print.c ) -target_include_directories(${TARGET_NAME} PUBLIC +target_include_directories(${OBSW_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/bsp_linux_board/boardtest/CMakeLists.txt b/bsp_linux_board/boardtest/CMakeLists.txt index 0599b73f..fe4910f2 100644 --- a/bsp_linux_board/boardtest/CMakeLists.txt +++ b/bsp_linux_board/boardtest/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${TARGET_NAME} PRIVATE +target_sources(${OBSW_NAME} PRIVATE ) diff --git a/bsp_q7s/CMakeLists.txt b/bsp_q7s/CMakeLists.txt index c4f85bd2..0a8cffe8 100644 --- a/bsp_q7s/CMakeLists.txt +++ b/bsp_q7s/CMakeLists.txt @@ -18,12 +18,9 @@ target_sources(${OBSW_NAME} PUBLIC add_subdirectory(boardtest) - add_subdirectory(boardconfig) add_subdirectory(comIF) -add_subdirectory(gpio) add_subdirectory(core) add_subdirectory(memory) add_subdirectory(callbacks) add_subdirectory(devices) - diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 2083ac6b..eba4fb36 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -29,6 +29,7 @@ static const int PTME_CONFIG = 4; } // namespace uiomapids namespace gpioNames { + static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; @@ -44,6 +45,8 @@ static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; static constexpr char GNSS_SELECT[] = "gnss_mux_select"; +static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; + static constexpr char HEATER_0[] = "heater0"; static constexpr char HEATER_1[] = "heater1"; static constexpr char HEATER_2[] = "heater2"; @@ -54,19 +57,20 @@ static constexpr char HEATER_6[] = "heater6"; static constexpr char HEATER_7[] = "heater7"; static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; +static constexpr char SPI_MUX_BIT_0_PIN[] = "spi_mux_bit_0"; static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; -static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; static constexpr char EN_RW_CS[] = "en_rw_cs"; static constexpr char EN_RW_1[] = "enable_rw_1"; static constexpr char EN_RW_2[] = "enable_rw_2"; static constexpr char EN_RW_3[] = "enable_rw_3"; static constexpr char EN_RW_4[] = "enable_rw_4"; -static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; + static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; +static constexpr char ENABLE_RADFET[] = "enable_radfet"; static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; @@ -80,6 +84,16 @@ static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; static constexpr char RS485_EN_RX_CLOCK[] = "rx_clock_enable_ltc2872"; static constexpr char RS485_EN_RX_DATA[] = "rx_data_enable_ltc2872"; static constexpr char PDEC_RESET[] = "pdec_reset"; + +static constexpr char PL_PCDU_ENABLE_VBAT0[] = "enable_plpcdu_vbat0"; +static constexpr char PL_PCDU_ENABLE_VBAT1[] = "enable_plpcdu_vbat1"; +static constexpr char PL_PCDU_ENABLE_DRO[] = "enable_plpcdu_dro"; +static constexpr char PL_PCDU_ENABLE_X8[] = "enable_plpcdu_x8"; +static constexpr char PL_PCDU_ENABLE_TX[] = "enable_plpcdu_tx"; +static constexpr char PL_PCDU_ENABLE_HPA[] = "enable_plpcdu_hpa"; +static constexpr char PL_PCDU_ENABLE_MPA[] = "enable_plpcdu_mpa"; +static constexpr char PL_PCDU_ADC_CS[] = "plpcdu_adc_chip_select"; + } // namespace gpioNames } // namespace q7s diff --git a/bsp_q7s/callbacks/CMakeLists.txt b/bsp_q7s/callbacks/CMakeLists.txt index 30268007..a4462937 100644 --- a/bsp_q7s/callbacks/CMakeLists.txt +++ b/bsp_q7s/callbacks/CMakeLists.txt @@ -2,4 +2,5 @@ target_sources(${OBSW_NAME} PRIVATE rwSpiCallback.cpp gnssCallback.cpp pcduSwitchCb.cpp + gpioCallbacks.cpp ) diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/callbacks/gpioCallbacks.cpp similarity index 85% rename from bsp_q7s/gpio/gpioCallbacks.cpp rename to bsp_q7s/callbacks/gpioCallbacks.cpp index e3033b7d..8f554a65 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/callbacks/gpioCallbacks.cpp @@ -25,38 +25,28 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { GpiodRegularByLineName* spiMuxBit = nullptr; /** Setting mux bit 1 to low will disable IC21 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_0_PIN, "SPI Mux Bit 1", + gpio::DIR_OUT, gpio::HIGH); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_0, spiMuxBit); + /** Setting mux bit 2 to low disables IC1 on the TCS board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 2", gpio::DIR_OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); - /** Setting mux bit 2 to low disables IC1 on the TCS board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", - gpio::DIR_OUT, gpio::HIGH); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 3", + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 3", gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); - - // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - // gpio::OUT, gpio::LOW); - // spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_1, spiMuxBit); - // /** Setting mux bit 2 to low disables IC1 on the TCS board */ - // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_2_PIN, "SPI Mux Bit 2", - // gpio::OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); - // /** Setting mux bit 3 to low disables IC2 on the TCS board and IC22 on the interface board - // */ spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit - // 3", gpio::OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_2, spiMuxBit); /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_3_PIN, "SPI Mux Bit 4", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 5", gpio::DIR_OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 6", gpio::DIR_OUT, gpio::LOW); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_6_PIN, "SPI Mux Bit 6", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit); GpiodRegularByLineName* enRwDecoder = new GpiodRegularByLineName(q7s::gpioNames::EN_RW_CS, "EN_RW_CS", gpio::DIR_OUT, gpio::HIGH); spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); @@ -147,6 +137,10 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev disableDecoderTcsIc2(); break; } + case (gpioIds::CS_SUS_0): { + disableDecoderInterfaceBoardIc1(); + break; + } case (gpioIds::CS_SUS_1): { disableDecoderInterfaceBoardIc1(); break; @@ -156,23 +150,23 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev break; } case (gpioIds::CS_SUS_3): { - disableDecoderInterfaceBoardIc2(); + disableDecoderInterfaceBoardIc1(); break; } case (gpioIds::CS_SUS_4): { - disableDecoderInterfaceBoardIc2(); + disableDecoderInterfaceBoardIc1(); break; } case (gpioIds::CS_SUS_5): { - disableDecoderInterfaceBoardIc2(); + disableDecoderInterfaceBoardIc1(); break; } case (gpioIds::CS_SUS_6): { - disableDecoderInterfaceBoardIc1(); + disableDecoderInterfaceBoardIc2(); break; } case (gpioIds::CS_SUS_7): { - disableDecoderInterfaceBoardIc1(); + disableDecoderInterfaceBoardIc2(); break; } case (gpioIds::CS_SUS_8): { @@ -180,25 +174,17 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev break; } case (gpioIds::CS_SUS_9): { - disableDecoderInterfaceBoardIc1(); + disableDecoderInterfaceBoardIc2(); break; } case (gpioIds::CS_SUS_10): { - disableDecoderInterfaceBoardIc1(); + disableDecoderInterfaceBoardIc2(); break; } case (gpioIds::CS_SUS_11): { disableDecoderInterfaceBoardIc2(); break; } - case (gpioIds::CS_SUS_12): { - disableDecoderInterfaceBoardIc2(); - break; - } - case (gpioIds::CS_SUS_13): { - disableDecoderInterfaceBoardIc1(); - break; - } case (gpioIds::CS_RW1): { disableRwDecoder(); break; @@ -300,71 +286,66 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev enableDecoderTcsIc2(); break; } - case (gpioIds::CS_SUS_1): { + case (gpioIds::CS_SUS_0): { selectY0(); enableDecoderInterfaceBoardIc1(); break; } + case (gpioIds::CS_SUS_1): { + selectY1(); + enableDecoderInterfaceBoardIc1(); + break; + } case (gpioIds::CS_SUS_2): { - selectY1(); + selectY2(); enableDecoderInterfaceBoardIc1(); break; } case (gpioIds::CS_SUS_3): { + selectY3(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_4): { + selectY4(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_5): { + selectY5(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_6): { selectY0(); enableDecoderInterfaceBoardIc2(); break; } - case (gpioIds::CS_SUS_4): { + case (gpioIds::CS_SUS_7): { selectY1(); enableDecoderInterfaceBoardIc2(); break; } - case (gpioIds::CS_SUS_5): { - selectY2(); - enableDecoderInterfaceBoardIc2(); - break; - } - case (gpioIds::CS_SUS_6): { - selectY2(); - enableDecoderInterfaceBoardIc1(); - break; - } - case (gpioIds::CS_SUS_7): { - selectY3(); - enableDecoderInterfaceBoardIc1(); - break; - } case (gpioIds::CS_SUS_8): { - selectY3(); + selectY2(); enableDecoderInterfaceBoardIc2(); break; } case (gpioIds::CS_SUS_9): { - selectY4(); - enableDecoderInterfaceBoardIc1(); + selectY3(); + enableDecoderInterfaceBoardIc2(); break; } case (gpioIds::CS_SUS_10): { - selectY5(); - enableDecoderInterfaceBoardIc1(); - break; - } - case (gpioIds::CS_SUS_11): { selectY4(); enableDecoderInterfaceBoardIc2(); break; } - case (gpioIds::CS_SUS_12): { + case (gpioIds::CS_SUS_11): { selectY5(); enableDecoderInterfaceBoardIc2(); break; } - case (gpioIds::CS_SUS_13): { - selectY6(); - enableDecoderInterfaceBoardIc1(); - break; - } case (gpioIds::CS_RW1): { selectY0(); enableRwDecoder(); @@ -394,52 +375,52 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Lev } void enableDecoderTcsIc1() { - 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_0); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); } void enableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_0); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); +} + +void enableDecoderInterfaceBoardIc1() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); +} + +void enableDecoderInterfaceBoardIc2() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } -void enableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); -} - -void enableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); -} - void disableDecoderTcsIc1() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0); gpioComInterface->pullHigh(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_2); } void disableDecoderTcsIc2() { + // DO NOT CHANGE THE ORDER HERE + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void disableDecoderInterfaceBoardIc1() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0); gpioComInterface->pullHigh(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_2); } void disableDecoderInterfaceBoardIc2() { + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_0); gpioComInterface->pullHigh(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_2); } void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); } @@ -447,57 +428,57 @@ void enableRwDecoder() { gpioComInterface->pullHigh(gpioIds::EN_RW_CS); } void disableRwDecoder() { gpioComInterface->pullLow(gpioIds::EN_RW_CS); } void selectY0() { + 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); } void selectY1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + 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); } void selectY2() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); } void selectY3() { + 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); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); } void selectY4() { + 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); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); } void selectY5() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); } void selectY6() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + 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); } void selectY7() { + 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); } void disableAllDecoder() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_0); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); gpioComInterface->pullLow(gpioIds::EN_RW_CS); } diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/callbacks/gpioCallbacks.h similarity index 100% rename from bsp_q7s/gpio/gpioCallbacks.h rename to bsp_q7s/callbacks/gpioCallbacks.h diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index bdbd51cc..3d279487 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,5 +1,7 @@ #include "CoreController.h" +#include + #include "OBSWConfig.h" #include "OBSWVersion.h" #include "fsfw/FSFWVersion.h" diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 8b2c4366..8ce3b422 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -8,6 +8,7 @@ #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" +#include "bsp_q7s/callbacks/gpioCallbacks.h" #include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/core/CoreController.h" @@ -17,7 +18,6 @@ #include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" #include "bsp_q7s/devices/startracker/StarTrackerHandler.h" #include "bsp_q7s/devices/startracker/StrHelper.h" -#include "bsp_q7s/gpio/gpioCallbacks.h" #include "bsp_q7s/memory/FileSystemHandler.h" #include "busConf.h" #include "ccsdsConfig.h" @@ -43,13 +43,15 @@ #include "linux/boardtest/SpiTestClass.h" #include "linux/csp/CspComIF.h" #include "linux/csp/CspCookie.h" +#include "linux/devices/GPSHyperionLinuxController.h" +#include "linux/devices/PayloadPcduHandler.h" #include "linux/devices/SolarArrayDeploymentHandler.h" #include "linux/devices/SusHandler.h" #include "linux/devices/devicedefinitions/SusDefinitions.h" +#include "linux/devices/devicedefinitions/payloadPcduDefinitions.h" #include "mission/core/GenericFactory.h" #include "mission/devices/ACUHandler.h" #include "mission/devices/BpxBatteryHandler.h" -#include "mission/devices/GPSHyperionLinuxController.h" #include "mission/devices/GyroADIS1650XHandler.h" #include "mission/devices/HeaterHandler.h" #include "mission/devices/IMTQHandler.h" @@ -127,6 +129,7 @@ void ObjectFactory::produce(void* args) { #if BOARD_TE0720 == 0 new CoreController(objects::CORE_CONTROLLER); + gpioCallbacks::disableAllDecoder(); createPcduComponents(gpioComIF); createRadSensorComponent(gpioComIF); createSunSensorComponents(gpioComIF, spiComIF); @@ -137,13 +140,11 @@ void ObjectFactory::produce(void* args) { createHeaterComponents(); createSolarArrayDeploymentComponents(); + createPlPcduComponents(gpioComIF, spiComIF); #if OBSW_ADD_SYRLINKS == 1 createSyrlinksComponents(); #endif /* OBSW_ADD_SYRLINKS == 1 */ - -#if OBSW_ADD_RTD_DEVICES == 1 createRtdComponents(gpioComIF); -#endif /* OBSW_ADD_RTD_DEVICES == 1 */ #if OBSW_ADD_MGT == 1 I2cCookie* imtqI2cCookie = @@ -251,9 +252,7 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, Ua new CspComIF(objects::CSP_COM_IF); *i2cComIF = new I2cComIF(objects::I2C_COM_IF); *uartComIF = new UartComIF(objects::UART_COM_IF); -#if OBSW_ADD_SPI_TEST_CODE == 0 *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); -#endif /* Q7S_ADD_SPI_TEST_CODE == 0 */ #if BOARD_TE0720 == 0 /* Adding gpios for chip select decoding to the gpioComIf */ @@ -295,18 +294,30 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { GpiodRegularByLineName* gpio = new GpiodRegularByLineName( q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::ENABLE_RADFET, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieRadSensor->addGpio(gpioIds::ENABLE_RADFET, gpio); gpioComIF->addGpios(gpioCookieRadSensor); SpiCookie* spiCookieRadSensor = new SpiCookie( addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + auto radSensor = + new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + static_cast(radSensor); +#if OBSW_TEST_RAD_SENSOR == 1 + radSensor->setStartUpImmediately(); + radSensor->setToGoToNormalModeImmediately(); +#endif } void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { GpioCookie* gpioCookieSus = new GpioCookie(); GpioCallback* susgpio = nullptr; + susgpio = new GpioCallback("Chip select SUS 0", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_0, susgpio); susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); @@ -340,72 +351,121 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComI susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); gpioComIF->addGpios(gpioCookieSus); - SpiCookie* spiCookieSus1 = - new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus2 = - new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus3 = - new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus4 = - new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus5 = - new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus6 = - new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus7 = - new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus8 = - new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus9 = - new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus10 = - new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus11 = - new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus12 = - new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); - SpiCookie* spiCookieSus13 = - new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, std::string(q7s::SPI_DEFAULT_DEV), - SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); +#if OBSW_ADD_SUN_SENSORS == 1 + SpiCookie* spiCookie = + new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler0 = new SusHandler(objects::SUS_0, 0, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_0); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, gpioIds::CS_SUS_1); - new SusHandler(objects::SUS_2, objects::SPI_COM_IF, spiCookieSus2, gpioComIF, gpioIds::CS_SUS_2); - new SusHandler(objects::SUS_3, objects::SPI_COM_IF, spiCookieSus3, gpioComIF, gpioIds::CS_SUS_3); - new SusHandler(objects::SUS_4, objects::SPI_COM_IF, spiCookieSus4, gpioComIF, gpioIds::CS_SUS_4); - new SusHandler(objects::SUS_5, objects::SPI_COM_IF, spiCookieSus5, gpioComIF, gpioIds::CS_SUS_5); - new SusHandler(objects::SUS_6, objects::SPI_COM_IF, spiCookieSus6, gpioComIF, gpioIds::CS_SUS_6); - new SusHandler(objects::SUS_7, objects::SPI_COM_IF, spiCookieSus7, gpioComIF, gpioIds::CS_SUS_7); - new SusHandler(objects::SUS_8, objects::SPI_COM_IF, spiCookieSus8, gpioComIF, gpioIds::CS_SUS_8); - new SusHandler(objects::SUS_9, objects::SPI_COM_IF, spiCookieSus9, gpioComIF, gpioIds::CS_SUS_9); - new SusHandler(objects::SUS_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, - gpioIds::CS_SUS_10); - new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, - gpioIds::CS_SUS_11); - new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, - gpioIds::CS_SUS_12); - new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, - gpioIds::CS_SUS_13); + spiCookie = + new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler1 = new SusHandler(objects::SUS_1, 1, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_1); + + spiCookie = + new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler2 = new SusHandler(objects::SUS_2, 2, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_2); + + spiCookie = + new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler3 = new SusHandler(objects::SUS_3, 3, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_3); + + spiCookie = + new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler4 = new SusHandler(objects::SUS_4, 4, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_4); + + spiCookie = + new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, std::string(q7s::SPI_DEFAULT_DEV), + SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler5 = new SusHandler(objects::SUS_5, 5, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_5); + + spiCookie = + new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler6 = new SusHandler(objects::SUS_6, 6, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_6); + + spiCookie = + new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler7 = new SusHandler(objects::SUS_7, 7, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_7); + + spiCookie = + new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler8 = new SusHandler(objects::SUS_8, 8, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_8); + + spiCookie = + new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler9 = new SusHandler(objects::SUS_9, 9, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_9); + + spiCookie = + new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler10 = new SusHandler(objects::SUS_10, 10, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_10); + + spiCookie = + new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); + SusHandler* susHandler11 = new SusHandler(objects::SUS_11, 11, objects::SPI_COM_IF, spiCookie, + gpioComIF, gpioIds::CS_SUS_11); + static_cast(susHandler0); + static_cast(susHandler1); + static_cast(susHandler2); + static_cast(susHandler3); + static_cast(susHandler4); + static_cast(susHandler5); + static_cast(susHandler6); + static_cast(susHandler7); + static_cast(susHandler8); + static_cast(susHandler9); + static_cast(susHandler10); + static_cast(susHandler11); +#if OBSW_TEST_SUS == 1 + susHandler0->setStartUpImmediately(); + susHandler1->setStartUpImmediately(); + susHandler2->setStartUpImmediately(); + susHandler3->setStartUpImmediately(); + susHandler4->setStartUpImmediately(); + susHandler5->setStartUpImmediately(); + susHandler6->setStartUpImmediately(); + susHandler7->setStartUpImmediately(); + susHandler8->setStartUpImmediately(); + susHandler9->setStartUpImmediately(); + susHandler10->setStartUpImmediately(); + susHandler11->setStartUpImmediately(); + susHandler0->setToGoToNormalMode(true); + susHandler1->setToGoToNormalMode(true); + susHandler2->setToGoToNormalMode(true); + susHandler3->setToGoToNormalMode(true); + susHandler4->setToGoToNormalMode(true); + susHandler5->setToGoToNormalMode(true); + susHandler6->setToGoToNormalMode(true); + susHandler7->setToGoToNormalMode(true); + susHandler8->setToGoToNormalMode(true); + susHandler9->setToGoToNormalMode(true); + susHandler10->setToGoToNormalMode(true); + susHandler11->setToGoToNormalMode(true); +#endif + +#endif /* OBSW_ADD_SUN_SENSORS == 1 */ } void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF) { @@ -514,9 +574,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); +#if OBSW_TEST_ACS == 1 mgmLis3Handler->setStartUpImmediately(); -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 mgmLis3Handler->setToGoToNormalMode(true); +#if OBSW_DEBUG_ACS == 1 + mgmLis3Handler->enablePeriodicPrintouts(true, 10); +#endif #endif spiCookie = @@ -524,9 +587,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, spi::RM3100_TRANSITION_DELAY); +#if OBSW_TEST_ACS == 1 mgmRm3100Handler->setStartUpImmediately(); -#if FSFW_HAL_RM3100_MGM_DEBUG == 1 mgmRm3100Handler->setToGoToNormalMode(true); +#if OBSW_DEBUG_ACS == 1 + mgmRm3100Handler->enablePeriodicPrintouts(true, 10); +#endif #endif spiCookie = @@ -534,9 +600,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); auto mgmLis3Handler2 = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); +#if OBSW_TEST_ACS == 1 mgmLis3Handler2->setStartUpImmediately(); -#if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 mgmLis3Handler2->setToGoToNormalMode(true); +#if OBSW_DEBUG_ACS == 1 + mgmLis3Handler2->enablePeriodicPrintouts(true, 10); +#endif #endif spiCookie = @@ -544,9 +613,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, spi::RM3100_TRANSITION_DELAY); +#if OBSW_TEST_ACS == 1 mgmRm3100Handler->setStartUpImmediately(); -#if FSFW_HAL_RM3100_MGM_DEBUG == 1 mgmRm3100Handler->setToGoToNormalMode(true); +#if OBSW_DEBUG_ACS == 1 + mgmRm3100Handler->enablePeriodicPrintouts(true, 10); +#endif #endif // Commented until ACS board V2 in in clean room again @@ -556,9 +628,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI spi::DEFAULT_ADIS16507_SPEED); auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie, ADIS1650X::Type::ADIS16505); +#if OBSW_TEST_ACS == 1 adisHandler->setStartUpImmediately(); -#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 adisHandler->setToGoToNormalModeImmediately(); +#if OBSW_DEBUG_ACS == 1 + adisHandler->enablePeriodicPrintouts(true, 10); +#endif #endif // Gyro 1 Side A @@ -567,9 +642,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); +#if OBSW_TEST_ACS == 1 gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 gyroL3gHandler->setToGoToNormalMode(true); +#if OBSW_DEBUG_ACS == 1 + gyroL3gHandler->enablePeriodicPrintouts(true, 10); +#endif #endif // Gyro 2 Side B spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, @@ -577,8 +655,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI spi::DEFAULT_ADIS16507_SPEED); adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie, ADIS1650X::Type::ADIS16505); +#if OBSW_TEST_ACS == 1 adisHandler->setStartUpImmediately(); -#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 adisHandler->setToGoToNormalModeImmediately(); #endif // Gyro 3 Side B @@ -587,9 +665,12 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); +#if OBSW_TEST_ACS == 1 gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 gyroL3gHandler->setToGoToNormalMode(true); +#if OBSW_DEBUG_ACS == 1 + gyroL3gHandler->enablePeriodicPrintouts(true, 10); +#endif #endif bool debugGps = false; @@ -735,6 +816,7 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(rtdGpioCookie); +#if OBSW_ADD_RTD_DEVICES == 1 SpiCookie* spiRtdIc0 = new SpiCookie(addresses::RTD_IC_3, gpioIds::RTD_IC_3, q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); @@ -817,13 +899,40 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { Max31865PT1000Handler* rtdIc15 = new Max31865PT1000Handler(objects::RTD_IC_18, objects::SPI_COM_IF, spiRtdIc15); +#if OBSW_TEST_RTD == 1 rtdIc0->setStartUpImmediately(); rtdIc1->setStartUpImmediately(); rtdIc2->setStartUpImmediately(); -#if OBSW_DEBUG_RTD == 1 + rtdIc3->setStartUpImmediately(); + rtdIc4->setStartUpImmediately(); + rtdIc5->setStartUpImmediately(); + rtdIc6->setStartUpImmediately(); + rtdIc7->setStartUpImmediately(); + rtdIc8->setStartUpImmediately(); + rtdIc9->setStartUpImmediately(); + rtdIc10->setStartUpImmediately(); + rtdIc11->setStartUpImmediately(); + rtdIc12->setStartUpImmediately(); + rtdIc13->setStartUpImmediately(); + rtdIc14->setStartUpImmediately(); + rtdIc15->setStartUpImmediately(); + rtdIc0->setInstantNormal(true); rtdIc1->setInstantNormal(true); rtdIc2->setInstantNormal(true); + rtdIc3->setInstantNormal(true); + rtdIc4->setInstantNormal(true); + rtdIc5->setInstantNormal(true); + rtdIc6->setInstantNormal(true); + rtdIc7->setInstantNormal(true); + rtdIc8->setInstantNormal(true); + rtdIc9->setInstantNormal(true); + rtdIc10->setInstantNormal(true); + rtdIc11->setInstantNormal(true); + rtdIc12->setInstantNormal(true); + rtdIc13->setInstantNormal(true); + rtdIc14->setInstantNormal(true); + rtdIc15->setInstantNormal(true); #endif static_cast(rtdIc0); @@ -842,6 +951,7 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { static_cast(rtdIc13); static_cast(rtdIc14); static_cast(rtdIc15); +#endif } void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { @@ -883,6 +993,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookieRw); +#if OBSW_ADD_RW == 1 auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); @@ -924,6 +1035,8 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { rwHandler4->setStartUpImmediately(); #endif rw4SpiCookie->setCallbackArgs(rwHandler4); + +#endif /* OBSW_ADD_RW == 1 */ } void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { @@ -991,13 +1104,13 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA); VirtualChannel* vc = nullptr; - vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE, objects::CCSDS_HANDLER); ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); - vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE, objects::CCSDS_HANDLER); ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE, objects::CCSDS_HANDLER); ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE, objects::CCSDS_HANDLER); ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); GpioCookie* gpioCookiePdec = new GpioCookie; @@ -1034,6 +1147,56 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { #endif /* BOARD_TE0720 == 0 */ } +void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { + // Create all GPIO components first + GpioCookie* plPcduGpios = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::string consumer; + // Switch pins are active high + consumer = "PLPCDU_ENB_VBAT_0"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_VBAT0, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_VBAT0, gpio); + consumer = "PLPCDU_ENB_VBAT_1"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_VBAT1, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_VBAT1, gpio); + consumer = "PLPCDU_ENB_DRO"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_DRO, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_DRO, gpio); + consumer = "PLPCDU_ENB_HPA"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_HPA, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_HPA, gpio); + consumer = "PLPCDU_ENB_MPA"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_MPA, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_MPA, gpio); + + consumer = "PLPCDU_ENB_X8"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_X8, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_X8, gpio); + consumer = "PLPCDU_ENB_TX"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_TX, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_TX, gpio); + + // Chip select pin is active low + consumer = "PLPCDU_ADC_CS"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ADC_CS, consumer, gpio::DIR_OUT, + gpio::Levels::HIGH); + plPcduGpios->addGpio(gpioIds::PLPCDU_ADC_CS, gpio); + gpioComIF->addGpios(plPcduGpios); + SpiCookie* spiCookie = new SpiCookie(addresses::PLPCDU_ADC, gpioIds::PLPCDU_ADC_CS, + q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE, + spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); + // Create device handler components + auto plPcduHandler = + PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie, gpioComIF); +} + void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 0 new Q7STestTask(objects::TEST_TASK); @@ -1055,18 +1218,18 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif -#if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_SUS == 1 GpioCookie* gpioCookieSus = new GpioCookie; GpiodRegular* chipSelectSus = new GpiodRegular( std::string("gpiochip1"), 9, std::string("Chip Select Sus Sensor"), gpio::DIR_OUT, 1); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); + gpioCookieSus->addGpio(gpioIds::CS_SUS_0, chipSelectSus); gpioComIF->addGpios(gpioCookieSus); SpiCookie* spiCookieSus = - new SpiCookie(addresses::SUS_1, std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, + new SpiCookie(addresses::SUS_0, std::string("/dev/spidev1.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); - new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus, gpioComIF, gpioIds::CS_SUS_1); + new SusHandler(objects::SUS_0, objects::SPI_COM_IF, spiCookieSus, gpioComIF, gpioIds::CS_SUS_0); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1 @@ -1084,7 +1247,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); #endif -#if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_RAD_SENSOR == 1 GpioCookie* gpioCookieRadSensor = new GpioCookie; GpiodRegular* chipSelectRadSensor = new GpiodRegular( std::string("gpiochip1"), 0, std::string("Chip select radiation sensor"), gpio::DIR_OUT, 1); diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index b4ccbea4..ecc92f01 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -13,6 +13,8 @@ void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, SpiComIF** spiComIF, I2cComIF** i2cComIF); + +void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF); void createTmpComponents(); void createPcduComponents(LinuxLibgpioIF* gpioComIF); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp index c7ba58bd..1d5dce85 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.cpp +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -10,7 +10,9 @@ PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + auto mqArgs = MqArgs(this->getObjectId()); + commandQueue = QueueFactory::instance()->createMessageQueue( + QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PlocMemoryDumper::~PlocMemoryDumper() {} diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 1478fbb8..b1d7f0c9 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -8,7 +8,9 @@ PlocUpdater::PlocUpdater(object_id_t objectId) : SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + auto mqArgs = MqArgs(this->getObjectId()); + commandQueue = QueueFactory::instance()->createMessageQueue( + QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PlocUpdater::~PlocUpdater() {} diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 71df6b0b..e5601ac0 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -44,7 +44,9 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, if (strHelper == nullptr) { sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; } - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); + auto mqArgs = MqArgs(this->getObjectId()); + eventQueue = QueueFactory::instance()->createMessageQueue( + EventMessage::EVENT_MESSAGE_SIZE * 5, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } StarTrackerHandler::~StarTrackerHandler() {} diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 8b5f85c2..7a4a791c 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -11,7 +11,9 @@ FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler) : SystemObject(fileSystemHandler) { - mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); + auto mqArgs = MqArgs(this->getObjectId()); + mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE, + MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } FileSystemHandler::~FileSystemHandler() { QueueFactory::instance()->deleteMessageQueue(mq); } diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index a86fd459..1362ef23 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -1,7 +1,6 @@ #include "simple.h" #include "iostream" - #include "q7sConfig.h" #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 09facbc1..c97bdd41 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -36,6 +36,7 @@ enum commonObjects: uint32_t { GYRO_1_L3G_HANDLER = 0x44120111, GYRO_2_ADIS_HANDLER = 0x44120212, GYRO_3_L3G_HANDLER = 0x44120313, + PLPCDU_HANDLER = 0x44300000, IMTQ_HANDLER = 0x44140014, PLOC_MPSOC_HANDLER = 0x44330015, @@ -62,19 +63,18 @@ enum commonObjects: uint32_t { RTD_IC_17 = 0x44420030, RTD_IC_18 = 0x44420031, - SUS_1 = 0x44120032, - SUS_2 = 0x44120033, - SUS_3 = 0x44120034, - SUS_4 = 0x44120035, - SUS_5 = 0x44120036, - SUS_6 = 0x44120037, - SUS_7 = 0x44120038, - SUS_8 = 0x44120039, - SUS_9 = 0x44120040, - SUS_10 = 0x44120041, - SUS_11 = 0x44120042, - SUS_12 = 0x44120043, - SUS_13 = 0x44120044, + SUS_0 = 0x44120032, + SUS_1 = 0x44120033, + SUS_2 = 0x44120034, + SUS_3 = 0x44120035, + SUS_4 = 0x44120036, + SUS_5 = 0x44120037, + SUS_6 = 0x44120038, + SUS_7 = 0x44120039, + SUS_8 = 0x44120040, + SUS_9 = 0x44120041, + SUS_10 = 0x44120042, + SUS_11 = 0x44120043, GPS_CONTROLLER = 0x44130045, diff --git a/common/config/devConf.h b/common/config/devConf.h index 78681ec7..deea6aa2 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -23,7 +23,13 @@ static constexpr uint32_t DEFAULT_L3G_SPEED = 976'000; static constexpr uint32_t L3G_TRANSITION_DELAY = 5000; static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3; -static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000; +/** + * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by + * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. + */ +static const uint32_t SUS_MAX1227_SPI_FREQ = 976'000; + +static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 976'000; static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_ADIS16507_SPEED = 976'000; diff --git a/fsfw b/fsfw index 32a9e0c7..d74a373f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 32a9e0c7044665f0265c10108c8d62d45c047769 +Subproject commit d74a373f1d6bc341c11d7ad89f369da5ff957928 diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 7ef76d95..e1af31e6 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -15,16 +15,20 @@ #include +#if defined(XIPHOS_Q7S) +#include "busConf.h" +#endif #include "devices/gpioIds.h" +#include "mission/devices/max1227.h" SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF *gpioIF) : TestTask(objectId), gpioIF(gpioIF) { if (gpioIF == nullptr) { sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; } - testMode = TestModes::MGM_LIS3MDL; - spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); - spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); + testMode = TestModes::MAX1227; + spiTransferStruct[0].rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); + setSendBuffer(); } ReturnValue_t SpiTestClass::performOneShotAction() { @@ -44,11 +48,25 @@ ReturnValue_t SpiTestClass::performOneShotAction() { performL3gTest(gyro1L3gd20ChipSelect); break; } + case (TestModes::MAX1227): { + performOneShotMax1227Test(); + break; + } } return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SpiTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiTestClass::performPeriodicAction() { + switch (testMode) { + case (TestModes::MAX1227): { + performPeriodicMax1227Test(); + break; + } + default: + break; + } + return HasReturnvaluesIF::RETURN_OK; +} void SpiTestClass::performRm3100Test(uint8_t mgmId) { /* Configure all SPI chip selects and pull them high */ @@ -180,7 +198,7 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { return; } setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - spiTransferStruct.delay_usecs = 0; + spiTransferStruct[0].delay_usecs = 0; uint8_t whoAmIRegVal = readStmRegister(fileDescriptor, currentGpioId, whoAmIReg, false); sif::info << "SpiTestClass::performLis3MdlTest: WHO AM I register 0b" @@ -273,6 +291,320 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) { sif::info << "Z: " << angVelocZ << std::endl; } +void SpiTestClass::performOneShotMax1227Test() { + using namespace max1227; + adcCfg.testRadSensorExtConvWithDelay = false; + adcCfg.testRadSensorIntConv = false; + + adcCfg.testSus[0].doTest = true; + adcCfg.testSus[0].intConv = true; + adcCfg.testSus[6].doTest = true; + adcCfg.testSus[6].intConv = true; + + adcCfg.testSus[1].doTest = true; + adcCfg.testSus[1].intConv = true; + adcCfg.testSus[7].doTest = true; + adcCfg.testSus[7].intConv = true; + + adcCfg.testSus[10].doTest = true; + adcCfg.testSus[10].intConv = true; + adcCfg.testSus[4].doTest = true; + adcCfg.testSus[4].intConv = true; + + adcCfg.testSus[11].doTest = true; + adcCfg.testSus[11].intConv = true; + adcCfg.testSus[5].doTest = true; + adcCfg.testSus[5].intConv = true; + + adcCfg.testSus[2].doTest = true; + adcCfg.testSus[2].intConv = true; + adcCfg.testSus[3].doTest = true; + adcCfg.testSus[3].intConv = true; + + adcCfg.testSus[8].doTest = true; + adcCfg.testSus[8].intConv = true; + adcCfg.testSus[9].doTest = true; + adcCfg.testSus[9].intConv = true; + + adcCfg.plPcduAdcExtConv = false; + adcCfg.plPcduAdcIntConv = true; + performMax1227Test(); +} + +void SpiTestClass::performPeriodicMax1227Test() { + using namespace max1227; + adcCfg.testRadSensorExtConvWithDelay = false; + adcCfg.testRadSensorIntConv = false; + + adcCfg.plPcduAdcExtConv = false; + adcCfg.plPcduAdcIntConv = false; + performMax1227Test(); +} + +void SpiTestClass::performMax1227Test() { +#ifdef XIPHOS_Q7S + std::string deviceName = q7s::SPI_DEFAULT_DEV; +#elif defined(RASPBERRY_PI) + std::string deviceName = ""; +#endif + int fd = 0; + UnixFileGuard fileHelper(deviceName, &fd, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + uint32_t spiSpeed = 1'000'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_3; + setSpiSpeedAndMode(fd, spiMode, spiSpeed); + + max1227RadSensorTest(fd); + int idx = 0; + bool firstTest = true; + for (auto &susCfg : adcCfg.testSus) { + if (susCfg.doTest) { + if (firstTest) { + firstTest = false; + sif::info << "---------- SUS ADC Values -----------" << std::endl; + } + sif::info << "SUS " << std::setw(2) << idx << ": "; + max1227SusTest(fd, susCfg); + } + idx++; + } + max1227PlPcduTest(fd); +} + +void SpiTestClass::max1227RadSensorTest(int fd) { + using namespace max1227; + if (adcCfg.testRadSensorExtConvWithDelay) { + sendBuffer[0] = max1227::buildResetByte(true); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + usleep(200); + sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_WITH_WAKEUP, + DiffSel::NONE_0); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + max1227::prepareExternallyClockedRead0ToN(sendBuffer.data(), 7, spiTransferStruct[0].len); + size_t tmpLen = spiTransferStruct[0].len; + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + std::memcpy(sendBuffer.data(), sendBuffer.data() + 1, tmpLen - 1); + spiTransferStruct[0].len = tmpLen - 1; + usleep(65); + transfer(fd, gpioIds::CS_RAD_SENSOR); + arrayprinter::print(recvBuffer.data(), 13, OutputType::HEX); + uint16_t adcRaw[8] = {}; + adcRaw[0] = (recvBuffer[0] << 8) | recvBuffer[1]; + adcRaw[1] = (recvBuffer[2] << 8) | recvBuffer[3]; + adcRaw[2] = (recvBuffer[4] << 8) | recvBuffer[5]; + adcRaw[3] = (recvBuffer[6] << 8) | recvBuffer[7]; + adcRaw[4] = (recvBuffer[8] << 8) | recvBuffer[9]; + adcRaw[5] = (recvBuffer[10] << 8) | recvBuffer[11]; + adcRaw[6] = (recvBuffer[12] << 8) | recvBuffer[13]; + adcRaw[7] = (recvBuffer[14] << 8) | recvBuffer[15]; + arrayprinter::print(recvBuffer.data(), 17, OutputType::HEX); + for (int idx = 0; idx < 8; idx++) { + sif::info << "ADC raw " << idx << ": " << adcRaw[idx] << std::endl; + } + max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data(), spiTransferStruct[0].len); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + usleep(65); + spiTransferStruct[0].len = 24; + std::memcpy(sendBuffer.data(), sendBuffer.data() + 1, 24); + transfer(fd, gpioIds::CS_RAD_SENSOR); + int16_t tempRaw = ((recvBuffer[22] & 0x0f) << 8) | recvBuffer[23]; + float temp = max1227::getTemperature(tempRaw); + sif::info << "Temperature: " << temp << std::endl; + } + if (adcCfg.testRadSensorIntConv) { + sendBuffer[0] = max1227::buildResetByte(false); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + usleep(5); + // Now use internal conversion + sendBuffer[0] = max1227::buildSetupByte(ClkSel::INT_CONV_INT_TIMED_CNVST_AS_AIN, + RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + usleep(10); + sendBuffer[0] = buildConvByte(ScanModes::CHANNELS_0_TO_N, 7, true); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::CS_RAD_SENSOR); + + usleep(65); + spiTransferStruct[0].len = 18; + // Shift out zeros + shiftOutZeros(); + transfer(fd, gpioIds::CS_RAD_SENSOR); + setSendBuffer(); + + arrayprinter::print(recvBuffer.data(), 14); + uint16_t adcRaw[8] = {}; + int16_t tempRaw = ((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1]; + sif::info << "Temperature: " << tempRaw * 0.125 << " C" << std::endl; + adcRaw[0] = (recvBuffer[2] << 8) | recvBuffer[3]; + adcRaw[1] = (recvBuffer[4] << 8) | recvBuffer[5]; + adcRaw[2] = (recvBuffer[6] << 8) | recvBuffer[7]; + adcRaw[3] = (recvBuffer[8] << 8) | recvBuffer[9]; + adcRaw[4] = (recvBuffer[10] << 8) | recvBuffer[11]; + adcRaw[5] = (recvBuffer[12] << 8) | recvBuffer[13]; + adcRaw[6] = (recvBuffer[14] << 8) | recvBuffer[15]; + adcRaw[7] = (recvBuffer[16] << 8) | recvBuffer[17]; + for (int idx = 0; idx < 8; idx++) { + sif::info << "ADC raw " << idx << ": " << adcRaw[idx] << std::endl; + } + } +} + +void SpiTestClass::max1227SusTest(int fd, SusTestCfg &cfg) { + using namespace max1227; + if (cfg.extConv) { + sendBuffer[0] = max1227::buildResetByte(false); + spiTransferStruct[0].len = 1; + transfer(fd, cfg.gpioId); + + usleep(65); + sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP, + DiffSel::NONE_0); + spiTransferStruct[0].len = 1; + transfer(fd, cfg.gpioId); + + max1227::prepareExternallyClockedRead0ToN(sendBuffer.data(), 5, spiTransferStruct[0].len); + transfer(fd, cfg.gpioId); + uint16_t adcRaw[6] = {}; + adcRaw[0] = (recvBuffer[1] << 8) | recvBuffer[2]; + adcRaw[1] = (recvBuffer[3] << 8) | recvBuffer[4]; + adcRaw[2] = (recvBuffer[5] << 8) | recvBuffer[6]; + adcRaw[3] = (recvBuffer[7] << 8) | recvBuffer[8]; + adcRaw[4] = (recvBuffer[9] << 8) | recvBuffer[10]; + adcRaw[5] = (recvBuffer[11] << 8) | recvBuffer[12]; + sif::info << "Ext Conv [" << std::hex << std::setw(3); + for (int idx = 0; idx < 5; idx++) { + sif::info << adcRaw[idx]; + if (idx < 6) { + sif::info << ","; + } + } + sif::info << std::dec << "]" << std::endl; // | Temperature: " << temp << " C" << std::endl; + } + if (cfg.intConv) { + sendBuffer[0] = max1227::buildResetByte(false); + spiTransferStruct[0].len = 1; + transfer(fd, cfg.gpioId); + usleep(65); + // Now use internal conversion + sendBuffer[0] = max1227::buildSetupByte(ClkSel::INT_CONV_INT_TIMED_CNVST_AS_AIN, + RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0); + spiTransferStruct[0].len = 1; + transfer(fd, cfg.gpioId); + usleep(10); + sendBuffer[0] = buildConvByte(ScanModes::CHANNELS_0_TO_N, 5, true); + spiTransferStruct[0].len = 1; + transfer(fd, cfg.gpioId); + + usleep(65); + spiTransferStruct[0].len = 14; + // Shift out zeros + shiftOutZeros(); + transfer(fd, cfg.gpioId); + setSendBuffer(); + // arrayprinter::print(recvBuffer.data(), 14); + float temp = static_cast(((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1]) * 0.125; + uint16_t adcRaw[6] = {}; + adcRaw[0] = (recvBuffer[2] << 8) | recvBuffer[3]; + adcRaw[1] = (recvBuffer[4] << 8) | recvBuffer[5]; + adcRaw[2] = (recvBuffer[6] << 8) | recvBuffer[7]; + adcRaw[3] = (recvBuffer[8] << 8) | recvBuffer[9]; + adcRaw[4] = (recvBuffer[10] << 8) | recvBuffer[11]; + adcRaw[5] = (recvBuffer[12] << 8) | recvBuffer[13]; + sif::info << "Int Conv [" << std::hex << std::setw(3); + for (int idx = 0; idx < 6; idx++) { + sif::info << adcRaw[idx]; + if (idx < 5) { + sif::info << ","; + } + } + sif::info << std::dec << "] | T[C] " << temp << std::endl; + } +} + +void SpiTestClass::max1227PlPcduTest(int fd) { + using namespace max1227; + if ((adcCfg.plPcduAdcExtConv or adcCfg.plPcduAdcIntConv) and adcCfg.vbatSwitch) { + // This enables the ADC + ReturnValue_t result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + adcCfg.vbatSwitch = false; + // Takes a bit of time until the ADC is usable + TaskFactory::delayTask(50); + } + if (adcCfg.plPcduAdcExtConv) { + sendBuffer[0] = max1227::buildResetByte(false); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::PLPCDU_ADC_CS); + sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP, + DiffSel::NONE_0); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::PLPCDU_ADC_CS); + uint8_t n = 11; + max1227::prepareExternallyClockedRead0ToN(sendBuffer.data(), n, spiTransferStruct[0].len); + transfer(fd, gpioIds::PLPCDU_ADC_CS); + uint16_t adcRaw[n + 1] = {}; + for (uint8_t idx = 0; idx < n + 1; idx++) { + adcRaw[idx] = (recvBuffer[idx * 2 + 1] << 8) | recvBuffer[idx * 2 + 2]; + } + arrayprinter::print(recvBuffer.data(), spiTransferStruct[0].len, OutputType::HEX); + sif::info << "PL PCDU ADC values:" << std::endl; + for (int idx = 0; idx < n + 1; idx++) { + sif::info << "Raw Value " << idx << ": " << adcRaw[idx] << std::endl; + } + max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data(), spiTransferStruct[0].len); + transfer(fd, gpioIds::PLPCDU_ADC_CS); + int16_t tempRaw = ((recvBuffer[23] & 0x0f) << 8) | recvBuffer[24]; + float temp = max1227::getTemperature(tempRaw); + sif::info << "Temperature: " << temp << std::endl; + } + if (adcCfg.plPcduAdcIntConv) { + sendBuffer[0] = max1227::buildResetByte(true); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::PLPCDU_ADC_CS); + // Now use internal conversion + sendBuffer[0] = max1227::buildSetupByte(ClkSel::INT_CONV_INT_TIMED_CNVST_AS_AIN, + RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::PLPCDU_ADC_CS); + usleep(10); + uint8_t n = 11; + sendBuffer[0] = buildConvByte(ScanModes::CHANNELS_0_TO_N, n, true); + spiTransferStruct[0].len = 1; + transfer(fd, gpioIds::PLPCDU_ADC_CS); + + usleep(65); + spiTransferStruct[0].len = 26; + // Shift out zeros + shiftOutZeros(); + transfer(fd, gpioIds::PLPCDU_ADC_CS); + setSendBuffer(); + arrayprinter::print(recvBuffer.data(), 26, OutputType::HEX); + uint16_t adcRaw[n + 1] = {}; + int16_t tempRaw = ((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1]; + sif::info << "Temperature: " << tempRaw * 0.125 << " C" << std::endl; + for (int idx = 0; idx < n + 1; idx++) { + adcRaw[idx] = (recvBuffer[idx * 2 + 2] << 8) | recvBuffer[idx * 2 + 3]; + sif::info << "ADC raw " << idx << ": " << adcRaw[idx] << std::endl; + } + } +} + void SpiTestClass::acsInit() { GpioCookie *gpioCookie = new GpioCookie(); @@ -348,8 +680,27 @@ void SpiTestClass::acsInit() { } void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { - int mode_test = SPI_MODE_3; - int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test); // reinterpret_cast(&mode)); + int modeUnix = 0; + switch (mode) { + case (spi::SpiModes::MODE_0): { + modeUnix = SPI_MODE_0; + break; + } + case (spi::SpiModes::MODE_1): { + modeUnix = SPI_MODE_1; + break; + } + case (spi::SpiModes::MODE_2): { + modeUnix = SPI_MODE_2; + break; + } + case (spi::SpiModes::MODE_3): { + modeUnix = SPI_MODE_3; + break; + } + } + + int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &modeUnix); // reinterpret_cast(&mode)); if (retval != 0) { utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); } @@ -361,7 +712,7 @@ void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t sp } void SpiTestClass::writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value) { - spiTransferStruct.len = 2; + spiTransferStruct[0].len = 2; sendBuffer[0] = reg; sendBuffer[1] = value; @@ -405,7 +756,7 @@ void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t r sendBuffer[0] = reg; std::memcpy(sendBuffer.data() + 1, values, len); - spiTransferStruct.len = len + 1; + spiTransferStruct[0].len = len + 1; if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { gpioIF->pullLow(chipSelect); @@ -429,13 +780,19 @@ void SpiTestClass::readMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t readMultipleRegisters(fd, chipSelect, reg, reply, len); } +void SpiTestClass::shiftOutZeros() { spiTransferStruct[0].tx_buf = 0; } + +void SpiTestClass::setSendBuffer() { + spiTransferStruct[0].tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); +} + void SpiTestClass::readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, size_t len) { if (reply == nullptr) { return; } - spiTransferStruct.len = len + 1; + spiTransferStruct[0].len = len + 1; sendBuffer[0] = reg | STM_READ_MASK; for (uint8_t idx = 0; idx < len; idx++) { @@ -465,7 +822,7 @@ uint8_t SpiTestClass::readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, } uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) { - spiTransferStruct.len = 2; + spiTransferStruct[0].len = 2; sendBuffer[0] = reg; sendBuffer[1] = 0; @@ -481,3 +838,28 @@ uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) { } return recvBuffer[1]; } + +ReturnValue_t SpiTestClass::transfer(int fd, gpioId_t chipSelect = gpio::NO_GPIO) { + int retval = 0; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (chipSelect != gpio::NO_GPIO) { + result = gpioIF->pullLow(chipSelect); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + + retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::transfer: ioctl failed"); + return HasReturnvaluesIF::RETURN_FAILED; + } + + if (chipSelect != gpio::NO_GPIO) { + result = gpioIF->pullHigh(chipSelect); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index 5df8cafb..d48d6655 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -6,21 +6,39 @@ #if defined(XIPHOS_Q7S) #include "busConf.h" #endif - #include #include #include #include +#include "devices/gpioIds.h" + +struct SusTestCfg { + SusTestCfg(bool doTest, gpioId_t gpioId) : gpioId(gpioId) {} + bool doTest = false; + const gpioId_t gpioId; + bool intConv = true; + bool extConv = false; +}; + +struct Max1227TestCfg { + bool testRadSensorExtConvWithDelay = false; + bool testRadSensorIntConv = false; + bool plPcduAdcExtConv = false; + bool plPcduAdcIntConv = false; + bool vbatSwitch = true; + + SusTestCfg testSus[12] = { + {false, gpioIds::CS_SUS_0}, {false, gpioIds::CS_SUS_1}, {false, gpioIds::CS_SUS_2}, + {false, gpioIds::CS_SUS_3}, {false, gpioIds::CS_SUS_4}, {false, gpioIds::CS_SUS_5}, + {false, gpioIds::CS_SUS_6}, {false, gpioIds::CS_SUS_7}, {false, gpioIds::CS_SUS_8}, + {false, gpioIds::CS_SUS_9}, {false, gpioIds::CS_SUS_10}, {false, gpioIds::CS_SUS_11}, + }; +}; class SpiTestClass : public TestTask { public: - enum TestModes { - NONE, - MGM_LIS3MDL, - MGM_RM3100, - GYRO_L3GD20H, - }; + enum TestModes { NONE, MGM_LIS3MDL, MGM_RM3100, GYRO_L3GD20H, MAX1227 }; TestModes testMode; @@ -31,14 +49,18 @@ class SpiTestClass : public TestTask { private: GpioIF* gpioIF; + Max1227TestCfg adcCfg = {}; std::array recvBuffer; std::array sendBuffer; - struct spi_ioc_transfer spiTransferStruct = {}; + struct spi_ioc_transfer spiTransferStruct[6] = {}; void performRm3100Test(uint8_t mgmId); void performLis3MdlTest(uint8_t lis3Id); void performL3gTest(uint8_t l3gId); + void performOneShotMax1227Test(); + void performPeriodicMax1227Test(); + void performMax1227Test(); /* ACS board specific code which pulls all GPIOs high */ void acsInit(); @@ -55,6 +77,7 @@ class SpiTestClass : public TestTask { uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; #else + uint8_t mgm0Lis3mdlChipSelect = 0; uint8_t mgm1Rm3100ChipSelect = 0; uint8_t gyro0AdisResetLine = 0; @@ -69,6 +92,13 @@ class SpiTestClass : public TestTask { static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; + void shiftOutZeros(); + void setSendBuffer(); + + void max1227RadSensorTest(int fd); + void max1227SusTest(int fd, SusTestCfg& cfg); + void max1227PlPcduTest(int fd); + void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, @@ -78,6 +108,7 @@ class SpiTestClass : public TestTask { void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, size_t len); void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); + ReturnValue_t transfer(int fd, gpioId_t chipSelect); uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 8d3272a1..a2bfa035 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -1,4 +1,11 @@ target_sources(${OBSW_NAME} PRIVATE SolarArrayDeploymentHandler.cpp + PayloadPcduHandler.cpp SusHandler.cpp ) + +if(EIVE_BUILD_GPSD_GPS_HANDLER) + target_sources(${OBSW_NAME} PRIVATE + GPSHyperionLinuxController.cpp + ) +endif() diff --git a/mission/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp similarity index 100% rename from mission/devices/GPSHyperionLinuxController.cpp rename to linux/devices/GPSHyperionLinuxController.cpp diff --git a/mission/devices/GPSHyperionLinuxController.h b/linux/devices/GPSHyperionLinuxController.h similarity index 100% rename from mission/devices/GPSHyperionLinuxController.h rename to linux/devices/GPSHyperionLinuxController.h diff --git a/linux/devices/PayloadPcduHandler.cpp b/linux/devices/PayloadPcduHandler.cpp new file mode 100644 index 00000000..08ebd6a5 --- /dev/null +++ b/linux/devices/PayloadPcduHandler.cpp @@ -0,0 +1,161 @@ +#include "PayloadPcduHandler.h" + +#include "devices/gpioIds.h" + +PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, + GpioIF* gpioIF) + : DeviceHandlerBase(objectId, comIF, cookie), gpioIF(gpioIF) {} + +void PayloadPcduHandler::doStartUp() { + if ((state != States::PCDU_OFF) and (state != States::ON_TRANS_SSR)) { + // Config error + sif::error << "PayloadPcduHandler::doStartUp: Invalid state" << std::endl; + } + if (state == States::PCDU_OFF) { + // Switch on relays here + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1); + state = States::ON_TRANS_SSR; + transitionOk = true; + } + if (state == States::ON_TRANS_SSR) { + // If necessary, check whether a certain amount of time has elapsed + if (transitionOk) { + transitionOk = false; + // We are now in ON mode + setMode(MODE_ON); + // The ADC can now be read. If the values are not close to zero, we should not allow + // transition + monMode = MonitoringMode::CLOSE_TO_ZERO; + } + } +} + +void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { + if (mode == _MODE_TO_NORMAL) { + if (state == States::ON_TRANS_ADC_CLOSE_ZERO) { + if (not commandExecuted) { + countdown.resetTimer(); + commandExecuted = true; + } + // ADC values are ok, 5 seconds have elapsed + if (transitionOk and countdown.hasTimedOut()) { + state = States::ON_TRANS_DRO; + // Now start monitoring for negative voltages instead + monMode = MonitoringMode::NEGATIVE; + countdown.resetTimer(); + commandExecuted = false; + transitionOk = false; + } + } + if (state == States::ON_TRANS_DRO) { + if (not commandExecuted) { + // Switch on DRO and start monitoring for negative voltagea + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); + commandExecuted = true; + } + // ADC values are ok, 5 seconds have elapsed + if (transitionOk and countdown.hasTimedOut()) { + state = States::ON_TRANS_X8; + countdown.resetTimer(); + commandExecuted = false; + transitionOk = false; + } + } + if (state == States::ON_TRANS_X8) { + if (not commandExecuted) { + // Switch on X8 + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8); + commandExecuted = true; + } + // ADC values are ok, 5 seconds have elapsed + if (transitionOk and countdown.hasTimedOut()) { + state = States::ON_TRANS_TX; + countdown.resetTimer(); + commandExecuted = false; + transitionOk = false; + } + } + if (state == States::ON_TRANS_TX) { + if (not commandExecuted) { + // Switch on TX + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX); + commandExecuted = true; + } + // ADC values are ok, 5 seconds have elapsed + if (transitionOk and countdown.hasTimedOut()) { + state = States::ON_TRANS_MPA; + countdown.resetTimer(); + commandExecuted = false; + transitionOk = false; + } + } + if (state == States::ON_TRANS_MPA) { + if (not commandExecuted) { + // Switch on MPA + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA); + commandExecuted = true; + } + // ADC values are ok, 5 seconds have elapsed + if (transitionOk and countdown.hasTimedOut()) { + state = States::ON_TRANS_HPA; + countdown.resetTimer(); + commandExecuted = false; + transitionOk = false; + } + } + if (state == States::ON_TRANS_HPA) { + if (not commandExecuted) { + // Switch on HPA + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA); + commandExecuted = true; + } + // ADC values are ok, 5 seconds have elapsed + if (transitionOk and countdown.hasTimedOut()) { + state = States::PCDU_ON; + setMode(MODE_NORMAL); + countdown.resetTimer(); + commandExecuted = false; + transitionOk = false; + } + } + } +} + +void PayloadPcduHandler::doShutDown() {} + +ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +void PayloadPcduHandler::fillCommandAndReplyMap() {} + +ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PayloadPcduHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + return HasReturnvaluesIF::RETURN_OK; +} + +uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + // 20 minutes transition delay is allowed + return 20 * 60 * 60; +} + +ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/linux/devices/PayloadPcduHandler.h b/linux/devices/PayloadPcduHandler.h new file mode 100644 index 00000000..53a96a5e --- /dev/null +++ b/linux/devices/PayloadPcduHandler.h @@ -0,0 +1,74 @@ +#ifndef LINUX_DEVICES_PLPCDUHANDLER_H_ +#define LINUX_DEVICES_PLPCDUHANDLER_H_ + +#include +#include + +#include "fsfw_hal/common/gpio/GpioIF.h" + +/** + * @brief Device handler for the EIVE Payload PCDU + * @details + * Documentation: + * https://egit.irs.uni-stuttgart.de/eive/eive_dokumente/src/branch/master/400_Raumsegment/412_PayloaPCDUDocumentation/release/EIVE-D-421-001_PLPCDU_Documentation.pdf + * + * Important components: + * - SSR - Solid State Relay: Decouples voltages from battery + * - DRO - Dielectric Resonsant Oscillator: Generates modulation signal + * - X8: Frequency X8 Multiplicator + * - TX: Transmitter/Sender module. Modulates data onto carrier signal + * - MPA - Medium Power Amplifier + * - HPA - High Power Amplifier + */ +class PayloadPcduHandler : DeviceHandlerBase { + public: + PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF); + + private: + enum class States { + PCDU_OFF, + // Solid State Relay, enable battery voltages VBAT0 and VBAT1. This will also switch on + // the ADC + ON_TRANS_SSR, + ON_TRANS_ADC_CLOSE_ZERO, + // Enable Dielectric Resonant Oscillator and start monitoring voltages as + // soon as DRO voltage reaches 6V + ON_TRANS_DRO, + // Switch on X8 compoennt and monitor voltages for 5 seconds + ON_TRANS_X8, + // Switch on TX component and monitor voltages for 5 seconds + ON_TRANS_TX, + // Switch on MPA component and monitor voltages for 5 seconds + ON_TRANS_MPA, + // Switch on HPA component and monitor voltages for 5 seconds + ON_TRANS_HPA, + // All components of the experiment are on + PCDU_ON, + } state = States::PCDU_OFF; + + enum class MonitoringMode { NONE, CLOSE_TO_ZERO, NEGATIVE } monMode = MonitoringMode::NONE; + + // This variable is tied to DRO +6 V voltage. Voltages, currents are monitored and the experiment + // is shut down immediately if there is a negative voltage. + bool transitionOk = false; + bool commandExecuted = false; + Countdown countdown = Countdown(5000); + GpioIF* gpioIF; + + void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; + void fillCommandAndReplyMap() override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, + size_t* foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; +}; + +#endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */ diff --git a/linux/devices/SolarArrayDeploymentHandler.cpp b/linux/devices/SolarArrayDeploymentHandler.cpp index fed3992b..13b46171 100644 --- a/linux/devices/SolarArrayDeploymentHandler.cpp +++ b/linux/devices/SolarArrayDeploymentHandler.cpp @@ -21,8 +21,9 @@ SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId deplSA2(deplSA2), burnTimeMs(burnTimeMs), actionHelper(this, nullptr) { + auto mqArgs = MqArgs(setObjectId_, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( - cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {} diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index 44755f41..e36460a3 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -1,149 +1,151 @@ #include "SusHandler.h" #include +#include #include #include "OBSWConfig.h" -SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, +SusHandler::SusHandler(object_id_t objectId, uint8_t susIdx, object_id_t comIF, CookieIF *comCookie, LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId) - : DeviceHandlerBase(objectId, comIF, comCookie), - gpioComIF(gpioComIF), - chipSelectId(chipSelectId), - dataset(this) { - if (comCookie == NULL) { - sif::error << "SusHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "SusHandler: Invalid GpioComIF" << std::endl; - } -} + : DeviceHandlerBase(objectId, comIF, comCookie), divider(5), dataset(this), susIdx(susIdx) {} SusHandler::~SusHandler() {} -ReturnValue_t SusHandler::performOperation(uint8_t counter) { - if (counter != FIRST_WRITE) { - DeviceHandlerBase::performOperation(counter); - return RETURN_OK; - } - - if (mode != MODE_NORMAL) { - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - return RETURN_OK; - } - - /* If device is in normale mode the communication sequence is initiated here */ - if (communicationStep == CommunicationStep::IDLE) { - communicationStep = CommunicationStep::WRITE_SETUP; - } - - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - - return RETURN_OK; -} - ReturnValue_t SusHandler::initialize() { ReturnValue_t result = RETURN_OK; result = DeviceHandlerBase::initialize(); if (result != RETURN_OK) { return result; } - auto spiComIF = dynamic_cast(communicationInterface); - if (spiComIF == nullptr) { - sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - spiMutex = spiComIF->getMutex(); - if (spiMutex == nullptr) { - sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } return RETURN_OK; } void SusHandler::doStartUp() { + if (comState == ComStates::IDLE) { + comState = ComStates::WRITE_SETUP; + commandExecuted = false; + } + if (comState == ComStates::WRITE_SETUP) { + if (commandExecuted) { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif + commandExecuted = false; + if (clkMode == ClkModes::INT_CLOCKED) { + comState = ComStates::START_INT_CLOCKED_CONVERSIONS; + } else { + comState = ComStates::EXT_CLOCKED_CONVERSIONS; + } + } + } } void SusHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } ReturnValue_t SusHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - if (communicationStep == CommunicationStep::IDLE) { - return NOTHING_TO_SEND; + switch (comState) { + case (ComStates::IDLE): { + return NOTHING_TO_SEND; + } + case (ComStates::WRITE_SETUP): { + *id = SUS::WRITE_SETUP; + return buildCommandFromCommand(*id, nullptr, 0); + } + case (ComStates::EXT_CLOCKED_CONVERSIONS): { + *id = SUS::READ_EXT_TIMED_CONVERSIONS; + return buildCommandFromCommand(*id, nullptr, 0); + } + case (ComStates::START_INT_CLOCKED_CONVERSIONS): { + *id = SUS::START_INT_TIMED_CONVERSIONS; + comState = ComStates::READ_INT_CLOCKED_CONVERSIONS; + return buildCommandFromCommand(*id, nullptr, 0); + } + case (ComStates::READ_INT_CLOCKED_CONVERSIONS): { + *id = SUS::READ_INT_TIMED_CONVERSIONS; + comState = ComStates::START_INT_CLOCKED_CONVERSIONS; + return buildCommandFromCommand(*id, nullptr, 0); + } + case (ComStates::EXT_CLOCKED_TEMP): { + *id = SUS::READ_EXT_TIMED_TEMPS; + return buildCommandFromCommand(*id, nullptr, 0); + } } - - if (communicationStep == CommunicationStep::WRITE_SETUP) { - *id = SUS::WRITE_SETUP; - communicationStep = CommunicationStep::START_CONVERSIONS; - } else if (communicationStep == CommunicationStep::START_CONVERSIONS) { - *id = SUS::START_CONVERSIONS; - communicationStep = CommunicationStep::READ_CONVERSIONS; - } else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { - *id = SUS::READ_CONVERSIONS; - communicationStep = CommunicationStep::IDLE; - } - return buildCommandFromCommand(*id, nullptr, 0); + return NOTHING_TO_SEND; } ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + if (comState == ComStates::WRITE_SETUP) { + *id = SUS::WRITE_SETUP; + return buildCommandFromCommand(*id, nullptr, 0); + } return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) { + using namespace max1227; switch (deviceCommand) { case (SUS::WRITE_SETUP): { - /** - * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a - * measurement the setup has to be rewritten. There must also be a little delay between - * the transmission of the setup byte and the first conversion. Thus the conversion - * will be performed in an extra step. - * Because the chip select is driven manually by the SusHandler the SPI bus must be - * protected with a mutex here. - */ - ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); - if (result == MutexIF::MUTEX_TIMEOUT) { - sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; - return ERROR_LOCK_MUTEX; - } else if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" << std::endl; - return ERROR_LOCK_MUTEX; + if (clkMode == ClkModes::INT_CLOCKED) { + cmdBuffer[0] = SUS::SETUP_INT_CLOKED; + } else { + cmdBuffer[0] = SUS::SETUP_EXT_CLOCKED; } - gpioComIF->pullLow(chipSelectId); - cmdBuffer[0] = SUS::SETUP; rawPacket = cmdBuffer; rawPacketLen = 1; - return RETURN_OK; + break; } - case (SUS::START_CONVERSIONS): { + case (SUS::START_INT_TIMED_CONVERSIONS): { std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - cmdBuffer[0] = SUS::CONVERSION; + cmdBuffer[0] = max1227::buildResetByte(true); + cmdBuffer[1] = SUS::CONVERSION; rawPacket = cmdBuffer; rawPacketLen = 2; - return RETURN_OK; + break; } - case (SUS::READ_CONVERSIONS): { + case (SUS::READ_INT_TIMED_CONVERSIONS): { std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); rawPacket = cmdBuffer; - rawPacketLen = SUS::SIZE_READ_CONVERSIONS; - return RETURN_OK; + rawPacketLen = SUS::SIZE_READ_INT_CONVERSIONS; + break; + } + case (SUS::READ_EXT_TIMED_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + rawPacket = cmdBuffer; + for (uint8_t idx = 0; idx < 6; idx++) { + cmdBuffer[idx * 2] = buildConvByte(ScanModes::N_ONCE, idx, false); + cmdBuffer[idx * 2 + 1] = 0; + } + cmdBuffer[12] = 0x00; + rawPacketLen = SUS::SIZE_READ_EXT_CONVERSIONS; + break; + } + case (SUS::READ_EXT_TIMED_TEMPS): { + cmdBuffer[0] = buildConvByte(ScanModes::N_ONCE, 0, true); + std::memset(cmdBuffer + 1, 0, 24); + rawPacket = cmdBuffer; + rawPacketLen = 25; + break; } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_OK; } void SusHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(SUS::WRITE_SETUP); - this->insertInCommandMap(SUS::START_CONVERSIONS); - this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); + insertInCommandAndReplyMap(SUS::WRITE_SETUP, 1); + insertInCommandAndReplyMap(SUS::START_INT_TIMED_CONVERSIONS, 1); + insertInCommandAndReplyMap(SUS::READ_INT_TIMED_CONVERSIONS, 1, &dataset, + SUS::SIZE_READ_INT_CONVERSIONS); + insertInCommandAndReplyMap(SUS::READ_EXT_TIMED_CONVERSIONS, 1, &dataset, + SUS::SIZE_READ_EXT_CONVERSIONS); + insertInCommandAndReplyMap(SUS::READ_EXT_TIMED_TEMPS, 1); } ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -155,38 +157,48 @@ ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSiz ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch (id) { - case SUS::READ_CONVERSIONS: { + case SUS::WRITE_SETUP: { + if (mode == _MODE_START_UP) { + commandExecuted = true; + } + return HasReturnvaluesIF::RETURN_OK; + } + case SUS::START_INT_TIMED_CONVERSIONS: { + return HasReturnvaluesIF::RETURN_OK; + } + case SUS::READ_INT_TIMED_CONVERSIONS: { PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; + + dataset.temperatureCelcius = static_cast((packet[0] << 8) | packet[1]) * 0.125; dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() - << ", Temperature: " << dataset.temperatureCelcius << " °C" << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " << std::dec - << dataset.ain0 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " << std::dec - << dataset.ain1 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " << std::dec - << dataset.ain2 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " << std::dec - << dataset.ain3 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " << std::dec - << dataset.ain4 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " << std::dec - << dataset.ain5 << std::endl; -#endif - /** SUS can now be shutdown and thus the SPI bus released again */ - gpioComIF->pullHigh(chipSelectId); - ReturnValue_t result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { - sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" << std::endl; - return ERROR_UNLOCK_MUTEX; + printDataset(); + break; + } + case (SUS::READ_EXT_TIMED_CONVERSIONS): { + PoolReadGuard readSet(&dataset); + dataset.ain0 = (packet[1] << 8) | packet[2]; + dataset.ain1 = (packet[3] << 8) | packet[4]; + dataset.ain2 = (packet[5] << 8) | packet[6]; + dataset.ain3 = (packet[7] << 8) | packet[8]; + dataset.ain4 = (packet[9] << 8) | packet[10]; + dataset.ain5 = (packet[11] << 8) | packet[12]; + // Read temperature in next read cycle + if (clkMode == ClkModes::EXT_CLOCKED_WITH_TEMP) { + comState = ComStates::EXT_CLOCKED_TEMP; } + printDataset(); + break; + } + case (SUS::READ_EXT_TIMED_TEMPS): { + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = + static_cast(((packet[23] & 0x0f) << 8) | packet[24]) * 0.125; + comState = ComStates::EXT_CLOCKED_CONVERSIONS; break; } default: { @@ -197,9 +209,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8 return HasReturnvaluesIF::RETURN_OK; } -void SusHandler::setNormalDatapoolEntriesInvalid() {} - -uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } +uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 2000; } ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { @@ -212,3 +222,21 @@ ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localData localDataPoolMap.emplace(SUS::AIN5, new PoolEntry({0})); return HasReturnvaluesIF::RETURN_OK; } + +void SusHandler::setToGoToNormalMode(bool enable) { this->goToNormalModeImmediately = enable; } + +void SusHandler::printDataset() { +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS == 1 + if (divider.checkAndIncrement()) { + sif::info << "SUS " << std::setw(2) << std::dec << static_cast(susIdx) << " ID " + << std::hex << "0x" << this->getObjectId() << " [" << std::hex << std::setw(3); + sif::info << dataset.ain0 << ","; + sif::info << dataset.ain1 << ","; + sif::info << dataset.ain2 << ","; + sif::info << dataset.ain3 << ","; + sif::info << dataset.ain4 << ","; + sif::info << dataset.ain5 << "] "; + sif::info << "T[C] " << dataset.temperatureCelcius << " C" << std::endl; + } +#endif +} diff --git a/linux/devices/SusHandler.h b/linux/devices/SusHandler.h index 0eab5fd0..4088bd0a 100644 --- a/linux/devices/SusHandler.h +++ b/linux/devices/SusHandler.h @@ -5,13 +5,16 @@ #include #include "devicedefinitions/SusDefinitions.h" +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" +#include "mission/devices/max1227.h" /** - * @brief This is the device handler class for the SUS sensor. The sensor is - * based on the MAX1227 ADC. Details about the SUS electronic can be found at - * https://egit.irs.uni-stuttgart.de/eive/eive_dokumente/src/branch/master/400_Raumsegment/443_SunSensorDocumentation/release + * @brief This is the device handler class for the SUS sensor based on the MAX1227 ADC. * - * @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf + * @details + * Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf + * Details about the SUS electronic can be found at + * https://egit.irs.uni-stuttgart.de/eive/eive_dokumente/src/branch/master/400_Raumsegment/443_SunSensorDocumentation/release * * @note When adding a SusHandler to the polling sequence table make sure to add a slot with * the executionStep FIRST_WRITE. Otherwise the communication sequence will never be @@ -21,15 +24,18 @@ */ class SusHandler : public DeviceHandlerBase { public: + enum ClkModes { INT_CLOCKED, EXT_CLOCKED, EXT_CLOCKED_WITH_TEMP }; + static const uint8_t FIRST_WRITE = 7; - SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + SusHandler(object_id_t objectId, uint8_t susIdx, object_id_t comIF, CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); virtual ~SusHandler(); - virtual ReturnValue_t performOperation(uint8_t counter) override; + // virtual ReturnValue_t performOperation(uint8_t counter) override; virtual ReturnValue_t initialize() override; + void setToGoToNormalMode(bool enable); protected: void doStartUp() override; @@ -42,7 +48,7 @@ class SusHandler : public DeviceHandlerBase { ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; - void setNormalDatapoolEntriesInvalid() override; + // void setNormalDatapoolEntriesInvalid() override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; @@ -53,19 +59,33 @@ class SusHandler : public DeviceHandlerBase { static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); - enum class CommunicationStep { IDLE, WRITE_SETUP, START_CONVERSIONS, READ_CONVERSIONS }; + enum class ComStates { + IDLE, + WRITE_SETUP, + EXT_CLOCKED_CONVERSIONS, + EXT_CLOCKED_TEMP, + START_INT_CLOCKED_CONVERSIONS, + READ_INT_CLOCKED_CONVERSIONS + }; - LinuxLibgpioIF* gpioComIF = nullptr; - - gpioId_t chipSelectId = gpio::NO_GPIO; + PeriodicOperationDivider divider; + // LinuxLibgpioIF* gpioComIF = nullptr; + // gpioId_t chipSelectId = gpio::NO_GPIO; + bool goToNormalModeImmediately = false; + bool commandExecuted = false; SUS::SusDataset dataset; + // Read temperature in each alternating communication step when using + // externally clocked mode + ClkModes clkMode = ClkModes::INT_CLOCKED; + uint8_t susIdx = 0; uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; - CommunicationStep communicationStep = CommunicationStep::IDLE; + ComStates comState = ComStates::IDLE; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t timeoutMs = 20; + void printDataset(); MutexIF* spiMutex = nullptr; }; diff --git a/linux/devices/devicedefinitions/GPSDefinitions.h b/linux/devices/devicedefinitions/GPSDefinitions.h new file mode 100644 index 00000000..5a565fea --- /dev/null +++ b/linux/devices/devicedefinitions/GPSDefinitions.h @@ -0,0 +1,63 @@ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ + +#include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + +namespace GpsHyperion { + +static constexpr DeviceCommandId_t GPS_REPLY = 0; +static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5; + +static constexpr uint32_t DATASET_ID = 0; + +enum GpsPoolIds : lp_id_t { + LATITUDE = 0, + LONGITUDE = 1, + ALTITUDE = 2, + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 +}; + +enum GpsFixModes : uint8_t { INVALID = 0, NO_FIX = 1, FIX_2D = 2, FIX_3D = 3 }; + +} // namespace GpsHyperion + +class GpsPrimaryDataset : public StaticLocalDataSet<18> { + public: + GpsPrimaryDataset(object_id_t gpsId) : StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { + setAllVariablesReadOnly(); + } + + lp_var_t latitude = lp_var_t(sid.objectId, GpsHyperion::LATITUDE, this); + lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); + lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); + lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = + lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); + + private: + friend class GPSHyperionLinuxController; + GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} +}; + +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ diff --git a/linux/devices/devicedefinitions/SusDefinitions.h b/linux/devices/devicedefinitions/SusDefinitions.h index 2a45ebc5..260bfdc7 100644 --- a/linux/devices/devicedefinitions/SusDefinitions.h +++ b/linux/devices/devicedefinitions/SusDefinitions.h @@ -8,25 +8,23 @@ namespace SUS { -/** - * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by - * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. - */ -static const uint32_t MAX1227_SPI_FREQ = 1000000; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending -static const DeviceCommandId_t WRITE_SETUP = 0x1; +static const DeviceCommandId_t WRITE_SETUP = 1; /** * This command initiates the ADC conversion for all channels including the internal * temperature sensor. */ -static const DeviceCommandId_t START_CONVERSIONS = 0x2; +static const DeviceCommandId_t START_INT_TIMED_CONVERSIONS = 2; /** * This command reads the internal fifo which holds the temperature and the channel * conversions. */ -static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +static constexpr DeviceCommandId_t READ_INT_TIMED_CONVERSIONS = 3; + +static constexpr DeviceCommandId_t READ_EXT_TIMED_CONVERSIONS = 4; + +static constexpr DeviceCommandId_t READ_EXT_TIMED_TEMPS = 5; /** * @brief This is the configuration byte which will be written to the setup register after @@ -39,7 +37,8 @@ static const DeviceCommandId_t READ_CONVERSIONS = 0x3; * written to the setup register * */ -static const uint8_t SETUP = 0b01101000; +static constexpr uint8_t SETUP_INT_CLOKED = 0b01101000; +static constexpr uint8_t SETUP_EXT_CLOCKED = 0b01111000; /** * @brief This values will always be written to the ADC conversion register to specify the @@ -51,12 +50,14 @@ static const uint8_t SETUP = 0b01101000; */ static const uint8_t CONVERSION = 0b10101001; -static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t SUS_DATA_SET_ID = READ_EXT_TIMED_CONVERSIONS; /** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ -static const uint8_t SIZE_READ_CONVERSIONS = 14; +static const uint8_t SIZE_READ_INT_CONVERSIONS = 14; +// 6 * conv byte, 6 * 0 and one trailing zero +static constexpr uint8_t SIZE_READ_EXT_CONVERSIONS = 13; -static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; +static const uint8_t MAX_CMD_SIZE = 32; static const uint8_t POOL_ENTRIES = 7; diff --git a/linux/devices/devicedefinitions/payloadPcduDefinitions.h b/linux/devices/devicedefinitions/payloadPcduDefinitions.h new file mode 100644 index 00000000..a2c362a0 --- /dev/null +++ b/linux/devices/devicedefinitions/payloadPcduDefinitions.h @@ -0,0 +1,12 @@ +#ifndef LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ +#define LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ + +#include + +namespace plpcdu { + +static constexpr size_t MAX_ADC_REPLY_SIZE = 32; + +} + +#endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */ diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index fd5ae534..569818f0 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -35,9 +35,9 @@ debugging. */ #define OBSW_USE_CCSDS_IP_CORE 1 // Set to 1 if all telemetry should be sent to the PTME IP Core -#define OBSW_TM_TO_PTME 1 +#define OBSW_TM_TO_PTME 0 // Set to 1 if telecommands are received via the PDEC IP Core -#define OBSW_TC_FROM_PDEC 1 +#define OBSW_TC_FROM_PDEC 0 #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_MGT 1 @@ -52,6 +52,7 @@ debugging. */ #define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_TMP_DEVICES 0 #define OBSW_ADD_RAD_SENSORS 0 +#define OBSW_ADD_PL_PCDU 0 #define OBSW_ADD_SYRLINKS 0 #define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0 #define OBSW_ENABLE_PERIODIC_HK 0 @@ -62,7 +63,7 @@ debugging. */ /** All of the following flags should be disabled for mission code */ /*******************************************************************/ -//! /* 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_PRINT_MISSED_DEADLINES 1 @@ -76,9 +77,15 @@ debugging. */ #define OBSW_ADD_I2C_TEST_CODE 0 #define OBSW_ADD_UART_TEST_CODE 0 +#define OBSW_TEST_ACS 0 +#define OBSW_DEBUG_ACS 0 +#define OBSW_TEST_SUS 0 +#define OBSW_DEBUG_SUS 0 +#define OBSW_TEST_RTD 0 +#define OBSW_DEBUG_RTD 0 +#define OBSW_TEST_RAD_SENSOR 0 +#define OBSW_DEBUG_RAD_SENSOR 0 #define OBSW_TEST_LIBGPIOD 0 -#define OBSW_TEST_RADIATION_SENSOR_HANDLER 0 -#define OBSW_TEST_SUS_HANDLER 0 #define OBSW_TEST_PLOC_HANDLER 0 #define OBSW_TEST_BPX_BATT 0 #define OBSW_TEST_CCSDS_BRIDGE 0 @@ -86,7 +93,6 @@ debugging. */ #define OBSW_TEST_TE7020_HEATER 0 #define OBSW_TEST_GPIO_OPEN_BY_LABEL 0 #define OBSW_TEST_GPIO_OPEN_BY_LINE_NAME 0 - #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_BPX_BATT 0 #define OBSW_DEBUG_PDU1 0 @@ -95,9 +101,6 @@ debugging. */ #define OBSW_DEBUG_ACU 0 #define OBSW_DEBUG_SYRLINKS 0 #define OBSW_DEBUG_IMTQ 0 -#define OBSW_DEBUG_RAD_SENSOR 0 -#define OBSW_DEBUG_SUS 0 -#define OBSW_DEBUG_RTD 0 #define OBSW_DEBUG_RW 0 #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 diff --git a/linux/fsfwconfig/devices/addresses.cpp b/linux/fsfwconfig/devices/addresses.cpp index 60b1370b..580818e0 100644 --- a/linux/fsfwconfig/devices/addresses.cpp +++ b/linux/fsfwconfig/devices/addresses.cpp @@ -1,7 +1 @@ -/** - * \file logicalAddresses.cpp - * - * \date 06.11.2019 - */ - #include "addresses.h" diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index a69cdaf9..0016c6a4 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -24,6 +24,7 @@ enum logicalAddresses : address_t { RAD_SENSOR = objects::RAD_SENSOR, + SUS_0 = objects::SUS_0, SUS_1 = objects::SUS_1, SUS_2 = objects::SUS_2, SUS_3 = objects::SUS_3, @@ -35,8 +36,6 @@ enum logicalAddresses : address_t { SUS_9 = objects::SUS_9, SUS_10 = objects::SUS_10, SUS_11 = objects::SUS_11, - SUS_12 = objects::SUS_12, - SUS_13 = objects::SUS_13, /* Dummy and Test Addresses */ DUMMY_ECHO = 129, @@ -71,7 +70,8 @@ enum spiAddresses : address_t { RW1, RW2, RW3, - RW4 + RW4, + PLPCDU_ADC }; /* Addresses of devices supporting the CSP protocol */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 46717569..e6f42eb4 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -54,6 +54,7 @@ enum gpioId_t { RTD_IC_17, RTD_IC_18, + CS_SUS_0, CS_SUS_1, CS_SUS_2, CS_SUS_3, @@ -65,17 +66,16 @@ enum gpioId_t { CS_SUS_9, CS_SUS_10, CS_SUS_11, - CS_SUS_12, - CS_SUS_13, + SPI_MUX_BIT_0, SPI_MUX_BIT_1, SPI_MUX_BIT_2, SPI_MUX_BIT_3, SPI_MUX_BIT_4, SPI_MUX_BIT_5, - SPI_MUX_BIT_6, CS_RAD_SENSOR, + ENABLE_RADFET, PAPB_BUSY_N, PAPB_EMPTY, @@ -110,7 +110,16 @@ enum gpioId_t { RS485_EN_RX_DATA, RS485_EN_RX_CLOCK, - BIT_RATE_SEL + BIT_RATE_SEL, + + PLPCDU_ENB_VBAT0, + PLPCDU_ENB_VBAT1, + PLPCDU_ENB_DRO, + PLPCDU_ENB_X8, + PLPCDU_ENB_TX, + PLPCDU_ENB_HPA, + PLPCDU_ENB_MPA, + PLPCDU_ADC_CS }; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 9ddff5d3..0c7fcd9c 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -28,6 +28,13 @@ ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { uint32_t length = thisSequence->getPeriodMs(); static_cast(length); +#if OBSW_ADD_PL_PCDU == 1 + thisSequence->addSlot(objects::PLPCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLPCDU_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLPCDU_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLPCDU_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLPCDU_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#endif #if OBSW_ADD_TMP_DEVICES == 1 thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -153,6 +160,19 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { #endif #if OBSW_ADD_SUN_SENSORS == 1 + + bool addSus0 = true; + bool addSus1 = true; + bool addSus2 = true; + bool addSus3 = true; + bool addSus4 = true; + bool addSus5 = true; + bool addSus6 = true; + bool addSus7 = true; + bool addSus8 = true; + bool addSus9 = true; + bool addSus10 = true; + bool addSus11 = true; /** * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all * requests to a sun sensor must be performed consecutively. Another reason for calling multiple @@ -161,253 +181,157 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be * inserted between the device handler cycles of one SUS. */ - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); + if (addSus0) { + /* Write setup */ + thisSequence->addSlot(objects::SUS_0, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_0, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_0, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_0, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_0, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_0, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_0, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_0, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_0, length * 0.4, DeviceHandlerIF::GET_READ); + } + if (addSus1) { + thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.4, DeviceHandlerIF::GET_READ); + } + if (addSus2) { + thisSequence->addSlot(objects::SUS_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.4, DeviceHandlerIF::GET_READ); + } + if (addSus3) { + thisSequence->addSlot(objects::SUS_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.4, DeviceHandlerIF::GET_READ); + } + if (addSus4) { + thisSequence->addSlot(objects::SUS_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.4, DeviceHandlerIF::GET_READ); + } + if (addSus5) { + thisSequence->addSlot(objects::SUS_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.4, DeviceHandlerIF::GET_READ); + } - /* Write setup */ - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); + if (addSus6) { + thisSequence->addSlot(objects::SUS_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.4, DeviceHandlerIF::GET_READ); + } - /* Write setup */ - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); + if (addSus7) { + thisSequence->addSlot(objects::SUS_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.4, DeviceHandlerIF::GET_READ); + } - /* Write setup */ - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); + if (addSus8) { + thisSequence->addSlot(objects::SUS_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); -#endif + thisSequence->addSlot(objects::SUS_8, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.4, DeviceHandlerIF::GET_READ); + } + + if (addSus9) { + thisSequence->addSlot(objects::SUS_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.4, DeviceHandlerIF::GET_READ); + } + + if (addSus10) { + thisSequence->addSlot(objects::SUS_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::SUS_10, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.4, DeviceHandlerIF::GET_READ); + } + + if (addSus11) { + thisSequence->addSlot(objects::SUS_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::SUS_11, length * 0.4, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.4, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.4, DeviceHandlerIF::GET_READ); + } +#endif /* OBSW_ADD_SUN_SENSORS == 1 */ #if OBSW_ADD_RW == 1 thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -452,21 +376,21 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); } @@ -474,7 +398,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // B side thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); @@ -484,21 +408,21 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); } #endif /* OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1 */ @@ -685,7 +609,7 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif -#if OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 +#if OBSW_TEST_RAD_SENSOR == 1 thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); @@ -693,7 +617,7 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif -#if OBSW_TEST_SUS_HANDLER == 1 +#if OBSW_TEST_SUS == 1 /* Write setup */ thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index f97c3965..b302d99e 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -24,7 +24,9 @@ PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, uioRamMemory(uioRamMemory), uioRegisters(uioRegisters), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + auto mqArgs = MqArgs(objectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue( + QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PdecHandler::~PdecHandler() {} diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index b17812e6..f2449271 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -69,7 +69,7 @@ void ObjectFactory::produceGenericObjects() { objects::CCSDS_PACKET_DISTRIBUTOR); // Every TM packet goes through this funnel - new TmFunnel(objects::TM_FUNNEL); + new TmFunnel(objects::TM_FUNNEL, 50); // PUS service stack new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, @@ -79,7 +79,7 @@ void ObjectFactory::produceGenericObjects() { new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW, pus::PUS_SERVICE_3); new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, - pus::PUS_SERVICE_5, 50); + pus::PUS_SERVICE_5, 120); new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 60); new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9); diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 3f5b5073..2e956c0e 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -1,5 +1,4 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE - GPSHyperionLinuxController.cpp GomspaceDeviceHandler.cpp BpxBatteryHandler.cpp Tmp1075Handler.cpp @@ -16,6 +15,7 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE RadiationSensorHandler.cpp GyroADIS1650XHandler.cpp RwHandler.cpp + max1227.cpp ) diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 0965e265..e3e418f7 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -20,10 +20,6 @@ GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, object_id_t dev primaryDataset(this), configDataset(this), breakCountdown() { -#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(5); -#endif - #if OBSW_ADIS1650X_LINUX_COM_IF == 1 SpiCookie *cookie = dynamic_cast(comCookie); if (cookie != nullptr) { @@ -101,7 +97,7 @@ ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t de switch (deviceCommand) { case (ADIS1650X::READ_OUT_CONFIG): { this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; - uint8_t regList[5]; + uint8_t regList[5] = {}; regList[0] = ADIS1650X::DIAG_STAT_REG; regList[1] = ADIS1650X::FILTER_CTRL_REG; regList[2] = ADIS1650X::MSC_CTRL_REG; @@ -305,18 +301,18 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { primaryDataset.setValidity(true, true); } -#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - if (debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; - sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; - sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; - sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; - sif::info << "X: " << primaryDataset.accelX.value << std::endl; - sif::info << "Y: " << primaryDataset.accelY.value << std::endl; - sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; + if (periodicPrintout) { + if (debugDivider.checkAndIncrement()) { + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; + sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; + sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; + sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; + sif::info << "X: " << primaryDataset.accelX.value << std::endl; + sif::info << "Y: " << primaryDataset.accelY.value << std::endl; + sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; + } } -#endif break; } @@ -446,6 +442,9 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie * } size_t idx = 0; + spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle(); + uint64_t origTx = transferStruct->tx_buf; + uint64_t origRx = transferStruct->rx_buf; while (idx < sendLen) { // Pull SPI CS low. For now, no support for active high given if (gpioId != gpio::NO_GPIO) { @@ -471,11 +470,12 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie * if (idx < sendLen) { usleep(ADIS1650X::STALL_TIME_MICROSECONDS); } - spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle(); + transferStruct->tx_buf += 2; transferStruct->rx_buf += 2; } - + transferStruct->tx_buf = origTx; + transferStruct->rx_buf = origRx; if (gpioId != gpio::NO_GPIO) { mutex->unlockMutex(); } @@ -486,4 +486,9 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie * void GyroADIS1650XHandler::setToGoToNormalModeImmediately() { goToNormalMode = true; } +void GyroADIS1650XHandler::enablePeriodicPrintouts(bool enable, uint8_t divider) { + periodicPrintout = enable; + debugDivider.setDivider(divider); +} + #endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index 1db0f3a8..55de1477 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -23,6 +23,7 @@ class GyroADIS1650XHandler : public DeviceHandlerBase { GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, ADIS1650X::Type type); + void enablePeriodicPrintouts(bool enable, uint8_t divider); void setToGoToNormalModeImmediately(); // DeviceHandlerBase abstract function implementation @@ -69,13 +70,13 @@ class GyroADIS1650XHandler : public DeviceHandlerBase { size_t sendLen, void *args); #endif -#if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - PeriodicOperationDivider *debugDivider; -#endif Countdown breakCountdown; void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); ReturnValue_t handleSensorData(const uint8_t *packet); + + bool periodicPrintout = false; + PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3); }; #endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */ diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 572810bd..255ba6ec 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -16,8 +16,9 @@ HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_ mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), actionHelper(this, nullptr) { + auto mqArgs = MqArgs(setObjectId_, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( - cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } HeaterHandler::~HeaterHandler() {} diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index 13bed074..408bbb95 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -12,8 +12,9 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) pdu2HkTableDataset(this), pdu1HkTableDataset(this), cmdQueueSize(cmdQueueSize) { + auto mqArgs = MqArgs(setObjectId, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( - cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PCDUHandler::~PCDUHandler() {} diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 83720b53..c5148c84 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -14,11 +14,13 @@ RadiationSensorHandler::~RadiationSensorHandler() {} void RadiationSensorHandler::doStartUp() { if (internalState == InternalState::CONFIGURED) { -#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); -#else - setMode(_MODE_TO_ON); -#endif + if (goToNormalMode) { + setMode(MODE_NORMAL); + } + + else { + setMode(_MODE_TO_ON); + } } } @@ -124,7 +126,8 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, case RAD_SENSOR::READ_CONVERSIONS: { uint8_t offset = 0; PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; + int16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1]; + dataset.temperatureCelcius = tempRaw * 0.125; offset += 2; dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); offset += 2; @@ -175,3 +178,5 @@ ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPoo localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry({0})); return HasReturnvaluesIF::RETURN_OK; } + +void RadiationSensorHandler::setToGoToNormalModeImmediately() { this->goToNormalMode = true; } diff --git a/mission/devices/RadiationSensorHandler.h b/mission/devices/RadiationSensorHandler.h index fe4e4264..0fed2c83 100644 --- a/mission/devices/RadiationSensorHandler.h +++ b/mission/devices/RadiationSensorHandler.h @@ -16,6 +16,7 @@ class RadiationSensorHandler : public DeviceHandlerBase { public: RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); virtual ~RadiationSensorHandler(); + void setToGoToNormalModeImmediately(); protected: void doStartUp() override; @@ -42,6 +43,7 @@ class RadiationSensorHandler : public DeviceHandlerBase { static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; + bool goToNormalMode = false; uint8_t cmdBuffer[MAX_CMD_LEN]; InternalState internalState = InternalState::SETUP; CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; diff --git a/mission/devices/max1227.cpp b/mission/devices/max1227.cpp new file mode 100644 index 00000000..88cab185 --- /dev/null +++ b/mission/devices/max1227.cpp @@ -0,0 +1,38 @@ +#include "max1227.h" + +#include + +uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) { + return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp; +} + +uint8_t max1227::buildSetupByte(ClkSel clkSel, RefSel refSel, DiffSel diffSel) { + return (1 << 6) | (clkSel << 4) | (refSel << 2) | diffSel; +} + +void max1227::prepareExternallyClockedSingleChannelRead(uint8_t *spiBuf, uint8_t channel, + size_t &sz) { + spiBuf[0] = buildConvByte(ScanModes::N_ONCE, channel, false); + spiBuf[1] = 0x00; + spiBuf[2] = 0x00; + sz = 3; +} + +uint8_t max1227::buildResetByte(bool fifoOnly) { return (1 << 4) | (fifoOnly << 3); } + +void max1227::prepareExternallyClockedRead0ToN(uint8_t *spiBuf, uint8_t n, size_t &sz) { + for (uint8_t idx = 0; idx <= n; idx++) { + spiBuf[idx * 2] = buildConvByte(ScanModes::N_ONCE, idx, false); + spiBuf[idx * 2 + 1] = 0x00; + } + spiBuf[(n + 1) * 2] = 0x00; + sz = (n + 1) * 2 + 1; +} + +void max1227::prepareExternallyClockedTemperatureRead(uint8_t *spiBuf, size_t &sz) { + spiBuf[0] = buildConvByte(ScanModes::N_ONCE, 0, true); + std::memset(spiBuf + 1, 0, 24); + sz = 25; +} + +float max1227::getTemperature(int16_t temp) { return static_cast(temp) * 0.125; } diff --git a/mission/devices/max1227.h b/mission/devices/max1227.h new file mode 100644 index 00000000..bf76a81b --- /dev/null +++ b/mission/devices/max1227.h @@ -0,0 +1,78 @@ +#ifndef MISSION_DEVICES_MAX1227_H_ +#define MISSION_DEVICES_MAX1227_H_ + +#include +#include + +namespace max1227 { + +enum ScanModes : uint8_t { + CHANNELS_0_TO_N = 0b00, + CHANNEL_N_TO_HIGHEST = 0b01, + N_REPEATEDLY = 0b10, + N_ONCE = 0b11 +}; + +enum ClkSel : uint8_t { + INT_CONV_INT_TIMED_CNVST_AS_CNVST = 0b00, + INT_CONV_EXT_TIMED_CNVST = 0b01, + // Default mode upon power-up + INT_CONV_INT_TIMED_CNVST_AS_AIN = 0b10, + // Use external SPI clock for conversion and timing + EXT_CONV_EXT_TIMED = 0b11 +}; + +enum RefSel : uint8_t { + INT_REF_WITH_WAKEUP = 0b00, + // No wakeup delay needed + EXT_REF_SINGLE_ENDED = 0b01, + INT_REF_NO_WAKEUP = 0b10, + // No wakeup delay needed + EXT_REF_DIFFERENTIAL = 0b11 +}; + +enum DiffSel : uint8_t { + NONE_0 = 0b00, + NONE_1 = 0b01, + // One unipolar config byte follows the setup byte + UNIPOLAR_CFG = 0b10, + // One bipolar config byte follows the setup byte + BIPOLAR_CFG = 0b11 +}; + +uint8_t buildResetByte(bool fifoOnly); +uint8_t buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp); +uint8_t buildSetupByte(ClkSel clkSel, RefSel refSel, DiffSel diffSel); + +/** + * If there is a wakeup delay, there needs to be a 65 us delay between sending + * the first byte (conversion byte) and the the rest of the SPI buffer. + * The raw ADC value will be located in the first and second reply byte. + * @param spiBuf + * @param n + * @param sz + */ +void prepareExternallyClockedSingleChannelRead(uint8_t* spiBuf, uint8_t channel, size_t& sz); + +/** + * If there is a wakeup delay, there needs to be a 65 us delay between sending + * the first byte (first conversion byte) the the rest of the SPI buffer. + * @param spiBuf + * @param n Channel number. Example: If the ADC has 6 channels, n will be 5 + * @param sz + */ +void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz); + +/** + * Prepare an externally clocked temperature read. 25 bytes have to be sent + * and the raw temperature value will appear on the last 2 bytes of the reply. + * @param spiBuf + * @param sz + */ +void prepareExternallyClockedTemperatureRead(uint8_t* spiBuf, size_t& sz); + +float getTemperature(int16_t temp); + +} // namespace max1227 + +#endif /* MISSION_DEVICES_MAX1227_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 35978627..d6c2367b 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -23,7 +23,9 @@ CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t enTxClock(enTxClock), enTxData(enTxData) { commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); + auto mqArgs = MqArgs(objectId, static_cast(this)); + eventQueue = + QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs); } CCSDSHandler::~CCSDSHandler() {} diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 4f62102c..284cbcba 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -132,7 +132,7 @@ class CCSDSHandler : public SystemObject, ActionHelper actionHelper; - MessageQueueId_t tcDistributorQueueId; + MessageQueueId_t tcDistributorQueueId = MessageQueueIF::NO_QUEUE; PtmeConfig* ptmeConfig = nullptr; diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 5b9387fd..9d413ca7 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -7,9 +7,11 @@ #include "fsfw/serviceinterface/ServiceInterfaceStream.h" #include "fsfw/tmtcservices/TmTcMessage.h" -VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : vcId(vcId) { - tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth, object_id_t ownerId) + : vcId(vcId) { + auto mqArgs = MqArgs(ownerId, reinterpret_cast(vcId)); + tmQueue = QueueFactory::instance()->createMessageQueue( + tmQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } ReturnValue_t VirtualChannel::initialize() { diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index 48cc74a4..c661c4c5 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -24,7 +24,7 @@ class VirtualChannel : public AcceptsTelemetryIF, public HasReturnvaluesIF { * @param vcId The virtual channel id assigned to this object * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects */ - VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); + VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth, object_id_t ownerId); ReturnValue_t initialize(); MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 5577f5fa..e22eabdf 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -11,10 +11,11 @@ object_id_t TmFunnel::storageDestination = objects::NO_OBJECT; TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth) : SystemObject(objectId), messageDepth(messageDepth) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); + auto mqArgs = MqArgs(objectId, static_cast(this)); + tmQueue = QueueFactory::instance()->createMessageQueue( + messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); storageQueue = QueueFactory::instance()->createMessageQueue( - messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); + messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } TmFunnel::~TmFunnel() {} diff --git a/tmtc b/tmtc index 6a783112..a671e864 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6a78311239bdf78040e43ef217035fcaa2ab9f3b +Subproject commit a671e86400152d8480c1efde29d69848ca6b6066