eive-obsw/mission/devices/devicedefinitions/Max31865Definitions.h
Robin Mueller 50c363fb6f
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
new RTD reader module handling all RTD SPI Communication
2022-05-09 21:29:54 +02:00

76 lines
2.4 KiB
C++

#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "objects/systemObjectList.h"
namespace MAX31865 {
enum PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, FAULT_BYTE };
enum Wires : unsigned int { TWO_WIRE = 0, THREE_WIRE = 1, FOUR_WIRE = 0 };
enum ConvMode : unsigned int { NORM_OFF = 0, AUTO = 1 };
enum Bias : unsigned int { ON = 0, OFF = 1 };
enum FilterSel : unsigned int { FIFTY_HERTZ = 1, SIXTY_HERTZ = 0 };
enum CfgBitPos {
FILTER_SEL = 0,
FAULTY_STATUS_CLEAR = 1,
FDCC = 2,
WIRE_SEL = 4,
ONE_SHOT = 5,
CONV_MODE = 6,
BIAS_SEL = 7
};
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
static constexpr DeviceCommandId_t REQUEST_CONFIG = 0x00;
static constexpr DeviceCommandId_t REQUEST_RTD = 0x01;
static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = 0x03;
static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = 0x05;
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = 0x07;
static constexpr DeviceCommandId_t CLEAR_FAULT_BYTE = 0x08;
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010;
static constexpr uint8_t WRITE_BIT = 0b10000000;
static constexpr uint8_t REG_CONFIG = 0x00;
static constexpr uint8_t REG_RTD = 0x01;
static constexpr size_t MAX_REPLY_SIZE = 5;
class Max31865Set : public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
public:
/**
* Constructor used by owner and data creators like device handlers.
* @param owner
* @param setId
*/
Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {}
/**
* Constructor used by data users like controllers.
* @param sid
*/
Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {}
lp_var_t<float> rtdValue = lp_var_t<float>(sid.objectId, PoolIds::RTD_VALUE, this);
lp_var_t<float> temperatureCelcius = lp_var_t<float>(sid.objectId, PoolIds::TEMPERATURE_C, this);
lp_var_t<uint8_t> errorByte = lp_var_t<uint8_t>(sid.objectId, PoolIds::FAULT_BYTE, this);
};
} // namespace MAX31865
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */