added eive specific max31865 handler
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
56f491befb
commit
23f209fb07
@ -286,10 +286,10 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
|
|||||||
std::array<Max31865PT1000Handler*, NUMBER_RTDS> rtds = {};
|
std::array<Max31865PT1000Handler*, NUMBER_RTDS> rtds = {};
|
||||||
RtdFdir* rtdFdir = nullptr;
|
RtdFdir* rtdFdir = nullptr;
|
||||||
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
|
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
|
||||||
rtdCookies[idx] =
|
rtdCookies[idx] = new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second,
|
||||||
new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second,
|
|
||||||
MAX31865::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
MAX31865::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||||
rtds[idx] = new Max31865PT1000Handler(rtdInfos[idx].first, objects::SPI_MAIN_COM_IF, rtdCookies[idx]);
|
rtds[idx] =
|
||||||
|
new Max31865PT1000Handler(rtdInfos[idx].first, objects::SPI_MAIN_COM_IF, rtdCookies[idx]);
|
||||||
rtds[idx]->setParent(objects::TCS_BOARD_ASS);
|
rtds[idx]->setParent(objects::TCS_BOARD_ASS);
|
||||||
rtdFdir = new RtdFdir(rtdInfos[idx].first);
|
rtdFdir = new RtdFdir(rtdInfos[idx].first);
|
||||||
rtds[idx]->setCustomFdir(rtdFdir);
|
rtds[idx]->setCustomFdir(rtdFdir);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <linux/devices/Max31865RtdReader.h>
|
#include <linux/devices/Max31865RtdReader.h>
|
||||||
|
|
||||||
Max31865RtdReader::Max31865RtdReader(object_id_t objectId, SpiComIF* comIF)
|
Max31865RtdReader::Max31865RtdReader(object_id_t objectId, SpiComIF* comIF)
|
||||||
: SystemObject(objectId), rtds(NUM_RTDS), comIF(comIF) {
|
: SystemObject(objectId), rtds(EiveMax31855::NUM_RTDS), comIF(comIF) {
|
||||||
readerMutex = MutexFactory::instance()->createMutex();
|
readerMutex = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ void Max31865RtdReader::rtdMainLoop() {
|
|||||||
periodicReadHandling();
|
periodicReadHandling();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Max31865RtdReader::rtdCanBeUsed(uint8_t idx) {
|
bool Max31865RtdReader::rtdIsActive(uint8_t idx) {
|
||||||
if (rtds[idx]->active and rtds[idx]->configured) {
|
if (rtds[idx]->on and rtds[idx]->active and rtds[idx]->configured) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -48,24 +48,26 @@ bool Max31865RtdReader::periodicInitHandling() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool someRtdActive = false;
|
bool someRtdOn = false;
|
||||||
for (auto& rtd : rtds) {
|
for (auto& rtd : rtds) {
|
||||||
if (rtd == nullptr) {
|
if (rtd == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rtd->active and not rtd->configured) {
|
if (rtd->on and not rtd->configured) {
|
||||||
someRtdActive = true;
|
if (rtd->cd.hasTimedOut()) {
|
||||||
uint8_t cfg = (Bias::OFF << CfgBitPos::BIAS_SEL) | (Wires::FOUR_WIRE << CfgBitPos::WIRE_SEL) |
|
uint8_t cfg =
|
||||||
(ConvMode::NORM_OFF << CfgBitPos::CONV_MODE) |
|
(Bias::OFF << CfgBitPos::BIAS_SEL) | (Wires::FOUR_WIRE << CfgBitPos::WIRE_SEL) |
|
||||||
(1 << CfgBitPos::FAULTY_STATUS_CLEAR);
|
(ConvMode::NORM_OFF << CfgBitPos::CONV_MODE) | (1 << CfgBitPos::FAULTY_STATUS_CLEAR);
|
||||||
result = writeCfgReg(rtd->spiCookie, cfg);
|
result = writeCfgReg(rtd->spiCookie, cfg);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
// TODO: Check retval
|
// TODO: Check retval
|
||||||
}
|
}
|
||||||
|
someRtdOn = true;
|
||||||
rtd->configured = true;
|
rtd->configured = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (not someRtdActive) {
|
}
|
||||||
|
if (not someRtdOn) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool someRtdUsable = false;
|
bool someRtdUsable = false;
|
||||||
@ -73,7 +75,7 @@ bool Max31865RtdReader::periodicInitHandling() {
|
|||||||
if (rtd == nullptr) {
|
if (rtd == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rtdCanBeUsed(rtd->idx)) {
|
if (rtdIsActive(rtd->idx)) {
|
||||||
someRtdUsable = true;
|
someRtdUsable = true;
|
||||||
result = biasSel(Bias::ON, rtd->spiCookie);
|
result = biasSel(Bias::ON, rtd->spiCookie);
|
||||||
}
|
}
|
||||||
@ -93,7 +95,7 @@ void Max31865RtdReader::periodicReadReqHandling() {
|
|||||||
if (rtd == nullptr) {
|
if (rtd == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rtd->active) {
|
if (rtdIsActive(rtd->idx)) {
|
||||||
uint8_t currentCfg = 0;
|
uint8_t currentCfg = 0;
|
||||||
auto result = readCfgReg(rtd->spiCookie, currentCfg);
|
auto result = readCfgReg(rtd->spiCookie, currentCfg);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -119,7 +121,7 @@ void Max31865RtdReader::periodicReadHandling() {
|
|||||||
if (rtd == nullptr) {
|
if (rtd == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rtd->active) {
|
if (rtdIsActive(rtd->idx)) {
|
||||||
uint16_t rtdVal = 0;
|
uint16_t rtdVal = 0;
|
||||||
bool faultBitSet = false;
|
bool faultBitSet = false;
|
||||||
result = readRtdVal(rtd->spiCookie, rtdVal, faultBitSet);
|
result = readRtdVal(rtd->spiCookie, rtdVal, faultBitSet);
|
||||||
@ -137,7 +139,9 @@ void Max31865RtdReader::periodicReadHandling() {
|
|||||||
if (rtd == nullptr) {
|
if (rtd == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rtd->active) {
|
// Even if a device was made inactive, turn off the bias here. If it was turned off, not
|
||||||
|
// necessary anymore..
|
||||||
|
if (rtd->on) {
|
||||||
result = biasSel(Bias::OFF, rtd->spiCookie);
|
result = biasSel(Bias::OFF, rtd->spiCookie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +156,7 @@ ReturnValue_t Max31865RtdReader::initializeInterface(CookieIF* cookie) {
|
|||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (rtdCookie->idx > NUM_RTDS) {
|
if (rtdCookie->idx > EiveMax31855::NUM_RTDS) {
|
||||||
throw std::invalid_argument("Invalid RTD index");
|
throw std::invalid_argument("Invalid RTD index");
|
||||||
}
|
}
|
||||||
rtds[rtdCookie->idx] = rtdCookie;
|
rtds[rtdCookie->idx] = rtdCookie;
|
||||||
@ -178,21 +182,40 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se
|
|||||||
// TODO: Emit warning, invalid command
|
// TODO: Emit warning, invalid command
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
auto cmd = static_cast<RtdCommands>(sendData[0]);
|
auto cmd = static_cast<EiveMax31855::RtdCommands>(sendData[0]);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case (RtdCommands::ON): {
|
case (EiveMax31855::RtdCommands::ON): {
|
||||||
if (not rtdCookie->active) {
|
if (not rtdCookie->on) {
|
||||||
rtdCookie->active = true;
|
rtdCookie->cd.setTimeout(MAX31865::WARMUP_MS);
|
||||||
|
rtdCookie->cd.resetTimer();
|
||||||
|
rtdCookie->on = true;
|
||||||
|
rtdCookie->active = false;
|
||||||
rtdCookie->configured = false;
|
rtdCookie->configured = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (RtdCommands::OFF): {
|
case (EiveMax31855::RtdCommands::ACTIVE): {
|
||||||
|
if (not rtdCookie->on) {
|
||||||
|
rtdCookie->cd.setTimeout(MAX31865::WARMUP_MS);
|
||||||
|
rtdCookie->cd.resetTimer();
|
||||||
|
rtdCookie->on = true;
|
||||||
|
rtdCookie->active = true;
|
||||||
|
rtdCookie->configured = false;
|
||||||
|
} else {
|
||||||
|
rtdCookie->active = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (EiveMax31855::RtdCommands::OFF): {
|
||||||
|
rtdCookie->on = false;
|
||||||
rtdCookie->active = false;
|
rtdCookie->active = false;
|
||||||
rtdCookie->configured = false;
|
rtdCookie->configured = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (RtdCommands::CFG): {
|
case (EiveMax31855::RtdCommands::HIGH_TRESHOLD):
|
||||||
|
case (EiveMax31855::RtdCommands::LOW_THRESHOLD):
|
||||||
|
case (EiveMax31855::RtdCommands::CFG):
|
||||||
|
default: {
|
||||||
// TODO: Only implement if needed
|
// TODO: Only implement if needed
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -9,32 +9,6 @@
|
|||||||
#include "fsfw/devicehandlers/DeviceCommunicationIF.h"
|
#include "fsfw/devicehandlers/DeviceCommunicationIF.h"
|
||||||
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
|
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
|
||||||
|
|
||||||
static constexpr uint8_t NUM_RTDS = 16;
|
|
||||||
|
|
||||||
enum RtdCommands : uint8_t { ON = 0, OFF = 1, CFG = 2 };
|
|
||||||
|
|
||||||
class ReadOutStruct : public SerialLinkedListAdapter<SerializeIF> {
|
|
||||||
public:
|
|
||||||
ReadOutStruct() { setLinks(); }
|
|
||||||
ReadOutStruct(uint32_t spiErrCnt, bool faultBitSet, uint8_t faultVal, uint16_t rtdVal)
|
|
||||||
: spiErrorCount(spiErrCnt), faultBitSet(faultBitSet), faultValue(faultVal), rtdVal(rtdVal) {
|
|
||||||
setLinks();
|
|
||||||
}
|
|
||||||
|
|
||||||
SerializeElement<uint32_t> spiErrorCount = 0;
|
|
||||||
SerializeElement<bool> faultBitSet = false;
|
|
||||||
SerializeElement<uint8_t> faultValue = 0;
|
|
||||||
SerializeElement<uint16_t> rtdVal = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setLinks() {
|
|
||||||
setStart(&spiErrorCount);
|
|
||||||
spiErrorCount.setNext(&faultBitSet);
|
|
||||||
faultBitSet.setNext(&faultValue);
|
|
||||||
faultValue.setNext(&rtdVal);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Max31865ReaderCookie {
|
struct Max31865ReaderCookie {
|
||||||
Max31865ReaderCookie(){};
|
Max31865ReaderCookie(){};
|
||||||
Max31865ReaderCookie(object_id_t handlerId_, uint8_t idx_, const std::string& locString_,
|
Max31865ReaderCookie(object_id_t handlerId_, uint8_t idx_, const std::string& locString_,
|
||||||
@ -46,14 +20,14 @@ struct Max31865ReaderCookie {
|
|||||||
|
|
||||||
std::string locString = "";
|
std::string locString = "";
|
||||||
std::array<uint8_t, 12> exchangeBuf{};
|
std::array<uint8_t, 12> exchangeBuf{};
|
||||||
bool active = false;
|
Countdown cd = Countdown(MAX31865::WARMUP_MS);
|
||||||
|
bool on = false;
|
||||||
bool configured = false;
|
bool configured = false;
|
||||||
|
bool active = false;
|
||||||
SpiCookie* spiCookie = nullptr;
|
SpiCookie* spiCookie = nullptr;
|
||||||
|
|
||||||
// Exchange data buffer struct
|
// Exchange data buffer struct
|
||||||
ReadOutStruct db;
|
EiveMax31855::ReadOutStruct db;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Max31865RtdReader : public SystemObject,
|
class Max31865RtdReader : public SystemObject,
|
||||||
@ -74,7 +48,7 @@ class Max31865RtdReader : public SystemObject,
|
|||||||
void periodicReadReqHandling();
|
void periodicReadReqHandling();
|
||||||
void periodicReadHandling();
|
void periodicReadHandling();
|
||||||
|
|
||||||
bool rtdCanBeUsed(uint8_t idx);
|
bool rtdIsActive(uint8_t idx);
|
||||||
ReturnValue_t writeCfgReg(SpiCookie* cookie, uint8_t cfg);
|
ReturnValue_t writeCfgReg(SpiCookie* cookie, uint8_t cfg);
|
||||||
ReturnValue_t biasSel(MAX31865::Bias bias, SpiCookie* cookie);
|
ReturnValue_t biasSel(MAX31865::Bias bias, SpiCookie* cookie);
|
||||||
ReturnValue_t readCfgReg(SpiCookie* cookie, uint8_t& cfg);
|
ReturnValue_t readCfgReg(SpiCookie* cookie, uint8_t& cfg);
|
||||||
|
@ -8,6 +8,7 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE
|
|||||||
PDU2Handler.cpp
|
PDU2Handler.cpp
|
||||||
ACUHandler.cpp
|
ACUHandler.cpp
|
||||||
SyrlinksHkHandler.cpp
|
SyrlinksHkHandler.cpp
|
||||||
|
Max31865EiveHandler.cpp
|
||||||
Max31865PT1000Handler.cpp
|
Max31865PT1000Handler.cpp
|
||||||
IMTQHandler.cpp
|
IMTQHandler.cpp
|
||||||
HeaterHandler.cpp
|
HeaterHandler.cpp
|
||||||
|
132
mission/devices/Max31865EiveHandler.cpp
Normal file
132
mission/devices/Max31865EiveHandler.cpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
#include "Max31865EiveHandler.h"
|
||||||
|
|
||||||
|
Max31865EiveHandler::Max31865EiveHandler(object_id_t objectId, object_id_t comIF,
|
||||||
|
CookieIF* comCookie)
|
||||||
|
: DeviceHandlerBase(objectId, comIF, comCookie, nullptr),
|
||||||
|
sensorDataset(this, EiveMax31855::RtdCommands::EXCHANGE_SET_ID) {}
|
||||||
|
|
||||||
|
void Max31865EiveHandler::doStartUp() {
|
||||||
|
if (state == InternalState::NONE or state == InternalState::INACTIVE) {
|
||||||
|
if (instantNormal) {
|
||||||
|
state = InternalState::ACTIVE;
|
||||||
|
} else {
|
||||||
|
state = InternalState::ON;
|
||||||
|
}
|
||||||
|
transitionOk = false;
|
||||||
|
}
|
||||||
|
if ((state == InternalState::ON or state == InternalState::ACTIVE) and transitionOk) {
|
||||||
|
if (instantNormal) {
|
||||||
|
setMode(_MODE_TO_NORMAL);
|
||||||
|
} else {
|
||||||
|
setMode(MODE_ON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Max31865EiveHandler::doShutDown() {
|
||||||
|
if (state == InternalState::NONE or state == InternalState::ACTIVE or
|
||||||
|
state == InternalState::ON) {
|
||||||
|
state = InternalState::INACTIVE;
|
||||||
|
transitionOk = false;
|
||||||
|
} else {
|
||||||
|
transitionOk = true;
|
||||||
|
}
|
||||||
|
if (state == InternalState::INACTIVE and transitionOk) {
|
||||||
|
setMode(_MODE_POWER_DOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Max31865EiveHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||||
|
*id = EiveMax31855::RtdCommands::EXCHANGE_SET_ID;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Max31865EiveHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||||
|
if (state == InternalState::ON) {
|
||||||
|
*id = EiveMax31855::RtdCommands::ON;
|
||||||
|
buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
|
if (state == InternalState::ACTIVE) {
|
||||||
|
*id = EiveMax31855::RtdCommands::ACTIVE;
|
||||||
|
buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
|
if (state == InternalState::INACTIVE) {
|
||||||
|
*id = EiveMax31855::RtdCommands::OFF;
|
||||||
|
buildCommandFromCommand(*id, nullptr, 0);
|
||||||
|
}
|
||||||
|
return NOTHING_TO_SEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Max31865EiveHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||||
|
const uint8_t* commandData,
|
||||||
|
size_t commandDataLen) {
|
||||||
|
auto cmdTyped = static_cast<EiveMax31855::RtdCommands>(deviceCommand);
|
||||||
|
switch (cmdTyped) {
|
||||||
|
case (EiveMax31855::RtdCommands::ON):
|
||||||
|
case (EiveMax31855::RtdCommands::ACTIVE):
|
||||||
|
case (EiveMax31855::RtdCommands::OFF): {
|
||||||
|
simpleCommand(cmdTyped);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (EiveMax31855::RtdCommands::LOW_THRESHOLD):
|
||||||
|
case (EiveMax31855::RtdCommands::HIGH_TRESHOLD): {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (EiveMax31855::RtdCommands::CFG): {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return NOTHING_TO_SEND;
|
||||||
|
}
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Max31865EiveHandler::simpleCommand(EiveMax31855::RtdCommands cmd) {
|
||||||
|
cmdBuf[0] = cmd;
|
||||||
|
rawPacket = cmdBuf.data();
|
||||||
|
rawPacketLen = 1;
|
||||||
|
}
|
||||||
|
void Max31865EiveHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||||
|
if (mode == _MODE_TO_NORMAL) {
|
||||||
|
state = InternalState::ACTIVE;
|
||||||
|
transitionOk = false;
|
||||||
|
if (transitionOk) {
|
||||||
|
setMode(MODE_NORMAL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Max31865EiveHandler::fillCommandAndReplyMap() {
|
||||||
|
insertInReplyMap(EiveMax31855::RtdCommands::EXCHANGE_SET_ID, 2, &sensorDataset);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Max31865EiveHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||||
|
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||||
|
if (remainingSize != exchangeStruct.getSerializedSize()) {
|
||||||
|
sif::error << "Invalid reply from RTD reader detected, reply size " << remainingSize
|
||||||
|
<< "not equal to exchange struct size" << exchangeStruct.getSerializedSize()
|
||||||
|
<< std::endl;
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
*foundId = EiveMax31855::RtdCommands::EXCHANGE_SET_ID;
|
||||||
|
*foundLen = remainingSize;
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Max31865EiveHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||||
|
const uint8_t* packet) {
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Max31865EiveHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 2000; }
|
||||||
|
|
||||||
|
ReturnValue_t Max31865EiveHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
|
LocalDataPoolManager& poolManager) {
|
||||||
|
localDataPoolMap.emplace(MAX31865::PoolIds::RTD_VALUE, new PoolEntry<float>({0}));
|
||||||
|
localDataPoolMap.emplace(MAX31865::PoolIds::TEMPERATURE_C, new PoolEntry<float>({0}));
|
||||||
|
localDataPoolMap.emplace(MAX31865::PoolIds::FAULT_BYTE, new PoolEntry<uint8_t>({0}));
|
||||||
|
poolManager.subscribeForPeriodicPacket(sensorDataset.getSid(), false, 30.0, false);
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
37
mission/devices/Max31865EiveHandler.h
Normal file
37
mission/devices/Max31865EiveHandler.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef MISSION_DEVICES_MAX31865EIVEHANDLER_H_
|
||||||
|
#define MISSION_DEVICES_MAX31865EIVEHANDLER_H_
|
||||||
|
|
||||||
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
|
|
||||||
|
#include "devicedefinitions/Max31865Definitions.h"
|
||||||
|
|
||||||
|
class Max31865EiveHandler : public DeviceHandlerBase {
|
||||||
|
public:
|
||||||
|
Max31865EiveHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void doStartUp() override;
|
||||||
|
void doShutDown() override;
|
||||||
|
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) 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;
|
||||||
|
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||||
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
|
LocalDataPoolManager& poolManager) override;
|
||||||
|
|
||||||
|
void simpleCommand(EiveMax31855::RtdCommands cmd);
|
||||||
|
std::array<uint8_t, 12> cmdBuf = {};
|
||||||
|
EiveMax31855::ReadOutStruct exchangeStruct;
|
||||||
|
bool instantNormal = false;
|
||||||
|
MAX31865::Max31865Set sensorDataset;
|
||||||
|
enum class InternalState { NONE, ON, ACTIVE, INACTIVE } state = InternalState::NONE;
|
||||||
|
bool transitionOk = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* MISSION_DEVICES_MAX31865EIVEHANDLER_H_ */
|
@ -8,7 +8,7 @@
|
|||||||
Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF,
|
Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF,
|
||||||
CookieIF *comCookie)
|
CookieIF *comCookie)
|
||||||
: DeviceHandlerBase(objectId, comIF, comCookie),
|
: DeviceHandlerBase(objectId, comIF, comCookie),
|
||||||
sensorDataset(this),
|
sensorDataset(this, MAX31865::REQUEST_RTD),
|
||||||
sensorDatasetSid(sensorDataset.getSid()) {
|
sensorDatasetSid(sensorDataset.getSid()) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
debugDivider = new PeriodicOperationDivider(10);
|
debugDivider = new PeriodicOperationDivider(10);
|
||||||
|
@ -28,6 +28,8 @@ enum CfgBitPos {
|
|||||||
BIAS_SEL = 7
|
BIAS_SEL = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr uint32_t WARMUP_MS = 100;
|
||||||
|
|
||||||
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
|
static constexpr DeviceCommandId_t CONFIG_CMD = 0x80;
|
||||||
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
|
static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83;
|
||||||
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
|
static constexpr DeviceCommandId_t WRITE_LOW_THRESHOLD = 0x85;
|
||||||
@ -50,20 +52,20 @@ static constexpr uint8_t REG_RTD = 0x01;
|
|||||||
|
|
||||||
static constexpr size_t MAX_REPLY_SIZE = 5;
|
static constexpr size_t MAX_REPLY_SIZE = 5;
|
||||||
|
|
||||||
class Max31865Set : public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
|
class Max31865Set : public StaticLocalDataSet<3> {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor used by owner and data creators like device handlers.
|
* Constructor used by owner and data creators like device handlers.
|
||||||
* @param owner
|
* @param owner
|
||||||
* @param setId
|
* @param setId
|
||||||
*/
|
*/
|
||||||
Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {}
|
Max31865Set(HasLocalDataPoolIF* owner, uint32_t setId) : StaticLocalDataSet(owner, setId) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used by data users like controllers.
|
* Constructor used by data users like controllers.
|
||||||
* @param sid
|
* @param sid
|
||||||
*/
|
*/
|
||||||
Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {}
|
Max31865Set(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {}
|
||||||
|
|
||||||
lp_var_t<float> rtdValue = lp_var_t<float>(sid.objectId, PoolIds::RTD_VALUE, this);
|
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<float> temperatureCelcius = lp_var_t<float>(sid.objectId, PoolIds::TEMPERATURE_C, this);
|
||||||
@ -72,4 +74,50 @@ class Max31865Set : public StaticLocalDataSet<sizeof(float) + sizeof(uint8_t)> {
|
|||||||
|
|
||||||
} // namespace MAX31865
|
} // namespace MAX31865
|
||||||
|
|
||||||
|
namespace EiveMax31855 {
|
||||||
|
|
||||||
|
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,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class ReadOutStruct : public SerialLinkedListAdapter<SerializeIF> {
|
||||||
|
public:
|
||||||
|
ReadOutStruct() { setLinks(); }
|
||||||
|
ReadOutStruct(bool active, uint32_t spiErrCnt, bool faultBitSet, uint8_t faultVal,
|
||||||
|
uint16_t rtdVal)
|
||||||
|
: active(active),
|
||||||
|
rtdVal(rtdVal),
|
||||||
|
faultBitSet(faultBitSet),
|
||||||
|
faultValue(faultVal),
|
||||||
|
spiErrorCount(spiErrCnt) {
|
||||||
|
setLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
SerializeElement<bool> active = false;
|
||||||
|
SerializeElement<uint16_t> rtdVal = 0;
|
||||||
|
SerializeElement<bool> faultBitSet = false;
|
||||||
|
SerializeElement<uint8_t> faultValue = 0;
|
||||||
|
SerializeElement<uint32_t> spiErrorCount = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setLinks() {
|
||||||
|
setStart(&active);
|
||||||
|
active.setNext(&rtdVal);
|
||||||
|
rtdVal.setNext(&faultBitSet);
|
||||||
|
faultBitSet.setNext(&faultValue);
|
||||||
|
faultValue.setNext(&spiErrorCount);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}; // namespace EiveMax31855
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#include "Max31865Definitions.h"
|
|
Loading…
Reference in New Issue
Block a user