Source file of ADM1177 Driver. More...
#include <stdlib.h>
#include "adm1177.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
Functions | |
int | adm1177_init (struct adm1177_dev **device, struct adm1177_init_param *init_param) |
Initializes I2C. | |
int | adm1177_remove (struct adm1177_dev *device) |
Free the resources allocated by adm1177_init(). | |
int | adm1177_set_vrange (struct adm1177_dev *device, uint8_t vrange) |
| |
int | adm1177_write (struct adm1177_dev *device, uint8_t cmd, uint8_t reg_address) |
| |
int | adm1177_read_status (struct adm1177_dev *device, uint8_t *status_byte) |
| |
int | adm1177_read_conv (struct adm1177_dev *device, uint16_t *conv_voltage, uint16_t *conv_current) |
| |
int | adm1177_to_microvolts (struct adm1177_dev *device, uint16_t raw_sample, uint64_t *voltage_uv) |
| |
int | adm1177_to_microampers (uint16_t raw_sample, uint64_t *current_ua) |
| |
Source file of ADM1177 Driver.
Header file of ADM1177 Driver.
Copyright 2023(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int adm1177_init | ( | struct adm1177_dev ** | device, |
struct adm1177_init_param * | init_param ) |
Initializes I2C.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int adm1177_read_conv | ( | struct adm1177_dev * | device, |
uint16_t * | conv_voltage, | ||
uint16_t * | conv_current ) |
device | - The device structure. |
conv_voltage | - The variable through which the voltage read from the ADC is received if requested. If it is 0, it means it was not requested. |
conv_current | - The variable through which the current read from the ADC is received if requested. If it is 0, it means it was not requested. |
int adm1177_read_status | ( | struct adm1177_dev * | device, |
uint8_t * | status_byte ) |
device | - The device structure. |
status_byte | - The pointer through which the status byte is transmitted. |
int adm1177_remove | ( | struct adm1177_dev * | device | ) |
Free the resources allocated by adm1177_init().
device | - The device structure. |
int adm1177_set_vrange | ( | struct adm1177_dev * | device, |
uint8_t | vrange ) |
device | - The device structure. |
vrange | - ADM1177_CMD_VRANGE for V Range of 6.65V, otherwise 26.65V will be used. |
int adm1177_to_microampers | ( | uint16_t | raw_sample, |
uint64_t * | current_ua ) |
raw_sample | - The raw sample of the Current Readback from the ADC. |
current_ua | - The pointer through which the converted microamper value is returned. |
int adm1177_to_microvolts | ( | struct adm1177_dev * | device, |
uint16_t | raw_sample, | ||
uint64_t * | voltage_uv ) |
device | - The device structure. |
raw_sample | - The raw sample of the Voltage Readback from the ADC. |
voltage_uv | - The pointer through which the converted microvolt value is returned. |
int adm1177_write | ( | struct adm1177_dev * | device, |
uint8_t | cmd, | ||
uint8_t | reg_address ) |
device | - The device structure. |
cmd | - The command byte indicates which operation to be performed. |
reg_address | - In case of a write extended command byte operation one of the ADM1177_REG_ALERT_EN, ADM1177_REG_ALERT_TH or ADM1177_REG_CONTROL will be used. In case of a write command byte operation reg_address will be set to 0. |