/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2026 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* 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 */

/* 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 */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define DIGI_OUT5_Pin GPIO_PIN_13
#define DIGI_OUT5_GPIO_Port GPIOC
#define DIGI_OUT6_Pin GPIO_PIN_14
#define DIGI_OUT6_GPIO_Port GPIOC
#define DIGI_OUT7_Pin GPIO_PIN_15
#define DIGI_OUT7_GPIO_Port GPIOC
#define AIN1_Pin GPIO_PIN_0
#define AIN1_GPIO_Port GPIOA
#define AIN2_Pin GPIO_PIN_1
#define AIN2_GPIO_Port GPIOA
#define RS485_Addr0_Pin GPIO_PIN_2
#define RS485_Addr0_GPIO_Port GPIOA
#define RS485_Addr1_Pin GPIO_PIN_3
#define RS485_Addr1_GPIO_Port GPIOA
#define RS485_Addr2_Pin GPIO_PIN_4
#define RS485_Addr2_GPIO_Port GPIOA
#define RS485_Addr3_Pin GPIO_PIN_5
#define RS485_Addr3_GPIO_Port GPIOA
#define SYS_CFG0_Pin GPIO_PIN_6
#define SYS_CFG0_GPIO_Port GPIOA
#define SYS_CFG1_Pin GPIO_PIN_7
#define SYS_CFG1_GPIO_Port GPIOA
#define DIGI_OUT0_Pin GPIO_PIN_0
#define DIGI_OUT0_GPIO_Port GPIOB
#define DIGI_OUT1_Pin GPIO_PIN_1
#define DIGI_OUT1_GPIO_Port GPIOB
#define DIGI_OUT2_Pin GPIO_PIN_2
#define DIGI_OUT2_GPIO_Port GPIOB
#define I2C2_SCL_CE_Pin GPIO_PIN_10
#define I2C2_SCL_CE_GPIO_Port GPIOB
#define I2C2_SDA_CE_Pin GPIO_PIN_11
#define I2C2_SDA_CE_GPIO_Port GPIOB
#define RS485_Addr4_Pin GPIO_PIN_12
#define RS485_Addr4_GPIO_Port GPIOB
#define RS485_Addr5_Pin GPIO_PIN_13
#define RS485_Addr5_GPIO_Port GPIOB
#define RS485_Addr6_Pin GPIO_PIN_14
#define RS485_Addr6_GPIO_Port GPIOB
#define RS485_Addr7_Pin GPIO_PIN_15
#define RS485_Addr7_GPIO_Port GPIOB
#define PG_RS485_Pin GPIO_PIN_8
#define PG_RS485_GPIO_Port GPIOA
#define TX_RS485_Pin GPIO_PIN_9
#define TX_RS485_GPIO_Port GPIOA
#define RX_RS485_Pin GPIO_PIN_10
#define RX_RS485_GPIO_Port GPIOA
#define PG_CE_Pin GPIO_PIN_11
#define PG_CE_GPIO_Port GPIOA
#define TX_EN_RS485_Pin GPIO_PIN_12
#define TX_EN_RS485_GPIO_Port GPIOA
#define PG_PH_Pin GPIO_PIN_15
#define PG_PH_GPIO_Port GPIOA
#define Calib_PH_Pin GPIO_PIN_3
#define Calib_PH_GPIO_Port GPIOB
#define LED_Red_Pin GPIO_PIN_4
#define LED_Red_GPIO_Port GPIOB
#define LED_Green_Pin GPIO_PIN_5
#define LED_Green_GPIO_Port GPIOB
#define I2C1_SCL_PH_Pin GPIO_PIN_6
#define I2C1_SCL_PH_GPIO_Port GPIOB
#define I2C1_SDA_PH_Pin GPIO_PIN_7
#define I2C1_SDA_PH_GPIO_Port GPIOB
#define DIGI_OUT3_Pin GPIO_PIN_8
#define DIGI_OUT3_GPIO_Port GPIOB
#define DIGI_OUT4_Pin GPIO_PIN_9
#define DIGI_OUT4_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */

#define 	STATE_RUNNING_OK				0x00
#define 	STATE_NO_SETUP_CALIBRATION		0x01
#define 	STATE_PH4_DRY_EC_CALIBRATION	0x02
#define 	STATE_PH7_WET_EC_CALIBRATION	0x03
#define 	STATE_RS485_SUPPLY_FAULT		0x04
#define 	STATE_PH_SUPPLY_FAULT			0x05
#define 	STATE_EC_RTD_SUPPLY_FAULT		0x06
#define 	STATE_HIGH_AMBIENT_TEMPERATURE	0x07

extern uint8_t main_state;
/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
