no-OS
Loading...
Searching...
No Matches
adhv4710.c File Reference

Implementation of ADHV4710 Driver. More...

#include "adhv4710.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "no_os_util.h"
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_irq.h"
#include "no_os_delay.h"
#include "no_os_units.h"
#include "no_os_alloc.h"
#include "no_os_crc16.h"
#include "no_os_print_log.h"
#include <stdlib.h>
#include <errno.h>
#include <math.h>
Include dependency graph for adhv4710.c:

Functions

int adhv4710_init (struct adhv4710_dev **device, struct adhv4710_init_param init_param)
 Initialize the device.
 
int adhv4710_read (struct adhv4710_dev *dev, uint8_t reg_addr, int8_t *reg_data)
 Read device register.
 
int adhv4710_write (struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t reg_data)
 Write device register.
 
int adhv4710_update_bits (struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_data)
 Update specific register bits.
 
int adhv4710_get_status (struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t msk, uint8_t *status)
 Get indicator of settings.
 
int adhv4710_remove (struct adhv4710_dev *dev)
 Remove the device and release resources.
 
int adhv4710_sw_reset (struct adhv4710_dev *dev)
 Reset the device using SW reset.
 
int adhv4710_hw_reset (struct adhv4710_dev *dev)
 Reset the device using HW reset.
 
int adhv4710_clear_shutdown_latch (struct adhv4710_dev *dev)
 Clear shutdown latch and re-enable amplifier from shutdown.
 
int adhv4710_shutdown_amplifier (struct adhv4710_dev *dev)
 Shutdown the amplifier.
 
int adhv4710_set_quiescent_current (struct adhv4710_dev *dev, uint8_t value, uint8_t direction)
 Program quiescent current of amplifier.
 
int adhv4710_enable_source_overcurrent_protection (struct adhv4710_dev *dev)
 Enable source overcurrent protection.
 
int adhv4710_set_source_overcurrent_level (struct adhv4710_dev *dev, uint8_t level)
 Set level of overcurrent source protection.
 
int adhv4710_enable_sink_overcurrent_protection (struct adhv4710_dev *dev)
 Enable sink overcurrent protection.
 
int adhv4710_set_sink_overcurrent_level (struct adhv4710_dev *dev, uint8_t level)
 Set level of overcurrent sink protection.
 
int adhv4710_enable_overvoltage_pos_protection (struct adhv4710_dev *dev)
 Enable overvoltage positive protection.
 
int adhv4710_set_overvoltage_pos_level (struct adhv4710_dev *dev, uint8_t level)
 Set level of overvoltage positive protection.
 
int adhv4710_enable_overvoltage_neg_protection (struct adhv4710_dev *dev)
 Enable overvoltage negative protection.
 
int adhv4710_set_overvoltage_neg_level (struct adhv4710_dev *dev, uint8_t level)
 Set level of overvoltage negative protection.
 
int adhv4710_enable_overtemperature_protection (struct adhv4710_dev *dev)
 Enable overtemperature protection.
 
int adhv4710_set_overtemperature_level (struct adhv4710_dev *dev, uint8_t level)
 Set level of overtemperature protection.
 
int adhv4710_version_product (struct adhv4710_dev *dev, uint8_t *data_read)
 Version product.
 

Detailed Description

Implementation of ADHV4710 Driver.

