eive-obsw/mission/devices/Max1227Handler.h

65 lines
2.0 KiB
C
Raw Normal View History

2021-04-29 10:40:11 +02:00
#ifndef MISSION_DEVICES_MAX1227HANDLER_H_
#define MISSION_DEVICES_MAX1227HANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/Tmp1075Definitions.h>
/**
* @brief This is the device handler class for the MAX1227 ADC converter.
*
* @details Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
*
* @author J. Meier
*/
class Max1227Handler: public DeviceHandlerBase {
public:
Max1227Handler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie);
virtual ~Max1227Handler();
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) 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;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
private:
/**
* @brief Function fills cmdBuffer with command to start the adc
* conversion for a new temperature value.
*/
void prepareAdcConversionCommand();
void prepareGetTempCommand();
enum class CommunicationStep {
START_ADC_CONVERSION,
GET_TEMPERATURE
};
TMP1075::Tmp1075Dataset dataset;
static const uint8_t MAX_CMD_LEN = 3;
uint8_t rememberRequestedSize = 0;
uint8_t rememberCommandId = TMP1075::NONE;
uint8_t cmdBuffer[MAX_CMD_LEN];
CommunicationStep communicationStep =
CommunicationStep::START_ADC_CONVERSION;
};
#endif /* MISSION_DEVICES_MAX1227HANDLER_H_ */