eive-obsw/mission/acs/susMax1227Helpers.h
Robin Mueller 63b50e6101
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop Build started...
clean up op done
2023-03-26 16:42:00 +02:00

78 lines
2.8 KiB
C++

#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <cstdint>
namespace susMax1227 {
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
static const DeviceCommandId_t WRITE_SETUP = 1;
/**
* This command initiates the ADC conversion for all channels including the internal
* temperature sensor.
*/
static const DeviceCommandId_t START_INT_TIMED_CONVERSIONS = 2;
/**
* This command reads the internal fifo which holds the temperature and the channel
* conversions.
*/
static constexpr DeviceCommandId_t READ_INT_TIMED_CONVERSIONS = 3;
static constexpr DeviceCommandId_t READ_EXT_TIMED_CONVERSIONS = 4;
static constexpr DeviceCommandId_t READ_EXT_TIMED_TEMPS = 5;
/**
* @brief This is the configuration byte which will be written to the setup register after
* power on.
*
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked
* Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be
* written to the setup register
*
*/
static constexpr uint8_t SETUP_INT_CLOKED = 0b01101000;
static constexpr uint8_t SETUP_EXT_CLOCKED = 0b01111000;
/**
* @brief This values will always be written to the ADC conversion register to specify the
* conversions to perform.
* @details Bit0: 1 - Enables temperature conversion
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N
* Bit6 - Bit3 defines N: 0b0101 (N = 5)
* Bit7: Always 1. Tells the ADC that this is the conversion register.
*/
static const uint8_t CONVERSION = 0b10101001;
static const uint8_t SUS_DATA_SET_ID = READ_INT_TIMED_CONVERSIONS;
/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */
static const uint8_t SIZE_READ_INT_CONVERSIONS = 14;
// 6 * conv byte, 6 * 0 and one trailing zero
static constexpr uint8_t SIZE_READ_EXT_CONVERSIONS = 13;
static const uint8_t MAX_CMD_SIZE = 32;
static const uint8_t POOL_ENTRIES = 7;
enum SusPoolIds : lp_id_t { TEMPERATURE_C, CHANNEL_VEC };
class SusDataset : public StaticLocalDataSet<POOL_ENTRIES> {
public:
SusDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SUS_DATA_SET_ID) {}
SusDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) {}
lp_var_t<float> tempC = lp_var_t<float>(sid.objectId, TEMPERATURE_C, this);
lp_vec_t<uint16_t, 6> channels = lp_vec_t<uint16_t, 6>(sid.objectId, CHANNEL_VEC, this);
};
} // namespace susMax1227
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */