clean up spi retval defs

This commit is contained in:
Robin Müller 2023-04-07 17:42:44 +02:00
parent e97fa5ac84
commit 285d327b97
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
8 changed files with 25 additions and 23 deletions

View File

@ -720,7 +720,8 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool ena
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float newCollectionInterval) { ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
float newCollectionInterval) {
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet == nullptr) { if (dataSet == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval", printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval",

View File

@ -5,8 +5,18 @@
namespace spi { namespace spi {
static constexpr uint8_t CLASS_ID = CLASS_ID::HAL_SPI;
static constexpr ReturnValue_t OPENING_FILE_FAILED = returnvalue::makeCode(CLASS_ID, 0);
/* Full duplex (ioctl) transfer failure */
static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED = returnvalue::makeCode(CLASS_ID, 1);
/* Half duplex (read/write) transfer failure */
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED = returnvalue::makeCode(CLASS_ID, 2);
static constexpr ReturnValue_t TIMEOUT = returnvalue::makeCode(CLASS_ID, 3);
static constexpr ReturnValue_t BUSY = returnvalue::makeCode(CLASS_ID, 4);
static constexpr ReturnValue_t GENERIC_ERROR = returnvalue::makeCode(CLASS_ID, 5);
enum SpiModes : uint8_t { MODE_0, MODE_1, MODE_2, MODE_3 }; enum SpiModes : uint8_t { MODE_0, MODE_1, MODE_2, MODE_3 };
} } // namespace spi
#endif /* FSFW_HAL_COMMON_SPI_SPICOMMON_H_ */ #endif /* FSFW_HAL_COMMON_SPI_SPICOMMON_H_ */

View File

@ -173,7 +173,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
int fileDescriptor = 0; int fileDescriptor = 0;
UnixFileGuard fileHelper(dev, fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); UnixFileGuard fileHelper(dev, fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if (fileHelper.getOpenResult() != returnvalue::OK) { if (fileHelper.getOpenResult() != returnvalue::OK) {
return OPENING_FILE_FAILED; return spi::OPENING_FILE_FAILED;
} }
spi::SpiModes spiMode = spi::SpiModes::MODE_0; spi::SpiModes spiMode = spi::SpiModes::MODE_0;
uint32_t spiSpeed = 0; uint32_t spiSpeed = 0;
@ -234,7 +234,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
if (retval < 0) { if (retval < 0) {
spiCookie->setTransferSize(0); spiCookie->setTransferSize(0);
utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); utility::handleIoctlError("SpiComIF::sendMessage: ioctl error.");
result = FULL_DUPLEX_TRANSFER_FAILED; result = spi::FULL_DUPLEX_TRANSFER_FAILED;
} }
#if FSFW_HAL_SPI_WIRETAPPING == 1 #if FSFW_HAL_SPI_WIRETAPPING == 1
performSpiWiretapping(spiCookie); performSpiWiretapping(spiCookie);
@ -250,7 +250,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
sif::printWarning("SpiComIF::sendMessage: Half-Duplex write operation failed!\n"); sif::printWarning("SpiComIF::sendMessage: Half-Duplex write operation failed!\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */
result = HALF_DUPLEX_TRANSFER_FAILED; result = spi::HALF_DUPLEX_TRANSFER_FAILED;
} }
} }
@ -287,7 +287,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
int fileDescriptor = 0; int fileDescriptor = 0;
UnixFileGuard fileHelper(dev, fileDescriptor, O_RDWR, "SpiComIF::requestReceiveMessage"); UnixFileGuard fileHelper(dev, fileDescriptor, O_RDWR, "SpiComIF::requestReceiveMessage");
if (fileHelper.getOpenResult() != returnvalue::OK) { if (fileHelper.getOpenResult() != returnvalue::OK) {
return OPENING_FILE_FAILED; return spi::OPENING_FILE_FAILED;
} }
uint8_t* rxBuf = nullptr; uint8_t* rxBuf = nullptr;
@ -327,7 +327,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
sif::printWarning("SpiComIF::sendMessage: Half-Duplex read operation failed!\n"); sif::printWarning("SpiComIF::sendMessage: Half-Duplex read operation failed!\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */
result = HALF_DUPLEX_TRANSFER_FAILED; result = spi::HALF_DUPLEX_TRANSFER_FAILED;
} }
if (gpioId != gpio::NO_GPIO and not csLockManual) { if (gpioId != gpio::NO_GPIO and not csLockManual) {

View File

@ -22,15 +22,6 @@ class SpiCookie;
*/ */
class SpiComIF : public DeviceCommunicationIF, public SystemObject { class SpiComIF : public DeviceCommunicationIF, public SystemObject {
public: public:
static constexpr uint8_t spiRetvalId = CLASS_ID::HAL_SPI;
static constexpr ReturnValue_t OPENING_FILE_FAILED = returnvalue::makeCode(spiRetvalId, 0);
/* Full duplex (ioctl) transfer failure */
static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED =
returnvalue::makeCode(spiRetvalId, 1);
/* Half duplex (read/write) transfer failure */
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED =
returnvalue::makeCode(spiRetvalId, 2);
SpiComIF(object_id_t objectId, std::string devname, GpioIF& gpioComIF); SpiComIF(object_id_t objectId, std::string devname, GpioIF& gpioComIF);
ReturnValue_t initializeInterface(CookieIF* cookie) override; ReturnValue_t initializeInterface(CookieIF* cookie) override;

View File

@ -357,13 +357,13 @@ ReturnValue_t SpiComIF::halErrorHandler(HAL_StatusTypeDef status, spi::TransferM
sif::printWarning("SpiComIF::handle%sSendOperation: HAL error %d occured\n", modeString, status); sif::printWarning("SpiComIF::handle%sSendOperation: HAL error %d occured\n", modeString, status);
switch (status) { switch (status) {
case (HAL_BUSY): { case (HAL_BUSY): {
return spi::HAL_BUSY_RETVAL; return spi::BUSY;
} }
case (HAL_ERROR): { case (HAL_ERROR): {
return spi::HAL_ERROR_RETVAL; return spi::GENERIC_ERROR;
} }
case (HAL_TIMEOUT): { case (HAL_TIMEOUT): {
return spi::HAL_TIMEOUT_RETVAL; return spi::TIMEOUT;
} }
default: { default: {
return returnvalue::FAILED; return returnvalue::FAILED;