no-OS
Loading...
Searching...
No Matches
iio_powrms.h File Reference

Header file for IIO POWRMS example. More...

#include "iio_app.h"
#include "no_os_uart.h"
#include "no_os_circular_buffer.h"
#include "powrms_data_processing.h"
Include dependency graph for iio_powrms.h:

Macros

#define INTC_DEVICE_ID   1
 
#define IIO_BUFF_TYPE   int32_t
 
#define TOTAL_PWM_CHANNELS   0
 
#define POWRMS_CIRC_BUFF_SIZE   512
 
#define MAX_SIZE_BASE_ADDR   (TOTAL_PWM_CHANNELS > 0 ? TOTAL_PWM_CHANNELS * POWRMS_CIRC_BUFF_SIZE : 1)
 
#define BUFFER_VAL_PRECISSION   1000.0
 
#define FREQUENCY_RANGES_BUFFER_SIZE   256
 
#define IIO_CH_V_IN_CORRECTED   0
 
#define IIO_CH_V_OUT_CORRECTED   1
 
#define IIO_CH_TEMPERATURE   2
 
#define IIO_CH_V_IN_RAW   3
 
#define IIO_CH_V_OUT_RAW   4
 
#define IIO_CH_P_FORWARD   5
 
#define IIO_CH_P_REVERSE   6
 
#define IIO_CH_PRECISION_ARRAY   7
 
#define IIO_CH_POLY_CALIB_5000MHZ   8
 
#define IIO_CH_POLY_CALIB_5000MHZ_REVERSE   9
 
#define IIO_CH_V_DIFF_RAW   10
 
#define IIO_ATTR_SCALE   0
 
#define IIO_ATTR_OFFSET   1
 
#define IIO_ATTR_PRECISION_FACTOR   2
 
#define IIO_ATTR_ARRAY_SIZE   3
 
#define IIO_POWRMS_NUM_CHANNELS   11
 
#define IIO_SCAN_REALBITS   32
 
#define IIO_SCAN_STORAGEBITS   32
 
#define IIO_SCAN_SHIFT   0
 
#define VOLTAGE_TO_MILLIVOLT_SCALE   1000
 
#define ADC_OFFSET_VALUE   0.0
 
#define FLOAT_PRECISION_DIGITS   3
 
#define FREQ_RANGE_VALUES_PER_RANGE   28
 
#define TEMP_COEFFS_PER_RANGE   3
 
#define MAX_FREQ_RANGE_INDEX   10
 
#define MIN_FREQ_RANGE_INDEX   0
 
#define CALIB_VALUES_BUFFER_SIZE   256
 
#define TEMP_VALUES_BUFFER_SIZE   150
 
#define MIN_REMAINING_BUFFER_SIZE   20
 
#define MIN_COMMA_BUFFER_SIZE   1
 
#define COMMA_SEPARATOR_SIZE   1
 
#define IIO_ERROR_INVALID_INPUT   -1
 
#define IIO_SUCCESS   0
 
#define CALIBRATION_ENABLED   1
 
#define CALIBRATION_DISABLED   0
 
#define DEV_MODE_TRIGGER_VALUE   1
 

Functions

int powrms_buffers_init (void)
 
void powrms_buffers_cleanup (void)
 
int powrms_push_vin0 (float value)
 
int powrms_push_vin1 (float value)
 
int powrms_push_p_fwd (float value)
 
int powrms_push_p_rev (float value)
 
int powrms_get_latest_vin0 (float *value)
 
int powrms_get_latest_vin1 (float *value)
 
int powrms_get_latest_p_fwd (float *value)
 
int powrms_get_latest_p_rev (float *value)
 
int powrms_set_precision_value (int index, float value)
 
float powrms_get_precision_value (int index)
 
int powrms_set_precision_array (const float *values, int count)
 
int powrms_get_precision_array (float *values, int max_count)
 
int powrms_set_precision_value_raw (int index, int32_t raw_value)
 
int32_t powrms_get_precision_value_raw (int index)
 
int powrms_set_precision_array_raw (const int32_t *raw_values, int count)
 
int powrms_get_precision_array_raw (int32_t *raw_values, int max_count)
 
int powrms_set_precision_value_reverse (int index, float value)
 
float powrms_get_precision_value_reverse (int index)
 
int powrms_set_precision_array_reverse (const float *values, int count)
 
int powrms_get_precision_array_reverse (float *values, int max_count)
 
int powrms_set_precision_value_raw_reverse (int index, int32_t raw_value)
 
int32_t powrms_get_precision_value_raw_reverse (int index)
 
int powrms_set_precision_array_raw_reverse (const int32_t *raw_values, int count)
 
int powrms_get_precision_array_raw_reverse (int32_t *raw_values, int max_count)
 
int powrms_set_frequency_range (int index, uint32_t frequency_MHz)
 
