![]() |
foxBMS
1.6.0
The foxBMS Battery Management System API Documentation
|
Headers for the diagnostic driver for the ADI analog front-end. More...
Go to the source code of this file.
Functions | |
void | ADI_TransmitCommand (uint16_t *command, ADI_STATE_s *adiState) |
send command to the ades183x daisy-chain (e.g., start voltage measurement). More... | |
void | ADI_CopyCommandBits (const uint16_t *sourceCommand, uint16_t *destinationCommand) |
copy command bits in variables. More... | |
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). More... | |
void | ADI_ReadDataBits (uint8_t receivedData, uint8_t *pDataToRead, uint8_t position, uint8_t mask) |
Helper function to read specific bits from received data. More... | |
void | ADI_ReadRegister (uint16_t *registerToRead, uint8_t *data, ADI_STATE_s *adiState) |
send command to the ades183x daisy-chain to read a register. More... | |
void | ADI_StoredConfigurationWriteToAfeGlobal (ADI_STATE_s *adiState) |
Sends data in the configuration stored in driver to all AFEs in the daisy chain, for all configuration registers. More... | |
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. More... | |
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 configuration register. More... | |
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. More... | |
void | ADI_ClearCommandCounter (ADI_STATE_s *adiState) |
Send RSTCC to AFEs in daisy-chain and clear command counter of AFE driver. More... | |
void | ADI_SpiTransmitReceiveData (ADI_STATE_s *adiState, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength) |
Transmits and receives data on SPI. More... | |
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. More... | |
void | ADI_Wait (uint32_t waitTime) |
wait for a certain number of milliseconds More... | |
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. More... | |
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. More... | |
Headers for the diagnostic driver for the ADI analog front-end.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
Definition in file adi_ades183x_helpers.h.
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.
If the stored and read configuration match, the corresponding flag is set to true in the error table, otherwise it is set to false.
registerSet | configuration register to check |
adiState | state of the driver |
Definition at line 161 of file adi_ades183x_helpers.c.
void ADI_ClearCommandCounter | ( | ADI_STATE_s * | adiState | ) |
Send RSTCC to AFEs in daisy-chain and clear command counter of AFE driver.
adiState | state of the driver |
SM_SPI_CNT: SPI Frame Counter Reset driver stored value of command counter by sending RSTCC command.
Definition at line 547 of file adi_ades183x_helpers.c.
void ADI_CopyCommandBits | ( | const uint16_t * | sourceCommand, |
uint16_t * | destinationCommand | ||
) |
copy command bits in variables.
The commands are defined as const. As some of them have configuration bits, they are first copied in a non-const variable. They can then be configured with ADI_WriteCommandConfigurationBits().
sourceCommand | command definition from command list |
destinationCommand | copied command bits from command definition |
Definition at line 260 of file adi_ades183x_helpers.c.
void ADI_ReadDataBits | ( | uint8_t | receivedData, |
uint8_t * | pDataToRead, | ||
uint8_t | position, | ||
uint8_t | mask | ||
) |
Helper function to read specific bits from received data.
receivedData | data received from the AFEs |
pDataToRead | specific bits read from received data |
position | position where to read the bits in received data |
mask | mask corresponding to bits to read |
Definition at line 268 of file adi_ades183x_helpers.c.
void ADI_ReadRegister | ( | uint16_t * | registerToRead, |
uint8_t * | data, | ||
ADI_STATE_s * | adiState | ||
) |
send command to the ades183x daisy-chain to read a register.
This is the core function to receive data from the ades183x daisy-chain. A 2 byte command is sent with the corresponding PEC. Example: Read configuration register (RDCFG). The data send is: 2 bytes (COMMAND) 2 bytes (PEC) The data received is: 6 bytes (IC1) 2 bytes (PEC) + 6 bytes (IC2) 2 bytes (PEC)
registerToRead | register to be read |
data | read data |
adiState | state of the driver |
SM_SPI_PEC: SPI Packet Error Code Calculate PEC for command.
SM_SPI_PEC: SPI Packet Error Code PEC check on read value.
SM_SPI_CNT: SPI Frame Counter Compare driver stored value of command counter with values sent by the AFEs.
command counter flag stays set as soon as an error was detected it can only be reset within the reset function
Definition at line 284 of file adi_ades183x_helpers.c.
void ADI_SpiTransmitReceiveData | ( | ADI_STATE_s * | adiState, |
uint16_t * | pTxBuff, | ||
uint16_t * | pRxBuff, | ||
uint32_t | frameLength | ||
) |
Transmits and receives data on SPI.
adiState | state of the ADI driver |
pTxBuff | pointer to data that is transmitted by the SPI interface |
pRxBuff | pointer to data that is received by the SPI interface |
frameLength | number of bytes to be transmitted by the SPI interface |
Definition at line 398 of file adi_ades183x_helpers.c.
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.
Does the same as ADI_StoredConfigurationFillRegisterData(), but for all AFEs in the daisy chain.
registerSet | configuration register to address |
registerOffset | position of byte to address in configuration register |
data | data to write to byte in register |
position | position where to store the data in byte |
mask | mask corresponding to data to store |
adiState | state of the driver |
Definition at line 456 of file adi_ades183x_helpers.c.
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 configuration register.
registerSet | configuration register to write |
adiState | state of the driver |
Definition at line 226 of file adi_ades183x_helpers.c.
void ADI_StoredConfigurationWriteToAfeGlobal | ( | ADI_STATE_s * | adiState | ) |
Sends data in the configuration stored in driver to all AFEs in the daisy chain, for all configuration registers.
adiState | state of the driver |
Definition at line 531 of file adi_ades183x_helpers.c.
void ADI_TransmitCommand | ( | uint16_t * | command, |
ADI_STATE_s * | adiState | ||
) |
send command to the ades183x daisy-chain (e.g., start voltage measurement).
command | command to be sent |
adiState | state of the driver |
SM_SPI_PEC: SPI Packet Error Code Calculate PEC for command.
SM_SPI_CNT: SPI Frame Counter Increment driver stored value of command counter if command causes increase.
If command increments AFE command counter, increment driver command counter
Definition at line 480 of file adi_ades183x_helpers.c.
void ADI_Wait | ( | uint32_t | waitTime | ) |
wait for a certain number of milliseconds
This function is used to wait for a definite amount of time. In foxBMS, block task running ades183x. The task cannot be woken up before the time has elapsed.
waitTime | time in ms during which task will be blocked |
Definition at line 563 of file adi_ades183x_helpers.c.
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).
configuredCommand | command in which bits are configured |
position | start bit of configuration field to write |
length | length of configuration field to write |
configuration | configuration to write to the configuration field |
Definition at line 204 of file adi_ades183x_helpers.c.
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.
pSentData | data to send to the AFEs |
dataToWrite | specific bits to write in data to be sent |
position | position where to write the bits in data to send |
mask | mask corresponding to bits to write |
Definition at line 572 of file adi_ades183x_helpers.c.
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.
This is the core function to transmit data to the ades183x daisy-chain. The data sent is: COMMAND + 6 bytes (IC1) + 6 bytes (IC2)
registerToWrite | register to write |
data | data to write in register |
adiState | state of the driver |
pecFaultInjection | used for diagnostics to inject faults in PEC |
SM_SPI_PEC: SPI Packet Error Code Calculate PEC for command.
SM_SPI_PEC: SPI Packet Error Code Calculate PEC for values to be sent to the daisy-chain.
SM_SPI_CNT: SPI Frame Counter Increment driver stored value of command counter if command causes increase.
Definition at line 588 of file adi_ades183x_helpers.c.
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.
registerToWrite | register to write |
data | data to write in register |
pecFaultInjection | used for diagnostics to inject faults in PEC |
adiState | state of the driver |
Definition at line 513 of file adi_ades183x_helpers.c.