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 "common.h"
#include "iio_trigger.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 (131072) |
#define | N_REGISTERS_CACHED ADC_REGISTER_COUNT |
#define | AD4170_IIO_VOLT_CH(nm, chn) |
#define | AD4170_IIO_TEMP_CH(nm, chn) |
Functions | |
int32_t | perform_adc_calibration (uint8_t chn, enum ad4170_mode calib_mode) |
Perform the ADC internal/system calibration. More... | |
int32_t | debug_reg_read (void *dev, uint32_t reg, uint32_t *readval) |
Read the debug register value. More... | |
int32_t | debug_reg_write (void *dev, uint32_t reg, uint32_t writeval) |
Write into the debug register. More... | |
int | ad4170_cache_register_values (void) |
Cache register values modified by attributes. More... | |
int | ad4170_restore_cache (void) |
Restore cached register values. More... | |
int32_t | iio_ad4170_trigger_handler (struct iio_device_data *iio_dev_data) |
Push data into IIO buffer when trigger handler IRQ is invoked. More... | |
void | ticker_callback (void *ctx) |
This is an ISR (Interrupt Service Routine) for Ticker object. More... | |
int32_t | ad4170_iio_initialize (void) |
Initialize the IIO interface for AD4170 IIO device. More... | |
void | ad4170_iio_event_handler (void) |
Run the AD4170 IIO event handler. More... | |
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 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-24 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 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 (131072) |
#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 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_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.
struct iio_device_data* ad4170_iio_dev_data |
struct iio_attribute channel_input_attributes[] |
bool data_capture_operation = false |
struct iio_device_init iio_device_init_params[NUM_OF_IIO_DEVICES] |
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 |
uint8_t read_reg_id = 0 |
struct ad4170_cached_reg reg_values[N_REGISTERS_CACHED] |
volatile bool tdm_read_started = false |