foxBMS  1.1.2
The foxBMS Battery Management System API Documentation
sps.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, 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 sps.h
44  * @author foxBMS Team
45  * @date 2020-10-14 (date of creation)
46  * @updated 2020-10-14 (date of last update)
47  * @ingroup DRIVERS
48  * @prefix SPS
49  *
50  * @brief Headers for the driver for the smart power switches.
51  *
52  */
53 
54 #ifndef FOXBMS__SPS_H_
55 #define FOXBMS__SPS_H_
56 
57 /*========== Includes =======================================================*/
58 #include "contactor_cfg.h"
59 #include "sps_cfg.h"
60 
61 #include "sps_types.h"
62 
63 /*========== Macros and Definitions =========================================*/
64 
65 /*========== Extern Constant and Variable Declarations ======================*/
66 
67 /*========== Extern Function Prototypes =====================================*/
68 
69 /**
70  * @brief Initialize IOs for the SPS driver.
71  * @details This function sets the necessary register (e.g., configure pins as
72  * input or output).
73  */
74 extern void SPS_Initialize(void);
75 
76 /**
77  * @brief Control function for the CONT driver state machine.
78  * @details This function contains the sequence of events in the SPS state
79  * machine. It must be called time-triggered, every 10ms. It exits
80  * without effect, if the function call is a reentrance.
81  */
82 extern void SPS_Ctrl(void);
83 
84 /**
85  * @brief Request state of a contactor
86  * @details This function checks if the requested channel is affiliated to contactors and
87  * then passes the arguments on to #SPS_RequestChannelState().
88  * @param[in] channelIndex number of the channel that should be accessed; This has to be
89  * a SPS channel and it has to be affiliated with #SPS_AFF_CONTACTOR
90  * @param[in] channelFunction requested functional state of the channel
91  */
92 extern void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction);
93 
94 /**
95  * @brief Request state of a general IO
96  * @details This function checks if the requested channel is affiliated to general IO and
97  * then passes the arguments on to #SPS_RequestChannelState().
98  * @param[in] channelIndex number of the channel that should be accessed; This has to be
99  * a SPS channel and it has to be affiliated with #SPS_AFF_GENERAL_IO
100  * @param[in] channelFunction requested functional state of the channel
101  */
102 extern void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction);
103 
104 /**
105  * @brief Get feedback value
106  * @details This function compares the measured current in the contactor
107  * channel with a fixed threshold and assumes the contactor feedback
108  * to be closed when this threshold is passed on the channel.
109  * @param[in] channelIndex index of the channel (contactor) that should be accessed
110  * @returns state of the channel's feedback
111  */
113 
114 /**
115  * @brief Returns the channel affiliation
116  * @param[in] channelIndex index of the channel in question
117  * @returns affiliation of the channel
118  */
120 
121 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
122 #ifdef UNITY_UNIT_TEST
123 extern void TEST_SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction);
124 extern SPS_STATE_e TEST_SPS_GetSpsState(void);
125 extern void TEST_SPS_SetSpsState(const SPS_STATE_e newState);
126 extern uint8_t TEST_SPS_GetSpsTimer(void);
127 extern void TEST_SPS_SetSpsTimer(const uint8_t newTimer);
128 #endif /* UNITY_UNIT_TEST */
129 
130 #endif /* FOXBMS__SPS_H_ */
Header for the configuration for the driver for the contactors.
enum CONT_ELECTRICAL_STATE_TYPE CONT_ELECTRICAL_STATE_TYPE_e
SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex)
Returns the channel affiliation.
Definition: sps.c:613
void SPS_Initialize(void)
Initialize IOs for the SPS driver.
Definition: sps.c:583
void SPS_Ctrl(void)
Control function for the CONT driver state machine.
Definition: sps.c:466
void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
Definition: sps.c:592
void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a contactor.
Definition: sps.c:587
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelFeedback(SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
Definition: sps.c:597
Header for the configuration for the driver for the smart power switches.
enum SPS_STATE SPS_STATE_e
enum SPS_CHANNEL_FUNCTION SPS_CHANNEL_FUNCTION_e
Types for the SPS driver.
uint8_t SPS_CHANNEL_INDEX
Definition: sps_types.h:63
enum SPS_CHANNEL_AFFILIATION SPS_CHANNEL_AFFILIATION_e
affiliation type of a sps channel