| [1] | 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) 2020 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 | /* Private includes ----------------------------------------------------------*/
|
|---|
| 34 | /* USER CODE BEGIN Includes */
|
|---|
| 35 |
|
|---|
| 36 | /* USER CODE END Includes */
|
|---|
| 37 |
|
|---|
| 38 | /* Exported types ------------------------------------------------------------*/
|
|---|
| 39 | /* USER CODE BEGIN ET */
|
|---|
| 40 |
|
|---|
| 41 | typedef enum SWITCH_MODE {SWITCH_OFF = 0, SWITCH_ON, SWITCH_AUTO} switch_mode_t;
|
|---|
| 42 | typedef enum RELAY_STATE {RELAY_IS_OPENED = 0, RELAY_IS_CLOSED, ONLY_BA_OPENED, ONLY_AB_OPENED} relay_state_t;
|
|---|
| 43 |
|
|---|
| 44 | /* USER CODE END ET */
|
|---|
| 45 |
|
|---|
| 46 | /* Exported constants --------------------------------------------------------*/
|
|---|
| 47 | /* USER CODE BEGIN EC */
|
|---|
| 48 |
|
|---|
| 49 | /* USER CODE END EC */
|
|---|
| 50 |
|
|---|
| 51 | /* Exported macro ------------------------------------------------------------*/
|
|---|
| 52 | /* USER CODE BEGIN EM */
|
|---|
| 53 |
|
|---|
| 54 | /* USER CODE END EM */
|
|---|
| 55 |
|
|---|
| 56 | /* Exported functions prototypes ---------------------------------------------*/
|
|---|
| 57 | void Error_Handler(void);
|
|---|
| 58 |
|
|---|
| 59 | /* USER CODE BEGIN EFP */
|
|---|
| 60 |
|
|---|
| [7] | 61 | #ifdef VARIANT_24V
|
|---|
| [4] | 62 | #define DISABLE_SHORTCUT_DETECTION_DURING_SWITCH_OFF
|
|---|
| [7] | 63 | #endif
|
|---|
| [1] | 64 |
|
|---|
| 65 | #ifdef DISABLE_SHORTCUT_DETECTION_DURING_SWITCH_OFF
|
|---|
| 66 | void DisableShortCutDetection(void);
|
|---|
| 67 | void EnableShortCutDetection(void);
|
|---|
| 68 | #endif
|
|---|
| 69 |
|
|---|
| 70 | /* USER CODE END EFP */
|
|---|
| 71 |
|
|---|
| 72 | /* Private defines -----------------------------------------------------------*/
|
|---|
| 73 | #define DISABLE_VBOOST_Pin GPIO_PIN_13
|
|---|
| 74 | #define DISABLE_VBOOST_GPIO_Port GPIOC
|
|---|
| 75 | #define TP2_Pin GPIO_PIN_14
|
|---|
| 76 | #define TP2_GPIO_Port GPIOC
|
|---|
| 77 | #define TP4_Pin GPIO_PIN_15
|
|---|
| 78 | #define TP4_GPIO_Port GPIOC
|
|---|
| 79 | #define SENSE_TEMP_Pin GPIO_PIN_0
|
|---|
| 80 | #define SENSE_TEMP_GPIO_Port GPIOA
|
|---|
| 81 | #define U_BAT_SENSE_Pin GPIO_PIN_1
|
|---|
| 82 | #define U_BAT_SENSE_GPIO_Port GPIOA
|
|---|
| 83 | #define I_PLUS_SENSE_Pin GPIO_PIN_2
|
|---|
| 84 | #define I_PLUS_SENSE_GPIO_Port GPIOA
|
|---|
| 85 | #define U_SW_SENSE_Pin GPIO_PIN_3
|
|---|
| 86 | #define U_SW_SENSE_GPIO_Port GPIOA
|
|---|
| 87 | #define DAC_A_Pin GPIO_PIN_4
|
|---|
| 88 | #define DAC_A_GPIO_Port GPIOA
|
|---|
| 89 | #define DAC_B_Pin GPIO_PIN_5
|
|---|
| 90 | #define DAC_B_GPIO_Port GPIOA
|
|---|
| 91 | #define I_MINUS_SENSE_Pin GPIO_PIN_6
|
|---|
| 92 | #define I_MINUS_SENSE_GPIO_Port GPIOA
|
|---|
| 93 | #define AB_SENSE_1_Pin GPIO_PIN_7
|
|---|
| 94 | #define AB_SENSE_1_GPIO_Port GPIOA
|
|---|
| 95 | #define LED_FUNCTION_Pin GPIO_PIN_0
|
|---|
| 96 | #define LED_FUNCTION_GPIO_Port GPIOB
|
|---|
| 97 | #define LED_ERROR_Pin GPIO_PIN_1
|
|---|
| 98 | #define LED_ERROR_GPIO_Port GPIOB
|
|---|
| 99 | #define LED_STATE_Pin GPIO_PIN_2
|
|---|
| 100 | #define LED_STATE_GPIO_Port GPIOB
|
|---|
| 101 | #define DIP2_Pin GPIO_PIN_10
|
|---|
| 102 | #define DIP2_GPIO_Port GPIOB
|
|---|
| 103 | #define DIP3_Pin GPIO_PIN_11
|
|---|
| 104 | #define DIP3_GPIO_Port GPIOB
|
|---|
| 105 | #define DIP4_Pin GPIO_PIN_12
|
|---|
| 106 | #define DIP4_GPIO_Port GPIOB
|
|---|
| 107 | #define DIP5_Pin GPIO_PIN_13
|
|---|
| 108 | #define DIP5_GPIO_Port GPIOB
|
|---|
| 109 | #define DIP6_Pin GPIO_PIN_14
|
|---|
| 110 | #define DIP6_GPIO_Port GPIOB
|
|---|
| 111 | #define DIP7_Pin GPIO_PIN_15
|
|---|
| 112 | #define DIP7_GPIO_Port GPIOB
|
|---|
| 113 | #define OUT_CS_Pin GPIO_PIN_8
|
|---|
| 114 | #define OUT_CS_GPIO_Port GPIOA
|
|---|
| 115 | #define RS485_D_Pin GPIO_PIN_9
|
|---|
| 116 | #define RS485_D_GPIO_Port GPIOA
|
|---|
| 117 | #define OVP_IN_Pin GPIO_PIN_6
|
|---|
| 118 | #define OVP_IN_GPIO_Port GPIOC
|
|---|
| 119 | #define LVP_IN_Pin GPIO_PIN_7
|
|---|
| 120 | #define LVP_IN_GPIO_Port GPIOC
|
|---|
| 121 | #define RS485_R_Pin GPIO_PIN_10
|
|---|
| 122 | #define RS485_R_GPIO_Port GPIOA
|
|---|
| 123 | #define R2_Pin GPIO_PIN_11
|
|---|
| 124 | #define R2_GPIO_Port GPIOA
|
|---|
| 125 | #define RS485_DE_Pin GPIO_PIN_12
|
|---|
| 126 | #define RS485_DE_GPIO_Port GPIOA
|
|---|
| 127 | #define BTN1_Pin GPIO_PIN_15
|
|---|
| 128 | #define BTN1_GPIO_Port GPIOA
|
|---|
| [2] | 129 | #define OUT_CTRL_Pin GPIO_PIN_0
|
|---|
| [1] | 130 | #define OUT_CTRL_GPIO_Port GPIOD
|
|---|
| 131 | #define SW_OFF_Pin GPIO_PIN_2
|
|---|
| 132 | #define SW_OFF_GPIO_Port GPIOD
|
|---|
| 133 | #define SW_ON_Pin GPIO_PIN_3
|
|---|
| 134 | #define SW_ON_GPIO_Port GPIOD
|
|---|
| 135 | #define LED_SW_ERROR_Pin GPIO_PIN_3
|
|---|
| 136 | #define LED_SW_ERROR_GPIO_Port GPIOB
|
|---|
| 137 | #define LED_SW_STATE_Pin GPIO_PIN_4
|
|---|
| 138 | #define LED_SW_STATE_GPIO_Port GPIOB
|
|---|
| 139 | #define DIP0_Pin GPIO_PIN_8
|
|---|
| 140 | #define DIP0_GPIO_Port GPIOB
|
|---|
| 141 | #define DIP1_Pin GPIO_PIN_9
|
|---|
| 142 | #define DIP1_GPIO_Port GPIOB
|
|---|
| 143 | /* USER CODE BEGIN Private defines */
|
|---|
| 144 |
|
|---|
| 145 | #ifdef DEBUG
|
|---|
| 146 | #define DEVICE_TYPE_ID 201
|
|---|
| 147 | #else
|
|---|
| 148 | #ifdef VARIANT_24V
|
|---|
| 149 | #define DEVICE_TYPE_ID 202
|
|---|
| [7] | 150 | #define INVERTER_CAP_PRECHARGE
|
|---|
| [1] | 151 | #else
|
|---|
| 152 | #define DEVICE_TYPE_ID 201
|
|---|
| 153 | #endif
|
|---|
| 154 | #endif
|
|---|
| 155 |
|
|---|
| 156 | #define FW_VERSION_MAJOR 1
|
|---|
| 157 | #define FW_VERSION_MINOR 0
|
|---|
| 158 | #define FW_VERSION_REVISION 0
|
|---|
| 159 | #ifdef VARIANT_24V
|
|---|
| 160 | #define DEVICE_SN 0xEC565524 // ECSGSS24 = ECS Green Smart Switch, 24V version (Must be substituted with real serial number)
|
|---|
| 161 | #else
|
|---|
| 162 | #define DEVICE_SN 0xEC565512 // ECSGSS12 = ECS Green Smart Switch, 12V version (Must be substituted with real serial number)
|
|---|
| 163 | #endif
|
|---|
| 164 |
|
|---|
| 165 | #define MB_BAUDRATE_DEFAULT 19200 // bit pro sekunde
|
|---|
| 166 | #define MB_PARITY_MODE_DEFAULT 'e' // EVEN - GERADE
|
|---|
| 167 | #define MB_STOPBITS_DEFAULT 1
|
|---|
| 168 | #define MB_SLAVE_ADRESS_DEFAULT 1
|
|---|
| 169 |
|
|---|
| 170 | #define ADC_CHANNELS 6
|
|---|
| 171 | #define TEMP_CHANNEL 0
|
|---|
| 172 | #define U_BAT_CHANNEL 1
|
|---|
| 173 | #define I_PLUS_CHANNEL 2
|
|---|
| 174 | #define U_SW_CHANNEL 3
|
|---|
| 175 | #define MOSFETS_VDROP_CHANNEL 4
|
|---|
| 176 | #define I_MINUS_CHANNEL 5
|
|---|
| 177 |
|
|---|
| 178 | #define ADC_RESOLUTION 12 // 12 bits
|
|---|
| 179 | #define ADC_MAX_VALUE 0xFFF // 4095
|
|---|
| 180 | #define ADC_VREF 3000 // mV
|
|---|
| 181 |
|
|---|
| 182 | //#define INA240_MAX_DIFF_2_MEASURE 75 // mV
|
|---|
| 183 |
|
|---|
| 184 | #ifdef VARIANT_24V
|
|---|
| 185 | #define CONTROL_CURRENT_A 380 // [A] long-term current limit of the device.
|
|---|
| [7] | 186 | #define SHORTCUT_CURRENT_mV 1100 // [mV] Some big value to pass test sequence
|
|---|
| 187 | #define INRUSH_CURRENT_mV 550 // [mV] Some big value to pass test sequence
|
|---|
| 188 | #define COPPER_V_DROP_AT_CONTROL_CURRENT_mV 200 // [mV] - must be measured on the board
|
|---|
| [1] | 189 | #else
|
|---|
| 190 | #define CONTROL_CURRENT_A 500 // [A] long-term current limit of the device.
|
|---|
| 191 | #define SHORTCUT_CURRENT_mV 1500 // [mV] Some big value to pass test sequence
|
|---|
| 192 | #define INRUSH_CURRENT_mV 616 // [mV] Some big value to pass test sequence
|
|---|
| 193 | #define COPPER_V_DROP_AT_CONTROL_CURRENT_mV 150 // [mV] - must be measured on the board
|
|---|
| 194 | #endif
|
|---|
| 195 | //#define COPPER_V_DROP_AT_INRUSH_CURRENT ((INRUSH_CURRENT_A * COPPER_V_DROP_AT_CONTROL_CURRENT_A)/CONTROL_CURRENT_A) // ~391mV
|
|---|
| 196 | //#define COPPER_V_DROP_AT_SHORTCUT_CURRENT ((SHORTCUT_CURRENT_A * COPPER_V_DROP_AT_CONTROL_CURRENT_A)/CONTROL_CURRENT_A) // ~1176mV
|
|---|
| 197 | //#if COPPER_V_DROP_AT_INRUSH_CURRENT > 3000 || COPPER_V_DROP_AT_SHORTCUT_CURRENT > 3000 || COPPER_V_DROP_AT_CONTROL_CURRENT_A > 3000
|
|---|
| 198 | //#error Voltage drop cannot be greater than 1.5V. See INA281B2 datasheet.
|
|---|
| 199 | //#endif
|
|---|
| 200 | #define ADC_VALUE_AT_INRUSH_CURRENT ((ADC_MAX_VALUE * INRUSH_CURRENT_mV)/ADC_VREF)
|
|---|
| 201 | //#define ADC_VALUE_DELTA_AT_SHORTCUT_CURRENT ((ADC_MAX_VALUE * COPPER_V_DROP_AT_SHORTCUT_CURRENT)/ADC_VREF) // 1605
|
|---|
| 202 | #define ADC_VALUE_AT_CONTROL_CURRENT ((ADC_MAX_VALUE * COPPER_V_DROP_AT_CONTROL_CURRENT_mV)/ADC_VREF) // 140
|
|---|
| 203 | #define CURRENT_INTEGRAL_FREQ 320000U // (7.5cycles + 12.5cycles)*1channels + (3.5cycles + 12.5cycles)*5channels = 20 + 80 = 100cycles @ 32MHz = 320 kHz
|
|---|
| 204 | #ifdef VARIANT_24V
|
|---|
| [7] | 205 | #define CURRENT_INTEGRATION_PERIOD 1500 // µs
|
|---|
| [1] | 206 | #else
|
|---|
| 207 | #define CURRENT_INTEGRATION_PERIOD 1700 // µs
|
|---|
| 208 | #endif
|
|---|
| 209 | #if CURRENT_INTEGRATION_PERIOD < 31
|
|---|
| 210 | #error CURRENT_INTEGRATION_PERIOD cannot be less then 31 µs!
|
|---|
| 211 | #endif
|
|---|
| 212 | #define CURRENT_INTEGRATION_STEPS ((CURRENT_INTEGRAL_FREQ * CURRENT_INTEGRATION_PERIOD) / (1000*1000)) // 640
|
|---|
| 213 | //#define COPPER_TEMP_COEFFICIENT 0.00393f
|
|---|
| 214 |
|
|---|
| 215 | #define DIP_IS_OFF GPIO_PIN_SET
|
|---|
| 216 | #define DIP_IS_ON GPIO_PIN_RESET
|
|---|
| 217 |
|
|---|
| 218 | #define OVP_PRESENT GPIO_PIN_SET
|
|---|
| 219 | #define OVP_NOT_PRESENT GPIO_PIN_RESET
|
|---|
| 220 |
|
|---|
| 221 | #define LVP_PRESENT GPIO_PIN_SET
|
|---|
| 222 | #define LVP_NOT_PRESENT GPIO_PIN_RESET
|
|---|
| 223 |
|
|---|
| 224 | #define OUT_CTRL_ACTIVATE GPIO_PIN_SET
|
|---|
| 225 | #define OUT_CTRL_DEACTIVATE GPIO_PIN_RESET
|
|---|
| 226 |
|
|---|
| 227 | #ifdef VARIANT_24V
|
|---|
| 228 | #define R19 30000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 229 | #define R20 30000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 230 | #define R27 30000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 231 | #define R23 30000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 232 | #define R24 30000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 233 | #define R25 30000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 234 | #define R26 10000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 235 | #define R33 10000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 236 | #define R35 1000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 237 | #define R37 100000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 238 | #define R43 100000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 239 | #define R42 1000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 240 | #if (R23 + R24 + R25 + R33 != R43) || R43 != R37 || R33 != R26 || (R19 + R20 + R27 + R26 != R43) || R35 != R42
|
|---|
| 241 | #error Registers values are not correct!
|
|---|
| 242 | #endif
|
|---|
| 243 | #define MAX_POSSIBLE_DIFF_TO_MEASURE ((ADC_VREF * R35 /* ((R23 + R24 + R25) + R33)*/)/(2 /* R43 */* R33)) // 150mV
|
|---|
| 244 | #else
|
|---|
| 245 | #define R31 10000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 246 | #define R37 10000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 247 | #define R23 47000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 248 | #define R25 47000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 249 | #define R22 10000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 250 | #define R24 10000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 251 | #define R33 470000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 252 | #define R38 470000 // Ohm. See schematic page 6. Revision 62
|
|---|
| 253 | #if R31 != R37 || R23 != R25 || R22 != R24 || R33 != R38 || R31 != R22
|
|---|
| 254 | #error Values of these two registers must be the same!
|
|---|
| 255 | #endif
|
|---|
| 256 | #define MAX_POSSIBLE_DIFF_TO_MEASURE ((ADC_VREF * /*R31*/ (R23 + R22))/(2 * R38 /*R22*/)) // 181mV
|
|---|
| 257 | #endif
|
|---|
| 258 | #define MAX_ALLOWED_MOSFETS_V_DROP 30 // mV
|
|---|
| 259 | #define MAX_ALLOWED_MOSFETS_V_DROP_DELTA 30 // mV
|
|---|
| 260 | #define MAX_ALLOWED_MOSFETS_V_DROP_ADC ((MAX_ALLOWED_MOSFETS_V_DROP * (ADC_MAX_VALUE/2)) / MAX_POSSIBLE_DIFF_TO_MEASURE) // 409
|
|---|
| 261 | #define POS_ALLOWED_MOSFETS_V_DROP_ADC (MAX_ALLOWED_MOSFETS_V_DROP_ADC + (ADC_MAX_VALUE/2)) // 2456
|
|---|
| 262 | #define NEG_ALLOWED_MOSFETS_V_DROP_ADC ((ADC_MAX_VALUE/2) - MAX_ALLOWED_MOSFETS_V_DROP_ADC) // 1638
|
|---|
| 263 |
|
|---|
| 264 | #define MOSFET_CHANNEL_A DAC_CHANNEL_1 //TIM_CHANNEL_1
|
|---|
| 265 | #define MOSFET_CHANNEL_B DAC_CHANNEL_2 //TIM_CHANNEL_2
|
|---|
| 266 | #define DAC_3V 0xFFF
|
|---|
| 267 | #define DAC_0V 0x00
|
|---|
| 268 | #define DAC_STEP 15
|
|---|
| 269 | #if DAC_3V % DAC_STEP
|
|---|
| 270 | #error DAC_STEP cannot be that value!
|
|---|
| 271 | #endif
|
|---|
| 272 |
|
|---|
| 273 | // MODBUS commands
|
|---|
| 274 | #define COMMAND_SAVE_CONFIG 1
|
|---|
| 275 | #define COMMAND_RESTART_MODBUS 2
|
|---|
| 276 | #define COMMAND_RESTORE_DEFAULTS 3
|
|---|
| 277 | #define COMMAND_SAVE_LOCK_KEY 5
|
|---|
| 278 | #define COMMAND_ON_SWITCH 10
|
|---|
| 279 | #define COMMAND_OFF_SWITCH 20
|
|---|
| 280 | #define COMMAND_AUTO_SWITCH 30
|
|---|
| 281 | #define COMMAND_RESTART 500
|
|---|
| 282 | #define COMMAND_SAVE_CONFIG_WITH_SN 50403
|
|---|
| 283 | #define COMMAND_OFFSET_CALIBRATION 40302
|
|---|
| 284 | #define COMMAND_CURRENT_CALIBRATION 30201
|
|---|
| 285 | #define COMMAND_CURRENT_OFFSET_CALIBRATION 60504
|
|---|
| 286 | #define COMMAND_TURN_OVERLOAD_DETECTION_OFF 20304
|
|---|
| 287 | #define COMMAND_TURN_OVERLOAD_DETECTION_ON 30405
|
|---|
| 288 |
|
|---|
| [7] | 289 | //#define U_BAT_CALC_PERIOD 5 // ms
|
|---|
| [1] | 290 | #ifdef VARIANT_24V
|
|---|
| 291 | #define U_BAT_CRITICAL_VOLTAGE 20000 // mV (If voltage on battery is lower than 10V, then there is a probability that MOSFETs will not open/close properly)
|
|---|
| 292 | #define U_BAT_RECOVERY_VOLTAGE 24000 // mV (If voltage on battery is higher than 12V, then it is fully recovered from possible previous discharge)
|
|---|
| 293 | #else
|
|---|
| [7] | 294 | #define U_BAT_CRITICAL_VOLTAGE_mV 10000 // mV (If voltage on battery is lower than 10V, then there is a probability that MOSFETs will not open/close properly)
|
|---|
| 295 | #define U_BAT_RECOVERY_VOLTAGE_mV 12000 // mV (If voltage on battery is higher than 12V, then it is fully recovered from possible previous discharge)
|
|---|
| 296 | #define ADC_BAT_CRITICAL_VOLTAGE ((((U_BAT_CRITICAL_VOLTAGE_mV / 1000) * R22) * (ADC_MAX_VALUE + 1)) / ((R23 + R22) * (ADC_VREF / 1000)))
|
|---|
| [1] | 297 | #endif
|
|---|
| 298 |
|
|---|
| 299 | #define BAT_CHARGE_SIGN_V 2 // mV If voltage on side A greater than voltage on side B by this value, then charging is going on
|
|---|
| 300 |
|
|---|
| 301 | //#define VOLTAGE_RATIO 20 // When we have ±20mV on INA240A1, the input voltage is ±1mV
|
|---|
| 302 |
|
|---|
| 303 | #define TEMP_SENSOR_mV_AT_MINUS30 300 // in mV (See LM61 datasheet)
|
|---|
| 304 | #define TEMP_SENSOR_mV_AT_PLUS100 1600 // in mV (See LM61 datasheet)
|
|---|
| 305 | #define TEMP_SENSOR_ADC_AT_MINUS30 ((TEMP_SENSOR_mV_AT_MINUS30 * ADC_MAX_VALUE) / ADC_VREF)
|
|---|
| 306 | #define TEMP_SENSOR_ADC_AT_PLUS100 ((TEMP_SENSOR_mV_AT_PLUS100 * ADC_MAX_VALUE) / ADC_VREF)
|
|---|
| 307 | #define TEMP_SENSOR_0_OFFSET 600 // in mV
|
|---|
| 308 | #define MIN_TEMP (-300) // Celsium degrees (See LM61 datasheet)
|
|---|
| 309 | #define MAX_TEMP (1000) // Celsium degrees (See LM61 datasheet)
|
|---|
| 310 | #define TEMP_RECOVER_PERCENT 25 // When temperature drops to (critical - 25%) then we remove overtemperature flag
|
|---|
| 311 |
|
|---|
| 312 | #define BTN_IS_PRESSED GPIO_PIN_RESET
|
|---|
| 313 |
|
|---|
| 314 | #define LVP_OVP_EVENT_NUM 4
|
|---|
| 315 |
|
|---|
| 316 | #define SWCLK_Port GPIOA
|
|---|
| 317 | #define SWCLK_Pin GPIO_PIN_14
|
|---|
| 318 | #define SWDIO_Port GPIOA
|
|---|
| 319 | #define SWDIO_Pin GPIO_PIN_13
|
|---|
| 320 |
|
|---|
| 321 | #define OVERTEMP_ERROR 0
|
|---|
| 322 | #define OVERCURRENT_ERROR 1
|
|---|
| 323 | #define OVERLOAD_ERROR 2
|
|---|
| 324 | #define LOWBAT_ERROR 3
|
|---|
| 325 | #define HEATER_IS_ON 4
|
|---|
| 326 | #define ABBA_VOLTAGE_ERROR 5
|
|---|
| 327 | //#define OFFSET_CALLIB_ERROR 4
|
|---|
| 328 | //#define OFFSET_CALLIB_IS_ON 5
|
|---|
| 329 | //#define OFFSET_CALLIB_SEQ_ERROR 6
|
|---|
| 330 | //#define EEPROM_SAVE_ERROR 7
|
|---|
| 331 | //#define CURRENT_SENSOR_CALLIB_IS_ON 8
|
|---|
| 332 | //#define CURRENT_SENSOR_CALLIB_TEMP_ERROR 9
|
|---|
| 333 | //#define CURRENT_SENSOR_CALLIB_ERROR 10
|
|---|
| 334 | //#define CURRENT_SENSOR_CALLIB_SEQ_ERROR 11
|
|---|
| 335 | //#define CURRENT_SENSOR_OFFSET_CALLIB_IS_ON 14
|
|---|
| 336 | //#define CURRENT_SENSOR_OFFSET_CALLIB_ERROR 15
|
|---|
| 337 |
|
|---|
| 338 | #define VBOOST_OFF_TIMER htim14
|
|---|
| 339 | #define VBOOST_ON_TIMER htim7
|
|---|
| 340 | #define VBOOST_ENABLE GPIO_PIN_SET
|
|---|
| 341 | #define VBOOST_DISABLE GPIO_PIN_RESET
|
|---|
| 342 |
|
|---|
| 343 | #define ON_MODE_AUTO_OFF_TIMER htim16
|
|---|
| 344 |
|
|---|
| 345 | #define I_RMS_SAMPLES_COUNT 4096
|
|---|
| 346 | #define I_RMS_SAMPLES_SUM_COUNT 32
|
|---|
| 347 |
|
|---|
| 348 | #define FC_WRITE_SINGLE_REGISTER 0x06
|
|---|
| 349 | #define FC_WRITE_MULTIPLE_REGISTER 0x10
|
|---|
| 350 |
|
|---|
| 351 | #define HOUR_TIME_INTERVALL (2UL * 60000UL) // 2 min for DEBUG
|
|---|
| 352 |
|
|---|
| 353 | #define DAC_HANDLE hdac1
|
|---|
| 354 | #define DAC_CH_A DOR1
|
|---|
| 355 | #define DAC_CH_B DOR2
|
|---|
| 356 | #define DAC_CH_A_ALIGNMENT DAC_DHR12R1_ALIGNMENT
|
|---|
| 357 | #define DAC_CH_B_ALIGNMENT DAC_DHR12R2_ALIGNMENT
|
|---|
| 358 |
|
|---|
| 359 | /* USER CODE END Private defines */
|
|---|
| 360 |
|
|---|
| 361 | #ifdef __cplusplus
|
|---|
| 362 | }
|
|---|
| 363 | #endif
|
|---|
| 364 |
|
|---|
| 365 | #endif /* __MAIN_H */
|
|---|