Merge remote-tracking branch 'origin/develop' into irini
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
target_sources(${OBSW_NAME} PUBLIC
|
||||
InitMission.cpp
|
||||
main.cpp
|
||||
gpioInit.cpp
|
||||
ObjectFactory.cpp
|
||||
)
|
||||
|
||||
|
@ -192,7 +192,7 @@ void initmission::createPstTasks(TaskFactory& factory,
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
#if OBSW_ADD_SPI_TEST_CODE == 0
|
||||
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
|
||||
"SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc);
|
||||
"SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
|
||||
result = pst::pstSpi(spiPst);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||
|
@ -6,10 +6,13 @@
|
||||
#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"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
#include "gpioInit.h"
|
||||
#include "linux/ObjectFactory.h"
|
||||
#include "linux/boardtest/LibgpiodTest.h"
|
||||
#include "linux/boardtest/SpiTestClass.h"
|
||||
#include "linux/boardtest/UartTestClass.h"
|
||||
@ -65,37 +68,55 @@ void ObjectFactory::produce(void* args) {
|
||||
GpioCookie* gpioCookie = nullptr;
|
||||
static_cast<void>(gpioCookie);
|
||||
|
||||
new SpiComIF(objects::SPI_COM_IF, gpioIF);
|
||||
SpiComIF* spiComIF = new SpiComIF(objects::SPI_COM_IF, gpioIF);
|
||||
static_cast<void>(spiComIF);
|
||||
auto pwrSwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
|
||||
static_cast<void>(pwrSwitcher);
|
||||
|
||||
std::string spiDev;
|
||||
SpiCookie* spiCookie = nullptr;
|
||||
static_cast<void>(spiCookie);
|
||||
#if OBSW_ADD_ACS_BOARD == 1 && defined(RASPBERRY_PI)
|
||||
createRpiAcsBoard(gpioIF, spiDev);
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_ACS_BOARD == 1
|
||||
if (gpioCookie == nullptr) {
|
||||
gpioCookie = new GpioCookie();
|
||||
}
|
||||
#if OBSW_ADD_SUN_SENSORS == 1 || defined(OBSW_ADD_RTD_DEVICES)
|
||||
#ifdef RASPBERRY_PI
|
||||
rpi::gpio::initSpiCsDecoder(gpioIF);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_SUN_SENSORS == 1
|
||||
createSunSensorComponents(gpioIF, spiComIF, pwrSwitcher, spi::DEV);
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_RTD_DEVICES == 1
|
||||
createRtdComponents(spi::DEV, gpioIF, pwrSwitcher);
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
createTestTasks();
|
||||
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
||||
}
|
||||
|
||||
void ObjectFactory::createRpiAcsBoard(GpioIF* gpioIF, std::string spiDev) {
|
||||
GpioCookie* gpioCookie = new GpioCookie();
|
||||
// TODO: Missing pin for Gyro 2
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_0_LIS3_CS, gpio::MGM_0_BCM_PIN, "MGM_0_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_1_RM3100_CS, gpio::MGM_1_BCM_PIN,
|
||||
"MGM_1_RM3100", gpio::Direction::OUT, 1);
|
||||
"MGM_1_RM3100", gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_2_LIS3_CS, gpio::MGM_2_BCM_PIN, "MGM_2_LIS3",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::MGM_3_RM3100_CS, gpio::MGM_3_BCM_PIN,
|
||||
"MGM_3_RM3100", gpio::Direction::OUT, 1);
|
||||
"MGM_3_RM3100", gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN,
|
||||
"GYRO_0_ADIS", gpio::Direction::OUT, 1);
|
||||
"GYRO_0_ADIS", gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_1_L3G_CS, gpio::GYRO_1_BCM_PIN, "GYRO_1_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_2_ADIS_CS, gpio::GYRO_2_BCM_PIN,
|
||||
"GYRO_2_ADIS", gpio::Direction::OUT, 1);
|
||||
"GYRO_2_ADIS", gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_3_L3G_CS, gpio::GYRO_3_BCM_PIN, "GYRO_3_L3G",
|
||||
gpio::Direction::OUT, 1);
|
||||
gpio::Direction::OUT, gpio::Levels::HIGH);
|
||||
gpioIF->addGpios(gpioCookie);
|
||||
|
||||
spiDev = "/dev/spidev0.1";
|
||||
spiCookie =
|
||||
SpiCookie* spiCookie =
|
||||
new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev,
|
||||
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
|
||||
auto mgmLis3Handler =
|
||||
@ -137,9 +158,9 @@ void ObjectFactory::produce(void* args) {
|
||||
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev,
|
||||
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
auto adisHandler =
|
||||
new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
|
||||
ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, ADIS1650X::Type::ADIS16505);
|
||||
adisHandler->setStartUpImmediately();
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
|
||||
@ -153,9 +174,9 @@ void ObjectFactory::produce(void* args) {
|
||||
|
||||
spiCookie =
|
||||
new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev,
|
||||
ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
adisHandler =
|
||||
new GyroADIS16507Handler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
|
||||
ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
|
||||
adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF,
|
||||
spiCookie, ADIS1650X::Type::ADIS16505);
|
||||
adisHandler->setStartUpImmediately();
|
||||
|
||||
spiCookie =
|
||||
@ -167,12 +188,6 @@ void ObjectFactory::produce(void* args) {
|
||||
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
|
||||
gyroL3gHandler->setToGoToNormalMode(true);
|
||||
#endif
|
||||
|
||||
#endif /* RPI_TEST_ACS_BOARD == 1 */
|
||||
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
createTestTasks();
|
||||
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
||||
}
|
||||
|
||||
void ObjectFactory::createTestTasks() {
|
||||
|
@ -1,10 +1,15 @@
|
||||
#ifndef BSP_LINUX_OBJECTFACTORY_H_
|
||||
#define BSP_LINUX_OBJECTFACTORY_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class GpioIF;
|
||||
|
||||
namespace ObjectFactory {
|
||||
void setStatics();
|
||||
void produce(void* args);
|
||||
|
||||
void createRpiAcsBoard(GpioIF* gpioIF, std::string spiDev);
|
||||
void createTestTasks();
|
||||
}; // namespace ObjectFactory
|
||||
|
||||
|
@ -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_ */
|
||||
|
37
bsp_linux_board/definitions.h
Normal file
37
bsp_linux_board/definitions.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef BSP_LINUX_BOARD_DEFINITIONS_H_
|
||||
#define BSP_LINUX_BOARD_DEFINITIONS_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
|
||||
namespace spi {
|
||||
|
||||
static constexpr char DEV[] = "/dev/spidev0.1";
|
||||
|
||||
}
|
||||
|
||||
/* 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;
|
||||
} // namespace gpio
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* BSP_LINUX_BOARD_DEFINITIONS_H_ */
|
56
bsp_linux_board/gpioInit.cpp
Normal file
56
bsp_linux_board/gpioInit.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "gpioInit.h"
|
||||
|
||||
#include <devices/gpioIds.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
|
||||
#include "definitions.h"
|
||||
#include "fsfw_hal/linux/rpi/GpioRPi.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
|
20
bsp_linux_board/gpioInit.h
Normal file
20
bsp_linux_board/gpioInit.h
Normal 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 gpio
|
||||
} // namespace rpi
|
||||
|
||||
#endif
|
@ -3,8 +3,8 @@
|
||||
#include "InitMission.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "OBSWVersion.h"
|
||||
#include "fsfw/version.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/version.h"
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
static const char* const BOARD_NAME = "Raspberry Pi";
|
||||
@ -22,8 +22,7 @@ int main(void) {
|
||||
std::cout << "-- EIVE OBSW --" << std::endl;
|
||||
std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl;
|
||||
std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << "."
|
||||
<< SW_REVISION << ", FSFW v" << fsfw::FSFW_VERSION
|
||||
<< "--" << std::endl;
|
||||
<< SW_REVISION << ", FSFW v" << fsfw::FSFW_VERSION << " --" << std::endl;
|
||||
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||
|
||||
initmission::initMission();
|
||||
|
Reference in New Issue
Block a user