226 uint16_t cellOffset = 0u;
227 uint16_t registerVoltageIndex = 0u;
228 uint16_t storedVoltageIndex = 0u;
229 uint16_t rawValue = 0u;
230 int16_t signedValue = 0;
231 float_t floatVoltage = 0.0f;
233 uint16_t bufferLSB = 0u;
234 uint16_t bufferMSB = 0u;
236 static uint16_t numberValidMeasurements = 0;
239 numberValidMeasurements = 0u;
242 switch (storeLocation) {
272 switch (registerSet) {
296 for (uint16_t m = 0u; m <
ADI_N_ADI; m++) {
299 registerVoltageIndex = c + cellOffset;
306 bufferMSB = (uint16_t)(data
309 bufferLSB = (uint16_t)(data
313 signedValue = (int16_t)rawValue;
317 voltage = (int16_t)floatVoltage;
333 (0x01u << storedVoltageIndex);
336 (~0x01u << storedVoltageIndex);
337 numberValidMeasurements++;
371 switch (registerType) {
394 uint16_t storedVoltageIndex = 0u;
395 for (uint8_t c = 0; c < registerVoltageIndex; c++) {
397 storedVoltageIndex++;
400 return storedVoltageIndex;
436 #ifdef UNITY_UNIT_TEST
438 extern void TEST_ADI_CopyCommandBytesCellVoltageRegister(
443 extern void TEST_ADI_CopyCommandBytesAverageCellVoltageRegisters(
448 extern void TEST_ADI_CopyCommandBytesFilteredCellVoltageRegisters(
453 extern void TEST_ADI_CopyCommandBytesRedundantCellVoltageRegisters(
458 extern void TEST_ADI_ReadAndStoreVoltages(
465 extern void TEST_ADI_SaveRxToCellVoltageBuffer(
const uint8_t adi_voltageInputsUsed[ADI_MAX_SUPPORTED_CELLS]
#define ADI_MAX_SUPPORTED_CELLS
uint16_t adi_command[ADI_COMMAND_DEFINITION_LENGTH]
uint8_t adi_dataReceive[BS_NR_OF_MODULES_PER_STRING *ADI_MAX_REGISTER_SIZE_IN_BYTES]
Header for the buffers used by the driver for the ADI analog front-end.
Header for the configuration for the ADI analog front-end.
const uint16_t adi_cmdAdcv[ADI_COMMAND_DEFINITION_LENGTH]
Header file of some software.
const uint16_t adi_cmdRdcva[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsva[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsvb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsvf[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdacf[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdcvd[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsvd[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdfcb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsve[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdfce[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdfcf[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdfcd[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdacc[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdaca[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdcvb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdace[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdfcc[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdfca[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdsvc[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdcvf[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdacd[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdacb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdcve[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdcvc[ADI_COMMAND_DEFINITION_LENGTH]
Header file of some software.
#define ADI_MEASUREMENT_RESTART_WAIT_TIME_ms
#define ADI_RESULT_REGISTER_SET_A
ADI_VOLTAGE_REGISTER_TYPE_e
@ ADI_CELL_VOLTAGE_REGISTER
@ ADI_FILTERED_CELL_VOLTAGE_REGISTER
@ ADI_AVERAGE_CELL_VOLTAGE_REGISTER
@ ADI_REDUNDANT_CELL_VOLTAGE_REGISTER
#define ADI_VOLTAGE_CONVERSION_FACTOR
#define ADI_ADCV_RSTF_POS
#define ADI_ADCV_RSTF_LEN
#define ADI_RAW_VOLTAGE_SIZE_IN_BYTES
#define ADI_RESULT_REGISTER_SET_C
#define ADI_VOLTAGE_CONVERSION_UNIT
#define ADI_MAX_NUMBER_OF_VOLTAGES_IN_REGISTER
#define ADI_RESULT_REGISTER_SET_D
#define ADI_VOLTAGE_06_08_OFFSET
#define ADI_ADCV_OW01_POS
#define ADI_VOLTAGE_15_18_OFFSET
#define ADI_MEASUREMENT_STOP_WAIT_TIME_ms
#define ADI_MAX_REGISTER_SIZE_IN_BYTES
#define ADI_VOLTAGE_00_02_OFFSET
#define ADI_RESULT_REGISTER_SET_E
#define ADI_REGISTER_CLEARED_VALUE
#define ADI_VOLTAGE_CONVERSION_OFFSET
#define ADI_VOLTAGE_12_14_OFFSET
#define ADI_VOLTAGE_03_05_OFFSET
#define ADI_ADCV_CONT_POS
#define ADI_ADCV_CONT_LEN
#define ADI_ADCV_OW01_LEN
ADI_VOLTAGE_STORE_LOCATION_e
@ ADI_AVERAGE_CELL_VOLTAGE
@ ADI_REDUNDANT_CELL_VOLTAGE
@ ADI_FILTERED_CELL_VOLTAGE
@ ADI_CELL_VOLTAGE_AVERAGE_OPEN_WIRE
@ ADI_VOLTAGE_STORE_LOCATION_E_MAX
@ ADI_CELL_VOLTAGE_OPEN_WIRE_ODD
@ ADI_CELL_VOLTAGE_OPEN_WIRE_EVEN
@ ADI_CELL_VOLTAGE_REDUNDANT_OPEN_WIRE
#define ADI_VOLTAGE_09_11_OFFSET
#define ADI_RESULT_REGISTER_SET_B
#define ADI_RESULT_REGISTER_SET_F
Headers for the diagnostic driver for the ADI analog front-end.
bool ADI_EvaluateDiagnosticCellVoltages(ADI_STATE_s *adiState, uint16_t moduleNumber)
Evaluate diagnostic for cell voltage measurement.
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_ReadRegister(uint16_t *registerToRead, uint8_t *data, ADI_STATE_s *adiState)
send command to the ades183x daisy-chain to read a register.
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.
void ADI_StopContinuousCellVoltageMeasurements(ADI_STATE_s *adiState)
Stop cell voltage measurement.
static void ADI_CopyCommandBytesAverageCellVoltageRegisters(ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters)
Copies the related command bytes to read the average voltage registers.
static void ADI_ReadAndStoreVoltages(ADI_STATE_s *adiState, ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters, ADI_VOLTAGE_STORE_LOCATION_e storeLocation)
Copies the related command bytes to read the average voltage registers.
static void ADI_CopyCommandBytesRedundantCellVoltageRegisters(ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters)
Copies the related command bytes to read the redundant voltage registers.
void ADI_GetVoltages(ADI_STATE_s *adiState, ADI_VOLTAGE_REGISTER_TYPE_e registerType, ADI_VOLTAGE_STORE_LOCATION_e storeLocation)
Reads and stores cell voltages.
uint16_t ADI_GetStoredVoltageIndex(uint16_t registerVoltageIndex)
Converts index of read voltages.
void ADI_RestartContinuousCellVoltageMeasurements(ADI_STATE_s *adiState)
Restart cell voltage measurement.
static void ADI_CopyCommandBytesCellVoltageRegister(ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters)
Copies the related command bytes to read the voltage registers.
static void ADI_CopyCommandBytesFilteredCellVoltageRegisters(ADI_COMMAND_READ_REGISTERS_s *commandBytesToReadVoltageRegisters)
Copies the related command bytes to read the filtered voltage registers.
static void ADI_SaveRxToCellVoltageBuffer(ADI_STATE_s *adiState, uint8_t *data, uint8_t registerSet, ADI_VOLTAGE_STORE_LOCATION_e storeLocation)
Saves the cell voltage values read from the daisy-chain.
Header file of some software.
#define BS_NR_OF_CELL_BLOCKS_PER_MODULE
number of cells per module
Assert macro implementation.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
#define NULL_PTR
Null pointer.
uint16_t registerA[ADI_COMMAND_DEFINITION_LENGTH]
uint16_t registerF[ADI_COMMAND_DEFINITION_LENGTH]
uint16_t registerB[ADI_COMMAND_DEFINITION_LENGTH]
uint16_t registerD[ADI_COMMAND_DEFINITION_LENGTH]
uint16_t registerC[ADI_COMMAND_DEFINITION_LENGTH]
uint16_t registerE[ADI_COMMAND_DEFINITION_LENGTH]
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageRedundant
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageFiltered
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageAverageOpenWire
ADI_ERROR_TABLE_s * errorTable
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageOpenWireEven
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageAverage
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageRedundantOpenWire
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltageOpenWireOdd
bool voltageRegisterContentIsNotStuck[BS_NR_OF_STRINGS][ADI_N_ADI]
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING][BS_NR_OF_CELL_BLOCKS_PER_MODULE]
uint64_t invalidCellVoltage[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]
uint16_t nrValidCellVoltages[BS_NR_OF_STRINGS]