uint32_t powrms_get_frequency_range (int index)
 
int powrms_set_frequency_ranges (const uint32_t *frequencies, int count)
 
int powrms_get_frequency_ranges (uint32_t *frequencies, int max_count)
 

Variables

struct iio_device powrms_iio_descriptor
 
IIO_BUFF_TYPE iio_data_buffer_loc [MAX_SIZE_BASE_ADDR]
 
struct no_os_circular_buffer * powrms_vin0_buffer
 
struct no_os_circular_buffer * powrms_vin1_buffer
 
struct no_os_circular_buffer * powrms_p_fwd_buffer
 
struct no_os_circular_buffer * powrms_p_rev_buffer
 

Detailed Description

Header file for IIO POWRMS example.

Author
rober.nosp@m.t.bu.nosp@m.dai@a.nosp@m.nalo.nosp@m.g.com

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.

Macro Definition Documentation

◆ ADC_OFFSET_VALUE

#define ADC_OFFSET_VALUE   0.0

◆ BUFFER_VAL_PRECISSION

#define BUFFER_VAL_PRECISSION   1000.0

◆ CALIB_VALUES_BUFFER_SIZE

#define CALIB_VALUES_BUFFER_SIZE   256

◆ CALIBRATION_DISABLED

#define CALIBRATION_DISABLED   0

◆ CALIBRATION_ENABLED

#define CALIBRATION_ENABLED   1

◆ COMMA_SEPARATOR_SIZE

#define COMMA_SEPARATOR_SIZE   1

◆ DEV_MODE_TRIGGER_VALUE

#define DEV_MODE_TRIGGER_VALUE   1

◆ FLOAT_PRECISION_DIGITS

#define FLOAT_PRECISION_DIGITS   3

◆ FREQ_RANGE_VALUES_PER_RANGE

#define FREQ_RANGE_VALUES_PER_RANGE   28

◆ FREQUENCY_RANGES_BUFFER_SIZE

#define FREQUENCY_RANGES_BUFFER_SIZE   256

◆ IIO_ATTR_ARRAY_SIZE

#define IIO_ATTR_ARRAY_SIZE   3

◆ IIO_ATTR_OFFSET

#define IIO_ATTR_OFFSET   1

◆ IIO_ATTR_PRECISION_FACTOR

#define IIO_ATTR_PRECISION_FACTOR   2

◆ IIO_ATTR_SCALE

#define IIO_ATTR_SCALE   0

◆ IIO_BUFF_TYPE

#define IIO_BUFF_TYPE   int32_t

◆ IIO_CH_P_FORWARD

#define IIO_CH_P_FORWARD   5

◆ IIO_CH_P_REVERSE

#define IIO_CH_P_REVERSE   6

◆ IIO_CH_POLY_CALIB_5000MHZ

#define IIO_CH_POLY_CALIB_5000MHZ   8

◆ IIO_CH_POLY_CALIB_5000MHZ_REVERSE

#define IIO_CH_POLY_CALIB_5000MHZ_REVERSE   9

◆ IIO_CH_PRECISION_ARRAY

#define IIO_CH_PRECISION_ARRAY   7

◆ IIO_CH_TEMPERATURE

#define IIO_CH_TEMPERATURE   2

◆ IIO_CH_V_DIFF_RAW

#define IIO_CH_V_DIFF_RAW   10

◆ IIO_CH_V_IN_CORRECTED

#define IIO_CH_V_IN_CORRECTED   0

◆ IIO_CH_V_IN_RAW

#define IIO_CH_V_IN_RAW   3

◆ IIO_CH_V_OUT_CORRECTED

#define IIO_CH_V_OUT_CORRECTED   1

◆ IIO_CH_V_OUT_RAW

#define IIO_CH_V_OUT_RAW   4

◆ IIO_ERROR_INVALID_INPUT

#define IIO_ERROR_INVALID_INPUT   -1

◆ IIO_POWRMS_NUM_CHANNELS

#define IIO_POWRMS_NUM_CHANNELS   11

◆ IIO_SCAN_REALBITS

#define IIO_SCAN_REALBITS   32

◆ IIO_SCAN_SHIFT

#define IIO_SCAN_SHIFT   0

◆ IIO_SCAN_STORAGEBITS

#define IIO_SCAN_STORAGEBITS   32

◆ IIO_SUCCESS

#define IIO_SUCCESS   0

◆ INTC_DEVICE_ID

#define INTC_DEVICE_ID   1

◆ MAX_FREQ_RANGE_INDEX

#define MAX_FREQ_RANGE_INDEX   10

◆ MAX_SIZE_BASE_ADDR

#define MAX_SIZE_BASE_ADDR   (TOTAL_PWM_CHANNELS > 0 ? TOTAL_PWM_CHANNELS * POWRMS_CIRC_BUFF_SIZE : 1)

◆ MIN_COMMA_BUFFER_SIZE

