Go to the documentation of this file.
40 #define LTC3337_I2C_ADDR 0x64 // b1100100[r/w] 0xC8, 0xC9
42 #define LTC3337_MAX_TEMP_C 159 //Maximum temperature for alarms
43 #define LTC3337_MIN_TEMP_C -41 //Minimum temperature for alarms
44 #define LTC3337_MAX_PRESCALE 15 //Maximum prescaler value
46 #define LTC3337_OVERFLOW_ALARM_MAX 0xFF //Max value for overflow alarm
48 #define LTC3337_REG_A 0x01 //Prescaler Select, IRQ Clear, Shutdown, Alarm Thresh
50 #define LTC3337_RA_PRESCALE_MSK NO_OS_GENMASK(3, 0)
51 #define LTC3337_RA_CLEAR_INT NO_OS_BIT(4)
52 #define LTC3337_RA_CNT_CHK NO_OS_BIT(5)
53 #define LTC3337_RA_SHTDN NO_OS_BIT(6)
54 #define LTC3337_RA_ADC_CONV NO_OS_BIT(7)
55 #define LTC3337_RA_ALARM_LVL_MSK NO_OS_GENMASK(15, 8)
57 #define LTC3337_REG_B 0x02 //Accumulated Charge
59 #define LTC3337_REG_C 0x03 //Status, Temperature
61 #define LTC3337_RC_OVERFLOW NO_OS_BIT(0)
62 #define LTC3337_RC_ALARM_TRIP NO_OS_BIT(1)
63 #define LTC3337_RC_ALARM_MIN NO_OS_BIT(2)
64 #define LTC3337_RC_ALARM_MAX NO_OS_BIT(3)
65 #define LTC3337_RC_ADC_READY NO_OS_BIT(4)
66 #define LTC3337_RC_IPK_PIN_MSK NO_OS_GENMASK(7, 5)
67 #define LTC3337_RC_DIE_TEMP_MSK NO_OS_GENMASK(15, 8)
69 #define LTC3337_REG_D 0x04 //BAT_IN V, Ipeak On
70 #define LTC3337_REG_E 0x05 //BAT_IN V, Ipeak Off
71 #define LTC3337_REG_F 0x06 //BAT_OUT V, Ipeak On
72 #define LTC3337_REG_G 0x07 //BAT_OUT V, Ipeak Off
73 #define LTC3337_BATV_MSK NO_OS_GENMASK(11, 0)
75 #define LTC3337_REG_H 0x08 //Temp Alarm Config
76 #define LTC3337_RH_HOT_ALARM_MSK NO_OS_GENMASK(15, 8)
77 #define LTC3337_RH_COLD_ALARM_MSK NO_OS_GENMASK(7, 0)
79 #define LTC3337_VLSB_UV 1465 //1.465 mV = 1465 uV
80 #define LTC3337_TLSB_MC 784 //0.784 Deg C = 784 mC
81 #define LTC3337_TEMP_MIN_C -41
83 #define LTC3337_NUM_IPEAKS 8 //3-bit iPeak Input
86 #define LTC3337_NANO_AMP 1000000000
87 #define LTC3337_CALC_SCALE 10000
88 #define LTC3337_CALC_TO_WHOLE (LTC3337_NANO_AMP / LTC3337_CALC_SCALE)
91 #define LTC3337_UV_TO_MV_SCALE 1000
94 #define LTC3337_MC_TO_C_SCALE 1000
161 uint16_t* raw_value);
179 uint16_t* reg_value);
int ltc3337_get_and_clear_interrupts(struct ltc3337_dev *dev, uint16_t *int_field, int16_t *temp_c)
Definition: ltc3337.c:441
int ltc3337_set_prescaler(struct ltc3337_dev *dev, uint8_t prescale)
Definition: ltc3337.c:271
#define LTC3337_RA_ALARM_LVL_MSK
Definition: ltc3337.h:55
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
ltc3337_voltage_src_t
Definition: ltc3337.h:126
int ltc3337_init(struct ltc3337_dev **device, struct ltc3337_init_param *init_param)
Definition: ltc3337.c:86
uint32_t qlsb_na_hr
Definition: ltc3337.c:45
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
#define LTC3337_NANO_AMP
Definition: ltc3337.h:86
#define LTC3337_BATV_MSK
Definition: ltc3337.h:73
int ltc3337_get_temperature_c(struct ltc3337_dev *dev, int16_t *value)
Definition: ltc3337.c:199
int ltc3337_set_temperature_alarms_c(struct ltc3337_dev *dev, int16_t hot_alarm, int16_t cold_alarm)
Definition: ltc3337.c:299
#define LTC3337_REG_B
Definition: ltc3337.h:57
uint8_t ipeak_latched
Definition: ltc3337.h:103
int ltc3337_set_counter_alarm(struct ltc3337_dev *dev, uint16_t reg_value, uint8_t round_up)
Definition: ltc3337.c:363
#define LTC3337_NUM_IPEAKS
Definition: ltc3337.h:83
@ BAT_OUT_IPEAK_OFF
Definition: ltc3337.h:130
#define LTC3337_RH_COLD_ALARM_MSK
Definition: ltc3337.h:77
#define LTC3337_REG_H
Definition: ltc3337.h:75
#define LTC3337_REG_E
Definition: ltc3337.h:70
#define LTC3337_REG_G
Definition: ltc3337.h:72
Definition: ad9361_util.h:69
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
#define LTC3337_RC_IPK_PIN_MSK
Definition: ltc3337.h:66
int ltc3337_init(struct ltc3337_dev **dev, struct ltc3337_init_param *init_param)
Definition: ltc3337.c:86
#define LTC3337_OVERFLOW_ALARM_MAX
Definition: ltc3337.h:46
int ltc3337_set_counter_shutdown(struct ltc3337_dev *dev, uint8_t shutdown_en)
Definition: ltc3337.c:327
#define LTC3337_REG_C
Definition: ltc3337.h:59
#define LTC3337_VLSB_UV
Definition: ltc3337.h:79
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
Definition: ltc3337.h:110
#define LTC3337_UV_TO_MV_SCALE
Definition: ltc3337.h:91
#define LTC3337_MC_TO_C_SCALE
Definition: ltc3337.h:94
Definition: ltc3337.h:101
int ltc3337_set_accumulated_charge(struct ltc3337_dev *dev, uint16_t reg_value, uint8_t round_up)
Definition: ltc3337.c:407
int ltc3337_get_accumulated_charge(struct ltc3337_dev *dev, struct charge_count_t *value, uint16_t *raw_value)
Definition: ltc3337.c:227
int ltc3337_set_counter_alarm(struct ltc3337_dev *dev, uint16_t counter_reg_val, uint8_t round_up)
Definition: ltc3337.c:363
#define LTC3337_REG_A
Definition: ltc3337.h:48
#define LTC3337_TLSB_MC
Definition: ltc3337.h:80
struct no_os_i2c_desc * i2c_desc
Definition: ltc3337.h:102
#define LTC3337_MAX_TEMP_C
Definition: ltc3337.h:42
int ltc3337_set_counter_shutdown(struct ltc3337_dev *dev, uint8_t shutdown_en)
Definition: ltc3337.c:327
#define LTC3337_RC_DIE_TEMP_MSK
Definition: ltc3337.h:67
Definition: ltc3337.h:118
int ltc3337_set_temperature_alarms_c(struct ltc3337_dev *dev, int16_t hot_alarm, int16_t cold_alarm)
Definition: ltc3337.c:299
@ BAT_IN_IPEAK_OFF
Definition: ltc3337.h:128
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
int ltc3337_get_voltage_mv(struct ltc3337_dev *dev, enum ltc3337_voltage_src_t source, uint32_t *value)
Definition: ltc3337.c:153
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
int ltc3337_set_accumulated_charge(struct ltc3337_dev *dev, uint16_t reg_value, uint8_t round_up)
Definition: ltc3337.c:407
int ltc3337_get_accumulated_charge(struct ltc3337_dev *dev, struct charge_count_t *value, uint16_t *raw_value)
Definition: ltc3337.c:227
int ltc3337_remove(struct ltc3337_dev *dev)
Definition: ltc3337.c:132
Header file of I2C Interface.
#define LTC3337_MIN_TEMP_C
Definition: ltc3337.h:43
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
#define LTC3337_RH_HOT_ALARM_MSK
Definition: ltc3337.h:76
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
uint16_t no_os_get_unaligned_le16(uint8_t *buf)
int ltc3337_calculate_charge_register(struct ltc3337_dev *dev, struct charge_count_t *charge_a, uint16_t *reg_value)
Definition: ltc3337.c:479
@ BAT_OUT_IPEAK_ON
Definition: ltc3337.h:129
uint32_t na_hr
Definition: ltc3337.h:120
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
int ltc3337_get_temperature_c(struct ltc3337_dev *dev, int16_t *value)
Definition: ltc3337.c:199
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
uint32_t a_hr
Definition: ltc3337.h:119
int ltc3337_get_and_clear_interrupts(struct ltc3337_dev *dev, uint16_t *int_field, int16_t *temp_c)
Definition: ltc3337.c:441
#define LTC3337_CALC_SCALE
Definition: ltc3337.h:87
int ltc3337_set_prescaler(struct ltc3337_dev *dev, uint8_t prescale)
Definition: ltc3337.c:271
#define LTC3337_RA_SHTDN
Definition: ltc3337.h:53
struct no_os_i2c_init_param i2c_init
Definition: ltc3337.h:111
Header file for the LTC3337 Driver.
uint8_t ipeak_ma
Definition: ltc3337.c:44
int ltc3337_get_voltage_mv(struct ltc3337_dev *dev, enum ltc3337_voltage_src_t source, uint32_t *value)
Definition: ltc3337.c:153
uint8_t prescale
Definition: ltc3337.h:112
int ltc3337_remove(struct ltc3337_dev *dev)
Definition: ltc3337.c:132
uint16_t latched_reg_a
Definition: ltc3337.h:104
Header file of utility functions.
#define LTC3337_RA_PRESCALE_MSK
Definition: ltc3337.h:50
#define LTC3337_REG_F
Definition: ltc3337.h:71
#define LTC3337_REG_D
Definition: ltc3337.h:69
int ltc3337_calculate_charge_register(struct ltc3337_dev *dev, struct charge_count_t *charge_a, uint16_t *reg_value)
Definition: ltc3337.c:479
@ BAT_IN_IPEAK_ON
Definition: ltc3337.h:127
#define LTC3337_TEMP_MIN_C
Definition: ltc3337.h:81
Error macro definition for ARM Compiler.
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54
#define LTC3337_CALC_TO_WHOLE
Definition: ltc3337.h:88
#define LTC3337_RA_CLEAR_INT
Definition: ltc3337.h:51