foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
mxm_1785x.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 mxm_1785x.h
44  * @author foxBMS Team
45  * @date 2019-01-15 (date of creation)
46  * @updated 2020-09-10 (date of last update)
47  * @ingroup DRIVERS
48  * @prefix MXM
49  *
50  * @brief Headers for the driver for the MAX17841B ASCI and MAX1785x monitoring chip
51  *
52  * @details def
53  *
54  */
55 
56 /**
57  * @brief Battery monitoring driver for MAX1785x battery monitoring ICs.
58  *
59  * This module supplies a driver for the Battery Monitoring ICs of the
60  * MAX1785x-family by Maxim Integrated.
61  *
62  * Entry point for the module is the function #MXM_Tick() in mxm_mic.c. It handles
63  * the measurement flow and the coordination of the underlying state-machines.
64  * Below this layer two state-machines are implemented.
65  *
66  * The state-machine in mxm_battery_management.c is executed with the
67  * #MXM_5XStateMachine()-function.
68  * This state-machine exposes commands of the Maxim Battery Management Protocol
69  * to the upper layers. Below, it translates these commands into state-changes
70  * for the underlying state-machine.
71  * This state-machine is implemented in mxm_17841b.c and executed with
72  * #MXM_41BStateMachine(). It handles the register- and buffer-transactions
73  * required for the MAX17841B communication interface (Maxim calls
74  * this chip ASCI).
75  *
76  */
77 
78 #ifndef FOXBMS__MXM_1785X_H_
79 #define FOXBMS__MXM_1785X_H_
80 
81 /*========== Includes =======================================================*/
82 #include "database_cfg.h"
83 #include "mxm_cfg.h"
84 
85 #include "mxm_17841b.h"
86 #include "mxm_1785x_tools.h"
87 #include "mxm_basic_defines.h"
88 #include "mxm_battery_management.h"
89 #include "mxm_crc8.h"
90 
91 /*========== Macros and Definitions =========================================*/
92 
93 /*========== Extern Constant and Variable Declarations ======================*/
94 
95 /*========== Extern Function Prototypes =====================================*/
96 /**
97  * @brief Main state-machine implementation
98  * @details This state-machine handles the main state of the driver.
99  * It runs the self-check, initializes communication and then
100  * transitions into the operation state in which it
101  * executes the state-machine described in
102  * #MXM_StateMachineOperation().
103  * @param[in,out] pInstance used as both input and output (stores
104  * state-information, requests and intermediate
105  * values)
106  */
107 extern void MXM_StateMachine(MXM_MONITORING_INSTANCE_s *pInstance);
108 
109 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
110 #ifdef UNITY_UNIT_TEST
114 extern void TEST_MXM_HandleStateWriteall(
115  MXM_MONITORING_INSTANCE_s *pInstance,
117 extern bool TEST_MXM_HandleStateReadall(
118  MXM_MONITORING_INSTANCE_s *pInstance,
119  MXM_REG_NAME_e registerName,
122  uint8_t *volt_rx_buffer,
123  uint16_t volt_rx_buffer_len,
124  MXM_DATA_STORAGE_s *datastorage,
125  MXM_CONVERSION_TYPE_e conversionType);
126 extern void TEST_MXM_ProcessOpenWire(MXM_MONITORING_INSTANCE_s *pInstance, DATA_BLOCK_OPEN_WIRE_s *pDataOpenWire);
127 #endif
128 
129 #endif /* FOXBMS__MXM_1785X_H_ */
TEST_MXM_ParseVoltageReadallTest
STD_RETURN_TYPE_e TEST_MXM_ParseVoltageReadallTest(MXM_MONITORING_INSTANCE_s *pInstance)
Definition: mxm_1785x.c:1920
MXM_StateMachine
void MXM_StateMachine(MXM_MONITORING_INSTANCE_s *pInstance)
Battery monitoring driver for MAX1785x battery monitoring ICs.
Definition: mxm_1785x.c:1824
MXM_DATA_STORAGE
Definition: mxm_basic_defines.h:146
DATA_BLOCK_OPENWIRE
Definition: database_cfg.h:296
MXM_MONINTORING_STATE_e
enum MXM_MONITORING_STATE MXM_MONINTORING_STATE_e
MXM_CONVERSION_TYPE_e
enum MXM_CONVERSION_TYPE MXM_CONVERSION_TYPE_e
TEST_MXM_MonGetVoltages
MXM_MONINTORING_STATE_e TEST_MXM_MonGetVoltages(MXM_MONITORING_INSTANCE_s *pInstance, MXM_REG_NAME_e regAddress)
Definition: mxm_1785x.c:1926
MXM_MONITORING_INSTANCE
Definition: mxm_1785x_tools.h:188
mxm_17841b.h
Headers for the driver for the MAX17841B ASCI and MAX1785x monitoring chip.
MXM_STATEMACHINE_OPERATION_STATES_e
MXM_STATEMACHINE_OPERATION_STATES_e
Definition: mxm_1785x_tools.h:85
STD_RETURN_TYPE_e
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
TEST_MXM_ProcessOpenWire
void TEST_MXM_ProcessOpenWire(MXM_MONITORING_INSTANCE_s *pInstance, DATA_BLOCK_OPEN_WIRE_s *pDataOpenWire)
Definition: mxm_1785x.c:1949
mxm_crc8.h
Headers for the CRC8 calculation for Maxim Integrated Monitoring devices.
mxm_cfg.h
Header for the configuration for the Maxim monitoring chip.
mxm_1785x_tools.h
This is a collection of helper functions for the MAX1785x ICs.
TEST_MXM_ParseVoltageReadall
STD_RETURN_TYPE_e TEST_MXM_ParseVoltageReadall(uint8_t *volt_rx_buffer, uint16_t volt_rx_buffer_len, MXM_DATA_STORAGE_s *datastorage, MXM_CONVERSION_TYPE_e conversionType)
Definition: mxm_1785x.c:1942
MXM_REG_NAME_e
enum MXM_REG_NAME MXM_REG_NAME_e
MAX1785x register names.
TEST_MXM_HandleStateReadall
bool TEST_MXM_HandleStateReadall(MXM_MONITORING_INSTANCE_s *pInstance, MXM_REG_NAME_e registerName, MXM_STATEMACHINE_OPERATION_STATES_e nextState)
Definition: mxm_1785x.c:1936
mxm_basic_defines.h
Basic defines for the complete Maxim driver.
TEST_MXM_HandleStateWriteall
void TEST_MXM_HandleStateWriteall(MXM_MONITORING_INSTANCE_s *pInstance, MXM_STATEMACHINE_OPERATION_STATES_e nextState)
Definition: mxm_1785x.c:1931
TEST_MXM_ParseVoltagesIntoDB
STD_RETURN_TYPE_e TEST_MXM_ParseVoltagesIntoDB(MXM_MONITORING_INSTANCE_s *pInstance)
Definition: mxm_1785x.c:1923
database_cfg.h
Database configuration header.
mxm_battery_management.h
Headers for the driver for the MAX17841B ASCI and MAX1785x monitoring chip.