eive-obsw/mission/devices/GyroADIS16507Handler.h

84 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_
2021-05-25 13:53:03 +02:00
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
2021-05-24 20:33:59 +02:00
#include "OBSWConfig.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
2021-05-24 01:20:44 +02:00
#include "devicedefinitions/GyroADIS16507Definitions.h"
2021-05-24 00:30:46 +02:00
2021-05-24 20:33:59 +02:00
#if OBSW_ADIS16507_LINUX_COM_IF == 1
class SpiComIF;
class SpiCookie;
#endif
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
*/
2021-05-24 00:30:46 +02:00
class GyroADIS16507Handler: public DeviceHandlerBase {
public:
2021-05-24 20:33:59 +02:00
GyroADIS16507Handler(object_id_t objectId, object_id_t deviceCommunication,
CookieIF * comCookie);
2021-05-24 00:30:46 +02: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;
2021-05-24 01:20:44 +02:00
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
2021-05-24 20:33:59 +02:00
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
2021-05-24 00:30:46 +02:00
private:
2021-05-24 20:33:59 +02:00
std::array<uint8_t, 32> commandBuffer;
AdisGyroPrimaryDataset primaryDataset;
AdisGyroConfigDataset configDataset;
2021-05-24 01:20:44 +02:00
enum class InternalState {
STARTUP,
2021-05-26 13:30:12 +02:00
CONFIG,
2021-05-24 01:20:44 +02:00
IDLE
};
2021-05-24 20:57:12 +02:00
enum class BurstModes {
BURST_16_BURST_SEL_0,
BURST_16_BURST_SEL_1,
BURST_32_BURST_SEL_0,
BURST_32_BURST_SEL_1
};
2021-05-24 01:20:44 +02:00
InternalState internalState = InternalState::STARTUP;
bool commandExecuted = false;
2021-05-24 20:33:59 +02:00
void prepareReadCommand(uint8_t* regList, size_t len);
2021-05-24 20:57:12 +02:00
BurstModes getBurstMode();
2021-05-24 20:33:59 +02:00
#if OBSW_ADIS16507_LINUX_COM_IF == 1
static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie,
const uint8_t *sendData, size_t sendLen, void* args);
#endif
2021-05-25 13:53:03 +02:00
#if ADIS16507_DEBUG == 1
PeriodicOperationDivider* debugDivider;
#endif
2021-05-26 13:11:48 +02:00
Countdown breakCountdown;
void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo);
2021-05-25 13:53:03 +02:00
ReturnValue_t handleSensorData(const uint8_t* packet);
2021-05-24 00:30:46 +02:00
};
#endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */