Merge branch 'master' into EA_series_development

pull/2/head
SP8EBC 2021-05-26 21:40:12 +02:00 zatwierdzone przez GitHub
commit 3a556c282b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
12 zmienionych plików z 425 dodań i 65 usunięć

16
README
Wyświetl plik

@ -1,7 +1,17 @@
ParaTNC version DF03, June 25th 2020
ParaTNC version DF15, April 4th 2021
-----------------------------------------
// Please look into 'doc' directory for more documentation and user manuals
// WARNING: This readme could be sligtly outdated due to my lack of time :)
// Ongoing changes
// ---------------
// Currently intense refactoring is done, which will result in new main software version EA00.
// EA00 will remove the support for any Hardware Revision before HW-RevC, so it won't work on STM32VLDISCOVERY
// anymore. Conditional compilation will be removed, so EA00 and all consecutive version will be build as
// one binary with support to everything. The configuration will be kept in Flash memory and could be
// altered 'on the fly' by using some external (not yet started) software tool, without a need to recompile
// and reflash the controller.
1. INTRODUCTION
ParaTNC is a hardware and a software which offers the functionality of multi function APRS controler.
@ -67,16 +77,20 @@ ParaTNC software and hardware are licensed under terms included to the source co
- Davis 6410 or any another analogue anemometer with resisntance as a direction output and impulses as a windspeed
WARNING: Not avaliable in Hardware Revision A due to lack of circuitry. Fully working only in HW-Rev C
- Lufft V200A/Ventus or any other UMB compatible device.
- Any Modbus-RTU sensor
b) Pressure Sensors:
- MS5611
- Bosh BMP280
- Any UMB protocol compatible device
- Any Modbus-RTU sensor
c) Temperature sensors:
- Dallas One wire DS18B20
- Any UMB protocol compatible device
- Any Modbus-RTU sensor
d) Humidity Sensors:
- DHT22
- Bosh BMP280
- Any Modbus-RTU sensor (F&F MB-AHT1 is recommended)
6. SUPPORTED FEATURES OD VE.Direct PROTOCOL

Wyświetl plik

@ -14,6 +14,8 @@
#define INTERNAL_WATCHDOG
#define EXTERNAL_WATCHDOG
#define PWR_SWITCH_BOTH
#define OWN_APRS_MSG_LN 160
extern uint32_t master_time;

Wyświetl plik

@ -16,13 +16,14 @@
//#define _DIGI_ONLY_789 // Limit digipeater to handle only -7, -8 and -9 SSIDs
//#define _VICTRON // Enable support for Victron VE.Direct protocol
//#define _UMB_MASTER
//#define _MODBUS_RTU
/* MODES OF OPERATION */
/* ------------------ */
//#define PARATNC_HWREV_A
#define PARATNC_HWREV_B
//#define PARATNC_HWREV_C
//#define PARATNC_HWREV_B
#define PARATNC_HWREV_C
/* ---------------------------- */
/* WEATHER/METEO CONFIGURATION */
@ -30,12 +31,12 @@
//#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
#define _ANEMOMETER_TX20
//#define _ANEMOMETER_ANALOGUE
//#define _ANEMOMETER_TX20
#define _ANEMOMETER_ANALOGUE
#define _ANEMOMETER_PULSES_IN_10SEC_PER_ONE_MS_OF_WINDSPEED 10
#define _SENSOR_MS5611
//#define _SENSOR_BME280
//#define _SENSOR_MS5611
#define _SENSOR_BME280
#define _UMB_SLAVE_ID 1
#define _UMB_SLAVE_CLASS 8
@ -54,8 +55,8 @@
// Coordines should be in APRS decimal format DDDMM.SS for Longitude and DDMM.SS for latitude
#define _CALL "SR9NSK"
#define _SSID 2
#define _LAT 4941.10
#define _SSID 1
#define _LAT 4941.15
#define _LATNS 'N'
#define _LON 01901.90
#define _LONWE 'E'
@ -109,6 +110,66 @@
// 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 0x04
#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_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)

Wyświetl plik

@ -75,13 +75,13 @@
// 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
#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 3 // WX packet interval in minutes
#define _BCN_INTERVAL 34 // Own beacon interval in minutes
#define _WX_INTERVAL 4 // WX packet interval in minutes
#define _BCN_INTERVAL 44 // 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

Wyświetl plik

@ -0,0 +1,239 @@
/*
* 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 *****************/
/* 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 "SR9WXL"
#define _SSID 0
#define _LAT 4947.70
#define _LATNS 'N'
#define _LON 01926.80
#define _LONWE 'E'
#define _COMMENT "DigiW1 + WX = TXPower 2W = Stacja GOPR Leskowiec = sp8ebc@interia.pl"
// 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 25 // 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 2 // * 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 0x04
#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_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

@ -11,7 +11,6 @@
#include <stdint.h>
#include "config_data.h"
extern uint32_t wx_last_good_temperature_time;
extern uint32_t wx_last_good_wind_time;
@ -30,14 +29,15 @@ typedef enum 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, const config_data_rtu_t * const config_rtu);
int32_t wx_get_bme280_temperature_pressure_humidity(float * const temperature, float * const pressure, int8_t * const humidity);
void wx_pool_anemometer(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, const config_data_rtu_t * const config_rtu);
void wx_check_force_i2c_reset(void);
void wx_pwr_init(void);
void wx_pwr_periodic_handle(void);
void wx_pwr_disable_12v_sw(void);
void wx_pwr_disable_5v_isol(void);
void wx_pwr_enable_12v_sw(void);
void wx_pwr_enable_5v_isol(void);
//void wx_pwr_disable_12v_sw(void);
//void wx_pwr_disable_5v_isol(void);
//void wx_pwr_enable_12v_sw(void);
//void wx_pwr_enable_5v_isol(void);
#endif /* WX_HANDLER_H_ */

Wyświetl plik

