no-OS
iio_ad74413r.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef IIO_AD74413R_H
34 #define IIO_AD74413R_H
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include "iio.h"
40 #include "ad74413r.h"
41 #include "iio_trigger.h"
42 
43 /******************************************************************************/
44 /*************************** Types Declarations *******************************/
45 /******************************************************************************/
46 
51  bool enabled;
52  enum ad74413r_diag_mode function;
53 };
54 
55 static const char * const ad74413r_diag_available[] = {
56  [AD74413R_DIAG_AGND] = "agnd",
57  [AD74413R_DIAG_TEMP] = "temp",
58  [AD74413R_DIAG_AVDD] = "avdd",
59  [AD74413R_DIAG_AVSS] = "avss",
60  [AD74413R_DIAG_REFOUT] = "refout",
61  [AD74413R_DIAG_ALDO_5V] = "aldo_5v",
62  [AD74413R_DIAG_ALDO_1V8] = "aldo_1v8",
63  [AD74413R_DIAG_DLDO_1V8] = "dldo_1v8",
64  [AD74413R_DIAG_DVCC] = "dvcc",
65  [AD74413R_DIAG_IOVDD] = "iovdd",
66  [AD74413R_SENSEL_A] = "sensel_a",
67  [AD74413R_SENSEL_B] = "sensel_b",
68  [AD74413R_SENSEL_C] = "sensel_c",
69  [AD74413R_SENSEL_D] = "sensel_d",
70 };
71 
78  uint32_t active_channels;
85 };
86 
96 };
97 
103  uint32_t num_channels;
104 };
105 
106 /******************************************************************************/
107 /************************ Functions Declarations ******************************/
108 /******************************************************************************/
112 
113 #endif
ad74413r_adc_sample
ad74413r_adc_sample
Definition: ad74413r.h:286
AD74413R_DIN_THRESH
#define AD74413R_DIN_THRESH
Definition: ad74413r.h:66
ad74413r_iio_desc::diag_channel_configs
struct ad74413r_diag_channel_config diag_channel_configs[AD74413R_N_DIAG_CHANNELS]
Definition: iio_ad74413r.h:83
ad74413r_iio_desc::iio_dev
struct iio_device * iio_dev
Definition: iio_ad74413r.h:77
AD74413R_DIAG_IOVDD
@ AD74413R_DIAG_IOVDD
Definition: ad74413r.h:251
AD74413R_STEP_500
@ AD74413R_STEP_500
Definition: ad74413r.h:272
no_os_alloc.h
END_ATTRIBUTES_ARRAY
#define END_ATTRIBUTES_ARRAY
Definition: iio_types.h:116
iio_trigger.h
Header file for iio_trigger.
ad74413r_iio_remove
int ad74413r_iio_remove(struct ad74413r_iio_desc *)
Free an iio descriptor.
Definition: iio_ad74413r.c:1582
ad74413r_reg_read_raw
int ad74413r_reg_read_raw(struct ad74413r_desc *desc, uint32_t addr, uint8_t *val)
Read a raw communication frame.
Definition: ad74413r.c:219
ad74413r_clear_errors
int ad74413r_clear_errors(struct ad74413r_desc *desc)
Clear the ALERT_STATUS register.
Definition: ad74413r.c:333
IIO_VAL_INT
@ IIO_VAL_INT
Definition: iio_types.h:50
iio_channel
Struct describing the scan type.
Definition: iio_types.h:168
scan_type::sign
char sign
Definition: iio_types.h:153
AD74413R_THRESHOLD_DAC_RANGE
#define AD74413R_THRESHOLD_DAC_RANGE
Definition: ad74413r.h:153
ad74413r_get_adc_range
int ad74413r_get_adc_range(struct ad74413r_desc *desc, uint32_t ch, uint16_t *val)
Get the ADC measurement range for a specific channel.
Definition: ad74413r.c:511
ad74413r_iio_desc::channel_configs
struct ad74413r_channel_config channel_configs[AD74413R_N_CHANNELS]
Definition: iio_ad74413r.h:80
AD74413R_THRESHOLD_RANGE
#define AD74413R_THRESHOLD_RANGE
Definition: ad74413r.h:155
iio_device::channels
struct iio_channel * channels
Definition: iio_types.h:254
IIO_VAL_FRACTIONAL_LOG2
@ IIO_VAL_FRACTIONAL_LOG2
Definition: iio_types.h:56
iio_device_data::dev
void * dev
Definition: iio_types.h:227
ad74413r_init_param
Initialization parameter for the device descriptor.
Definition: ad74413r.h:296
AD74413R_STEP_120
@ AD74413R_STEP_120
Definition: ad74413r.h:271
ad74413r_init
int ad74413r_init(struct ad74413r_desc **desc, struct ad74413r_init_param *init_param)
Initialize the device structure.
Definition: ad74413r.c:1170
ad74413r_diag_channel_config
Diagnostics channel state.
Definition: iio_ad74413r.h:50
AD74413R_CURRENT_OUT
@ AD74413R_CURRENT_OUT
Definition: ad74413r.h:196
iio_desc
Definition: iio.c:204
iio_ch_info
Structure holding channel attributess.
Definition: iio_types.h:103
ad74413r_set_threshold
int ad74413r_set_threshold(struct ad74413r_desc *desc, uint32_t ch, uint32_t threshold)
Set the threshold, for which a signal would be considered high, when the ADC is running in digital in...
Definition: ad74413r.c:993
no_os_units.h
Header file of Units.
ad74413r_iio_desc::trigger
struct iio_hw_trig * trigger
Definition: iio_ad74413r.h:81
ad74413r_set_adc_conv_seq
int ad74413r_set_adc_conv_seq(struct ad74413r_desc *desc, enum ad74413r_conv_seq status)
Start or stop ADC conversions.
Definition: ad74413r.c:679
iio_trig_disable
int iio_trig_disable(void *trig)
Disable system interrupt which is linked to the given trigger.
Definition: iio_trigger.c:127
IIO_VAL_FRACTIONAL
@ IIO_VAL_FRACTIONAL
Definition: iio_types.h:55
ad74413r_iio_desc::ad74413r_desc
struct ad74413r_desc * ad74413r_desc
Definition: iio_ad74413r.h:76
AD74413R_ADC
@ AD74413R_ADC
Definition: iio_ad74413r.c:88
AD74413R_ADC_RESOLUTION
#define AD74413R_ADC_RESOLUTION
Definition: ad74413r.h:149
ad74413r_decimal
ADC value format.
Definition: ad74413r.h:305
AD74413R_N_DIAG_CHANNELS
#define AD74413R_N_DIAG_CHANNELS
Definition: ad74413r.h:42
iio_ch_info::ch_out
bool ch_out
Definition: iio_types.h:107
ad74413r_diag_channel_config::enabled
bool enabled
Definition: iio_ad74413r.h:51
AD74413R_DIAG_DLDO_1V8
@ AD74413R_DIAG_DLDO_1V8
Definition: ad74413r.h:249
ad74413r_iio_desc::no_of_active_channels
uint8_t no_of_active_channels
Definition: iio_ad74413r.h:79
AD74413R_ADC_CHANNEL
#define AD74413R_ADC_CHANNEL(type, attrs)
Definition: iio_ad74413r.c:50
AD74413R_DIAG_CHANNEL
#define AD74413R_DIAG_CHANNEL(_addr, _type)
Definition: iio_ad74413r.c:59
IIO_RESISTANCE
@ IIO_RESISTANCE
Definition: iio_types.h:72
ad74413r_conv_seq
ad74413r_conv_seq
ADC conversion sequence commands.
Definition: ad74413r.h:220
AD74413R_N_CHANNELS
#define AD74413R_N_CHANNELS
Definition: ad74413r.h:41
AD74413R_CURRENT_IN_EXT_HART
@ AD74413R_CURRENT_IN_EXT_HART
Definition: ad74413r.h:203
ad74413r_channel_map::num_channels
uint32_t num_channels
Definition: iio_ad74413r.h:103
ad74413r_iio_desc_init_param::diag_channel_configs
struct ad74413r_diag_channel_config diag_channel_configs[AD74413R_N_DIAG_CHANNELS]
Definition: iio_ad74413r.h:94
AD74413R_DAC_RESOLUTION
#define AD74413R_DAC_RESOLUTION
Definition: ad74413r.h:147
ad74413r_iio_desc_init_param::trigger
struct iio_hw_trig * trigger
Definition: iio_ad74413r.h:93
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
AD74413R_DIAG_AVSS
@ AD74413R_DIAG_AVSS
Definition: ad74413r.h:245
AD74413R_VOLTAGE_OUT
@ AD74413R_VOLTAGE_OUT
Definition: ad74413r.h:195
AD74413R_SLEW_EN_MASK
#define AD74413R_SLEW_EN_MASK
Definition: ad74413r.h:113
AD74413R_DIN_COMP_CH
#define AD74413R_DIN_COMP_CH(x)
Definition: ad74413r.h:133
AD74413R_DIN_COMP_OUT
#define AD74413R_DIN_COMP_OUT
Definition: ad74413r.h:69
AD74413R_ADC_RESULT
#define AD74413R_ADC_RESULT(x)
Definition: ad74413r.h:70
ad74413r_remove
int ad74413r_remove(struct ad74413r_desc *desc)
Free the device descriptor.
Definition: ad74413r.c:1227
AD74413R_START_CONT
@ AD74413R_START_CONT
Definition: ad74413r.h:223
iio_chan_type
IIO channel types.
iio_channel::ch_out
bool ch_out
Definition: iio_types.h:188
ad74413r_set_diag
int ad74413r_set_diag(struct ad74413r_desc *desc, uint32_t ch, enum ad74413r_diag_mode diag_code)
Set which diagnostic value to be loaded in the DIAG_RESULT register.
Definition: ad74413r.c:882
IIO_SHARED_BY_ALL
@ IIO_SHARED_BY_ALL
Definition: iio_types.h:122
iio_channel::channel
int channel
Definition: iio_types.h:174
iio_device::pre_enable
int32_t(* pre_enable)(void *dev, uint32_t mask)
Definition: iio_types.h:274
iio.h
Header file of iio.
no_os_error.h
Error codes definition.
AD74413R_STEP_64
@ AD74413R_STEP_64
Definition: ad74413r.h:270
ad74413r_reg_write
int ad74413r_reg_write(struct ad74413r_desc *desc, uint32_t addr, uint16_t val)
Write a register's value.
Definition: ad74413r.c:248
AD74413R_DIAG_DVCC
@ AD74413R_DIAG_DVCC
Definition: ad74413r.h:250
iio_attribute::name
const char * name
Definition: iio_types.h:131
AD74413R_ADC_CODE_MAX
#define AD74413R_ADC_CODE_MAX
Definition: ad74413r.h:150
AD74413R_DIAG_RESULT
#define AD74413R_DIAG_RESULT(x)
Definition: ad74413r.h:71
ad74413r_get_adc_single
int ad74413r_get_adc_single(struct ad74413r_desc *desc, uint32_t ch, uint16_t *val, bool is_diag)
Get a single ADC raw value for a specific channel, then power down the ADC.
Definition: ad74413r.c:705
ad74413r_channel_config::function
enum ad74413r_op_mode function
Definition: ad74413r.h:315
iio_trig_enable
int iio_trig_enable(void *trig)
Enable system interrupt which is linked to the given trigger.
Definition: iio_trigger.c:110
AD74413R_SENSEL_C
@ AD74413R_SENSEL_C
Definition: ad74413r.h:254
ad74413r_channel_map
Structure used to store a set of channel specific to an operation mode.
Definition: iio_ad74413r.h:101
ad74413r_iio_init
int ad74413r_iio_init(struct ad74413r_iio_desc **, struct ad74413r_iio_desc_init_param *)
Initializes the AD74413R IIO descriptor.
Definition: iio_ad74413r.c:1531
iio_attribute
Structure holding pointers to show and store functions.
Definition: iio_types.h:129
ad74413r_desc
AD74413r device descriptor.
Definition: ad74413r.h:349
AD74413R_LIN_RATE_150KHZ
@ AD74413R_LIN_RATE_150KHZ
Definition: ad74413r.h:282
ad74413r_iio_desc
Descriptor that stores a iio specific state.
Definition: iio_ad74413r.h:75
AD74413R_SENSEL_D
@ AD74413R_SENSEL_D
Definition: ad74413r.h:255
channel_type
channel_type
Definition: iio_ad74413r.c:87
AD74413R_SENSEL_A
@ AD74413R_SENSEL_A
Definition: ad74413r.h:252
ad74413r.h
Header file of AD74413r Driver.
AD74413R_DIGITAL_INPUT
@ AD74413R_DIGITAL_INPUT
Definition: ad74413r.h:201
IIO_CURRENT
@ IIO_CURRENT
Definition: iio_types.h:66
iio_parse_value
int32_t iio_parse_value(char *buf, enum iio_val fmt, int32_t *val, int32_t *val2)
Definition: iio.c:630
ad74413r_iio_desc_init_param::ad74413r_init_param
struct ad74413r_init_param * ad74413r_init_param
Definition: iio_ad74413r.h:91
ad74413r_get_adc_diag_rate
int ad74413r_get_adc_diag_rate(struct ad74413r_desc *desc, uint32_t ch, enum ad74413r_adc_sample *val)
Get the ADC sample rate for the diagnostics channels.
Definition: ad74413r.c:633
AD74413R_COMP_THRESH_MASK
#define AD74413R_COMP_THRESH_MASK
Definition: ad74413r.h:129
ad74413r_iio_desc_init_param
Init parameter for the iio descriptor.
Definition: iio_ad74413r.h:90
IIO_VOLTAGE
@ IIO_VOLTAGE
Definition: iio_types.h:65
AD74412R
@ AD74412R
Definition: ad74413r.h:176
ad74413r_get_adc_rate
int ad74413r_get_adc_rate(struct ad74413r_desc *desc, uint32_t ch, enum ad74413r_adc_sample *val)
Get the ADC sample rate.
Definition: ad74413r.c:593
AD74413R_SENSE_RESISTOR_OHMS
#define AD74413R_SENSE_RESISTOR_OHMS
Definition: ad74413r.h:169
ad74413r_reg_update
int ad74413r_reg_update(struct ad74413r_desc *desc, uint32_t addr, uint16_t mask, uint16_t val)
Update a register's field.
Definition: ad74413r.c:289
iio_device_data::buffer
struct iio_buffer * buffer
Definition: iio_types.h:228
iio_ad74413r.h
Header file of the IIO AD74413r Driver.
ad74413r_range_to_voltage_range
int ad74413r_range_to_voltage_range(enum ad74413r_adc_range range, uint32_t *val)
Convert the measuring range of the ADC from range enum values to millivolts.
Definition: ad74413r.c:136
AD74413R_CURRENT_IN_LOOP
@ AD74413R_CURRENT_IN_LOOP
Definition: ad74413r.h:199
AD74413R_DIAG_AVDD
@ AD74413R_DIAG_AVDD
Definition: ad74413r.h:244
ad74413r_set_adc_rate
int ad74413r_set_adc_rate(struct ad74413r_desc *desc, uint32_t ch, enum ad74413r_adc_sample val)
Set the ADC sample rate.
Definition: ad74413r.c:613
iio_format_value
int iio_format_value(char *buf, uint32_t len, enum iio_val fmt, int32_t size, int32_t *vals)
Definition: iio.c:686
ad74413r_iio_init
int ad74413r_iio_init(struct ad74413r_iio_desc **iio_desc, struct ad74413r_iio_desc_init_param *init_param)
Initializes the AD74413R IIO descriptor.
Definition: iio_ad74413r.c:1531
AD74413R_RESISTANCE
@ AD74413R_RESISTANCE
Definition: ad74413r.h:200
AD74413R_DAC_CODE_MAX
#define AD74413R_DAC_CODE_MAX
Definition: ad74413r.h:148
ad74413r_adc_get_value
int ad74413r_adc_get_value(struct ad74413r_desc *desc, uint32_t ch, struct ad74413r_decimal *val)
Get the ADC real value, according to the operation mode.
Definition: ad74413r.c:771
iio_ch_info::address
uint32_t address
Definition: iio_types.h:113
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
ad74413r_set_channel_function
int ad74413r_set_channel_function(struct ad74413r_desc *desc, uint32_t ch, enum ad74413r_op_mode ch_func)
Set the operation mode for a specific channel.
Definition: ad74413r.c:421
ad74413r_diag_mode
ad74413r_diag_mode
Possible values to be loaded in the DIAG_RESULT register.
Definition: ad74413r.h:241
AD74413R_CURRENT_IN_EXT
@ AD74413R_CURRENT_IN_EXT
Definition: ad74413r.h:198
iio_device::num_ch
uint16_t num_ch
Definition: iio_types.h:252
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
IIO_TEMP
@ IIO_TEMP
Definition: iio_types.h:69
AD74413R_STOP_PWR_DOWN
@ AD74413R_STOP_PWR_DOWN
Definition: ad74413r.h:224
iio_ch_info::type
enum iio_chan_type type
Definition: iio_types.h:109
no_os_hweight8
unsigned int no_os_hweight8(uint8_t word)
AD74413R_DIAG_ALDO_1V8
@ AD74413R_DIAG_ALDO_1V8
Definition: ad74413r.h:248
ad74413r_set_channel_dac_code
int ad74413r_set_channel_dac_code(struct ad74413r_desc *desc, uint32_t ch, uint16_t dac_code)
Set and load a code for the DAC on a specific channel.
Definition: ad74413r.c:863
ad74413r_iio_desc::active_channels
uint32_t active_channels
Definition: iio_ad74413r.h:78
NULL
#define NULL
Definition: wrapper.h:64
AD74413R_DIAG_TEMP
@ AD74413R_DIAG_TEMP
Definition: ad74413r.h:243
iio_channel::scan_index
int scan_index
Definition: iio_types.h:182
ad74413r_iio_remove
int ad74413r_iio_remove(struct ad74413r_iio_desc *desc)
Free an iio descriptor.
Definition: iio_ad74413r.c:1582
ad74413r_set_diag_channel_enable
int ad74413r_set_diag_channel_enable(struct ad74413r_desc *desc, uint32_t ch, bool status)
Enable conversions on a diagnostic register.
Definition: ad74413r.c:497
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
AD74413R_DAC_RANGE
#define AD74413R_DAC_RANGE
Definition: ad74413r.h:145
iio_device
Structure holding channels and attributes of a device.
Definition: iio_types.h:247
AD74413R_DAC_CHANNEL
#define AD74413R_DAC_CHANNEL(type)
Definition: iio_ad74413r.c:70
ad74413r_channel_config
Device channel state.
Definition: ad74413r.h:313
AD74413R_DIGITAL_INPUT_LOOP
@ AD74413R_DIGITAL_INPUT_LOOP
Definition: ad74413r.h:202
AD74413R_DAC_CODE
#define AD74413R_DAC_CODE(x)
Definition: ad74413r.h:63
AD74413R_LIN_RATE_4KHZ
@ AD74413R_LIN_RATE_4KHZ
Definition: ad74413r.h:280
AD74413R_OUTPUT_CONFIG
#define AD74413R_OUTPUT_CONFIG(x)
Definition: ad74413r.h:62
AD74413R_DIAG_AGND
@ AD74413R_DIAG_AGND
Definition: ad74413r.h:242
AD74413R_DIAG_ASSIGN_MASK
#define AD74413R_DIAG_ASSIGN_MASK(x)
Definition: ad74413r.h:142
AD74413R_HIGH_Z
@ AD74413R_HIGH_Z
Definition: ad74413r.h:194
ad74413r_range_to_voltage_offset
int ad74413r_range_to_voltage_offset(enum ad74413r_adc_range range, int32_t *val)
Convert the measuring range of the ADC from range enum values to millivolts.
Definition: ad74413r.c:163
AD74413R_SENSEL_B
@ AD74413R_SENSEL_B
Definition: ad74413r.h:253
AD74413R_LIN_RATE_64KHZ
@ AD74413R_LIN_RATE_64KHZ
Definition: ad74413r.h:281
AD74413R_DIAG
@ AD74413R_DIAG
Definition: iio_ad74413r.c:89
scan_type
Definition: iio_types.h:151
AD74413R_DIAG_ALDO_5V
@ AD74413R_DIAG_ALDO_5V
Definition: ad74413r.h:247
AD74413R_SLEW_LIN_RATE_MASK
#define AD74413R_SLEW_LIN_RATE_MASK
Definition: ad74413r.h:115
ad74413r_iio_desc_init_param::channel_configs
struct ad74413r_channel_config channel_configs[AD74413R_N_CHANNELS]
Definition: iio_ad74413r.h:92
AD74413R_STEP_1820
@ AD74413R_STEP_1820
Definition: ad74413r.h:273
ad74413r_set_adc_channel_enable
int ad74413r_set_adc_channel_enable(struct ad74413r_desc *desc, uint32_t ch, bool status)
Enable/disable a specific ADC channel.
Definition: ad74413r.c:475
no_os_util.h
Header file of utility functions.
iio_device_data
Definition: iio_types.h:226
ad74413r_channel_map::channels
struct iio_channel * channels
Definition: iio_ad74413r.h:102
AD74413R_LIN_RATE_240KHZ
@ AD74413R_LIN_RATE_240KHZ
Definition: ad74413r.h:283
AD74413R_DIAG_ASSIGN
#define AD74413R_DIAG_ASSIGN
Definition: ad74413r.h:68
AD74413R_CHANNELS
#define AD74413R_CHANNELS(name)
Definition: iio_ad74413r.c:84
iio_hw_trig
IIO hardware trigger structure.
Definition: iio_trigger.h:56
AD74413R_DIAG_REFOUT
@ AD74413R_DIAG_REFOUT
Definition: ad74413r.h:246
IIO_SHARED_BY_DIR
@ IIO_SHARED_BY_DIR
Definition: iio_types.h:121
AD74413R_SLEW_LIN_STEP_MASK
#define AD74413R_SLEW_LIN_STEP_MASK
Definition: ad74413r.h:114
iio_channel::address
unsigned long address
Definition: iio_types.h:180
ad74413r_reg_read
int ad74413r_reg_read(struct ad74413r_desc *desc, uint32_t addr, uint16_t *val)
Read a register's value.
Definition: ad74413r.c:263
AD74413R_CURRENT_IN_LOOP_HART
@ AD74413R_CURRENT_IN_LOOP_HART
Definition: ad74413r.h:204
iio_buffer_push_scan
int iio_buffer_push_scan(struct iio_buffer *buffer, void *data)
Definition: iio.c:1434
IIO_VAL_INT_MULTIPLE
@ IIO_VAL_INT_MULTIPLE
Definition: iio_types.h:54
AD74413R_VOLTAGE_IN
@ AD74413R_VOLTAGE_IN
Definition: ad74413r.h:197
ad74413r_adc_range
ad74413r_adc_range
ADC ranges configurations. These are dependent on the operation mode.
Definition: ad74413r.h:210
ad74413r_iio_desc::conv_state
enum ad74413r_conv_seq conv_state
Definition: iio_ad74413r.h:82
ad74413r_set_adc_diag_rate
int ad74413r_set_adc_diag_rate(struct ad74413r_desc *desc, uint32_t ch, enum ad74413r_adc_sample val)
Set the ADC sample rate for the diagnostics channels.
Definition: ad74413r.c:653