2021-05-03 11:59:33 +02:00
|
|
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_
|
|
|
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_
|
|
|
|
|
|
|
|
namespace SUS {
|
|
|
|
|
2021-05-09 16:48:55 +02:00
|
|
|
/**
|
|
|
|
* The MAX1227 in externally clocked mode did not properly work with frequencies higher than
|
|
|
|
* 1 MHz.
|
|
|
|
*/
|
|
|
|
static const uint32_t SUS_MAX_1227_SPEED = 1000000;
|
|
|
|
|
2021-05-03 11:59:33 +02:00
|
|
|
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
|
|
|
|
|
2021-05-10 11:13:39 +02:00
|
|
|
static const DeviceCommandId_t WRITE_SETUP = 0x1;
|
|
|
|
/**
|
|
|
|
* This command initiates the ADC conversion for all channels including the internal
|
|
|
|
* temperature sensor.
|
|
|
|
*/
|
|
|
|
static const DeviceCommandId_t START_CONVERSIONS = 0x2;
|
2021-05-03 11:59:33 +02:00
|
|
|
/**
|
2021-05-10 11:13:39 +02:00
|
|
|
* This command reads the internal fifo which holds the temperature and the channel
|
|
|
|
* conversions.
|
2021-05-03 11:59:33 +02:00
|
|
|
*/
|
2021-05-10 11:13:39 +02:00
|
|
|
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This is the configuration byte which will be written to the setup register after
|
|
|
|
* power on.
|
|
|
|
*
|
2021-05-07 18:48:42 +02:00
|
|
|
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte
|
2021-05-10 11:13:39 +02:00
|
|
|
* 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
|
2021-05-03 11:59:33 +02:00
|
|
|
*
|
|
|
|
*/
|
2021-05-10 11:13:39 +02:00
|
|
|
static const uint8_t SETUP = 0b01101000;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
|
|
|
/**
|
2021-05-10 11:13:39 +02:00
|
|
|
* @brief This values will always be written to the ADC conversion register to specify the
|
2021-05-03 11:59:33 +02:00
|
|
|
* conversions to perform.
|
|
|
|
* @details Bit0: 1 - Enables temperature conversion
|
2021-05-10 11:13:39 +02:00
|
|
|
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N
|
|
|
|
* Bit6 - Bit3 defines N: 0b0101 (N = 5)
|
2021-05-03 11:59:33 +02:00
|
|
|
* Bit7: Always 1. Tells the ADC that this is the conversion register.
|
|
|
|
*/
|
2021-05-10 11:13:39 +02:00
|
|
|
static const uint8_t CONVERSION = 0b10101001;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
2021-05-10 11:13:39 +02:00
|
|
|
/** Writing this value resets the fifo */
|
2021-05-07 18:48:42 +02:00
|
|
|
static const uint8_t RESET_FIFO = 0b00011000;
|
|
|
|
|
2021-05-06 18:00:58 +02:00
|
|
|
static const uint8_t DUMMY_BYTE = 0x0;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
2021-05-10 11:13:39 +02:00
|
|
|
static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS;
|
2021-05-09 16:48:55 +02:00
|
|
|
|
2021-05-10 11:13:39 +02:00
|
|
|
/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */
|
|
|
|
static const uint8_t SIZE_READ_CONVERSIONS = 14;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
2021-05-10 11:13:39 +02:00
|
|
|
static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS;
|
2021-05-06 18:00:58 +02:00
|
|
|
|
2021-05-09 16:48:55 +02:00
|
|
|
static const uint8_t POOL_ENTRIES = 7;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
2021-05-07 18:48:42 +02:00
|
|
|
|
2021-05-03 11:59:33 +02:00
|
|
|
enum Max1227PoolIds: lp_id_t {
|
|
|
|
TEMPERATURE_C,
|
2021-05-09 16:48:55 +02:00
|
|
|
AIN0,
|
|
|
|
AIN1,
|
|
|
|
AIN2,
|
|
|
|
AIN3,
|
|
|
|
AIN4,
|
|
|
|
AIN5,
|
2021-05-03 11:59:33 +02:00
|
|
|
};
|
|
|
|
|
2021-05-09 16:48:55 +02:00
|
|
|
class SusDataset: public StaticLocalDataSet<POOL_ENTRIES> {
|
2021-05-03 11:59:33 +02:00
|
|
|
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> temperatureCelcius = lp_var_t<float>(sid.objectId, TEMPERATURE_C, this);
|
2021-05-09 16:48:55 +02:00
|
|
|
lp_var_t<uint16_t> ain0 = lp_var_t<uint16_t>(sid.objectId, AIN0, this);
|
|
|
|
lp_var_t<uint16_t> ain1 = lp_var_t<uint16_t>(sid.objectId, AIN1, this);
|
|
|
|
lp_var_t<uint16_t> ain2 = lp_var_t<uint16_t>(sid.objectId, AIN2, this);
|
|
|
|
lp_var_t<uint16_t> ain3 = lp_var_t<uint16_t>(sid.objectId, AIN3, this);
|
|
|
|
lp_var_t<uint16_t> ain4 = lp_var_t<uint16_t>(sid.objectId, AIN4, this);
|
|
|
|
lp_var_t<uint16_t> ain5 = lp_var_t<uint16_t>(sid.objectId, AIN5, this);
|
2021-05-03 11:59:33 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */
|