continued rpi sus port

This commit is contained in:
Robin Müller 2022-03-30 17:44:07 +02:00
parent 9f937781b7
commit 2c8b691ca4
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
12 changed files with 128 additions and 21 deletions

View File

@ -1,6 +1,7 @@
target_sources(${OBSW_NAME} PUBLIC
InitMission.cpp
main.cpp
gpioInit.cpp
ObjectFactory.cpp
)

View File

@ -2,9 +2,11 @@
#include "OBSWConfig.h"
#include "devConf.h"
#include "gpioInit.h"
#include "devices/addresses.h"
#include "devices/gpioIds.h"
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
#include "fsfw/power/DummyPowerSwitcher.h"
#include "fsfw/tasks/TaskFactory.h"
#include "fsfw/tmtcpacket/pus/tm.h"
#include "fsfw/tmtcservices/CommandingServiceBase.h"
@ -67,14 +69,19 @@ void ObjectFactory::produce(void* args) {
std::string spiDev = "/dev/spidev0.1";
SpiComIF* spiComIF = new SpiComIF(objects::SPI_COM_IF, gpioIF);
static_cast<void>(spiComIF);
auto pwrSwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
#if OBSW_ADD_ACS_BOARD == 1
#if OBSW_ADD_ACS_BOARD == 1 && defined(RASPBERRY_PI)
createRpiAcsBoard(gpioIF, spiDev);
#endif
#if OBSW_ADD_SUN_SENSORS == 1
createSunSensorComponents(gpioIF, spiComIF, nullptr, spiDev);
#ifdef RASPBERRY_PI
rpi::gpio::initSpiCsDecoder(gpioIF);
#endif
createSunSensorComponents(gpioIF, spiComIF, pwrSwitcher, spiDev);
#endif
#if OBSW_ADD_TEST_CODE == 1
createTestTasks();

View File

@ -17,16 +17,4 @@
#define RPI_ADD_UART_TEST 0
/* Adapt these values accordingly */
namespace gpio {
static constexpr uint8_t MGM_0_BCM_PIN = 17;
static constexpr uint8_t MGM_1_BCM_PIN = 27;
static constexpr uint8_t MGM_2_BCM_PIN = 22;
static constexpr uint8_t MGM_3_BCM_PIN = 23;
static constexpr uint8_t GYRO_0_BCM_PIN = 5;
static constexpr uint8_t GYRO_1_BCM_PIN = 6;
static constexpr uint8_t GYRO_2_BCM_PIN = 13;
static constexpr uint8_t GYRO_3_BCM_PIN = 19;
}
#endif /* BSP_RPI_BOARDCONFIG_RPI_CONFIG_H_ */

View File

@ -0,0 +1,30 @@
#ifndef BSP_LINUX_BOARD_DEFINITIONS_H_
#define BSP_LINUX_BOARD_DEFINITIONS_H_
#include "OBSWConfig.h"
#include <cstdint>
#ifdef RASPBERRY_PI
/* Adapt these values accordingly */
namespace gpio {
static constexpr uint8_t MGM_0_BCM_PIN = 17;
static constexpr uint8_t MGM_1_BCM_PIN = 27;
static constexpr uint8_t MGM_2_BCM_PIN = 22;
static constexpr uint8_t MGM_3_BCM_PIN = 23;
static constexpr uint8_t GYRO_0_BCM_PIN = 5;
static constexpr uint8_t GYRO_1_BCM_PIN = 6;
static constexpr uint8_t GYRO_2_BCM_PIN = 13;
static constexpr uint8_t GYRO_3_BCM_PIN = 19;
static constexpr uint8_t SPI_MUX_0_BCM = 17;
static constexpr uint8_t SPI_MUX_1_BCM = 27;
static constexpr uint8_t SPI_MUX_2_BCM = 22;
static constexpr uint8_t SPI_MUX_3_BCM = 23;
static constexpr uint8_t SPI_MUX_4_BCM = 5;
static constexpr uint8_t SPI_MUX_5_BCM = 6;
}
#endif
#endif /* BSP_LINUX_BOARD_DEFINITIONS_H_ */

View File

@ -0,0 +1,56 @@
#include "gpioInit.h"
#include "definitions.h"
#include <devices/gpioIds.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw_hal/common/gpio/GpioCookie.h>
#include "fsfw_hal/linux/rpi/GpioRPi.h"
#include <fsfw_hal/common/gpio/GpioIF.h>
#ifdef RASPBERRY_PI
struct MuxInfo {
MuxInfo(gpioId_t gpioId, int bcmNum, std::string consumer)
: gpioId(gpioId), bcmNum(bcmNum), consumer(consumer) {}
gpioId_t gpioId;
int bcmNum;
std::string consumer;
};
void rpi::gpio::initSpiCsDecoder(GpioIF* gpioComIF) {
using namespace ::gpio;
ReturnValue_t result;
if (gpioComIF == nullptr) {
sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl;
return;
}
std::array<::MuxInfo, 6> muxInfo {
MuxInfo(gpioIds::SPI_MUX_BIT_0, SPI_MUX_0_BCM, "SPI_MUX_0"),
MuxInfo(gpioIds::SPI_MUX_BIT_1, SPI_MUX_1_BCM, "SPI_MUX_1"),
MuxInfo(gpioIds::SPI_MUX_BIT_2, SPI_MUX_2_BCM, "SPI_MUX_2"),
MuxInfo(gpioIds::SPI_MUX_BIT_3, SPI_MUX_3_BCM, "SPI_MUX_3"),
MuxInfo(gpioIds::SPI_MUX_BIT_4, SPI_MUX_4_BCM, "SPI_MUX_4"),
MuxInfo(gpioIds::SPI_MUX_BIT_5, SPI_MUX_5_BCM, "SPI_MUX_5"),
};
GpioCookie* spiMuxGpios = new GpioCookie;
for (const auto& info: muxInfo) {
result = createRpiGpioConfig(spiMuxGpios, info.gpioId, info.bcmNum, info.consumer,
Direction::OUT, Levels::LOW);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Creating Raspberry Pi SPI Mux GPIO failed with code " << result << std::endl;
return;
}
}
result = gpioComIF->addGpios(spiMuxGpios);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl;
return;
}
}
#endif

