added adc and temp handling
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Robin Müller 2022-02-21 15:28:33 +01:00
parent 134b0d3822
commit 8953f6f60d
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 23 additions and 49 deletions

View File

@ -1,3 +1,4 @@
#include <fsfw/src/fsfw/datapool/PoolReadGuard.h>
#include "PayloadPcduHandler.h" #include "PayloadPcduHandler.h"
#include "devices/gpioIds.h" #include "devices/gpioIds.h"
@ -216,6 +217,18 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
case(SETUP_CMD): { case(SETUP_CMD): {
break; break;
} }
case(READ_WITH_TEMP): {
PoolReadGuard pg(&adcSet);
if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
for(uint8_t idx = 0; idx < 12; idx ++) {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
}
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
adcSet.tempC.value = max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
}
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -227,18 +240,7 @@ uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo
ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_0, &ain0); localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::CHANNEL_VEC, &channelValues);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_1, &ain1);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_2, &ain2);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_3, &ain3);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_4, &ain4);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_5, &ain5);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_6, &ain6);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_7, &ain7);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_8, &ain8);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_9, &ain9);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_10, &ain10);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::AIN_11, &ain11);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC); localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -62,18 +62,7 @@ class PayloadPcduHandler : DeviceHandlerBase {
Countdown adcCountdown = Countdown(50); Countdown adcCountdown = Countdown(50);
GpioIF* gpioIF; GpioIF* gpioIF;
PoolEntry<uint16_t> ain0 = PoolEntry<uint16_t>({0}); PoolEntry<uint16_t> channelValues = PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
PoolEntry<uint16_t> ain1 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain2 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain3 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain4 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain5 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain6 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain7 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain8 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain9 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain10 = PoolEntry<uint16_t>({0});
PoolEntry<uint16_t> ain11 = PoolEntry<uint16_t>({0});
PoolEntry<float> tempC = PoolEntry<float>({0.0}); PoolEntry<float> tempC = PoolEntry<float>({0.0});
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;

View File

@ -11,19 +11,8 @@ namespace plpcdu {
using namespace max1227; using namespace max1227;
enum PlPcduPoolIds: uint32_t { enum PlPcduPoolIds: uint32_t {
AIN_0 = 0, CHANNEL_VEC = 0,
AIN_1 = 1, TEMP = 1
AIN_2 = 2,
AIN_3 = 3,
AIN_4 = 4,
AIN_5 = 5,
AIN_6 = 6,
AIN_7 = 7,
AIN_8 = 8,
AIN_9 = 9,
AIN_10 = 10,
AIN_11 = 11,
TEMP = 12
}; };
static constexpr size_t MAX_ADC_REPLY_SIZE = 64; static constexpr size_t MAX_ADC_REPLY_SIZE = 64;
@ -33,6 +22,11 @@ static constexpr DeviceCommandId_t SETUP_CMD = 1;
static constexpr DeviceCommandId_t READ_TEMP = 2; static constexpr DeviceCommandId_t READ_TEMP = 2;
static constexpr DeviceCommandId_t READ_WITH_TEMP = 3; static constexpr DeviceCommandId_t READ_WITH_TEMP = 3;
// 12 ADC values * 2 + trailing zero
static constexpr size_t ADC_REPLY_SIZE = 25;
// Conversion byte + 24 * zero
static constexpr size_t TEMP_REPLY_SIZE = 25;
static constexpr uint8_t SETUP_BYTE = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, static constexpr uint8_t SETUP_BYTE = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED,
RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0); RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0);
@ -49,18 +43,7 @@ class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
PlPcduAdcSet(object_id_t objectId) PlPcduAdcSet(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, ADC_SET_ID)) {} : StaticLocalDataSet(sid_t(objectId, ADC_SET_ID)) {}
lp_var_t<uint16_t> ain0 = lp_var_t<uint16_t>(sid.objectId, AIN_0, this); lp_vec_t<uint16_t, 12> channels = lp_vec_t<uint16_t, 12>(sid.objectId, CHANNEL_VEC, this);
lp_var_t<uint16_t> ain1 = lp_var_t<uint16_t>(sid.objectId, AIN_1, this);
lp_var_t<uint16_t> ain2= lp_var_t<uint16_t>(sid.objectId, AIN_2, this);
lp_var_t<uint16_t> ain3 = lp_var_t<uint16_t>(sid.objectId, AIN_3, this);
lp_var_t<uint16_t> ain4 = lp_var_t<uint16_t>(sid.objectId, AIN_4, this);
lp_var_t<uint16_t> ain5 = lp_var_t<uint16_t>(sid.objectId, AIN_5, this);
lp_var_t<uint16_t> ain6 = lp_var_t<uint16_t>(sid.objectId, AIN_6, this);
lp_var_t<uint16_t> ain7 = lp_var_t<uint16_t>(sid.objectId, AIN_7, this);
lp_var_t<uint16_t> ain8 = lp_var_t<uint16_t>(sid.objectId, AIN_8, this);
lp_var_t<uint16_t> ain9 = lp_var_t<uint16_t>(sid.objectId, AIN_9, this);
lp_var_t<uint16_t> ain10 = lp_var_t<uint16_t>(sid.objectId, AIN_10, this);
lp_var_t<uint16_t> ain11 = lp_var_t<uint16_t>(sid.objectId, AIN_11, this);
lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this); lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this);
}; };