save before implementing SusHandler with chip select

This commit is contained in:
2021-05-06 18:00:58 +02:00
parent 80b32331c9
commit 931c17e971
8 changed files with 246 additions and 140 deletions

View File

@ -10,8 +10,8 @@ namespace SUS {
* temperature sensor.
*/
static const DeviceCommandId_t WRITE_SETUP = 0x1;
static const DeviceCommandId_t START_CONVERSION = 0x2;
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
static const DeviceCommandId_t PERFORM_CONVERSIONS = 0x2;
static const DeviceCommandId_t READ_TEMP = 0x3;
/**
* @brief This is the configuration byte which will be written to the setup register after
@ -19,12 +19,15 @@ namespace SUS {
*
* @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b10, following byte will be written to the
* unipolar register to perform differential conversion
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b11, external reference differential (AIN6 is REF-)
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference differential (AIN6 is REF-)
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b11, MAX1227 clocked through SPI SCLK
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
*
*/
static const uint8_t SETUP_DEFINITION = 0b01101110;
// static const uint8_t SETUP_DEFINITION = 0b0111110;
// Internal reference 0b10
static const uint8_t SETUP_DEFINITION = 0b0111010;
/**
* @brief This byte will be written to the unipolar register
@ -38,21 +41,24 @@ namespace SUS {
* @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)
* Bit2 (SCAN1) and Bit1 (SCAN0): 0b11, No scan, converts channel N once only.
* Scanning is not supported in spi clock mode.
* Bit6 - Bit3 defines N: 0b0001 (N = 4)
* Bit7: Always 1. Tells the ADC that this is the conversion register.
*/
static const uint8_t CONVERSION_DEFINITION = 0b10100001;
// static const uint8_t CONVERT_TEMPERATURE = 0b10000111;
static const uint8_t CONVERT_TEMPERATURE = 0b10000110;
static const uint8_t CONVERT_DIFF_CHANNEL_0_1 = 0b10000110;
static const uint8_t CONVERT_DIFF_CHANNEL_2_3 = 0b10010110;
static const uint8_t CONVERT_DIFF_CHANNEL_4_5 = 0b10100110;
static const uint8_t DUMMY_BYTE = 0xFF;
static const uint8_t DUMMY_BYTE = 0x0;
static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS;
static const uint8_t SUS_DATA_SET_ID = PERFORM_CONVERSIONS;
/**
* One temperature value, one differential conversion for channels 0/1, one for channels 2/3 and
* one for channels 3/4
*/
static const uint8_t READ_SIZE = 8;
static const uint8_t SIZE_PERFORM_CONVERSIONS = 34;
static const uint8_t MAX_CMD_SIZE = SIZE_PERFORM_CONVERSIONS;
enum Max1227PoolIds: lp_id_t {
TEMPERATURE_C,