Update FSFW #13
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
@ -188,7 +188,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
|
|||||||
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
||||||
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
||||||
spiCookie->assignWriteBuffer(sendData);
|
spiCookie->assignWriteBuffer(sendData);
|
||||||
spiCookie->assignTransferSize(sendLen);
|
spiCookie->setTransferSize(sendLen);
|
||||||
|
|
||||||
bool fullDuplex = spiCookie->isFullDuplex();
|
bool fullDuplex = spiCookie->isFullDuplex();
|
||||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||||
@ -330,6 +330,7 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
|||||||
|
|
||||||
*buffer = rxBuf;
|
*buffer = rxBuf;
|
||||||
*size = spiCookie->getCurrentTransferSize();
|
*size = spiCookie->getCurrentTransferSize();
|
||||||
|
spiCookie->setTransferSize(0);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ bool SpiCookie::isFullDuplex() const {
|
|||||||
return not this->halfDuplex;
|
return not this->halfDuplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiCookie::assignTransferSize(size_t transferSize) {
|
void SpiCookie::setTransferSize(size_t transferSize) {
|
||||||
spiTransferStruct.len = transferSize;
|
spiTransferStruct.len = transferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +103,10 @@ public:
|
|||||||
void assignReadBuffer(uint8_t* rx);
|
void assignReadBuffer(uint8_t* rx);
|
||||||
void assignWriteBuffer(const uint8_t* tx);
|
void assignWriteBuffer(const uint8_t* tx);
|
||||||
/**
|
/**
|
||||||
* Assign size for the next transfer.
|
* Set size for the next transfer. Set to 0 for no transfer
|
||||||
* @param transferSize
|
* @param transferSize
|
||||||
*/
|
*/
|
||||||
void assignTransferSize(size_t transferSize);
|
void setTransferSize(size_t transferSize);
|
||||||
size_t getCurrentTransferSize() const;
|
size_t getCurrentTransferSize() const;
|
||||||
|
|
||||||
struct UncommonParameters {
|
struct UncommonParameters {
|
||||||
@ -158,8 +158,6 @@ private:
|
|||||||
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
|
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
|
||||||
spi::send_callback_function_t callback, void* args);
|
spi::send_callback_function_t callback, void* args);
|
||||||
|
|
||||||
size_t currentTransferSize = 0;
|
|
||||||
|
|
||||||
address_t spiAddress;
|
address_t spiAddress;
|
||||||
gpioId_t chipSelectPin;
|
gpioId_t chipSelectPin;
|
||||||
std::string spiDevice;
|
std::string spiDevice;
|
||||||
|
Loading…
Reference in New Issue
Block a user