v1.12.0 #269

Merged
muellerr merged 493 commits from develop into main 2022-07-04 11:19:05 +02:00
7 changed files with 117 additions and 84 deletions
Showing only changes of commit c043375ae3 - Show all commits

View File

@ -10,6 +10,22 @@
namespace rwSpiCallback { namespace rwSpiCallback {
namespace {
static bool MODE_SET = false;
ReturnValue_t openSpi(const std::string& devname, int flags, GpioIF* gpioIF, gpioId_t gpioId,
MutexIF* mutex, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs,
int& fd);
/**
* @brief This function closes a spi session. Pulls the chip select to high an releases the
* mutex.
* @param gpioId Gpio ID of chip select
* @param gpioIF Pointer to gpio interface to drive the chip select
* @param mutex The spi mutex
*/
void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex);
} // namespace
ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData,
size_t sendLen, void* args) { size_t sendLen, void* args) {
// Stopwatch watch; // Stopwatch watch;
@ -35,33 +51,26 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
} }
int fileDescriptor = 0; int fileDescriptor = 0;
std::string device = cookie->getSpiDevice(); const std::string& dev = comIf->getSpiDev();
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor);
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl;
return SpiComIF::OPENING_FILE_FAILED;
}
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
uint32_t spiSpeed = 0;
cookie->getSpiParameters(spiMode, spiSpeed, nullptr);
comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl;
return result; return result;
} }
/** Sending frame start sign */ spi::SpiModes spiMode = spi::SpiModes::MODE_0;
writeBuffer[0] = 0x7E; uint32_t spiSpeed = 0;
writeSize = 1; cookie->getSpiParameters(spiMode, spiSpeed, nullptr);
// We are in protected section, so we can use the static variable here without issues.
// We don't need to set the speed because a SPI core is used, but the mode has to be set once
// correctly for all RWs
if (not MODE_SET) {
comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
MODE_SET = true;
}
// Pull SPI CS low. For now, no support for active high given /** Sending frame start sign */
if (gpioId != gpio::NO_GPIO) { writeBuffer[0] = FLAG_BYTE;
if (gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { writeSize = 1;
sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl;
}
}
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;
@ -97,7 +106,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
} }
/** Sending frame end sign */ /** Sending frame end sign */
writeBuffer[0] = 0x7E; writeBuffer[0] = FLAG_BYTE;
writeSize = 1; writeSize = 1;
if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) { if (write(fileDescriptor, writeBuffer, writeSize) != static_cast<ssize_t>(writeSize)) {
@ -115,8 +124,14 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
size_t replyBufferSize = cookie->getMaxBufferSize(); size_t replyBufferSize = cookie->getMaxBufferSize();
/** 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.
closeSpi(gpioId, gpioIF, mutex);
usleep(RwDefinitions::SPI_REPLY_DELAY); usleep(RwDefinitions::SPI_REPLY_DELAY);
result = openSpi(dev, O_RDWR, gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
/** /**
* The reaction wheel responds with empty frames while preparing the reply data. * The reaction wheel responds with empty frames while preparing the reply data.
@ -204,8 +219,9 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
result = RwHandler::SPI_READ_FAILURE; result = RwHandler::SPI_READ_FAILURE;
break; break;
} }
if (byteRead != 0x7E) { if (byteRead != FLAG_BYTE) {
sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; sif::error << "rwSpiCallback::spiCallback: Missing end sign " << static_cast<int>(FLAG_BYTE)
<< std::endl;
decodedFrameLen--; decodedFrameLen--;
result = RwHandler::MISSING_END_SIGN; result = RwHandler::MISSING_END_SIGN;
break; break;
@ -221,6 +237,33 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen
return result; return result;
} }
namespace {
ReturnValue_t openSpi(const std::string& devname, int flags, GpioIF* gpioIF, gpioId_t gpioId,
MutexIF* mutex, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs,
int& fd) {
ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl;
return result;
}
fd = open(devname.c_str(), flags);
if (fd < 0) {
sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl;
return SpiComIF::OPENING_FILE_FAILED;
}
// Pull SPI CS low. For now, no support for active high given
if (gpioId != gpio::NO_GPIO) {
result = gpioIF->pullLow(gpioId);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl;
return result;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) {
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) {
@ -232,4 +275,7 @@ void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) {
; ;
} }
} }
} // namespace
} // namespace rwSpiCallback } // namespace rwSpiCallback

View File

@ -33,14 +33,5 @@ static constexpr uint8_t FLAG_BYTE = 0x7E;
ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData,
size_t sendLen, void* args); size_t sendLen, void* args);
/**
* @brief This function closes a spi session. Pulls the chip select to high an releases the
* mutex.
* @param gpioId Gpio ID of chip select
* @param gpioIF Pointer to gpio interface to drive the chip select
* @param mutex The spi mutex
*/
void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex);
} // namespace rwSpiCallback } // namespace rwSpiCallback
#endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ #endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */

