precision-converters-firmware
Loading...
Searching...
No Matches
Classes | Macros | Functions
ad552xr_support.c File Reference

Source file for the AD552XR IIO Application Support. More...

#include <stdint.h>
#include "app_config.h"
#include "ad552xr_support.h"
#include "ad552xr_user_config.h"
#include "ad552xr.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
#include "no_os_util.h"
#include "no_os_spi.h"
#include "stm32_pwm_ex.h"
Include dependency graph for ad552xr_support.c:

Classes

struct  ad552xr_spi_intr_tx_info
 Structure to hold the SPI transfer information in SPI interrupt mode.
 

Macros

#define TIM_COMPENSATION   (150)
 
#define TIM_BYTE_TRANSFER   (8 * HZ_NS_CONVERT(SPI_SPEED))
 
#define NUM_BYTES_TRANSFER
 
#define TIM_DMA_HIGH_TIME   (TIM_BYTE_TRANSFER)
 
#define TIM_DMA_LOW_TIME   (20)
 
#define TIM_DMA_PERIOD   (TIM_DMA_LOW_TIME + TIM_DMA_HIGH_TIME)
 
#define TIM_CS_HIGH_TIME   (100)
 
#define TIM_CS_LOW_TIME   (NUM_BYTES_TRANSFER * TIM_DMA_PERIOD)
 
#define TIM_DAC_UPDATE_PERIOD   (TIM_CS_LOW_TIME + TIM_COMPENSATION)
 

Functions

int32_t ad552xr_set_sampling_rate (uint32_t val)
 Set the sampling rate.
 
int32_t ad552xr_get_sampling_rate (uint32_t *val)
 Get the sampling rate.
 
int32_t ad552xr_data_transfer_start (struct iio_device_data *iio_dev_data, uint8_t *dst_data_buffer)
 Start the device data transfer for SPI interrupt interface mode.
 
int32_t ad552xr_data_transfer_system_init (void)
 Initialize the Data Transfer System.
 
int32_t ad552xr_data_transfer_system_remove (void)
 De-initialize the Data Transfer System.
 
int32_t ad552xr_data_transfer_prepare (void *dev, uint32_t mask)
 Prepares the device for data transfer.
 
int32_t ad552xr_data_transfer_stop (void *dev)
 Stop the device data transfer.
 

Detailed Description

Source file for the AD552XR IIO Application Support.

This module contains support functions needed for IIO application

Copyright (c) 2026 Analog Devices, Inc.

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

◆ NUM_BYTES_TRANSFER

#define NUM_BYTES_TRANSFER
Value:
(sizeof(uint16_t) +\
#define AD552XR_DAC_RESOLUTION
Definition app_config.h:34

◆ TIM_BYTE_TRANSFER

#define TIM_BYTE_TRANSFER   (8 * HZ_NS_CONVERT(SPI_SPEED))

◆ TIM_COMPENSATION

#define TIM_COMPENSATION   (150)

◆ TIM_CS_HIGH_TIME

#define TIM_CS_HIGH_TIME   (100)

◆ TIM_CS_LOW_TIME

#define TIM_CS_LOW_TIME   (NUM_BYTES_TRANSFER * TIM_DMA_PERIOD)

◆ TIM_DAC_UPDATE_PERIOD

#define TIM_DAC_UPDATE_PERIOD   (TIM_CS_LOW_TIME + TIM_COMPENSATION)

◆ TIM_DMA_HIGH_TIME

#define TIM_DMA_HIGH_TIME   (TIM_BYTE_TRANSFER)

◆ TIM_DMA_LOW_TIME

#define TIM_DMA_LOW_TIME   (20)

◆ TIM_DMA_PERIOD

#define TIM_DMA_PERIOD   (TIM_DMA_LOW_TIME + TIM_DMA_HIGH_TIME)

Function Documentation

◆ ad552xr_data_transfer_prepare()

int32_t ad552xr_data_transfer_prepare ( void *  dev,
uint32_t  mask 
)

Prepares the device for data transfer.

Parameters
dev[in,out]-Application descriptor.
mask[in]-Channels select mask.
Returns
0 in case of success, error code otherwise.

◆ ad552xr_data_transfer_start()

int32_t ad552xr_data_transfer_start ( struct iio_device_data *  iio_dev_data,
uint8_t *  dst_data_buffer 
)

Start the device data transfer for SPI interrupt interface mode.

This function will be called from IIO Trigger ISR. In the first call, it will populate the data buffer with valid data and LDAC commands. Then it will enable TGP timer to trigger HW LDAC if necessary. The SPI data frames will be transferred for every function call. In the end of the LDAC cycle, if SW LDAC is configured for any channel, it will be triggered in the end of SPI transfer. This cycle will be repeated until the stop function is called.

Parameters
iio_dev_data[in]- IIO device data instance.
dst_data_buffer[in,out]- Destination data buffer to populate the data.
Returns
0 in case of success, negative error code otherwise

◆ ad552xr_data_transfer_stop()

int32_t ad552xr_data_transfer_stop ( void *  dev)

Stop the device data transfer.

Parameters
dev[in,out]-Application descriptor.
Returns
0 in case of success, error code otherwise.

◆ ad552xr_data_transfer_system_init()

int32_t ad552xr_data_transfer_system_init ( void  )

Initialize the Data Transfer System.

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

◆ ad552xr_data_transfer_system_remove()

int32_t ad552xr_data_transfer_system_remove ( void  )

De-initialize the Data Transfer System.

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

◆ ad552xr_get_sampling_rate()

int32_t ad552xr_get_sampling_rate ( uint32_t *  val)

Get the sampling rate.

Parameters
val[out]- Sample rate value.
Returns
0 in case of success, negative error code otherwise.

◆ ad552xr_set_sampling_rate()

int32_t ad552xr_set_sampling_rate ( uint32_t  val)

Set the sampling rate.

Parameters
val[in]- Sample rate value.
Returns
0 in case of success, negative error code otherwise.