foxBMS  1.1.1
The foxBMS Battery Management System API Documentation
mxm_1785x.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 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
111 extern STD_RETURN_TYPE_e TEST_MXM_ParseVoltageReadallTest(MXM_MONITORING_INSTANCE_s *pInstance);
112 extern STD_RETURN_TYPE_e TEST_MXM_ParseVoltagesIntoDB(MXM_MONITORING_INSTANCE_s *pInstance);
113 extern MXM_MONINTORING_STATE_e TEST_MXM_MonGetVoltages(MXM_MONITORING_INSTANCE_s *pInstance, MXM_REG_NAME_e regAddress);
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,
121 extern STD_RETURN_TYPE_e TEST_MXM_ParseVoltageReadall(
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_ */
Database configuration header.
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
Headers for the driver for the MAX17841B ASCI and MAX1785x monitoring chip.
void MXM_StateMachine(MXM_MONITORING_INSTANCE_s *pInstance)
Battery monitoring driver for MAX1785x battery monitoring ICs.
Definition: mxm_1785x.c:1934
This is a collection of helper functions for the MAX1785x ICs.
MXM_STATEMACHINE_OPERATION_STATES_e
enum MXM_MONITORING_STATE MXM_MONINTORING_STATE_e
Basic defines for the complete Maxim driver.
enum MXM_CONVERSION_TYPE MXM_CONVERSION_TYPE_e
Headers for the driver for the MAX17841B ASCI and MAX1785x monitoring chip.
Header for the configuration for the Maxim monitoring chip.
Headers for the CRC8 calculation for Maxim Integrated Monitoring devices.
enum MXM_REG_NAME MXM_REG_NAME_e
MAX1785x register names.