View File

@ -150,8 +150,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, *gpioComIF); *spiMainComIF = new SpiComIF(objects::SPI_MAIN_COM_IF, q7s::SPI_DEFAULT_DEV, *gpioComIF);
*spiRWComIF = new SpiComIF(objects::SPI_RW_COM_IF, *gpioComIF); *spiRWComIF = new SpiComIF(objects::SPI_RW_COM_IF, q7s::SPI_RW_DEV, *gpioComIF);
/* Adding gpios for chip select decoding to the gpioComIf */ /* Adding gpios for chip select decoding to the gpioComIf */
q7s::gpioCallbacks::initSpiCsDecoder(*gpioComIF); q7s::gpioCallbacks::initSpiCsDecoder(*gpioComIF);
} }
@ -211,9 +211,9 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
gpioCookieRadSensor->addGpio(gpioIds::ENABLE_RADFET, gpio); gpioCookieRadSensor->addGpio(gpioIds::ENABLE_RADFET, gpio);
gpioChecker(gpioComIF->addGpios(gpioCookieRadSensor), "RAD sensor"); gpioChecker(gpioComIF->addGpios(gpioCookieRadSensor), "RAD sensor");
SpiCookie* spiCookieRadSensor = new SpiCookie( SpiCookie* spiCookieRadSensor =
addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, std::string(q7s::SPI_DEFAULT_DEV), new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, RAD_SENSOR::READ_SIZE,
RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
auto radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_MAIN_COM_IF, auto radSensor = new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_MAIN_COM_IF,
spiCookieRadSensor, gpioComIF); spiCookieRadSensor, gpioComIF);
static_cast<void>(radSensor); static_cast<void>(radSensor);
@ -332,8 +332,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
#if OBSW_ADD_ACS_HANDLERS == 1 #if OBSW_ADD_ACS_HANDLERS == 1
std::string spiDev = q7s::SPI_DEFAULT_DEV; std::string spiDev = q7s::SPI_DEFAULT_DEV;
SpiCookie* spiCookie = SpiCookie* spiCookie =
new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, MGMLIS3MDL::MAX_BUFFER_SIZE,
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, auto mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_0_LIS3_HANDLER, objects::SPI_MAIN_COM_IF,
spiCookie, spi::LIS3_TRANSITION_DELAY); spiCookie, spi::LIS3_TRANSITION_DELAY);
fdir = new AcsBoardFdir(objects::MGM_0_LIS3_HANDLER); fdir = new AcsBoardFdir(objects::MGM_0_LIS3_HANDLER);
@ -347,8 +347,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
mgmLis3Handler->enablePeriodicPrintouts(true, 10); mgmLis3Handler->enablePeriodicPrintouts(true, 10);
#endif #endif
spiCookie = spiCookie =
new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, RM3100::MAX_BUFFER_SIZE,
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
auto mgmRm3100Handler = auto mgmRm3100Handler =
new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie,
spi::RM3100_TRANSITION_DELAY); spi::RM3100_TRANSITION_DELAY);
@ -364,8 +364,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
mgmRm3100Handler->enablePeriodicPrintouts(true, 10); mgmRm3100Handler->enablePeriodicPrintouts(true, 10);
#endif #endif
spiCookie = spiCookie =
new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, MGMLIS3MDL::MAX_BUFFER_SIZE,
MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED);
mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, mgmLis3Handler = new MgmLIS3MDLHandler(objects::MGM_2_LIS3_HANDLER, objects::SPI_MAIN_COM_IF,
spiCookie, spi::LIS3_TRANSITION_DELAY); spiCookie, spi::LIS3_TRANSITION_DELAY);
fdir = new AcsBoardFdir(objects::MGM_2_LIS3_HANDLER); fdir = new AcsBoardFdir(objects::MGM_2_LIS3_HANDLER);
@ -380,8 +380,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
mgmLis3Handler->enablePeriodicPrintouts(true, 10); mgmLis3Handler->enablePeriodicPrintouts(true, 10);
#endif #endif
spiCookie = spiCookie =
new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, RM3100::MAX_BUFFER_SIZE,
RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED);
mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_MAIN_COM_IF, mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_MAIN_COM_IF,
spiCookie, spi::RM3100_TRANSITION_DELAY); spiCookie, spi::RM3100_TRANSITION_DELAY);
fdir = new AcsBoardFdir(objects::MGM_3_RM3100_HANDLER); fdir = new AcsBoardFdir(objects::MGM_3_RM3100_HANDLER);
@ -396,9 +396,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
#endif #endif
// Commented until ACS board V2 in in clean room again // Commented until ACS board V2 in in clean room again
// Gyro 0 Side A // Gyro 0 Side A
spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, spiCookie =
ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, ADIS1650X::MAXIMUM_REPLY_SIZE,
spi::DEFAULT_ADIS16507_SPEED); spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED);
auto adisHandler = auto adisHandler =
new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie,
ADIS1650X::Type::ADIS16505); ADIS1650X::Type::ADIS16505);
@ -414,8 +414,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
adisHandler->enablePeriodicPrintouts(true, 10); adisHandler->enablePeriodicPrintouts(true, 10);
#endif #endif
// Gyro 1 Side A // Gyro 1 Side A
spiCookie = spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, L3GD20H::MAX_BUFFER_SIZE,
new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
auto gyroL3gHandler = new GyroHandlerL3GD20H( auto gyroL3gHandler = new GyroHandlerL3GD20H(
objects::GYRO_1_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); objects::GYRO_1_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY);
@ -431,9 +430,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
gyroL3gHandler->enablePeriodicPrintouts(true, 10); gyroL3gHandler->enablePeriodicPrintouts(true, 10);
#endif #endif
// Gyro 2 Side B // Gyro 2 Side B
spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, spiCookie =
ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, ADIS1650X::MAXIMUM_REPLY_SIZE,
spi::DEFAULT_ADIS16507_SPEED); spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED);
adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_MAIN_COM_IF, adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_MAIN_COM_IF,
spiCookie, ADIS1650X::Type::ADIS16505); spiCookie, ADIS1650X::Type::ADIS16505);
fdir = new AcsBoardFdir(objects::GYRO_2_ADIS_HANDLER); fdir = new AcsBoardFdir(objects::GYRO_2_ADIS_HANDLER);
@ -444,8 +443,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI
adisHandler->setToGoToNormalModeImmediately(); adisHandler->setToGoToNormalModeImmediately();
#endif #endif
// Gyro 3 Side B // Gyro 3 Side B
spiCookie = spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, L3GD20H::MAX_BUFFER_SIZE,
new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE,
spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED);
gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_MAIN_COM_IF, gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_MAIN_COM_IF,
spiCookie, spi::L3G_TRANSITION_DELAY); spiCookie, spi::L3G_TRANSITION_DELAY);
@ -661,8 +659,8 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF,
std::array<RwHandler*, 4> rws = {}; std::array<RwHandler*, 4> rws = {};
for (uint8_t idx = 0; idx < rwCookies.size(); idx++) { for (uint8_t idx = 0; idx < rwCookies.size(); idx++) {
rwCookies[idx] = new SpiCookie(rwCookieParams[idx].first, rwCookieParams[idx].second, rwCookies[idx] = new SpiCookie(rwCookieParams[idx].first, rwCookieParams[idx].second,
q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED,
spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); &rwSpiCallback::spiCallback, nullptr);
rws[idx] = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, rws[idx] = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF,
rwGpioIds[idx]); rwGpioIds[idx]);
rwCookies[idx]->setCallbackArgs(rws[idx]); rwCookies[idx]->setCallbackArgs(rws[idx]);
@ -837,8 +835,8 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
gpio::Levels::HIGH); gpio::Levels::HIGH);
plPcduGpios->addGpio(gpioIds::PLPCDU_ADC_CS, gpio); plPcduGpios->addGpio(gpioIds::PLPCDU_ADC_CS, gpio);
gpioChecker(gpioComIF->addGpios(plPcduGpios), "PL PCDU"); gpioChecker(gpioComIF->addGpios(plPcduGpios), "PL PCDU");
SpiCookie* spiCookie = new SpiCookie(addresses::PLPCDU_ADC, gpioIds::PLPCDU_ADC_CS, SpiCookie* spiCookie =
q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE, new SpiCookie(addresses::PLPCDU_ADC, gpioIds::PLPCDU_ADC_CS, plpcdu::MAX_ADC_REPLY_SIZE,
spi::DEFAULT_MAX_1227_MODE, spi::PL_PCDU_MAX_1227_SPEED); spi::DEFAULT_MAX_1227_MODE, spi::PL_PCDU_MAX_1227_SPEED);
// Create device handler components // Create device handler components
auto plPcduHandler = new PayloadPcduHandler( auto plPcduHandler = new PayloadPcduHandler(

2
fsfw

@ -1 +1 @@
Subproject commit d72b212fa629029924d9862e3e862d0388911f8e Subproject commit e06c457743991b2a0c2d84de9e169508ac428aa8

View File

@ -67,8 +67,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
#if OBSW_ADD_SUN_SENSORS == 1 #if OBSW_ADD_SUN_SENSORS == 1
SusFdir* fdir = nullptr; SusFdir* fdir = nullptr;
std::array<SusHandler*, 12> susHandlers = {}; std::array<SusHandler*, 12> susHandlers = {};
SpiCookie* spiCookie = SpiCookie* spiCookie = new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, SUS::MAX_CMD_SIZE,
new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, spiDev, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[0] = susHandlers[0] =
new SusHandler(objects::SUS_0_N_LOC_XFYFZM_PT_XF, 0, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_0_N_LOC_XFYFZM_PT_XF, 0, objects::SPI_MAIN_COM_IF, spiCookie);
@ -76,7 +75,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[0]->setParent(objects::SUS_BOARD_ASS); susHandlers[0]->setParent(objects::SUS_BOARD_ASS);
susHandlers[0]->setCustomFdir(fdir); susHandlers[0]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[1] = susHandlers[1] =
new SusHandler(objects::SUS_1_N_LOC_XBYFZM_PT_XB, 1, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_1_N_LOC_XBYFZM_PT_XB, 1, objects::SPI_MAIN_COM_IF, spiCookie);
@ -84,7 +83,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[1]->setParent(objects::SUS_BOARD_ASS); susHandlers[1]->setParent(objects::SUS_BOARD_ASS);
susHandlers[1]->setCustomFdir(fdir); susHandlers[1]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[2] = susHandlers[2] =
new SusHandler(objects::SUS_2_N_LOC_XFYBZB_PT_YB, 2, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_2_N_LOC_XFYBZB_PT_YB, 2, objects::SPI_MAIN_COM_IF, spiCookie);
@ -92,7 +91,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[2]->setParent(objects::SUS_BOARD_ASS); susHandlers[2]->setParent(objects::SUS_BOARD_ASS);
susHandlers[2]->setCustomFdir(fdir); susHandlers[2]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[3] = susHandlers[3] =
new SusHandler(objects::SUS_3_N_LOC_XFYBZF_PT_YF, 3, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_3_N_LOC_XFYBZF_PT_YF, 3, objects::SPI_MAIN_COM_IF, spiCookie);
@ -100,7 +99,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[3]->setParent(objects::SUS_BOARD_ASS); susHandlers[3]->setParent(objects::SUS_BOARD_ASS);
susHandlers[3]->setCustomFdir(fdir); susHandlers[3]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[4] = susHandlers[4] =
new SusHandler(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, 4, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, 4, objects::SPI_MAIN_COM_IF, spiCookie);
@ -108,7 +107,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[4]->setParent(objects::SUS_BOARD_ASS); susHandlers[4]->setParent(objects::SUS_BOARD_ASS);
susHandlers[4]->setCustomFdir(fdir); susHandlers[4]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[5] = susHandlers[5] =
new SusHandler(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, 5, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, 5, objects::SPI_MAIN_COM_IF, spiCookie);
@ -116,7 +115,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[5]->setParent(objects::SUS_BOARD_ASS); susHandlers[5]->setParent(objects::SUS_BOARD_ASS);
susHandlers[5]->setCustomFdir(fdir); susHandlers[5]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[6] = susHandlers[6] =
new SusHandler(objects::SUS_6_R_LOC_XFYBZM_PT_XF, 6, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_6_R_LOC_XFYBZM_PT_XF, 6, objects::SPI_MAIN_COM_IF, spiCookie);
@ -124,7 +123,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[6]->setParent(objects::SUS_BOARD_ASS); susHandlers[6]->setParent(objects::SUS_BOARD_ASS);
susHandlers[6]->setCustomFdir(fdir); susHandlers[6]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[7] = susHandlers[7] =
new SusHandler(objects::SUS_7_R_LOC_XBYBZM_PT_XB, 7, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_7_R_LOC_XBYBZM_PT_XB, 7, objects::SPI_MAIN_COM_IF, spiCookie);
@ -132,7 +131,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[7]->setParent(objects::SUS_BOARD_ASS); susHandlers[7]->setParent(objects::SUS_BOARD_ASS);
susHandlers[7]->setCustomFdir(fdir); susHandlers[7]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[8] = susHandlers[8] =
new SusHandler(objects::SUS_8_R_LOC_XBYBZB_PT_YB, 8, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_8_R_LOC_XBYBZB_PT_YB, 8, objects::SPI_MAIN_COM_IF, spiCookie);
@ -140,7 +139,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[8]->setParent(objects::SUS_BOARD_ASS); susHandlers[8]->setParent(objects::SUS_BOARD_ASS);
susHandlers[8]->setCustomFdir(fdir); susHandlers[8]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[9] = susHandlers[9] =
new SusHandler(objects::SUS_9_R_LOC_XBYBZB_PT_YF, 9, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_9_R_LOC_XBYBZB_PT_YF, 9, objects::SPI_MAIN_COM_IF, spiCookie);
@ -148,7 +147,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[9]->setParent(objects::SUS_BOARD_ASS); susHandlers[9]->setParent(objects::SUS_BOARD_ASS);
susHandlers[9]->setCustomFdir(fdir); susHandlers[9]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[10] = susHandlers[10] =
new SusHandler(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, 10, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, 10, objects::SPI_MAIN_COM_IF, spiCookie);
@ -156,7 +155,7 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo
susHandlers[10]->setParent(objects::SUS_BOARD_ASS); susHandlers[10]->setParent(objects::SUS_BOARD_ASS);
susHandlers[10]->setCustomFdir(fdir); susHandlers[10]->setCustomFdir(fdir);
spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, spiDev, SUS::MAX_CMD_SIZE, spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, SUS::MAX_CMD_SIZE,
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[11] = susHandlers[11] =
new SusHandler(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, 11, objects::SPI_MAIN_COM_IF, spiCookie); new SusHandler(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, 11, objects::SPI_MAIN_COM_IF, spiCookie);
@ -286,7 +285,7 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
RtdFdir* rtdFdir = nullptr; RtdFdir* rtdFdir = nullptr;
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) { for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
rtdCookies[idx] = rtdCookies[idx] =
new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second, spiDev, new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second,
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
rtds[idx] = new Max31865PT1000Handler(rtdIds[idx], objects::SPI_MAIN_COM_IF, rtdCookies[idx]); rtds[idx] = new Max31865PT1000Handler(rtdIds[idx], objects::SPI_MAIN_COM_IF, rtdCookies[idx]);
rtds[idx]->setParent(objects::TCS_BOARD_ASS); rtds[idx]->setParent(objects::TCS_BOARD_ASS);

View File

@ -408,7 +408,7 @@ ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *
int retval = 0; int retval = 0;
// Prepare transfer // Prepare transfer
int fileDescriptor = 0; int fileDescriptor = 0;
std::string device = cookie->getSpiDevice(); std::string device = comIf->getSpiDev();
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return SpiComIF::OPENING_FILE_FAILED; return SpiComIF::OPENING_FILE_FAILED;

View File

@ -697,8 +697,7 @@ ReturnValue_t PayloadPcduHandler::transferAsTwo(SpiComIF* comIf, SpiCookie* cook
int retval = 0; int retval = 0;
// Prepare transfer // Prepare transfer
int fileDescriptor = 0; int fileDescriptor = 0;
std::string device = cookie->getSpiDevice(); UnixFileGuard fileHelper(comIf->getSpiDev(), &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return SpiComIF::OPENING_FILE_FAILED; return SpiComIF::OPENING_FILE_FAILED;
} }