Add MAX6675 sensor

This is basically a cut down version of MAX31855 without reference
temperature reading and lower resolution (only positive, 12bit only).

This implements 16bit protocol (31855 uses 32bit). SetOption94 enables
the new behavior.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* treat occasional 0xfff as an error
* do not add new sensor pins, use SetOption94 instead
This commit is contained in:
Alexey Kardashevskiy 2020-06-03 16:09:28 +10:00
parent 61b47e345d
commit 5558da527a
2 changed files with 15 additions and 1 deletions

View File

@ -113,7 +113,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t fade_at_startup : 1; // bit 9 (v8.2.0.3) - SetOption91 - Enable light fading at start/power on
uint32_t pwm_ct_mode : 1; // bit 10 (v8.2.0.4) - SetOption92 - Set PWM Mode from regular PWM to ColorTemp control (Xiaomi Philips ...)
uint32_t compress_rules_cpu : 1; // bit 11 (v8.2.0.6) - SetOption93 - Keep uncompressed rules in memory to avoid CPU load of uncompressing at each tick
uint32_t spare12 : 1;
uint32_t max6675 : 1; // bit 12 (v8.3.1.2) - SetOption94 - Implement simpler MAX6675 protocol instead of MAX31855
uint32_t spare13 : 1;
uint32_t spare14 : 1;
uint32_t spare15 : 1;

View File

@ -50,6 +50,20 @@ void MAX31855_Init(void){
* Acquires the raw data via SPI, checks for MAX31855 errors and fills result structure
*/
void MAX31855_GetResult(void){
// Controlled via SetOption94
if (Settings.flag4.max6675) {
int32_t RawData = MAX31855_ShiftIn(16);
int32_t temp = (RawData >> 3) & ((1 << 12) - 1);
/* Occasionally the sensor returns 0xfff, consider it an error */
if (temp == ((1 << 12) - 1))
return;
MAX31855_Result.ErrorCode = 0;
MAX31855_Result.ReferenceTemperature = NAN;
MAX31855_Result.ProbeTemperature = ConvertTemp(0.25 * temp);
return;
}
int32_t RawData = MAX31855_ShiftIn(32);
uint8_t probeerror = RawData & 0x7;