precision-converters-firmware
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
ltc2672_iio.c File Reference

Implementation of LTC2672 IIO application interfaces. More...

#include <stdio.h>
#include <string.h>
#include "app_config.h"
#include "ltc2672_iio.h"
#include "ltc2672_user_config.h"
#include "common.h"
#include "no_os_util.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
Include dependency graph for ltc2672_iio.c:

Macros

#define LTC2672_CHN_ATTR(_name, _priv)
 
#define LTC2672_CHN_AVAIL_ATTR(_name, _priv)
 
#define LTC2672_CH(_name, _idx, _type)
 
#define NUM_OF_IIO_DEVICES   1
 
#define BYTES_PER_SAMPLE   sizeof(uint16_t)
 
#define BYTE_SIZE   (uint32_t)8
 
#define BYTE_MASK   (uint32_t)0xff
 
#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)
 
#define LTC2672_MIN_REF_VOLTAGE   1.225
 
#define LTC2672_MAX_REF_VOLTAGE   1.275
 
#define LTC2672_MIN_FSADJ_RESISTOR   19
 
#define LTC2672_MAX_FSADJ_RESISTOR   41
 
#define CONFIG_COMMAND(oc, pl, ts, rd)   (oc << 3) | (pl << 2) | (ts << 1) | (rd << 0)
 
#define INDEX_TO_DEV_ID(x)   ((x * 2) + 1)
 

Enumerations

enum  ltc2672_iio_attr_id {
  DAC_CH_RAW ,
  DAC_CH_OFFSET ,
  DAC_CH_SCALE ,
  DAC_CH_SPAN ,
  DAC_CH_CURRENT ,
  DAC_CH_INPUT_A ,
  DAC_CH_INPUT_B ,
  DAC_CH_POWERDOWN ,
  DAC_CH_SW_LDAC ,
  DAC_CH_WRITE_TO_N_UPDATE_ALL ,
  DAC_CH_TOGGLE_SEL ,
  DAC_CH_OPEN_CIRCUIT_FAULT ,
  DAC_RAW ,
  DAC_SPAN ,
  DAC_CURRENT ,
  DAC_MUX ,
  DAC_READBACK ,
  DAC_RESET ,
  DAC_HW_TOGGLE_STATE ,
  DAC_TOGGLE_PWM ,
  DAC_SAMPLE_RATE ,
  DAC_CHIP_POWERDOWN ,
  DAC_INPUT_A ,
  DAC_INPUT_B ,
  DAC_HW_LDAC ,
  DAC_SW_LDAC ,
  DAC_FAULT ,
  DAC_OPEN_CIRCUIT_CONFIG ,
  DAC_POWER_LIMIT_CONFIG ,
  DAC_THERMAL_SHUTDOWN_CONFIG ,
  DAC_EXTERNAL_REFERENCE_CONFIG ,
  DAC_SW_TOGGLE_STATE ,
  DAC_OVER_TEMP_FAULT ,
  DAC_POWER_LIMIT_FAULT ,
  DAC_SPI_LENGTH_FAULT ,
  DAC_REFERENCE ,
  DAC_RESISTOR ,
  DAC_NO_OP
}
 

Functions

int32_t ltc2672_set_toggling_rate (uint32_t *toggling_rate)
 Set the toggling rate and get the updated value supported by MCU platform and the device.
 
int32_t ltc2672_iio_init ()
 Initialize the IIO interface for LTC2672 IIO device.
 
void ltc2672_iio_event_handler (void)
 Run the LTC2672 IIO event handler.
 

Variables

struct ltc2672_dev * ltc2672_dev_desc
 
float ref_voltage = DAC_VREF
 
float resistor_fsadj = DAC_FSADJ_RESISTOR
 
uint8_t toggle_sel_bits = 0
 
uint8_t fault_register = 0
 
uint32_t ltc2672_toggle_rate = LTC2672_MAX_TOGGLE_RATE
 

Detailed Description

Implementation of LTC2672 IIO application interfaces.

Copyright (c) 2023-25 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.

Macro Definition Documentation

◆ BYTE_MASK

#define BYTE_MASK   (uint32_t)0xff

◆ BYTE_SIZE

#define BYTE_SIZE   (uint32_t)8

◆ BYTES_PER_SAMPLE

#define BYTES_PER_SAMPLE   sizeof(uint16_t)

◆ CHN_STORAGE_BITS

#define CHN_STORAGE_BITS   (BYTES_PER_SAMPLE * 8)

◆ CONFIG_COMMAND

