kopia lustrzana https://github.com/SP8EBC/ParaTNC
gpio configuration changed to comply with ParaMETEO hardware revision c
rodzic
f899378ff8
commit
327e6c3861
43
include/io.h
43
include/io.h
|
@ -23,21 +23,21 @@ void io_ext_watchdog_config(void);
|
|||
void io_ext_watchdog_service(void);
|
||||
|
||||
|
||||
inline void io_5v_isol_sw___cntrl_vbat_s_enable(void) {
|
||||
inline void io_5v_isol_sw_enable(void) {
|
||||
// ParaMETEO - UC_CNTRL_VS
|
||||
GPIOB->BSRR |= GPIO_BSRR_BS8;
|
||||
}
|
||||
inline void io_5v_isol_sw___cntrl_vbat_s_disable(void) {
|
||||
inline void io_5v_isol_sw_disable(void) {
|
||||
// ParaMETEO - UC_CNTRL_VS
|
||||
GPIOB->BSRR |= GPIO_BSRR_BR8;
|
||||
}
|
||||
|
||||
inline void io_12v_sw___cntrl_vbat_g_enable(void) {
|
||||
inline void io_12v_sw_enable(void) {
|
||||
// ParaMETEO - UC_CNTRL_VG
|
||||
GPIOA->BSRR |= GPIO_BSRR_BS6;
|
||||
|
||||
}
|
||||
inline void io_12v_sw___cntrl_vbat_g_disable(void) {
|
||||
inline void io_12v_sw_disable(void) {
|
||||
// ParaMETEO - UC_CNTRL_VG
|
||||
GPIOA->BSRR |= GPIO_BSRR_BR6;
|
||||
|
||||
|
@ -61,11 +61,42 @@ inline uint8_t io_get_12v_sw___cntrl_vbat_g(void) {
|
|||
}
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_g_enable(void) {
|
||||
GPIOA->BSRR |= GPIO_BSRR_BS6;
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_g_disable(void) {
|
||||
GPIOA->BSRR |= GPIO_BSRR_BR6;
|
||||
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_s_enable(void) {
|
||||
GPIOC->BSRR |= GPIO_BSRR_BS13;
|
||||
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_s_disable(void) {
|
||||
GPIOC->BSRR |= GPIO_BSRR_BR13;
|
||||
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_c_enable(void) {
|
||||
GPIOA->BSRR |= GPIO_BSRR_BS1;
|
||||
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_c_disable(void) {
|
||||
GPIOA->BSRR |= GPIO_BSRR_BR1;
|
||||
|
||||
}
|
||||
|
||||
inline void io___cntrl_vbat_r_enable(void) {
|
||||
;
|
||||
GPIOB->BSRR |= GPIO_BSRR_BS1;
|
||||
|
||||
}
|
||||
inline void io___cntrl_vbat_r_disable(void) {
|
||||
;
|
||||
GPIOB->BSRR |= GPIO_BSRR_BR1;
|
||||
|
||||
}
|
||||
|
||||
#endif /* IO_H_ */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "config_data.h"
|
||||
|
||||
#define SW_VER "EA05"
|
||||
#define SW_DATE "06032022"
|
||||
#define SW_DATE "26032022"
|
||||
|
||||
#define SYSTICK_TICKS_PER_SECONDS 100
|
||||
#define SYSTICK_TICKS_PERIOD 10
|
||||
|
|
|
@ -14,21 +14,21 @@
|
|||
* 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 |
|
||||
* | | | | | |
|
||||
* | | | sensors | Internal / external | GPRS |
|
||||
* | | | | VHF Radio | |
|
||||
* =------------------------------------------------------------=
|
||||
* | C0 |Running| ON | ON | ON |
|
||||
* | C1 |Running| ON | ON | OFF |
|
||||
* | C2 |Running| OFF | ON | OFF |
|
||||
* | C3 |Running| OFF | ON | ON |
|
||||
* | M4 |Running| ON | OFF | OFF |
|
||||
* | I5 |Running| OFF | OFF | OFF |
|
||||
* | L6 | Stop2 | OFF | OFF | ON |
|
||||
* | L7 | Stop2 | OFF | OFF | OFF |
|
||||
* \------------------------------------------------------------/
|
||||
* /----------------------------------------------------------------------\
|
||||
* | 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 |
|
||||
* \----------------------------------------------------------------------/
|
||||
*
|
||||
* C = modes with communication enabled
|
||||
* M = mode with measuremenet only w/o any communication
|
||||
|
|
43
src/io.c
43
src/io.c
|
@ -55,15 +55,6 @@ void io_ext_watchdog_config(void) {
|
|||
Configure_GPIO(GPIOA,12,GPPP_OUTPUT_50MHZ);
|
||||
#endif
|
||||
|
||||
#ifdef STM32L471xx
|
||||
GPIO_InitTypeDef.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitTypeDef.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitTypeDef.Pin = LL_GPIO_PIN_1;
|
||||
GPIO_InitTypeDef.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitTypeDef.Speed = LL_GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitTypeDef.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitTypeDef);
|
||||
#endif
|
||||
}
|
||||
|
||||
void io_ext_watchdog_service(void) {
|
||||
|
@ -83,37 +74,3 @@ void io_ext_watchdog_service(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
//#ifdef STM32F10X_MD_VL
|
||||
//void io_5v_isol_sw_cntrl_vbat_s_enable(void) {
|
||||
// //GPIO_SetBits(GPIOB, GPIO_Pin_8);
|
||||
// GPIOB->BSRR |= GPIO_BSRR_BS8;
|
||||
//}
|
||||
//void io_5v_isol_sw_cntrl_vbat_s_disable(void) {
|
||||
// //GPIO_ResetBits(GPIOB, GPIO_Pin_8);
|
||||
// GPIOB->BSRR |= GPIO_BSRR_BR8;
|
||||
//}
|
||||
//
|
||||
//void io_12v_sw_cntrl_vbat_g_enable(void) {
|
||||
// //GPIO_SetBits(GPIOA, GPIO_Pin_6);
|
||||
// GPIOA->BSRR |= GPIO_BSRR_BS6;
|
||||
//
|
||||
//}
|
||||
//void io_12v_sw_cntrl_vbat_g_disable(void) {
|
||||
// //GPIO_ResetBits(GPIOA, GPIO_Pin_6);
|
||||
// GPIOA->BSRR |= GPIO_BSRR_BR6;
|
||||
//
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
//
|
||||
//#ifdef STM32L471xx
|
||||
//void io_5v_isol_sw_cntrl_vbat_s_enable(void) {
|
||||
//}
|
||||
//void io_5v_isol_sw_cntrl_vbat_s_disable(void) {
|
||||
//}
|
||||
//
|
||||
//void io_12v_sw_cntrl_vbat_g_enable(void) {
|
||||
//}
|
||||
//void io_12v_sw_cntrl_vbat_g_disable(void) {
|
||||
//}
|
||||
//#endif
|
||||
|
|
|
@ -203,14 +203,17 @@ int pwr_save_switch_mode_to_c0(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// turn ON +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
// turn ON +5V_S
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
// turn ON +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_enable();
|
||||
|
||||
// turn ON +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_enable();
|
||||
io___cntrl_vbat_g_enable();
|
||||
|
||||
// turn ON +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_enable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -236,13 +239,16 @@ int pwr_save_switch_mode_to_c1(void) {
|
|||
}
|
||||
|
||||
// turn ON +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
// turn ON +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_enable();
|
||||
|
||||
// turn OFF +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_disable();
|
||||
io___cntrl_vbat_g_disable();
|
||||
|
||||
// turn ON +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_enable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -269,13 +275,16 @@ void pwr_save_switch_mode_to_c2(void) {
|
|||
}
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_disable();
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
// turn ON +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_enable();
|
||||
|
||||
// turn OFF +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_disable();
|
||||
io___cntrl_vbat_g_disable();
|
||||
|
||||
// turn ON +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_enable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -298,13 +307,16 @@ void pwr_save_switch_mode_to_c3(void) {
|
|||
}
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_disable();
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
// turn ON +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_enable();
|
||||
|
||||
// turn ON +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_enable();
|
||||
io___cntrl_vbat_g_enable();
|
||||
|
||||
// turn ON +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_enable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -328,13 +340,16 @@ int pwr_save_switch_mode_to_m4(void) {
|
|||
}
|
||||
|
||||
// turn ON +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
// turn OFF +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_disable();
|
||||
|
||||
// turn OFF +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_disable();
|
||||
io___cntrl_vbat_g_disable();
|
||||
|
||||
// turn ON +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_enable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -358,13 +373,16 @@ void pwr_save_switch_mode_to_i5(void) {
|
|||
}
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_disable();
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
// turn OFF +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_disable();
|
||||
|
||||
// turn OFF +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_disable();
|
||||
io___cntrl_vbat_g_disable();
|
||||
|
||||
// turn OFF +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_disable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -388,13 +406,16 @@ void pwr_save_switch_mode_to_l6(uint16_t sleep_time) {
|
|||
}
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_disable();
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
// turn OFF +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_disable();
|
||||
|
||||
// turn ON +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_enable();
|
||||
io___cntrl_vbat_g_enable();
|
||||
|
||||
// turn OFF +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_disable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
@ -429,13 +450,16 @@ void pwr_save_switch_mode_to_l7(uint16_t sleep_time) {
|
|||
}
|
||||
|
||||
// turn OFF +5V_S (and internal VHF radio module in HW-RevB)
|
||||
io_5v_isol_sw___cntrl_vbat_s_disable();
|
||||
io___cntrl_vbat_s_disable();
|
||||
|
||||
// turn OFF +5V_R and VBATT_SW_R
|
||||
io___cntrl_vbat_r_disable();
|
||||
|
||||
// turn OFF +4V_G
|
||||
io_12v_sw___cntrl_vbat_g_disable();
|
||||
io___cntrl_vbat_g_disable();
|
||||
|
||||
// turn OFF +5V_C (SD card, PT100 interface and Op Amplifier)
|
||||
io___cntrl_vbat_c_disable();
|
||||
|
||||
// unlock access to backup registers
|
||||
pwr_save_unclock_rtc_backup_regs();
|
||||
|
|
|
@ -37,11 +37,7 @@ void wx_pwr_switch_case_under_reset_parameteo() {
|
|||
if (pwr_save_get_inhibit_pwr_switch_periodic() == 1)
|
||||
return;
|
||||
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
|
||||
#ifdef PWR_SWITCH_BOTH
|
||||
io_12v_sw___cntrl_vbat_g_enable();
|
||||
#endif
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
wx_force_i2c_sensor_reset = 1;
|
||||
|
||||
|
@ -52,10 +48,10 @@ void wx_pwr_switch_case_under_reset_parameteo() {
|
|||
void wx_pwr_switch_case_under_reset_paratnc() {
|
||||
|
||||
// Turn on the +5V_ISOL (VDD_SW) voltage
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
io_5v_isol_sw_enable();
|
||||
|
||||
#ifdef PWR_SWITCH_BOTH
|
||||
io_12v_sw___cntrl_vbat_g_enable();
|
||||
io_12v_sw_enable();
|
||||
|
||||
wx_force_i2c_sensor_reset = 1;
|
||||
#endif
|
||||
|
@ -69,9 +65,7 @@ void wx_pwr_switch_case_off_parameteo() {
|
|||
return;
|
||||
|
||||
// Turn on the +5V_ISOL (VDD_SW) voltage
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
|
||||
io_12v_sw___cntrl_vbat_g_enable();
|
||||
io___cntrl_vbat_s_enable();
|
||||
|
||||
wx_force_i2c_sensor_reset = 1;
|
||||
|
||||
|
@ -88,7 +82,7 @@ void wx_pwr_switch_case_off_paratnc() {
|
|||
|
||||
// Turn on the +5V_ISOL (VDD_SW) voltage
|
||||
//GPIO_SetBits(GPIOB, GPIO_Pin_8);
|
||||
io_5v_isol_sw___cntrl_vbat_s_enable();
|
||||
io_5v_isol_sw_enable();
|
||||
}
|
||||
|
||||
void wx_pwr_switch_init(void) {
|
||||
|
@ -127,18 +121,16 @@ void wx_pwr_switch_init(void) {
|
|||
#if defined(STM32L471xx)
|
||||
LL_GPIO_InitTypeDef GPIO_InitTypeDef;
|
||||
|
||||
// PB8 - UC_CNTRL_VS
|
||||
// in ParaMETEO HW-RevB it is connected internally to SENSORS_PWR_CNTRL and +5V_SW_C_PWR_CNTRL
|
||||
// PC13 - UC_CNTRL_VS
|
||||
GPIO_InitTypeDef.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitTypeDef.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitTypeDef.Pin = LL_GPIO_PIN_8;
|
||||
GPIO_InitTypeDef.Pin = LL_GPIO_PIN_13;
|
||||
GPIO_InitTypeDef.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitTypeDef.Speed = LL_GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitTypeDef.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitTypeDef);
|
||||
LL_GPIO_Init(GPIOC, &GPIO_InitTypeDef);
|
||||
|
||||
// PA6 - UC_CNTRL_VG
|
||||
// in ParaMETEO HW-RevB it is connected internally to GSM_PWR_CNTRL and RADIO_PWR_CNTRL
|
||||
GPIO_InitTypeDef.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitTypeDef.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitTypeDef.Pin = LL_GPIO_PIN_6;
|
||||
|
@ -147,6 +139,24 @@ void wx_pwr_switch_init(void) {
|
|||
GPIO_InitTypeDef.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitTypeDef);
|
||||
|
||||
// PA1 - UC_CNTRL_VC
|
||||
GPIO_InitTypeDef.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitTypeDef.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitTypeDef.Pin = LL_GPIO_PIN_1;
|
||||
GPIO_InitTypeDef.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitTypeDef.Speed = LL_GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitTypeDef.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitTypeDef);
|
||||
|
||||
// PB1 - UC_CNTRL_VC
|
||||
GPIO_InitTypeDef.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitTypeDef.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitTypeDef.Pin = LL_GPIO_PIN_1;
|
||||
GPIO_InitTypeDef.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitTypeDef.Speed = LL_GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitTypeDef.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitTypeDef);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -175,13 +185,18 @@ void wx_pwr_switch_periodic_handle(void) {
|
|||
// if timeout watchod expired there is a time to reset the supply voltage
|
||||
wx_pwr_state = WX_PWR_UNDER_RESET;
|
||||
|
||||
#if (defined STM32F10X_MD_VL)
|
||||
// pull the output down to switch the relay and disable +5V_ISOL (VDD_SW)
|
||||
io_5v_isol_sw___cntrl_vbat_s_disable();
|
||||
io_5v_isol_sw_disable();
|
||||
|
||||
#ifdef PWR_SWITCH_BOTH
|
||||
io_12v_sw___cntrl_vbat_g_disable();
|
||||
io_12v_sw_disable();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined STM32L471xx)
|
||||
io___cntrl_vbat_s_disable();
|
||||
#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;
|
||||
|
|
Ładowanie…
Reference in New Issue