v1.15.0 #311

Merged
muellerr merged 107 commits from develop into main 2022-10-27 11:28:49 +02:00
8 changed files with 46 additions and 36 deletions
Showing only changes of commit 5173a0c9cb - Show all commits

View File

@ -41,19 +41,19 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
uint8_t writeSize = 0; uint8_t writeSize = 0;
gpioId_t gpioId = cookie->getChipSelectPin(); gpioId_t gpioId = cookie->getChipSelectPin();
GpioIF* gpioIF = comIf->getGpioInterface(); GpioIF& gpioIF = comIf->getGpioInterface();
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 0; uint32_t timeoutMs = 0;
MutexIF* mutex = comIf->getCsMutex(); MutexIF* mutex = comIf->getCsMutex();
cookie->getMutexParams(timeoutType, timeoutMs); cookie->getMutexParams(timeoutType, timeoutMs);
if (mutex == nullptr or gpioIF == nullptr) { if (mutex == nullptr) {
sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl;
return returnvalue::FAILED; return returnvalue::FAILED;
} }
int fileDescriptor = 0; int fileDescriptor = 0;
const std::string& dev = comIf->getSpiDev(); const std::string& dev = comIf->getSpiDev();
result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor); result = openSpi(dev, O_RDWR, &gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -75,7 +75,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return RwHandler::SPI_WRITE_FAILURE; return RwHandler::SPI_WRITE_FAILURE;
} }
@ -100,7 +100,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
} }
if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return RwHandler::SPI_WRITE_FAILURE; return RwHandler::SPI_WRITE_FAILURE;
} }
idx++; idx++;
@ -112,14 +112,14 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return RwHandler::SPI_WRITE_FAILURE; return RwHandler::SPI_WRITE_FAILURE;
} }
uint8_t* rxBuf = nullptr; uint8_t* rxBuf = nullptr;
result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return result; return result;
} }
@ -127,9 +127,9 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
// There must be a delay of at least 20 ms after sending the command. // There must be a delay of at least 20 ms after sending the command.
// Delay for 70 ms here and release the SPI bus for that duration. // Delay for 70 ms here and release the SPI bus for that duration.
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
usleep(RwDefinitions::SPI_REPLY_DELAY); usleep(RwDefinitions::SPI_REPLY_DELAY);
result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor); result = openSpi(dev, O_RDWR, &gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -142,13 +142,13 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
for (int idx = 0; idx < 10; idx++) { for (int idx = 0; idx < 10; idx++) {
if (read(fileDescriptor, &byteRead, 1) != 1) { if (read(fileDescriptor, &byteRead, 1) != 1) {
sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return RwHandler::SPI_READ_FAILURE; return RwHandler::SPI_READ_FAILURE;
} }
if (idx == 0) { if (idx == 0) {
if (byteRead != FLAG_BYTE) { if (byteRead != FLAG_BYTE) {
sif::error << "Invalid data, expected start marker" << std::endl; sif::error << "Invalid data, expected start marker" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return RwHandler::NO_START_MARKER; return RwHandler::NO_START_MARKER;
} }
} }
@ -159,7 +159,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
if (idx == 9) { if (idx == 9) {
sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return RwHandler::NO_REPLY; return RwHandler::NO_REPLY;
} }
} }
@ -199,7 +199,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
continue; continue;
} else { } else {
sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl;
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
result = RwHandler::INVALID_SUBSTITUTE; result = RwHandler::INVALID_SUBSTITUTE;
break; break;
} }
@ -233,7 +233,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
cookie->setTransferSize(decodedFrameLen); cookie->setTransferSize(decodedFrameLen);
closeSpi(fileDescriptor, gpioId, gpioIF, mutex); closeSpi(fileDescriptor, gpioId, &gpioIF, mutex);
return result; return result;
} }

View File

