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
59/* ADHV4710 Register Map */
60/* 8 BIT REGISTERS */
61#define ADHV4710_REG_CTRL_REG_00 0x000
62#define ADHV4710_REG_CTRL_REG_03 0x003
63#define ADHV4710_REG_CTRL_REG_04 0x004
64#define ADHV4710_REG_CTRL_REG_08 0x008
65#define ADHV4710_REG_CTRL_REG_09 0x009
66#define ADHV4710_REG_CTRL_REG_10 0x00A
67#define ADHV4710_REG_CTRL_REG_11 0x00B
68#define ADHV4710_REG_CTRL_REG_12 0x00C
69#define ADHV4710_REG_CTRL_REG_13 0x00D
70#define ADHV4710_REG_CTRL_REG_14 0x00E
71#define ADHV4710_REG_CTRL_REG_25 0x019
72#define ADHV4710_REG_CTRL_REG_26 0x01A
73
74/* ADHV4710_REG_CTRL_REG_00 Bit Definition */
75#define ADHV4710_HV_RESET_MSK NO_OS_BIT(7)
76#define ADHV4710_HV_SLEEP_MSK NO_OS_BIT(4)
77
78/* ADHV4710_REG_CTRL_REG_03 Bit Definition */
79#define ADHV4710_SOFT_RESET_MSK NO_OS_BIT(0)
80
81/* ADHV4710_REG_CTRL_REG_04 Bit Definition */
82#define ADHV4710_SET_IQ_MSK NO_OS_GENMASK(7, 0)
83
84/* ADHV4710_REG_CTRL_REG_08 Bit Definition */
85#define ADHV4710_OC_SRC_ARM_MSK NO_OS_BIT(7)
86#define ADEHV4710_OC_SRC_LIMIT_MSK NO_OS_GENMASK(6, 0)
87
88/* ADHV4710_REG_CTRL_REG_09 Bit Definition */
89#define ADHV4710_OC_SNK_ARM_MSK NO_OS_BIT(7)
90#define ADEHV4710_OC_SNK_LIMIT_MSK NO_OS_GENMASK(6, 0)
91
92/* ADHV4710_REG_CTRL_REG_10 Bit Definition */
93#define ADHV4710_OV_POS_ARM_MSK NO_OS_BIT(7)
94#define ADEHV4710_OV_POS_LIMIT_MSK NO_OS_GENMASK(6, 0)
95
96/* ADHV4710_REG_CTRL_REG_011 Bit Definition */
97#define ADHV4710_OV_NEG_ARM_MSK NO_OS_BIT(7)
98#define ADEHV4710_OV_NEG_LIMIT_MSK NO_OS_GENMASK(6, 0)
99
100/* ADHV4710_REG_CTRL_REG_12 Bit Definition */
101#define ADHV4710_OT_ARM_MSK NO_OS_BIT(7)
102#define ADEHV4710_OT_LIMIT_MSK NO_OS_GENMASK(6, 0)
103
104/* ADHV4710_REG_CTRL_REG_13 Bit Definition */
105#define ADHV4710_OC_SRC_ALARM_LATCH_MSK NO_OS_BIT(4)
106#define ADHV4710_OC_SNK_ALARM_LATCH_MSK NO_OS_BIT(3)
107#define ADHV4710_OV_POS_ALARM_LATCH_MSK NO_OS_BIT(2)
108#define ADHV4710_OV_NEG_ALARM_LATCH_MSK NO_OS_BIT(1)
109#define ADHV4710_OT_ALARM_LATCH_MSK NO_OS_BIT(0)
110#define ADHV4710_ALL_ALARM_LATCH_MSK NO_OS_GENMASK(4, 0)
111
112/* ADHV4710_REG_CTRL_REG_14 Bit Definition */
113#define ADHV4710_SHUTDOWN_FLAG_MSK NO_OS_BIT(7)
114#define ADHV4710_OC_SRC_ALARM_MSK NO_OS_BIT(4)
115#define ADHV4710_OC_SNK_ALARM_MSK NO_OS_BIT(3)
116#define ADHV4710_OV_POS_ALARM_MSK NO_OS_BIT(2)
117#define ADHV4710_OV_NEG_ALARM_MSK NO_OS_BIT(1)
118#define ADHV4710_OT_ALARM_MSK NO_OS_BIT(0)
119
120/* ADHV4710_REG_CTRL_25 Bit Definition */
121#define ADHV4710_DIE_REV_MSK NO_OS_GENMASK(3, 0)
122
123/* ADHV4710_REG_CTRL_26 Bit Definition */
124#define ADHV4710_CHIP_ID_MSK NO_OS_GENMASK(7, 0)
125
126#define ADHV4710_INC_DEC_MSK NO_OS_BIT(7)
127#define ADHV4710_INCREASE_I 1
128#define ADHV4710_DECREASE_I 0
129
140
151
152/* Initialize the device. */
155
156/* Read device register. */
157int adhv4710_read(struct adhv4710_dev *dev, uint8_t reg_addr,
158 int8_t *reg_data);
159
160/* Write device register. */
161int adhv4710_write(struct adhv4710_dev *dev, uint8_t reg_addr,
162 uint8_t reg_data);
163
164/* Update specific register bits. */
165int adhv4710_update_bits(struct adhv4710_dev *dev, uint8_t reg_addr,
166 uint8_t mask, uint8_t reg_data);
167
168/* Get status for a specific bit setting. */
169int adhv4710_get_status(struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t msk,
170 uint8_t *status);
171
172/* Remove the device and release resources. */
173int adhv4710_remove(struct adhv4710_dev *dev);
174
175/* Reset the device using SW reset. */
176int adhv4710_sw_reset(struct adhv4710_dev *dev);
177
178/* Reset the device using HW reset. */
179int adhv4710_hw_reset(struct adhv4710_dev *dev);
180
181/* Clear shutdown latch and re-enable amplifier from shutdown */
183
184/* Shut down the amplifier */
186
187/* Program quiescent current of amplifier */
188int adhv4710_set_quiescent_current(struct adhv4710_dev *dev, uint8_t value,
189 uint8_t direction);
190
191/* Enable source overcurrent protection */
193
194/* Set level of overcurrent source protection */
196 uint8_t level);
197
198/* Enable sink overcurrent protection */
200
201/* Set level of overcurrent sink protection */
203 uint8_t level);
204
205/* Enable overvoltage positive protection */
207
208/* Set level of overvoltage positive protection */
209int adhv4710_set_overvoltage_pos_level(struct adhv4710_dev *dev, uint8_t level);
210
211/* Enable overvoltage negative protection */
213
214/* Set level of overvoltage negative protection */
215int adhv4710_set_overvoltage_neg_level(struct adhv4710_dev *dev, uint8_t level);
216
217/* Enable overtemperature protection */
219
220/* Set level of overtemperature protection */
221int adhv4710_set_overtemperature_level(struct adhv4710_dev *dev, uint8_t level);
222
223/* Version product */
224int adhv4710_version_product(struct adhv4710_dev *dev, uint8_t *data_read);
225
226#endif /* __ADHV4710_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int adhv4710_enable_overvoltage_pos_protection(struct adhv4710_dev *dev)
Enable overvoltage positive protection.
Definition adhv4710.c:391
int adhv4710_enable_overvoltage_neg_protection(struct adhv4710_dev *dev)
Enable overvoltage negative protection.
Definition adhv4710.c:416
int adhv4710_clear_shutdown_latch(struct adhv4710_dev *dev)
Clear shutdown latch and re-enable amplifier from shutdown.
Definition adhv4710.c:292
int adhv4710_write(struct adhv4710_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition adhv4710.c:146
int adhv4710_enable_source_overcurrent_protection(struct adhv4710_dev *dev)
Enable source overcurrent protection.
Definition adhv4710.c:340
int adhv4710_set_overtemperature_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overtemperature protection.
Definition adhv4710.c:453
int adhv4710_set_source_overcurrent_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overcurrent source protection.
Definition adhv4710.c:353
int adhv4710_sw_reset(struct adhv4710_dev *dev)
Reset the device using SW reset.
Definition adhv4710.c:251
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:177
int adhv4710_set_overvoltage_neg_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overvoltage negative protection.
Definition adhv4710.c:429
int adhv4710_set_quiescent_current(struct adhv4710_dev *dev, uint8_t value, uint8_t direction)
Program quiescent current of amplifier.
Definition adhv4710.c:325
int adhv4710_enable_sink_overcurrent_protection(struct adhv4710_dev *dev)
Enable sink overcurrent protection.
Definition adhv4710.c:366
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:202
int adhv4710_version_product(struct adhv4710_dev *dev, uint8_t *data_read)
Version product.
Definition adhv4710.c:466
int adhv4710_shutdown_amplifier(struct adhv4710_dev *dev)
Shutdown the amplifier.
Definition adhv4710.c:311
int adhv4710_hw_reset(struct adhv4710_dev *dev)
Reset the device using HW reset.
Definition adhv4710.c:263
int adhv4710_set_overvoltage_pos_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overvoltage positive protection.
Definition adhv4710.c:404
int adhv4710_set_sink_overcurrent_level(struct adhv4710_dev *dev, uint8_t level)
Set level of overcurrent sink protection.
Definition adhv4710.c:379
int adhv4710_init(struct adhv4710_dev **device, struct adhv4710_init_param init_param)
Initialize the device.
Definition adhv4710.c:59
int adhv4710_remove(struct adhv4710_dev *dev)
Remove the device and release resources.
Definition adhv4710.c:226
int adhv4710_enable_overtemperature_protection(struct adhv4710_dev *dev)
Enable overtemperature protection.
Definition adhv4710.c:441
int adhv4710_read(struct adhv4710_dev *dev, uint8_t reg_addr, int8_t *reg_data)
Read device register.
Definition adhv4710.c:109
Error macro definition for ARM Compiler.
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.
ADHV4710 Device structure.
Definition adhv4710.h:145
struct no_os_spi_desc * spi_desc
Definition adhv4710.h:147
struct no_os_gpio_desc * gpio_reset
Definition adhv4710.h:149
ADHV4710 Device initialization parameters.
Definition adhv4710.h:134
struct no_os_spi_init_param * spi_init
Definition adhv4710.h:136
struct no_os_gpio_init_param * gpio_reset
Definition adhv4710.h:138
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