kopia lustrzana https://github.com/SP8EBC/ParaTNC
vbat_r power cycle daily
rodzic
d92a16428b
commit
67d08ffdce
|
@ -89,6 +89,9 @@ typedef struct __attribute__((aligned (4))) config_data_mode_t {
|
|||
// only for ParaMETEO
|
||||
uint8_t gsm;
|
||||
|
||||
// only for ParaMETEO
|
||||
uint8_t nvm_logger;
|
||||
|
||||
} config_data_mode_t;
|
||||
|
||||
typedef struct __attribute__((aligned (4))) config_data_basic_t {
|
||||
|
@ -97,6 +100,9 @@ typedef struct __attribute__((aligned (4))) config_data_basic_t {
|
|||
#define ENGINEERING1_INH_WX_PWR_HNDL (1 << 1)
|
||||
#define ENGINEERING1_EARLY_TX_ASSERT (1 << 2)
|
||||
|
||||
#define ENGINEERING2 (1)
|
||||
#define ENGINEERING2_POWER_CYCLE_R (1 << 2)
|
||||
|
||||
char callsign[7];
|
||||
|
||||
uint8_t ssid;
|
||||
|
@ -146,6 +152,16 @@ typedef struct __attribute__((aligned (4))) config_data_basic_t {
|
|||
*/
|
||||
uint8_t engineering1;
|
||||
|
||||
/**
|
||||
* Ugly and nasty workarounds of (mostly hardware) problems. Use only
|
||||
* where there is no hope left.
|
||||
*
|
||||
* bit0 - must be set to zero to enable this engineering
|
||||
* bit1 - reboot after 99 telemetry frames
|
||||
* bit2 - power cycle vbat_r two minutes before weather frame
|
||||
*/
|
||||
uint8_t engineering2;
|
||||
|
||||
} config_data_basic_t;
|
||||
|
||||
typedef enum config_data_wx_sources_enum_t {
|
||||
|
|
|
@ -40,5 +40,6 @@ const uint32_t * configuration_get_address(configuration_handler_region_t region
|
|||
|
||||
int configuration_get_inhibit_wx_pwr_handle(void);
|
||||
int configuration_get_early_tx_assert(void);
|
||||
int configuration_get_power_cycle_vbat_r(void);
|
||||
|
||||
#endif /* CONFIGURATION_HANDLER_H_ */
|
||||
|
|
|
@ -38,6 +38,8 @@ uint16_t io_vbat_meas_get(void);
|
|||
uint16_t io_vbat_meas_average(uint16_t sample);
|
||||
void io_vbat_meas_disable(void);
|
||||
void io_vbat_meas_enable(void);
|
||||
|
||||
void io_pool_vbat_r(uint8_t minutes_to_wx);
|
||||
#endif
|
||||
|
||||
#define VBAT_MEAS_A_COEFF 1200
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "drivers/serial.h"
|
||||
#include "config_data.h"
|
||||
|
||||
#define SW_VER "EA18"
|
||||
#define SW_DATE "19112022"
|
||||
#define SW_VER "EA19"
|
||||
#define SW_DATE "31012023"
|
||||
#define SW_KISS_PROTO "A"
|
||||
|
||||
#define SYSTICK_TICKS_PER_SECONDS 100
|
||||
|
|
|
@ -130,7 +130,13 @@ const config_data_mode_t __attribute__((section(".config_section_default.mode"))
|
|||
#if (defined _GSM_KEEP_MODEM_ALWAYS_ON)
|
||||
.powersave_keep_gsm_always_enabled = 1
|
||||
#else
|
||||
.powersave_keep_gsm_always_enabled = 0
|
||||
.powersave_keep_gsm_always_enabled = 0,
|
||||
#endif
|
||||
|
||||
#if (defined _NVM_LOGGER)
|
||||
.nvm_logger = 1
|
||||
#else
|
||||
.nvm_logger = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -839,3 +839,9 @@ int configuration_get_early_tx_assert(void) {
|
|||
return out;
|
||||
}
|
||||
|
||||
int configuration_get_power_cycle_vbat_r(void) {
|
||||
|
||||
int out = 0;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
51
src/io.c
51
src/io.c
|
@ -18,6 +18,16 @@
|
|||
#ifdef STM32L471xx
|
||||
#include <stm32l4xx.h>
|
||||
#include <stm32l4xx_ll_gpio.h>
|
||||
|
||||
/**
|
||||
* Internal state of VBAT R pooler
|
||||
*/
|
||||
typedef enum io_pool_vbat_r_state_t {
|
||||
POOL_VBAT_R_TURNED_ON, //!< VBAT_R is turned on but it is still 2 minutes remaining
|
||||
POOL_VBAT_R_TURNED_OFF, //!< 2 minutes remaining and VBAT_R was turned off
|
||||
POOL_VBAT_R_WAIT, //!< VBAT_R was turned off but wait
|
||||
POOL_VBAT_R_DONT_SWITCH //!< more or less than 2 minutes to wx packet or VBAT_R was restarted already
|
||||
}io_pool_vbat_r_state_t;
|
||||
#endif
|
||||
|
||||
#include "station_config.h"
|
||||
|
@ -33,6 +43,10 @@ static uint16_t io_vbatt_history[VBATT_HISTORY_LN];
|
|||
static uint8_t io_vbatt_history_it = 0;
|
||||
|
||||
#define MINIMUM_SENSEFUL_VBATT_VOLTAGE 512u
|
||||
|
||||
//! An instance of VBAT_R pooler internal state
|
||||
io_pool_vbat_r_state_t io_vbat_r_state = POOL_VBAT_R_DONT_SWITCH;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -477,5 +491,42 @@ void io_vbat_meas_enable(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void io_pool_vbat_r(uint8_t minutes_to_wx) {
|
||||
|
||||
// check how many minutes reamins to weather packet
|
||||
if (minutes_to_wx == 2) {
|
||||
// hardcoded to 2 minutes
|
||||
|
||||
switch(io_vbat_r_state) {
|
||||
case POOL_VBAT_R_TURNED_ON:
|
||||
// turn off VBAT_R
|
||||
io___cntrl_vbat_r_disable();
|
||||
|
||||
io_vbat_r_state = POOL_VBAT_R_TURNED_OFF;
|
||||
|
||||
break;
|
||||
case POOL_VBAT_R_TURNED_OFF:
|
||||
// wait few more seconds before turning on back
|
||||
io_vbat_r_state = POOL_VBAT_R_WAIT;
|
||||
|
||||
break;
|
||||
case POOL_VBAT_R_WAIT:
|
||||
// turn back on
|
||||
io___cntrl_vbat_r_enable();
|
||||
|
||||
io_vbat_r_state = POOL_VBAT_R_DONT_SWITCH;
|
||||
|
||||
break;
|
||||
case POOL_VBAT_R_DONT_SWITCH:
|
||||
// VBAT_R has been already power cycled, do nothing more
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// don't do nothing with VBAT_R and keep it turned on
|
||||
io_vbat_r_state = POOL_VBAT_R_TURNED_ON;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
56
src/main.c
56
src/main.c
|
@ -162,79 +162,79 @@ const config_data_rtu_t * main_config_data_rtu = 0;
|
|||
const config_data_gsm_t * main_config_data_gsm = 0;
|
||||
#endif
|
||||
|
||||
// global variable incremented by the SysTick handler to measure time in miliseconds
|
||||
//! global variable incremented by the SysTick handler to measure time in miliseconds
|
||||
uint32_t master_time = 0;
|
||||
|
||||
// current timestamp from RTC in NVM format
|
||||
//! current timestamp from RTC in NVM format
|
||||
uint32_t main_nvm_timestamp = 0;
|
||||
|
||||
// this global variable stores numbers of ticks of idling CPU
|
||||
//! this global variable stores numbers of ticks of idling CPU
|
||||
uint32_t main_idle_cpu_ticks = 0;
|
||||
|
||||
// current cpu idle ticks
|
||||
//! current cpu idle ticks
|
||||
uint32_t main_current_cpu_idle_ticks = 0;
|
||||
|
||||
// approx cpu load in percents
|
||||
//! approx cpu load in percents
|
||||
int8_t main_cpu_load = 0;
|
||||
|
||||
// global variable used as a timer to trigger meteo sensors mesurements
|
||||
//! global variable used as a timer to trigger meteo sensors mesurements
|
||||
int32_t main_wx_sensors_pool_timer = 65500;
|
||||
|
||||
// global variable used as a timer to trigger packet sending
|
||||
//! global variable used as a timer to trigger packet sending
|
||||
int32_t main_one_minute_pool_timer = 45000;
|
||||
|
||||
// one second pool interval
|
||||
//! one second pool interval
|
||||
int32_t main_one_second_pool_timer = 1000;
|
||||
|
||||
// two second pool interval
|
||||
//! two second pool interval
|
||||
int32_t main_two_second_pool_timer = 2000;
|
||||
|
||||
// ten second pool interval
|
||||
//! ten second pool interval
|
||||
int32_t main_ten_second_pool_timer = 10000;
|
||||
|
||||
// serial context for UART used to KISS
|
||||
//! serial context for UART used to KISS
|
||||
srl_context_t main_kiss_srl_ctx;
|
||||
|
||||
// serial context for UART used for comm with wx sensors
|
||||
//! serial context for UART used for comm with wx sensors
|
||||
srl_context_t main_wx_srl_ctx;
|
||||
|
||||
#if defined(STM32L471xx)
|
||||
// serial context for communication with GSM module
|
||||
//! serial context for communication with GSM module
|
||||
srl_context_t main_gsm_srl_ctx;
|
||||
#endif
|
||||
|
||||
// operation mode of USART1 (RS232 on RJ45 socket)
|
||||
//! operation mode of USART1 (RS232 on RJ45 socket)
|
||||
main_usart_mode_t main_usart1_kiss_mode = USART_MODE_UNDEF;
|
||||
|
||||
// operation mode of USART2 (RS485)
|
||||
//! operation mode of USART2 (RS485)
|
||||
main_usart_mode_t main_usart2_wx_mode = USART_MODE_UNDEF;
|
||||
|
||||
// a pointer to KISS context
|
||||
//! a pointer to KISS context
|
||||
srl_context_t* main_kiss_srl_ctx_ptr;
|
||||
|
||||
// a pointer to wx comms context
|
||||
//! a pointer to wx comms context
|
||||
srl_context_t* main_wx_srl_ctx_ptr;
|
||||
|
||||
// a pointer to gsm context
|
||||
//! a pointer to gsm context
|
||||
srl_context_t* main_gsm_srl_ctx_ptr;
|
||||
|
||||
// target USART1 (kiss) baudrate
|
||||
//! target USART1 (kiss) baudrate
|
||||
uint32_t main_target_kiss_baudrate;
|
||||
|
||||
// target USART2 (wx) baudrate
|
||||
//! target USART2 (wx) baudrate
|
||||
uint32_t main_target_wx_baudrate;
|
||||
|
||||
// controls if the KISS modem is enabled
|
||||
//! controls if the KISS modem is enabled
|
||||
uint8_t main_kiss_enabled = 1;
|
||||
|
||||
// controls if DAVIS serialprotocol client is enabled by the configuration
|
||||
//! controls if DAVIS serialprotocol client is enabled by the configuration
|
||||
uint8_t main_davis_serial_enabled = 0;
|
||||
|
||||
uint8_t main_modbus_rtu_master_enabled = 0;
|
||||
|
||||
uint8_t main_reset_config_to_default = 0;
|
||||
|
||||
// global variables represending the AX25/APRS stack
|
||||
//! global variables represending the AX25/APRS stack
|
||||
AX25Ctx main_ax25;
|
||||
Afsk main_afsk;
|
||||
|
||||
|
@ -253,15 +253,15 @@ uint8_t main_small_buffer[MAIN_SMALL_BUFFER_LN];
|
|||
char main_symbol_f = '/';
|
||||
char main_symbol_s = '#';
|
||||
|
||||
// global variable used to store return value from various functions
|
||||
//! global variable used to store return value from various functions
|
||||
volatile uint8_t retval = 100;
|
||||
|
||||
uint16_t buffer_len = 0;
|
||||
|
||||
// return value from UMB related functions
|
||||
//! return value from UMB related functions
|
||||
umb_retval_t main_umb_retval = UMB_UNINITIALIZED;
|
||||
|
||||
// result of CRC calculation
|
||||
//! result of CRC calculation
|
||||
uint32_t main_crc_result = 0;
|
||||
|
||||
#if defined(STM32L471xx)
|
||||
|
@ -1012,7 +1012,9 @@ int main(int argc, char* argv[]){
|
|||
|
||||
#ifdef STM32L471xx
|
||||
|
||||
nvm_measurement_init();
|
||||
if (main_config_data_mode->nvm_logger != 0) {
|
||||
nvm_measurement_init();
|
||||
}
|
||||
|
||||
if (main_config_data_mode->gsm == 1) {
|
||||
it_handlers_inhibit_radiomodem_dcd_led = 1;
|
||||
|
|
|
@ -204,7 +204,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
packet_tx_telemetry_counter++;
|
||||
packet_tx_telemetry_descr_counter++;
|
||||
if ((main_config_data_mode->wx & WX_ENABLED) == WX_ENABLED) {
|
||||
// increse these counters only when WX is enabled
|
||||
// increase these counters only when WX is enabled
|
||||
packet_tx_meteo_counter++;
|
||||
packet_tx_meteo_kiss_counter++;
|
||||
}
|
||||
|
@ -236,14 +236,14 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
// check if there is a time to send meteo packet through RF
|
||||
if (packet_tx_meteo_counter >= packet_tx_meteo_interval && packet_tx_meteo_interval != 0) {
|
||||
|
||||
#ifdef STM32L471xx
|
||||
packet_tx_nvm.temperature_humidity = wx_get_nvm_record_temperature();
|
||||
packet_tx_nvm.wind = wx_get_nvm_record_wind();
|
||||
packet_tx_nvm.timestamp = main_get_nvm_timestamp();
|
||||
if (config_mode->nvm_logger != 0) {
|
||||
packet_tx_nvm.temperature_humidity = wx_get_nvm_record_temperature();
|
||||
packet_tx_nvm.wind = wx_get_nvm_record_wind();
|
||||
packet_tx_nvm.timestamp = main_get_nvm_timestamp();
|
||||
|
||||
// write to NVM if it is enabled
|
||||
nvm_measurement_store(&packet_tx_nvm);
|
||||
#endif
|
||||
// write to NVM if it is enabled
|
||||
nvm_measurement_store(&packet_tx_nvm);
|
||||
}
|
||||
|
||||
// this function is required if more than one RF frame will be send from this function at once
|
||||
// it waits for transmission completion and add some delay to let digipeaters do theris job
|
||||
|
|
Ładowanie…
Reference in New Issue