precision-converters-firmware
|
Implementation of AD4170 IIO application interfaces. More...
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "ad4170_iio.h"
#include "app_config.h"
#include "ad4170_regs.h"
#include "ad4170_support.h"
#include "ad4170_temperature_sensor.h"
#include "no_os_error.h"
#include "no_os_irq.h"
#include "no_os_delay.h"
#include "no_os_util.h"
#include "common.h"
#include "iio_trigger.h"
#include "no_os_gpio.h"
#include "stm32_tdm_support.h"
#include "pl_gui_views.h"
#include "pl_gui_events.h"
#include "adi_fft.h"
Classes | |
struct | adc_calibration_configs |
struct | ad4170_cached_reg |
Cached register. More... | |
Macros | |
#define | LOADCELL_SAMPLES_COUNT 10 |
#define | CJC_CHANNEL 2 |
#define | NUM_OF_IIO_DEVICES 1 |
#define | IIO_TRIGGER_NAME "ad4170_iio_trigger" |
#define | CHN_REAL_BITS (ADC_RESOLUTION) |
#define | CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8) |
#define | LED_TOGGLE_TIME (500) |
#define | LED_TOGGLE_TICK_CNTR (LED_TOGGLE_TIME / (TICKER_INTERRUPT_PERIOD_uSEC / 1000)) |
#define | BYTE_SIZE (uint32_t)8 |
#define | BYTE_MASK (uint32_t)0xff |
#define | BUF_READ_TIMEOUT 0xffffffff |
#define | DATA_BUFFER_SIZE (16384) |
#define | APP_LOCAL_BACKEND_BUF_SIZE 0x1000 |
#define | N_REGISTERS_CACHED ADC_REGISTER_COUNT |
#define | MAX_LOCAL_BUF_SIZE 8000 |
#define | MAX_DMA_NDTR (no_os_min(65535, MAX_LOCAL_BUF_SIZE)) |
#define | AD4170_IIO_VOLT_CH(nm, chn) |
#define | AD4170_IIO_TEMP_CH(nm, chn) |
Enumerations | |
enum | ad4170_attr_id { IIO_RAW_ATTR_ID , IIO_SCALE_ATTR_ID , IIO_OFFSET_ATTR_ID , INTERNAL_CALIB_ID , SYSTEM_CALIB_ID , LOADCELL_OFFSET_CALIB_ID , LOADCELL_GAIN_CALIB_ID , FILTER_ATTR_ID , REF_SELECT_ATTR_ID } |
enum | calibration_state { FULL_SCALE_CALIB_STATE , ZERO_SCALE_CALIB_STATE , CALIB_COMPLETE_STATE } |
enum | calib_status { CALIB_NOT_DONE , CALIB_IN_PROGRESS , CALIB_DONE , CALIB_ERROR , CALIB_SKIPPED } |
Functions | |
int32_t | perform_adc_calibration (uint8_t chn, enum ad4170_mode calib_mode) |
Perform the ADC internal/system calibration. | |
int32_t | debug_reg_read (void *dev, uint32_t reg, uint32_t *readval) |
Read the debug register value. | |
int32_t | debug_reg_write (void *dev, uint32_t reg, uint32_t writeval) |
Write into the debug register. | |
int | ad4170_cache_register_values (void) |
Cache register values modified by attributes. | |
int | ad4170_restore_cache (void) |
Restore cached register values. | |
int32_t | iio_ad4170_trigger_handler (struct iio_device_data *iio_dev_data) |
Push data into IIO buffer when trigger handler IRQ is invoked. | |
void | ticker_callback (void *ctx) |
This is an ISR (Interrupt Service Routine) for Ticker object. | |
void | ad4170_configure_filter_params (void) |
Configure filter parameters according to active device chosen. | |
int32_t | ad4170_iio_initialize (void) |
Initialize the IIO interface for AD4170 IIO device. | |
void | ad4170_iio_event_handler (void) |
Run the AD4170 IIO event handler. | |
Variables | |
struct ad4170_dev * | p_ad4170_dev_inst = NULL |
struct iio_device * | p_iio_ad4170_dev |
struct iio_device_init | iio_device_init_params [NUM_OF_IIO_DEVICES] |
uint8_t | num_of_active_channels |
struct iio_device_data * | ad4170_iio_dev_data |
volatile bool | tdm_read_started = false |
bool | data_capture_operation = false |
struct pl_gui_views | pocket_lab_gui_views [] |
struct adi_fft_init_params | fft_init_params |
struct pl_gui_device_param | pl_gui_device_params |
struct pl_gui_desc * | pocket_lab_gui_desc |
struct stm32_spi_init_param * | spi_init_param |
volatile struct iio_device_data * | iio_dev_data_g |
uint32_t | nb_of_samples_g |
int32_t | data_read |
volatile bool | dma_config_updated = false |
volatile bool | ad4170_dma_buff_full = false |
volatile uint32_t * | buff_start_addr |
uint8_t | local_buf [MAX_LOCAL_BUF_SIZE] |
struct ad4170_cached_reg | reg_values [N_REGISTERS_CACHED] |
uint8_t | read_reg_id = 0 |
struct iio_attribute | channel_input_attributes [] |
Implementation of AD4170 IIO application interfaces.
This module acts as an interface for AD4170 IIO application
Copyright (c) 2021-2025 Analog Devices, Inc. All rights reserved.
This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.
#define AD4170_IIO_TEMP_CH | ( | nm, | |
chn | |||
) |
#define AD4170_IIO_VOLT_CH | ( | nm, | |
chn | |||
) |
#define APP_LOCAL_BACKEND_BUF_SIZE 0x1000 |
#define BUF_READ_TIMEOUT 0xffffffff |
#define BYTE_MASK (uint32_t)0xff |
#define BYTE_SIZE (uint32_t)8 |
#define CHN_REAL_BITS (ADC_RESOLUTION) |
#define CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8) |
#define CJC_CHANNEL 2 |
#define DATA_BUFFER_SIZE (16384) |
#define IIO_TRIGGER_NAME "ad4170_iio_trigger" |
#define LED_TOGGLE_TICK_CNTR (LED_TOGGLE_TIME / (TICKER_INTERRUPT_PERIOD_uSEC / 1000)) |
#define LED_TOGGLE_TIME (500) |
#define LOADCELL_SAMPLES_COUNT 10 |
#define MAX_DMA_NDTR (no_os_min(65535, MAX_LOCAL_BUF_SIZE)) |
#define MAX_LOCAL_BUF_SIZE 8000 |
#define N_REGISTERS_CACHED ADC_REGISTER_COUNT |
#define NUM_OF_IIO_DEVICES 1 |
enum ad4170_attr_id |
enum calib_status |
enum calibration_state |
int ad4170_cache_register_values | ( | void | ) |
Cache register values modified by attributes.
void ad4170_configure_filter_params | ( | void | ) |
Configure filter parameters according to active device chosen.
None |
void ad4170_iio_event_handler | ( | void | ) |
Run the AD4170 IIO event handler.
This function monitors the new IIO client event
int32_t ad4170_iio_initialize | ( | void | ) |
Initialize the IIO interface for AD4170 IIO device.
int ad4170_restore_cache | ( | void | ) |
Restore cached register values.
int32_t debug_reg_read | ( | void * | dev, |
uint32_t | reg, | ||
uint32_t * | readval | ||
) |
Read the debug register value.
dev- | Pointer to IIO device instance |
reg- | Register address to read from |
readval- | Pointer to variable to read data into |
int32_t debug_reg_write | ( | void * | dev, |
uint32_t | reg, | ||
uint32_t | writeval | ||
) |
Write into the debug register.
dev- | Pointer to IIO device instance |
reg- | Register address to write into |
writeval- | Register value to write |
int32_t iio_ad4170_trigger_handler | ( | struct iio_device_data * | iio_dev_data | ) |
Push data into IIO buffer when trigger handler IRQ is invoked.
iio_dev_data[in] | - IIO device data instance |
int32_t perform_adc_calibration | ( | uint8_t | chn, |
enum ad4170_mode | calib_mode | ||
) |
Perform the ADC internal/system calibration.
chn[in] | - ADC channel |
calib_mode[in] | - Calibration mode |
void ticker_callback | ( | void * | ctx | ) |
This is an ISR (Interrupt Service Routine) for Ticker object.
ctx[in] | - Callback context (unused) |
This function is periodically called based on the time period configured during Ticker instance creation/initialization.
volatile bool ad4170_dma_buff_full = false |
struct iio_device_data* ad4170_iio_dev_data |
volatile uint32_t* buff_start_addr |
struct iio_attribute channel_input_attributes[] |
bool data_capture_operation = false |
int32_t data_read |
volatile bool dma_config_updated = false |
struct adi_fft_init_params fft_init_params |
volatile struct iio_device_data* iio_dev_data_g |
struct iio_device_init iio_device_init_params[NUM_OF_IIO_DEVICES] |
uint8_t local_buf[MAX_LOCAL_BUF_SIZE] |
uint32_t nb_of_samples_g |
uint8_t num_of_active_channels |
struct ad4170_dev* p_ad4170_dev_inst = NULL |
Pointer to the struct representing the AD4170 IIO device
struct iio_device* p_iio_ad4170_dev |
struct pl_gui_device_param pl_gui_device_params |
struct pl_gui_desc* pocket_lab_gui_desc |
struct pl_gui_views pocket_lab_gui_views[] |
uint8_t read_reg_id = 0 |
struct ad4170_cached_reg reg_values[N_REGISTERS_CACHED] |
struct stm32_spi_init_param* spi_init_param |
volatile bool tdm_read_started = false |