SP8EBC-ParaTNC/src/io.c

77 wiersze
1.2 KiB
C
Czysty Zwykły widok Historia

2020-06-11 18:36:36 +00:00
/*
* io.c
*
* Created on: 11.06.2020
* Author: mateusz
*/
2021-06-13 06:36:32 +00:00
#include "station_config_target_hw.h"
2020-06-11 18:36:36 +00:00
#include "io.h"
2021-06-13 06:36:32 +00:00
#ifdef STM32F10X_MD_VL
2020-06-11 18:36:36 +00:00
#include <stm32f10x.h>
#include <drivers/f1/gpio_conf_stm32f1x.h>
2021-06-13 06:36:32 +00:00
#endif
#ifdef STM32L471xx
#include <stm32l4xx.h>
#include <stm32l4xx_ll_gpio.h>
#endif
2020-06-11 18:36:36 +00:00
#include "station_config.h"
2021-06-13 06:36:32 +00:00
#if defined(PARAMETEO)
LL_GPIO_InitTypeDef GPIO_InitTypeDef;
#endif
2020-06-11 18:36:36 +00:00
2021-06-13 06:36:32 +00:00
void io_oc_init(void) {
#ifdef STM32F10X_MD_VL
2020-06-11 18:36:36 +00:00
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
2021-06-13 06:36:32 +00:00
#endif
2020-06-11 18:36:36 +00:00
}
void io_oc_output_low(void) {
2021-06-13 06:36:32 +00:00
#ifdef STM32F10X_MD_VL
2020-06-11 18:36:36 +00:00
GPIO_SetBits(GPIOA, GPIO_Pin_11);
2021-06-13 06:36:32 +00:00
#endif
2020-06-11 18:36:36 +00:00
}
void io_oc_output_hiz(void) {
2021-06-13 06:36:32 +00:00
#ifdef STM32F10X_MD_VL
2020-06-11 18:36:36 +00:00
GPIO_ResetBits(GPIOA, GPIO_Pin_11);
2021-06-13 06:36:32 +00:00
#endif
}
void io_ext_watchdog_config(void) {
#ifdef STM32F10X_MD_VL
// initialize Watchdog output
Configure_GPIO(GPIOA,12,GPPP_OUTPUT_50MHZ);
#endif
}
void io_ext_watchdog_service(void) {
#ifdef STM32F10X_MD_VL
#endif
#ifdef STM32L471xx
if ((GPIOA->ODR & GPIO_ODR_OD1) == 0) {
// set high
GPIOA->BSRR |= GPIO_BSRR_BS1;
}
else {
// set low
GPIOA->BSRR |= GPIO_BSRR_BR1;
}
2021-06-13 06:36:32 +00:00
#endif
2020-06-11 18:36:36 +00:00
}