Update Linux GPIO #20

Merged
meierj merged 26 commits from mueller/update-linux-gpio into eive/develop 2021-09-27 15:28:20 +02:00
3 changed files with 29 additions and 32 deletions
Showing only changes of commit 7c21980ece - Show all commits

View File

@ -3,9 +3,9 @@
#include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/datapool/PoolReadGuard.h"
GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication, GyroHandlerL3GD20H::GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
CookieIF *comCookie): CookieIF *comCookie, uint8_t switchId, uint32_t transitionDelayMs):
DeviceHandlerBase(objectId, deviceCommunication, comCookie), DeviceHandlerBase(objectId, deviceCommunication, comCookie),
dataset(this) { switchId(switchId), transitionDelayMs(transitionDelayMs), dataset(this) {
#if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1
debugDivider = new PeriodicOperationDivider(5); debugDivider = new PeriodicOperationDivider(5);
#endif #endif
@ -47,7 +47,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
switch(internalState) { switch(internalState) {
case(InternalState::NONE): case(InternalState::NONE):
case(InternalState::NORMAL): { case(InternalState::NORMAL): {
return HasReturnvaluesIF::RETURN_OK; return NOTHING_TO_SEND;
} }
case(InternalState::CONFIGURE): { case(InternalState::CONFIGURE): {
*id = L3GD20H::CONFIGURE_CTRL_REGS; *id = L3GD20H::CONFIGURE_CTRL_REGS;
@ -66,10 +66,11 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
/* Might be a configuration error. */ /* Might be a configuration error. */
sif::debug << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" << sif::warning << "GyroL3GD20Handler::buildTransitionDeviceCommand: "
std::endl; "Unknown internal state!" << std::endl;
#else #else
sif::printDebug("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n"); sif::printDebug("GyroL3GD20Handler::buildTransitionDeviceCommand: "
"Unknown internal state!\n");
#endif #endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -144,7 +145,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildCommandFromCommand(
ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len, ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) { DeviceCommandId_t *foundId, size_t *foundLen) {
/* For SPI, the ID will always be the one of the last sent command. */ // For SPI, the ID will always be the one of the last sent command
*foundId = this->getPendingCommand(); *foundId = this->getPendingCommand();
*foundLen = this->rawPacketLen; *foundLen = this->rawPacketLen;
@ -166,7 +167,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
commandExecuted = true; commandExecuted = true;
} }
else { else {
/* Attempt reconfiguration. */ // Attempt reconfiguration
internalState = InternalState::CONFIGURE; internalState = InternalState::CONFIGURE;
return DeviceHandlerIF::DEVICE_REPLY_INVALID; return DeviceHandlerIF::DEVICE_REPLY_INVALID;
} }
@ -199,13 +200,12 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
if(debugDivider->checkAndIncrement()) { if(debugDivider->checkAndIncrement()) {
/* Set terminal to utf-8 if there is an issue with micro printout. */ /* Set terminal to utf-8 if there is an issue with micro printout. */
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "GyroHandlerL3GD20H: Angular velocities in degrees per second:" << sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl;
std::endl; sif::info << "X: " << angVelocX << std::endl;
sif::info << "X: " << angVelocX << " \xC2\xB0" << std::endl; sif::info << "Y: " << angVelocY << std::endl;
sif::info << "Y: " << angVelocY << " \xC2\xB0" << std::endl; sif::info << "Z: " << angVelocZ << std::endl;
sif::info << "Z: " << angVelocZ << " \xC2\xB0" << std::endl;
#else #else
sif::printInfo("GyroHandlerL3GD20H: Angular velocities in degrees per second:\n"); sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n");
sif::printInfo("X: %f\n", angVelocX); sif::printInfo("X: %f\n", angVelocX);
sif::printInfo("Y: %f\n", angVelocY); sif::printInfo("Y: %f\n", angVelocY);
sif::printInfo("Z: %f\n", angVelocZ); sif::printInfo("Z: %f\n", angVelocZ);
@ -231,7 +231,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
uint32_t GyroHandlerL3GD20H::getTransitionDelayMs(Mode_t from, Mode_t to) { uint32_t GyroHandlerL3GD20H::getTransitionDelayMs(Mode_t from, Mode_t to) {
return 10000; return this->transitionDelayMs;
} }
void GyroHandlerL3GD20H::setGoNormalModeAtStartup() { void GyroHandlerL3GD20H::setGoNormalModeAtStartup() {
@ -240,14 +240,10 @@ void GyroHandlerL3GD20H::setGoNormalModeAtStartup() {
ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool( ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_X, localDataPoolMap.emplace(L3GD20H::ANG_VELOC_X, new PoolEntry<float>({0.0}));
new PoolEntry<float>({0.0})); localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry<float>({0.0}));
new PoolEntry<float>({0.0})); localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z,
new PoolEntry<float>({0.0}));
localDataPoolMap.emplace(L3GD20H::TEMPERATURE,
new PoolEntry<float>({0.0}));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -7,10 +7,6 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/globalfunctions/PeriodicOperationDivider.h> #include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#ifndef FSFW_HAL_L3GD20_GYRO_DEBUG
#define FSFW_HAL_L3GD20_GYRO_DEBUG 0
#endif /* FSFW_HAL_L3GD20_GYRO_DEBUG */
/** /**
* @brief Device Handler for the L3GD20H gyroscope sensor * @brief Device Handler for the L3GD20H gyroscope sensor
* (https://www.st.com/en/mems-and-sensors/l3gd20h.html) * (https://www.st.com/en/mems-and-sensors/l3gd20h.html)
@ -23,9 +19,12 @@
class GyroHandlerL3GD20H: public DeviceHandlerBase { class GyroHandlerL3GD20H: public DeviceHandlerBase {
public: public:
GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication, GyroHandlerL3GD20H(object_id_t objectId, object_id_t deviceCommunication,
CookieIF* comCookie); CookieIF* comCookie, uint8_t switchId, uint32_t transitionDelayMs = 10000);
virtual ~GyroHandlerL3GD20H(); virtual ~GyroHandlerL3GD20H();
/**
* @brief Configure device handler to go to normal mode immediately
*/
void setGoNormalModeAtStartup(); void setGoNormalModeAtStartup();
protected: protected:
@ -51,6 +50,8 @@ protected:
LocalDataPoolManager &poolManager) override; LocalDataPoolManager &poolManager) override;
private: private:
uint8_t switchId = 0;
uint32_t transitionDelayMs = 0;
GyroPrimaryDataset dataset; GyroPrimaryDataset dataset;
enum class InternalState { enum class InternalState {

View File

@ -13,10 +13,10 @@
/** /**
* @brief FailureReport class to serialize a failure report * @brief FailureReport class to serialize a failure report
* @brief Subservice 1, 3, 5, 7 * @brief Subservice 2, 4, 6, 8
* @ingroup spacepackets * @ingroup spacepackets
*/ */
class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7 class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8
public: public:
FailureReport(uint8_t failureSubtype_, uint16_t packetId_, FailureReport(uint8_t failureSubtype_, uint16_t packetId_,
uint16_t packetSequenceControl_, uint8_t stepNumber_, uint16_t packetSequenceControl_, uint8_t stepNumber_,
@ -108,10 +108,10 @@ private:
}; };
/** /**
* @brief Subservices 2, 4, 6, 8 * @brief Subservices 1, 3, 5, 7
* @ingroup spacepackets * @ingroup spacepackets
*/ */
class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8 class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7
public: public:
SuccessReport(uint8_t subtype_, uint16_t packetId_, SuccessReport(uint8_t subtype_, uint16_t packetId_,
uint16_t packetSequenceControl_,uint8_t stepNumber_) : uint16_t packetSequenceControl_,uint8_t stepNumber_) :