123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 |
- /* 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>© Copyright (c) 2019 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 "stm32f4xx_hal.h"
- /* Private includes ----------------------------------------------------------*/
- /* USER CODE BEGIN Includes */
- #include "stdio.h"
- #include "string.h"
- #include "iwdg.h"
- /* USER CODE END Includes */
- /* Exported types ------------------------------------------------------------*/
- /* USER CODE BEGIN ET */
- #define DEBUG_INFO(format, args...) printf("[%s:%d][Info] "format, __FUNCTION__, __LINE__, ##args)
- #define DEBUG_WARN(format, args...) printf("[%s:%d][Warn] "format, __FUNCTION__, __LINE__, ##args)
- #define DEBUG_ERROR(format, args...) printf("[%s:%d][Error] "format, __FUNCTION__, __LINE__, ##args)
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
- #define MEMORY_LENGTH_CONFIG 0x1000
- #define MEM_REAL_LENGTH 27 //27 two word = 52 word
- #define bool char
- //#define DEBUG
- enum
- {
- Fan1 = 0,
- Fan2,
- Fan3,
- Fan4,
- Fan5,
- Fan6,
- Fan7,
- Fan8
- };
- enum
- {
- AC_L1_GAIN = 0,
- AC_L2_GAIN,
- AC_L3_GAIN,
- DC_SMR1_GAIN,
- DC_SMR2_GAIN
- };
- enum
- {
- MainRelay = 0x10,
- GunRelay = 0x12,
- MainBridge1 = 0x13,
- MainBridge2 = 0x14,
- MainBridge3 = 0x15,
- };
- enum
- {
- Input_L1_AC_voltage = 0x01,
- Input_L2_AC_voltage,
- Input_L3_AC_voltage,
-
- Output_L1_AC_current = 0x11,
- Output_L2_AC_current,
- Output_L3_AC_current,
-
- Leak_current = 0x21,
- GMI_voltage = 0x31,
-
- GFD_Resister_Left = 0x46,
- GFD_Resister_Right = 0x47,
-
- Battery1_input_voltage = 0x51,
- Battery2_input_voltage,
- SMR1_output_voltage = 0x61,
- SMR2_output_voltage,
- SMR3_output_voltage,
- SMR4_output_voltage,
- SMR5_output_voltage,
- SMR6_output_voltage,
- };
- enum
- {
- Parallel_relay_n = 0,
- Parallel_relay_p,
- SMR1_relay_n,
- SMR1_relay_p,
- SMR2_relay_n,
- SMR2_relay_p,
-
- LED1,
- Chdemo_Delay,
- Reserved,
- };
- typedef union
- {
- uint64_t All;
- uint8_t Status[8];
- struct __attribute__ ((packed))
- {
- uint8_t AC_Contactor :1;
- uint8_t Precharge1 :1;
- uint8_t Precharge2 :1;
- uint8_t Reserved_0 :5;
-
- uint8_t SMR1_relay_n :1;
- uint8_t SMR1_relay_p :1;
- uint8_t Reserved_1 :6;
- uint8_t SMR2_relay_n :1;
- uint8_t SMR2_relay_p :1;
- uint8_t Reserved_2 :6;
- uint8_t SMR3_relay_n :1;
- uint8_t SMR3_relay_p :1;
- uint8_t Reserved_3 :6;
- uint8_t SMR4_relay_n :1;
- uint8_t SMR4_relay_p :1;
- uint8_t Reserved_4 :6;
- uint8_t SMR5_relay_n :1;
- uint8_t SMR5_relay_p :1;
- uint8_t Reserved_5 :6;
- uint8_t SMR6_relay_n :1;
- uint8_t SMR6_relay_p :1;
- uint8_t Reserved_6 :6;
- uint8_t Reserved_7 :8;
- } flags;
- } RLY_STATUS;
- typedef struct
- {
- uint8_t AC_Contactor :1;
- uint8_t Precharge1 :1;
- uint8_t Precharge2 :1;
- uint8_t Reserved_0 :5;
-
- uint8_t SMR1_relay_n :1;
- uint8_t SMR1_relay_p :1;
- uint8_t Reserved_1 :6;
- uint8_t SMR2_relay_n :1;
- uint8_t SMR2_relay_p :1;
- uint8_t Reserved_2 :6;
- uint8_t SMR3_relay_n :1;
- uint8_t SMR3_relay_p :1;
- uint8_t Reserved_3 :6;
- uint8_t SMR4_relay_n :1;
- uint8_t SMR4_relay_p :1;
- uint8_t Reserved_4 :6;
- uint8_t SMR5_relay_n :1;
- uint8_t SMR5_relay_p :1;
- uint8_t Reserved_5 :6;
- uint8_t SMR6_relay_n :1;
- uint8_t SMR6_relay_p :1;
- uint8_t Reserved_6 :6;
- } RLY_ST;
- typedef union
- {
- uint64_t All;
- struct __attribute__ ((packed))
- {
- uint8_t AC_Contactor :1;
- uint8_t Precharge1 :1;
- uint8_t Precharge2 :1;
- uint8_t Reserved_0 :5;
-
- uint8_t SMR1_relay_n :1;
- uint8_t SMR1_relay_p :1;
- uint8_t Reserved_1 :6;
- uint8_t SMR2_relay_n :1;
- uint8_t SMR2_relay_p :1;
- uint8_t Reserved_2 :6;
- uint8_t SMR3_relay_n :1;
- uint8_t SMR3_relay_p :1;
- uint8_t Reserved_3 :6;
- uint8_t SMR4_relay_n :1;
- uint8_t SMR4_relay_p :1;
- uint8_t Reserved_4 :6;
- uint8_t SMR5_relay_n :1;
- uint8_t SMR5_relay_p :1;
- uint8_t Reserved_5 :6;
- uint8_t SMR6_relay_n :1;
- uint8_t SMR6_relay_p :1;
- uint8_t Reserved_6 :6;
- uint8_t Reserved_7 :8;
- } flags;
- } RLY_GPIO;
- typedef union
- {
- uint16_t All;
- struct __attribute__ ((packed))
- {
- uint8_t Relay1_Fail :1;
- uint8_t Relay2_Fail :1;
- uint8_t Relay3_Fail :1;
- uint8_t Relay4_Fail :1;
- uint8_t Relay5_Fail :1;
- uint8_t Relay6_Fail :1;
- uint8_t Relay7_Fail :1;
- uint8_t Relay8_Fail :1;
-
- uint8_t Gfd_Alarm_0 :1;
- uint8_t Gfd_Alarm_1 :1;
- uint8_t Reserved_1 :6;
- } flags;
- } ALARM;
- typedef union
- {
- uint8_t All;
- struct __attribute__ ((packed))
- {
- // LSB to begin
- uint8_t Fan_Enable:1;
- uint8_t Drv_Up:1;
- uint8_t Drv_Down:1;
- uint8_t Reversed:5;
- // MSB to End
- } flags;
- } _GPIO_;
- typedef union
- {
- uint8_t Mode;
- struct __attribute__ ((packed))
- {
- // LSB to begin
- uint8_t SW0:1;
- uint8_t SW1:1;
- uint8_t SW2:1;
- uint8_t Reversed:5;
- // MSB to End
- } flags;
- } _DIP_SW_;
- typedef struct COEFFICIENT
- {
- float gain_volt;
- float offset_volt;
- } Coefficient;
- typedef struct SF_TEST
- {
- struct
- {
- uint8_t SF_test_status;
- uint8_t SF_Act;
- uint8_t SF_State;
- union
- {
- uint64_t value;
- struct
- {
- uint8_t test_item1 :1;
- uint8_t test_item2 :1;
- uint8_t test_item3 :1;
- uint8_t test_item4 :1;
- uint8_t test_item5 :1;
- uint8_t test_item6 :1;
- uint8_t test_item7 :1;
- uint8_t test_item8 :1;
- uint8_t test_item9 :1;
- uint8_t test_item10 :1;
- uint8_t test_item11 :1;
- uint8_t test_item12 :1;
- uint8_t test_item13 :1;
- uint8_t test_item14 :1;
- uint8_t test_item15 :1;
- uint8_t test_item16 :1;
- uint8_t test_item17 :1;
- uint8_t test_item18 :1;
- uint8_t test_item19 :1;
- uint8_t test_item20 :1;
- uint8_t test_item21 :1;
- uint8_t test_item22 :1;
- uint8_t test_item23 :1;
- uint8_t test_item24 :1;
- uint8_t test_item25 :1;
- uint8_t test_item26 :1;
- uint8_t test_item27 :1;
- uint8_t test_item28 :1;
- uint8_t test_item29 :1;
- uint8_t test_item30 :1;
- uint8_t test_item31 :1;
- uint8_t test_item32 :1;
- uint8_t test_item33 :1;
- uint8_t test_item34 :1;
- } items;
- } data;
- } SF_Config;
- } SF_test;
- // V18 memory structure.
- typedef struct MEM
- {
- struct
- {
- union
- {
- // 0x1000 = 10240 byte , uint32_t = 4byte , array size = 10240/4 = 1000
- uint32_t value[MEMORY_LENGTH_CONFIG];
-
- struct
- {
- // 16 Byte -> Voltage correction point data(adc & meter) [point][adc & meter], unit: 0.1V
- uint16_t Correction_Volt[9][2]; // [L1-point1~L3-point3][ADC,Set Value]
- uint16_t DC_Correction_Volt[12][2]; // [SMR1 point1~SMR6 point2][ADC,Set Value]
- uint16_t GFD_Correction_Resistor[4][2]; // [L-GFD point1~R-GFD point2][ADC,Set Value]
- uint16_t DCIn_Correction_Volt[2][2]; // [DC In 2 point][ADC,Set Value]
-
- } item;
- } data;
-
- struct
- {
- uint8_t update:1; // Update ram content to external flash request
- uint8_t clear:1; // Clear ram & external flash content request
- uint8_t read:1; // Read external flash content to ram request
- uint8_t reserved:5;
- } op_bits;
-
- } Module_Config;
- }Mem;
- struct Detet_Fan_IO
- {
- uint32_t Difference;
- uint32_t Frequency;
- uint32_t ubFan_RPM;
- uint8_t Rpm_Idx;
- uint16_t Second;
- uint8_t Fan_Fail;
- };
- struct Gun_Gfd_Check
- {
- uint8_t Rfd_State;
- uint8_t Csu_State;
- uint8_t Gfd_Running_Count;
- uint8_t Gfd_Warning_Count;
- uint8_t bResult_Gfd;
- uint32_t R_GFD;
- uint32_t R_GFD_v;
- uint32_t R_GFD_Fail;
- uint8_t Rfd_State_Fail;
- uint32_t SMR_Voltage_Fail;
- uint8_t bFirstGfd;
- };
- extern const uint16_t nRPM_Tbl[11][2];
- extern uint16_t serial_n;
- extern SF_test sf_t;
- extern float Avg_offset_v;
- extern uint16_t Freq_CLC_Grid_v;
- extern uint8_t bGfd_Correct[2];
- extern uint32_t nGfd_Temp[2][17];
- extern uint32_t R_GFD_Total[2];
- extern uint8_t nGfd_Idx[2];
- extern uint16_t pwmVal;
- extern uint8_t dir;
- extern uint8_t bRelayFeedback;
- extern uint8_t nBoard_Addr;
- extern float c_vadc[2];
- extern uint8_t nGun;
- extern bool GainCaliFlag;
- #define vsense1 24.42 // for ADC1 (330 / 4095 / 0.0033) = 24.42
- #define vsense2 0.002919
- //#define vsense3 4.118 // for current (330 / 4095 / 0.01957 ) = 4.118
- #define vsense3 24448.7 // 5000 / (5.1*4.01) * 100 = 24448.7 (5000:CT �I��v 5.1:�q���q�� 20.5K/5.11K=4.01 OP���v)
- #define v_div_1K 0.8059 // 3300 / 4095
- #define v_div 0.0008059 // 3.3 / 4095
- #define FAN_RPM_DEF 6200
- #define FAN_PWM_PERIOD 4200
- #define FAN_TOLERANCE 50 // 50 Percent
- #define PWM_Limit 9980
- #define OFF 0
- #define ON 1
- #define FAIL 0
- #define PASS 1
- #define NO 0
- #define YES 1
- #define true 1
- #define false 0
- #define SMR1_Relay_Shift_V 0 // 27
- #define SMR1_Fuse_Shift_V 0
- #define SMR2_Relay_Shift_V 0 // 14
- #define SMR2_Fuse_Shift_V 0
- #define LINE_VOLTAGE_POINT 100
- #define LINE_VOLTAGE_TOLERANCE 200
- #define V165_OFFSET 7
- //<<<<<<< HEAD
- #define DC_LOW_GAIN 1
- #define DC_HIGH_GAIN 1 // 1.0035
- //=======
- //#define DC_LOW_GAIN 1.0314
- //#define DC_HIGH_GAIN 1.02 // 1.0035
- //>>>>>>> be39927da1874c206c78d2be3fcbaa101e72d2ea
- #define GFD_UNKNOW 0
- #define GFD_PASS 1
- #define GFD_FAIL 2
- #define GFD_WARNING 3
- //<<<<<<< HEAD
- #define GFD_TEST_TIMES 15
- #define GFD_SLEF_TEST_RESISTOR_TOLERANCE 45000 // 30K -> 45K ohm
- //#define GFD_SELF_TEST_RESISTOR 55000
- #define GFD_SELF_TEST_RESISTOR (50000 + GFD_SLEF_TEST_RESISTOR_TOLERANCE) // 95K ohm
- #define GFD_FILTER_LIMIT 16
- //=======
- //#define GFD_OPT_COUP_RESISTER 35000
- //#define GFD_TEST_TIMES 15
- //>>>>>>> be39927da1874c206c78d2be3fcbaa101e72d2ea
- #define ISOLATION_TEST_VOLTAGE 5000
- #define WAIT_FOR_RESISTER_CALC 30 // mini_second
- #define WAIT_FOR_RESISTER_CALC_LONG 50
- #define WAIT_FOR_RESISTER_CALC_FAST 30
- #define MCU_DATA 0
- #define METER_DATA 1
- #define PREVENT_REPEAT_OFF 1
- #define RELAY_ALL_ON 0
- #define FEEDBACK_PIN 1
- #define DEBUG_PRINTF 1
- #define GFD_SELF_TEST 1
- #define GFD_DEFAULT_V4 1
- #define READ_IO_NO_DELAY 1
- #define AC_INPUT_1ST_POINT 2800 // OVP +10
- #define AC_INPUT_2ND_POINT 2200 // UVP -10
- #define AC_INPUT_3RD_POINT 1600 // UVP -10
- #define DC_OUTPUT_1ST_POINT 9500
- #define DC_OUTPUT_2ND_POINT 1500
- #define GFD_RESISTOR_WARNING 100
- #define GFD_RESISTOR_PRE_WARNING 500
- #define EVSE_MAX_OUTPUT_VOLTAGE 950
- #define GFD_EXTRA_FAIL_RESISTOR 5000
- #define GFD_RESISTOR_COEFFICIENT 73.8 // 73.8 , 51.3
- #define GFD_SENSE_VOLTAGE_UP_LIMIT 1.75 // 1.75
- #define GFD_SENSE_VOLTAGE_DOWN_LIMIT 1.55 // 1.55
- #define GFD_SENSE_CENTER_VOLTAGE 1.65
- #define GFD_WORKING_VOLTAGE 2000 // 200v, for Safety Test : 1400
- //#define AC_CORRECT_GAIN_MAX_NUM 6
- #define DC_CORRECT_GAIN_MAX_NUM 6
- #define GFD_CORRECT_GAIN_MAX_NUM 2
- //#define DC_CORR_2ND_SHIFT 7
- //#define DEFAULT_COFF_3 1.00768
- //#define DEFAULT_OFFST_3 -15.556
- //#define DEFAULT_COFF_4 1.00553
- //#define DEFAULT_OFFST_4 -2.262
- //
- //#define DEFAULT_COFF_5 1.086
- //#define DEFAULT_OFFST_5 -358.322
- //#define DEFAULT_COFF_6 1.241
- //#define DEFAULT_OFFST_6 -481.362
- /* 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 */
- #define PWM_CH_FAN_START 0
- //void user_pwm_setvalue(uint8_t ch, uint16_t value);
- /* USER CODE END EFP */
- /* Private defines -----------------------------------------------------------*/
- #define CP0_EXTI_Pin GPIO_PIN_0
- #define CP0_EXTI_GPIO_Port GPIOF
- #define CP0_EXTI_EXTI_IRQn EXTI0_IRQn
- #define CP1_EXTI_Pin GPIO_PIN_1
- #define CP1_EXTI_GPIO_Port GPIOF
- #define CP1_EXTI_EXTI_IRQn EXTI1_IRQn
- #define CP2_EXTI_Pin GPIO_PIN_2
- #define CP2_EXTI_GPIO_Port GPIOF
- #define CP2_EXTI_EXTI_IRQn EXTI2_IRQn
- #define CP3_EXTI_Pin GPIO_PIN_3
- #define CP3_EXTI_GPIO_Port GPIOF
- #define CP3_EXTI_EXTI_IRQn EXTI3_IRQn
- #define CP4_EXTI_Pin GPIO_PIN_4
- #define CP4_EXTI_GPIO_Port GPIOF
- #define CP4_EXTI_EXTI_IRQn EXTI4_IRQn
- #define CP5_EXTI_Pin GPIO_PIN_5
- #define CP5_EXTI_GPIO_Port GPIOF
- #define CP5_EXTI_EXTI_IRQn EXTI9_5_IRQn
- #define SMR1_Gfd_Sense_Pin GPIO_PIN_6
- #define SMR1_Gfd_Sense_GPIO_Port GPIOF
- #define SMR2_Gfd_Sense_Pin GPIO_PIN_7
- #define SMR2_Gfd_Sense_GPIO_Port GPIOF
- #define DC_In_Pin GPIO_PIN_10
- #define DC_In_GPIO_Port GPIOF
- #define SMR3_Relay_Voltage_Pin GPIO_PIN_1
- #define SMR3_Relay_Voltage_GPIO_Port GPIOC
- #define SMR4_Relay_Voltage_Pin GPIO_PIN_2
- #define SMR4_Relay_Voltage_GPIO_Port GPIOC
- #define SMR5_Relay_Voltage_Pin GPIO_PIN_3
- #define SMR5_Relay_Voltage_GPIO_Port GPIOC
- #define SMR6_Relay_Voltage_Pin GPIO_PIN_0
- #define SMR6_Relay_Voltage_GPIO_Port GPIOA
- #define CSRHB_VER_Pin GPIO_PIN_3
- #define CSRHB_VER_GPIO_Port GPIOA
- #define SMR1_Relay_Voltage_Pin GPIO_PIN_4
- #define SMR1_Relay_Voltage_GPIO_Port GPIOA
- #define SMR1_Current_Pin GPIO_PIN_5
- #define SMR1_Current_GPIO_Port GPIOA
- #define SMR2_Relay_Voltage_Pin GPIO_PIN_6
- #define SMR2_Relay_Voltage_GPIO_Port GPIOA
- #define SMR2_Current_Pin GPIO_PIN_7
- #define SMR2_Current_GPIO_Port GPIOA
- #define AC_Input_L1_Pin GPIO_PIN_4
- #define AC_Input_L1_GPIO_Port GPIOC
- #define AC_Input_L2_Pin GPIO_PIN_5
- #define AC_Input_L2_GPIO_Port GPIOC
- #define AC_Input_L3_Pin GPIO_PIN_0
- #define AC_Input_L3_GPIO_Port GPIOB
- #define Vref_165_Pin GPIO_PIN_1
- #define Vref_165_GPIO_Port GPIOB
- #define Contactor_Enable_Pin GPIO_PIN_13
- #define Contactor_Enable_GPIO_Port GPIOF
- #define PSU_Enable1_Pin GPIO_PIN_14
- #define PSU_Enable1_GPIO_Port GPIOF
- #define PSU_Enable2_Pin GPIO_PIN_15
- #define PSU_Enable2_GPIO_Port GPIOF
- #define SW1_Pin GPIO_PIN_1
- #define SW1_GPIO_Port GPIOG
- #define SW0_Pin GPIO_PIN_7
- #define SW0_GPIO_Port GPIOE
- #define SW2_Pin GPIO_PIN_8
- #define SW2_GPIO_Port GPIOE
- #define SMR5_Relay_p_Ret_Pin GPIO_PIN_13
- #define SMR5_Relay_p_Ret_GPIO_Port GPIOB
- #define SMR5_Relay_n_Ret_Pin GPIO_PIN_14
- #define SMR5_Relay_n_Ret_GPIO_Port GPIOB
- #define SMR6_Relay_p_Ret_Pin GPIO_PIN_8
- #define SMR6_Relay_p_Ret_GPIO_Port GPIOD
- #define SMR6_Relay_n_Ret_Pin GPIO_PIN_9
- #define SMR6_Relay_n_Ret_GPIO_Port GPIOD
- #define Sys2_Self_Test_DC_n_Pin GPIO_PIN_10
- #define Sys2_Self_Test_DC_n_GPIO_Port GPIOD
- #define Sys2_Self_Test_DC_p_Pin GPIO_PIN_11
- #define Sys2_Self_Test_DC_p_GPIO_Port GPIOD
- #define Drv_Down_2_Pin GPIO_PIN_12
- #define Drv_Down_2_GPIO_Port GPIOD
- #define Drv_Up_2_Pin GPIO_PIN_13
- #define Drv_Up_2_GPIO_Port GPIOD
- #define SMR4_Relay_p_Ret_Pin GPIO_PIN_14
- #define SMR4_Relay_p_Ret_GPIO_Port GPIOD
- #define SMR4_Relay_n_Ret_Pin GPIO_PIN_15
- #define SMR4_Relay_n_Ret_GPIO_Port GPIOD
- #define AC_Contactor_Ret_Pin GPIO_PIN_2
- #define AC_Contactor_Ret_GPIO_Port GPIOG
- #define SMR1_Relay_p_Ret_Pin GPIO_PIN_3
- #define SMR1_Relay_p_Ret_GPIO_Port GPIOG
- #define SMR1_Relay_n_Ret_Pin GPIO_PIN_4
- #define SMR1_Relay_n_Ret_GPIO_Port GPIOG
- #define SMR2_Relay_p_Ret_Pin GPIO_PIN_5
- #define SMR2_Relay_p_Ret_GPIO_Port GPIOG
- #define SMR2_Relay_n_Ret_Pin GPIO_PIN_6
- #define SMR2_Relay_n_Ret_GPIO_Port GPIOG
- #define SMR3_Relay_p_Ret_Pin GPIO_PIN_7
- #define SMR3_Relay_p_Ret_GPIO_Port GPIOG
- #define SMR3_Relay_n_Ret_Pin GPIO_PIN_8
- #define SMR3_Relay_n_Ret_GPIO_Port GPIOG
- #define Precharge1_Ret_Pin GPIO_PIN_6
- #define Precharge1_Ret_GPIO_Port GPIOC
- #define DBG_RX_Pin GPIO_PIN_7
- #define DBG_RX_GPIO_Port GPIOC
- #define Precharge2_Ret_Pin GPIO_PIN_8
- #define Precharge2_Ret_GPIO_Port GPIOC
- #define RS485_DE_Pin GPIO_PIN_9
- #define RS485_DE_GPIO_Port GPIOC
- #define RS485_RE_Pin GPIO_PIN_8
- #define RS485_RE_GPIO_Port GPIOA
- #define Sys1_Self_Test_DC_p_Pin GPIO_PIN_12
- #define Sys1_Self_Test_DC_p_GPIO_Port GPIOA
- #define SMR1_RLY_p_Enable_Pin GPIO_PIN_15
- #define SMR1_RLY_p_Enable_GPIO_Port GPIOA
- #define SMR1_RLY_n_Enable_Pin GPIO_PIN_10
- #define SMR1_RLY_n_Enable_GPIO_Port GPIOC
- #define SMR3_RLY_p_Enable_Pin GPIO_PIN_11
- #define SMR3_RLY_p_Enable_GPIO_Port GPIOC
- #define SMR2_RLY_p_Enable_Pin GPIO_PIN_12
- #define SMR2_RLY_p_Enable_GPIO_Port GPIOC
- #define SMR2_RLY_n_Enable_Pin GPIO_PIN_0
- #define SMR2_RLY_n_Enable_GPIO_Port GPIOD
- #define Precharge1_Enable_Pin GPIO_PIN_1
- #define Precharge1_Enable_GPIO_Port GPIOD
- #define Drv_Up_Pin GPIO_PIN_2
- #define Drv_Up_GPIO_Port GPIOD
- #define Drv_Down_Pin GPIO_PIN_3
- #define Drv_Down_GPIO_Port GPIOD
- #define SMR3_RLY_n_Enable_Pin GPIO_PIN_4
- #define SMR3_RLY_n_Enable_GPIO_Port GPIOD
- #define Precharge2_Enable_Pin GPIO_PIN_5
- #define Precharge2_Enable_GPIO_Port GPIOD
- #define SMR4_RLY_p_Enable_Pin GPIO_PIN_6
- #define SMR4_RLY_p_Enable_GPIO_Port GPIOD
- #define SMR4_RLY_n_Enable_Pin GPIO_PIN_7
- #define SMR4_RLY_n_Enable_GPIO_Port GPIOD
- #define SMR5_RLY_p_Enable_Pin GPIO_PIN_10
- #define SMR5_RLY_p_Enable_GPIO_Port GPIOG
- #define SMR5_RLY_n_Enable_Pin GPIO_PIN_11
- #define SMR5_RLY_n_Enable_GPIO_Port GPIOG
- #define SMR6_RLY_p_Enable_Pin GPIO_PIN_12
- #define SMR6_RLY_p_Enable_GPIO_Port GPIOG
- #define SMR6_RLY_n_Enable_Pin GPIO_PIN_13
- #define SMR6_RLY_n_Enable_GPIO_Port GPIOG
- #define DBG_TX_Pin GPIO_PIN_14
- #define DBG_TX_GPIO_Port GPIOG
- #define Sys1_Self_Test_DC_n_Pin GPIO_PIN_5
- #define Sys1_Self_Test_DC_n_GPIO_Port GPIOB
- #define LED1_Pin GPIO_PIN_7
- #define LED1_GPIO_Port GPIOB
- #define LED2_Pin GPIO_PIN_0
- #define LED2_GPIO_Port GPIOE
- #define LED3_Pin GPIO_PIN_1
- #define LED3_GPIO_Port GPIOE
- /* USER CODE BEGIN Private defines */
- extern struct MODULE_INFO
- {
- // Board info
- uint8_t Soft_Ver_Ptr[16];
- uint8_t Hard_Ver_Ptr[16];
- uint8_t SN[20];
-
- // Dip_Switch Status
- _DIP_SW_ Dip_status;
-
- // Relay DC voltage info
- uint32_t SMR1_Relay_V;
- uint32_t SMR1_Relay_C;
- uint32_t SMR2_Relay_V;
- uint32_t SMR2_Relay_C;
- uint32_t SMR3_Relay_V;
- uint32_t SMR4_Relay_V;
- uint32_t SMR5_Relay_V;
- uint32_t SMR6_Relay_V;
- uint32_t Verf_165_V;
- uint32_t BAT_Voltage;
- // Ground sense info
- float Vref_165;
- float SMR_Gfd_Sense[2];
- float SMR_Gfd_Diff[2];
- uint32_t R_GFD;
- struct Gun_Gfd_Check gfd_chk[2];
-
- // GPIO info
- RLY_STATUS Relay_Status;
- RLY_GPIO Relay_IO;
- _GPIO_ Gpio_status;
- struct Detet_Fan_IO fan[1];
-
- // Memory info
- Mem memory;
-
- // Coefficient info
- Coefficient ACVcoeff[3]; // 0~2:AC,3~8:DC SMR1~SMR6,9~10:GRD
- Coefficient DCVcoeff[6];
- Coefficient GFDcoeff[2];
- Coefficient DCINcoeff;
- // Alarm info
- ALARM Alarm_CSU;
- }Module_Info;
- extern RLY_ST RelayStatus;
- extern struct COUNTER
- {
- uint8_t nAC_Drop;
- uint8_t nInterLock;
- uint8_t nRelay_Timeout[8];
-
- }Counter;
- extern struct OP_FLAG
- {
- uint8_t bRelay_Config_Change:1;
- uint8_t bInterLock:1;
-
- }OpFlag;
- extern struct EXT_inupt
- {
- bool Exti_SMR1_Flag:1;
- bool Exti_SMR2_Flag:1;
- bool Exti_SMR3_Flag:1;
- bool Exti_SMR4_Flag:1;
- bool Exti_SMR5_Flag:1;
- bool Exti_SMR6_Flag:1;
- bool reserve :2;
-
- }Exti;
- extern uint8_t EXTI_SMR1_Count;
- extern uint8_t EXTI_SMR2_Count;
- extern uint8_t EXTI_SMR3_Count;
- extern uint8_t EXTI_SMR4_Count;
- extern uint8_t EXTI_SMR5_Count;
- extern uint8_t EXTI_SMR6_Count;
- extern uint8_t EXTI_Test_Count;
- extern uint8_t EXTI_TestFlag1;
- extern uint8_t EXTI_TestFlag2;
- extern uint8_t EXTI_TestFlag3;
- extern uint8_t EXTI_TestFlag4;
- extern uint8_t EXTI_TestFlag5;
- extern uint8_t EXTI_TestFlag6;
- extern CAN_TxHeaderTypeDef TxHeader;
- extern CAN_RxHeaderTypeDef RxHeader;
- extern uint8_t TxData[8];
- extern uint8_t RxData[8];
- extern uint32_t TxMailbox;
- extern uint32_t canError;
- extern uint8_t temp1,temp2,temp3,temp4;
- extern float temp5,temp6,temp7,temp8;
- /* USER CODE END Private defines */
- #ifdef __cplusplus
- }
- #endif
- #endif /* __MAIN_H */
|