@ -145,10 +145,8 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, Ua
new CspComIF(objects::CSP_COM_IF); new CspComIF(objects::CSP_COM_IF);
*i2cComIF = new I2cComIF(objects::I2C_COM_IF); *i2cComIF = new I2cComIF(objects::I2C_COM_IF);
*uartComIF = new UartComIF(objects::UART_COM_IF); *uartComIF = new UartComIF(objects::UART_COM_IF);
*spiMainComIF = new SpiComIF(objects::SPI_MAIN_COM_IF, q7s::SPI_DEFAULT_DEV, *gpioComIF); *spiMainComIF = new SpiComIF(objects::SPI_MAIN_COM_IF, q7s::SPI_DEFAULT_DEV, **gpioComIF);
*spiRWComIF = new SpiComIF(objects::SPI_RW_COM_IF, q7s::SPI_RW_DEV, *gpioComIF); *spiRWComIF = new SpiComIF(objects::SPI_RW_COM_IF, q7s::SPI_RW_DEV, **gpioComIF);
/* Adding gpios for chip select decoding to the gpioComIf */
q7s::gpioCallbacks::initSpiCsDecoder(*gpioComIF);
} }
void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher) { void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher) {
@ -193,8 +191,11 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI
#endif #endif
} }
void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { ReturnValue_t ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
using namespace gpio; using namespace gpio;
if(gpioComIF == nullptr) {
return returnvalue::FAILED;
}
GpioCookie* gpioCookieRadSensor = new GpioCookie; GpioCookie* gpioCookieRadSensor = new GpioCookie;
std::stringstream consumer; std::stringstream consumer;
consumer << "0x" << std::hex << objects::RAD_SENSOR; consumer << "0x" << std::hex << objects::RAD_SENSOR;
@ -220,6 +221,7 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
#if OBSW_DEBUG_RAD_SENSOR == 1 #if OBSW_DEBUG_RAD_SENSOR == 1
radSensor->enablePeriodicDataPrint(true); radSensor->enablePeriodicDataPrint(true);
#endif #endif
return returnvalue::OK;
} }
void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF, void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF,

View File

@ -26,7 +26,7 @@ void createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher
void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF,
PowerSwitchIF* pwrSwitcher); PowerSwitchIF* pwrSwitcher);
void createTmpComponents(); void createTmpComponents();
void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF);
void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF, void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF,
PowerSwitchIF* pwrSwitcher); PowerSwitchIF* pwrSwitcher);
void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable); void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable);

View File

@ -1,3 +1,4 @@
#include <bsp_q7s/callbacks/q7sGpioCallbacks.h>
#include <fsfw/health/HealthTableIF.h> #include <fsfw/health/HealthTableIF.h>
#include <fsfw/power/DummyPowerSwitcher.h> #include <fsfw/power/DummyPowerSwitcher.h>
@ -24,6 +25,9 @@ void ObjectFactory::produce(void* args) {
I2cComIF* i2cComIF = nullptr; I2cComIF* i2cComIF = nullptr;
SpiComIF* spiRwComIF = nullptr; SpiComIF* spiRwComIF = nullptr;
createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF, &spiRwComIF); createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF, &spiRwComIF);
/* Adding gpios for chip select decoding to the gpioComIf */
q7s::gpioCallbacks::initSpiCsDecoder(gpioComIF);
gpioCallbacks::disableAllDecoder(gpioComIF);
// Hardware is usually not connected to EM, so we need to create dummies which replace lower // Hardware is usually not connected to EM, so we need to create dummies which replace lower
// level components. // level components.
@ -33,7 +37,6 @@ void ObjectFactory::produce(void* args) {
new CoreController(objects::CORE_CONTROLLER); new CoreController(objects::CORE_CONTROLLER);
gpioCallbacks::disableAllDecoder(gpioComIF);
PowerSwitchIF* pwrSwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); PowerSwitchIF* pwrSwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0);
static_cast<void>(pwrSwitcher); static_cast<void>(pwrSwitcher);
@ -47,7 +50,10 @@ void ObjectFactory::produce(void* args) {
// createSolarArrayDeploymentComponents(); // createSolarArrayDeploymentComponents();
// createPayloadComponents(gpioComIF); // createPayloadComponents(gpioComIF);
// createHeaterComponents(gpioComIF, pwrSwitcher, healthTable); // createHeaterComponents(gpioComIF, pwrSwitcher, healthTable);
createRadSensorComponent(gpioComIF);
// TODO: Careful! Swichting this on somehow messes with the communication with the ProASIC
// and will cause xsc_boot_copy commands to always boot to 0 0
// createRadSensorComponent(gpioComIF);
#if OBSW_ADD_ACS_BOARD == 1 #if OBSW_ADD_ACS_BOARD == 1
createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher); createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher);

View File

@ -1,3 +1,4 @@
#include <bsp_q7s/callbacks/q7sGpioCallbacks.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h> #include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include "OBSWConfig.h" #include "OBSWConfig.h"
@ -23,10 +24,11 @@ void ObjectFactory::produce(void* args) {
PowerSwitchIF* pwrSwitcher = nullptr; PowerSwitchIF* pwrSwitcher = nullptr;
SpiComIF* spiRwComIF = nullptr; SpiComIF* spiRwComIF = nullptr;
createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF, &spiRwComIF); createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF, &spiRwComIF);
createTmpComponents(); /* Adding gpios for chip select decoding to the gpioComIf */
new CoreController(objects::CORE_CONTROLLER); q7s::gpioCallbacks::initSpiCsDecoder(gpioComIF);
gpioCallbacks::disableAllDecoder(gpioComIF); gpioCallbacks::disableAllDecoder(gpioComIF);
new CoreController(objects::CORE_CONTROLLER);
createPcduComponents(gpioComIF, &pwrSwitcher); createPcduComponents(gpioComIF, &pwrSwitcher);
createRadSensorComponent(gpioComIF); createRadSensorComponent(gpioComIF);
createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV); createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV);

