no-OS
Loading...
Searching...
No Matches
adhv4710.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef __ADHV4710_H__
34#define __ADHV4710_H__
35
36#include <stdbool.h>
37#include <stdint.h>
38#include <string.h>
39#include "no_os_util.h"
40#include "no_os_spi.h"
41#include "no_os_gpio.h"
42#include "no_os_irq.h"
43#include "no_os_delay.h"
44#include "no_os_units.h"
45#include "no_os_alloc.h"
46#include "no_os_crc16.h"
47#include "no_os_print_log.h"
48#include <stdlib.h>
49#include <errno.h>
50#include <math.h>
51
52/* SPI commands */
53#define ADHV4710_SPI_READ NO_OS_BIT(7)
54
55/* Version product */
56#define ADHV4710_SILICON_REV 0x4
57#define ADHV4710_VERSION_PRODUCT 0x46
58#define ADHV4711_VERSION_PRODUCT 0x47
59
60/* ADHV4710 Register Map */
61/* 8 BIT REGISTERS */
62#define ADHV4710_REG_CTRL_REG_00 0x000
63#define ADHV4710_REG_CTRL_REG_03 0x003
64#define ADHV4710_REG_CTRL_REG_04 0x004
65#define ADHV4710_REG_CTRL_REG_08 0x008
66#define ADHV4710_REG_CTRL_REG_09 0x009
67#define ADHV4710_REG_CTRL_REG_10 0x00A
68#define ADHV4710_REG_CTRL_REG_11 0x00B
69#define ADHV4710_REG_CTRL_REG_12 0x00C
70#define ADHV4710_REG_CTRL_REG_13 0x00D
71#define ADHV4710_REG_CTRL_REG_14 0x00E
72#define ADHV4710_REG_CTRL_REG_25 0x019
73#define ADHV4710_REG_CTRL_REG_26 0x01A
74
75/* ADHV4710_REG_CTRL_REG_00 Bit Definition */
76#define ADHV4710_HV_RESET_MSK NO_OS_BIT(7)
77#define ADHV4710_HV_SLEEP_MSK NO_OS_BIT(4)
78
79/* ADHV4710_REG_CTRL_REG_03 Bit Definition */
80#define ADHV4710_SOFT_RESET_MSK NO_OS_BIT(0)
81
82/* ADHV4710_REG_CTRL_REG_04 Bit Definition */
83#define ADHV4710_SET_IQ_MSK NO_OS_GENMASK(7, 0)
84
85/* ADHV4710_REG_CTRL_REG_08 Bit Definition */
86#define ADHV4710_OC_SRC_ARM_MSK NO_OS_BIT(7)
87#define ADEHV4710_OC_SRC_LIMIT_MSK NO_OS_GENMASK(6, 0)
88
89/* ADHV4710_REG_CTRL_REG_09 Bit Definition */
90#define ADHV4710_OC_SNK_ARM_MSK NO_OS_BIT(7)
91#define ADEHV4710_OC_SNK_LIMIT_MSK NO_OS_GENMASK(6, 0)
92
93/* ADHV4710_REG_CTRL_REG_10 Bit Definition */
94#define ADHV4710_OV_POS_ARM_MSK NO_OS_BIT(7)
95#define ADEHV4710_OV_POS_LIMIT_MSK NO_OS_GENMASK(6, 0)
96
97/* ADHV4710_REG_CTRL_REG_011 Bit Definition */
98#define ADHV4710_OV_NEG_ARM_MSK NO_OS_BIT(7)
99#define ADEHV4710_OV_NEG_LIMIT_MSK NO_OS_GENMASK(6, 0)
100
101/* ADHV4710_REG_CTRL_REG_12 Bit Definition */
102#define ADHV4710_OT_ARM_MSK NO_OS_BIT(7)
103#define ADEHV4710_OT_LIMIT_MSK NO_OS_GENMASK(6, 0)
104
105/* ADHV4710_REG_CTRL_REG_13 Bit Definition */
106#define ADHV4710_OC_SRC_ALARM_LATCH_MSK NO_OS_BIT(4)
107#define ADHV4710_OC_SNK_ALARM_LATCH_MSK NO_OS_BIT(3)
108#define ADHV4710_OV_POS_ALARM_LATCH_MSK NO_OS_BIT(2)
109#define ADHV4710_OV_NEG_ALARM_LATCH_MSK NO_OS_BIT(1)
110#define ADHV4710_OT_ALARM_LATCH_MSK NO_OS_BIT(0)
111#define ADHV4710_ALL_ALARM_LATCH_MSK NO_OS_GENMASK(4, 0)
112
113/* ADHV4710_REG_CTRL_REG_14 Bit Definition */
114#define ADHV4710_SHUTDOWN_FLAG_MSK NO_OS_BIT(7)
115#define ADHV4710_OC_SRC_ALARM_MSK NO_OS_BIT(4)
116#define ADHV4710_OC_SNK_ALARM_MSK NO_OS_BIT(3)
117#define ADHV4710_OV_POS_ALARM_MSK NO_OS_BIT(2)
118#define ADHV4710_OV_NEG_ALARM_MSK NO_OS_BIT(1)
119#define ADHV4710_OT_ALARM_MSK NO_OS_BIT(0)
120
121/* ADHV4710_REG_CTRL_25 Bit Definition */
122#define ADHV4710_DIE_REV_MSK NO_OS_GENMASK(3, 0)
123
124/* ADHV4710_REG_CTRL_26 Bit Definition */
125#define ADHV4710_CHIP_ID_MSK NO_OS_GENMASK(7, 0)
126
127#define ADHV4710_INC_DEC_MSK NO_OS_BIT(7)
128#define ADHV4710_INCREASE_I 1
129#define ADHV4710_DECREASE_I 0
130
141
150
163
176
177/* Initialize the device. */
180
181/* Read device register. */
182int adhv4710_read(struct adhv4710_dev *dev, uint8_t reg_addr,
183 int8_t *reg_data);
184
185/* Write device register. */
186int adhv4710_write(struct adhv4710_dev *dev, uint8_t reg_addr,
187 uint8_t reg_data);
188
189/* Update specific register bits. */
190int adhv4710_update_bits(struct adhv4710_dev *dev, uint8_t reg_addr,
191 uint8_t mask, uint8_t reg_data);
192
193/* Get status for a specific bit setting. */
194int adhv4710_get_status(struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t msk,
195 uint8_t *status);
196
197/* Remove the device and release resources. */
198int adhv4710_remove(struct adhv4710_dev *dev);
199
200/* Reset the device using SW reset. */
201int adhv4710_sw_reset(struct adhv4710_dev *dev);
202
203/* Reset the device using HW reset. */
204int adhv4710_hw_reset(struct adhv4710_dev *dev);
205
206/* Clear shutdown latch and re-enable amplifier from shutdown */
208
209/* Shut down the amplifier */
211
212/* Program quiescent current of amplifier */
213int adhv4710_set_quiescent_current(struct adhv4710_dev *dev, uint8_t value,
214 uint8_t direction);
215
216/* Enable source overcurrent protection */
218
219/* Set level of overcurrent source protection */
221 uint8_t level);
222
223/* Enable sink overcurrent protection */
225
226/* Set level of overcurrent sink protection */
228 uint8_t level);
229
230/* Enable overvoltage positive protection */
232
233/* Set level of overvoltage positive protection */
234int adhv4710_set_overvoltage_pos_level(struct adhv4710_dev *dev, uint8_t level);
235
236/* Enable overvoltage negative protection */
238
239/* Set level of overvoltage negative protection */
240int adhv4710_set_overvoltage_neg_level(struct adhv4710_dev *dev, uint8_t level);
241
242/* Enable overtemperature protection */
244
245/* Set level of overtemperature protection */
246int adhv4710_set_overtemperature_level(struct adhv4710_dev *dev, uint8_t level);
247
248/* Version product */
249int adhv4710_version_product(struct adhv4710_dev *dev, uint8_t *data_read);
250
251#endif /* __ADHV4710_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:109
int adhv4710_enable_overvoltage_pos_protection(struct adhv4710_dev *dev)
Enable overvoltage positive protection.
Definition adhv4710.c:407
int adhv4710_enable_overvoltage_neg_protection(struct adhv4710_dev *dev)
Enable overvoltage negative protection.
Definition adhv4710.c:432
int adhv4710_clear_shutdown_latch(struct adhv4710_dev *dev)
Clear shutdown latch and re-enable amplifier from shutdown.
Definition adhv4710.c:308
int adhv4710_write(struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition adhv4710.c:162
int adhv4710_enable_source_overcurrent_protection(struct adhv4710_dev *dev)
Enable source overcurrent protection.
Definition adhv4710.c:356
int adhv4710_set_overtemperature_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overtemperature protection.
Definition adhv4710.c:469
adhv4710_type
Supported device variants.
Definition adhv4710.h:135
@ ID_ADHV4711
Definition adhv4710.h:139
@ ID_ADHV4710
Definition adhv4710.h:137
int adhv4710_set_source_overcurrent_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overcurrent source protection.
Definition adhv4710.c:369
int adhv4710_sw_reset(struct adhv4710_dev *dev)
Reset the device using SW reset.
Definition adhv4710.c:267
int adhv4710_update_bits(struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_data)
Update specific register bits.
Definition adhv4710.c:193
int adhv4710_set_overvoltage_neg_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overvoltage negative protection.
Definition adhv4710.c:445
int adhv4710_set_quiescent_current(struct adhv4710_dev *dev, uint8_t value, uint8_t direction)
Program quiescent current of amplifier.
Definition adhv4710.c:341
int adhv4710_enable_sink_overcurrent_protection(struct adhv4710_dev *dev)
Enable sink overcurrent protection.
Definition adhv4710.c:382
int adhv4710_get_status(struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t msk, uint8_t *status)
Get indicator of settings.
Definition adhv4710.c:218
int adhv4710_version_product(struct adhv4710_dev *dev, uint8_t *data_read)
Version product.
Definition adhv4710.c:482
int adhv4710_shutdown_amplifier(struct adhv4710_dev *dev)
Shutdown the amplifier.
Definition adhv4710.c:327
int adhv4710_hw_reset(struct adhv4710_dev *dev)
Reset the device using HW reset.
Definition adhv4710.c:279
int adhv4710_set_overvoltage_pos_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overvoltage positive protection.
Definition adhv4710.c:420
int adhv4710_set_sink_overcurrent_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overcurrent sink protection.
Definition adhv4710.c:395
int adhv4710_init(struct adhv4710_dev **device, struct adhv4710_init_param init_param)
Initialize the device.
Definition adhv4710.c:65
int adhv4710_remove(struct adhv4710_dev *dev)
Remove the device and release resources.
Definition adhv4710.c:242
int adhv4710_enable_overtemperature_protection(struct adhv4710_dev *dev)
Enable overtemperature protection.
Definition adhv4710.c:457
int adhv4710_read(struct adhv4710_dev *dev, uint8_t reg_addr, int8_t *reg_data)
Read device register.
Definition adhv4710.c:125
Header file of CRC-16 computation.
Header file of Delay functions.
Header file of GPIO Interface.
Header file of IRQ interface.
Print messages helpers.
Header file of SPI Interface.
Header file of Units.
Header file of utility functions.
Per-variant constants.
Definition adhv4710.h:146
uint8_t version_product
Definition adhv4710.h:148
ADHV4710 Device structure.
Definition adhv4710.h:168
struct no_os_spi_desc * spi_desc
Definition adhv4710.h:170
struct no_os_gpio_desc * gpio_reset
Definition adhv4710.h:172
enum adhv4710_type id
Definition adhv4710.h:174
ADHV4710 Device initialization parameters.
Definition adhv4710.h:155
struct no_os_spi_init_param * spi_init
Definition adhv4710.h:157
enum adhv4710_type id
Definition adhv4710.h:161
struct no_os_gpio_init_param * gpio_reset
Definition adhv4710.h:159
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128