102 uint8_t registerOffset,
112 uint8_t registerOffset,
151 for (uint16_t i = 0u; i <
ADI_N_ADI; i++) {
166 bool configurationAIsOk =
true;
167 bool configurationBIsOk =
true;
174 configurationAIsOk =
false;
179 if (configurationAIsOk ==
false) {
184 configurationAIsOk =
true;
189 configurationBIsOk =
false;
194 if (configurationBIsOk ==
false) {
199 configurationBIsOk =
true;
205 uint16_t *configuredCommand,
208 uint16_t configuration) {
221 command |= (configuration << position) & mask;
264 destinationCommand[i] = sourceCommand[i];
268 extern void ADI_ReadDataBits(uint8_t receivedData, uint8_t *pDataToRead, uint8_t position, uint8_t mask) {
276 *pDataToRead = (receivedData & mask) >> position;
290 uint16_t PEC_result = 0u;
292 uint8_t afeCommandCounter = 0u;
299 uint16_t dataLength = registerLengthInBytes;
326 for (uint16_t i = 0; i <
ADI_N_ADI; i++) {
328 for (
byte = 0u;
byte < registerLengthInBytes;
byte++) {
329 data[
byte + (i * dataLength)] =
334 for (
byte = 0u;
byte < registerLengthInBytes;
byte++) {
361 (adiState->
data.
rxBuffer[crcByte0Position + (i * spiFrameLength)] &
366 #if (ADI_DISCARD_PEC == false)
383 uint16_t commandCounterData = adiState->
data.
rxBuffer[crcFirstBytePosition + (i * spiFrameLength)] &
402 uint32_t frameLength) {
410 if (frameLength == 0u) {
436 uint32_t ulNotifiedValue = 0u;
449 }
else if ((retVal ==
STD_OK) && (retValDummy ==
STD_OK)) {
458 uint8_t registerOffset,
485 uint16_t PEC_result = 0u;
514 const uint16_t *registerToWrite,
522 for (uint16_t i = 0u; i <
ADI_N_ADI; i++) {
557 for (uint16_t i = 0u; i <
ADI_N_ADI; i++) {
572 extern void ADI_WriteDataBits(uint8_t *pSentData, uint8_t dataToWrite, uint8_t position, uint8_t mask) {
580 uint8_t tempData = (uint8_t)((((uint16_t)dataToWrite) << position) &
ADI_DATA_MASK_SEED);
582 *pSentData |= tempData & mask;
589 const uint16_t *registerToWrite,
597 uint16_t PEC_result = 0;
600 uint16_t spiFrameLength = registerLengthInBytes + 2u;
601 uint16_t dataLength = registerLengthInBytes;
624 for (uint16_t i = 0u; i <
ADI_N_ADI; i++) {
626 for (uint16_t
byte = 0;
byte < registerLengthInBytes;
byte++) {
629 data[
byte + (i * dataLength)];
637 for (uint16_t
byte = 0;
byte < registerLengthInBytes;
byte++) {
638 uint16_t bufferData =
649 adiState->
data.
txBuffer[crcFirstBytePosition + (i * spiFrameLength)] =
651 adiState->
data.
txBuffer[crcFirstBytePosition + 1u + (i * spiFrameLength)] =
654 adiState->
data.
txBuffer[crcFirstBytePosition + (i * spiFrameLength)] =
676 #ifdef UNITY_UNIT_TEST
677 extern void TEST_ADI_StoredConfigurationFillRegisterData(
680 uint8_t registerOffset,
687 extern void TEST_ADI_IncrementCommandCounter(
ADI_STATE_s *adiState) {
Headers for the driver for the ADI analog front-end.
#define ADI_DMA_SPI_FINISHED_NOTIFICATION_VALUE
uint8_t adi_configurationRegisterBgroup[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING *ADI_MAX_REGISTER_SIZE_IN_BYTES]
uint16_t adi_command[ADI_COMMAND_DEFINITION_LENGTH]
uint8_t adi_readConfigurationRegisterBgroup[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING *ADI_MAX_REGISTER_SIZE_IN_BYTES]
uint8_t adi_configurationRegisterAgroup[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING *ADI_MAX_REGISTER_SIZE_IN_BYTES]
uint8_t adi_dataTransmit[BS_NR_OF_MODULES_PER_STRING *ADI_MAX_REGISTER_SIZE_IN_BYTES]
uint8_t adi_readConfigurationRegisterAgroup[BS_NR_OF_STRINGS][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.
const uint16_t adi_cmdRdcfga[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRstcc[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdWrcfgb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdRdcfgb[ADI_COMMAND_DEFINITION_LENGTH]
const uint16_t adi_cmdWrcfga[ADI_COMMAND_DEFINITION_LENGTH]
Header file of some software.
#define ADI_COMMAND_CODE_LENGTH
#define ADI_COMMAND_PEC_SECOND_BYTE_POSITION
#define ADI_COMMAND_AND_PEC_SIZE_IN_BYTES
#define ADI_COMMAND_COUNTER_POSITION
#define ADI_COMMAND_INC_POSITION
#define ADI_PEC10_FULL_EXCLUDE_COMMAND_COUNTER
#define ADI_COMMAND_COUNTER_MASK
#define ADI_COMMAND_COUNTER_MAX_VALUE
#define ADI_PEC10_MSB_EXCLUDE_COMMAND_COUNTER
#define ADI_FIRST_DATA_BYTE_POSITION_IN_TRANSMISSION_FRAME
#define ADI_COMMAND_SECOND_BYTE_POSITION
#define ADI_COMMAND_SIZE_IN_BYTES
#define ADI_REGISTER_OFFSET5
#define ADI_SPI_WAKEUP_WAIT_TIME_US
#define ADI_DATA_PEC_FIRST_BYTE_POSITION
#define ADI_ONE_BYTE_MASK
#define ADI_COMMAND_BYTE0_POSITION
#define ADI_MAX_REGISTER_SIZE_IN_BYTES
#define ADI_COMMAND_COUNTER_RESTART_VALUE
#define ADI_COMMAND_PEC_FIRST_BYTE_POSITION
#define ADI_N_BYTES_FOR_DATA_TRANSMISSION
#define ADI_COMMAND_BYTE1_POSITION
#define ADI_TRANSMISSION_TIMEOUT
#define ADI_COMMAND_FIRST_BYTE_POSITION
#define ADI_SIZE_OF_DATA_FOR_PEC_COMPUTATION
#define ADI_COMMAND_MASK_SEED
#define ADI_COMMAND_COUNTER_RESET_VALUE
#define ADI_DATA_MASK_SEED
#define ADI_COMMAND_DATA_LENGTH_POSITION
ADI_PEC_FAULT_INJECTION_e
@ ADI_PEC_NO_FAULT_INJECTION
@ ADI_COMMAND_PEC_FAULT_INJECTION
@ ADI_DATA_PEC_FAULT_INJECTION
#define ADI_SIZE_OF_DATA_FOR_PEC_COMPUTATION_WITH_COUNTER
#define ADI_PEC_SIZE_IN_BYTES
#define ADI_DATA_PEC_SECOND_BYTE_POSITION
#define ADI_COMMAND_DEFINITION_LENGTH
#define ADI_MAX_BIT_POSITION_IN_BYTE
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_WriteRegister(const uint16_t *registerToWrite, uint8_t *data, ADI_PEC_FAULT_INJECTION_e pecFaultInjection, ADI_STATE_s *adiState)
sends command to the ades183x daisy-chain to write data.
STD_RETURN_TYPE_e ADI_CheckConfigurationRegister(ADI_CFG_REGISTER_SET_e registerSet, ADI_STATE_s *adiState)
Compares the configuration stored in the AFE driver with the configuration read from the AFEs.
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.
static void ADI_IncrementCommandCounter(ADI_STATE_s *adiState)
Increment command counter of AFE driver.
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.
static void ADI_StoredConfigurationFillRegisterData(uint8_t module, 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 a specific AFE.
Headers for the diagnostic driver for the ADI analog front-end.
uint16_t ADI_Pec10(uint8_t length, uint8_t *data, bool receive)
calculates the PEC10 K
uint16_t ADI_Pec15(uint8_t length, uint8_t *data)
calculates the PEC15
Headers for the PEC computations.
#define BS_NR_OF_MODULES_PER_STRING
number of modules in a string
#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.
OS_STD_RETURN_e OS_WaitForNotification(uint32_t *pNotifiedValue, uint32_t timeout)
Wait for a notification.
void OS_DelayTaskUntil(uint32_t *pPreviousWakeTime, uint32_t milliseconds)
Delay a task until a specified time.
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength)
Transmits and receives data on SPI with DMA.
STD_RETURN_TYPE_e SPI_TransmitDummyByte(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay)
Sends a dummy byte to wake up the SPI interface.
STD_RETURN_TYPE_e SPI_TransmitData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint32 frameLength)
Transmits data on SPI without DMA.
SPI_INTERFACE_CONFIG_s spi_adiInterface[BS_NR_OF_STRINGS]
uint8_t commandCounter[BS_NR_OF_STRINGS][ADI_N_ADI]
ADI_ERROR_TABLE_s * errorTable
bool crcIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool commandCounterIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool spiIsOk[BS_NR_OF_STRINGS]
bool configurationAIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]
bool configurationBIsOk[BS_NR_OF_STRINGS][ADI_N_ADI]