2022-02-22 13:27:21 +01:00
|
|
|
#ifndef LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_
|
|
|
|
#define LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_
|
|
|
|
|
|
|
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
#include "mission/devices/max1227.h"
|
|
|
|
|
|
|
|
namespace plpcdu {
|
|
|
|
|
|
|
|
using namespace max1227;
|
|
|
|
|
2022-02-25 11:16:04 +01:00
|
|
|
enum PlPcduAdcChannels : uint8_t {
|
2022-02-24 12:44:50 +01:00
|
|
|
U_BAT_DIV_6 = 0,
|
|
|
|
// According to schematic, will be 2.2158V for Vneg = +0V and 0.2446V for Vneg = -6V
|
|
|
|
// Full Forumula: V_neg = V_post - (R1 + R2) / R1 * (V_pos - V_out) with R1 being 27.4k
|
|
|
|
// and R2 being 49.9k
|
|
|
|
U_NEG_V_FB = 1,
|
|
|
|
I_HPA = 2,
|
|
|
|
U_HPA_DIV_6 = 3,
|
|
|
|
I_MPA = 4,
|
|
|
|
U_MPA_DIV_6 = 5,
|
|
|
|
I_TX = 6,
|
|
|
|
U_TX_DIV_6 = 7,
|
|
|
|
I_X8 = 8,
|
|
|
|
U_X8_DIV_6 = 9,
|
|
|
|
I_DRO = 10,
|
|
|
|
U_DRO_DIV_6 = 11,
|
|
|
|
NUM_CHANNELS = 12
|
|
|
|
};
|
|
|
|
|
2022-02-22 13:27:21 +01:00
|
|
|
enum PlPcduPoolIds : uint32_t { CHANNEL_VEC = 0, TEMP = 1 };
|
|
|
|
|
|
|
|
static constexpr size_t MAX_ADC_REPLY_SIZE = 64;
|
|
|
|
|
|
|
|
static constexpr DeviceCommandId_t READ_CMD = 0;
|
|
|
|
static constexpr DeviceCommandId_t SETUP_CMD = 1;
|
2022-02-22 16:51:26 +01:00
|
|
|
static constexpr DeviceCommandId_t READ_TEMP_EXT = 2;
|
|
|
|
static constexpr DeviceCommandId_t READ_WITH_TEMP_EXT = 3;
|
2022-02-22 13:27:21 +01:00
|
|
|
|
|
|
|
static constexpr Submode_t NORMAL_ADC_ONLY = 0;
|
|
|
|
static constexpr Submode_t NORMAL_ALL_ON = 1;
|
|
|
|
|
|
|
|
// 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, 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_vec_t<uint16_t, 12> channels = lp_vec_t<uint16_t, 12>(sid.objectId, CHANNEL_VEC, this);
|
|
|
|
lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMP, this);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace plpcdu
|
|
|
|
|
|
|
|
#endif /* LINUX_DEVICES_DEVICEDEFINITIONS_PAYLOADPCDUDEFINITIONS_H_ */
|