diff --git a/max31865.c b/max31865.c --- a/max31865.c +++ b/max31865.c @@ -89,14 +89,17 @@ void max31865_readtemp(SPI_HandleTypeDef // Release CS HAL_GPIO_WritePin(MAX_CS, 1); - status->error_code = data[0]; - - HAL_Delay(400); // FIXME: remove? - status->state_resume = status->state; - status->state = STATE_TC_ERROR; - status->temp = 0; - status->temp_frac = 0; - + // check to see if it's an error we care about + if(data[0] & 0b00111100) { + status->error_code = data[0]; + status->state_resume = status->state; + status->state = STATE_TC_ERROR; + status->temp = 0; + status->temp_frac = 0; + } + else { + max31865_clear_errors(spi_get()); + } } else { @@ -107,7 +110,7 @@ void max31865_readtemp(SPI_HandleTypeDef //convert adc to resistance //Rrtd = adc / range * Rref - status->temp = (int32_t) adc_count * 48600L; + status->temp = (int32_t) adc_count * 40200L; status->temp /= 32768L; //resistance to temp //(x - in1) * (cal2 - cal1) / (in2 - in1) + cal1 @@ -127,7 +130,7 @@ void max31865_readtemp(SPI_HandleTypeDef //convert adc to resistance //Rrtd = adc / range * Rref - status->temp = (int32_t) adc_count * 48600L; + status->temp = (int32_t) adc_count * 40200L; status->temp /= 32768L; //resistance to temp //(x - in1) * (cal2 - cal1) / (in2 - in1) + cal1