diff --git a/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch b/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch index 6dc4206..ab475ab 100644 --- a/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch +++ b/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch @@ -1,6 +1,6 @@ - + @@ -57,6 +57,6 @@ - + diff --git a/hardware/ParaTNC-HW-RevCplus-gerber-schematic-partlist.zip b/hardware/ParaTNC-HW-RevCplus-gerber-schematic-partlist.zip index 15b65d4..f8c12b9 100644 Binary files a/hardware/ParaTNC-HW-RevCplus-gerber-schematic-partlist.zip and b/hardware/ParaTNC-HW-RevCplus-gerber-schematic-partlist.zip differ diff --git a/include/config_data.h b/include/config_data.h index dd0fb37..c3f3c20 100644 --- a/include/config_data.h +++ b/include/config_data.h @@ -164,6 +164,10 @@ typedef struct __attribute__((aligned (4))) config_data_basic_t { */ uint8_t engineering2; + uint16_t battery_scalling_a; + + uint16_t battery_scalling_b; + } config_data_basic_t; typedef enum config_data_wx_sources_enum_t { diff --git a/include/configuration_handler.h b/include/configuration_handler.h index 5f5aed5..a7dd269 100644 --- a/include/configuration_handler.h +++ b/include/configuration_handler.h @@ -43,4 +43,8 @@ int configuration_get_early_tx_assert(void); int configuration_get_power_cycle_vbat_r(void); int configuration_get_reboot_after_24_hours(void); +uint16_t configuration_get_vbat_a_coeff(void); +uint16_t configuration_get_vbat_b_coeff(void); + + #endif /* CONFIGURATION_HANDLER_H_ */ diff --git a/include/etc/io_default_vbat_scaling.h b/include/etc/io_default_vbat_scaling.h new file mode 100644 index 0000000..c3f018d --- /dev/null +++ b/include/etc/io_default_vbat_scaling.h @@ -0,0 +1,16 @@ +/* + * io_default_vbat_scaling.h + * + * Created on: Apr 9, 2023 + * Author: mateusz + */ + +#ifndef IO_DEFAULT_VBAT_SCALING_H_ +#define IO_DEFAULT_VBAT_SCALING_H_ + +#define VBAT_MEAS_A_COEFF 1000 +#define VBAT_MEAS_B_COEFF 95 + + + +#endif /* IO_DEFAULT_VBAT_SCALING_H_ */ diff --git a/include/io.h b/include/io.h index 41fc7b3..8f2fc48 100644 --- a/include/io.h +++ b/include/io.h @@ -42,8 +42,7 @@ void io_vbat_meas_enable(void); void io_pool_vbat_r(int16_t minutes_to_wx); #endif -#define VBAT_MEAS_A_COEFF 1200 -#define VBAT_MEAS_B_COEFF 40 + /** * Keep this uncommented to configure ADC which monitor Vbatt to diff --git a/include/kiss_communication.h b/include/kiss_communication.h index 4c57750..862c93f 100644 --- a/include/kiss_communication.h +++ b/include/kiss_communication.h @@ -25,33 +25,7 @@ #define NONSTANDARD (uint8_t)0x0F -#define KISS_DATA (uint8_t) 0x00 -#define KISS_GET_RUNNING_CONFIG (uint8_t) 0x20 -#define KISS_RUNNING_CONFIG (uint8_t) 0x70 - -#define KISS_GET_VERSION_AND_ID (uint8_t) 0x21 -#define KISS_VERSION_AND_ID (uint8_t) 0x71 - -#define KISS_ERASE_STARTUP_CFG (uint8_t) 0x22 -#define KISS_ERASE_STARTUP_CFG_RESP (uint8_t) 0x72 - -#define KISS_PROGRAM_STARTUP_CFG (uint8_t) 0x23 -#define KISS_PROGRAM_STARTUP_CFG_RESP (uint8_t) 0x73 - -#define KISS_CONFIG_CRC (uint8_t) 0x24 -#define KISS_CONFIG_CRC_RESP (uint8_t) 0x74 - -#define KISS_RESTART (uint8_t) 0x25 -#define KISS_RESTART_RESP (uint8_t) 0x75 - -#define KISS_TOGGLE_PTT (uint8_t) 0x26 -//#define KISS_RESTART_RESP (uint8_t) 0x76 - -#define KISS_CONTROL_VOLTAGE (uint8_t) 0x27 -#define KISS_CONTROL_VOLTAGE_RESP (uint8_t) 0x77 - -#define KISS_RETURN_IDLE 1 extern uint8_t kiss_current_async_message; diff --git a/include/kiss_communication_service_ids.h b/include/kiss_communication_service_ids.h new file mode 100644 index 0000000..f2fb853 --- /dev/null +++ b/include/kiss_communication_service_ids.h @@ -0,0 +1,47 @@ +/* + * kiss_communication_service_ids.h + * + * Created on: Apr 9, 2023 + * Author: mateusz + */ + +#ifndef KISS_COMMUNICATION_SERVICE_IDS_H_ +#define KISS_COMMUNICATION_SERVICE_IDS_H_ + + +#define KISS_DATA (uint8_t) 0x00 + +#define KISS_RESTART (uint8_t) 0x11 +#define KISS_RESTART_RESP (uint8_t) 0x51 + +#define KISS_GET_VERSION_AND_ID (uint8_t) 0x21 +#define KISS_VERSION_AND_ID (uint8_t) 0x61 + +#define KISS_READ_DID (uint8_t) 0x22 +#define KISS_READ_DID_RESP (uint8_t) 0x62 + +#define KISS_READ_MEM_ADDR (uint8_t) 0x23 +#define KISS_READ_MEM_ADDR_RESP (uint8_t) 0x63 + +#define KISS_PROGRAM_STARTUP_CFG (uint8_t) 0x34 +#define KISS_PROGRAM_STARTUP_CFG_RESP (uint8_t) 0x74 + +#define KISS_GET_RUNNING_CONFIG (uint8_t) 0x35 +#define KISS_RUNNING_CONFIG (uint8_t) 0x75 + +#define KISS_ERASE_STARTUP_CFG (uint8_t) 0x37 +#define KISS_ERASE_STARTUP_CFG_RESP (uint8_t) 0x77 + +//#define KISS_CONFIG_CRC (uint8_t) 0x24 +//#define KISS_CONFIG_CRC_RESP (uint8_t) 0x74 + +//#define KISS_TOGGLE_PTT (uint8_t) 0x26 +//#define KISS_RESTART_RESP (uint8_t) 0x76 + +//#define KISS_CONTROL_VOLTAGE (uint8_t) 0x27 +//#define KISS_CONTROL_VOLTAGE_RESP (uint8_t) 0x77 + +#define KISS_RETURN_IDLE 1 + + +#endif /* KISS_COMMUNICATION_SERVICE_IDS_H_ */ diff --git a/include/main.h b/include/main.h index b262fde..d12d724 100644 --- a/include/main.h +++ b/include/main.h @@ -8,7 +8,7 @@ #include "config_data.h" #define SW_VER "EA20" -#define SW_DATE "18022023" +#define SW_DATE "09042023" #define SW_KISS_PROTO "A" #define SYSTICK_TICKS_PER_SECONDS 100 diff --git a/src/config_data_default.c b/src/config_data_default.c index 343c181..bae7f39 100644 --- a/src/config_data_default.c +++ b/src/config_data_default.c @@ -10,6 +10,7 @@ // reprogram it from the default set stored somewhere within .code section #include "config_data.h" +#include "io_default_vbat_scaling.h" #include "station_config.h" @@ -212,10 +213,13 @@ const config_data_basic_t __attribute__((section(".config_section_default.basic" #endif #ifdef ENG2 - .engineering2 = ENG2 + .engineering2 = ENG2, #else - .engineering2 = 0 + .engineering2 = 0, #endif + + .battery_scalling_a = VBAT_MEAS_A_COEFF, + .battery_scalling_b = VBAT_MEAS_B_COEFF }; /** diff --git a/src/config_data_first.c b/src/config_data_first.c index c696156..b2766f7 100644 --- a/src/config_data_first.c +++ b/src/config_data_first.c @@ -11,6 +11,7 @@ */ #include "config_data.h" +#include "io_default_vbat_scaling.h" #include "station_config.h" @@ -205,10 +206,13 @@ const config_data_basic_t __attribute__((section(".config_section_first.basic")) #endif #ifdef ENG1 - .engineering1 = ENG1 + .engineering1 = ENG1, #else - .engineering1 = 0xFF + .engineering1 = 0xFF, #endif + + .battery_scalling_a = VBAT_MEAS_A_COEFF, + .battery_scalling_b = VBAT_MEAS_B_COEFF }; /** diff --git a/src/config_data_second.c b/src/config_data_second.c index 7d498f1..0caddb9 100644 --- a/src/config_data_second.c +++ b/src/config_data_second.c @@ -6,6 +6,7 @@ */ #include "config_data.h" +#include "io_default_vbat_scaling.h" #include "station_config.h" @@ -199,10 +200,13 @@ const config_data_basic_t __attribute__((section(".config_section_second.basic") #endif #ifdef ENG1 - .engineering1 = ENG1 + .engineering1 = ENG1, #else - .engineering1 = 0xFF + .engineering1 = 0xFF, #endif + + .battery_scalling_a = VBAT_MEAS_A_COEFF, + .battery_scalling_b = VBAT_MEAS_B_COEFF }; /** diff --git a/src/configuration_handler.c b/src/configuration_handler.c index 717d80c..adcfb8b 100644 --- a/src/configuration_handler.c +++ b/src/configuration_handler.c @@ -11,6 +11,8 @@ #include "config_data.h" #include "config_data_externs.h" +#include "io_default_vbat_scaling.h" + #include "main.h" #ifdef STM32F10X_MD_VL @@ -41,13 +43,13 @@ #define CONFIG_SECTION_DEFAULT_START 0x0801E000 #define CONFIG_MODE_PGM_CNTR 0x0 -#define CONFIG_MODE_OFSET 0x20 // Current size: 0x10, free: 0x10 -#define CONFIG_BASIC_OFFSET 0x40 // Current size: 0x9D, free: 0x43 -#define CONFIG_SOURCES_OFFSET 0x120 // Current size: 0x4, free: 0x1C -#define CONFIG_UMB_OFFSET 0x140 // Current size: 0x12, free: 0xE -#define CONFIG_RTU_OFFSET 0x160 // Current size: 0x54, free: 0x4C -#define CONFIG_GSM_OFFSET 0x200 // Current size: 0xF8, -#define CONFIG__END__OFFSET 0x300 +#define CONFIG_MODE_OFSET 0x20 // Current size: 0x14, free: 0x0C +#define CONFIG_BASIC_OFFSET 0x40 // Current size: 0xA4, free: 0x3C +#define CONFIG_SOURCES_OFFSET 0x120 // Current size: 0x8, free: 0x18 +#define CONFIG_UMB_OFFSET 0x140 // Current size: 0x10, free: 0x10 +#define CONFIG_RTU_OFFSET 0x160 // Current size: 0x10, free: 0x90 +#define CONFIG_GSM_OFFSET 0x200 // Current size: 0x114, +#define CONFIG__END__OFFSET 0x7E0 #include @@ -863,3 +865,36 @@ int configuration_get_reboot_after_24_hours(void) { return out; } + +uint16_t configuration_get_vbat_a_coeff(void) { + + uint16_t out = 0; + + // get coefficient stored into flash memory + out = main_config_data_basic->battery_scalling_a; + + // check if it is set to non default value + if (out == 0x00 || out == 0xFF) { + // revert back to hardcoded value + out = VBAT_MEAS_A_COEFF; + } + + return out; +} + + +uint16_t configuration_get_vbat_b_coeff(void) { + + uint16_t out = 0; + + // get coefficient stored into flash memory + out = main_config_data_basic->battery_scalling_b; + + // check if it is set to non default value + if (out == 0x00 || out == 0xFF) { + // revert back to hardcoded value + out = VBAT_MEAS_B_COEFF; + } + + return out; +} diff --git a/src/kiss_callback.c b/src/kiss_callback.c index 6246d1a..e730215 100644 --- a/src/kiss_callback.c +++ b/src/kiss_callback.c @@ -6,6 +6,7 @@ */ #include "kiss_communication.h" +#include "kiss_communication_service_ids.h" #include "configuration_handler.h" #include "main.h" diff --git a/src/kiss_communication.c b/src/kiss_communication.c index 3f1a215..ca54030 100644 --- a/src/kiss_communication.c +++ b/src/kiss_communication.c @@ -7,7 +7,7 @@ #include #include "kiss_callback.h" - +#include "kiss_communication_service_ids.h" #include "main.h" #include "config_data_externs.h" diff --git a/src/main.c b/src/main.c index e30284e..f9bf6d9 100644 --- a/src/main.c +++ b/src/main.c @@ -52,6 +52,7 @@ #include "float_to_string.h" #include "pwr_save.h" #include +#include "io_default_vbat_scaling.h" #include "it_handlers.h" @@ -557,7 +558,7 @@ int main(int argc, char* argv[]){ pwr_save_init(main_config_data_mode->powersave); // initialize B+ measurement - io_vbat_meas_init(VBAT_MEAS_A_COEFF, VBAT_MEAS_B_COEFF); + io_vbat_meas_init(configuration_get_vbat_a_coeff(), configuration_get_vbat_b_coeff()); #endif // initalizing separated Open Collector output @@ -1494,9 +1495,11 @@ int main(int argc, char* argv[]){ wx_pwr_switch_periodic_handle(); } +#ifdef PARAMETEO if (configuration_get_power_cycle_vbat_r() == 1 && !main_afsk.sending) { io_pool_vbat_r(packet_tx_get_minutes_to_next_wx()); } +#endif wx_check_force_i2c_reset(); diff --git a/src/packet_tx_handler.c b/src/packet_tx_handler.c index 97dbdb0..7290520 100644 --- a/src/packet_tx_handler.c +++ b/src/packet_tx_handler.c @@ -236,6 +236,7 @@ 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 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(); @@ -244,6 +245,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con // write to NVM if it is enabled nvm_measurement_store(&packet_tx_nvm); } +#endif // 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 diff --git a/src/wx_handler_humidity.c b/src/wx_handler_humidity.c index f89fa88..de8e3ad 100644 --- a/src/wx_handler_humidity.c +++ b/src/wx_handler_humidity.c @@ -56,9 +56,8 @@ int32_t wx_get_humidity_measurement(const config_data_wx_sources_t * const confi // set the flag that external temperature is available out |= WX_HANDLER_PARAMETER_RESULT_HUMIDITY; - if (measurement_result == BME280_OK) { - rte_wx_humidity_valid = rte_wx_humidity; - } + rte_wx_humidity_valid = rte_wx_humidity; + } break; diff --git a/src/wx_handler_pressure.c b/src/wx_handler_pressure.c index 1e9131e..1e3e97d 100644 --- a/src/wx_handler_pressure.c +++ b/src/wx_handler_pressure.c @@ -107,20 +107,20 @@ int32_t wx_get_pressure_measurement(const config_data_wx_sources_t * const confi case WX_SOURCE_RTU: case WX_SOURCE_FULL_RTU: { - // get the value read from RTU registers - measurement_retval = rtu_get_humidity(&rte_wx_humidity, config_rtu); - - // check - if (measurement_retval == MODBUS_RET_OK || measurement_retval == MODBUS_RET_DEGRADED) { - - // set the flag that external temperature is available - output |= WX_HANDLER_PARAMETER_RESULT_HUMIDITY; - - if (measurement_retval == BME280_OK) { - rte_wx_humidity_valid = rte_wx_humidity; - } - } - +// // get the value read from RTU registers +// measurement_retval = rtu_get_humidity(&rte_wx_humidity, config_rtu); +// +// // check +// if (measurement_retval == MODBUS_RET_OK || measurement_retval == MODBUS_RET_DEGRADED) { +// +// // set the flag that external temperature is available +// output |= WX_HANDLER_PARAMETER_RESULT_HUMIDITY; +// +// if (measurement_retval == BME280_OK) { +// rte_wx_humidity_valid = rte_wx_humidity; +// } +// } +// break; } case WX_SOURCE_DAVIS_SERIAL: