diff --git a/include/main.h b/include/main.h index e5dfa0d..82e6f67 100644 --- a/include/main.h +++ b/include/main.h @@ -8,7 +8,7 @@ #include "config_data.h" #define SW_VER "ZT17" -#define SW_DATE "06112022" +#define SW_DATE "11112022" #define SW_KISS_PROTO "A" #define SYSTICK_TICKS_PER_SECONDS 100 diff --git a/include/nvm.h b/include/nvm.h index 7bc8c57..94c420b 100644 --- a/include/nvm.h +++ b/include/nvm.h @@ -50,6 +50,8 @@ typedef enum nvm_state_result_t { NVM_PGM_ERROR }nvm_state_result_t; +extern uint8_t * nvm_data_ptr; + void nvm_measurement_init(void); nvm_state_result_t nvm_measurement_store(nvm_measurement_t * data); void nvm_erase_all(void); diff --git a/src/packet_tx_handler.c b/src/packet_tx_handler.c index 2a13870..d821d5c 100644 --- a/src/packet_tx_handler.c +++ b/src/packet_tx_handler.c @@ -477,7 +477,8 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con if (packet_tx_telemetry_descr_counter >= packet_tx_telemetry_descr_interval) { #ifdef PARAMETEO - telemetry_send_status_powersave_registers(REGISTER_LAST_SLEEP, REGISTER_LAST_WKUP, REGISTER_COUNTERS, REGISTER_MONITOR, REGISTER_LAST_SLTIM); + //telemetry_send_status_powersave_registers(REGISTER_LAST_SLEEP, REGISTER_LAST_WKUP, REGISTER_COUNTERS, REGISTER_MONITOR, REGISTER_LAST_SLTIM); + telemetry_send_nvm_status_tatry(); #endif packet_tx_multi_per_call_handler(); diff --git a/system/include/aprs/telemetry.h b/system/include/aprs/telemetry.h index 78e4019..5e59426 100644 --- a/system/include/aprs/telemetry.h +++ b/system/include/aprs/telemetry.h @@ -102,6 +102,7 @@ void telemetry_send_status_powersave_registers(uint32_t register_last_sleep, uin * These are very special telemetry format for scientific weather stations in TATRY */ #ifdef TATRY +void telemetry_send_nvm_status_tatry(void); void telemetry_send_chns_description_tatry(const config_data_basic_t * const config_basic); void telemetry_send_values_tatry(); #endif diff --git a/system/include/drivers/max31865.h b/system/include/drivers/max31865.h index 3ddbb51..7f84340 100644 --- a/system/include/drivers/max31865.h +++ b/system/include/drivers/max31865.h @@ -23,8 +23,10 @@ typedef enum max31865_qf_t { MAX_QF_NOT_AVALIABLE }max31865_qf_t; +extern uint16_t max31865_raw_result; extern uint8_t max31865_current_fault_status; extern uint8_t max31865_measurements_counter; +extern uint8_t max31865_merasurements_error_counter; extern int_average_t max31865_average; extern uint8_t max31865_ok; diff --git a/system/src/aprs/telemetry.c b/system/src/aprs/telemetry.c index 2f61ead..5e9f069 100644 --- a/system/src/aprs/telemetry.c +++ b/system/src/aprs/telemetry.c @@ -622,6 +622,18 @@ void telemetry_send_status_powersave_registers(uint32_t register_last_sleep, uin #include "drivers/max31865.h" #include "int_average.h" #include "math.h" +#include "nvm.h" + +void telemetry_send_nvm_status_tatry(void) { + main_wait_for_tx_complete(); + + memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg)); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ">[nvm status][[nvm_timestamp: 0x%lX][nvm_data_ptr: 0x%p]", main_get_nvm_timestamp(), nvm_data_ptr); + ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len); + //while (main_ax25.dcd == 1); + afsk_txStart(&main_afsk); + main_wait_for_tx_complete(); +} void telemetry_send_chns_description_tatry(const config_data_basic_t * const config_basic) { // a buffer to assembly the 'call-ssid' string at the begining of the frame @@ -636,7 +648,7 @@ void telemetry_send_chns_description_tatry(const config_data_basic_t * const con // clear the output frame buffer memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg)); - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :PARM.Spi,LastTempr,MaxTempr,Vbatt,PtSts,LSERDY,RTCEN,MAX_OK,SLEEP,N,N,N,N", config_basic->callsign); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :PARM.MaxLsb,MaxMsb,LastTempr,Vbatt,PtSts,LSERDY,RTCEN,MAX_OK,SLEEP,SPI_ER,SPI_OK,N,N", config_basic->callsign); main_own_aprs_msg[main_own_aprs_msg_len] = 0; ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len); @@ -645,8 +657,8 @@ void telemetry_send_chns_description_tatry(const config_data_basic_t * const con main_wait_for_tx_complete(); delay_fixed(1500); - memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg));// / / / / - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :EQNS.0,1,0,0,0.25,-40,0,0.25,-40,0,0.02,10,0,1,0", config_basic->callsign); + memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg));// / / / / + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :EQNS.0,1,0,0,1,0,0,0.25,-40,0,0.02,10,0,1,0", config_basic->callsign); main_own_aprs_msg[main_own_aprs_msg_len] = 0; ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len); @@ -656,7 +668,7 @@ void telemetry_send_chns_description_tatry(const config_data_basic_t * const con delay_fixed(1500); memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg)); - main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :UNIT.Cnt,DegC,DegC,V,Raw,Hi,Hi,Hi,Hi,Hi,Hi,Hi,Hi", config_basic->callsign); + main_own_aprs_msg_len = sprintf(main_own_aprs_msg, ":%-6s :UNIT.Raw,Raw,DegC,V,Raw,Hi,Hi,Hi,Hi,Hi,Hi,Hi,Hi", config_basic->callsign); main_own_aprs_msg[main_own_aprs_msg_len] = 0; ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len); @@ -668,11 +680,11 @@ void telemetry_send_chns_description_tatry(const config_data_basic_t * const con void telemetry_send_values_tatry() { - uint8_t spi_transmission_counter = max31865_measurements_counter; uint8_t scaled_last_temperature = 0; - uint8_t scaled_max_temperature = 0; uint8_t scaled_vbatt_voltage = 0; uint8_t pt_status = max31865_current_fault_status; + uint8_t pt_raw_lsb = (uint8_t)(max31865_raw_result & 0xFF); + uint8_t pt_raw_msb = (uint8_t)((max31865_raw_result & 0xFF00) >> 8); float value = 0.0f; @@ -701,35 +713,26 @@ void telemetry_send_values_tatry() { scaled_last_temperature = (uint8_t)roundf(((value + 400.0f) * 0.4f)); } - value = int_get_max(&max31865_average); - if (value < -400.0f) { - scaled_max_temperature = (uint8_t)0; - } - else if (value > 240.0f) { - scaled_max_temperature = (uint8_t)255; - } - else { - scaled_max_temperature = (uint8_t)roundf(((value + 400.0f) * 0.4f)); - } - memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg)); main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "T#%03d,%03d,%03d,%03d,%03d,%03d,%c%c%c%c%c%c%c%c", telemetry_counter++, - spi_transmission_counter, + pt_raw_lsb, + pt_raw_msb, scaled_last_temperature, - scaled_max_temperature, scaled_vbatt_voltage, pt_status, ((RCC->BDCR & RCC_BDCR_LSERDY) > 0) ? '1' : '0', ((RCC->BDCR & RCC_BDCR_RTCEN) > 0) ? '1' : '0', (max31865_ok) ? '1' : '0', (main_woken_up_for_telemetry > 0) ? '1' : '0', - '0', - '0', + (max31865_merasurements_error_counter > 0) ? '1' : '0', + (max31865_measurements_counter > 0) ? '1' : '0', '0', '0'); main_woken_up_for_telemetry = 0; + max31865_merasurements_error_counter = 0; + max31865_measurements_counter = 0; // reset the frame counter if it overflowed if (telemetry_counter > 999) diff --git a/system/src/cmsis/stm32l4xx/system_stm32l4xx.c b/system/src/cmsis/stm32l4xx/system_stm32l4xx.c index 56fcf7b..19b5295 100644 --- a/system/src/cmsis/stm32l4xx/system_stm32l4xx.c +++ b/system/src/cmsis/stm32l4xx/system_stm32l4xx.c @@ -457,10 +457,10 @@ void system_clock_start_rtc_l4(void) { } // set date - RTC->DR = 0x0021A820; + RTC->DR = 0x00229110; // set time - RTC->TR = 0x00232711; + RTC->TR = 0x00191311; // exit RTC set mode RTC->ISR &= (0xFFFFFFFF ^ RTC_ISR_INIT); diff --git a/system/src/drivers/max31865.c b/system/src/drivers/max31865.c index bb0d19c..f955e2d 100644 --- a/system/src/drivers/max31865.c +++ b/system/src/drivers/max31865.c @@ -151,6 +151,7 @@ max31865_qf_t max31865_quality_factor = MAX_QF_UNKNOWN; * */ uint8_t max31865_measurements_counter = 0; +uint8_t max31865_merasurements_error_counter = 0; int_average_t max31865_average; @@ -374,6 +375,8 @@ void max31865_pool(void) { max31865_quality_factor = MAX_QF_FULL; } else { + max31865_merasurements_error_counter++; + max31865_current_state = MAX_ERROR; max31865_quality_factor = MAX_QF_NOT_AVALIABLE;