152 Serial.begin(115200);
165 if (Serial.available())
169 Serial.println(user_command);
222 Serial.println(
"A PEC error was detected in the received data");
231 Serial.println(
"cell conversion completed");
240 Serial.println(
"A PEC error was detected in the received data");
249 Serial.println(
"aux conversion completed");
258 Serial.println(
"A PEC error was detected in the received data");
264 Serial.println(
"transmit 'm' to quit");
269 if (Serial.available() > 0)
280 Serial.println(
"A PEC error was detected in the received data");
289 Serial.println(
"Incorrect Option");
315 Serial.println(
"Please enter LTC6804 Command");
316 Serial.println(
"Write Configuration: 1");
317 Serial.println(
"Read Configuration: 2");
318 Serial.println(
"Start Cell Voltage Conversion: 3");
319 Serial.println(
"Read Cell Voltages: 4");
320 Serial.println(
"Start Aux Voltage Conversion: 5");
321 Serial.println(
"Read Aux Voltages: 6");
322 Serial.println(
"loop cell voltages: 7");
323 Serial.println(
"Please enter command: ");
336 for (
int current_ic = 0 ; current_ic <
TOTAL_IC; current_ic++)
338 Serial.print(
" IC ");
339 Serial.print(current_ic+1,DEC);
340 for (
int i=0;
i<12;
i++)
343 Serial.print(
i+1,DEC);
359 for (
int current_ic =0 ; current_ic <
TOTAL_IC; current_ic++)
361 Serial.print(
" IC ");
362 Serial.print(current_ic+1,DEC);
363 for (
int i=0;
i < 5;
i++)
365 Serial.print(
" GPIO-");
366 Serial.print(
i+1,DEC);
368 Serial.print(
aux_codes[current_ic][
i]*0.0001,4);
371 Serial.print(
" Vref2");
373 Serial.print(
aux_codes[current_ic][5]*0.0001,4);
386 Serial.println(
"Written Configuration: ");
387 for (
int current_ic = 0; current_ic<
TOTAL_IC; current_ic++)
389 Serial.print(
" IC ");
390 Serial.print(current_ic+1,DEC);
394 Serial.print(
", 0x");
396 Serial.print(
", 0x");
398 Serial.print(
", 0x");
400 Serial.print(
", 0x");
402 Serial.print(
", 0x");
404 Serial.print(
", Calculated PEC: 0x");
407 Serial.print(
", 0x");
420 Serial.println(
"Received Configuration ");
421 for (
int current_ic=0; current_ic<
TOTAL_IC; current_ic++)
423 Serial.print(
" IC ");
424 Serial.print(current_ic+1,DEC);
425 Serial.print(
": 0x");
427 Serial.print(
", 0x");
429 Serial.print(
", 0x");
431 Serial.print(
", 0x");
433 Serial.print(
", 0x");
435 Serial.print(
", 0x");
437 Serial.print(
", Received PEC: 0x");
439 Serial.print(
", 0x");
451 Serial.print((byte)data,HEX);
454 Serial.print((byte)data,HEX);
int8_t LTC6804_rdcfg(uint8_t total_ic, uint8_t r_config[][8])
static void run_command(uint16_t cmd)
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()
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.
Header File for Linduino Libraries and Demo Code.
static void print_rxconfig()
void LTC6804_initialize()
This function will initialize all 6804 variables and the SPI port.
static void serial_print_hex(uint8_t data)
union LT_union_int32_4bytes data
#define input(pin)
Return the state of pin "pin".
LTC6804-2 Multicell Battery Monitor.
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 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 ...
uint16_t pec15_calc(uint8_t len, uint8_t *data)
const uint8_t TOTAL_IC
number of ICs in the isoSPI network LTC6804-2 ICs must be addressed in ascending order starting at 0...
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void print_config()
static uint16_t cell_codes[TOTAL_IC][12]
The cell codes will be stored in the cell_codes[][12] array in the following format: ...
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.