foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
sbc_fs8x.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 - 2018, NXP Semiconductors, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 /** @file sbc_fs8x.h
32  * @brief FS8x driver interface.
33  *
34  * @author nxf44615
35  * @version 1.1
36  * @date 9-Oct-2018
37  * @copyright Copyright (c) 2016 - 2018, NXP Semiconductors, Inc.
38  *
39  * @updated 2020-03-18 (date of last update)
40  * Adapted driver to pass interface configuration as parameter into the
41  * functions to enable the usage of multiple ICs in the system.
42  */
43 
44 #ifndef SBC_FS8X_H_
45 #define SBC_FS8X_H_
46 
47 /*******************************************************************************
48  * Includes
49  ******************************************************************************/
50 
51 #include <stdbool.h>
52 #include "sbc_fs8x_map.h"
53 #include "sbc_fs8x_common.h"
54 
55 /*******************************************************************************
56  * Definitions
57  ******************************************************************************/
58 /** @brief Watchdog seed default value. */
59 #define FS8x_WD_SEED_DEFAULT 0x5AB2U
60 
61 /** @addtogroup EnumsDefs
62  * @{ */
63 /** @brief Voltage outputs. Can be used with function @ref FS8x_SetRegulatorState(). */
64 typedef enum
65 {
66  fs8xBuck1 = 4, /**< BUCK1 */
67  fs8xBuck2 = 3, /**< BUCK2 */
68  fs8xBuck3 = 2, /**< BUCK3 */
69  fs8xLdo1 = 1, /**< LDO1 */
70  fs8xLdo2 = 0, /**< LDO2 */
71  fs8xVBoost = 5, /**< VBOOST */
72  fs8xVPre = 6 /**< VPRE */
74 
75 /** AMUX channel selection. Can be used with function @ref FS8x_SwitchAMUXchannel(). */
76 typedef enum
77 {
80  fs8xAmuxTempSensor = FS8X_M_AMUX_TEMPERATURE_SENSOR, /**< Temperature sensor */
102 /** @} */
103 
104 /*******************************************************************************
105  * Global Variables
106  ******************************************************************************/
107 
108 /*******************************************************************************
109  * API
110  ******************************************************************************/
111 /** @defgroup API Driver API
112  * @{ */
113 /** @brief Changes seed of LFSR used for watchdog.
114  *
115  * The watchdog seed can be changed just during the INIT_FS phase (for challenger WD)
116  * or during the OPEN watchdog window (for simple WD). Timing is up to the application!
117  * @param [in,out] spiInterface SPI communication interface config
118  * @param [in] drvData Driver run-time data.
119  * @param [in] wdSeed Watchdog LFSR seed.
120  * @return @ref fs8x_status_t "Status return code." */
121 fs8x_status_t FS8x_WD_ChangeSeed(SPI_INTERFACE_CONFIG_s* spiInterface, fs8x_drv_data_t* drvData, uint16_t wdSeed);
122 
123 /** @brief Performs the watchdog refresh.
124  * @param [in,out] spiInterface SPI communication interface config
125  * @param [in] drvData Driver run-time data.
126  * @return @ref fs8x_status_t "Status return code." */
128 
129 /** @brief FS0B release routine.
130  *
131  * This function also checks all preconditions before
132  * it sends the register write command (LBIST_OK = ABIST1_OK = ABIST2_OK = 1,
133  * Fault Error Counter = 0). If any precondition is not met, the function returns
134  * @ref fs8xStatusError.
135  * @param [in,out] spiInterface SPI communication interface config
136  * @param [in] drvData Driver run-time data.
137  * @return @ref fs8x_status_t "Status return code." */
139 
140 /** @brief Switches a desired channel to the AMUX pin.
141  * @param [in,out] spiInterface SPI communication interface config
142  * @param [in] drvData Driver run-time data.
143  * @param [in] channelSelection Selected channel to be delivered to AMUX pin.
144  * @return @ref fs8x_status_t "Status return code." */
146  fs8x_amux_selection_t channelSelection);
147 
148 /** @brief Sets state (enable/disable) of the selected voltage regulator.
149  * @param [in,out] spiInterface SPI communication interface config
150  * @param [in] drvData Driver run-time data.
151  * @param [in] vreg Voltage regulator enum (LDO1-2, BUCK1-3, BOOST, VPRE).
152  * @param [in] enable State (enable = true / disable = false).
153  * @return @ref fs8x_status_t "Status return code." */
155  fs8x_reg_output_t vreg, bool enable);
156 
157 /** @brief Reads actual Fault Error Counter value.
158  * @param [in,out] spiInterface SPI communication interface config
159  * @param [in] drvData Driver run-time data.
160  * @param [out] faultErrorCounterValue Fault Error counter value storage.
161  * @return @ref fs8x_status_t "Status return code." */
163  uint8_t* faultErrorCounterValue);
164 /** @} */
165 #endif /* SBC_FS8X_H_ */
fs8x_status_t FS8x_GetFaultErrorCounterValue(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData, uint8_t *faultErrorCounterValue)
Reads actual Fault Error Counter value.
Definition: sbc_fs8x.c:270
fs8x_status_t FS8x_WD_Refresh(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData)
Performs the watchdog refresh.
Definition: sbc_fs8x.c:160
fs8x_status_t FS8x_WD_ChangeSeed(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData, uint16_t wdSeed)
Changes seed of LFSR used for watchdog.
Definition: sbc_fs8x.c:137
fs8x_status_t FS8x_FS0B_Release(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData)
FS0B release routine.
Definition: sbc_fs8x.c:184
fs8x_status_t FS8x_SetRegulatorState(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData, fs8x_reg_output_t vreg, bool enable)
Sets state (enable/disable) of the selected voltage regulator.
Definition: sbc_fs8x.c:253
fs8x_status_t FS8x_SwitchAMUXchannel(SPI_INTERFACE_CONFIG_s *spiInterface, fs8x_drv_data_t *drvData, fs8x_amux_selection_t channelSelection)
Switches a desired channel to the AMUX pin.
Definition: sbc_fs8x.c:235
fs8x_status_t
Status return codes.
fs8x_reg_output_t
Voltage outputs. Can be used with function FS8x_SetRegulatorState().
Definition: sbc_fs8x.h:65
fs8x_amux_selection_t
Definition: sbc_fs8x.h:77
@ fs8xVBoost
Definition: sbc_fs8x.h:71
@ fs8xBuck3
Definition: sbc_fs8x.h:68
@ fs8xVPre
Definition: sbc_fs8x.h:72
@ fs8xBuck1
Definition: sbc_fs8x.h:66
@ fs8xLdo2
Definition: sbc_fs8x.h:70
@ fs8xBuck2
Definition: sbc_fs8x.h:67
@ fs8xLdo1
Definition: sbc_fs8x.h:69
@ fs8xAmuxVboostVoltDiv2_5
Definition: sbc_fs8x.h:87
@ fs8xAmuxWake2VoltDiv14
Definition: sbc_fs8x.h:100
@ fs8xAmuxVdigFs
Definition: sbc_fs8x.h:96
@ fs8xAmuxVldo2VoltDiv2_5
Definition: sbc_fs8x.h:89
@ fs8xAmuxVbuck1Volt
Definition: sbc_fs8x.h:83
@ fs8xAmuxPsync
Definition: sbc_fs8x.h:97
@ fs8xAmuxVbosVoltDiv2_5
Definition: sbc_fs8x.h:90
@ fs8xAmuxWake1VoltDiv7_5
Definition: sbc_fs8x.h:92
@ fs8xAmuxVpreVoltDiv2_5
Definition: sbc_fs8x.h:86
@ fs8xAmuxVbuck3VoltDiv2_5
Definition: sbc_fs8x.h:85
@ fs8xAmuxVbuck2Volt
Definition: sbc_fs8x.h:84
@ fs8xAmuxVldo1VoltDiv2_5
Definition: sbc_fs8x.h:88
@ fs8xAmuxVsup1VoltDiv14
Definition: sbc_fs8x.h:98
@ fs8xAmuxBandgapMain
Definition: sbc_fs8x.h:81
@ fs8xAmuxVdig
Definition: sbc_fs8x.h:95
@ fs8xAmuxWake2VoltDiv7_5
Definition: sbc_fs8x.h:93
@ fs8xAmuxVsup1VoltDiv7_5
Definition: sbc_fs8x.h:91
@ fs8xAmuxBandgapFailSafe
Definition: sbc_fs8x.h:82
@ fs8xAmuxVana
Definition: sbc_fs8x.h:94
@ fs8xAmuxWake1VoltDiv14
Definition: sbc_fs8x.h:99
@ fs8xAmuxTempSensor
Definition: sbc_fs8x.h:80
@ fs8xAmuxVddio
Definition: sbc_fs8x.h:79
@ fs8xAmuxGnd
Definition: sbc_fs8x.h:78
Driver common structures, enums, macros and configuration values.
FS8x register map.
#define FS8X_M_AMUX_VBUCK3_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:934
#define FS8X_M_AMUX_VBOOST_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:942
#define FS8X_M_AMUX_VLDO1_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:946
#define FS8X_M_AMUX_VBUCK2_VOLTAGE
Definition: sbc_fs8x_map.h:930
#define FS8X_M_AMUX_VDDIO
Definition: sbc_fs8x_map.h:910
#define FS8X_M_AMUX_TEMPERATURE_SENSOR
Definition: sbc_fs8x_map.h:914
#define FS8X_M_AMUX_PSYNC_VOLTAGE
Definition: sbc_fs8x_map.h:986
#define FS8X_M_AMUX_WAKE2_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:970
#define FS8X_M_AMUX_VDIG
Definition: sbc_fs8x_map.h:978
#define FS8X_M_AMUX_GND
Definition: sbc_fs8x_map.h:906
#define FS8X_M_AMUX_VPRE_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:938
#define FS8X_M_AMUX_VSUP1_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:962
#define FS8X_M_AMUX_VLDO2_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:950
#define FS8X_M_AMUX_VBOS_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:954
#define FS8X_M_AMUX_BAND_GAP_MAIN
Definition: sbc_fs8x_map.h:918
#define FS8X_M_AMUX_VANA
Definition: sbc_fs8x_map.h:974
#define FS8X_M_AMUX_VDIG_FS
Definition: sbc_fs8x_map.h:982
#define FS8X_M_AMUX_VBUCK1_VOLTAGE
Definition: sbc_fs8x_map.h:926
#define FS8X_M_RATIO_RATIO_14
Definition: sbc_fs8x_map.h:995
#define FS8X_M_AMUX_WAKE1_VOLTAGE_DIVIDED
Definition: sbc_fs8x_map.h:966
#define FS8X_M_AMUX_BAND_GAP_FAIL_SAFE
Definition: sbc_fs8x_map.h:922
This data structure is used by the FS8x driver (this is the first parameter of most the FS8x function...