eive-obsw/mission/acs/GyrAdis1650XHandler.h

72 lines
2.7 KiB
C
Raw Normal View History

2021-05-24 00:30:46 +02:00
#ifndef MISSION_DEVICES_GYROADIS16507HANDLER_H_
#define MISSION_DEVICES_GYROADIS16507HANDLER_H_
2023-03-24 20:50:33 +01:00
#include <mission/acs/acsBoardPolling.h>
#include <mission/acs/gyroAdisHelpers.h>
2023-02-26 14:55:33 +01:00
2021-09-22 16:00:31 +02:00
#include "FSFWConfig.h"
2022-01-18 11:41:19 +01:00
#include "OBSWConfig.h"
2021-09-22 16:00:31 +02:00
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
2022-01-18 11:41:19 +01:00
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
2021-09-22 16:00:31 +02:00
2021-06-15 13:58:19 +02:00
/**
* @brief Device handle for the ADIS16507 Gyroscope by Analog Devices
* @details
* Flight manual:
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro
*/
2023-02-26 14:55:33 +01:00
class GyrAdis1650XHandler : public DeviceHandlerBase {
2022-01-18 11:41:19 +01:00
public:
2023-02-26 14:55:33 +01:00
GyrAdis1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
adis1650x::Type type);
2022-01-18 11:41:19 +01:00
2022-02-19 16:51:46 +01:00
void enablePeriodicPrintouts(bool enable, uint8_t divider);
2022-01-19 14:08:30 +01:00
void setToGoToNormalModeImmediately();
2022-01-18 11:41:19 +01:00
// DeviceHandlerBase abstract function implementation
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen) override;
void fillCommandAndReplyMap() override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
2023-02-26 14:55:33 +01:00
LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
2022-01-18 11:41:19 +01:00
private:
2023-02-26 14:55:33 +01:00
std::array<uint8_t, 32> cmdBuf;
acs::Adis1650XRequest adisRequest;
adis1650x::Type adisType;
2022-01-18 11:41:19 +01:00
AdisGyroPrimaryDataset primaryDataset;
AdisGyroConfigDataset configDataset;
2023-02-26 14:55:33 +01:00
double sensitivity = adis1650x::SENSITIVITY_UNSET;
2023-01-18 13:43:28 +01:00
2022-01-19 14:08:30 +01:00
bool warningSwitch = true;
2022-01-18 11:41:19 +01:00
2023-02-27 11:44:52 +01:00
enum class InternalState { NONE, STARTUP, SHUTDOWN };
2022-01-18 11:41:19 +01:00
InternalState internalState = InternalState::STARTUP;
bool commandExecuted = false;
2023-02-24 01:09:00 +01:00
PoolEntry<uint16_t> rangMdl = PoolEntry<uint16_t>();
2023-02-26 14:55:33 +01:00
adis1650x::BurstModes getBurstMode();
2021-05-24 20:33:59 +02:00
2022-01-18 11:41:19 +01:00
Countdown breakCountdown;
void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo);
2023-02-26 14:55:33 +01:00
ReturnValue_t preparePeriodicRequest(acs::SimpleSensorMode mode);
2021-05-25 13:53:03 +02:00
2022-01-18 11:41:19 +01:00
ReturnValue_t handleSensorData(const uint8_t *packet);
2022-02-19 16:51:46 +01:00
bool periodicPrintout = false;
PeriodicOperationDivider debugDivider = PeriodicOperationDivider(3);
2021-05-24 00:30:46 +02:00
};
#endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */