pull/2/head
Mateusz Lubecki 2021-04-15 18:50:28 +02:00
rodzic 2a7642606e
commit fba10b0b4a
19 zmienionych plików z 576 dodań i 231 usunięć

Wyświetl plik

@ -67,7 +67,7 @@ all: ParaTNC.elf secondary-outputs
ParaTNC.elf: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Cross ARM C++ Linker'
arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"ParaTNC.map" --specs=nano.specs -u _printf_float -fstack-usage -o "ParaTNC.elf" $(OBJS) $(USER_OBJS) $(LIBS)
arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"ParaTNC.map" --specs=nano.specs -u _printf_float -o "ParaTNC.elf" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

Wyświetl plik

@ -19,7 +19,8 @@ C_SRCS += \
../src/rte_pv.c \
../src/rte_rtu.c \
../src/rte_wx.c \
../src/wx_handler.c
../src/wx_handler.c \
../src/wx_handler_temperature.c
OBJS += \
./src/KissCommunication.o \
@ -37,7 +38,8 @@ OBJS += \
./src/rte_pv.o \
./src/rte_rtu.o \
./src/rte_wx.o \
./src/wx_handler.o
./src/wx_handler.o \
./src/wx_handler_temperature.o
C_DEPS += \
./src/KissCommunication.d \
@ -55,14 +57,15 @@ C_DEPS += \
./src/rte_pv.d \
./src/rte_rtu.d \
./src/rte_wx.d \
./src/wx_handler.d
./src/wx_handler.d \
./src/wx_handler_temperature.d
# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -47,7 +47,7 @@ C_DEPS += \
system/src/aprs/%.o: ../system/src/aprs/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -20,7 +20,7 @@ C_DEPS += \
system/src/cmsis/%.o: ../system/src/cmsis/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -23,7 +23,7 @@ C_DEPS += \
system/src/cortexm/%.o: ../system/src/cortexm/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -20,7 +20,7 @@ C_DEPS += \
system/src/davis_vantage/%.o: ../system/src/davis_vantage/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -20,7 +20,7 @@ C_DEPS += \
system/src/diag/%.o: ../system/src/diag/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -38,7 +38,7 @@ C_DEPS += \
system/src/drivers/%.o: ../system/src/drivers/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -26,7 +26,7 @@ C_DEPS += \
system/src/modbus_rtu/%.o: ../system/src/modbus_rtu/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -43,7 +43,7 @@ system/src/newlib/%.o: ../system/src/newlib/%.cpp
system/src/newlib/%.o: ../system/src/newlib/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -44,7 +44,7 @@ C_DEPS += \
system/src/stm32f1-stdperiph/%.o: ../system/src/stm32f1-stdperiph/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -26,7 +26,7 @@ C_DEPS += \
system/src/umb_master/%.o: ../system/src/umb_master/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -17,7 +17,7 @@ C_DEPS += \
system/src/ve_direct_protocol/%.o: ../system/src/ve_direct_protocol/%.c
@echo 'Building file: $<'
@echo 'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -g3 -DDEBUG -DTRACE -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include/aprs" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph" -std=gnu11 -Wunused-function -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Wyświetl plik

@ -0,0 +1,285 @@
/*
* config.h
*
* Created on: 03.07.2017
* Author: mateusz
*/
#ifndef STATION_CONFIG_H_
#define STATION_CONFIG_H_
/* ------------------ */
/* MODES OF OPERATION */
#define _METEO // Enable meteo station
#define _DIGI // Enable WIDE1-1 digipeater
//#define _DIGI_ONLY_789 // Limit digipeater to handle only -7, -8 and -9 SSIDs
//#define _VICTRON // Enable support for Victron VE.Direct protocol
/* MODES OF OPERATION */
/* ------------------ */
//#define PARATNC_HWREV_A
//#define PARATNC_HWREV_B
#define PARATNC_HWREV_C
/* ---------------------------- */
/* WEATHER/METEO CONFIGURATION */
// If none of those three sources are chosen (uncommented) the software will use internal sensors
//#define _UMB_MASTER
//#define _DAVIS_SERIAL
#define _MODBUS_RTU // use Modbus RTU slave devices as a external meteo data source. For more configuration
// (slave ids, registers...) please look into MODBUS RTU CONFIGURATION section of this file
#define _INTERNAL_AS_BACKUP // if defined ParaTNC will switch to internal sensors in case of
// the communication with UMB/Dallas Serial/Modbus external sensors will hang up
//#define _DALLAS_AS_TELEM // Use Dallas one-wire thermometer as a 5th telemetry channel
// May be used even if _METEO is not enabled
#define _DALLAS_SPLIT_PIN // Must be enabled for all ParaTNC hardware revisions
/******** INTERNAL SENSORS CONFIGURATION *****************/
//#define _ANEMOMETER_TX20 // Use TX20 as an internal anemometer
#define _ANEMOMETER_ANALOGUE // Use analogue/mechanical (like Davis 6410) as an internal anemometr
#define _ANEMOMETER_PULSES_IN_10SEC_PER_ONE_MS_OF_WINDSPEED 10
//#define _SENSOR_MS5611
#define _SENSOR_BME280
#define _UMB_SLAVE_ID 1
#define _UMB_SLAVE_CLASS 8
#define _UMB_CHANNEL_WINDSPEED 460
#define _UMB_CHANNEL_WINDGUSTS 440
#define _UMB_CHANNEL_WINDDIRECTION 580
#define _UMB_CHANNEL_TEMPERATURE 100
#define _UMB_CHANNEL_QFE 300
/******** INTERNAL SENSORS CONFIGURATION *****************/
/*************** DATA SOURCES CONFIG ***********************/
//#define _TEMPERATURE_INTERNAL
//#define _TEMPERATURE_UMB
//#define _TEMPERATURE_RTU
//#define _TEMPERATURE_DAVIS
//
//#define _PRESSURE_INTERNAL
//#define _PRESSURE_UMB
//#define _PRESSURE_RTU
//#define _PRESSURE_DAVIS
//
//#define _HUMIDITY_INTERNAL
//#define _HUMIDITY_UMB
//#define _HUMIDITY_RTU
//#define _HUMIDITY_DAVIS
//
//
//#define _WIND_INTERNAL
//#define _WIND_UMB
//#define _WIND_RTU
//#define _WIND_FULL_RTU
//#define _WIND_DAVIS
/*************** DATA SOURCES CONFIG ***********************/
/* WEATHER/METEO CONFIGURATION */
/* ---------------------------- */
//#define _MUTE_RF // TODO: Not yet implemented - This will make station RXonly and disable all data transmission
//#define _MUTE_OWN // TODO: Not yet implemented - This will disable all self-generated packets (wx, telemetry, beacon)
// and switch device to "pure" kiss TNC operation. Packets from PC will be transmitted normally.
// Coordines should be in APRS decimal format DDDMM.SS for Longitude and DDMM.SS for latitude
#define _CALL "SP8EBC"
#define _SSID 1
#define _LAT 4948.82
#define _LATNS 'N'
#define _LON 01903.50
#define _LONWE 'E'
#define _COMMENT "Set Your configuration in this file and rename to station_config.h"
// You can use only one of these below defines to choose symbol. Meteo data are are always transmitted with blue WX symbol
//#define _SYMBOL_DIGI // uncomment if you want digi symbol(green star with D inside)
#define _SYMBOL_WIDE1_DIGI // uncomment if you want 'little' digi symbol (green star with digit 1 overlaid)
//#define _SYMBOL_HOUSE // uncomment if you want house symbol
//#define _SYMBOL_RXIGATE // uncomment if you want rxigate symbol (black diamond with R)
//#define _SYMBOL_IGATE // uncomment if you want igate symol (black diamond with I)
// Or you can keep commented all symbol defines and choose custom one based on data from APRS symbols table
//#define _SYMBOL_F '/'
//#define _SYMBOL_S '#'
// Uncomment one of these two defines to choose what path You want. If you uncommend both of them or
// if you keep both commended path will be completely disabled. CALL-S>AKLPRZ:data
#define _WIDE1_PATH // CALL-S>AKLPRZ,WIDE1-1:data
//#define _WIDE21_PATH // CALL-S>AKLPRZ,WIDE2-1:data
// Comment this to disable beacon auto sending during startup (this can be risky if RF feedback occur)
//#define _BCN_ON_STARTUP
#define _WX_INTERVAL 4 // WX packet interval in minutes
#define _BCN_INTERVAL 45 // Own beacon interval in minutes
#define _PTT_PUSHPULL // Uncomment this if you want PTT line to work as Push-pull instead of Open Drain
#define _SERIAL_BAUDRATE 9600
// Transmitting delay
#define _DELAY_BASE 20 // * 50ms. For example setting 10 gives 500msec delay. Maximum value is 20
//#define _RANDOM_DELAY // adds random delay TO fixed time set by _DELAY_BASE. This additional time can be
// from 100ms up to 1 sec in 100ms steps. Values are drawn from samples going from ADC
// so it is better to use Unsquelched output in radio to provide much more randomness
//After waiting time declared above ParaTNC will check DCD (Data Carrier Detect) flag, which works as some
//kind of semaphore. If radio channel is not occupied by any other transmission TX will be keyed up immediately,
//otherwise software will wait for clear conditions.
// Few IMPORTANT hints about setting transmit delay properly.
//
// Transmit delay is key parameter to maintain RF network free from packet losses and collisions. If your station will be
// installed on tall object, without any other digi's close to it, you can set _DELAY_BASE to very low value and disable
// _RANDOM_DELAY. If you wanna rather auxiliary station, witch should only fill gap in RF coverage in small area, then
// _DELAY_BASE parameter should be not less than 12 (600msec), the smallest range the higher _DELAY_BASE should be.
// Additionally for gapfillers (auxiliary stations) _RANDOM_DELAY schould be enabled.
//
// This delay will ensure that while other station will be transmitting repeated packets from mobile, Yours will keep
// always quiet and won't jam RF network. This greatly improve DCD based access to channel. Various controllers uses
// various lenght of preamble, some of them produce signal which might be impossible to decode by ParaTNC, so DCD
// is only one part of effective multiaccess to medium.
/* ---------------------------- */
/* MODBUS RTU CONFIGURATION */
// scaling coefficients are used as follows
//
// A * x ^ 2 + B * x + C
// real value = ---------------------------
// D
//
// because of that D cannot be set to zero
#define _RTU_SLAVE_SPEED 9600u
#define _RTU_SLAVE_PARITY 0
#define _RTU_SLAVE_STOP_BITS 2
#define _RTU_SLAVE_ID_1 0x01
#define _RTU_SLAVE_FUNC_1 0x03
#define _RTU_SLAVE_ADDR_1 0x00
#define _RTU_SLAVE_LENGHT_1 0x01
#define _RTU_SLAVE_SCALING_A_1 0
#define _RTU_SLAVE_SCALING_B_1 1
#define _RTU_SLAVE_SCALING_C_1 0
#define _RTU_SLAVE_SCALING_D_1 10
#define _RTU_SLAVE_ID_2 0x01
#define _RTU_SLAVE_FUNC_2 0x03
#define _RTU_SLAVE_ADDR_2 0x01
//#define _RTU_SLAVE_LENGHT_2 0x01
#define _RTU_SLAVE_SCALING_A_2 0
#define _RTU_SLAVE_SCALING_B_2 1
#define _RTU_SLAVE_SCALING_C_2 0
#define _RTU_SLAVE_SCALING_D_2 1
#define _RTU_SLAVE_ID_3 0x01
#define _RTU_SLAVE_FUNC_3 0x03
#define _RTU_SLAVE_ADDR_3 0x02
//#define _RTU_SLAVE_LENGHT_3 0x01
#define _RTU_SLAVE_SCALING_A_3 0
#define _RTU_SLAVE_SCALING_B_3 1
#define _RTU_SLAVE_SCALING_C_3 0
#define _RTU_SLAVE_SCALING_D_3 1
#define _RTU_SLAVE_ID_4 0x01
#define _RTU_SLAVE_FUNC_4 0x03
#define _RTU_SLAVE_ADDR_4 0x03
//#define _RTU_SLAVE_LENGHT_4 0x01
#define _RTU_SLAVE_SCALING_A_4 0
#define _RTU_SLAVE_SCALING_B_4 1
#define _RTU_SLAVE_SCALING_C_4 0
#define _RTU_SLAVE_SCALING_D_4 1
#define _RTU_SLAVE_ID_5 0x00
#define _RTU_SLAVE_FUNC_5 0x00
#define _RTU_SLAVE_ADDR_5 0x03
//#define _RTU_SLAVE_LENGHT_4 0x01
#define _RTU_SLAVE_SCALING_A_5 0
#define _RTU_SLAVE_SCALING_B_5 1
#define _RTU_SLAVE_SCALING_C_5 0
#define _RTU_SLAVE_SCALING_D_5 1
#define _RTU_SLAVE_ID_6 0x00
#define _RTU_SLAVE_FUNC_6 0x00
#define _RTU_SLAVE_ADDR_6 0x00
//#define _RTU_SLAVE_LENGHT_4 0x01
#define _RTU_SLAVE_SCALING_A_6 0
#define _RTU_SLAVE_SCALING_B_6 1
#define _RTU_SLAVE_SCALING_C_6 0
#define _RTU_SLAVE_SCALING_D_6 1
//#define _RTU_SLAVE_TEMPERATURE_SOURCE 1
#define _RTU_SLAVE_HUMIDITY_SOURCE 2
//#define _RTU_SLAVE_PRESSURE_SOURCE 3
//#define _RTU_SLAVE_WIND_DIRECTION_SORUCE 4
//#define _RTU_SLAVE_WIND_SPEED_SOURCE 4
/* MODBUS RTU CONFIGURATION */
/* ---------------------------- */
// Do not touch this
#if defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F '/'
#define _SYMBOL_S '#'
#elif !defined (_SYMBOL_DIGI) && defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F '1'
#define _SYMBOL_S '#'
#elif !defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F '/'
#define _SYMBOL_S '-'
#elif !defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F 'I'
#define _SYMBOL_S '&'
#elif !defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
defined (_SYMBOL_IGATE)
#define _SYMBOL_F 'R'
#define _SYMBOL_S '&'
#elif !defined (_SYMBOL_F) && !defined (_SYMBOL_S)
#error "Missing symbol configuration in station_config.h"
#elif defined (_SYMBOL_F) && defined (_SYMBOL_S)
#else
#error "Wrong symbol configuration in station_config.h"
#endif
#if defined (_METEO) && !defined (_DIGI)
#define _DIGI
#endif
#if defined(PARATNC_HWREV_A) && (defined (_METEO) || defined (_DALLAS_AS_TELEM)) && !defined(_DALLAS_SPLIT_PIN)
#define _DALLAS_SPLIT_PIN
#endif
#if defined(PARATNC_HWREV_B) && (defined (_METEO) || defined (_DALLAS_AS_TELEM)) && !defined(_DALLAS_SPLIT_PIN)
#define _DALLAS_SPLIT_PIN
#endif
#if defined(_ANEMOMETER_TX20) && defined(_ANEMOMETER_ANALOGUE)
#error "You cannot use two anemometers at once!!!"
#endif
#if defined(_MOBUS_RTU) && defined(_DAVIS_SERIAL)
#error "You cannot use modbus RTU devices and Davis weather station at once!!!"
#endif
#if !defined(_ANEMOMETER_TX20) && !defined(_ANEMOMETER_ANALOGUE) && !defined(_UMB_MASTER) && defined(_METEO)
#define _ANEMOMETER_TX20
#endif
#endif /* STATION_CONFIG_H_ */

Wyświetl plik

@ -15,6 +15,12 @@
extern uint32_t wx_last_good_temperature_time;
extern uint32_t wx_last_good_wind_time;
#define WX_HANDLER_PARAMETER_RESULT_TEMPERATURE (1 << 1)
#define WX_HANDLER_PARAMETER_RESULT_PRESSURE (1 << 2)
#define WX_HANDLER_PARAMETER_RESULT_HUMIDITY (1 << 3)
#define WX_HANDLER_PARAMETER_RESULT_WIND (1 << 4)
#define WX_HANDLER_PARAMETER_RESULT_TEMP_INTERNAL (1 << 5)
typedef enum wx_pwr_state_t {
WX_PWR_OFF,
WX_PWR_ON,
@ -23,9 +29,8 @@ typedef enum wx_pwr_state_t {
}wx_pwr_state_t;
void wx_get_all_measurements(const config_data_wx_sources_t * const config_sources, const config_data_mode_t * const config_mode, const config_data_umb_t * const config_umb);
int32_t wx_get_dallas_temperature(void);
int32_t wx_get_bme280_temperature_pressure_humidity(float * const temperature, float * const pressure, int8_t * const humidity);
int32_t wx_get_ms5611_temperature(float * const temperature);
int32_t wx_get_ms5611_pressure(float * const pressure);
void wx_pool_anemometer(void);
void wx_pwr_init(void);

Wyświetl plik

@ -0,0 +1,18 @@
/*
* wx_handler_temperature.h
*
* Created on: Apr 14, 2021
* Author: mateusz
*/
#ifndef WX_HANDLER_TEMPERATURE_H_
#define WX_HANDLER_TEMPERATURE_H_
#include "config_data.h"
int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const config_sources, const config_data_mode_t * const config_mode, const config_data_umb_t * const config_umb);
int32_t wx_get_temperature_dallas(void);
int32_t wx_get_temperature_ms5611(float * const temperature);
int32_t wx_get_temperature_bme280();
#endif /* WX_HANDLER_TEMPERATURE_H_ */