View File

@ -0,0 +1,20 @@
#pragma once
#include "OBSWConfig.h"
class GpioIF;
#ifdef RASPBERRY_PI
namespace rpi {
namespace gpio {
/**
* @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on
* the TCS Board and the interface board.
*/
void initSpiCsDecoder(GpioIF* gpioComIF);
} // namespace gpioCallbacks
} // namespace rpi
#endif

2
fsfw

@ -1 +1 @@
Subproject commit 283a37dccc064b71a0e4ca5c483c9a5a5241d355
Subproject commit 127fbeb98020e091f9b5a385fd2a2ca47ccbc02f

@ -1 +1 @@
Subproject commit a3ea5dd2e7223c52e4f494e170850609b7b3a572
Subproject commit 1c8be25e185aada13392a75234fa463240f424a0

View File

@ -3,9 +3,14 @@
#include "OBSWConfig.h"
#if defined(XIPHOS_Q7S)
#ifdef XIPHOS_Q7S
#include "busConf.h"
#endif
#ifdef RASPBERRY_PI
#include <bsp_linux_board/definitions.h>
#endif
#include <fsfw_hal/common/gpio/GpioIF.h>
#include <fsfw_hal/linux/spi/SpiCookie.h>
#include <test/testtasks/TestTask.h>

View File

@ -134,7 +134,7 @@ ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t
return result;
}
void HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const {
ReturnValue_t HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) {
ReturnValue_t result;
store_address_t storeAddress;
uint8_t commandData[2];

View File

@ -43,8 +43,8 @@ class HeaterHandler : public ExecutableObjectIF,
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override;
virtual void sendFuseOnCommand(uint8_t fuseNr) const override;
virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override;
virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
/**
* @brief This function will be called from the Heater object to check
* the current switch state.

2
tmtc

@ -1 +1 @@
Subproject commit e37430423e814b9e05f25d63970f2c2b5048cfb1
Subproject commit 5c43f638acb87e4ae07cea697cf8875c06431427