Author
REtz (radu..nosp@m.etz@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2025(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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Function Documentation

◆ adhv4710_clear_shutdown_latch()

int adhv4710_clear_shutdown_latch ( struct adhv4710_dev * dev)

Clear shutdown latch and re-enable amplifier from shutdown.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_enable_overtemperature_protection()

int adhv4710_enable_overtemperature_protection ( struct adhv4710_dev * dev)

Enable overtemperature protection.

Parameters
dev- The device structure.
Here is the caller graph for this function:

◆ adhv4710_enable_overvoltage_neg_protection()

int adhv4710_enable_overvoltage_neg_protection ( struct adhv4710_dev * dev)

Enable overvoltage negative protection.

Parameters
dev- The device structure.
Here is the caller graph for this function:

◆ adhv4710_enable_overvoltage_pos_protection()

int adhv4710_enable_overvoltage_pos_protection ( struct adhv4710_dev * dev)

Enable overvoltage positive protection.

Parameters
dev- The device structure.
Here is the caller graph for this function:

◆ adhv4710_enable_sink_overcurrent_protection()

int adhv4710_enable_sink_overcurrent_protection ( struct adhv4710_dev * dev)

Enable sink overcurrent protection.

Parameters
dev- The device structure.
Here is the caller graph for this function:

◆ adhv4710_enable_source_overcurrent_protection()

int adhv4710_enable_source_overcurrent_protection ( struct adhv4710_dev * dev)

Enable source overcurrent protection.

Parameters
dev- The device structure.
Here is the caller graph for this function:

◆ adhv4710_get_status()

int adhv4710_get_status ( struct adhv4710_dev * dev,
uint8_t reg_addr,
uint8_t msk,
uint8_t * status )

Get indicator of settings.

Parameters
dev- The device structure.
reg_addr- The register address.
msk- Bit that needs to be tested.
status- Status indicator.
Returns
0 in case of success, negative error code otherwise.

◆ adhv4710_hw_reset()

int adhv4710_hw_reset ( struct adhv4710_dev * dev)

Reset the device using HW reset.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_init()

int adhv4710_init ( struct adhv4710_dev ** device,
struct adhv4710_init_param init_param )

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_read()

int adhv4710_read ( struct adhv4710_dev * dev,
uint8_t reg_addr,
int8_t * reg_data )

Read device register.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The data read from 32bit register.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_remove()

int adhv4710_remove ( struct adhv4710_dev * dev)

Remove the device and release resources.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adhv4710_set_overtemperature_level()

int adhv4710_set_overtemperature_level ( struct adhv4710_dev * dev,
uint8_t level )

Set level of overtemperature protection.

Parameters
dev- The device structure.
level- The level of overtemperature protection (level = round( (threshold[℃] + 266.64[℃]) / 6.51[℃/LSB]) ).
Here is the caller graph for this function:

◆ adhv4710_set_overvoltage_neg_level()

int adhv4710_set_overvoltage_neg_level ( struct adhv4710_dev * dev,
uint8_t level )

Set level of overvoltage negative protection.

Parameters
dev- The device structure.
level- The level of overvoltage negative protection (level = round(threshold[V] / 1.953[V/LSB])).
Here is the caller graph for this function:

◆ adhv4710_set_overvoltage_pos_level()

int adhv4710_set_overvoltage_pos_level ( struct adhv4710_dev * dev,
uint8_t level )

Set level of overvoltage positive protection.

Parameters
dev- The device structure.
level- The level of overvoltage positive protection (level = round(threshold[V] / 1.953[V/LSB])).
Here is the caller graph for this function:

◆ adhv4710_set_quiescent_current()

int adhv4710_set_quiescent_current ( struct adhv4710_dev * dev,
uint8_t value,
uint8_t direction )

Program quiescent current of amplifier.

Parameters
dev- The device structure.
value- The quiescent current value to be set (0x0 for nominal supply current).
direction- The direction of the quiescent current (0 for reduction, 1 for increase).
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_set_sink_overcurrent_level()

int adhv4710_set_sink_overcurrent_level ( struct adhv4710_dev * dev,
uint8_t level )

Set level of overcurrent sink protection.

Parameters
dev- The device structure.
level- The level of overcurrent source protection (level = round(threshold[mA] / 15.625[mA/LSB])).
Here is the caller graph for this function:

◆ adhv4710_set_source_overcurrent_level()

int adhv4710_set_source_overcurrent_level ( struct adhv4710_dev * dev,
uint8_t level )

Set level of overcurrent source protection.

Parameters
dev- The device structure.
level- The level of overcurrent source protection (level = round(threshold[mA] / 15.625[mA/LSB])).
Here is the caller graph for this function:

◆ adhv4710_shutdown_amplifier()

int adhv4710_shutdown_amplifier ( struct adhv4710_dev * dev)

Shutdown the amplifier.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adhv4710_sw_reset()

int adhv4710_sw_reset ( struct adhv4710_dev * dev)

Reset the device using SW reset.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adhv4710_update_bits()

int adhv4710_update_bits ( struct adhv4710_dev * dev,
uint8_t reg_addr,
uint8_t mask,
uint8_t reg_data )

Update specific register bits.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Specific bits mask.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_version_product()

int adhv4710_version_product ( struct adhv4710_dev * dev,
uint8_t * data_read )

Version product.

Parameters
dev- The device structure.
data_read- The version product read value
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adhv4710_write()

int adhv4710_write ( struct adhv4710_dev * dev,
uint8_t reg_addr,
uint8_t reg_data )

Write device register.

Parameters
dev-The device structure.
reg_addr- The register address.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: