precision-converters-firmware
|
Implementation of AD7768-1 IIO application interfaces. More...
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "app_config.h"
#include "ad77681_iio.h"
#include "ad77681_user_config.h"
#include "ad77681_regs.h"
#include "ad77681_support.h"
#include "common.h"
#include "iio_trigger.h"
#include "no_os_error.h"
#include "no_os_util.h"
Macros | |
#define | NUM_OF_IIO_DEVICES 1 |
#define | IIO_TRIGGER_NAME "ad77681_iio_trigger" |
#define | AD77681_NUM_CHANNELS 1 |
#define | BYTES_PER_SAMPLE sizeof(uint32_t) |
#define | CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8) |
#define | AD77681_SCALE_FACTOR (1 << ADC_RESOLUTION) |
#define | AD77681_DEFAULT_SCALE ((((float)(AD77681_VOLTAGE_REF / 1000.00) * 2) / AD77681_SCALE_FACTOR) * 1000) |
#define | AD77681_REG_MAX_ADDR AD77681_REG_MCLK_COUNTER + 1 |
#define | SINGLE_MODE_CONV_STANDBY 6 |
#define | PERIODIC_MODE_CONV_STANDBY 7 |
#define | DATA_BUFFER_SIZE (32768) |
Functions | |
int | get_raw (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
Getter/Setter for the raw attribute value. More... | |
int | set_raw (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
int | get_scale (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
Getter/Setter for the scale attribute value. More... | |
int | set_scale (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
int | get_power_mode (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
Getter/Setter for the power mode attribute value. More... | |
int | set_power_mode (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
int | get_conv_mode (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
Getter/Setter for the conversion mode attribute value. More... | |
int | set_conv_mode (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
int | get_mclk_division (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
Getter/Setter for the MCLK division attribute value. More... | |
int | set_mclk_division (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t id) |
bool | debug_get_reg_value (uint8_t reg, uint8_t *Reg_add) |
Get the actual register address value from the list. 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... | |
int32_t | iio_ad77681_trigger_handler (struct iio_device_data *iio_dev_data) |
Push data into IIO buffer when trigger handler IRQ is invoked. More... | |
int32_t | ad77681_iio_initialize (void) |
Initialize the IIO interface for AD7768-1 IIO device. More... | |
void | ad77681_iio_event_handler (void) |
Run the AD77681 IIO event handler. More... | |
Variables | |
struct ad77681_dev * | p_ad77681_dev_inst = NULL |
struct ad77681_status_registers * | p_ad77681_stat_reg = NULL |
struct iio_attribute | channel_input_attributes [] |
struct scan_type | chn_scan |
Implementation of AD7768-1 IIO application interfaces.
This module acts as an interface for AD7768-1 IIO application
Copyright (c) 2021-23 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 AD77681_DEFAULT_SCALE ((((float)(AD77681_VOLTAGE_REF / 1000.00) * 2) / AD77681_SCALE_FACTOR) * 1000) |
#define AD77681_NUM_CHANNELS 1 |
#define AD77681_REG_MAX_ADDR AD77681_REG_MCLK_COUNTER + 1 |
#define AD77681_SCALE_FACTOR (1 << ADC_RESOLUTION) |
#define BYTES_PER_SAMPLE sizeof(uint32_t) |
#define CHN_STORAGE_BITS (BYTES_PER_SAMPLE * 8) |
#define DATA_BUFFER_SIZE (32768) |
#define IIO_TRIGGER_NAME "ad77681_iio_trigger" |
#define NUM_OF_IIO_DEVICES 1 |
#define PERIODIC_MODE_CONV_STANDBY 7 |
#define SINGLE_MODE_CONV_STANDBY 6 |
void ad77681_iio_event_handler | ( | void | ) |
Run the AD77681 IIO event handler.
This function monitors the new IIO client event
int32_t ad77681_iio_initialize | ( | void | ) |
Initialize the IIO interface for AD7768-1 IIO device.
bool debug_get_reg_value | ( | uint8_t | reg, |
uint8_t * | Reg_add | ||
) |
Get the actual register address value from the list.
reg- | Register address to read from |
Reg_add | - actual value of Register address |
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 |
int get_conv_mode | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
Getter/Setter for the conversion mode attribute value.
device- | pointer to IIO device structure |
buf- | pointer to buffer holding attribute value |
len- | length of buffer string data |
channel- | pointer to IIO channel structure |
id- | Attribute ID (optional) |
int get_mclk_division | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
Getter/Setter for the MCLK division attribute value.
device- | pointer to IIO device structure |
buf- | pointer to buffer holding attribute value |
len- | length of buffer string data |
channel- | pointer to IIO channel structure |
id- | Attribute ID (optional) |
int get_power_mode | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
Getter/Setter for the power mode attribute value.
device- | pointer to IIO device structure |
buf- | pointer to buffer holding attribute value |
len- | length of buffer string data |
channel- | pointer to IIO channel structure |
id- | Attribute ID (optional) |
int get_raw | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
Getter/Setter for the raw attribute value.
device- | pointer to IIO device structure |
buf- | pointer to buffer holding attribute value |
len- | length of buffer string data |
channel- | pointer to IIO channel structure |
id- | Attribute ID (optional) |
int get_scale | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
Getter/Setter for the scale attribute value.
device- | pointer to IIO device structure |
buf- | pointer to buffer holding attribute value |
len- | length of buffer string data |
channel- | pointer to IIO channel structure |
id- | Attribute ID (optional) |
int32_t iio_ad77681_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 |
int set_conv_mode | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
int set_mclk_division | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
int set_power_mode | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
int set_raw | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
int set_scale | ( | void * | device, |
char * | buf, | ||
uint32_t | len, | ||
const struct iio_ch_info * | channel, | ||
intptr_t | id | ||
) |
struct iio_attribute channel_input_attributes[] |
struct scan_type chn_scan |
struct ad77681_dev* p_ad77681_dev_inst = NULL |
struct ad77681_status_registers* p_ad77681_stat_reg = NULL |