foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
adi_ades183x_initialization.c
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_initialization.c
44  * @author foxBMS Team
45  * @date 2019-08-27 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVER
49  * @prefix ADI
50  *
51  * @brief Implementation of some software
52  *
53  */
54 
55 /*========== Includes =======================================================*/
56 
58 
59 #include "adi_ades183x_buffers.h"
60 #include "adi_ades183x_commands.h"
61 #include "adi_ades183x_defs.h"
62 #include "adi_ades183x_helpers.h"
63 
64 #include <stdbool.h>
65 #include <stdint.h>
66 
67 /*========== Macros and Definitions =========================================*/
68 /* Wait at least one micro second for the AFE to wakeup */
69 #define ADI_AFE_WAKEUP_TIME ((ADI_DAISY_CHAIN_WAKE_UP_TIME_us / ADI_COEFFICIENT_US_TO_MS) + 1u)
70 #define ADI_ISO_SPI_WAKEUP_TIME ((ADI_DAISY_CHAIN_READY_TIME_us / ADI_COEFFICIENT_US_TO_MS) + 1u)
71 
72 /*========== Static Constant and Variable Definitions =======================*/
73 
74 /*========== Extern Constant and Variable Definitions =======================*/
75 
76 /*========== Static Function Prototypes =====================================*/
77 
78 /**
79  * @brief TODO.
80  * @details TODO
81  * @param adiState state of the driver
82  */
84 
85 /**
86  * @brief Disable balancing.
87  * @details TODO
88  * @param adiState state of the driver
89  */
90 static void ADI_DisableBalancingOnStartup(ADI_STATE_s *adiState);
91 
92 /**
93  * @brief TODO.
94  * @details TODO
95  * @param adiState state of the driver
96  */
97 static void ADI_GetSerialIdsOfAllIcsInString(ADI_STATE_s *adiState);
98 
99 /**
100  * @brief TODO.
101  * @details TODO
102  * @param adiState state of the driver
103  */
104 static void ADI_GetRevisionOfAllIcsInString(ADI_STATE_s *adiState);
105 
106 /**
107  * @brief Initialize the driver configuration.
108  * @details TODO
109  * @param adiState state of the driver
110  */
111 static void ADI_InitializeConfiguration(ADI_STATE_s *adiState);
112 
113 /**
114  * @brief Resets the error table.
115  * @details This function should be called during initialization or before
116  * starting a new measurement cycle
117  * @param adiState state of the driver
118  */
119 static void ADI_ResetErrorTable(ADI_STATE_s *adiState);
120 
121 /**
122  * @brief Reset TODO.
123  * @details TODO
124  * @param adiState state of the driver
125  */
126 static void ADI_ResetIirFilterOnStartup(ADI_STATE_s *adiState);
127 
128 /**
129  * @brief Start cell voltage measurement.
130  * @details This function should be called during initialization or before
131  * starting a new measurement cycle
132  * @param adiState state of the driver
133  */
135 
136 /**
137  * @brief Wake up the AFE.
138  * @details TODO
139  * @param adiState state of the driver
140  */
141 static void ADI_WakeUpDaisyChain(ADI_STATE_s *adiState);
142 
143 /*========== Static Function Implementations ================================*/
144 
146  FAS_ASSERT(adiState != NULL_PTR);
147 
185 }
186 
188  FAS_ASSERT(adiState != NULL_PTR);
189 
190  /* balancing: Set all PWM values to 0 for all AFEs in the daisy-chain */
199 }
200 
202  FAS_ASSERT(adiState != NULL_PTR);
203 
206  for (uint16_t m = 0; m < ADI_N_ADI; m++) {
207  adiState->serialId[adiState->currentString][m] = 0u;
208  for (uint8_t byte = 0u; byte < ADI_RDSID_LEN; byte++) {
209  adiState->serialId[adiState->currentString][m] |= ((uint64_t)adi_dataReceive[(m * ADI_RDSID_LEN) + byte])
210  << (ADI_BYTE_SHIFT * byte);
211  }
212  }
213 }
214 
216  FAS_ASSERT(adiState != NULL_PTR);
217 
220  for (uint16_t m = 0; m < ADI_N_ADI; m++) {
223  &(adiState->revision[adiState->currentString][m]),
226  }
227 }
228 
229 static void ADI_InitializeConfiguration(ADI_STATE_s *adiState) {
230  FAS_ASSERT(adiState != NULL_PTR);
231 
232  /* Configuration register A */
233  /* CFGRA0 */
234  /**
235  * SM_VCELL_RED: Cell Voltage Measurement Redundancy
236  * CTH[2:0]=0b010 -> S-ADC comparison threshold set to 9 mV
237  */
244  adiState);
251  adiState);
252  /* CFGRA1 */
253  /* Do not assert any fault flags. Field will be used in diagnostic functions */
260  adiState);
261  /* CFGRA2 */
268  adiState);
275  adiState);
276  /* Disable soak time on AUX ADCs */
283  adiState);
284  /* CFGRA3 */
291  adiState);
292  /* CFGRA4 */
299  adiState);
300  /* CFGRA5 */
307  adiState);
314  adiState);
321  adiState);
328  adiState);
329 
330  /* Configuration register B */
331  /* CFGRB0 */
338  adiState);
339  /* CFGRB1 */
346  adiState);
353  adiState);
354  /* CFGRB2 */
361  adiState);
362  /* CFGRB3 */
369  adiState);
376  adiState);
383  adiState);
384  /* CFGRB4 */
391  adiState);
392  /* CFGRB5 */
399  adiState);
400 }
401 
402 static void ADI_ResetErrorTable(ADI_STATE_s *adiState) {
403  FAS_ASSERT(adiState != NULL_PTR);
404 
405  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
406  adiState->data.errorTable->spiIsOk[stringNumber] = true;
407  for (uint16_t m = 0; m < ADI_N_ADI; m++) {
408  adiState->data.errorTable->crcIsOk[stringNumber][m] = true;
409  adiState->data.errorTable->commandCounterIsOk[stringNumber][m] = true;
410  adiState->data.errorTable->configurationAIsOk[stringNumber][m] = true;
411  adiState->data.errorTable->configurationBIsOk[stringNumber][m] = true;
412  adiState->data.errorTable->voltageRegisterContentIsNotStuck[stringNumber][m] = true;
413  adiState->data.errorTable->auxiliaryRegisterContentIsNotStuck[stringNumber][m] = true;
414  adiState->data.errorTable->adcComparisonIsOk[stringNumber][m] = true;
415  adiState->data.errorTable->compFlagIsCleared[stringNumber][m] = true;
416  adiState->data.errorTable->spiFltFlagIsCleared[stringNumber][m] = true;
417  adiState->data.errorTable->filteredVoltageRangeIsOk[stringNumber][m] = true;
418  adiState->data.errorTable->evenWireIsOk[stringNumber][m] = true;
419  adiState->data.errorTable->oddWireIsOk[stringNumber][m] = true;
420  adiState->data.errorTable->evenWireHasNoLatentFault[stringNumber][m] = true;
421  adiState->data.errorTable->oddWireHasNoLatentFault[stringNumber][m] = true;
422  adiState->data.errorTable->adcCompFlagsHaveNoLatentFault[stringNumber][m] = true;
423  adiState->data.errorTable->auxComparisonIsOk[stringNumber][m] = true;
424  adiState->data.errorTable->auxVoltageRangeIsOk[stringNumber][m] = true;
425  adiState->data.errorTable->analogSupplyOvervoltageFlagIsCleared[stringNumber][m] = true;
426  adiState->data.errorTable->analogSupplyUndervoltageFlagIsCleared[stringNumber][m] = true;
427  adiState->data.errorTable->digitalSupplyOvervoltageFlagIsCleared[stringNumber][m] = true;
428  adiState->data.errorTable->digitalSupplyUndervoltageFlagIsCleared[stringNumber][m] = true;
429  adiState->data.errorTable->vdeFlagIsCleared[stringNumber][m] = true;
430  adiState->data.errorTable->oscchkFlagIsCleared[stringNumber][m] = true;
431  adiState->data.errorTable->analogSupplyOvervoltageFlagHasNoLatentFault[stringNumber][m] = true;
432  adiState->data.errorTable->analogSupplyUndervoltageFlagHasNoLatentFault[stringNumber][m] = true;
433  adiState->data.errorTable->digitalSupplyOvervoltageFlagHasNoLatentFault[stringNumber][m] = true;
434  adiState->data.errorTable->digitalSupplyUndervoltageFlagHasNoLatentFault[stringNumber][m] = true;
435  adiState->data.errorTable->vdeFlagHasNoLatentFault[stringNumber][m] = true;
436  adiState->data.errorTable->vdelFlagHasNoLatentFault[stringNumber][m] = true;
437  adiState->data.errorTable->analogSupplyRangeIsOk[stringNumber][m] = true;
438  adiState->data.errorTable->digitalSupplyRangeIsOk[stringNumber][m] = true;
439  adiState->data.errorTable->vresRangeIsOk[stringNumber][m] = true;
440  adiState->data.errorTable->dieTemperatureIsOk[stringNumber][m] = true;
441  adiState->data.errorTable->oscchkFlagHasNoLatentFault[stringNumber][m] = true;
442  adiState->data.errorTable->ocCounterFasterFlagHasNoLatentFault[stringNumber][m] = true;
443  adiState->data.errorTable->ocCounterSlowerFlagHasNoLatentFault[stringNumber][m] = true;
444  adiState->data.errorTable->thsdFlagHasNoLatentFault[stringNumber][m] = true;
445  adiState->data.errorTable->tmodchkFlagHasNoLatentFault[stringNumber][m] = true;
446  adiState->data.errorTable->tmodchkFlagIsCleared[stringNumber][m] = true;
447  adiState->data.errorTable->cmedFlagIsCleared[stringNumber][m] = true;
448  adiState->data.errorTable->smedFlagIsCleared[stringNumber][m] = true;
449  adiState->data.errorTable->sleepFlagIsCleared[stringNumber][m] = true;
450  adiState->data.errorTable->cmedFlagHasNoLatentFault[stringNumber][m] = true;
451  adiState->data.errorTable->smedFlagHasNoLatentFault[stringNumber][m] = true;
452  adiState->data.errorTable->initResetAuxValuesAreOk[stringNumber][m] = true;
453  adiState->data.errorTable->initClearedAuxValuesAreOk[stringNumber][m] = true;
454  }
455  }
456 }
457 
458 static void ADI_ResetIirFilterOnStartup(ADI_STATE_s *adiState) {
459  FAS_ASSERT(adiState != NULL_PTR);
460 
461  /* IIR filter: Change FILT configuration for all AFEs */
468  adiState);
470 }
471 
473  FAS_ASSERT(adiState != NULL_PTR);
474 
475  /* Mute balancing before starting cell voltage measurements */
477  ADI_TransmitCommand(adi_command, adiState);
478 
479  /**
480  * SM_VCELL_RED: Cell Voltage Measurement Redundancy
481  * Set RD bit to enable redundant cell voltage measurements
482  */
489  ADI_TransmitCommand(adi_command, adiState);
491 }
492 
493 static void ADI_WakeUpDaisyChain(ADI_STATE_s *adiState) {
494  FAS_ASSERT(adiState != NULL_PTR);
495 
496  /* Send dummy bytes to wake up the daisy chain */
497  uint16_t txData = 0u;
498  /* Send dummy byte and wait at least T_wake for each device to wake up */
499  ADI_SpiTransmitReceiveData(adiState, &txData, NULL_PTR, 0u);
501 
502  /* Send dummy byte and wait at least T_ready for each isoSPI to get active */
503  ADI_SpiTransmitReceiveData(adiState, &txData, NULL_PTR, 0u);
505 }
506 
507 /*========== Extern Function Implementations ================================*/
508 /* RequirementId: D7.1 V0R4 FUN-4.10.01.01 */
509 /* RequirementId: D7.1 V0R4 FUN-4.10.01.02 */
510 /* RequirementId: D7.1 V0R4 FUN-4.10.02.01 */
511 /* RequirementId: D7.1 V0R4 FUN-6.10.02.01 */
512 extern void ADI_InitializeMeasurement(ADI_STATE_s *adiState) {
513  FAS_ASSERT(adiState != NULL_PTR);
514 
516  adiState->currentString = 0u;
517 
518  ADI_ResetErrorTable(adiState);
519 
520  while (adiState->currentString < adiState->spiNumberInterfaces) {
522 
523  /* Wake up daisy-chain */
524  ADI_WakeUpDaisyChain(adiState);
525  /* Issue soft reset to be sure that all AFEs are in the reset state */
527  ADI_TransmitCommand(adi_command, adiState);
529  /* Wake up daisy-chain */
530  ADI_WakeUpDaisyChain(adiState);
531  ADI_ClearCommandCounter(adiState); /* reset command counter */
532 
533  /* Set default configuration in AFE Driver storage */
534  ADI_InitializeConfiguration(adiState);
535  /* REFON bit in configuration register A must be set before checking reset/cleared values */
538  /* Write default configuration from AFE Driver storage to daisy-chain, for all registers */
540 
542 
544 
545  ADI_ResetIirFilterOnStartup(adiState);
546 
547  /* Clear all flags in Status Register Group C */
549 
550  /* TODO: why and what happens here?! */
553  for (uint16_t m = 0u; m < ADI_N_ADI; m++) {
554  /* Get STR5 */
555  uint8_t statusData = adi_dataReceive[(m * ADI_RDSTATC_LEN) + ADI_REGISTER_OFFSET5];
556  /* Check COMP flag */
557  uint8_t flagComp = 0u;
559  if (flagComp != 1u) {
560  adiState->data.errorTable->compFlagIsCleared[adiState->currentString][m] = false;
561  }
562  }
563 
564  /* Start continuous cell voltage measurements */
566  /* Read serial IDs of all ICs in string */
568  /* Read revisions of all ICs in string */
570  ++adiState->currentString;
571  }
572  adiState->currentString = 0u;
573 }
574 
575 /*========== Externalized Static Function Implementations (Unit Test) =======*/
576 #ifdef UNITY_UNIT_TEST
577 extern void TEST_ADI_ClearAllFlagsInStatusRegisterGroupC(ADI_STATE_s *adiState) {
579 }
580 extern void TEST_ADI_DisableBalancingOnStartup(ADI_STATE_s *adiState) {
582 }
583 extern void TEST_ADI_GetRevisionOfAllIcsInString(ADI_STATE_s *adiState) {
585 }
586 extern void TEST_ADI_GetSerialIdsOfAllIcsInString(ADI_STATE_s *adiState) {
588 }
589 extern void TEST_ADI_InitializeConfiguration(ADI_STATE_s *adiState) {
590  ADI_InitializeConfiguration(adiState);
591 }
592 extern void TEST_ADI_ResetErrorTable(ADI_STATE_s *adiState) {
593  ADI_ResetErrorTable(adiState);
594 }
595 extern void TEST_ADI_StartContinuousCellVoltageMeasurements(ADI_STATE_s *adiState) {
597 }
598 extern void TEST_ADI_WakeUpDaisyChain(ADI_STATE_s *adiState) {
599  ADI_WakeUpDaisyChain(adiState);
600 }
601 extern void TEST_ADI_ResetIirFilterOnStartup(ADI_STATE_s *adiState) {
602  ADI_ResetIirFilterOnStartup(adiState);
603 }
604 #endif
uint16_t adi_command[ADI_COMMAND_DEFINITION_LENGTH]
uint8_t adi_dataReceive[BS_NR_OF_MODULES_PER_STRING *ADI_MAX_REGISTER_SIZE_IN_BYTES]
uint8_t adi_writeGlobal[ADI_MAX_REGISTER_SIZE_IN_BYTES]
uint8_t adi_clearFlagData[ADI_CLRFLAG_DATA_LENGTH]
Header for the buffers used by the driver for the ADI analog front-end.
const uint16_t adi_cmdWrpwma[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdstatc[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdMute[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdAdcv[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdClrflag[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdWrpwmb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdstate[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdSrst[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsid[ADI_COMMAND_DEFINITION_LENGTH]
Header file of some software.
Headers for the driver for the ades183x analog front-end.
#define ADI_STCR0_CS4FLT_MASK
#define ADI_STCR0_CS3FLT_POS
#define ADI_CFGRA5_FC_0_2_POS
#define ADI_DEFAULT_DCC_9_16_SETUP
#define ADI_STCR0_CS8FLT_POS
#define ADI_TREFUP_ms
#define ADI_CFGRB0_VUV_0_7_MASK
#define ADI_STCR0_CS5FLT_MASK
#define ADI_DEFAULT_DCT0_0_5_SETUP
#define ADI_STCR5_SLEEP_MASK
#define ADI_CFGRB1_VOV_0_3_MASK
#define ADI_DEFAULT_VUV_8_11_SETUP
#define ADI_CFGRB3_DTRNG_MASK
#define ADI_CFGRA1_FLAG_D_0_7_POS
#define ADI_DEFAULT_FLAG_D_SETUP
#define ADI_DEFAULT_SNAP_ST_SETUP
#define ADI_STCR1_CS16FLT_MASK
#define ADI_STCR1_CS16FLT_POS
#define ADI_STER5_REV_0_3_MASK
#define ADI_CFGRA4_GPO_9_10_POS
#define ADI_DEFAULT_MUTE_ST_SETUP
#define ADI_STCR5_OSCCHK_POS
#define ADI_STCR0_CS4FLT_POS
#define ADI_STCR4_SMED_MASK
#define ADI_BYTE_SHIFT
#define ADI_STCR4_CED_POS
#define ADI_CFGRB5_DCC_9_16_MASK
#define ADI_STCR5_OSCCHK_MASK
#define ADI_STCR0_CS6FLT_POS
#define ADI_STCR4_VD_UV_POS
#define ADI_DEFAULT_IIR_SETUP
#define ADI_CFGRB4_DCC_1_8_POS
#define ADI_STCR5_SPIFLT_MASK
#define ADI_CFGRB4_DCC_1_8_MASK
#define ADI_IIR_FILTER_PARAMETER_2
#define ADI_CFGRA5_MUTE_ST_POS
#define ADI_ADCV_RSTF_POS
#define ADI_DEFAULT_VOV_0_3_SETUP
#define ADI_ADCV_RSTF_LEN
#define ADI_CFGRA5_SNAP_ST_MASK
#define ADI_DEFAULT_OWA_SETUP
#define ADI_START_AUX_CHANNEL
#define ADI_STER5_REV_0_3_POS
#define ADI_STCR0_CS2FLT_POS
#define ADI_STCR4_VA_OV_POS
#define ADI_STCR5_VDE_MASK
#define ADI_CFGRA5_COMM_BK_POS
#define ADI_STCR4_VD_UV_MASK
#define ADI_RDSTATC_LEN
#define ADI_STCR1_CS9FLT_MASK
#define ADI_STCR5_SPIFLT_POS
#define ADI_CFGRA4_GPO_9_10_MASK
#define ADI_ADCV_RD_LEN
#define ADI_STCR1_CS14FLT_POS
#define ADI_STCR5_SLEEP_POS
#define ADI_N_ADI
#define ADI_CFGRB3_DTMEN_MASK
#define ADI_CFGRB2_VOV_4_11_MASK
#define ADI_DEFAULT_VUV_0_7_SETUP
#define ADI_STCR0_CS7FLT_POS
#define ADI_CFGRB3_DCT0_0_5_POS
#define ADI_CFGRB3_DTRNG_POS
#define ADI_STCR1_CS13FLT_MASK
#define ADI_CFGRB3_DTMEN_POS
#define ADI_STCR4_VA_OV_MASK
#define ADI_CFGRA0_CTH_0_2_MASK
#define ADI_REGISTER_OFFSET5
#define ADI_STCR0_CS1FLT_MASK
#define ADI_CFGRA5_FC_0_2_MASK
#define ADI_STCR1_CS13FLT_POS
#define ADI_STCR5_COMP_MASK
#define ADI_ADCV_OW01_POS
#define ADI_DEFAULT_OWRNG_SETUP
#define ADI_STCR0_CS6FLT_MASK
#define ADI_STCR4_CED_MASK
#define ADI_CFGRB3_DCT0_0_5_MASK
#define ADI_STCR4_VD_OV_MASK
#define ADI_DEFAULT_DTRNG_SETUP
#define ADI_STCR0_CS3FLT_MASK
#define ADI_CFGRA0_REFON_POS
#define ADI_ADCV_RD_POS
#define ADI_STCR1_CS12FLT_MASK
#define ADI_STCR5_THSD_MASK
#define ADI_STCR5_THSD_POS
#define ADI_CFGRB1_VUV_8_11_POS
#define ADI_STCR4_VA_UV_POS
#define ADI_CFGRB1_VUV_8_11_MASK
#define ADI_CFGRA5_COMM_BK_MASK
#define ADI_STCR4_SMED_POS
#define ADI_DEFAULT_GPO_9_10_SETUP
#define ADI_CFGRB0_VUV_0_7_POS
#define ADI_CFGRA0_CTH_0_2_POS
#define ADI_CFGRA2_SOAKON_POS
#define ADI_ADCV_DCP_LEN
#define ADI_STCR4_CMED_MASK
@ ADI_CFG_REGISTER_SET_B
@ ADI_CFG_REGISTER_SET_A
#define ADI_STCR4_VA_UV_MASK
#define ADI_STCR0_CS2FLT_MASK
#define ADI_STCR0_CS7FLT_MASK
#define ADI_IIR_SETTLING_TIME_ms
#define ADI_CFGRA0_REFON_MASK
#define ADI_REGISTER_OFFSET3
#define ADI_RDSID_LEN
#define ADI_STCR5_COMP_POS
#define ADI_STCR1_CS15FLT_MASK
#define ADI_DEFAULT_SOAKON_SETUP
#define ADI_STCR5_TMODCHK_POS
#define ADI_CFGRA2_OWRNG_MASK
#define ADI_STCR1_CS10FLT_POS
#define ADI_DEFAULT_REFON_SETUP
#define ADI_CFGRA2_OWA_0_2_POS
#define ADI_DEFAULT_COMM_BK_SETUP
#define ADI_CFGRA5_MUTE_ST_MASK
#define ADI_STCR4_CMED_POS
#define ADI_STCR5_VDEL_POS
#define ADI_ADCV_CONT_POS
#define ADI_STCR5_VDE_POS
#define ADI_ADCV_CONT_LEN
#define ADI_REGISTER_OFFSET0
#define ADI_STCR5_VDEL_MASK
#define ADI_STCR0_CS1FLT_POS
#define ADI_STCR1_CS11FLT_MASK
#define ADI_DEFAULT_DCC_1_8_SETUP
#define ADI_CFGRA1_FLAG_D_0_7_MASK
#define ADI_STCR4_SED_MASK
#define ADI_DEFAULT_CTH_COMPARISON_THRESHOLD
#define ADI_STCR0_CS8FLT_MASK
#define ADI_ADCV_OW01_LEN
#define ADI_CFGRA3_GPO_1_8_POS
#define ADI_REGISTER_OFFSET1
#define ADI_DEFAULT_VOV_4_11_SETUP
#define ADI_STCR1_CS9FLT_POS
#define ADI_STCR1_CS15FLT_POS
@ ADI_PEC_NO_FAULT_INJECTION
#define ADI_CFGRA3_GPO_1_8_MASK
#define ADI_STCR1_CS11FLT_POS
#define ADI_CFGRA5_SNAP_ST_POS
#define ADI_DEFAULT_DTMEN_SETUP
#define ADI_CFGRB1_VOV_0_3_POS
#define ADI_ADCV_DCP_POS
#define ADI_CFGRB5_DCC_9_16_POS
#define ADI_RDSTATE_LEN
#define ADI_STCR1_CS10FLT_MASK
#define ADI_CFGRA2_OWA_0_2_MASK
#define ADI_CFGRA2_OWRNG_POS
#define ADI_STCR5_TMODCHK_MASK
#define ADI_DEFAULT_GPO_1_8_SETUP
#define ADI_STCR4_SED_POS
#define ADI_STCR0_CS5FLT_POS
#define ADI_TSOFTRESET_ms
#define ADI_CFGRB2_VOV_4_11_POS
#define ADI_STCR1_CS12FLT_POS
#define ADI_STCR1_CS14FLT_MASK
#define ADI_REGISTER_OFFSET4
#define ADI_REGISTER_OFFSET2
#define ADI_CFGRA2_SOAKON_MASK
#define ADI_STCR4_VD_OV_POS
void ADI_WriteCommandConfigurationBits(uint16_t *configuredCommand, uint8_t position, uint8_t length, uint16_t configuration)
write configuration bits in commands (e.g., channel in ADAX command).
void ADI_WriteDataBits(uint8_t *pSentData, uint8_t dataToWrite, uint8_t position, uint8_t mask)
Helper function to write specific bits in data to be sent.
void ADI_ReadDataBits(uint8_t receivedData, uint8_t *pDataToRead, uint8_t position, uint8_t mask)
Helper function to read specific bits from received data.
void ADI_ReadRegister(uint16_t *registerToRead, uint8_t *data, ADI_STATE_s *adiState)
send command to the ades183x daisy-chain to read a register.
void ADI_ClearCommandCounter(ADI_STATE_s *adiState)
Send RSTCC to AFEs in daisy-chain and clear command counter of AFE driver.
void ADI_StoredConfigurationWriteToAfeGlobal(ADI_STATE_s *adiState)
Sends data in the configuration stored in driver to all AFEs in the daisy chain, for all configuratio...
void ADI_StoredConfigurationFillRegisterDataGlobal(ADI_CFG_REGISTER_SET_e registerSet, uint8_t registerOffset, uint8_t data, uint8_t position, uint8_t mask, ADI_STATE_s *adiState)
Writes data in the configuration stored in AFE driver, for all AFEs in the daisy-chain.
void ADI_SpiTransmitReceiveData(ADI_STATE_s *adiState, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength)
Transmits and receives data on SPI.
void ADI_WriteRegisterGlobal(const uint16_t *registerToWrite, uint8_t *data, ADI_PEC_FAULT_INJECTION_e pecFaultInjection, ADI_STATE_s *adiState)
Write the same 6 bytes to all devices in the daisy-chain.
STD_RETURN_TYPE_e ADI_StoredConfigurationWriteToAfe(ADI_CFG_REGISTER_SET_e registerSet, ADI_STATE_s *adiState)
Sends data in the configuration stored in driver to all AFEs in the daisy chain, for a specific confi...
void ADI_TransmitCommand(uint16_t *command, ADI_STATE_s *adiState)
send command to the ades183x daisy-chain (e.g., start voltage measurement).
void ADI_Wait(uint32_t waitTime)
wait for a certain number of milliseconds
void ADI_CopyCommandBits(const uint16_t *sourceCommand, uint16_t *destinationCommand)
copy command bits in variables.
Headers for the diagnostic driver for the ADI analog front-end.
static void ADI_ResetIirFilterOnStartup(ADI_STATE_s *adiState)
Reset TODO.
static void ADI_WakeUpDaisyChain(ADI_STATE_s *adiState)
Wake up the AFE.
static void ADI_InitializeConfiguration(ADI_STATE_s *adiState)
Initialize the driver configuration.
static void ADI_GetRevisionOfAllIcsInString(ADI_STATE_s *adiState)
TODO.
#define ADI_AFE_WAKEUP_TIME
static void ADI_StartContinuousCellVoltageMeasurements(ADI_STATE_s *adiState)
Start cell voltage measurement.
static void ADI_DisableBalancingOnStartup(ADI_STATE_s *adiState)
Disable balancing.
void ADI_InitializeMeasurement(ADI_STATE_s *adiState)
Implements the initialization for the ades183x driver.
static void ADI_ResetErrorTable(ADI_STATE_s *adiState)
Resets the error table.
static void ADI_GetSerialIdsOfAllIcsInString(ADI_STATE_s *adiState)
TODO.
static void ADI_ClearAllFlagsInStatusRegisterGroupC(ADI_STATE_s *adiState)
TODO.
#define ADI_ISO_SPI_WAKEUP_TIME
Header file of some software.
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:255
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:77
ADI_ERROR_TABLE_s * errorTable
bool crcIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool adcComparisonIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool initClearedAuxValuesAreOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool compFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool evenWireIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool digitalSupplyRangeIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool oscchkFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool analogSupplyOvervoltageFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool analogSupplyUndervoltageFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool tmodchkFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool analogSupplyOvervoltageFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool smedFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool oscchkFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool voltageRegisterContentIsNotStuck[BS_NR_OF_STRINGS][ADI_N_ADI]
bool oddWireIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool commandCounterIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool auxiliaryRegisterContentIsNotStuck[BS_NR_OF_STRINGS][ADI_N_ADI]
bool vdeFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool dieTemperatureIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool spiIsOk[BS_NR_OF_STRINGS]
bool digitalSupplyOvervoltageFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool vdelFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool analogSupplyRangeIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool cmedFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool filteredVoltageRangeIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool initResetAuxValuesAreOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool digitalSupplyOvervoltageFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool adcCompFlagsHaveNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool thsdFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool vdeFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool cmedFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool configurationAIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool auxComparisonIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool sleepFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool ocCounterSlowerFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool spiFltFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool auxVoltageRangeIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool tmodchkFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool oddWireHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool configurationBIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool evenWireHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool vresRangeIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool smedFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool ocCounterFasterFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool digitalSupplyUndervoltageFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
bool digitalSupplyUndervoltageFlagIsCleared[BS_NR_OF_STRINGS][ADI_N_ADI]
bool analogSupplyUndervoltageFlagHasNoLatentFault[BS_NR_OF_STRINGS][ADI_N_ADI]
uint8_t revision[BS_NR_OF_STRINGS][ADI_N_ADI]
uint64_t serialId[BS_NR_OF_STRINGS][ADI_N_ADI]
uint8_t spiNumberInterfaces
uint8_t redundantAuxiliaryChannel[BS_NR_OF_STRINGS]