@ -382,6 +382,9 @@ int main(int argc, char* argv[]){
#endif
// initalizing separated Open Collector output
io_oc_init();
// initialize sensor power control and switch off supply voltage
wx_pwr_init();
@ -529,7 +532,7 @@ int main(int argc, char* argv[]){
IWDG_Enable();
// do not disable the watchdog when the core is halted on a breakpoint
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // TODO
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE);
// reload watchdog counter
IWDG_ReloadCounter();
@ -543,9 +546,6 @@ int main(int argc, char* argv[]){
// initialize GPIO pins leds are connecting to
led_init();
// initalizing separated Open Collector output
io_oc_init();
// initialize AX25 & APRS stuff
AFSK_Init(&main_afsk);
ax25_init(&main_ax25, &main_afsk, 0, 0x00);
@ -918,6 +918,8 @@ int main(int argc, char* argv[]){
if (main_two_second_pool_timer < 10) {
wx_check_force_i2c_reset();
wx_pwr_periodic_handle();
#ifdef INTERNAL_WATCHDOG

Wyświetl plik

@ -12,6 +12,8 @@
#include "./umb_master/umb_master.h"
#include "./modbus_rtu/rtu_configuration.h"
#include "main.h"
#include "delay.h"
@ -124,6 +126,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
packet_tx_telemetry_descr_counter >= packet_tx_modbus_raw_values)
{
packet_tx_multi_per_call_handler();
telemetry_send_status_raw_values_modbus();
@ -141,6 +144,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
}
}
// check if Victron VE.Direct serial protocol client is enabled and it is
// a time to send the status message
if (config_mode->victron == 1 &&
@ -269,6 +273,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
// if _DALLAS_AS_TELEM will be enabled the fifth channel will be set to temperature measured by DS12B20
//telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, rte_wx_temperature_dallas_valid, dallas_qf, rte_wx_ms5611_qf, rte_wx_dht_valid.qf, rte_wx_umb_qf);
if (config_mode->wx == 1) {
// if _METEO will be enabled, but without _DALLAS_AS_TELEM the fifth channel will be used to transmit temperature from MS5611
// which may be treated then as 'rack/cabinet internal temperature'. Dallas DS12B10 will be used for ragular WX frames
telemetry_send_values(rx10m, tx10m, digi10m, kiss10m, rte_wx_temperature_internal_valid, dallas_qf, pressure_qf, humidity_qf, wind_qf);
@ -291,6 +296,11 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
if (config_mode->victron == 1) {
telemetry_send_chns_description_pv(&config_basic);
if (rte_pv_battery_voltage == 0) {
rte_main_reboot_req = 1;
}
//telemetry_send_status_pv(&rte_pv_average, &rte_pv_last_error, rte_pv_struct.system_state);
}
else {
@ -305,6 +315,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
if (config_mode->wx_umb == 1) {
umb_clear_error_history(&rte_wx_umb_context);
}

Wyświetl plik

@ -12,6 +12,7 @@
#include <rte_wx.h>
#include <rte_rtu.h>
#include <rte_main.h>
#include <math.h>
#include <stm32f10x.h>
@ -33,6 +34,7 @@ uint32_t wx_last_good_wind_time = 0;
uint32_t wx_last_good_temperature_time = 0;
wx_pwr_state_t wx_pwr_state;
uint32_t wx_wind_pool_call_counter = 0;
uint8_t wx_force_i2c_sensor_reset = 0;
static const float direction_constant = M_PI/180.0f;
static const config_data_wx_sources_t internal = {
@ -51,6 +53,24 @@ static const config_data_wx_sources_t internal = {
#define MODBUS_QF_PRESSURE_DEGR (1 << 6)
void wx_check_force_i2c_reset(void) {
if (wx_force_i2c_sensor_reset == 1) {
wx_force_i2c_sensor_reset = 0;
#if defined (_SENSOR_BME280)
bme280_reset(&rte_wx_bme280_qf);
bme280_setup();
#endif
#if defined (_SENSOR_MS5611)
ms5611_reset(&rte_wx_ms5611_qf);
ms5611_trigger_measure(0, 0);
#endif
}
}
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, const config_data_rtu_t * const config_rtu) {
int32_t parameter_result = 0; // stores which parameters have been retrieved successfully. this is used for failsafe handling
@ -362,6 +382,10 @@ void wx_pwr_periodic_handle(void) {
// pull the output down to switch the relay and disable +5V_ISOL (VDD_SW)
GPIO_ResetBits(GPIOB, GPIO_Pin_8);
#ifdef PWR_SWITCH_BOTH
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
#endif
// setting the last_good timers to current value to prevent reset loop
wx_last_good_temperature_time = master_time;
wx_last_good_wind_time = master_time;
@ -398,6 +422,12 @@ void wx_pwr_periodic_handle(void) {
// Turn on the +5V_ISOL (VDD_SW) voltage
GPIO_SetBits(GPIOB, GPIO_Pin_8);
#ifdef PWR_SWITCH_BOTH
GPIO_SetBits(GPIOA, GPIO_Pin_6);
wx_force_i2c_sensor_reset = 1;
#endif
wx_pwr_state = WX_PWR_ON;
break;
@ -406,43 +436,43 @@ void wx_pwr_periodic_handle(void) {
}
}
void wx_pwr_disable_12v_sw(void) {
#if (defined PARATNC_HWREV_C)
wx_pwr_state = WX_PWR_DISABLED;
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
#endif
}
void wx_pwr_disable_5v_isol(void) {
wx_pwr_state = WX_PWR_DISABLED;
GPIO_ResetBits(GPIOB, GPIO_Pin_8);
}
void wx_pwr_enable_12v_sw(void) {
#if (defined PARATNC_HWREV_C)
wx_pwr_state = WX_PWR_OFF;
// setting last good measurements timers to inhibit relay clicking
// just after the power is applied
wx_last_good_temperature_time = master_time;
wx_last_good_wind_time = master_time;
#endif
}
void wx_pwr_enable_5v_isol(void) {
#if (defined PARATNC_HWREV_C)
wx_pwr_state = WX_PWR_OFF;
// setting last good measurements timers to inhibit relay clicking
// just after the power is applied
wx_last_good_temperature_time = master_time;
wx_last_good_wind_time = master_time;
#endif
}
//void wx_pwr_disable_12v_sw(void) {
//#if (defined PARATNC_HWREV_C)
// wx_pwr_state = WX_PWR_DISABLED;
//
// GPIO_ResetBits(GPIOA, GPIO_Pin_6);
//
//#endif
//}
//
//void wx_pwr_disable_5v_isol(void) {
// wx_pwr_state = WX_PWR_DISABLED;
//
// GPIO_ResetBits(GPIOB, GPIO_Pin_8);
//
//
//}
//
//void wx_pwr_enable_12v_sw(void) {
//#if (defined PARATNC_HWREV_C)
// wx_pwr_state = WX_PWR_OFF;
//
// // setting last good measurements timers to inhibit relay clicking
// // just after the power is applied
// wx_last_good_temperature_time = master_time;
// wx_last_good_wind_time = master_time;
//
//#endif
//}
//
//void wx_pwr_enable_5v_isol(void) {
//#if (defined PARATNC_HWREV_C)
// wx_pwr_state = WX_PWR_OFF;
//
// // setting last good measurements timers to inhibit relay clicking
// // just after the power is applied
// wx_last_good_temperature_time = master_time;
// wx_last_good_wind_time = master_time;
//
//#endif
//}

Wyświetl plik

@ -37,4 +37,6 @@
#define RTU_MAX_VALID_PRESSURE 1100
#define RTU_MIN_VALID_PRESSURE 900
//#define RTU_ENABLE_DEBUG_STATUS
#endif /* INCLUDE_MODBUS_RTU_RTU_CONFIGURATION_H_ */

Wyświetl plik

@ -8,7 +8,7 @@
#ifndef VE_DIRECT_PROTOCOL_AVERAGE_STRUCT_H_
#define VE_DIRECT_PROTOCOL_AVERAGE_STRUCT_H_
#define VE_DIRECT_AVERAGE_LEN 48
#define VE_DIRECT_AVERAGE_LEN 24
typedef __attribute__ ((aligned(1))) struct ve_direct_average_struct {

Wyświetl plik

@ -224,8 +224,7 @@ int32_t rtu_serial_pool(void) {
// stupid workaround. If there is a lot of I/O errors reset the controller
if (rte_rtu_number_of_serial_io_errors >= (RTU_NUMBER_OF_ERRORS_TO_TRIG_STATUS * 3) ||
rtu_time_of_last_succ_comm_at_previous_error_status == rtu_time_of_last_successfull_comm)
if (rte_rtu_number_of_serial_io_errors >= (0xFF - RTU_NUMBER_OF_ERRORS_TO_TRIG_STATUS))
{
rte_main_reboot_req = 1;
}