precision-converters-firmware
Macros | Enumerations | Functions | Variables
ad2s1210_iio.c File Reference

Implementation of AD2S1210 IIO application interfaces. More...

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include "iio.h"
#include "iio_trigger.h"
#include "ad2s1210_iio.h"
#include "app_config.h"
#include "ad2s1210_user_config.h"
#include "common.h"
#include "no_os_error.h"
#include "no_os_util.h"
Include dependency graph for ad2s1210_iio.c:

Macros

#define AD2S1210_CHN_ATTR(_name, _priv)
 
#define AD2S1210_CH(_name, _idx, _type, _ch_out)
 
#define NUM_OF_IIO_DEVICES   1
 
#define BYTES_PER_SAMPLE   2
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define AD2S1210_IIO_TRIGGER_NAME   "ad2s1210_iio_trigger"
 
#define DATA_BUFFER_SIZE   (32768) /* 32kbytes */
 

Enumerations

enum  ad2s1210_attribute_id {
  RAW_ATTR_ID ,
  SCALE_ATTR_ID ,
  SAMPLING_FREQ_ATTR_ID ,
  LABEL_ATTR_ID ,
  HYSTERESIS_ATTR_ID ,
  HYSTERESIS_AVAILABLE_ATTR_ID ,
  FREQ_ATTR_ID ,
  FREQ_AVAIL_ATTR_ID
}
 

Functions

int32_t ad2s1210_trigger_handler (struct iio_device_data *iio_dev_data)
 Push data into IIO buffer when trigger handler IRQ is invoked. More...
 
int32_t ad2s1210_iio_initialize (void)
 Initialize the IIO interface for AD2S1210 IIO device. More...
 
void ad2s1210_iio_event_handler (void)
 Run the AD2S1210 IIO event handler. More...
 

Variables

struct ad2s1210_dev * ad2s1210_dev_inst
 
uint32_t active_chn_count
 
struct scan_type chn_scan [RESOLVER_CHANNELS]
 

Detailed Description

Implementation of AD2S1210 IIO application interfaces.

Copyright (c) 2023 Analog Devices, Inc. Copyright (c) 2023 BayLibre, SAS. 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.

Macro Definition Documentation

◆ AD2S1210_CH

#define AD2S1210_CH (   _name,
  _idx,
  _type,
  _ch_out 
)
Value:
{\
.name = _name, \
.ch_type = _type,\
.ch_out = _ch_out,\
.indexed = true,\
.channel = 0,\
.scan_index = _idx,\
.scan_type = &chn_scan[_idx],\
.attributes = &ad2s1210_iio_ch_attributes[_idx][0]\
}
struct scan_type chn_scan[RESOLVER_CHANNELS]
Definition: ad2s1210_iio.c:110

◆ AD2S1210_CHN_ATTR

#define AD2S1210_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = iio_ad2s1210_attr_get,\
.store = iio_ad2s1210_attr_set\
}

◆ AD2S1210_IIO_TRIGGER_NAME

#define AD2S1210_IIO_TRIGGER_NAME   "ad2s1210_iio_trigger"

◆ BYTES_PER_SAMPLE

#define BYTES_PER_SAMPLE   2

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ DATA_BUFFER_SIZE

#define DATA_BUFFER_SIZE   (32768) /* 32kbytes */

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

Enumeration Type Documentation

◆ ad2s1210_attribute_id

Enumerator
RAW_ATTR_ID 
SCALE_ATTR_ID 
SAMPLING_FREQ_ATTR_ID 
LABEL_ATTR_ID 
HYSTERESIS_ATTR_ID 
HYSTERESIS_AVAILABLE_ATTR_ID 
FREQ_ATTR_ID 
FREQ_AVAIL_ATTR_ID 

Function Documentation

◆ ad2s1210_iio_event_handler()

void ad2s1210_iio_event_handler ( void  )

Run the AD2S1210 IIO event handler.

Returns
none

This function monitors the new IIO client event

Here is the caller graph for this function:

◆ ad2s1210_iio_initialize()

int32_t ad2s1210_iio_initialize ( void  )

Initialize the IIO interface for AD2S1210 IIO device.

Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ad2s1210_trigger_handler()

int32_t ad2s1210_trigger_handler ( struct iio_device_data *  iio_dev_data)

Push data into IIO buffer when trigger handler IRQ is invoked.

Parameters
iio_dev_data[in]- IIO device data instance
Returns
0 in case of success or negative value otherwise

Variable Documentation

◆ active_chn_count

uint32_t active_chn_count

◆ ad2s1210_dev_inst

struct ad2s1210_dev* ad2s1210_dev_inst

◆ chn_scan

struct scan_type chn_scan[RESOLVER_CHANNELS]
Initial value:
= {
{
.sign = 'u',
.realbits = CHN_STORAGE_BITS,
.storagebits = CHN_STORAGE_BITS,
.shift = 0,
.is_big_endian = true,
},
{
.sign = 's',
.realbits = CHN_STORAGE_BITS,
.storagebits = CHN_STORAGE_BITS,
.shift = 0,
.is_big_endian = true,
},
{
.sign = 'u',
.realbits = CHN_STORAGE_BITS,
.storagebits = CHN_STORAGE_BITS,
.shift = 0,
.is_big_endian = false,
},
}
#define CHN_STORAGE_BITS
Definition: ad2s1210_iio.c:70