no-OS
Macros | Functions | Variables
iio_adis.c File Reference

Implementation of iio_adis.c. More...

#include "iio_adis_internals.h"
#include "no_os_delay.h"
#include "no_os_units.h"
#include <stdio.h>
#include <string.h>
#include "adis.h"
#include "adis_internals.h"
#include "iio_trigger.h"
Include dependency graph for iio_adis.c:

Macros

#define ADIS_BURST_DATA_SEL_0_CHN_MASK   NO_OS_GENMASK(5, 0)
 
#define ADIS_BURST_DATA_SEL_1_CHN_MASK   NO_OS_GENMASK(12, 7)
 

Functions

int adis_iio_read_reg (struct adis_iio_dev *device, uint32_t reg, uint32_t *readval)
 Wrapper for reading adis register. More...
 
int adis_iio_write_reg (struct adis_iio_dev *device, uint32_t reg, uint32_t writeval)
 Wrapper for writing to adis register. More...
 
int adis_iio_read_raw (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for raw attribute. More...
 
int adis_iio_read_scale (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for scale attribute. More...
 
int adis_iio_read_offset (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for offset attribute. More...
 
int adis_iio_read_calibbias (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for calibbias attribute. More...
 
int adis_iio_write_calibbias (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the write request for calibbias attribute. More...
 
int adis_iio_read_calibscale (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for calibscale attribute. More...
 
int adis_iio_write_calibscale (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the write request for calibscale attribute. More...
 
int adis_iio_read_lpf (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for lpf attribute. More...
 
int adis_iio_write_lpf (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the write request for lpf attribute. More...
 
int adis_iio_read_sampling_freq (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for sampling frequency attribute. More...
 
int adis_iio_write_sampling_freq (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the write request for sampling frequency attribute. More...
 
int adis_iio_read_gyro_meas_range (struct adis_iio_dev *iio_adis, char *buf)
 Reads gyroscope measurement range value and returns it in char format. More...
 
int adis_iio_read_debug_attrs (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the read request for debug attributes. More...
 
int adis_iio_write_debug_attrs (void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
 Handles the write request for debug attributes. More...
 
int adis_iio_pre_enable (void *dev, uint32_t mask)
 API to be called before trigger is enabled. More...
 
int adis_iio_post_disable (void *dev, uint32_t mask)
 API to be called after trigger is disabled. More...
 
int adis_iio_trigger_handler (struct iio_device_data *dev_data)
 Handles trigger: reads one data-set and writes it to the buffer. More...
 
int adis_iio_trigger_handler_with_fifo (struct iio_device_data *dev_data)
 Handles trigger: reads all available samples in FIFO and writes them to the buffer. More...
 

Variables

struct iio_attribute adis_dev_attrs []
 
struct iio_attribute adis_iio_anglvel_attrs []
 
struct iio_attribute adis_iio_accel_attrs []
 
struct iio_attribute adis_iio_temp_attrs []
 
struct iio_attribute adis_iio_delta_angl_attrs []
 
struct iio_attribute adis_iio_delta_vel_attrs []
 

Detailed Description

Implementation of iio_adis.c.

Author
RBolboac (ramon.nosp@m.a.bo.nosp@m.lboac.nosp@m.a@an.nosp@m.alog..nosp@m.com)

Copyright 2023(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

◆ ADIS_BURST_DATA_SEL_0_CHN_MASK

#define ADIS_BURST_DATA_SEL_0_CHN_MASK   NO_OS_GENMASK(5, 0)

◆ ADIS_BURST_DATA_SEL_1_CHN_MASK

#define ADIS_BURST_DATA_SEL_1_CHN_MASK   NO_OS_GENMASK(12, 7)

Function Documentation

◆ adis_iio_post_disable()

int adis_iio_post_disable ( void *  dev,
uint32_t  mask 
)

API to be called after trigger is disabled.

Parameters
dev- The iio device structure.
mask- The active channels mask.
Returns
0 in case of success, error code otherwise.

◆ adis_iio_pre_enable()

int adis_iio_pre_enable ( void *  dev,
uint32_t  mask 
)

API to be called before trigger is enabled.

Parameters
dev- The iio device structure.
mask- The active channels mask.
Returns
0 in case of success, error code otherwise.

◆ adis_iio_read_calibbias()

int adis_iio_read_calibbias ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for calibbias attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_calibscale()

int adis_iio_read_calibscale ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for calibscale attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_debug_attrs()

int adis_iio_read_debug_attrs ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for debug attributes.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_gyro_meas_range()

int adis_iio_read_gyro_meas_range ( struct adis_iio_dev iio_adis,
char *  buf 
)

Reads gyroscope measurement range value and returns it in char format.

Parameters
iio_adis- The iio adis device.
buf- The gyroscope measurement range value in char format.
Returns
the size of the written data in buf in case of success, error code otherwise.
Here is the caller graph for this function:

◆ adis_iio_read_lpf()

int adis_iio_read_lpf ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for lpf attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_offset()

int adis_iio_read_offset ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for offset attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_raw()

int adis_iio_read_raw ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for raw attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_reg()

int adis_iio_read_reg ( struct adis_iio_dev device,
uint32_t  reg,
uint32_t *  readval 
)

Wrapper for reading adis register.

Parameters
device- The iio device structure.
reg- Address of the register to be read from.
readval- Read data.
Returns
ret - Result of the reading procedure.

◆ adis_iio_read_sampling_freq()

int adis_iio_read_sampling_freq ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for sampling frequency attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_read_scale()

int adis_iio_read_scale ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the read request for scale attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with requested data.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the size of the read data in case of success, error code otherwise.

◆ adis_iio_trigger_handler()

int adis_iio_trigger_handler ( struct iio_device_data dev_data)

Handles trigger: reads one data-set and writes it to the buffer.

Parameters
dev_data- The iio device data structure.
Returns
the size of the written data in case of success, error code otherwise.

◆ adis_iio_trigger_handler_with_fifo()

int adis_iio_trigger_handler_with_fifo ( struct iio_device_data dev_data)

Handles trigger: reads all available samples in FIFO and writes them to the buffer.

Parameters
dev_data- The iio device data structure.
Returns
the size of the written data in case of success, error code otherwise.

◆ adis_iio_write_calibbias()

int adis_iio_write_calibbias ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the write request for calibbias attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with the data to be written.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the result of the writing procedure.

◆ adis_iio_write_calibscale()

int adis_iio_write_calibscale ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the write request for calibscale attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with the data to be written.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the result of the writing procedure.

◆ adis_iio_write_debug_attrs()

int adis_iio_write_debug_attrs ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the write request for debug attributes.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with the data to be written.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the result of the writing procedure.

◆ adis_iio_write_lpf()

int adis_iio_write_lpf ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the write request for lpf attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with the data to be written.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the result of the writing procedure.

◆ adis_iio_write_reg()

int adis_iio_write_reg ( struct adis_iio_dev device,
uint32_t  reg,
uint32_t  writeval 
)

Wrapper for writing to adis register.

Parameters
device- The iio device structure.
reg- Address of the register to be written to.
writeval- Data to be written.
Returns
ret - Result of the writing procedure.

◆ adis_iio_write_sampling_freq()

int adis_iio_write_sampling_freq ( void *  dev,
char *  buf,
uint32_t  len,
const struct iio_ch_info channel,
intptr_t  priv 
)

Handles the write request for sampling frequency attribute.

Parameters
dev- The iio device structure.
buf- Command buffer to be filled with the data to be written.
len- Length of the received command buffer in bytes.
channel- Command channel info.
priv- Command attribute id.
Returns
the result of the writing procedure.

Variable Documentation

◆ adis_dev_attrs

struct iio_attribute adis_dev_attrs[]
Initial value:
= {
{
.name = "filter_low_pass_3db_frequency",
.shared = IIO_SHARED_BY_ALL,
},
{
.name = "sampling_frequency",
.shared = IIO_SHARED_BY_ALL,
},
}

◆ adis_iio_accel_attrs

struct iio_attribute adis_iio_accel_attrs[]
Initial value:
= {
{
.name = "calibbias",
},
{
.name = "raw",
},
{
.name = "scale",
.shared = IIO_SHARED_BY_TYPE,
},
}

◆ adis_iio_anglvel_attrs

struct iio_attribute adis_iio_anglvel_attrs[]
Initial value:
= {
{
.name = "calibbias",
},
{
.name = "raw",
},
{
.name = "scale",
.shared = IIO_SHARED_BY_TYPE,
},
}

◆ adis_iio_delta_angl_attrs

struct iio_attribute adis_iio_delta_angl_attrs[]
Initial value:
= {
{
.name = "raw",
},
{
.name = "scale",
.shared = IIO_SHARED_BY_TYPE,
},
}

◆ adis_iio_delta_vel_attrs

struct iio_attribute adis_iio_delta_vel_attrs[]
Initial value:
= {
{
.name = "raw",
},
{
.name = "scale",
.shared = IIO_SHARED_BY_TYPE,
},
}

◆ adis_iio_temp_attrs

struct iio_attribute adis_iio_temp_attrs[]
Initial value:
= {
{
.name = "raw",
},
{
.name = "scale",
},
}
adis_iio_write_lpf
int adis_iio_write_lpf(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the write request for lpf attribute.
Definition: iio_adis.c:562
END_ATTRIBUTES_ARRAY
#define END_ATTRIBUTES_ARRAY
Definition: iio_types.h:116
adis_iio_write_sampling_freq
int adis_iio_write_sampling_freq(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the write request for sampling frequency attribute.
Definition: iio_adis.c:753
IIO_SHARED_BY_TYPE
@ IIO_SHARED_BY_TYPE
Definition: iio_types.h:120
adis_iio_write_calibbias
int adis_iio_write_calibbias(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the write request for calibbias attribute.
Definition: iio_adis.c:344
IIO_SHARED_BY_ALL
@ IIO_SHARED_BY_ALL
Definition: iio_types.h:122
adis_iio_read_lpf
int adis_iio_read_lpf(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the read request for lpf attribute.
Definition: iio_adis.c:498
adis_iio_read_sampling_freq
int adis_iio_read_sampling_freq(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the read request for sampling frequency attribute.
Definition: iio_adis.c:657
adis_iio_read_calibbias
int adis_iio_read_calibbias(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the read request for calibbias attribute.
Definition: iio_adis.c:288
adis_iio_read_scale
int adis_iio_read_scale(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the read request for scale attribute.
Definition: iio_adis.c:174
adis_iio_read_raw
int adis_iio_read_raw(void *dev, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Handles the read request for raw attribute.
Definition: iio_adis.c:97