Go to the documentation of this file.
43 #define LTC2992_REG_CTRLA 0x00
44 #define LTC2992_REG_CTRLB 0x01
45 #define LTC2992_REG_ALERT1 0x02
46 #define LTC2992_REG_FAULT1 0x03
47 #define LTC2992_REG_NADC 0x04
48 #define LTC2992_REG_POWER1 0x05
49 #define LTC2992_REG_POWER1_MAX 0x08
50 #define LTC2992_REG_POWER1_MIN 0x0B
51 #define LTC2992_REG_POWER1_MAX_THRESH 0x0E
52 #define LTC2992_REG_POWER1_MIN_THRESH 0x11
53 #define LTC2992_REG_DSENSE1 0x14
54 #define LTC2992_REG_DSENSE1_MAX 0x16
55 #define LTC2992_REG_DSENSE1_MIN 0x18
56 #define LTC2992_REG_DSENSE1_MAX_THRESH 0x1A
57 #define LTC2992_REG_DSENSE1_MIN_THRESH 0x1C
58 #define LTC2992_REG_SENSE1 0x1E
59 #define LTC2992_REG_SENSE1_MAX 0x20
60 #define LTC2992_REG_SENSE1_MIN 0x22
61 #define LTC2992_REG_SENSE1_MAX_THRESH 0x24
62 #define LTC2992_REG_SENSE1_MIN_THRESH 0x26
63 #define LTC2992_REG_G1 0x28
64 #define LTC2992_REG_G1_MAX 0x2A
65 #define LTC2992_REG_G1_MIN 0x2C
66 #define LTC2992_REG_G1_MAX_THRESH 0x2E
67 #define LTC2992_REG_G1_MIN_THRESH 0x30
68 #define LTC2992_REG_ALERT2 0x34
69 #define LTC2992_REG_FAULT2 0x35
70 #define LTC2992_REG_G2 0x5A
71 #define LTC2992_REG_G2_MAX 0x5C
72 #define LTC2992_REG_G2_MIN 0x5E
73 #define LTC2992_REG_G2_MAX_THRESH 0x60
74 #define LTC2992_REG_G2_MIN_THRESH 0x62
75 #define LTC2992_REG_G3 0x64
76 #define LTC2992_REG_G3_MAX 0x66
77 #define LTC2992_REG_G3_MIN 0x68
78 #define LTC2992_REG_G3_MAX_THRESH 0x6A
79 #define LTC2992_REG_G3_MIN_THRESH 0x6C
80 #define LTC2992_REG_G4 0x6E
81 #define LTC2992_REG_G4_MAX 0x70
82 #define LTC2992_REG_G4_MIN 0x72
83 #define LTC2992_REG_G4_MAX_THRESH 0x74
84 #define LTC2992_REG_G4_MIN_THRESH 0x76
85 #define LTC2992_REG_ISUM 0x78
86 #define LTC2992_REG_ISUM_MAX 0x7A
87 #define LTC2992_REG_ISUM_MIN 0x7C
88 #define LTC2992_REG_ISUM_MAX_THRESH 0x7E
89 #define LTC2992_REG_ISUM_MIN_THRESH 0x80
90 #define LTC2992_REG_PSUM 0x82
91 #define LTC2992_REG_PSUM_MAX 0x85
92 #define LTC2992_REG_PSUM_MIN 0x88
93 #define LTC2992_REG_PSUM_MAX_THRESH 0x8B
94 #define LTC2992_REG_PSUM_MIN_THRESH 0x8E
95 #define LTC2992_REG_ALERT3 0x91
96 #define LTC2992_REG_FAULT3 0x92
97 #define LTC2992_REG_GPIO_STATUS 0x95
98 #define LTC2992_REG_GPIO_IO_CTRL 0x96
99 #define LTC2992_REG_GPIO4_CTRL 0x97
100 #define LTC2992_REG_MFR_SPECIAL_ID 0xE7
102 #define LTC2992_REG_POWER(x) (LTC2992_REG_POWER1 + ((x) * 0x32))
103 #define LTC2992_REG_POWER_MAX(x) (LTC2992_REG_POWER1_MAX + ((x) * 0x32))
104 #define LTC2992_REG_POWER_MIN(x) (LTC2992_REG_POWER1_MIN + ((x) * 0x32))
105 #define LTC2992_REG_POWER_MAX_THRESH(x) (LTC2992_REG_POWER1_MAX_THRESH + ((x) * 0x32))
106 #define LTC2992_REG_POWER_MIN_THRESH(x) (LTC2992_REG_POWER1_MIN_THRESH + ((x) * 0x32))
107 #define LTC2992_REG_DSENSE(x) (LTC2992_REG_DSENSE1 + ((x) * 0x32))
108 #define LTC2992_REG_DSENSE_MAX(x) (LTC2992_REG_DSENSE1_MAX + ((x) * 0x32))
109 #define LTC2992_REG_DSENSE_MIN(x) (LTC2992_REG_DSENSE1_MIN + ((x) * 0x32))
110 #define LTC2992_REG_DSENSE_MAX_THRESH(x) (LTC2992_REG_DSENSE1_MAX_THRESH + ((x) * 0x32))
111 #define LTC2992_REG_DSENSE_MIN_THRESH(x) (LTC2992_REG_DSENSE1_MIN_THRESH + ((x) * 0x32))
112 #define LTC2992_REG_SENSE(x) (LTC2992_REG_SENSE1 + ((x) * 0x32))
113 #define LTC2992_REG_SENSE_MAX(x) (LTC2992_REG_SENSE1_MAX + ((x) * 0x32))
114 #define LTC2992_REG_SENSE_MIN(x) (LTC2992_REG_SENSE1_MIN + ((x) * 0x32))
115 #define LTC2992_REG_SENSE_MAX_THRESH(x) (LTC2992_REG_SENSE1_MAX_THRESH + ((x) * 0x32))
116 #define LTC2992_REG_SENSE_MIN_THRESH(x) (LTC2992_REG_SENSE1_MIN_THRESH + ((x) * 0x32))
117 #define LTC2992_REG_POWER_FAULT(x) (LTC2992_REG_FAULT1 + ((x) * 0x32))
118 #define LTC2992_REG_SENSE_FAULT(x) (LTC2992_REG_FAULT1 + ((x) * 0x32))
119 #define LTC2992_REG_DSENSE_FAULT(x) (LTC2992_REG_FAULT1 + ((x) * 0x32))
121 #define LTC2992_OFFSET_CAL_MSK NO_OS_BIT(7)
122 #define LTC2992_MEASURE_MODE_MSK NO_OS_GENMASK(6,5)
123 #define LTC2992_VSEL_CON_MSK NO_OS_GENMASK(4,3)
124 #define LTC2992_VSEL_SNAP_MSK NO_OS_GENMASK(2,0)
125 #define LTC2992_POWER_ALERT_MSK NO_OS_GENMASK(7,6)
126 #define LTC2992_DSENSE_ALERT_MSK NO_OS_GENMASK(5,4)
127 #define LTC2992_SENSE_ALERT_MSK NO_OS_GENMASK(3,2)
128 #define LTC2992_ISUM_ALERT_MSK NO_OS_GENMASK(3,2)
129 #define LTC2992_PSUM_ALERT_MSK NO_OS_GENMASK(1,0)
130 #define LTC2992_POWER_FAULT_MSK NO_OS_GENMASK(7,6)
131 #define LTC2992_DSENSE_FAULT_MSK NO_OS_GENMASK(5,4)
132 #define LTC2992_SENSE_FAULT_MSK NO_OS_GENMASK(3,2)
133 #define LTC2992_ISUM_FAULT_MSK NO_OS_GENMASK(3,2)
134 #define LTC2992_PSUM_FAULT_MSK NO_OS_GENMASK(1,0)
135 #define LTC2992_12B_SENSE_VAL_MSK NO_OS_GENMASK(15,4)
136 #define LTC2992_12B_POWER_VAL_MSK NO_OS_GENMASK(23,0)
137 #define LTC2992_8B_SENSE_VAL_MSK NO_OS_GENMASK(15,8)
138 #define LTC2992_8B_POWER_VAL_MSK NO_OS_GENMASK(23,8)
140 #define LTC2992_G1_FAULT_ALERT_MSK 0x03
141 #define LTC2992_G2_FAULT_ALERT_MSK 0x03
142 #define LTC2992_G3_FAULT_ALERT_MSK 0xC0
143 #define LTC2992_G4_FAULT_ALERT_MSK 0x30
145 #define LTC2992_ALERT_CLR_BIT NO_OS_BIT(7)
146 #define LTC2992_READ_CTRL_BIT NO_OS_BIT(5)
147 #define LTC2992_STUCK_BUS_TIMEOUT_BIT NO_OS_BIT(4)
148 #define LTC2992_PEAK_RST_BIT NO_OS_BIT(3)
149 #define LTC2992_RESET_BIT NO_OS_BIT(0)
150 #define LTC2992_G4_ALERT_PIN_BIT NO_OS_BIT(7)
151 #define LTC2992_G1_CTRL_BIT NO_OS_BIT(7)
152 #define LTC2992_G2_CTRL_BIT NO_OS_BIT(6)
153 #define LTC2992_G3_CTRL_BIT NO_OS_BIT(0)
154 #define LTC2992_G4_CTRL_BIT NO_OS_BIT(6)
156 #define LTC2992_MFR_ID_VALUE 0x62
157 #define LTC2992_RESOLUTION_POS 7
296 uint32_t *data, uint8_t num_bytes);
300 uint32_t value, uint8_t num_bytes);
304 uint8_t mask, uint8_t val);
309 uint32_t *voltage_data);
314 uint32_t *vshunt_data);
319 uint32_t *current_data);
324 uint32_t *power_data);
353 uint32_t thresh_value);
358 uint32_t thresh_value);
380 uint32_t *gpio_data);
385 uint32_t *gpio_data);
390 uint32_t *gpio_data);
395 uint32_t thresh_value);
400 uint32_t thresh_value);
#define LTC2992_REG_G4_MIN
Definition: ltc2992.h:82
#define LTC2992_REG_DSENSE(x)
Definition: ltc2992.h:107
@ LTC2992_MODE_SHUTDOWN
Definition: ltc2992.h:204
#define LTC2992_VSEL_CON_MSK
Definition: ltc2992.h:123
#define LTC2992_VSEL_SNAP_MSK
Definition: ltc2992.h:124
int ltc2992_set_gpio_min_thresh(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t thresh_value)
Set lower threshold level in a GPIO.
Definition: ltc2992.c:1266
#define LTC2992_G3_CTRL_BIT
Definition: ltc2992.h:153
#define MILLI
Definition: no_os_units.h:48
void no_os_put_unaligned_be16(uint16_t val, uint8_t *buf)
void no_os_put_unaligned_be24(uint32_t val, uint8_t *buf)
@ LTC2992_CALIBRATE_ON_DEMAND
Definition: ltc2992.h:197
uint8_t alert
Definition: ltc2992.h:251
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
int ltc2992_set_min_thresh(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t thresh_value)
Set lower thresh level for alert at a SENSE channel.
Definition: ltc2992.c:892
#define LTC2992_REG_FAULT3
Definition: ltc2992.h:96
int ltc2992_init(struct ltc2992_dev **device, struct ltc2992_init_param *init_param)
Initialize communication peripheral for the device.
Definition: ltc2992.c:179
#define LTC2992_REG_G3_MAX_THRESH
Definition: ltc2992.h:78
ltc2992_fault_status
Definition: ltc2992.h:237
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
@ LTC2992_MODE_SINGLE_CYCLE
Definition: ltc2992.h:203
#define LTC2992_12B_POWER_VAL_MSK
Definition: ltc2992.h:136
#define dev_err(dev, format,...)
Definition: ad9361_util.h:63
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
#define LTC2992_REG_ISUM_MIN_THRESH
Definition: ltc2992.h:89
#define LTC2992_REG_FAULT2
Definition: ltc2992.h:69
#define LTC2992_REG_NADC
Definition: ltc2992.h:47
#define LTC2992_REG_ISUM_MAX
Definition: ltc2992.h:86
int ltc2992_get_power(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *power_data)
Read bus power output in a sense channel.
Definition: ltc2992.c:621
struct no_os_gpio_desc * alert_gpio_desc
Definition: ltc2992.h:259
@ LTC2992_GPIO1
Definition: ltc2992.h:170
#define LTC2992_READ_CTRL_BIT
Definition: ltc2992.h:146
#define LTC2992_G1_CTRL_BIT
Definition: ltc2992.h:151
#define LTC2992_REG_GPIO4_CTRL
Definition: ltc2992.h:99
#define LTC2992_OFFSET_CAL_MSK
Definition: ltc2992.h:121
#define LTC2992_REG_ISUM_MAX_THRESH
Definition: ltc2992.h:88
int ltc2992_get_sum(struct ltc2992_dev *dev, enum ltc2992_channel chan, uint32_t *sum_data)
Read the shunt voltage sum or power sum of both sense channels.
Definition: ltc2992.c:638
@ LTC2992_FAULT_OVERVALUE
Definition: ltc2992.h:240
int ltc2992_get_gpio_fault(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_fault_status *fault)
Get GPIO fault status.
Definition: ltc2992.c:1315
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 LTC2992_REG_POWER_MIN(x)
Definition: ltc2992.h:104
ltc2992_gpio
Definition: ltc2992.h:169
#define LTC2992_REG_G2_MAX
Definition: ltc2992.h:71
#define LTC2992_REG_MFR_SPECIAL_ID
Definition: ltc2992.h:100
int ltc2992_get_vshunt(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *vshunt_data)
Read shunt voltage in a sense channel.
Definition: ltc2992.c:579
int ltc2992_get_max_data(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t *data)
Read maximum sense data at a SENSE channel.
Definition: ltc2992.c:720
@ LTC2992_CONT_VSEL_GPIOS_ONLY
Definition: ltc2992.h:211
#define LTC2992_REG_G2
Definition: ltc2992.h:70
enum ltc2992_continuous_vsel continuous_vsel
Definition: ltc2992.h:270
#define LTC2992_REG_G1_MAX_THRESH
Definition: ltc2992.h:66
#define LTC2992_REG_DSENSE_MAX(x)
Definition: ltc2992.h:108
@ LTC2992_FAULT_ALL
Definition: ltc2992.h:241
@ LTC2992_RESOLUTION_12_BIT
Definition: ltc2992.h:226
@ LTC2992_SNAP_VSEL_SENSE1
Definition: ltc2992.h:215
ltc2992_channel
Definition: ltc2992.h:186
int ltc2992_get_gpio_fault(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_fault_status *fault)
Get GPIO fault status.
Definition: ltc2992.c:1315
int ltc2992_get_sense_data(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t *data)
Read sense data at a SENSE channel.
Definition: ltc2992.c:682
struct no_os_i2c_desc * i2c_desc
Definition: ltc2992.h:258
@ LTC2992_SNAP_VSEL_GPIO3
Definition: ltc2992.h:219
uint32_t shunt_resistor
Definition: ltc2992.h:272
#define LTC2992_REG_POWER(x)
Definition: ltc2992.h:102
enum ltc2992_measure_mode measure_mode
Definition: ltc2992.h:269
Definition: ad9361_util.h:69
#define LTC2992_REG_G1_MIN_THRESH
Definition: ltc2992.h:67
int ltc2992_write_reg(struct ltc2992_dev *dev, uint8_t addr, uint32_t value, uint8_t num_bytes)
Write raw data to device register.
Definition: ltc2992.c:332
#define LTC2992_REG_G1_MIN
Definition: ltc2992.h:65
#define LTC2992_REG_SENSE(x)
Definition: ltc2992.h:112
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 LTC2992_12B_SENSE_VAL_MSK
Definition: ltc2992.h:135
#define LTC2992_ALERT_CLR_BIT
Definition: ltc2992.h:145
#define LTC2992_POWER_FAULT_MSK
Definition: ltc2992.h:130
int ltc2992_set_gpio_max_thresh(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t thresh_value)
Set upper threshold level in a GPIO.
Definition: ltc2992.c:1247
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:124
@ LTC2992_SNAP_VSEL_GPIO1_GPIO2
Definition: ltc2992.h:222
#define LTC2992_MFR_ID_VALUE
Definition: ltc2992.h:156
@ LTC2992_ALERT_DISABLE_ALL
Definition: ltc2992.h:231
#define LTC2992_REG_G4_MAX
Definition: ltc2992.h:81
#define LTC2992_REG_G3_MIN_THRESH
Definition: ltc2992.h:79
#define LTC2992_G4_CTRL_BIT
Definition: ltc2992.h:154
#define MICRO
Definition: no_os_units.h:49
@ LTC2992_VOLTAGE
Definition: ltc2992.h:187
#define LTC2992_REG_POWER_MAX_THRESH(x)
Definition: ltc2992.h:105
@ LTC2992_CONT_VSEL_SENSE_ONLY
Definition: ltc2992.h:209
uint8_t ctrl_mask
Definition: ltc2992.h:254
@ LTC2992_SNAP_VSEL_SENSE1_SENSE2
Definition: ltc2992.h:221
int ltc2992_set_gpio_max_thresh(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t thresh_value)
Set upper threshold level in a GPIO.
Definition: ltc2992.c:1247
enum ltc2992_snapshot_vsel snapshot_vsel
Definition: ltc2992.h:271
#define LTC2992_REG_PSUM_MIN
Definition: ltc2992.h:92
@ LTC2992_MODE_CONTINUOUS
Definition: ltc2992.h:201
#define LTC2992_REG_ALERT2
Definition: ltc2992.h:68
int ltc2992_remove(struct ltc2992_dev *dev)
Free resources allocated to the device.
Definition: ltc2992.c:272
uint32_t shunt_resistor
Definition: ltc2992.h:260
struct no_os_i2c_init_param i2c_init
Definition: ltc2992.h:265
int ltc2992_get_gpio_data(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data)
Get data from a GPIO data converter.
Definition: ltc2992.c:1193
#define LTC2992_REG_DSENSE_MIN_THRESH(x)
Definition: ltc2992.h:111
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
#define LTC2992_REG_PSUM_MAX
Definition: ltc2992.h:91
ltc2992_adr_state
Definition: ltc2992.h:163
@ LTC2992_CONT_VSEL_ALL
Definition: ltc2992.h:208
@ LTC2992_CURRENT
Definition: ltc2992.h:189
int ltc2992_write_reg(struct ltc2992_dev *dev, uint8_t addr, uint32_t value, uint8_t num_bytes)
Write raw data to device register.
Definition: ltc2992.c:332
int ltc2992_get_gpio_data(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data)
Get data from a GPIO data converter.
Definition: ltc2992.c:1193
ltc2992_calibration
Definition: ltc2992.h:195
#define LTC2992_G2_FAULT_ALERT_MSK
Definition: ltc2992.h:141
#define LTC2992_REG_DSENSE_FAULT(x)
Definition: ltc2992.h:119
@ LTC2992_ADR_HIGH
Definition: ltc2992.h:164
#define LTC2992_PSUM_FAULT_MSK
Definition: ltc2992.h:134
bool fault_clear_on_read
Definition: ltc2992.h:274
#define LTC2992_REG_G2_MAX_THRESH
Definition: ltc2992.h:73
@ LTC2992_MODE_SNAPSHOT
Definition: ltc2992.h:202
#define LTC2992_SENSE_ALERT_MSK
Definition: ltc2992.h:127
#define LTC2992_REG_DSENSE_MAX_THRESH(x)
Definition: ltc2992.h:110
Definition: ltc2992.h:244
uint8_t max_thresh
Definition: ltc2992.h:248
int ltc2992_set_gpio_output(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_gpio_output output)
Set GPIO output.
Definition: ltc2992.c:1404
#define LTC2992_ISUM_FAULT_MSK
Definition: ltc2992.h:133
@ LTC2992_ALERT_ENABLE_OV
Definition: ltc2992.h:233
int ltc2992_addr_gen(struct ltc2992_init_param *init_param, enum ltc2992_adr_state a0, enum ltc2992_adr_state a1)
Generate device I2C address based on ADR pin states.
Definition: ltc2992.c:118
uint8_t min_thresh
Definition: ltc2992.h:249
#define LTC2992_REG_DSENSE_MIN(x)
Definition: ltc2992.h:109
@ LTC2992_FAULT_NONE
Definition: ltc2992.h:238
@ LTC2992_GPIO_OUTPUT_HI_Z
Definition: ltc2992.h:177
uint32_t no_os_get_unaligned_be24(uint8_t *buf)
int ltc2992_get_current(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *current_data)
Read bus current along a sense channel.
Definition: ltc2992.c:596
uint8_t min
Definition: ltc2992.h:247
@ LTC2992_SNAP_VSEL_GPIO4
Definition: ltc2992.h:220
#define LTC2992_REG_SENSE_FAULT(x)
Definition: ltc2992.h:118
uint8_t ctrl
Definition: ltc2992.h:253
uint64_t no_os_mul_u32_u32(uint32_t a, uint32_t b)
#define LTC2992_STUCK_BUS_TIMEOUT_BIT
Definition: ltc2992.h:147
@ LTC2992_GPIO2
Definition: ltc2992.h:171
int ltc2992_update_reg(struct ltc2992_dev *dev, uint8_t addr, uint8_t mask, uint8_t val)
Update register value in the device.
Definition: ltc2992.c:365
#define LTC2992_REG_G2_MIN_THRESH
Definition: ltc2992.h:74
@ LTC2992_VSHUNT
Definition: ltc2992.h:188
@ LTC2992_GPIO_OUTPUT_PULL_LOW
Definition: ltc2992.h:178
int ltc2992_get_current(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *current_data)
Read bus current along a sense channel.
Definition: ltc2992.c:596
#define LTC2992_REG_G1_MAX
Definition: ltc2992.h:64
#define LTC2992_REG_ISUM
Definition: ltc2992.h:85
#define LTC2992_PEAK_RST_BIT
Definition: ltc2992.h:148
bool stuck_bus_timer_wakeup_en
Definition: ltc2992.h:275
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
int ltc2992_get_gpio_state(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint8_t *state)
Get GPIO state.
Definition: ltc2992.c:1375
int ltc2992_reset_alert_pin(struct ltc2992_dev *dev)
Reset alert pin (GPI04) status.
Definition: ltc2992.c:1355
#define LTC2992_REG_CTRLA
Definition: ltc2992.h:43
@ LTC2992_ADR_LOW
Definition: ltc2992.h:165
#define no_os_clamp(val, min_val, max_val)
Definition: no_os_util.h:69
@ LTC2992_ISUM
Definition: ltc2992.h:191
int ltc2992_remove(struct ltc2992_dev *dev)
Free resources allocated to the device.
Definition: ltc2992.c:272
ltc2992_gpio_output
Definition: ltc2992.h:176
uint8_t resolution
Definition: ltc2992.h:261
bool alert_clear
Definition: ltc2992.h:273
#define LTC2992_REG_POWER_MIN_THRESH(x)
Definition: ltc2992.h:106
#define LTC2992_REG_SENSE_MAX_THRESH(x)
Definition: ltc2992.h:115
int ltc2992_get_fault(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, enum ltc2992_fault_status *fault)
Get fault status.
Definition: ltc2992.c:1037
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
int ltc2992_get_voltage(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *voltage_data)
Read bus voltage in a sense channel.
Definition: ltc2992.c:562
int ltc2992_get_gpio_state(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint8_t *state)
Get GPIO state.
Definition: ltc2992.c:1375
ltc2992_sense
Definition: ltc2992.h:181
ltc2992_alert_value
Definition: ltc2992.h:230
#define LTC2992_REG_CTRLB
Definition: ltc2992.h:44
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
#define LTC2992_G3_FAULT_ALERT_MSK
Definition: ltc2992.h:142
enum ltc2992_resolution resolution
Definition: ltc2992.h:267
#define LTC2992_POWER_ALERT_MSK
Definition: ltc2992.h:125
int ltc2992_get_gpio_min_data(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data)
Get minimum data from a GPIO data converter.
Definition: ltc2992.c:1229
#define LTC2992_REG_GPIO_STATUS
Definition: ltc2992.h:97
ltc2992_resolution
Definition: ltc2992.h:225
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
#define LTC2992_DSENSE_ALERT_MSK
Definition: ltc2992.h:126
int ltc2992_read_reg(struct ltc2992_dev *dev, uint8_t addr, uint32_t *data, uint8_t num_bytes)
Read raw data from device register.
Definition: ltc2992.c:292
#define LTC2992_REG_SENSE_MIN_THRESH(x)
Definition: ltc2992.h:116
#define no_os_clamp_t(type, val, min_val, max_val)
Definition: no_os_util.h:71
Header file of I2C Interface.
@ LTC2992_ALERT_ENABLE_UV
Definition: ltc2992.h:232
#define LTC2992_REG_G3
Definition: ltc2992.h:75
int ltc2992_set_gpio_output(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_gpio_output output)
Set GPIO output.
Definition: ltc2992.c:1404
ltc2992_snapshot_vsel
Definition: ltc2992.h:214
@ LTC2992_CONT_VSEL_GPIO1_GPIO2
Definition: ltc2992.h:210
#define LTC2992_REG_GPIO_IO_CTRL
Definition: ltc2992.h:98
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
int ltc2992_clear_gpio_fault(struct ltc2992_dev *dev, enum ltc2992_gpio gpio)
Clear GPIO fault status.
Definition: ltc2992.c:1343
int ltc2992_reset_alert_pin(struct ltc2992_dev *dev)
Reset alert pin (GPI04) status.
Definition: ltc2992.c:1355
int ltc2992_set_alert(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, enum ltc2992_alert_value alert)
Enable alert.
Definition: ltc2992.c:951
int ltc2992_get_gpio_min_data(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data)
Get minimum data from a GPIO data converter.
Definition: ltc2992.c:1229
int ltc2992_addr_gen(struct ltc2992_init_param *init_param, enum ltc2992_adr_state a0, enum ltc2992_adr_state a1)
Generate device I2C address based on ADR pin states.
Definition: ltc2992.c:118
ltc2992_measure_mode
Definition: ltc2992.h:200
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
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
int ltc2992_set_gpio_alert(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_alert_value alert_value)
Enable alert when GPIO level reaches beyond threshold limit.
Definition: ltc2992.c:1292
@ LTC2992_FAULT_UNDERVALUE
Definition: ltc2992.h:239
#define LTC2992_REG_G3_MIN
Definition: ltc2992.h:77
Definition: ltc2992.h:257
uint8_t fault_alert_mask
Definition: ltc2992.h:252
#define LTC2992_REG_POWER_FAULT(x)
Definition: ltc2992.h:117
#define LTC2992_REG_G2_MIN
Definition: ltc2992.h:72
@ LTC2992_PSUM
Definition: ltc2992.h:192
uint8_t fault
Definition: ltc2992.h:250
#define LTC2992_REG_G4_MAX_THRESH
Definition: ltc2992.h:83
#define LTC2992_REG_ISUM_MIN
Definition: ltc2992.h:87
int ltc2992_get_sum(struct ltc2992_dev *dev, enum ltc2992_channel chan, uint32_t *sum_data)
Read the shunt voltage sum or power sum of both sense channels.
Definition: ltc2992.c:638
int ltc2992_get_fault(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, enum ltc2992_fault_status *fault)
Get fault status.
Definition: ltc2992.c:1037
#define LTC2992_REG_FAULT1
Definition: ltc2992.h:46
#define LTC2992_REG_PSUM_MAX_THRESH
Definition: ltc2992.h:93
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
int ltc2992_update_reg(struct ltc2992_dev *dev, uint8_t addr, uint8_t mask, uint8_t val)
Update register value in the device.
Definition: ltc2992.c:365
int ltc2992_clear_fault(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan)
Clear fault status.
Definition: ltc2992.c:1112
@ LTC2992_SNAP_VSEL_GPIO2
Definition: ltc2992.h:218
int ltc2992_get_max_data(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t *data)
Read maximum sense data at a SENSE channel.
Definition: ltc2992.c:720
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
#define LTC2992_REG_PSUM
Definition: ltc2992.h:90
#define LTC2992_REG_G1
Definition: ltc2992.h:63
#define LTC2992_G4_ALERT_PIN_BIT
Definition: ltc2992.h:150
Definition: ltc2992.h:264
#define LTC2992_REG_SENSE_MAX(x)
Definition: ltc2992.h:113
int ltc2992_set_gpio_min_thresh(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t thresh_value)
Set lower threshold level in a GPIO.
Definition: ltc2992.c:1266
int ltc2992_get_gpio_max_data(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data)
Get maximum data from a GPIO data converter.
Definition: ltc2992.c:1211
@ LTC2992_ALERT_ENABLE_ALL
Definition: ltc2992.h:234
#define LTC2992_REG_ALERT3
Definition: ltc2992.h:95
@ LTC2992_SNAP_VSEL_SENSE2
Definition: ltc2992.h:216
int ltc2992_set_min_thresh(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t thresh_value)
Set lower thresh level for alert at a SENSE channel.
Definition: ltc2992.c:892
@ LTC2992_SENSE2
Definition: ltc2992.h:183
#define LTC2992_MEASURE_MODE_MSK
Definition: ltc2992.h:122
int ltc2992_get_voltage(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *voltage_data)
Read bus voltage in a sense channel.
Definition: ltc2992.c:562
@ LTC2992_POWER
Definition: ltc2992.h:190
int ltc2992_init(struct ltc2992_dev **device, struct ltc2992_init_param *init_param)
Initialize communication peripheral for the device.
Definition: ltc2992.c:179
int ltc2992_set_max_thresh(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t thresh_value)
Set upper thresh level for alert at a SENSE channel.
Definition: ltc2992.c:840
Header file of GPIO Interface.
#define LTC2992_RESET_BIT
Definition: ltc2992.h:149
uint8_t data
Definition: ltc2992.h:245
int ltc2992_get_gpio_max_data(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data)
Get maximum data from a GPIO data converter.
Definition: ltc2992.c:1211
#define LTC2992_REG_POWER_MAX(x)
Definition: ltc2992.h:103
#define LTC2992_REG_G4_MIN_THRESH
Definition: ltc2992.h:84
@ LTC2992_RESOLUTION_8_BIT
Definition: ltc2992.h:227
int ltc2992_get_power(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *power_data)
Read bus power output in a sense channel.
Definition: ltc2992.c:621
#define LTC2992_8B_POWER_VAL_MSK
Definition: ltc2992.h:138
#define LTC2992_G4_FAULT_ALERT_MSK
Definition: ltc2992.h:143
#define LTC2992_REG_PSUM_MIN_THRESH
Definition: ltc2992.h:94
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
#define LTC2992_G1_FAULT_ALERT_MSK
Definition: ltc2992.h:140
@ LTC2992_GPIO4
Definition: ltc2992.h:173
int ltc2992_read_reg(struct ltc2992_dev *dev, uint8_t addr, uint32_t *data, uint8_t num_bytes)
Read raw data from device register.
Definition: ltc2992.c:292
Header file of utility functions.
#define LTC2992_DSENSE_FAULT_MSK
Definition: ltc2992.h:131
#define LTC2992_G2_CTRL_BIT
Definition: ltc2992.h:152
@ LTC2992_CALIBRATE_ALWAYS
Definition: ltc2992.h:196
@ LTC2992_GPIO3
Definition: ltc2992.h:172
int ltc2992_clear_gpio_fault(struct ltc2992_dev *dev, enum ltc2992_gpio gpio)
Clear GPIO fault status.
Definition: ltc2992.c:1343
#define LTC2992_RESOLUTION_POS
Definition: ltc2992.h:157
#define LTC2992_REG_G4
Definition: ltc2992.h:80
@ LTC2992_ADR_NC
Definition: ltc2992.h:166
int ltc2992_set_alert(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, enum ltc2992_alert_value alert)
Enable alert.
Definition: ltc2992.c:951
@ LTC2992_SNAP_VSEL_GPIO1
Definition: ltc2992.h:217
int ltc2992_set_gpio_alert(struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_alert_value alert_value)
Enable alert when GPIO level reaches beyond threshold limit.
Definition: ltc2992.c:1292
#define LTC2992_REG_G3_MAX
Definition: ltc2992.h:76
int ltc2992_get_vshunt(struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *vshunt_data)
Read shunt voltage in a sense channel.
Definition: ltc2992.c:579
int ltc2992_get_min_data(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t *data)
Read minimum sense data at a SENSE channel.
Definition: ltc2992.c:780
@ LTC2992_SENSE1
Definition: ltc2992.h:182
#define LTC2992_ISUM_ALERT_MSK
Definition: ltc2992.h:128
struct no_os_gpio_init_param alert_gpio_init
Definition: ltc2992.h:266
#define LTC2992_8B_SENSE_VAL_MSK
Definition: ltc2992.h:137
Error macro definition for ARM Compiler.
int ltc2992_set_max_thresh(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t thresh_value)
Set upper thresh level for alert at a SENSE channel.
Definition: ltc2992.c:840
#define LTC2992_PSUM_ALERT_MSK
Definition: ltc2992.h:129
#define LTC2992_REG_ALERT1
Definition: ltc2992.h:45
ltc2992_continuous_vsel
Definition: ltc2992.h:207
#define LTC2992_SENSE_FAULT_MSK
Definition: ltc2992.h:132
int ltc2992_get_sense_data(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t *data)
Read sense data at a SENSE channel.
Definition: ltc2992.c:682
int ltc2992_clear_fault(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan)
Clear fault status.
Definition: ltc2992.c:1112
#define MILLIAMPER_PER_AMPER
Definition: no_os_units.h:62
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54
enum ltc2992_calibration calibration
Definition: ltc2992.h:268
#define LTC2992_REG_SENSE_MIN(x)
Definition: ltc2992.h:114
int ltc2992_get_min_data(struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, uint32_t *data)
Read minimum sense data at a SENSE channel.
Definition: ltc2992.c:780
uint64_t no_os_div_u64(uint64_t dividend, uint32_t divisor)
uint8_t max
Definition: ltc2992.h:246
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75