changed SusHandler MAX1227 to internal clock mode

This commit is contained in:
2021-05-10 11:13:39 +02:00
parent a6465c42ba
commit e1e69539ca
4 changed files with 52 additions and 90 deletions

View File

@ -11,55 +11,52 @@ 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;
static const DeviceCommandId_t READ_CHANNELS = 0x2;
static const DeviceCommandId_t READ_TEMPERATURE = 0x3;
static const DeviceCommandId_t REQUEST_TEMPERATURE = 0x4;
/**
* This command initiates the ADC conversion for all channels including the internal
* temperature sensor.
*/
static const DeviceCommandId_t START_CONVERSIONS = 0x2;
/**
* This command reads the internal fifo which holds the temperature and the channel
* conversions.
*/
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 byte is following the setup byte
* Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay
* Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b11, MAX1227 clocked through SPI SCLK
* Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register
* 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 const uint8_t SETUP_DEFINITION = 0b01111000;
static const uint8_t SETUP = 0b01101000;
/**
* @brief This value will always be written to the ADC conversion register to specify the
* @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): 0b11, No scan, converts channel N once only.
* Scanning is not supported in spi clock mode.
* Bit6 - Bit3 defines N: 0b0001 (N = 4)
* 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 CONVERT_TEMPERATURE = 0b10000001;
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;
static const uint8_t CONVERT_DIFF_CHANNEL_5 = 0b10101110;
static const uint8_t CONVERSION = 0b10101001;
/** Writing this value resets the fifo */
static const uint8_t RESET_FIFO = 0b00011000;
static const uint8_t DUMMY_BYTE = 0x0;
static const uint8_t SUS_DATA_SET_ID = READ_CHANNELS;
static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS;
/** Size of data replies */
static const uint8_t SIZE_READ_CHANNELS = 13;
static const uint8_t SIZE_READ_TEMPERATURE = 25;
/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */
static const uint8_t SIZE_READ_CONVERSIONS = 14;
static const uint8_t MAX_CMD_SIZE = SIZE_READ_TEMPERATURE;
static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS;
static const uint8_t POOL_ENTRIES = 7;