From 0dd67e45fb22d54771f9b49b8a740a26b4c54910 Mon Sep 17 00:00:00 2001 From: Mateusz Lubecki Date: Sun, 3 Apr 2022 17:59:00 +0200 Subject: [PATCH] fix in +5V_C voltage switching in ParaMETEO --- STM32F100_ParaTNC/makefile | 1 + STM32F100_ParaTNC/sources.mk | 1 + STM32F100_ParaTNC/src/subdir.mk | 12 ++++---- include/pwr_save.h | 36 +++++++++++++---------- include/station_config_target_hw.h | 4 +-- include/{pwr_switch.h => wx_pwr_switch.h} | 1 + src/io.c | 19 +++++++----- src/main.c | 2 +- src/{pwr_switch.c => wx_pwr_switch.c} | 3 +- 9 files changed, 45 insertions(+), 34 deletions(-) rename include/{pwr_switch.h => wx_pwr_switch.h} (90%) rename src/{pwr_switch.c => wx_pwr_switch.c} (99%) diff --git a/STM32F100_ParaTNC/makefile b/STM32F100_ParaTNC/makefile index dc1a6f8..33fc6e2 100644 --- a/STM32F100_ParaTNC/makefile +++ b/STM32F100_ParaTNC/makefile @@ -13,6 +13,7 @@ RM := rm -rf -include system/src/stm32f1-stdperiph/subdir.mk -include system/src/newlib/subdir.mk -include system/src/modbus_rtu/subdir.mk +-include system/src/http_client/subdir.mk -include system/src/drivers/f1/subdir.mk -include system/src/drivers/subdir.mk -include system/src/diag/subdir.mk diff --git a/STM32F100_ParaTNC/sources.mk b/STM32F100_ParaTNC/sources.mk index 4848207..c4dc3c4 100644 --- a/STM32F100_ParaTNC/sources.mk +++ b/STM32F100_ParaTNC/sources.mk @@ -35,6 +35,7 @@ system/src/davis_vantage \ system/src/diag \ system/src/drivers \ system/src/drivers/f1 \ +system/src/http_client \ system/src/modbus_rtu \ system/src/newlib \ system/src/stm32f1-stdperiph \ diff --git a/STM32F100_ParaTNC/src/subdir.mk b/STM32F100_ParaTNC/src/subdir.mk index 7659a57..41301ee 100644 --- a/STM32F100_ParaTNC/src/subdir.mk +++ b/STM32F100_ParaTNC/src/subdir.mk @@ -21,7 +21,6 @@ C_SRCS += \ ../src/it_handlers.c \ ../src/main.c \ ../src/packet_tx_handler.c \ -../src/pwr_switch.c \ ../src/rte_main.c \ ../src/rte_pv.c \ ../src/rte_pwr.c \ @@ -30,7 +29,8 @@ C_SRCS += \ ../src/wx_handler.c \ ../src/wx_handler_humidity.c \ ../src/wx_handler_pressure.c \ -../src/wx_handler_temperature.c +../src/wx_handler_temperature.c \ +../src/wx_pwr_switch.c OBJS += \ ./src/KissCommunication.o \ @@ -50,7 +50,6 @@ OBJS += \ ./src/it_handlers.o \ ./src/main.o \ ./src/packet_tx_handler.o \ -./src/pwr_switch.o \ ./src/rte_main.o \ ./src/rte_pv.o \ ./src/rte_pwr.o \ @@ -59,7 +58,8 @@ OBJS += \ ./src/wx_handler.o \ ./src/wx_handler_humidity.o \ ./src/wx_handler_pressure.o \ -./src/wx_handler_temperature.o +./src/wx_handler_temperature.o \ +./src/wx_pwr_switch.o C_DEPS += \ ./src/KissCommunication.d \ @@ -79,7 +79,6 @@ C_DEPS += \ ./src/it_handlers.d \ ./src/main.d \ ./src/packet_tx_handler.d \ -./src/pwr_switch.d \ ./src/rte_main.d \ ./src/rte_pv.d \ ./src/rte_pwr.d \ @@ -88,7 +87,8 @@ C_DEPS += \ ./src/wx_handler.d \ ./src/wx_handler_humidity.d \ ./src/wx_handler_pressure.d \ -./src/wx_handler_temperature.d +./src/wx_handler_temperature.d \ +./src/wx_pwr_switch.d # Each subdirectory must supply rules for building sources it contributes diff --git a/include/pwr_save.h b/include/pwr_save.h index e303ec9..f3f877f 100644 --- a/include/pwr_save.h +++ b/include/pwr_save.h @@ -14,27 +14,33 @@ * This header file defines all functions related to powersaving, switching between different power states, * stopping cpu core etc. Generally they are few power states as below * - * /----------------------------------------------------------------------\ - * | State | CPU | +5V_S | +5V_R and VBATT_SW_R | +4V_G | +5V_C | - * | | | | | | | - * | | | sensors | Internal / external | GPRS | SD card | - * | | | | VHF Radio | | PT100 | - * =----------------------------------------------------------------------= - * | C0 |Running| ON | ON | ON | ON | - * | C1 |Running| ON | ON | OFF | ON | - * | C2 |Running| OFF | ON | OFF | ON | - * | C3 |Running| OFF | ON | ON | ON | - * | M4 |Running| ON | OFF | OFF | OFF | - * | I5 |Running| OFF | OFF | OFF | OFF | - * | L6 | Stop2 | OFF | OFF | ON | OFF | - * | L7 | Stop2 | OFF | OFF | OFF | OFF | - * \----------------------------------------------------------------------/ + * /-------------------------------------------------------------------------\ + * | State | CPU | +5V_S | +7V5_R and VBATT_SW_R | +4V_G | +5V_C | + * | | | VBATT_SW_S | | | | + * =-------------------------------------------------------------------------= + * | C0 |Running| ON | ON | ON | ON | + * | C1 |Running| ON | ON | OFF | ON | + * | C2 |Running| OFF | ON | OFF | ON | + * | C3 |Running| OFF | ON | ON | ON | + * | M4 |Running| ON | OFF | OFF | OFF | + * | I5 |Running| OFF | OFF | OFF | OFF | + * | L6 | Stop2 | OFF | OFF | ON | OFF | + * | L7 | Stop2 | OFF | OFF | OFF | OFF | + * \-------------------------------------------------------------------------/ * * C = modes with communication enabled * M = mode with measuremenet only w/o any communication * I = idle / initialization mode with anything disabled * L = low power consumption modes with CPU halted in STOP2 mode * + * What is supplied by which voltage + * +3V3_C - Microcontroller and UART-RS232 converter. It is always present + * +4V_G - GSM module + * +5V_C and +3V3_CC derived from it - LMV358 op amp, microSD Cards, PT100 interface + * +5V_S and +3V3_S derived from it - Wind sensor, one wire thermometer, RS485 + * +7V5_R - external VHF radio + * + * * Stop2 mode is a power saving mode defined in STM paperwork (DM0083560 * aka Reference Manual RM0351). This mode halts CPU core completely and * disable HCLK, AHB1 & AHB2 buses, but preserves StaticRAM and registers diff --git a/include/station_config_target_hw.h b/include/station_config_target_hw.h index 5067abd..f31f7ed 100644 --- a/include/station_config_target_hw.h +++ b/include/station_config_target_hw.h @@ -10,8 +10,8 @@ //#define PARATNC_HWREV_A //#define PARATNC_HWREV_B -//#define PARATNC_HWREV_C -#define PARAMETEO +#define PARATNC_HWREV_C +//#define PARAMETEO #ifdef PARAMETEO // those defines and an undef are only required for shitty Eclipse indexer to see anything from STM32L471xx target diff --git a/include/pwr_switch.h b/include/wx_pwr_switch.h similarity index 90% rename from include/pwr_switch.h rename to include/wx_pwr_switch.h index 6a893f1..6d29c28 100644 --- a/include/pwr_switch.h +++ b/include/wx_pwr_switch.h @@ -16,6 +16,7 @@ typedef enum wx_pwr_state_t { WX_PWR_DISABLED }wx_pwr_state_t; +extern wx_pwr_state_t wx_pwr_state; void wx_pwr_switch_init(void); void wx_pwr_switch_periodic_handle(void); diff --git a/src/io.c b/src/io.c index 3bd29af..61d1ea1 100644 --- a/src/io.c +++ b/src/io.c @@ -6,6 +6,7 @@ */ +#include #include "station_config_target_hw.h" #include "io.h" @@ -136,26 +137,28 @@ void io_ext_watchdog_config(void) { void io_ext_watchdog_service(void) { #ifdef STM32F10X_MD_VL - -#endif - -#ifdef STM32L471xx - if ((GPIOA->ODR & GPIO_ODR_OD1) == 0) { + if ((GPIOA->ODR & GPIO_ODR_ODR12) == 0) { // set high - GPIOA->BSRR |= GPIO_BSRR_BS1; + GPIOA->BSRR |= GPIO_BSRR_BS12; } else { // set low - GPIOA->BSRR |= GPIO_BSRR_BR1; + GPIOA->BSRR |= GPIO_BSRR_BR12; } #endif + +#ifdef STM32L471xx + +#endif } void io_vbat_meas_init(int8_t a_coeff, int8_t b_coeff) { + +#ifdef STM32L471xx io_vbat_a_coeff = a_coeff; io_vbat_b_coeff = b_coeff; -#ifdef STM32L471xx + GPIO_InitTypeDef.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitTypeDef.OutputType = LL_GPIO_OUTPUT_PUSHPULL; GPIO_InitTypeDef.Pin = LL_GPIO_PIN_5; diff --git a/src/main.c b/src/main.c index 7f07c9b..dea8c76 100644 --- a/src/main.c +++ b/src/main.c @@ -44,7 +44,7 @@ #include "io.h" #include "float_to_string.h" #include "pwr_save.h" -#include "pwr_switch.h" +#include #include "it_handlers.h" diff --git a/src/pwr_switch.c b/src/wx_pwr_switch.c similarity index 99% rename from src/pwr_switch.c rename to src/wx_pwr_switch.c index e123f05..7868338 100644 --- a/src/pwr_switch.c +++ b/src/wx_pwr_switch.c @@ -5,8 +5,7 @@ * Author: mateusz */ -#include "pwr_switch.h" - +#include #include "station_config.h" #include "main.h" #include "rte_wx.h"