no-OS
|
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include "no_os_util.h"
#include "no_os_alloc.h"
#include "no_os_i2c.h"
#include "no_os_units.h"
#include "ltc2992.h"
Functions | |
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. More... | |
int | ltc2992_init (struct ltc2992_dev **device, struct ltc2992_init_param *init_param) |
Initialize communication peripheral for the device. More... | |
int | ltc2992_remove (struct ltc2992_dev *dev) |
Free resources allocated to the device. More... | |
int | ltc2992_read_reg (struct ltc2992_dev *dev, uint8_t addr, uint32_t *data, uint8_t num_bytes) |
Read raw data from device register. More... | |
int | ltc2992_write_reg (struct ltc2992_dev *dev, uint8_t addr, uint32_t value, uint8_t num_bytes) |
Write raw data to device register. More... | |
int | ltc2992_update_reg (struct ltc2992_dev *dev, uint8_t addr, uint8_t mask, uint8_t val) |
Update register value in the device. More... | |
int | ltc2992_get_voltage (struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *voltage_data) |
Read bus voltage in a sense channel. More... | |
int | ltc2992_get_vshunt (struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *vshunt_data) |
Read shunt voltage in a sense channel. More... | |
int | ltc2992_get_current (struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *current_data) |
Read bus current along a sense channel. More... | |
int | ltc2992_get_power (struct ltc2992_dev *dev, enum ltc2992_sense sense, uint32_t *power_data) |
Read bus power output in a sense channel. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | ltc2992_set_alert (struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, enum ltc2992_alert_value alert) |
Enable alert. More... | |
int | ltc2992_get_fault (struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan, enum ltc2992_fault_status *fault) |
Get fault status. More... | |
int | ltc2992_clear_fault (struct ltc2992_dev *dev, enum ltc2992_sense sense, enum ltc2992_channel chan) |
Clear fault status. More... | |
int | ltc2992_get_gpio_data (struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint32_t *gpio_data) |
Get data from a GPIO data converter. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | ltc2992_get_gpio_fault (struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_fault_status *fault) |
Get GPIO fault status. More... | |
int | ltc2992_clear_gpio_fault (struct ltc2992_dev *dev, enum ltc2992_gpio gpio) |
Clear GPIO fault status. More... | |
int | ltc2992_reset_alert_pin (struct ltc2992_dev *dev) |
Reset alert pin (GPI04) status. More... | |
int | ltc2992_get_gpio_state (struct ltc2992_dev *dev, enum ltc2992_gpio gpio, uint8_t *state) |
Get GPIO state. More... | |
int | ltc2992_set_gpio_output (struct ltc2992_dev *dev, enum ltc2992_gpio gpio, enum ltc2992_gpio_output output) |
Set GPIO output. More... | |
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.
init_param | - Initialization parameter. |
a0 | - ADR0 state. Example: LTC2992_ADR_HIGH - ADR at high logic level. LTC2992_ADR_LOW - ADR at ground.. LTC2992_ADR_NC - ADR not connected. |
a1 | - ADR1 state. Example: LTC2992_ADR_HIGH - ADR at high logic level. LTC2992_ADR_LOW - ADR at ground. LTC2992_ADR_NC - ADR not connected. |
int ltc2992_clear_fault | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
enum ltc2992_channel | chan | ||
) |
Clear fault status.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 LTC2992_SENSE2 |
chan | - Measured data channel. Example: LTC2992_VOLTAGE LTC2992_VSHUNT LTC2992_CURRENT LTC2992_POWER LTC2992_ISUM LTC2992_PSUM |
int ltc2992_clear_gpio_fault | ( | struct ltc2992_dev * | dev, |
enum ltc2992_gpio | gpio | ||
) |
Clear GPIO fault status.
dev | - The device structure. |
gpio | - GPIO to clear fault. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
int ltc2992_get_current | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
uint32_t * | current_data | ||
) |
Read bus current along a sense channel.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
current_data | - Current read in milliamperes. |
int ltc2992_get_fault | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
enum ltc2992_channel | chan, | ||
enum ltc2992_fault_status * | fault | ||
) |
Get fault status.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 LTC2992_SENSE2 |
chan | - Measured data channel. Example: LTC2992_VOLTAGE LTC2992_VSHUNT LTC2992_CURRENT LTC2992_POWER LTC2992_ISUM LTC2992_PSUM |
fault | - Alert value to set. Example: LTC2992_FAULT_NONE - No fault event LTC2992_FAULT_UNDERVALUE - Undervalue fault occurred LTC2992_FAULT_OVERVALUE - Overvalue fault occurred |
int ltc2992_get_gpio_data | ( | struct ltc2992_dev * | dev, |
enum ltc2992_gpio | gpio, | ||
uint32_t * | gpio_data | ||
) |
Get data from a GPIO data converter.
dev | - The device structure. |
gpio | - GPIO to get. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
gpio_data | - Data read |
int ltc2992_get_gpio_fault | ( | struct ltc2992_dev * | dev, |
enum ltc2992_gpio | gpio, | ||
enum ltc2992_fault_status * | fault | ||
) |
Get GPIO fault status.
dev | - The device structure. |
gpio | - GPIO to read fault status. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
fault | - Alert value to set. Example: LTC2992_FAULT_NONE - No fault event LTC2992_FAULT_UNDERVALUE - Undervalue fault occurred LTC2992_FAULT_OVERVALUE - Overvalue fault occurred |
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.
dev | - The device structure. |
gpio | - GPIO to read. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
gpio_data | - Data read |
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.
dev | - The device structure. |
gpio | - GPIO to get. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
gpio_data | - Data read |
int ltc2992_get_gpio_state | ( | struct ltc2992_dev * | dev, |
enum ltc2992_gpio | gpio, | ||
uint8_t * | state | ||
) |
Get GPIO state.
dev | - The device structure. |
gpio | - GPIO to read state. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
state | - GPIO state Example: 0 - GPIO is logic low 1 - GPIO is logic high |
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.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
chan | - Measured data channel. Example: LTC2992_VOLTAGE - Read bus voltage in millivolts. LTC2992_VSHUNT - Read shunt voltage in microvolts. LTC2992_CURRENT - Read current in milliamperes. LTC2992_POWER - Read power in milliwatts. LTC2992_ISUM - Read ISUM in microvolts. LTC2992_PSUM - Read PSUM in milliwatts. |
data | - Read max data. |
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.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
chan | - Measured data channel. Example: LTC2992_VOLTAGE - Read bus voltage in millivolts. LTC2992_VSHUNT - Read shunt voltage in microvolts. LTC2992_CURRENT - Read current in milliamperes. LTC2992_POWER - Read power in milliwatts. LTC2992_ISUM - Read ISUM in microvolts. LTC2992_PSUM - Read PSUM in milliwatts. |
data | - Read min data. |
int ltc2992_get_power | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
uint32_t * | power_data | ||
) |
Read bus power output in a sense channel.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
power_data | - Power read in milliwatts. |
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.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
chan | - Measured data channel. Example: LTC2992_VOLTAGE - Read bus voltage in millivolts. LTC2992_VSHUNT - Read shunt voltage in microvolts. LTC2992_CURRENT - Read current in milliamperes. LTC2992_POWER - Read power in milliwatts. LTC2992_ISUM - Read ISUM in microvolts. LTC2992_PSUM - Read PSUM in milliwatts. |
data | - Read data. |
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.
dev | - The device structure. |
chan | - Measured channel. Example: LTC2992_VSHUNT - Read ISUM. LTC2992_POWER - Read PSUM. |
sum_data | - Sum read in microvolts or milliwatts. |
int ltc2992_get_voltage | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
uint32_t * | voltage_data | ||
) |
Read bus voltage in a sense channel.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
voltage_data | - Voltage read in millivolts. |
int ltc2992_get_vshunt | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
uint32_t * | vshunt_data | ||
) |
Read shunt voltage in a sense channel.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 - Read in SENSE1 channel. LTC2992_SENSE2 - Read in SENSE2 channel. |
vshunt_data | - Voltage read in microvolts. |
int ltc2992_init | ( | struct ltc2992_dev ** | device, |
struct ltc2992_init_param * | init_param | ||
) |
Initialize communication peripheral for the device.
device | - The device structure. |
init_param | - Initial parameters. |
int ltc2992_read_reg | ( | struct ltc2992_dev * | dev, |
uint8_t | addr, | ||
uint32_t * | data, | ||
uint8_t | num_bytes | ||
) |
Read raw data from device register.
dev | - The device structure. |
addr | - The register address. |
data | - Register data pointer. |
num_bytes | - Number of bytes to read. |
int ltc2992_remove | ( | struct ltc2992_dev * | dev | ) |
Free resources allocated to the device.
dev | - The device structure. |
int ltc2992_reset_alert_pin | ( | struct ltc2992_dev * | dev | ) |
Reset alert pin (GPI04) status.
dev | - The device structure. |
int ltc2992_set_alert | ( | struct ltc2992_dev * | dev, |
enum ltc2992_sense | sense, | ||
enum ltc2992_channel | chan, | ||
enum ltc2992_alert_value | alert | ||
) |
Enable alert.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 LTC2992_SENSE2 |
chan | - Measured data channel. Example: LTC2992_VOLTAGE LTC2992_VSHUNT LTC2992_CURRENT LTC2992_POWER LTC2992_ISUM LTC2992_PSUM |
alert | - Alert value to set. Example: LTC2992_ALERT_DISABLE_ALL - Disable alert LTC2992_ALERT_ENABLE_UV - Enable undervalue alert LTC2992_ALERT_ENABLE_OV - Enable overvalue alert LTC2992_ALERT_ENABLE_ALL - Enable undervalue and overvalue alert |
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.
dev | - The device structure. |
gpio | - GPIO to enable alert. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
alert_value | - Alert value to set. Example: LTC2992_ALERT_DISABLE_ALL - Disable alert LTC2992_ALERT_ENABLE_UV - Enable undervalue alert LTC2992_ALERT_ENABLE_OV - Enable overvalue alert LTC2992_ALERT_ENABLE_ALL - Enable undervalue and overvalue alert |
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.
dev | - The device structure. |
gpio | - GPIO to set. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
thresh_value | - Set threshold. |
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.
dev | - The device structure. |
gpio | - GPIO to set. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
thresh_value | - Set threshold. |
int ltc2992_set_gpio_output | ( | struct ltc2992_dev * | dev, |
enum ltc2992_gpio | gpio, | ||
enum ltc2992_gpio_output | output | ||
) |
Set GPIO output.
dev | - The device structure. |
gpio | - GPIO to set. Example: LTC2992_GPIO1 LTC2992_GPIO2 LTC2992_GPIO3 LTC2992_GPIO4 |
output | - GPIO output to set Example: LTC2992_GPIO_OUTPUT_HI_Z - Output high impedance. LTC2992_GPIO_OUTPUT_PULL_LOW - Pull output low. |
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.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 LTC2992_SENSE2 |
chan | - Measured data channel. Example: LTC2992_VOLTAGE - Bus voltage thresh in millivolts. LTC2992_VSHUNT - Shunt voltage thresh in microvolts. LTC2992_CURRENT - Current thresh in milliamperes. LTC2992_POWER - Power thresh in milliwatts. LTC2992_ISUM - ISUM thresh in microvolts. LTC2992_PSUM - PSUM thresh in milliwatts. |
thresh_value | - Thresh level to set. |
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.
dev | - The device structure. |
sense | - Sense channel. Example: LTC2992_SENSE1 LTC2992_SENSE2 |
chan | - Measured data channel. Example: LTC2992_VOLTAGE - Bus voltage thresh in millivolts. LTC2992_VSHUNT - Shunt voltage thresh in microvolts. LTC2992_CURRENT - Current thresh in milliamperes. LTC2992_POWER - Power thresh in milliwatts. LTC2992_ISUM - ISUM thresh in microvolts. LTC2992_PSUM - PSUM thresh in milliwatts. |
thresh_value | - Thresh level to set. |
int ltc2992_update_reg | ( | struct ltc2992_dev * | dev, |
uint8_t | addr, | ||
uint8_t | mask, | ||
uint8_t | val | ||
) |
Update register value in the device.
dev | - The device structure. |
addr | - The register address. |
mask | - Mask of the bitfield to be updated. |
val | - Value to write. |
int ltc2992_write_reg | ( | struct ltc2992_dev * | dev, |
uint8_t | addr, | ||
uint32_t | value, | ||
uint8_t | num_bytes | ||
) |
Write raw data to device register.
dev | - The device structure. |
addr | - The register address. |
value | - Value to write. |
num_bytes | - Number of bytes to write. |