eive-obsw/mission/tcs/Tmp1075Handler.h

62 lines
2.4 KiB
C
Raw Permalink Normal View History

2023-03-26 16:42:00 +02:00
#ifndef MISSION_TCS_TMP1075HANDLER_H_
#define MISSION_TCS_TMP1075HANDLER_H_
2021-01-08 09:34:43 +01:00
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
2023-03-26 16:42:00 +02:00
#include <mission/tcs/Tmp1075Definitions.h>
2021-01-08 09:34:43 +01:00
/**
* @brief This is the device handler class for the tmp1075 temperature sensor.
*
* @details The tmp1075 communicates via I2C. After the address byte and the
* read and write bit, a pointer address must be sent to the device.
* This pointer address is stored in the pointer register of the
* tmp1075 and defines to which address following data bytes will
* be written or from which address data will be read.
*
* @author J. Meier
*/
2022-01-17 15:58:27 +01:00
class Tmp1075Handler : public DeviceHandlerBase {
public:
Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie);
virtual ~Tmp1075Handler();
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;
2023-04-04 14:45:09 +02:00
ReturnValue_t setHealth(HealthState health) override;
2022-01-17 15:58:27 +01:00
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;
2021-01-08 09:34:43 +01:00
};
2023-03-26 16:42:00 +02:00
#endif /* MISSION_TCS_TMP1075HANDLER_H_ */