/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "Bluecell_operate.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */


/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */
extern volatile uint16_t ADC1value[4];
extern volatile uint16_t ADC3value[5];

extern uint32_t adc1cnt;
extern uint32_t adc3cnt;

extern ADC_HandleTypeDef hadc1;
extern ADC_HandleTypeDef hadc3;
extern I2C_HandleTypeDef hi2c2;


/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define LED_FAIL2_Pin GPIO_PIN_3
#define LED_FAIL2_GPIO_Port GPIOE
#define FAIL_MBIC_Pin GPIO_PIN_4
#define FAIL_MBIC_GPIO_Port GPIOE
#define BOOT_LED_Pin GPIO_PIN_15
#define BOOT_LED_GPIO_Port GPIOC
#define DET_UL4_OUT_Pin GPIO_PIN_6
#define DET_UL4_OUT_GPIO_Port GPIOF
#define DET_DL1_IN_Pin GPIO_PIN_7
#define DET_DL1_IN_GPIO_Port GPIOF
#define DET_DL2_IN_Pin GPIO_PIN_8
#define DET_DL2_IN_GPIO_Port GPIOF
#define DET_DL3_IN_Pin GPIO_PIN_9
#define DET_DL3_IN_GPIO_Port GPIOF
#define DET_DL4_IN_Pin GPIO_PIN_10
#define DET_DL4_IN_GPIO_Port GPIOF
#define RFU_TEMP_Pin GPIO_PIN_2
#define RFU_TEMP_GPIO_Port GPIOC
#define RFU_TX_Pin GPIO_PIN_2
#define RFU_TX_GPIO_Port GPIOA
#define RFU_RX_Pin GPIO_PIN_3
#define RFU_RX_GPIO_Port GPIOA
#define DET_UL1_OUT_Pin GPIO_PIN_4
#define DET_UL1_OUT_GPIO_Port GPIOA
#define DET_UL2_OUT_Pin GPIO_PIN_5
#define DET_UL2_OUT_GPIO_Port GPIOA
#define DET_UL3_OUT_Pin GPIO_PIN_6
#define DET_UL3_OUT_GPIO_Port GPIOA
#define ATT_CLOCK3_Pin GPIO_PIN_0
#define ATT_CLOCK3_GPIO_Port GPIOG
#define ATT_DATA3_Pin GPIO_PIN_1
#define ATT_DATA3_GPIO_Port GPIOG
#define ATT_CLOCK4_Pin GPIO_PIN_10
#define ATT_CLOCK4_GPIO_Port GPIOE
#define ATT_DATA4_Pin GPIO_PIN_11
#define ATT_DATA4_GPIO_Port GPIOE
#define ATT_EN_DL4_Pin GPIO_PIN_12
#define ATT_EN_DL4_GPIO_Port GPIOE
#define ATT_EN_UL4_Pin GPIO_PIN_13
#define ATT_EN_UL4_GPIO_Port GPIOE
#define PATH_EN_DL4_Pin GPIO_PIN_14
#define PATH_EN_DL4_GPIO_Port GPIOE
#define PATH_EN_UL4_Pin GPIO_PIN_15
#define PATH_EN_UL4_GPIO_Port GPIOE
#define EEPROM_SCL_Pin GPIO_PIN_10
#define EEPROM_SCL_GPIO_Port GPIOB
#define EEPROM_SDA_Pin GPIO_PIN_11
#define EEPROM_SDA_GPIO_Port GPIOB
#define ATT_EN_UL1_Pin GPIO_PIN_14
#define ATT_EN_UL1_GPIO_Port GPIOB
#define PATH_EN_DL1_Pin GPIO_PIN_15
#define PATH_EN_DL1_GPIO_Port GPIOB
#define PATH_EN_DL2_Pin GPIO_PIN_10
#define PATH_EN_DL2_GPIO_Port GPIOD
#define PATH_EN_UL2_Pin GPIO_PIN_11
#define PATH_EN_UL2_GPIO_Port GPIOD
#define LED_ACT_Pin GPIO_PIN_14
#define LED_ACT_GPIO_Port GPIOD
#define LED_FAIL_Pin GPIO_PIN_15
#define LED_FAIL_GPIO_Port GPIOD
#define ATT_EN_DL3_Pin GPIO_PIN_2
#define ATT_EN_DL3_GPIO_Port GPIOG
#define ATT_EN_UL3_Pin GPIO_PIN_3
#define ATT_EN_UL3_GPIO_Port GPIOG
#define PATH_EN_DL3_Pin GPIO_PIN_4
#define PATH_EN_DL3_GPIO_Port GPIOG
#define PATH_EN_UL3_Pin GPIO_PIN_5
#define PATH_EN_UL3_GPIO_Port GPIOG
#define _PATH_SW1_Pin GPIO_PIN_8
#define _PATH_SW1_GPIO_Port GPIOG
#define PATH_EN_UL1_Pin GPIO_PIN_6
#define PATH_EN_UL1_GPIO_Port GPIOC
#define MBIC_UP_Pin GPIO_PIN_9
#define MBIC_UP_GPIO_Port GPIOA
#define MBIC_DOWN_Pin GPIO_PIN_10
#define MBIC_DOWN_GPIO_Port GPIOA
#define UNIT_ID0_Pin GPIO_PIN_10
#define UNIT_ID0_GPIO_Port GPIOC
#define UNIT_ID1_Pin GPIO_PIN_11
#define UNIT_ID1_GPIO_Port GPIOC
#define UNIT_ID2_Pin GPIO_PIN_12
#define UNIT_ID2_GPIO_Port GPIOC
#define UNIT_ID3_Pin GPIO_PIN_0
#define UNIT_ID3_GPIO_Port GPIOD
#define ATT_CLOCK2_Pin GPIO_PIN_2
#define ATT_CLOCK2_GPIO_Port GPIOD
#define ATT_DATA2_Pin GPIO_PIN_3
#define ATT_DATA2_GPIO_Port GPIOD
#define ATT_EN_DL2_Pin GPIO_PIN_4
#define ATT_EN_DL2_GPIO_Port GPIOD
#define ATT_EN_UL2_Pin GPIO_PIN_7
#define ATT_EN_UL2_GPIO_Port GPIOD
#define PATH_SW1_Pin GPIO_PIN_9
#define PATH_SW1_GPIO_Port GPIOG
#define _PATH_SW2_Pin GPIO_PIN_10
#define _PATH_SW2_GPIO_Port GPIOG
#define PATH_SW2_Pin GPIO_PIN_11
#define PATH_SW2_GPIO_Port GPIOG
#define _PATH_SW3_Pin GPIO_PIN_12
#define _PATH_SW3_GPIO_Port GPIOG
#define PATH_SW3_Pin GPIO_PIN_13
#define PATH_SW3_GPIO_Port GPIOG
#define _PATH_SW4_Pin GPIO_PIN_14
#define _PATH_SW4_GPIO_Port GPIOG
#define PATH_SW4_Pin GPIO_PIN_15
#define PATH_SW4_GPIO_Port GPIOG
#define ATT_CLOCK1_Pin GPIO_PIN_6
#define ATT_CLOCK1_GPIO_Port GPIOB
#define ATT_DATA1_Pin GPIO_PIN_7
#define ATT_DATA1_GPIO_Port GPIOB
#define ATT_EN_DL1_Pin GPIO_PIN_9
#define ATT_EN_DL1_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
#define MBIC_ON_MAINTAIN_SEC 3000
#define MBIC_ON_SHUTDOWN_MAINTAIN_SEC 5000//5
#define MBIC_RECOVERY_SHUTDOWN_MAINTAIN_SEC 20000//30
#define MBIC_RECOVERY_LAST_SHUTDOWN_MAINTAIN_SEC  52000 * 5 //5min
#define MBIC_RECOVERY_SELFTEST_TIMER_SEC 1800000 //30min



#define MBIC_OFF_MAINTAIN_SEC 10000

#define ADC_AVERAGECNT 100
#define ADC1_CNT 4
#define ADC3_CNT 5

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
