2020-06-11 18:36:36 +00:00
|
|
|
/*
|
|
|
|
* io.h
|
|
|
|
*
|
|
|
|
* Created on: 11.06.2020
|
|
|
|
* Author: mateusz
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IO_H_
|
|
|
|
#define IO_H_
|
|
|
|
|
2022-04-19 17:56:53 +00:00
|
|
|
/**
|
|
|
|
* This header file (and corresponding .c file is responsible for configuring and servicing
|
|
|
|
* various things connected to GPIO pins. Watchdog, Output collector out (for ParaTNC) and
|
|
|
|
* switching on/off different voltages across both ParaTNC and ParaMETEO
|
|
|
|
*/
|
|
|
|
|
2021-06-13 18:25:45 +00:00
|
|
|
#ifdef STM32F10X_MD_VL
|
|
|
|
#include <stm32f10x.h>
|
|
|
|
#endif
|
|
|
|
#ifdef STM32L471xx
|
|
|
|
#include <stm32l4xx.h>
|
|
|
|
#endif
|
|
|
|
|
2022-05-14 19:49:48 +00:00
|
|
|
void io_uart_init(void);
|
|
|
|
|
2020-06-11 18:36:36 +00:00
|
|
|
void io_oc_init(void);
|
|
|
|
void io_oc_output_low(void);
|
|
|
|
void io_oc_output_hiz(void);
|
|
|
|
|
2022-03-26 18:43:41 +00:00
|
|
|
void io_pwr_init(void);
|
|
|
|
|
2021-06-13 06:36:32 +00:00
|
|
|
void io_ext_watchdog_config(void);
|
|
|
|
void io_ext_watchdog_service(void);
|
2020-06-11 18:36:36 +00:00
|
|
|
|
2023-06-10 15:51:41 +00:00
|
|
|
void io_buttons_init(void);
|
|
|
|
|
2022-04-20 20:30:29 +00:00
|
|
|
#ifdef PARAMETEO
|
2022-04-05 17:01:57 +00:00
|
|
|
void io_vbat_meas_init(int16_t a_coeff, int16_t b_coeff);
|
2022-03-26 18:43:41 +00:00
|
|
|
uint16_t io_vbat_meas_get(void);
|
2022-04-20 20:30:29 +00:00
|
|
|
uint16_t io_vbat_meas_average(uint16_t sample);
|
2022-11-05 16:54:50 +00:00
|
|
|
void io_vbat_meas_disable(void);
|
|
|
|
void io_vbat_meas_enable(void);
|
2023-02-01 15:05:18 +00:00
|
|
|
|
2023-02-02 20:50:42 +00:00
|
|
|
void io_pool_vbat_r(int16_t minutes_to_wx);
|
2022-04-20 20:30:29 +00:00
|
|
|
#endif
|
2022-03-26 18:43:41 +00:00
|
|
|
|
2023-04-09 17:30:09 +00:00
|
|
|
|
2022-11-05 16:54:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Keep this uncommented to configure ADC which monitor Vbatt to
|
|
|
|
* continous mode, instead of single shot
|
|
|
|
*/
|
|
|
|
//#define VBAT_MEAS_CONTINOUS
|
2021-06-13 18:25:45 +00:00
|
|
|
|
2022-03-26 16:57:36 +00:00
|
|
|
inline void io_5v_isol_sw_enable(void) {
|
2021-09-01 21:12:24 +00:00
|
|
|
// ParaMETEO - UC_CNTRL_VS
|
2021-06-13 18:25:45 +00:00
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
2022-03-26 16:57:36 +00:00
|
|
|
inline void io_5v_isol_sw_disable(void) {
|
2021-09-01 21:12:24 +00:00
|
|
|
// ParaMETEO - UC_CNTRL_VS
|
2021-06-13 18:25:45 +00:00
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
|
2022-03-26 16:57:36 +00:00
|
|
|
inline void io_12v_sw_enable(void) {
|
2021-09-01 21:12:24 +00:00
|
|
|
// ParaMETEO - UC_CNTRL_VG
|
2021-06-13 18:25:45 +00:00
|
|
|
GPIOA->BSRR |= GPIO_BSRR_BS6;
|
|
|
|
|
|
|
|
}
|
2022-03-26 16:57:36 +00:00
|
|
|
inline void io_12v_sw_disable(void) {
|
2021-09-01 21:12:24 +00:00
|
|
|
// ParaMETEO - UC_CNTRL_VG
|
2021-06-13 18:25:45 +00:00
|
|
|
GPIOA->BSRR |= GPIO_BSRR_BR6;
|
|
|
|
|
|
|
|
}
|
2020-06-11 18:36:36 +00:00
|
|
|
|
2021-09-11 19:04:08 +00:00
|
|
|
inline uint8_t io_get_5v_isol_sw___cntrl_vbat_s(void) {
|
|
|
|
if ((GPIOB->ODR & (1 << 8)) != 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint8_t io_get_12v_sw___cntrl_vbat_g(void) {
|
|
|
|
if ((GPIOA->ODR & (1 << 6)) != 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-29 17:00:12 +00:00
|
|
|
#ifdef PARAMETEO
|
2022-03-26 16:57:36 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-09-01 21:12:24 +00:00
|
|
|
inline void io___cntrl_vbat_r_enable(void) {
|
2022-03-26 16:57:36 +00:00
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BS1;
|
|
|
|
|
2021-09-01 21:12:24 +00:00
|
|
|
}
|
|
|
|
inline void io___cntrl_vbat_r_disable(void) {
|
2022-03-26 16:57:36 +00:00
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BR1;
|
|
|
|
|
2021-09-01 21:12:24 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 18:55:27 +00:00
|
|
|
inline void io___cntrl_vbat_m_enable(void) {
|
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BS0;
|
|
|
|
|
|
|
|
}
|
|
|
|
inline void io___cntrl_vbat_m_disable(void) {
|
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BR0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-05-06 12:53:21 +00:00
|
|
|
inline void io___cntrl_gprs_pwrkey_press() {
|
|
|
|
GPIOA->BSRR |= GPIO_BSRR_BS7;
|
|
|
|
|
|
|
|
}
|
|
|
|
inline void io___cntrl_gprs_pwrkey_release() {
|
|
|
|
GPIOA->BSRR |= GPIO_BSRR_BR7;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-05-14 19:49:48 +00:00
|
|
|
inline void io___cntrl_gprs_dtr_low() {
|
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BR8;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void io___cntrl_gprs_dtr_high() {
|
|
|
|
GPIOB->BSRR |= GPIO_BSRR_BS8;
|
|
|
|
}
|
|
|
|
|
2023-10-29 05:36:28 +00:00
|
|
|
inline uint8_t io_get_cntrl_vbat_g(void) {
|
|
|
|
uint8_t out = 0;
|
|
|
|
|
|
|
|
if ((GPIOA->ODR & GPIO_ODR_ODR_6) != 0) {
|
|
|
|
out = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2022-04-05 19:21:28 +00:00
|
|
|
inline uint8_t io_get_cntrl_vbat_c(void) {
|
|
|
|
uint8_t out = 0;
|
|
|
|
|
|
|
|
if ((GPIOA->ODR & GPIO_ODR_ODR_1) != 0) {
|
|
|
|
out = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2022-05-07 14:17:55 +00:00
|
|
|
inline uint8_t io_get_cntrl_vbat_s(void) {
|
|
|
|
uint8_t out = 0;
|
|
|
|
|
|
|
|
if ((GPIOC->ODR & GPIO_ODR_ODR_13) != 0) {
|
|
|
|
out = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
2023-07-22 22:06:46 +00:00
|
|
|
|
|
|
|
inline uint8_t io_get_cntrl_vbat_m(void) {
|
|
|
|
uint8_t out = 0;
|
|
|
|
|
|
|
|
if ((GPIOB->ODR & GPIO_BSRR_BS0) != 0) {
|
|
|
|
out = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2022-07-16 13:01:10 +00:00
|
|
|
#else
|
|
|
|
inline uint8_t io_get_cntrl_vbat_s(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
2022-05-07 14:17:55 +00:00
|
|
|
|
2023-08-09 09:00:43 +00:00
|
|
|
inline uint8_t io_get_cntrl_vbat_m(void) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-07-16 13:01:10 +00:00
|
|
|
#endif
|
2022-04-05 19:21:28 +00:00
|
|
|
|
2020-06-11 18:36:36 +00:00
|
|
|
#endif /* IO_H_ */
|