#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ namespace RAD_SENSOR { 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; static const DeviceCommandId_t START_CONVERSION = 0x2; static const DeviceCommandId_t READ_CONVERSIONS = 0x3; /** * @brief This is the configuration byte which will be written to the setup register after * power on. * * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b01, external reference single ended * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register * */ static const uint8_t SETUP_DEFINITION = 0b01101000; /** * @brief This value 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 (channel conversion from 0 to N) * Bit6 - Bit3 defines N: 0b0001 (N = 1) * Bit7: Always 1. Tells the ADC that this is the conversion register. */ static const uint8_t CONVERSION_DEFINITION = 0b10001001; /** * @brief Writing this value resets the fifo of the MAX1227. */ static const uint8_t RESET_DEFINITION = 0b00011000; static const uint8_t DUMMY_BYTE = 0xFF; static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; /** * One temperature value, conversion of channel 0 and conversion of channel 1 */ static const uint8_t READ_SIZE = 6; enum Max1227PoolIds: lp_id_t { TEMPERATURE_C, CHANNEL_0, CHANNEL_1, }; class RadSensorDataset: public StaticLocalDataSet { public: RadSensorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) { } RadSensorDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) { } lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); lp_var_t channel0 = lp_var_t(sid.objectId, CHANNEL_0, this); lp_var_t channel1 = lp_var_t(sid.objectId, CHANNEL_1, this); }; } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */