2021-05-03 11:59:33 +02:00
|
|
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_
|
|
|
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_
|
|
|
|
|
|
|
|
namespace SUS {
|
|
|
|
|
|
|
|
static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This command initiates the ADC conversion for all channels including the internal
|
|
|
|
* temperature sensor.
|
|
|
|
*/
|
|
|
|
static const DeviceCommandId_t WRITE_SETUP = 0x1;
|
2021-05-06 18:00:58 +02:00
|
|
|
static const DeviceCommandId_t PERFORM_CONVERSIONS = 0x2;
|
|
|
|
static const DeviceCommandId_t READ_TEMP = 0x3;
|
2021-05-08 22:49:21 +02:00
|
|
|
static const DeviceCommandId_t RQUEST_TEMP = 0x4;
|
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-09 14:39:56 +02:00
|
|
|
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay
|
2021-05-06 18:00:58 +02:00
|
|
|
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b11, MAX1227 clocked through SPI SCLK
|
2021-05-03 11:59:33 +02:00
|
|
|
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
|
|
|
|
*
|
|
|
|
*/
|
2021-05-09 10:06:36 +02:00
|
|
|
static const uint8_t SETUP_DEFINITION = 0b01111000;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This value will always be written to the ADC conversion register to specify the
|
|
|
|
* conversions to perform.
|
|
|
|
* @details Bit0: 1 - Enables temperature conversion
|
2021-05-06 18:00:58 +02:00
|
|
|
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b11, No scan, converts channel N once only.
|
|
|
|
* Scanning is not supported in spi clock mode.
|
2021-05-03 11:59:33 +02:00
|
|
|
* Bit6 - Bit3 defines N: 0b0001 (N = 4)
|
|
|
|
* Bit7: Always 1. Tells the ADC that this is the conversion register.
|
|
|
|
*/
|
2021-05-07 18:48:42 +02:00
|
|
|
static const uint8_t CONVERT_TEMPERATURE = 0b10000001;
|
2021-05-08 22:49:21 +02:00
|
|
|
static const uint8_t CONVERT_DIFF_CHANNEL_0 = 0b10000110;
|
|
|
|
static const uint8_t CONVERT_DIFF_CHANNEL_1 = 0b10001110;
|
|
|
|
static const uint8_t CONVERT_DIFF_CHANNEL_2 = 0b10010110;
|
|
|
|
static const uint8_t CONVERT_DIFF_CHANNEL_3 = 0b10011110;
|
|
|
|
static const uint8_t CONVERT_DIFF_CHANNEL_4 = 0b10100110;
|
2021-05-09 14:39:56 +02:00
|
|
|
static const uint8_t CONVERT_DIFF_CHANNEL_5 = 0b10101110;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
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-06 18:00:58 +02:00
|
|
|
static const uint8_t SUS_DATA_SET_ID = PERFORM_CONVERSIONS;
|
2021-05-03 11:59:33 +02:00
|
|
|
|
2021-05-06 18:00:58 +02:00
|
|
|
static const uint8_t SIZE_PERFORM_CONVERSIONS = 34;
|
|
|
|
|
|
|
|
static const uint8_t MAX_CMD_SIZE = SIZE_PERFORM_CONVERSIONS;
|
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,
|
|
|
|
DIFF_SCAN_CHANNEL_0_1,
|
|
|
|
DIFF_SCAN_CHANNEL_2_3,
|
|
|
|
DIFF_SCAN_CHANNEL_4_5,
|
|
|
|
};
|
|
|
|
|
|
|
|
class SusDataset: public StaticLocalDataSet<sizeof(float)> {
|
|
|
|
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);
|
|
|
|
lp_var_t<uint16_t> diffScanChannel0_1 = lp_var_t<uint16_t>(sid.objectId, DIFF_SCAN_CHANNEL_0_1, this);
|
|
|
|
lp_var_t<uint16_t> diffScanChannel2_3 = lp_var_t<uint16_t>(sid.objectId, DIFF_SCAN_CHANNEL_2_3, this);
|
|
|
|
lp_var_t<uint16_t> diffScanChannel4_5 = lp_var_t<uint16_t>(sid.objectId, DIFF_SCAN_CHANNEL_4_5, this);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */
|