153 Serial.begin(115200);
166 if (Serial.available())
170 Serial.println(user_command);
223 Serial.println(
"A PEC error was detected in the received data");
232 Serial.println(
"cell conversion completed");
241 Serial.println(
"A PEC error was detected in the received data");
250 Serial.println(
"aux conversion completed");
259 Serial.println(
"A PEC error was detected in the received data");
265 Serial.println(
"transmit 'm' to quit");
270 if (Serial.available() > 0)
281 Serial.println(
"A PEC error was detected in the received data");
290 Serial.println(
"Incorrect Option");
317 Serial.println(
"Please enter LTC6804 Command");
318 Serial.println(
"Write Configuration: 1");
319 Serial.println(
"Read Configuration: 2");
320 Serial.println(
"Start Cell Voltage Conversion: 3");
321 Serial.println(
"Read Cell Voltages: 4");
322 Serial.println(
"Start Aux Voltage Conversion: 5");
323 Serial.println(
"Read Aux Voltages: 6");
324 Serial.println(
"loop cell voltages: 7");
325 Serial.println(
"Please enter command: ");
338 for (
int current_ic = 0 ; current_ic <
TOTAL_IC; current_ic++)
340 Serial.print(
" IC ");
341 Serial.print(current_ic+1,DEC);
342 for (
int i=0;
i<12;
i++)
345 Serial.print(
i+1,DEC);
361 for (
int current_ic =0 ; current_ic <
TOTAL_IC; current_ic++)
363 Serial.print(
" IC ");
364 Serial.print(current_ic+1,DEC);
365 for (
int i=0;
i < 5;
i++)
367 Serial.print(
" GPIO-");
368 Serial.print(
i+1,DEC);
370 Serial.print(
aux_codes[current_ic][
i]*0.0001,4);
373 Serial.print(
" Vref2");
375 Serial.print(
aux_codes[current_ic][5]*0.0001,4);
388 Serial.println(
"Written Configuration: ");
389 for (
int current_ic = 0; current_ic<
TOTAL_IC; current_ic++)
391 Serial.print(
" IC ");
392 Serial.print(current_ic+1,DEC);
396 Serial.print(
", 0x");
398 Serial.print(
", 0x");
400 Serial.print(
", 0x");
402 Serial.print(
", 0x");
404 Serial.print(
", 0x");
406 Serial.print(
", Calculated PEC: 0x");
409 Serial.print(
", 0x");
422 Serial.println(
"Received Configuration ");
423 for (
int current_ic=0; current_ic<
TOTAL_IC; current_ic++)
425 Serial.print(
" IC ");
426 Serial.print(current_ic+1,DEC);
427 Serial.print(
": 0x");
429 Serial.print(
", 0x");
431 Serial.print(
", 0x");
433 Serial.print(
", 0x");
435 Serial.print(
", 0x");
437 Serial.print(
", 0x");
439 Serial.print(
", Received PEC: 0x");
441 Serial.print(
", 0x");
453 Serial.print((byte)data,HEX);
456 Serial.print((byte)data,HEX);
int8_t LTC6804_rdcfg(uint8_t total_ic, uint8_t r_config[][8])
static uint8_t tx_cfg[TOTAL_IC][6]
The tx_cfg[][6] stores the LTC6804 configuration data that is going to be written to the LTC6804 ICs ...
static void print_rxconfig()
int8_t LTC6804_rdaux(uint8_t reg, uint8_t total_ic, uint16_t aux_codes[][6])
Reads and parses the LTC6804 auxiliary registers.
unsigned char user_command
static void print_cells()
Header File for Linduino Libraries and Demo Code.
void LTC6804_initialize()
This function will initialize all 6804 variables and the SPI port.
union LT_union_int32_4bytes data
static void print_config()
#define input(pin)
Return the state of pin "pin".
uint16_t pec15_calc(uint8_t len, uint8_t *data)
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
const uint8_t TOTAL_IC
number of ICs in the daisy chain
static uint16_t aux_codes[TOTAL_IC][6]
The GPIO codes will be stored in the aux_codes[][6] array in the following format: ...
static void run_command(uint32_t cmd)
static uint16_t cell_codes[TOTAL_IC][12]
The cell codes will be stored in the cell_codes[][12] array in the following format: ...
LTC6804-1 Multicell Battery Monitor.
uint8_t LTC6804_rdcv(uint8_t reg, uint8_t total_ic, uint16_t cell_codes[][12])
Reads and parses the LTC6804 cell voltage registers.
void LTC6804_wrcfg(uint8_t total_ic, uint8_t config[][6])
Write the LTC6804 configuration register.
static void serial_print_hex(uint8_t data)
static uint8_t rx_cfg[TOTAL_IC][8]
the rx_cfg[][8] array stores the data that is read back from a LTC6804-1 daisy chain.