foxBMS  1.3.0
The foxBMS Battery Management System API Documentation
contactor.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, 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 contactor.h
44  * @author foxBMS Team
45  * @date 2020-02-11 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup DRIVERS
49  * @prefix CONT
50  *
51  * @brief Headers for the driver for the contactors.
52  *
53  */
54 
55 #ifndef FOXBMS__CONTACTOR_H_
56 #define FOXBMS__CONTACTOR_H_
57 
58 /*========== Includes =======================================================*/
59 #include "contactor_cfg.h"
60 
61 /*========== Macros and Definitions =========================================*/
62 
63 /*========== Extern Constant and Variable Declarations ======================*/
64 
65 /*========== Extern Function Prototypes =====================================*/
66 
67 /**
68  * @brief Gets the latest value the contactors were set to.
69  * @param[in] name name of the contactor
70  * @return returns CONT_SWITCH_OFF or CONT_SWITCH_ON
71  */
73 
74 /**
75  * @brief Reads the feedback pin of every contactor and returns its current
76  * value (#CONT_SWITCH_OFF/#CONT_SWITCH_ON).
77  * @details If the contactor has a feedback pin the measured feedback is
78  * returned. If the contactor has no feedback pin, it is assumed that
79  * after a certain time the contactor has reached the requested state.
80  */
81 void CONT_GetContactorFeedback(void);
82 
83 /**
84  * @brief Sets the contactor state to its requested state, if the contactor
85  * is at that time not in the requested state.
86  * @details If the new state was already requested, but not reached (meaning
87  * the measured feedback does not return the requested state), there
88  * are two states: it can be still ok (#STD_OK), because the contactor
89  * has some time left to get physically in the requested state (passed
90  * time since the request is lower than the limit) or it can be not ok
91  * (#STD_NOT_OK), because there is timing violation, i.e. the
92  * contactor has surpassed the maximum time for getting in the
93  * requested state. It returns #STD_OK if the requested state was
94  * successfully set or if the contactor was at the requested state
95  * before.
96  * @param name
97  * @param requestedContactorState
98  * @return retVal (type: STD_RETURN_TYPE_e)
99  */
101  const CONT_NAMES_e name,
102  CONT_ELECTRICAL_STATE_TYPE_e requestedContactorState);
103 
104 /** @brief Substates of the CONT state machine */
105 typedef enum {
112 
113 /**
114  * @brief Gets the current state.
115  * @details This function is used in the functioning of the CONT state machine.
116  * @param contactorNumber contactor to be addressed
117  * @return current state, taken from #CONT_ELECTRICAL_STATE_TYPE_e
118  */
119 extern CONT_ELECTRICAL_STATE_TYPE_e CONT_GetState(uint8_t contactorNumber);
120 
121 /**
122  * @brief Closes the contactor of a string.
123  * @details This function makes a close state request to the contactor of a
124  * specific string.
125  * @param stringNumber String addressed
126  */
127 extern STD_RETURN_TYPE_e CONT_CloseString(uint8_t stringNumber);
128 
129 /**
130  * @brief Opens the contactor of a string.
131  * @details This function makes an open state request to the contactor of a
132  * specific string.
133  * @param stringNumber String addressed
134  */
135 extern STD_RETURN_TYPE_e CONT_OpenString(uint8_t stringNumber);
136 
137 /**
138  * @brief Closes precharge.
139  * @details This function makes a close state request to the precharge
140  * contactor.
141  * @param stringNumber String addressed
142  */
143 extern STD_RETURN_TYPE_e CONT_ClosePrecharge(uint8_t stringNumber);
144 
145 /**
146  * @brief Opens precharge.
147  * @details This function makes an open state request to the precharge
148  * contactor.
149  * @param stringNumber String addressed
150  */
151 extern STD_RETURN_TYPE_e CONT_OpenPrecharge(uint8_t stringNumber);
152 
153 /**
154  * @brief checks the feedback of the contactors
155  * @details makes a DIAG entry for each contactor when the feedback does not
156  * match the set value
157  */
158 extern void CONT_CheckFeedback(void);
159 
160 /**
161  * @brief initializes the contactor module
162  */
163 extern void CONT_Initialize(void);
164 
165 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
166 #ifdef UNITY_UNIT_TEST
167 extern void TEST_CONT_InitializationCheckOfContactorRegistry(void);
168 extern CONT_CONTACTOR_INDEX TEST_CONT_ResolveContactorName(const CONT_NAMES_e name);
169 #endif /* UNITY_UNIT_TEST */
170 
171 #endif /* FOXBMS__CONTACTOR_H_ */
CONT_ELECTRICAL_STATE_TYPE_e CONT_GetState(uint8_t contactorNumber)
Gets the current state.
Definition: contactor.c:297
void CONT_CheckFeedback(void)
checks the feedback of the contactors
Definition: contactor.c:222
STD_RETURN_TYPE_e CONT_OpenPrecharge(uint8_t stringNumber)
Opens precharge.
Definition: contactor.c:271
CONT_ELECTRICAL_STATE_TYPE_e CONT_GetContactorSetValue(const CONT_NAMES_e name)
Gets the latest value the contactors were set to.
Definition: contactor.c:167
STD_RETURN_TYPE_e CONT_SetContactorState(const CONT_NAMES_e name, CONT_ELECTRICAL_STATE_TYPE_e requestedContactorState)
Sets the contactor state to its requested state, if the contactor is at that time not in the requeste...
Definition: contactor.c:193
STD_RETURN_TYPE_e CONT_CloseString(uint8_t stringNumber)
Closes the contactor of a string.
Definition: contactor.c:227
void CONT_GetContactorFeedback(void)
Reads the feedback pin of every contactor and returns its current value (CONT_SWITCH_OFF/CONT_SWITCH_...
Definition: contactor.c:173
STD_RETURN_TYPE_e CONT_ClosePrecharge(uint8_t stringNumber)
Closes precharge.
Definition: contactor.c:244
void CONT_Initialize(void)
initializes the contactor module
Definition: contactor.c:302
CONT_STATEMACH_SUB_e
Substates of the CONT state machine.
Definition: contactor.h:105
@ CONT_ENTRY
Definition: contactor.h:106
@ CONT_SET_EDGE_LOW_INIT
Definition: contactor.h:107
@ CONT_SET_EDGE_HIGH
Definition: contactor.h:108
@ CONT_CHECK_REQUESTS
Definition: contactor.h:110
@ CONT_SET_EDGE_LOW
Definition: contactor.h:109
STD_RETURN_TYPE_e CONT_OpenString(uint8_t stringNumber)
Opens the contactor of a string.
Definition: contactor.c:235
Header for the configuration for the driver for the contactors.
uint8_t CONT_CONTACTOR_INDEX
CONT_ELECTRICAL_STATE_TYPE_e
Definition: contactor_cfg.h:71
CONT_NAMES_e
Definition: contactor_cfg.h:78
STD_RETURN_TYPE_e
Definition: fstd_types.h:81