Wyświetl plik

@ -28,12 +28,11 @@
#define WX_WATCHDOG_PERIOD (SYSTICK_TICKS_PER_SECONDS * SYSTICK_TICKS_PERIOD * 90)
#define WX_WATCHDOG_RESET_DURATION (SYSTICK_TICKS_PER_SECONDS * SYSTICK_TICKS_PERIOD * 3)
#define WX_MAX_TEMPERATURE_SLEW_RATE 4.0f
//#define WX_MAX_TEMPERATURE_SLEW_RATE 4.0f
uint32_t wx_last_good_temperature_time = 0;
uint32_t wx_last_good_wind_time = 0;
uint32_t wx_last_good_temperature_time = 0;
wx_pwr_state_t wx_pwr_state;
uint8_t wx_inhibit_slew_rate_check = 1;
uint32_t wx_wind_pool_call_counter = 0;
static const float direction_constant = M_PI/180.0f;
@ -46,12 +45,6 @@ static const float direction_constant = M_PI/180.0f;
#define MODBUS_QF_PRESSURE_FULL (1 << 5)
#define MODBUS_QF_PRESSURE_DEGR (1 << 6)
#define PARAMETER_RESULT_TEMPERATURE (1 << 1)
#define PARAMETER_RESULT_PRESSURE (1 << 2)
#define PARAMETER_RESULT_HUMIDITY (1 << 3)
#define PARAMETER_RESULT_WIND (1 << 4)
#define PARAMETER_RESULT_TEMP_INTERNAL (1 << 5)
void wx_get_all_measurements(const config_data_wx_sources_t * const config_sources, const config_data_mode_t * const config_mode, const config_data_umb_t * const config_umb) {
int32_t return_value = 0;
@ -62,134 +55,7 @@ void wx_get_all_measurements(const config_data_wx_sources_t * const config_sourc
int8_t modbus_qf = 0; // quality factor for Modbus-RTU communication
umb_qf_t umb_quality_factor = UMB_QF_UNITIALIZED; // wuality factor for UMB communication
// choose a temperature source from the configuration
switch(config_sources->temperature) {
// controller measures two temperatures
// internal - provided by pressure/humidity sensor on PCB
// external - usually dallas one wire but it might by something different
case WX_SOURCE_INTERNAL: {
// internal means sensors connected directly to the controller - one-wire and/or I2C on the PCB
// it has nothing to do with distinction between external and internal temperature
// check which sensor is configured. it doesn't check which one is
// in fact installed. if the configuration doesn't mach with hardware
// the measuremenet won't be retrieved
if (config_mode->wx_ms5611_or_bme == 1) {
// this will get all three parameters (humidity, pressure, internal temp) in single call
function_result = wx_get_bme280_temperature_pressure_humidity(&rte_wx_temperature_internal, &rte_wx_pressure, &rte_wx_humidity);
}
else {
// ms5611 is a bit different as the sensor (internal) temperature is collected separately from pressure
function_result = wx_get_ms5611_temperature(&rte_wx_temperature_internal);
}
// check if temperature from pressure sensor has been retrieved w/o errors
if (function_result == BME280_OK || function_result == MS5611_OK) {
// set the flag for internal temperature
parameter_result |= PARAMETER_RESULT_TEMP_INTERNAL;
// check which sensor is used once again
if (config_mode->wx_ms5611_or_bme == 1) {
// BME280 measures all three things at one call to the driver
parameter_result |= PARAMETER_RESULT_PRESSURE;
parameter_result |= PARAMETER_RESULT_HUMIDITY;
// always read the temperature as it is used as an internal temperature in 5th telemetry channel
rte_wx_temperature_internal_valid = rte_wx_temperature_external;
// set humidity
rte_wx_humidity_valid = rte_wx_humidity;
// add the current pressure into buffer for average calculation
rte_wx_pressure_history[rte_wx_pressure_it++] = rte_wx_pressure;
// reseting the average length iterator
j = 0;
// check if and end of the buffer was reached
if (rte_wx_pressure_it >= PRESSURE_AVERAGE_LN) {
rte_wx_pressure_it = 0;
}
// calculating the average of pressure measuremenets
for (i = 0; i < PRESSURE_AVERAGE_LN; i++) {
// skip empty slots in the history to provide proper value even for first wx packet
if (rte_wx_pressure_history[i] < 10.0f) {
continue;
}
// add to the average
pressure_average_sum += rte_wx_pressure_history[i];
// increase the average lenght iterator
j++;
}
rte_wx_pressure_valid = pressure_average_sum / (float)j;
}
else {
; // MS5611 measures pressure and temperature separately
}
}
// measure an external temperature using Dallas one wire sensor.
// 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.
function_result = wx_get_dallas_temperature();
// check if communication with dallas sensor has successed
if (function_result == 0) {
// if yes set the local variable with flag signalling that we have an external temperature
parameter_result |= PARAMETER_RESULT_TEMPERATURE;
}
break;
}
case WX_SOURCE_UMB: {
// get current UMB bus quality factor
umb_quality_factor = umb_get_current_qf(&rte_wx_umb_context, master_time);
// if there are any data collected from UMB sensors
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
rte_wx_temperature_average_external_valid = umb_get_temperature(config_umb);
// set the flag that external temperature is available
parameter_result |= PARAMETER_RESULT_TEMPERATURE;
}
else {
// do nothing if no new data was received from UMB sensor in last 10 minutes
;
}
break;
}
case WX_SOURCE_RTU:
case WX_SOURCE_FULL_RTU: {
// get the value read from RTU registers
function_result = rtu_get_temperature(rte_wx_temperature_external);
// check
if (function_result == MODBUS_RET_OK || function_result == MODBUS_RET_DEGRADED) {
// set the flag that external temperature is available
parameter_result |= PARAMETER_RESULT_TEMPERATURE;
}
break;
}
case WX_SOURCE_DAVIS_SERIAL:
break;
}
/**
*
@ -395,7 +261,7 @@ void wx_get_all_measurements(const config_data_wx_sources_t * const config_sourc
wx_get_dallas_temperature();
// enabling slew rate checking after first power up
wx_inhibit_slew_rate_check = 0;
//wx_inhibit_slew_rate_check = 0;
#endif
#if (!defined(_UMB_MASTER) && !defined(_DAVIS_SERIAL) && !defined(_MODBUS_RTU) && defined (_SENSOR_MS5611)) || (defined (_SENSOR_MS5611) && defined (_MODBUS_RTU))
@ -482,69 +348,7 @@ void wx_get_all_measurements(const config_data_wx_sources_t * const config_sourc
}
int32_t wx_get_dallas_temperature() {
int32_t output = 0;
// get the value from dallas one-wire sensor
rte_wx_temperature_external = dallas_query(&rte_wx_current_dallas_qf);
// checking if communication was successfull
if (rte_wx_temperature_external != -128.0f) {
// calculate the slew rate
rte_wx_temperature_external_slew_rate = rte_wx_temperature_external - rte_wx_temperature_external_valid;
// chcecking the positive (ascending) slew rate of the temperature measuremenets
if (rte_wx_temperature_external_slew_rate > WX_MAX_TEMPERATURE_SLEW_RATE && wx_inhibit_slew_rate_check == 0) {
// if temeperature measuremenet has changed more than maximum allowed slew rate set degradadet QF
rte_wx_error_dallas_qf = DALLAS_QF_DEGRADATED;
// and increase the temperature only by 1.0f to decrease slew rate
rte_wx_temperature_external += 1.0f;
}
// chcecking the negaive (descending) slew rate of the temperature measuremenets
if (rte_wx_temperature_external_slew_rate < -WX_MAX_TEMPERATURE_SLEW_RATE && wx_inhibit_slew_rate_check == 0) {
// if temeperature measuremenet has changed more than maximum allowed slew rate set degradadet QF
rte_wx_error_dallas_qf = DALLAS_QF_DEGRADATED;
// and decrease the temperature only by 1.0f to decrease slew rate
rte_wx_temperature_external -= 1.0f;
}
// store current value
rte_wx_temperature_external_valid = rte_wx_temperature_external;
// include current temperature into the average
dallas_average(rte_wx_temperature_external, &rte_wx_dallas_average);
// update the current temperature with current average
rte_wx_temperature_average_external_valid = dallas_get_average(&rte_wx_dallas_average);
// update current minimal temperature
rte_wx_temperature_min_external_valid = dallas_get_min(&rte_wx_dallas_average);
// and update maximum also
rte_wx_temperature_max_external_valid = dallas_get_max(&rte_wx_dallas_average);
// updating last good measurement time
wx_last_good_temperature_time = master_time;
}
else {
// if there were a communication error set the error to unavaliable
rte_wx_error_dallas_qf = DALLAS_QF_NOT_AVALIABLE;
// set the output value
output = -1;
}
return output;
}
int32_t wx_get_bme280_temperature_pressure_humidity(float * const temperature, float * const pressure, int8_t * const humidity) {
@ -581,14 +385,6 @@ int32_t wx_get_bme280_temperature_pressure_humidity(float * const temperature, f
return return_value;
}
int32_t wx_get_ms5611_temperature(float * const temperature) {
int32_t return_value = 0;
// quering MS5611 sensor for temperature
return_value = ms5611_get_temperature(&temperature, &rte_wx_ms5611_qf);
return return_value;
}
int32_t wx_get_ms5611_pressure(float * const pressure) {

Wyświetl plik

@ -0,0 +1,238 @@
/*
* wx_handler_temperature.c
*
* Created on: Apr 14, 2021
* Author: mateusz
*/
#include "wx_handler_temperature.h"
#include <rte_wx.h>
#include <wx_handler.h>
#include <main.h>
#include <drivers/dallas.h>
#include <drivers/ms5611.h>
#include <drivers/bme280.h>
#include <modbus_rtu/rtu_getters.h>
#include <modbus_rtu/rtu_return_values.h>
#define WX_MAX_TEMPERATURE_SLEW_RATE 4.0f
uint8_t wx_inhibit_slew_rate_check = 1;
int32_t wx_get_temperature_measurement(const config_data_wx_sources_t * const config_sources, const config_data_mode_t * const config_mode, const config_data_umb_t * const config_umb) {
int32_t function_result = -1; // used for return values from various functions
int8_t parameter_result = 0; // stores which parameters have been retrieved successfully. this is used for failsafe handling
umb_qf_t umb_quality_factor = UMB_QF_UNITIALIZED; // wuality factor for UMB communication
int32_t i = 0, j = 0;
// choose a temperature source from the configuration
switch(config_sources->temperature) {
// controller measures two temperatures
// internal - provided by pressure/humidity sensor on PCB
// external - usually dallas one wire but it might by something different
case WX_SOURCE_INTERNAL: {
// internal means sensors connected directly to the controller - one-wire and/or I2C on the PCB
// it has nothing to do with distinction between external and internal temperature
// check which sensor is configured. it doesn't check which one is
// in fact installed. if the configuration doesn't mach with hardware
// the measuremenet won't be retrieved
if (config_mode->wx_ms5611_or_bme == 1) {
// this will get all three parameters (humidity, pressure, internal temp) in single call
function_result = wx_get_bme280_temperature_pressure_humidity(&rte_wx_temperature_internal, &rte_wx_pressure, &rte_wx_humidity);
}
else {
// ms5611 is a bit different as the sensor (internal) temperature is collected separately from pressure
function_result = wx_get_ms5611_temperature(&rte_wx_temperature_internal);
}
// check if temperature from pressure sensor has been retrieved w/o errors
if (function_result == BME280_OK || function_result == MS5611_OK) {
// set the flag for internal temperature
parameter_result |= WX_HANDLER_PARAMETER_RESULT_TEMP_INTERNAL;
// check which sensor is used once again
if (config_mode->wx_ms5611_or_bme == 1) {
// BME280 measures all three things at one call to the driver
parameter_result |= WX_HANDLER_PARAMETER_RESULT_PRESSURE;
parameter_result |= WX_HANDLER_PARAMETER_RESULT_HUMIDITY;
// always read the temperature as it is used as an internal temperature in 5th telemetry channel
rte_wx_temperature_internal_valid = rte_wx_temperature_external;
// set humidity
rte_wx_humidity_valid = rte_wx_humidity;
// add the current pressure into buffer for average calculation
rte_wx_pressure_history[rte_wx_pressure_it++] = rte_wx_pressure;
// reseting the average length iterator
j = 0;
// check if and end of the buffer was reached
if (rte_wx_pressure_it >= PRESSURE_AVERAGE_LN) {
rte_wx_pressure_it = 0;
}
// calculating the average of pressure measuremenets
for (i = 0; i < PRESSURE_AVERAGE_LN; i++) {
// skip empty slots in the history to provide proper value even for first wx packet
if (rte_wx_pressure_history[i] < 10.0f) {
continue;
}
// add to the average
pressure_average_sum += rte_wx_pressure_history[i];
// increase the average lenght iterator
j++;
}
rte_wx_pressure_valid = pressure_average_sum / (float)j;
}
else {
; // MS5611 measures pressure and temperature separately
}
}
// measure an external temperature using Dallas one wire sensor.
// 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.
function_result = wx_get_dallas_temperature();
// check if communication with dallas sensor has successed
if (function_result == 0) {
// if yes set the local variable with flag signalling that we have an external temperature
parameter_result |= WX_HANDLER_PARAMETER_RESULT_TEMPERATURE;
}
break;
}
case WX_SOURCE_UMB: {
// get current UMB bus quality factor
umb_quality_factor = umb_get_current_qf(&rte_wx_umb_context, master_time);
// if there are any data collected from UMB sensors
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
rte_wx_temperature_average_external_valid = umb_get_temperature(config_umb);
// set the flag that external temperature is available
parameter_result |= WX_HANDLER_PARAMETER_RESULT_TEMPERATURE;
}
else {
// do nothing if no new data was received from UMB sensor in last 10 minutes
;
}
break;
}
case WX_SOURCE_RTU:
case WX_SOURCE_FULL_RTU: {
// get the value read from RTU registers
function_result = rtu_get_temperature(&rte_wx_temperature_external);
// check
if (function_result == MODBUS_RET_OK || function_result == MODBUS_RET_DEGRADED) {
// set the flag that external temperature is available
parameter_result |= WX_HANDLER_PARAMETER_RESULT_TEMPERATURE;
}
break;
}
case WX_SOURCE_DAVIS_SERIAL:
break;
}
return function_result;
}
int32_t wx_get_temperature_dallas() {
int32_t output = 0;
// get the value from dallas one-wire sensor
rte_wx_temperature_external = dallas_query(&rte_wx_current_dallas_qf);
// checking if communication was successfull
if (rte_wx_temperature_external != -128.0f) {
// calculate the slew rate
rte_wx_temperature_external_slew_rate = rte_wx_temperature_external - rte_wx_temperature_external_valid;
// chcecking the positive (ascending) slew rate of the temperature measuremenets
if (rte_wx_temperature_external_slew_rate > WX_MAX_TEMPERATURE_SLEW_RATE && wx_inhibit_slew_rate_check == 0) {
// if temeperature measuremenet has changed more than maximum allowed slew rate set degradadet QF
rte_wx_error_dallas_qf = DALLAS_QF_DEGRADATED;
// and increase the temperature only by 1.0f to decrease slew rate
rte_wx_temperature_external += 1.0f;
}
// chcecking the negaive (descending) slew rate of the temperature measuremenets
if (rte_wx_temperature_external_slew_rate < -WX_MAX_TEMPERATURE_SLEW_RATE && wx_inhibit_slew_rate_check == 0) {
// if temeperature measuremenet has changed more than maximum allowed slew rate set degradadet QF
rte_wx_error_dallas_qf = DALLAS_QF_DEGRADATED;
// and decrease the temperature only by 1.0f to decrease slew rate
rte_wx_temperature_external -= 1.0f;
}
// store current value
rte_wx_temperature_external_valid = rte_wx_temperature_external;
// include current temperature into the average
dallas_average(rte_wx_temperature_external, &rte_wx_dallas_average);
// update the current temperature with current average
rte_wx_temperature_average_external_valid = dallas_get_average(&rte_wx_dallas_average);
// update current minimal temperature
rte_wx_temperature_min_external_valid = dallas_get_min(&rte_wx_dallas_average);
// and update maximum also
rte_wx_temperature_max_external_valid = dallas_get_max(&rte_wx_dallas_average);
// updating last good measurement time
wx_last_good_temperature_time = master_time;
}
else {
// if there were a communication error set the error to unavaliable
rte_wx_error_dallas_qf = DALLAS_QF_NOT_AVALIABLE;
// set the output value
output = -1;
}
return output;
}
int32_t wx_get_temperature_ms5611(float * const temperature) {
int32_t return_value = 0;
// quering MS5611 sensor for temperature
return_value = ms5611_get_temperature(&temperature, &rte_wx_ms5611_qf);
return return_value;
}

