foxBMS - Unit Tests  1.5.1
The foxBMS Unit Tests API Documentation
interlock_cfg.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file interlock_cfg.h
44  * @author foxBMS Team
45  * @date 2020-02-24 (date of creation)
46  * @updated 2023-02-23 (date of last update)
47  * @version v1.5.1
48  * @ingroup DRIVERS_CONFIGURATION
49  * @prefix ILCK
50  *
51  * @brief Header for the configuration for the driver for the interlock
52  *
53  */
54 
55 #ifndef FOXBMS__INTERLOCK_CFG_H_
56 #define FOXBMS__INTERLOCK_CFG_H_
57 
58 /*========== Includes =======================================================*/
59 
60 #include "HL_reg_het.h"
61 
62 #include <stdint.h>
63 
64 /*========== Macros and Definitions =========================================*/
65 
66 /** IO register to which the interlock is connected */
67 #define ILCK_IO_REG_DIR (hetREG1->DIR)
68 /** IO port for interlock related pins */
69 #define ILCK_IO_REG_PORT (hetREG1)
70 
71 /** Enable pin for diagnostic power supply */
72 #define ILCK_INTERLOCK_CONTROL_PIN_IL_HS_ENABLE (30u)
73 
74 /** Defines the pin where interlock feedback pin is connected to the mcu */
75 #define ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE (29u)
76 
77 /* Defines to which ADC input the interlock circuitry is connected to */
78 /** High-side voltage sense signal connected to ADC input 2 (IL_HS_VS) */
79 #define ILCK_ADC_INPUT_HIGH_SIDE_VOLTAGE_SENSE (2u)
80 /** Low-side voltage sense signal connected to ADC input 3 (IL_LS_VS) */
81 #define ILCK_ADC_INPUT_LOW_SIDE_VOLTAGE_SENSE (3u)
82 /** High-side current sense signal connected to ADC input 4 (IL_HS_CS) */
83 #define ILCK_ADC_INPUT_HIGH_SIDE_CURRENT_SENSE (4u)
84 /** Low-side current sense signal connected to ADC input 5 (IL_LS_CS) */
85 #define ILCK_ADC_INPUT_LOW_SIDE_CURRENT_SENSE (5u)
86 
87 /** Factor of resistor divider used for measuring the low- and high-side
88  * interlock voltages. Used resistor values are 5k6 ohm and 3k9 ohm. */
89 #define ILCK_VOLTAGE_DIVIDER_FACTOR ((5.6f + 3.9f) / 3.9f)
90 
91 /**
92  * Conversion factor for interlock current IL_HS_CS
93  * 2k49 ohm is the resistance through which sense current flows
94  * 80 is the (output current / sense current) ratio of high-side power switch
95  * TPS2H000-Q1 data sheet SLVSD72D - DECEMBER 2015 - REVISED DECEMBER 2019 p.8
96  */
97 #define ILCK_FACTOR_IL_HS_CS_1_ohm (80.0f / 2049.0f)
98 
99 /** Linear conversion factor for low-side interlock current measurement
100  * (IL_LS_CS). Measurement performed via 2 ohm shunt with a gain of 20V/V */
101 #define ILCK_FACTOR_IL_LS_CS_1_ohm (0.025f)
102 
103 /**
104  * @brief ILCK statemachine short time definition in #ILCK_Trigger() calls
105  * until next state/substate is processed
106  */
107 #define ILCK_STATEMACH_SHORTTIME (1u)
108 
109 /** Symbolic names for contactors' possible states */
110 typedef enum {
111  ILCK_SWITCH_OFF, /*!< Contactor off --> Contactor is open */
112  ILCK_SWITCH_ON, /*!< Contactor on --> Contactor is closed */
113  ILCK_SWITCH_UNDEF, /*!< Contactor undefined --> Contactor state not known */
115 
116 /*========== Extern Constant and Variable Declarations ======================*/
117 
118 /*========== Extern Function Prototypes =====================================*/
119 
120 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
121 #ifdef UNITY_UNIT_TEST
122 #endif
123 
124 #endif /* FOXBMS__INTERLOCK_CFG_H_ */
ILCK_ELECTRICAL_STATE_TYPE_e
@ ILCK_SWITCH_ON
@ ILCK_SWITCH_UNDEF
@ ILCK_SWITCH_OFF