eive-obsw/mission/devices/devicedefinitions/payloadPcduDefinitions.h
2022-02-21 14:42:05 +01:00

70 lines
2.4 KiB
C++

#ifndef LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_
#define LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include "mission/devices/max1227.h"
#include <cstddef>
namespace plpcdu {
using namespace max1227;
enum PlPcduPoolIds: uint32_t {
AIN_0 = 0,
AIN_1 = 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 DeviceCommandId_t READ_CMD = 0;
static constexpr DeviceCommandId_t SETUP_CMD = 1;
static constexpr DeviceCommandId_t READ_TEMP = 2;
static constexpr DeviceCommandId_t READ_WITH_TEMP = 3;
static constexpr uint8_t SETUP_BYTE = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED,
RefSel::INT_REF_NO_WAKEUP, DiffSel::NONE_0);
static constexpr uint32_t ADC_SET_ID = READ_CMD;
static constexpr uint8_t CHANNELS_NUM = 12;
static constexpr uint8_t CHANNEL_N = CHANNELS_NUM - 1;
// Store temperature as well
static constexpr size_t DATASET_ENTRIES = CHANNELS_NUM + 1;
class PlPcduAdcSet : public StaticLocalDataSet<DATASET_ENTRIES> {
public:
PlPcduAdcSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ADC_SET_ID) {}
PlPcduAdcSet(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, ADC_SET_ID)) {}
lp_var_t<uint16_t> ain0 = lp_var_t<uint16_t>(sid.objectId, AIN_0, 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);
};
}
#endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */