Hardware Abstraction Layer for FreeRTOS
ltc6811.h File Reference
#include <hal.h>
#include <i2c.h>
#include <adc.h>
#include <spi.h>
Include dependency graph for ltc6811.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LTC_CMD_WRCFGA   (0x1)
 
#define LTC_CMD_WRCFGA_0_GPIO_PULLUP(gpio)   ((1 << gpio) << 3)
 
#define LTC_CMD_WRCFGA_0_REFON   BIT(2)
 
#define LTC_CMD_WRCFGA_0_DTEN   BIT(1)
 
#define LTC_CMD_WRCFGA_0_ADCOPT   BIT(0)
 
#define LTC_CMD_WRCFGA_4_DCC(x)   BIT(x)
 
#define LTC_CMD_WRCFGA_5_DCTO(DCTO)   (DCTO << 4)
 
#define LTC_CMD_RDCFGA   (0x2)
 
#define LTC_CMD_RDCVA   (0x4)
 
#define LTC_CMD_RDCVB   (0x6)
 
#define LTC_CMD_RDCVC   (0x8)
 
#define LTC_CMD_RDCVD   (0xA)
 
#define LTC_CMD_RDAUXA   (0xC)
 
#define LTC_CMD_RDAUXB   (0xE)
 
#define LTC_CMD_RDSTATA   (0x10)
 
#define LTC_CMD_RDSTATB   (0x12)
 
#define LTC_CMD_WRSCTRL   (0x14)
 
#define LTC_CMD_WRPWM   (0x20)
 
#define LTC_CMD_RDSCTRL   (0x16)
 
#define LTC_CMD_RDPWM   (0x22)
 
#define LTC_CMD_STSCTRL   (0x19)
 
#define LTC_CMD_CLRSCTRL   (0x18)
 
#define LTC_CMD_ADCV(CH, DCP, MD)   (BIT(5) | BIT(6) | BIT(9) | (((CH) & 0x7) << 0) | (((DCP) & 0x1) << 4) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADCV_NORM_DCP_ALL   (0x370)
 
#define LTC_CMD_ADOW(CH, DCP, PUP, MD)   (BIT(3) | BIT(5) | BIT(9) | (((CH) & 0x7) << 0) |(((PUP) & 0x1) << 6) ((DCP & 0x1) << 4) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADOW_NORM_PUP_ALL   (0x378)
 
#define LTC_CMD_ADOW_NORM_PDN_ALL   (0x338)
 
#define LTC_CMD_CVST(ST, MD)   (BIT(0) | BIT(1) | BIT(2) | BIT(9) | (((ST) & 0x3) << 5) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_CVST_NORM_ST1   (0x327)
 
#define LTC_CMD_ADOL(DCP, MD)   (BIT(0) | BIT(9) | (((DCP) & 0x1) << 4) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADOL_NORM_DCP   (0x311)
 
#define LTC_CMD_ADAX(CHG, MD)   (BIT(5) | BIT(6) | BIT(10) | (((CHG) & 0x7) << 0) | (((MD & 0x3) << 7)))
 
#define LTC_CMD_ADAX_NORM_GPIO1   (0x561)
 
#define LTC_CMD_ADAX_NORM_GPIO2   (0x562)
 
#define LTC_CMD_ADAXD(CHG, MD)   (BIT(10) | (((CHG) & 0x7) << 0) | (((MD & 0x3) << 7)))
 
#define LTC_CMD_ADAXD_NORM_GPIO1   (0x501)
 
#define LTC_CMD_ADAXD_NORM_GPIO2   (0x502)
 
#define LTC_CMD_AXST(ST, MD)   (BIT(0) | BIT(1) | BIT(2) | BIT(10) | (((ST) & 0x3) << 5) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_AXST_NORM_ST1   (0x527)
 
#define LTC_CMD_ADSTAT(CHST, MD)   (BIT(3) | BIT(5) | BIT(6) | BIT(10) | (((CHST) & 0x7) << 0) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADSTAT_NORM_ALL   (0x568)
 
#define LTC_CMD_ADSTATD(CHST, MD)   (BIT(3) | BIT(10) | (((CHST) & 0x7) << 0) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADSTATD_NORM_ALL   (0x508)
 
#define LTC_CMD_STATST(ST, MD)   (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(10) | (((ST) & 0x3) << 5) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_STATST_NORM_ST1   (0x52F)
 
#define LTC_CMD_ADCVAX(DCP, MD)   (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(6) | BIT(10) | (((DCP) & 0x1) << 4) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADCVAX_NORM_DCP   (0x57F)
 
#define LTC_CMD_ADCVSC(DCP, MD)   (BIT(0) | BIT(1) | BIT(2) | BIT(6) | BIT(10) | (((DCP) & 0x1) << 4) | (((MD) & 0x3) << 7))
 
#define LTC_CMD_ADCVSC_NORM_DCP   (0x577)
 
#define LTC_CMD_CLRCELL   (0x711)
 
#define LTC_CMD_CLRAUX   (0x712)
 
#define LTC_CMD_CLRSTAT   (0x713)
 
#define LTC_CMD_PLADC   (0x714)
 
#define LTC_CMD_DIAGN   (0x715)
 
#define LTC_CMD_WRCOMM   (0x721)
 
#define LTC_CMD_RDCOMM   (0x722)
 
#define LTC_CMD_STCOMM   (0x723)
 
#define LTC6811_ADDDEV(id, numberofslave, _cellUnderVoltage, _cellOverVoltage)
 
#define LTC6811_SLAVE_ADDDEV(masterid, id)
 
#define LTC6811_ID(id)   HAL_GET_ID(hal, ltc6811, ltc6811_dev_##id)
 
#define LTC6811_SLAVE_ID(masterid, id)   HAL_GET_ID(hal, ltc6811, ltc6811_slave_##masterid##_##id)
 
#define LTC6811_ADC_ID(masterid, id, adcid)   HAL_GET_ID(adc, ltc6811, ltc6811_adc_##masterid##_##id##_##adcid)
 
#define LTC6811_GET_ALL_ADCS(masterid, id, adcs)
 

Typedefs

typedef int16_t ltc_cmd_t
 

Functions

struct ltc6811 * ltc6811_init (uint32_t index)
 
struct ltc6811_slave * ltc6811_slave_init (uint32_t index)
 
int32_t ltc6811_connect (struct ltc6811 *ltc, struct spi *spi, uint8_t cs, uint16_t gpio, uint32_t baudrate)
 
int32_t ltc6811_write (struct ltc6811 *ltc, ltc_cmd_t cmd, uint8_t *data, uint32_t len)
 
int32_t ltc6811_read (struct ltc6811 *ltc, ltc_cmd_t cmd, uint8_t *data, uint32_t len)
 
uint16_t ltc6811_calcPEC (uint8_t *data, uint8_t len)
 
int32_t ltc6811_writeRegister (struct ltc6811 *ltc, ltc_cmd_t cmd, uint8_t *newData, uint8_t *oldData)
 
int32_t ltc6811_readRegister (struct ltc6811 *ltc, ltc_cmd_t cmd, uint8_t *registerContent)
 
int32_t ltc6811_setADCCallback (struct ltc6811 *ltc, bool(*callback)(struct ltc6811 *ltc, void *data), void *data)
 
int32_t ltc6811_startADC (struct ltc6811 *ltc)
 
int32_t ltc6811_stopADC (struct ltc6811 *ltc)