#define CONFIG_COMMAND (   oc,
  pl,
  ts,
  rd 
)    (oc << 3) | (pl << 2) | (ts << 1) | (rd << 0)

◆ INDEX_TO_DEV_ID

#define INDEX_TO_DEV_ID (   x)    ((x * 2) + 1)

◆ LTC2672_CH

#define LTC2672_CH (   _name,
  _idx,
  _type 
)
Value:
{\
.name = _name, \
.ch_type = _type,\
.ch_out = true,\
.indexed = true,\
.channel = _idx,\
.scan_index = _idx,\
.scan_type = &ltc2672_iio_scan_type,\
.attributes = ltc2672_iio_ch_attributes\
}

◆ LTC2672_CHN_ATTR

#define LTC2672_CHN_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ltc2672_iio_attr_get,\
.store = ltc2672_iio_attr_set\
}

◆ LTC2672_CHN_AVAIL_ATTR

#define LTC2672_CHN_AVAIL_ATTR (   _name,
  _priv 
)
Value:
{\
.name = _name,\
.priv = _priv,\
.show = ltc2672_iio_attr_available_get,\
.store = ltc2672_iio_attr_available_set\
}

◆ LTC2672_MAX_FSADJ_RESISTOR

#define LTC2672_MAX_FSADJ_RESISTOR   41

◆ LTC2672_MAX_REF_VOLTAGE

#define LTC2672_MAX_REF_VOLTAGE   1.275

◆ LTC2672_MIN_FSADJ_RESISTOR

#define LTC2672_MIN_FSADJ_RESISTOR   19

◆ LTC2672_MIN_REF_VOLTAGE

#define LTC2672_MIN_REF_VOLTAGE   1.225

◆ NUM_OF_IIO_DEVICES

#define NUM_OF_IIO_DEVICES   1

Enumeration Type Documentation

◆ ltc2672_iio_attr_id

Enumerator
DAC_CH_RAW 
DAC_CH_OFFSET 
DAC_CH_SCALE 
DAC_CH_SPAN 
DAC_CH_CURRENT 
DAC_CH_INPUT_A 
DAC_CH_INPUT_B 
DAC_CH_POWERDOWN 
DAC_CH_SW_LDAC 
DAC_CH_WRITE_TO_N_UPDATE_ALL 
DAC_CH_TOGGLE_SEL 
DAC_CH_OPEN_CIRCUIT_FAULT 
DAC_RAW 
DAC_SPAN 
DAC_CURRENT 
DAC_MUX 
DAC_READBACK 
DAC_RESET 
DAC_HW_TOGGLE_STATE 
DAC_TOGGLE_PWM 
DAC_SAMPLE_RATE 
DAC_CHIP_POWERDOWN 
DAC_INPUT_A 
DAC_INPUT_B 
DAC_HW_LDAC 
DAC_SW_LDAC 
DAC_FAULT 
DAC_OPEN_CIRCUIT_CONFIG 
DAC_POWER_LIMIT_CONFIG 
DAC_THERMAL_SHUTDOWN_CONFIG 
DAC_EXTERNAL_REFERENCE_CONFIG 
DAC_SW_TOGGLE_STATE 
DAC_OVER_TEMP_FAULT 
DAC_POWER_LIMIT_FAULT 
DAC_SPI_LENGTH_FAULT 
DAC_REFERENCE 
DAC_RESISTOR 
DAC_NO_OP 

Function Documentation

◆ ltc2672_iio_event_handler()

void ltc2672_iio_event_handler ( void  )

Run the LTC2672 IIO event handler.

Returns
none.

This function monitors the new IIO client event.

Here is the caller graph for this function:

◆ ltc2672_iio_init()

int32_t ltc2672_iio_init ( void  )

Initialize the IIO interface for LTC2672 IIO device.

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

◆ ltc2672_set_toggling_rate()

int32_t ltc2672_set_toggling_rate ( uint32_t *  toggling_rate)

Set the toggling rate and get the updated value supported by MCU platform and the device.

Parameters
toggling_rate[in,out]- Update rate value
Returns
0 in case of success, negative error code otherwise

Variable Documentation

◆ fault_register

uint8_t fault_register = 0

◆ ltc2672_dev_desc

struct ltc2672_dev* ltc2672_dev_desc

◆ ltc2672_toggle_rate

uint32_t ltc2672_toggle_rate = LTC2672_MAX_TOGGLE_RATE

◆ ref_voltage

float ref_voltage = DAC_VREF

◆ resistor_fsadj

float resistor_fsadj = DAC_FSADJ_RESISTOR

◆ toggle_sel_bits

uint8_t toggle_sel_bits = 0