#define MIN_COMMA_BUFFER_SIZE   1

◆ MIN_FREQ_RANGE_INDEX

#define MIN_FREQ_RANGE_INDEX   0

◆ MIN_REMAINING_BUFFER_SIZE

#define MIN_REMAINING_BUFFER_SIZE   20

◆ POWRMS_CIRC_BUFF_SIZE

#define POWRMS_CIRC_BUFF_SIZE   512

◆ TEMP_COEFFS_PER_RANGE

#define TEMP_COEFFS_PER_RANGE   3

◆ TEMP_VALUES_BUFFER_SIZE

#define TEMP_VALUES_BUFFER_SIZE   150

◆ TOTAL_PWM_CHANNELS

#define TOTAL_PWM_CHANNELS   0

◆ VOLTAGE_TO_MILLIVOLT_SCALE

#define VOLTAGE_TO_MILLIVOLT_SCALE   1000

Function Documentation

◆ powrms_buffers_cleanup()

void powrms_buffers_cleanup ( void )

◆ powrms_buffers_init()

int powrms_buffers_init ( void )

◆ powrms_get_frequency_range()

uint32_t powrms_get_frequency_range ( int index)

◆ powrms_get_frequency_ranges()

int powrms_get_frequency_ranges ( uint32_t * frequencies,
int max_count )

◆ powrms_get_latest_p_fwd()

int powrms_get_latest_p_fwd ( float * value)

◆ powrms_get_latest_p_rev()

int powrms_get_latest_p_rev ( float * value)

◆ powrms_get_latest_vin0()

int powrms_get_latest_vin0 ( float * value)

◆ powrms_get_latest_vin1()

int powrms_get_latest_vin1 ( float * value)

◆ powrms_get_precision_array()

int powrms_get_precision_array ( float * values,
int max_count )

◆ powrms_get_precision_array_raw()

int powrms_get_precision_array_raw ( int32_t * raw_values,
int max_count )

◆ powrms_get_precision_array_raw_reverse()

int powrms_get_precision_array_raw_reverse ( int32_t * raw_values,
int max_count )

◆ powrms_get_precision_array_reverse()

int powrms_get_precision_array_reverse ( float * values,
int max_count )

◆ powrms_get_precision_value()

float powrms_get_precision_value ( int index)

◆ powrms_get_precision_value_raw()

int32_t powrms_get_precision_value_raw ( int index)

◆ powrms_get_precision_value_raw_reverse()

int32_t powrms_get_precision_value_raw_reverse ( int index)

◆ powrms_get_precision_value_reverse()

float powrms_get_precision_value_reverse ( int index)

◆ powrms_push_p_fwd()

int powrms_push_p_fwd ( float value)

◆ powrms_push_p_rev()

int powrms_push_p_rev ( float value)

◆ powrms_push_vin0()

int powrms_push_vin0 ( float value)

◆ powrms_push_vin1()

int powrms_push_vin1 ( float value)

◆ powrms_set_frequency_range()

int powrms_set_frequency_range ( int index,
uint32_t frequency_MHz )

◆ powrms_set_frequency_ranges()

int powrms_set_frequency_ranges ( const uint32_t * frequencies,
int count )

◆ powrms_set_precision_array()

int powrms_set_precision_array ( const float * values,
int count )

◆ powrms_set_precision_array_raw()

int powrms_set_precision_array_raw ( const int32_t * raw_values,
int count )

◆ powrms_set_precision_array_raw_reverse()

int powrms_set_precision_array_raw_reverse ( const int32_t * raw_values,
int count )

◆ powrms_set_precision_array_reverse()

int powrms_set_precision_array_reverse ( const float * values,
int count )

◆ powrms_set_precision_value()

int powrms_set_precision_value ( int index,
float value )

◆ powrms_set_precision_value_raw()

int powrms_set_precision_value_raw ( int index,
int32_t raw_value )

◆ powrms_set_precision_value_raw_reverse()

int powrms_set_precision_value_raw_reverse ( int index,
int32_t raw_value )

◆ powrms_set_precision_value_reverse()

int powrms_set_precision_value_reverse ( int index,
float value )

Variable Documentation

◆ iio_data_buffer_loc

IIO_BUFF_TYPE iio_data_buffer_loc[MAX_SIZE_BASE_ADDR]
extern

◆ powrms_iio_descriptor

struct iio_device powrms_iio_descriptor
extern

◆ powrms_p_fwd_buffer

struct no_os_circular_buffer* powrms_p_fwd_buffer
extern

◆ powrms_p_rev_buffer

struct no_os_circular_buffer* powrms_p_rev_buffer
extern

◆ powrms_vin0_buffer

struct no_os_circular_buffer* powrms_vin0_buffer
extern

◆ powrms_vin1_buffer

struct no_os_circular_buffer* powrms_vin1_buffer
extern