foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
adi_ades183x.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, 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 adi_ades183x.h
44  * @author foxBMS Team
45  * @date 2015-09-01 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVERS
49  * @prefix ADI
50  *
51  * @brief Headers for the driver for the ADI analog front-end.
52  *
53  */
54 
55 #ifndef FOXBMS__ADI_ADES183X_H_
56 #define FOXBMS__ADI_ADES183X_H_
57 
58 /*========== Includes =======================================================*/
59 /* clang-format off */
60 #include "adi_ades183x_cfg.h"
61 /* clang-format on */
62 
63 #include "adi_ades183x_defs.h"
64 #include "afe.h"
65 
66 #include <stdbool.h>
67 #include <stdint.h>
68 
69 /*========== Macros and Definitions =========================================*/
70 
71 /* Value notified to the AFE task in the DMA callback called when
72  the SPI transaction for the communication with the ADI AFE is
73  finished */
74 #define ADI_DMA_SPI_FINISHED_NOTIFICATION_VALUE (0x50u)
75 
76 /*========== Extern Constant and Variable Declarations ======================*/
77 
78 /** Contains the internal state of the adi driver. */
80 
81 /*========== Extern Function Prototypes =====================================*/
82 
83 /**
84  * @brief Sets the pins to activate the interface board.
85  */
86 extern void ADI_ActivateInterfaceBoard(void);
87 
88 /**
89  * @brief Makes a request to the ADI driver.
90  * @param request request to be made with string addressed
91  * @return STD_OK if request queue was empty, STD_NOT_OK otherwise
92  */
94 
95 /**
96  * @brief Implements the actual measurement sequence for the ADI driver.
97  * @details This function contains the sequence of events
98  * @param adiState state of the adi driver
99  */
100 extern void ADI_MeasurementCycle(ADI_STATE_s *adiState);
101 
102 /**
103  * @brief Gets the measurement initialization status.
104  * @param adiState state of the adi driver
105  * @return true if a first measurement cycle was made, false otherwise
106  */
107 extern bool ADI_IsFirstMeasurementCycleFinished(ADI_STATE_s *adiState);
108 
109 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
110 #ifdef UNITY_UNIT_TEST
111 extern void TEST_ADI_AccessToDatabase(ADI_STATE_s *adiState);
112 extern void TEST_ADI_BalanceControl(ADI_STATE_s *adiState);
113 extern STD_RETURN_TYPE_e TEST_ADI_GetRequest(AFE_REQUEST_e *request);
114 extern bool TEST_ADI_ProcessMeasurementNotStartedState(ADI_STATE_s *adiState, AFE_REQUEST_e *request);
115 extern void TEST_ADI_RunCurrentStringMeasurement(ADI_STATE_s *adiState);
116 extern void TEST_ADI_SetFirstMeasurementCycleFinished(ADI_STATE_s *adiState);
117 #endif
118 
119 #endif /* FOXBMS__ADI_ADES183X_H_ */
STD_RETURN_TYPE_e ADI_MakeRequest(AFE_REQUEST_e request)
Makes a request to the ADI driver.
Definition: adi_ades183x.c:342
ADI_STATE_s adi_stateBase
Definition: adi_ades183x.c:116
void ADI_MeasurementCycle(ADI_STATE_s *adiState)
Implements the actual measurement sequence for the ADI driver.
Definition: adi_ades183x.c:364
bool ADI_IsFirstMeasurementCycleFinished(ADI_STATE_s *adiState)
Gets the measurement initialization status.
Definition: adi_ades183x.c:354
void ADI_ActivateInterfaceBoard(void)
Sets the pins to activate the interface board.
Definition: adi_ades183x.c:322
Header for the configuration for the ADI analog front-end.
Headers for the driver for the ades183x analog front-end.
AFE driver header.
AFE_REQUEST_e
Definition: afe.h:69
STD_RETURN_TYPE_e
Definition: fstd_types.h:82