foxBMS  1.0.0
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
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
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_ */
SPS_RequestContactorState
void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a contactor.
Definition: sps.c:588
SPS_CHANNEL_FUNCTION_e
enum SPS_CHANNEL_FUNCTION SPS_CHANNEL_FUNCTION_e
sps_types.h
Types for the SPS driver.
SPS_CHANNEL_INDEX
uint8_t SPS_CHANNEL_INDEX
Definition: sps_types.h:63
SPS_Initialize
void SPS_Initialize(void)
Initialize IOs for the SPS driver.
Definition: sps.c:584
SPS_RequestGeneralIOState
void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction)
Request state of a general IO.
Definition: sps.c:593
SPS_Ctrl
void SPS_Ctrl(void)
Control function for the CONT driver state machine.
Definition: sps.c:467
SPS_CHANNEL_AFFILIATION_e
enum SPS_CHANNEL_AFFILIATION SPS_CHANNEL_AFFILIATION_e
affiliation type of a sps channel
SPS_GetChannelAffiliation
SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex)
Returns the channel affiliation.
Definition: sps.c:614
SPS_GetChannelFeedback
CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelFeedback(SPS_CHANNEL_INDEX channelIndex)
Get feedback value.
Definition: sps.c:598
CONT_ELECTRICAL_STATE_TYPE_e
enum CONT_ELECTRICAL_STATE_TYPE CONT_ELECTRICAL_STATE_TYPE_e
sps_cfg.h
Header for the configuration for the driver for the smart power switches.
SPS_STATE_e
enum SPS_STATE SPS_STATE_e
contactor_cfg.h
Header for the configuration for the driver for the contactors.