kopia lustrzana https://github.com/SP8EBC/ParaTNC
temperature measurement handling refactored (probably)
rodzic
be29dcb740
commit
5b1173106a
|
@ -23,6 +23,7 @@ RM := rm -rf
|
|||
-include system/src/cortexm/subdir.mk
|
||||
-include system/src/cmsis/subdir.mk
|
||||
-include system/src/aprs/subdir.mk
|
||||
-include system/src/subdir.mk
|
||||
-include src/subdir.mk
|
||||
-include subdir.mk
|
||||
-include objects.mk
|
||||
|
|
|
@ -31,6 +31,7 @@ src \
|
|||
system/src/aprs \
|
||||
system/src/cmsis \
|
||||
system/src/cortexm \
|
||||
system/src \
|
||||
system/src/davis_vantage \
|
||||
system/src/diag \
|
||||
system/src/drivers \
|
||||
|
|
|
@ -12,7 +12,6 @@ C_SRCS += \
|
|||
../src/config_data_first.c \
|
||||
../src/config_data_second.c \
|
||||
../src/configuration_handler.c \
|
||||
../src/crc_.c \
|
||||
../src/delay.c \
|
||||
../src/dummy.c \
|
||||
../src/float_to_string.c \
|
||||
|
@ -42,7 +41,6 @@ OBJS += \
|
|||
./src/config_data_first.o \
|
||||
./src/config_data_second.o \
|
||||
./src/configuration_handler.o \
|
||||
./src/crc_.o \
|
||||
./src/delay.o \
|
||||
./src/dummy.o \
|
||||
./src/float_to_string.o \
|
||||
|
@ -72,7 +70,6 @@ C_DEPS += \
|
|||
./src/config_data_first.d \
|
||||
./src/config_data_second.d \
|
||||
./src/configuration_handler.d \
|
||||
./src/crc_.d \
|
||||
./src/delay.d \
|
||||
./src/dummy.d \
|
||||
./src/float_to_string.d \
|
||||
|
|
|
@ -8,7 +8,6 @@ C_SRCS += \
|
|||
../system/src/drivers/bme280.c \
|
||||
../system/src/drivers/dallas.c \
|
||||
../system/src/drivers/dma_helper_functions.c \
|
||||
../system/src/drivers/max31865.c \
|
||||
../system/src/drivers/ms5611.c
|
||||
|
||||
OBJS += \
|
||||
|
@ -16,7 +15,6 @@ OBJS += \
|
|||
./system/src/drivers/bme280.o \
|
||||
./system/src/drivers/dallas.o \
|
||||
./system/src/drivers/dma_helper_functions.o \
|
||||
./system/src/drivers/max31865.o \
|
||||
./system/src/drivers/ms5611.o
|
||||
|
||||
C_DEPS += \
|
||||
|
@ -24,7 +22,6 @@ C_DEPS += \
|
|||
./system/src/drivers/bme280.d \
|
||||
./system/src/drivers/dallas.d \
|
||||
./system/src/drivers/dma_helper_functions.d \
|
||||
./system/src/drivers/max31865.d \
|
||||
./system/src/drivers/ms5611.d
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ typedef struct __attribute__((aligned (4))) config_data_mode_t {
|
|||
/**
|
||||
* 0x00 or 0xFF - PT sensor disabled
|
||||
* bit0 - enabled / disabled
|
||||
* bit1 - PT100 (0) or PT1000 (1)
|
||||
* bit1 - PT100 (1) or PT1000 (0)
|
||||
* bit2 through bit7 - resistor value from lookup table
|
||||
* */
|
||||
uint8_t wx_pt_sensor;
|
||||
|
|
|
@ -73,7 +73,7 @@ const config_data_mode_t __attribute__((section(".config_section_default.mode"))
|
|||
.wx_umb = 0,
|
||||
#endif
|
||||
|
||||
.wx_pt_sensor = 0x77, // TODO:
|
||||
.wx_pt_sensor = 0x71, // TODO:
|
||||
|
||||
#ifdef _DUST_SDS011_SERIAL
|
||||
.wx_dust_sensor = WX_DUST_SDS011_SERIAL,
|
||||
|
@ -226,7 +226,9 @@ const config_data_wx_sources_t __attribute__((section(".config_section_default.s
|
|||
#ifdef _TEMPERATURE_DAVIS
|
||||
.temperature = WX_SOURCE_DAVIS_SERIAL,
|
||||
#endif
|
||||
|
||||
#ifdef _TEMPERATURE_INTERNAL_PT100
|
||||
.temperature = WX_SOURCE_INTERNAL_PT100,
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _PRESSURE_INTERNAL
|
||||
|
|
|
@ -1431,8 +1431,9 @@ int main(int argc, char* argv[]){
|
|||
|
||||
wx_check_force_i2c_reset();
|
||||
|
||||
#ifdef STM32L471xx
|
||||
max31865_pool();
|
||||
|
||||
#endif
|
||||
#ifdef INTERNAL_WATCHDOG
|
||||
IWDG_ReloadCounter();
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,8 @@ int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const co
|
|||
umb_qf_t umb_quality_factor = UMB_QF_UNITIALIZED; // wuality factor for UMB communication
|
||||
int16_t temp = 0;
|
||||
|
||||
float temperature = 0.0f;
|
||||
|
||||
// choose main temperature source from the configuration. main sensor is something which is used to send data though aprs
|
||||
switch(config_sources->temperature) {
|
||||
// controller measures two temperatures
|
||||
|
@ -67,21 +69,21 @@ int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const co
|
|||
// this function has blockin I/O which also adds a delay required by MS5611
|
||||
// sensor to finish data acquisition after the pressure measurement
|
||||
// is triggered.
|
||||
measurement_result = wx_get_temperature_dallas();
|
||||
wx_get_temperature_dallas();
|
||||
|
||||
#ifdef STM32L471xx
|
||||
// measure temperature from PT100 sensor if it is selected as main temperature sensor
|
||||
// (main means sensor which is used to send WX packets)
|
||||
if (config_sources->temperature == WX_SOURCE_INTERNAL_PT100 && max31865_get_qf() == MAX_QF_FULL) {
|
||||
*output = (float)rte_wx_temperature_average_pt / 10.0f;
|
||||
temperature = (float)rte_wx_temperature_average_pt / 10.0f;
|
||||
|
||||
parameter_result = parameter_result | WX_HANDLER_PARAMETER_RESULT_TEMPERATURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (config_sources->temperature == WX_SOURCE_INTERNAL && rte_wx_current_dallas_qf != DALLAS_QF_NOT_AVALIABLE) {
|
||||
*output = float_get_average(&rte_wx_dallas_average);
|
||||
}
|
||||
temperature = float_get_average(&rte_wx_dallas_average);
|
||||
|
||||
// check if communication with dallas sensor has successed
|
||||
if (measurement_result == 0) {
|
||||
// if yes set the local variable with flag signalling that we have an external temperature
|
||||
parameter_result = parameter_result | WX_HANDLER_PARAMETER_RESULT_TEMPERATURE;
|
||||
}
|
||||
|
||||
|
@ -95,7 +97,7 @@ int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const co
|
|||
if (umb_quality_factor == UMB_QF_FULL || umb_quality_factor == UMB_QF_DEGRADED) {
|
||||
|
||||
// get the average temperature directly, there is no need for any further processing
|
||||
*output = umb_get_temperature(config_umb);
|
||||
temperature = umb_get_temperature(config_umb);
|
||||
|
||||
// set the flag that external temperature is available
|
||||
parameter_result = parameter_result | WX_HANDLER_PARAMETER_RESULT_TEMPERATURE;
|
||||
|
@ -113,7 +115,7 @@ int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const co
|
|||
// get the value read from RTU registers
|
||||
measurement_result = rtu_get_temperature(&temp, config_rtu);
|
||||
|
||||
*output = (float)temp / 10.0f;
|
||||
temperature = (float)temp / 10.0f;
|
||||
|
||||
// check
|
||||
if (measurement_result == MODBUS_RET_OK || measurement_result == MODBUS_RET_DEGRADED) {
|
||||
|
@ -129,6 +131,10 @@ int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const co
|
|||
|
||||
}
|
||||
|
||||
if ((parameter_result & WX_HANDLER_PARAMETER_RESULT_TEMPERATURE) != 0) {
|
||||
*output = temperature;
|
||||
}
|
||||
|
||||
//#if defined(STM32L471xx)
|
||||
// // get modbus temperature reading regardless if it has been chosen as main
|
||||
// if (config_mode->wx_modbus == 1) {
|
||||
|
|
|
@ -326,8 +326,13 @@ void max31865_pool(void) {
|
|||
|
||||
max31865_raw_result = max31865_raw_result >> 1;
|
||||
|
||||
rte_wx_temperature_average_pt = max31865_get_pt100_result(0);
|
||||
// test = max31865_get_result(100);
|
||||
// rte_wx_temperature_average_pt = max31865_get_pt100_result(0);
|
||||
if (max31865_rdt_sensor_type == 0) {
|
||||
rte_wx_temperature_average_pt = max31865_get_result(1000);
|
||||
}
|
||||
else {
|
||||
rte_wx_temperature_average_pt = max31865_get_result(100);
|
||||
}
|
||||
|
||||
max31865_quality_factor = MAX_QF_FULL;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue