2021-06-21 09:50:26 +02:00
|
|
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_
|
|
|
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_
|
2021-03-05 12:57:42 +01:00
|
|
|
|
|
|
|
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
2022-01-17 15:58:27 +01:00
|
|
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
2021-03-05 12:57:42 +01:00
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
2022-01-17 15:58:27 +01:00
|
|
|
|
2021-05-17 20:03:56 +02:00
|
|
|
#include "objects/systemObjectList.h"
|
2021-03-05 12:57:42 +01:00
|
|
|
|
2022-05-09 21:29:54 +02:00
|
|
|
namespace MAX31865 {
|
2021-03-05 12:57:42 +01:00
|
|
|
|
2022-05-13 10:10:02 +02:00
|
|
|
enum class PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, LAST_FAULT_BYTE, FAULT_BYTE };
|
2022-05-09 21:29:54 +02:00
|
|
|
enum Wires : unsigned int { TWO_WIRE = 0, THREE_WIRE = 1, FOUR_WIRE = 0 };
|
|
|
|
|
|
|
|
enum ConvMode : unsigned int { NORM_OFF = 0, AUTO = 1 };
|
|
|
|
|
2022-05-14 09:41:28 +02:00
|
|
|
enum Bias : unsigned int { OFF = 0, ON = 1 };
|
2022-05-09 21:29:54 +02:00
|
|
|
|
|
|
|
enum FilterSel : unsigned int { FIFTY_HERTZ = 1, SIXTY_HERTZ = 0 };
|
|
|
|
|
|
|
|
enum CfgBitPos {
|
|
|
|
FILTER_SEL = 0,
|
2022-05-14 11:34:25 +02:00
|
|
|
FAULT_STATUS_CLEAR = 1,
|
2022-05-09 21:29:54 +02:00
|
|
|
FDCC = 2,
|
|
|
|
WIRE_SEL = 4,
|
|
|
|
ONE_SHOT = 5,
|
|
|
|
CONV_MODE = 6,
|
|
|
|
BIAS_SEL = 7
|
|
|
|
};
|
2021-03-05 12:57:42 +01:00
|
|
|
|
2022-05-12 09:48:41 +02:00
|
|
|
static constexpr uint32_t WARMUP_MS = 100;
|
|
|
|
|
2022-05-12 11:27:30 +02:00
|
|
|
static constexpr uint8_t WRITE_BIT = 0b10000000;
|
|
|
|
|
|
|
|
enum Regs : uint8_t {
|
|
|
|
CONFIG = 0x00,
|
|
|
|
RTD = 0x01,
|
|
|
|
HIGH_THRESHOLD = 0x03,
|
|
|
|
LOW_THRESHOLD = 0x05,
|
|
|
|
FAULT_BYTE = 0x07
|
|
|
|
};
|
|
|
|
|
2021-03-05 12:57:42 +01:00
|
|
|
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
|
2021-06-02 10:25:35 +02:00
|
|
|
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
|
|
|
|
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
|
2021-12-15 11:20:28 +01:00
|
|
|
|
2022-05-12 11:27:30 +02:00
|
|
|
static constexpr DeviceCommandId_t REQUEST_CONFIG = CONFIG;
|
|
|
|
static constexpr DeviceCommandId_t REQUEST_RTD = RTD;
|
|
|
|
static constexpr DeviceCommandId_t REQUEST_HIGH_THRESHOLD = HIGH_THRESHOLD;
|
|
|
|
static constexpr DeviceCommandId_t REQUEST_LOW_THRESHOLD = LOW_THRESHOLD;
|
|
|
|
static constexpr DeviceCommandId_t REQUEST_FAULT_BYTE = FAULT_BYTE;
|
2021-12-15 11:20:28 +01:00
|
|
|
static constexpr DeviceCommandId_t CLEAR_FAULT_BYTE = 0x08;
|
|
|
|
|
2021-03-13 14:42:30 +01:00
|
|
|
static constexpr uint32_t MAX31865_SET_ID = REQUEST_RTD;
|
2021-12-15 11:20:28 +01:00
|
|
|
static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010;
|
2021-03-13 14:42:30 +01:00
|
|
|
|
|
|
|
static constexpr size_t MAX_REPLY_SIZE = 5;
|
2021-03-05 12:57:42 +01:00
|
|
|
|
2022-11-25 10:13:24 +01:00
|
|
|
class PrimarySet : public StaticLocalDataSet<4> {
|
2022-01-17 15:58:27 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructor used by owner and data creators like device handlers.
|
|
|
|
* @param owner
|
|
|
|
* @param setId
|
|
|
|
*/
|
2022-11-25 10:13:24 +01:00
|
|
|
PrimarySet(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {}
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor used by data users like controllers.
|
|
|
|
* @param sid
|
|
|
|
*/
|
2022-11-25 10:13:24 +01:00
|
|
|
PrimarySet(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {}
|
2022-01-17 15:58:27 +01:00
|
|
|
|
2022-05-12 11:27:30 +02:00
|
|
|
lp_var_t<float> rtdValue =
|
|
|
|
lp_var_t<float>(sid.objectId, static_cast<lp_id_t>(PoolIds::RTD_VALUE), this);
|
|
|
|
lp_var_t<float> temperatureCelcius =
|
|
|
|
lp_var_t<float>(sid.objectId, static_cast<lp_id_t>(PoolIds::TEMPERATURE_C), this);
|
2022-05-13 10:10:02 +02:00
|
|
|
lp_var_t<uint8_t> lastErrorByte =
|
|
|
|
lp_var_t<uint8_t>(sid.objectId, static_cast<lp_id_t>(PoolIds::LAST_FAULT_BYTE), this);
|
2022-05-12 11:27:30 +02:00
|
|
|
lp_var_t<uint8_t> errorByte =
|
|
|
|
lp_var_t<uint8_t>(sid.objectId, static_cast<lp_id_t>(PoolIds::FAULT_BYTE), this);
|
2021-03-05 12:57:42 +01:00
|
|
|
};
|
|
|
|
|
2022-05-09 21:29:54 +02:00
|
|
|
} // namespace MAX31865
|
2021-03-05 12:57:42 +01:00
|
|
|
|
2022-05-12 09:48:41 +02:00
|
|
|
namespace EiveMax31855 {
|
|
|
|
|
2022-05-14 09:41:28 +02:00
|
|
|
static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm
|
2022-05-12 09:48:41 +02:00
|
|
|
static constexpr uint8_t NUM_RTDS = 16;
|
|
|
|
|
|
|
|
enum RtdCommands : DeviceCommandId_t {
|
|
|
|
ON = 0,
|
|
|
|
EXCHANGE_SET_ID = MAX31865::REQUEST_RTD,
|
|
|
|
ACTIVE = 2,
|
|
|
|
LOW_THRESHOLD = 3,
|
|
|
|
HIGH_TRESHOLD = 4,
|
|
|
|
OFF = 5,
|
|
|
|
CFG = 6,
|
2022-05-12 11:27:30 +02:00
|
|
|
NUM_CMDS
|
2022-05-12 09:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ReadOutStruct : public SerialLinkedListAdapter<SerializeIF> {
|
|
|
|
public:
|
|
|
|
ReadOutStruct() { setLinks(); }
|
|
|
|
ReadOutStruct(bool active, uint32_t spiErrCnt, bool faultBitSet, uint8_t faultVal,
|
|
|
|
uint16_t rtdVal)
|
|
|
|
: active(active),
|
2022-05-14 09:41:28 +02:00
|
|
|
adcCode(rtdVal),
|
2022-05-12 09:48:41 +02:00
|
|
|
faultBitSet(faultBitSet),
|
|
|
|
faultValue(faultVal),
|
|
|
|
spiErrorCount(spiErrCnt) {
|
|
|
|
setLinks();
|
|
|
|
}
|
|
|
|
|
2022-05-14 09:41:28 +02:00
|
|
|
//! RTD was set on and is configured, but is not periodically polled
|
|
|
|
SerializeElement<bool> configured = false;
|
|
|
|
//! RTD is active and polled periodically
|
2022-05-12 09:48:41 +02:00
|
|
|
SerializeElement<bool> active = false;
|
2022-05-14 09:41:28 +02:00
|
|
|
SerializeElement<uint16_t> adcCode = 0;
|
2022-05-12 09:48:41 +02:00
|
|
|
SerializeElement<bool> faultBitSet = false;
|
|
|
|
SerializeElement<uint8_t> faultValue = 0;
|
|
|
|
SerializeElement<uint32_t> spiErrorCount = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setLinks() {
|
2022-05-14 09:41:28 +02:00
|
|
|
setStart(&configured);
|
|
|
|
configured.setNext(&active);
|
|
|
|
active.setNext(&adcCode);
|
|
|
|
adcCode.setNext(&faultBitSet);
|
2022-05-12 09:48:41 +02:00
|
|
|
faultBitSet.setNext(&faultValue);
|
|
|
|
faultValue.setNext(&spiErrorCount);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace EiveMax31855
|
|
|
|
|
2021-06-21 09:50:26 +02:00
|
|
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */
|