...
Responsible for interfacing with all daisy-chained LTC LTC8611 chips, and create aux and cell conversionsconversion
LTC AFE Driver FSM Structure:
States:
LTC_AFE_IDLE
Initial state, waits for a conversion to be initiated (may or may not need)
Input function:
receives signal to transition to trigger cell conversions
LTC_AFE_TRIGGER_CELL_CONV
Trigger conversion of voltage values
Output:
Send command to start conversion of cell voltage values
Input func:
Check to see if 10ms has passed
Transition to read cells
LTC_AFE_READ_CELLS
Output function:
SPI exchange to read/store cell values, take any immediate action
Input function transitions to aux conversion assuming no faults
LTC_AFE_TRIGGER_AUX_CONV
Output:
Send command to start read temperature values of a cell (we should maybe change to set of cells)
Input
Transition to read aux if 6 ms have passed
LTC_AFE_READ_AUX
Output:
Read current cell, increment cell number
Input
if cell number == number of cells, aux is done reading → transition to complete
else transition back to trigger aux conversion for next conversion
LTC_AUX_COMPLETE
Fault Behaviour:
Just transition to Idle for now. We will signal main BMS if an error occurs
Transitions:
LTC_AFE_IDLE → LTC_AFE_TRIGGER_CELL_CONV, LTC_AFE_IDLE → LTC_AFE_TRIGGER_AUX_CONV
We would like to transition from the idle state whenever one of the exposed API functions is called (trigger_read_conv or trigger_aux_conv), and the calling of these functions would trigger a transition to the relevant state.
LTC_AFE_TRIGGER_CELL_CONV → LTC_AFE_READ_CELLS, LTC_AFE_TRIGGER_CELL_CONV → LTC_AFE_IDLE
Once in this state most of the time we would like to trigger a read after a soft timer has run. However, if the trigger_cell_conv operation fails (SPI fails, etc), then we return to the idle state.
LTC_AFE_READ_CELLS → LTC_AFE_IDLE, LTC_AFE_READ_CELLS → LTC_AFE_READ_CELLS
Once in this state, the read operation will be run and data from the AFEs will be returned allowing us to stay if we would like more data or go back to idle to start the process from scratch.
LTC_AFE_TRIGGER_AUX_CONV → LTC_AFE_READ_AUX, LTC_AFE_TRIGGER_AUX_CONV → LTC_AFE_IDLE
Similar to the trigger_cell state.
LTC_AFE_READ_AUX → LTC_AFE_AUX_COMPLETE, LTC_AFE_READ_AUX → LTC_AFE_READ_AUX, LTC_AFE_READ_AUX → LTC_AFE_TRIGGER_AUX_CONV, LTC_AFE_READ_AUX → LTC_AFE_IDLE
Similar to the read_cells state, but here, we can also go back to the trigger or go to the complete state.
LTC_AFE_AUX_COMPLETE → LTC_AFE_IDLE
When complete, we will go to idle and start the FSM from scratch.