eive-obsw/mission/devices/SusHandler.h

67 lines
2.2 KiB
C
Raw Normal View History

2021-05-03 11:59:33 +02:00
#ifndef MISSION_DEVICES_SUSHANDLER_H_
#define MISSION_DEVICES_SUSHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/SusDefinitions.h>
2021-05-07 18:48:42 +02:00
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
2021-05-03 11:59:33 +02:00
/**
* @brief This is the device handler class for the SUS sensor. The sensor is
* based on the MAX1227 ADC. Details about the SUS electronic can be found at
* https://egit.irs.uni-stuttgart.de/eive/eive_dokumente/src/branch/master/400_Raumsegment/443_SunSensorDocumentation/release
*
* @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf
*
* @author J. Meier
*/
class SusHandler: public DeviceHandlerBase {
public:
SusHandler(object_id_t objectId, object_id_t comIF,
2021-05-07 18:48:42 +02:00
CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId);
2021-05-03 11:59:33 +02:00
virtual ~SusHandler();
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:
enum class CommunicationStep {
PERFORM_CONVERSIONS,
REQUEST_TEMP,
2021-05-09 12:09:39 +02:00
READ_TEMP,
WRITE_SETUP
2021-05-03 11:59:33 +02:00
};
enum class InternalState {
SETUP,
CONFIGURED
};
2021-05-07 18:48:42 +02:00
LinuxLibgpioIF* gpioComIF = nullptr;
gpioId_t chipSelectId = gpio::NO_GPIO;
2021-05-03 11:59:33 +02:00
SUS::SusDataset dataset;
uint8_t cmdBuffer[SUS::MAX_CMD_SIZE];
2021-05-03 11:59:33 +02:00
InternalState internalState = InternalState::SETUP;
2021-05-09 14:39:56 +02:00
CommunicationStep communicationStep = CommunicationStep::WRITE_SETUP;
2021-05-03 11:59:33 +02:00
};
#endif /* MISSION_DEVICES_SUSHANDLER_H_ */