Wyświetl plik

@ -157,38 +157,38 @@ int32_t rtu_serial_init(rtu_pool_queue_t* queue, uint8_t io_mode, srl_context_t*
//#ifdef _MODBUS_RTU
queue->function_id[0] =_RTU_SLAVE_FUNC_1;
queue->function_id[0] = config->slave_1_function;
queue->function_parameter[0] = &rte_wx_modbus_rtu_f1;
rte_wx_modbus_rtu_f1.slave_address = config->slave_1_bus_address;
rte_wx_modbus_rtu_f1.base_address = config->slave_1_register_address;
rte_wx_modbus_rtu_f1.number_of_registers = config->slave_1_lenght;
queue->function_id[1] =_RTU_SLAVE_FUNC_2;
queue->function_id[1] =config->slave_2_function;;
queue->function_parameter[1] = &rte_wx_modbus_rtu_f2;
rte_wx_modbus_rtu_f2.slave_address = config->slave_2_bus_address;
rte_wx_modbus_rtu_f2.base_address = config->slave_2_register_address;
rte_wx_modbus_rtu_f2.number_of_registers = config->slave_2_lenght;
queue->function_id[2] =_RTU_SLAVE_FUNC_3;
queue->function_id[2] =config->slave_3_function;;
queue->function_parameter[2] = &rte_wx_modbus_rtu_f3;
rte_wx_modbus_rtu_f3.slave_address = config->slave_3_bus_address;
rte_wx_modbus_rtu_f3.base_address = config->slave_3_register_address;
rte_wx_modbus_rtu_f3.number_of_registers = config->slave_3_lenght;
queue->function_id[3] =_RTU_SLAVE_FUNC_4;
queue->function_id[3] =config->slave_4_function;;
queue->function_parameter[3] = &rte_wx_modbus_rtu_f4;
rte_wx_modbus_rtu_f4.slave_address = config->slave_4_bus_address;
rte_wx_modbus_rtu_f4.base_address = config->slave_4_register_address;
rte_wx_modbus_rtu_f4.number_of_registers = config->slave_4_lenght;
queue->function_id[4] =_RTU_SLAVE_FUNC_5;
queue->function_id[4] =config->slave_5_function;;
queue->function_parameter[4] = &rte_wx_modbus_rtu_f5;
rte_wx_modbus_rtu_f5.slave_address = config->slave_5_bus_address;
rte_wx_modbus_rtu_f5.base_address = config->slave_5_register_address;
rte_wx_modbus_rtu_f5.number_of_registers = config->slave_5_lenght;
queue->function_id[5] =_RTU_SLAVE_FUNC_6;
queue->function_id[5] =config->slave_6_function;;
queue->function_parameter[5] = &rte_wx_modbus_rtu_f6;
rte_wx_modbus_rtu_f6.slave_address = config->slave_6_bus_address;
rte_wx_modbus_rtu_f6.base_address = config->slave_6_register_address;