| 1 | /* USER CODE BEGIN Header */ | 
|---|
| 2 | /** | 
|---|
| 3 | ****************************************************************************** | 
|---|
| 4 | * @file           : main.h | 
|---|
| 5 | * @brief          : Header for main.c file. | 
|---|
| 6 | *                   This file contains the common defines of the application. | 
|---|
| 7 | ****************************************************************************** | 
|---|
| 8 | * @attention | 
|---|
| 9 | * | 
|---|
| 10 | * <h2><center>© Copyright (c) 2019 STMicroelectronics. | 
|---|
| 11 | * All rights reserved.</center></h2> | 
|---|
| 12 | * | 
|---|
| 13 | * This software component is licensed by ST under BSD 3-Clause license, | 
|---|
| 14 | * the "License"; You may not use this file except in compliance with the | 
|---|
| 15 | * License. You may obtain a copy of the License at: | 
|---|
| 16 | *                        opensource.org/licenses/BSD-3-Clause | 
|---|
| 17 | * | 
|---|
| 18 | ****************************************************************************** | 
|---|
| 19 | */ | 
|---|
| 20 | /* USER CODE END Header */ | 
|---|
| 21 |  | 
|---|
| 22 | /* Define to prevent recursive inclusion -------------------------------------*/ | 
|---|
| 23 | #ifndef __MAIN_H | 
|---|
| 24 | #define __MAIN_H | 
|---|
| 25 |  | 
|---|
| 26 | #ifdef __cplusplus | 
|---|
| 27 | extern "C" { | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | /* Includes ------------------------------------------------------------------*/ | 
|---|
| 31 | #include "stm32g0xx_hal.h" | 
|---|
| 32 |  | 
|---|
| 33 |  | 
|---|
| 34 | /* Private includes ----------------------------------------------------------*/ | 
|---|
| 35 | /* USER CODE BEGIN Includes */ | 
|---|
| 36 |  | 
|---|
| 37 | /* USER CODE END Includes */ | 
|---|
| 38 |  | 
|---|
| 39 | /* Exported types ------------------------------------------------------------*/ | 
|---|
| 40 | /* USER CODE BEGIN ET */ | 
|---|
| 41 |  | 
|---|
| 42 | /* USER CODE END ET */ | 
|---|
| 43 |  | 
|---|
| 44 | /* Exported constants --------------------------------------------------------*/ | 
|---|
| 45 | /* USER CODE BEGIN EC */ | 
|---|
| 46 |  | 
|---|
| 47 | /* USER CODE END EC */ | 
|---|
| 48 |  | 
|---|
| 49 | /* Exported macro ------------------------------------------------------------*/ | 
|---|
| 50 | /* USER CODE BEGIN EM */ | 
|---|
| 51 |  | 
|---|
| 52 | /* USER CODE END EM */ | 
|---|
| 53 |  | 
|---|
| 54 | /* Exported functions prototypes ---------------------------------------------*/ | 
|---|
| 55 | void Error_Handler(void); | 
|---|
| 56 |  | 
|---|
| 57 | /* USER CODE BEGIN EFP */ | 
|---|
| 58 |  | 
|---|
| 59 | /* USER CODE END EFP */ | 
|---|
| 60 |  | 
|---|
| 61 | /* Private defines -----------------------------------------------------------*/ | 
|---|
| 62 | #define ADC_DATA_READY_Pin GPIO_PIN_9 | 
|---|
| 63 | #define ADC_DATA_READY_GPIO_Port GPIOB | 
|---|
| 64 | #define AIN_U_SHUNT_Pin GPIO_PIN_0 | 
|---|
| 65 | #define AIN_U_SHUNT_GPIO_Port GPIOA | 
|---|
| 66 | //#define ADC_POWER_DOWN_Pin GPIO_PIN_4 | 
|---|
| 67 | //#define ADC_POWER_DOWN_GPIO_Port GPIOB | 
|---|
| 68 | #define ADC_RESET_Pin GPIO_PIN_5 | 
|---|
| 69 | #define ADC_RESET_GPIO_Port GPIOB | 
|---|
| 70 | #define ADC_START_CONV_Pin GPIO_PIN_12 | 
|---|
| 71 | #define ADC_START_CONV_GPIO_Port GPIOA | 
|---|
| 72 | #define ADC_SPI1_NSS_Pin GPIO_PIN_15 | 
|---|
| 73 | #define ADC_SPI1_NSS_GPIO_Port GPIOA | 
|---|
| 74 | #define ADC_SPI1_SCK_Pin GPIO_PIN_5 | 
|---|
| 75 | #define ADC_SPI1_SCK_GPIO_Port GPIOA | 
|---|
| 76 | #define ADC_SPI1_MISO_Pin GPIO_PIN_6 | 
|---|
| 77 | #define ADC_SPI1_MISO_GPIO_Port GPIOA | 
|---|
| 78 | #define ADC_SPI1_MOSI_Pin GPIO_PIN_7 | 
|---|
| 79 | #define ADC_SPI1_MOSI_GPIO_Port GPIOA | 
|---|
| 80 | #define ADC_FAST_P_Pin GPIO_PIN_3 | 
|---|
| 81 | #define ADC_FAST_P_GPIO_Port GPIOA | 
|---|
| 82 | #define ADC_FAST_N_Pin GPIO_PIN_4 | 
|---|
| 83 | #define ADC_FAST_N_GPIO_Port GPIOA | 
|---|
| 84 | #define AIN_VREF_MEAS_Pin GPIO_PIN_2 | 
|---|
| 85 | #define AIN_VREF_MEAS_GPIO_Port GPIOA | 
|---|
| 86 | #define TEMP_SENSOR_Pin GPIO_PIN_2 | 
|---|
| 87 | #define TEMP_SENSOR_GPIO_Port GPIOB | 
|---|
| 88 | #define OVP_ENABLE_Pin GPIO_PIN_8 | 
|---|
| 89 | #define OVP_ENABLE_GPIO_Port GPIOA | 
|---|
| 90 | #define LVP_ENABLE_Pin GPIO_PIN_9 | 
|---|
| 91 | #define LVP_ENABLE_GPIO_Port GPIOA | 
|---|
| 92 | #define BUTTON_Pin GPIO_PIN_6 | 
|---|
| 93 | #define BUTTON_GPIO_Port GPIOC | 
|---|
| 94 | #define LED_FUNCTION_Pin GPIO_PIN_10 | 
|---|
| 95 | #define LED_FUNCTION_GPIO_Port GPIOA | 
|---|
| 96 | #define LED_ERROR_Pin GPIO_PIN_11 | 
|---|
| 97 | #define LED_ERROR_GPIO_Port GPIOA | 
|---|
| 98 | #define RS485_R_Pin GPIO_PIN_6 | 
|---|
| 99 | #define RS485_R_GPIO_Port GPIOB | 
|---|
| 100 | #define RS485_D_Pin GPIO_PIN_7 | 
|---|
| 101 | #define RS485_D_GPIO_Port GPIOB | 
|---|
| 102 | #define AUX_EN_Pin GPIO_PIN_8 | 
|---|
| 103 | #define AUX_EN_GPIO_Port GPIOB | 
|---|
| 104 | /* USER CODE BEGIN Private defines */ | 
|---|
| 105 | #define LVP_SENSE_MEAS_Pin GPIO_PIN_1 | 
|---|
| 106 | #define LVP_SENSE_MEAS_GPIO_Port GPIOB | 
|---|
| 107 | #define OVP_SENSE_MEAS_Pin GPIO_PIN_0 | 
|---|
| 108 | #define OVP_SENSE_MEAS_GPIO_Port GPIOB | 
|---|
| 109 |  | 
|---|
| 110 |  | 
|---|
| 111 | #define AIN_U_BATTERY_PLUS_Pin GPIO_PIN_1 | 
|---|
| 112 | #define AIN_U_BATTERY_PLUS_GPIO_Port GPIOA | 
|---|
| 113 | #define AIN_U_BATTERY_MINUS_Pin GPIO_PIN_2 | 
|---|
| 114 | #define AIN_U_BATTERY_MINUS_GPIO_Port GPIOA | 
|---|
| 115 |  | 
|---|
| 116 | // mögliche Kommandos für das Command Register | 
|---|
| 117 | #define COMMAND_STORE_CONFIG                                                            1 | 
|---|
| 118 | #define COMMAND_FULL_RESTORE                                                            2 | 
|---|
| 119 | #define COMMAND_FACTORY_RESTORE                                                         3 | 
|---|
| 120 | #define COMMAND_RESTORE_LAST_SAVED_VALUES                                       4 | 
|---|
| 121 | #define COMMAND_RESTART                                                                         6 | 
|---|
| 122 | #define COMMAND_BATTERY_CURRENT_OFFSET_CAL                                      7 | 
|---|
| 123 | #define COMMAND_BATTERY_CURRENT_OFFSET_COMMONMODE_CAL           8 | 
|---|
| 124 | #define COMMAND_BATTERY_CURRENT_OFFSET_TEMP_CAL                         9 | 
|---|
| 125 | #define COMMAND_BATTERY_CURRENT_GAIN_CAL                                        10 | 
|---|
| 126 | #define COMMAND_BATTERY_CURRENT_GAIN_TEMP_SHUNT_CAL                     11 | 
|---|
| 127 | //#define COMMAND_BATTERY_CURRENT_GAIN_TEMP_CHIP_CAL            12 | 
|---|
| 128 | #define COMMAND_STORE_WITH_SERIAL_NUMBER                                        1234 | 
|---|
| 129 | #define COMMAND_SET_RDP_LEVEL0                                                          1010 | 
|---|
| 130 | #define COMMAND_SET_RDP_LEVEL1                                                          1011 | 
|---|
| 131 | #define COMMAND_SET_RDP_LEVEL1_AND_BOOTSEL                                      1012 | 
|---|
| 132 |  | 
|---|
| 133 | enum SOC_CALC_MODE{ | 
|---|
| 134 | SOC_CALC_MODE_AH_RATED, | 
|---|
| 135 | SOC_CALC_MODE_AH_AUTO, | 
|---|
| 136 | SOC_CALC_MODE_WH_RATED, | 
|---|
| 137 | SOC_CALC_MODE_WH_AUTO, | 
|---|
| 138 | SOC_CALC_MODE_WH_AUTO_TEMP, | 
|---|
| 139 | }; | 
|---|
| 140 |  | 
|---|
| 141 | typedef union error_message_t | 
|---|
| 142 | { | 
|---|
| 143 | char msg[sizeof(uint64_t)]; | 
|---|
| 144 | uint64_t number; | 
|---|
| 145 | } error_message_t; | 
|---|
| 146 |  | 
|---|
| 147 | // Defines um printf auszuschalten | 
|---|
| 148 | //#define PRINT_BATTERY_CURRENT | 
|---|
| 149 | //#define PRINT_BATTERY_VOLTAGE | 
|---|
| 150 | //#define PRINT_SHUNT_TEMPERATURE | 
|---|
| 151 | // | 
|---|
| 152 | //#define PRINT_STM32G0_SHUNTVOLTAGE | 
|---|
| 153 | //#define PRINT_STM32G0_CHIPTEMPERATURE | 
|---|
| 154 | //#define PRINT_STM32G0_VREF_MEASURE | 
|---|
| 155 |  | 
|---|
| 156 | //#define PRINT_FREQUENCY_MEASURE_RESULT | 
|---|
| 157 |  | 
|---|
| 158 | // Funktionen einkommentieren | 
|---|
| 159 | #define DO_HSI16_CALIBRATION | 
|---|
| 160 | //#define MCO_TEST_FUNCTION | 
|---|
| 161 | //#define CHECK_CHANGED_FREQUENCY | 
|---|
| 162 | /* USER CODE END Private defines */ | 
|---|
| 163 |  | 
|---|
| 164 | #ifdef __cplusplus | 
|---|
| 165 | } | 
|---|
| 166 | #endif | 
|---|
| 167 |  | 
|---|
| 168 | #endif /* __MAIN_H */ | 
|---|
| 169 |  | 
|---|
| 170 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | 
|---|