2
fsfw

@ -1 +1 @@
Subproject commit 1f05e6b297af8a6d310394e959c4d0cf13632831 Subproject commit 60ff411721909bd6e4c34523a2248d8dca2507b1

View File

@ -422,12 +422,12 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *
cookie->setTransferSize(2); cookie->setTransferSize(2);
gpioId_t gpioId = cookie->getChipSelectPin(); gpioId_t gpioId = cookie->getChipSelectPin();
GpioIF *gpioIF = comIf->getGpioInterface(); GpioIF& gpioIF = comIf->getGpioInterface();
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 0; uint32_t timeoutMs = 0;
MutexIF *mutex = comIf->getCsMutex(); MutexIF *mutex = comIf->getCsMutex();
cookie->getMutexParams(timeoutType, timeoutMs); cookie->getMutexParams(timeoutType, timeoutMs);
if (mutex == nullptr or gpioIF == nullptr) { if (mutex == nullptr) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "GyroADIS16507Handler::spiSendCallback: " sif::warning << "GyroADIS16507Handler::spiSendCallback: "
"Mutex or GPIO interface invalid" "Mutex or GPIO interface invalid"
@ -453,7 +453,7 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *
while (idx < sendLen) { while (idx < sendLen) {
// Pull SPI CS low. For now, no support for active high given // Pull SPI CS low. For now, no support for active high given
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioIF->pullLow(gpioId); gpioIF.pullLow(gpioId);
} }
// Execute transfer // Execute transfer
@ -468,7 +468,7 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *
#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioIF->pullHigh(gpioId); gpioIF.pullHigh(gpioId);
} }
idx += 2; idx += 2;

View File

@ -719,11 +719,11 @@ ReturnValue_t PayloadPcduHandler::transferAsTwo(SpiComIF* comIf, SpiCookie* cook
cookie->setTransferSize(transferLen); cookie->setTransferSize(transferLen);
gpioId_t gpioId = cookie->getChipSelectPin(); gpioId_t gpioId = cookie->getChipSelectPin();
GpioIF* gpioIF = comIf->getGpioInterface(); GpioIF& gpioIF = comIf->getGpioInterface();
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 0; uint32_t timeoutMs = 0;
MutexIF* mutex = comIf->getCsMutex(); MutexIF* mutex = comIf->getCsMutex();
if (mutex == nullptr or gpioIF == nullptr) { if (mutex == nullptr) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "GyroADIS16507Handler::spiSendCallback: " sif::warning << "GyroADIS16507Handler::spiSendCallback: "
"Mutex or GPIO interface invalid" "Mutex or GPIO interface invalid"
@ -753,7 +753,7 @@ ReturnValue_t PayloadPcduHandler::transferAsTwo(SpiComIF* comIf, SpiCookie* cook
transferStruct->len = transferLen; transferStruct->len = transferLen;
// Pull SPI CS low. For now, no support for active high given // Pull SPI CS low. For now, no support for active high given
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioIF->pullLow(gpioId); gpioIF.pullLow(gpioId);
} }
// Execute transfer // Execute transfer
@ -768,14 +768,14 @@ ReturnValue_t PayloadPcduHandler::transferAsTwo(SpiComIF* comIf, SpiCookie* cook
#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioIF->pullHigh(gpioId); gpioIF.pullHigh(gpioId);
} }
transferStruct->tx_buf += transferLen; transferStruct->tx_buf += transferLen;
transferStruct->rx_buf += transferLen; transferStruct->rx_buf += transferLen;
transferStruct->len = plpcdu::TEMP_REPLY_SIZE - 1; transferStruct->len = plpcdu::TEMP_REPLY_SIZE - 1;
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioIF->pullLow(gpioId); gpioIF.pullLow(gpioId);
} }
// Execute transfer // Execute transfer
@ -790,7 +790,7 @@ ReturnValue_t PayloadPcduHandler::transferAsTwo(SpiComIF* comIf, SpiCookie* cook
#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioIF->pullHigh(gpioId); gpioIF.pullHigh(gpioId);
} }
transferStruct->tx_buf = origTx; transferStruct->tx_buf = origTx;