no-OS
Loading...
Searching...
No Matches
ad5755.c File Reference

Implementation of AD5755 Driver. More...

#include <stdlib.h>
#include "ad5755.h"
#include "ad5755_cfg.h"
#include "no_os_alloc.h"
Include dependency graph for ad5755.c:

Functions

int8_t ad5755_init (struct ad5755_dev **device, struct ad5755_init_param init_param)
 Initializes the device and powers-up all channels. The device is initialized with the values held by AD5755_InitialSettings structure.
 
int32_t ad5755_remove (struct ad5755_dev *dev)
 Free the resources allocated by ad5755_init().
 
int32_t ad5755_get_register_value (struct ad5755_dev *dev, uint8_t register_address)
 Reads the value of a register.
 
uint16_t ad5755_set_register_value (struct ad5755_dev *dev, uint8_t register_address, uint8_t channel, uint16_t register_value)
 Writes data into a register.
 
void ad5755_software_reset (struct ad5755_dev *dev)
 Performs a software reset to the device.
 
void ad5755_watch_dog_setup (struct ad5755_dev *dev, uint8_t wtd_enable, uint8_t timeout)
 Enables/Disables watchdog timer and sets the timeout period.
 
void ad5755_feed_watch_dog_timer (struct ad5755_dev *dev)
 Write a "service pulse" to the AD5755 watchdog timer when enabled.
 
void ad5755_set_control_registers (struct ad5755_dev *dev, uint8_t ctrl_reg_address, uint8_t channel, uint16_t reg_value)
 Configures one of the control registers.
 
uint8_t ad5755_check_crc (uint8_t *data, uint8_t bytes_number)
 Computes the CRC for a data buffer.
 
void ad5755_set_channel_power (struct ad5755_dev *dev, uint8_t channel, uint8_t pwr_status)
 Allows power-up/down of the dc-to-dc converter, DAC and internal amplifiers for the selected channel.
 
void ad5755_set_channel_range (struct ad5755_dev *dev, uint8_t channel, uint8_t range)
 Sets the range of a channel.
 
void ad5755_channel_clear_enable (struct ad5755_dev *dev, uint8_t channel, uint8_t clear_en)
 Selects if the channel clears when CLEAR pin is activated.
 
void ad5755_slew_rate_ctrl (struct ad5755_dev *dev, int8_t channel, int8_t sr_en, int8_t updt_freq, int8_t step_size)
 Configures the Digital Slew Rate Control.
 
float ad5755_set_voltage (struct ad5755_dev *dev, uint8_t channel, float voltage)
 Sets the output voltage of a channel.
 
float ad5755_set_current (struct ad5755_dev *dev, uint8_t channel, float m_acurrent)
 Sets the output current of a channel.
 

Detailed Description

Implementation of AD5755 Driver.

Author
Istvan Csomortani (istva.nosp@m.n.cs.nosp@m.omort.nosp@m.ani@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2012(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ad5755_channel_clear_enable()

void ad5755_channel_clear_enable ( struct ad5755_dev * dev,
uint8_t channel,
uint8_t clear_en )

Selects if the channel clears when CLEAR pin is activated.

Parameters
dev- The device structure.
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
clear_en- Clear Enable option. Example: 1 - channel clears when the part is cleared; 0 - channel does not clear when the part is cleared.

◆ ad5755_check_crc()

uint8_t ad5755_check_crc ( uint8_t * data,
uint8_t bytes_number )

Computes the CRC for a data buffer.

Parameters
data- Data buffer.
bytes_number- Data buffer size in bytes.
Returns
The computed CRC.

◆ ad5755_feed_watch_dog_timer()

void ad5755_feed_watch_dog_timer ( struct ad5755_dev * dev)

Write a "service pulse" to the AD5755 watchdog timer when enabled.

Parameters
dev- The device structure.

◆ ad5755_get_register_value()

int32_t ad5755_get_register_value ( struct ad5755_dev * dev,
uint8_t register_address )

Reads the value of a register.

Parameters
dev- The device structure.
register_address- Address of the register. Example: AD5755_RD_DATA_REG(x) AD5755_RD_CTRL_REG(x) AD5755_RD_GAIN_REG(x) AD5755_RD_OFFSET_REG(x) AD5755_RD_CODE_REG(x) AD5755_RD_SR_CTRL_REG(x) AD5755_RD_STATUS_REG AD5755_RD_MAIN_CTRL_REG AD5755_RD_Dc_DC_CTRL_REG x = any of AD5755_DAC_A, .. AD5755_DAC_D
Returns
regValue - Value of the register.

◆ ad5755_init()

int8_t ad5755_init ( struct ad5755_dev ** device,
struct ad5755_init_param init_param )

Initializes the device and powers-up all channels. The device is initialized with the values held by AD5755_InitialSettings structure.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
status - Result of the initialization procedure. Example: -1 - SPI peripheral was not initialized. 0 - SPI peripheral is initialized.

◆ ad5755_remove()

int32_t ad5755_remove ( struct ad5755_dev * dev)

Free the resources allocated by ad5755_init().

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5755_set_channel_power()

void ad5755_set_channel_power ( struct ad5755_dev * dev,
uint8_t channel,
uint8_t pwr_status )

Allows power-up/down of the dc-to-dc converter, DAC and internal amplifiers for the selected channel.

Parameters
dev- The device structure.
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
pwr_status- Power mode. Example: 0 - power-down the channel; 1 - power-up the channel.

◆ ad5755_set_channel_range()

void ad5755_set_channel_range ( struct ad5755_dev * dev,
uint8_t channel,
uint8_t range )

Sets the range of a channel.

Parameters
dev- The device structure.
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
range- Range option. Example: AD5755_R_0_5_V - 0 V to 5 V voltage range (default) AD5755_R_0_10_V - 0 V to 10 V voltage range AD5755_R_M5_P5_V - -5 V to +5 V voltage range AD5755_R_M10_P10_V - -10 V to 10 V voltage range AD5755_R_4_20_MA - 4 mA to 20 mA current range AD5755_R_0_20_MA - 0 mA to 20 mA current range AD5755_R_0_24_MA - 0 mA to 24 mA current range

◆ ad5755_set_control_registers()

void ad5755_set_control_registers ( struct ad5755_dev * dev,
uint8_t ctrl_reg_address,
uint8_t channel,
uint16_t reg_value )

Configures one of the control registers.

Parameters
dev- The device structure.
ctrl_reg_address- Control Register Address. Example: AD5755_CREG_SLEW AD5755_CREG_MAIN AD5755_CREG_DAC AD5755_CREG_DC_DC AD5755_CREG_SOFT
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
reg_value- Value to be written to the selected Control Register.

◆ ad5755_set_current()

float ad5755_set_current ( struct ad5755_dev * dev,
uint8_t channel,
float m_acurrent )

Sets the output current of a channel.

Parameters
dev- The device structure.
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
m_acurrent- Value to be outputted by the DAC(milliampere).
Returns
The actual current value that can be outputted by the channel.

◆ ad5755_set_register_value()

uint16_t ad5755_set_register_value ( struct ad5755_dev * dev,
uint8_t register_address,
uint8_t channel,
uint16_t register_value )

Writes data into a register.

Parameters
dev- The device structure.
register_address- Address of the register. Example: AD5755_DREG_WR_DAC AD5755_DREG_WR_GAIN AD5755_DREG_WR_GAIN_ALL AD5755_DREG_WR_OFFSET AD5755_DREG_WR_OFFSET_ALL AD5755_DREG_WR_CLR_CODE AD5755_DREG_WR_CTRL_REG
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
register_value- Data value to write.

◆ ad5755_set_voltage()

float ad5755_set_voltage ( struct ad5755_dev * dev,
uint8_t channel,
float voltage )

Sets the output voltage of a channel.

Parameters
dev- The device structure.
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
voltage- Value to be outputted by the DAC(Volts).
Returns
The actual voltage value that can be outputted by the channel.

◆ ad5755_slew_rate_ctrl()

void ad5755_slew_rate_ctrl ( struct ad5755_dev * dev,
int8_t channel,
int8_t sr_en,
int8_t updt_freq,
int8_t step_size )

Configures the Digital Slew Rate Control.

Parameters
dev- The device structure.
channel- Channel option. Example: AD5755_DAC_A AD5755_DAC_B AD5755_DAC_C AD5755_DAC_D
sr_en- Enable/Disable the Slew Rate Control. Example: 0 - disable feature; 1 - enable feature.
updt_freq- Update Clock Frequency(Hz). Example: AD5755_SR_CLK_64K AD5755_SR_CLK_32k ... AD5755_SR_CLK_8 AD5755_SR_CLK_4 AD5755_SR_CLK_0_5
step_size- Step Size (LSBs). Example: AD5755_STEP_1 AD5755_STEP_2 ... AD5755_STEP_128 AD5755_STEP_256

◆ ad5755_software_reset()

void ad5755_software_reset ( struct ad5755_dev * dev)

Performs a software reset to the device.

Parameters
dev- The device structure.

◆ ad5755_watch_dog_setup()

void ad5755_watch_dog_setup ( struct ad5755_dev * dev,
uint8_t wtd_enable,
uint8_t timeout )

Enables/Disables watchdog timer and sets the timeout period.

Parameters
dev- The device structure.
wtd_enable- Watchdog enable option. Example: 0 - disables watchdog timer 1 - enabled watchdog timer
timeout- Timeout period for the watchdog timer. Example: AD5755_WD_5MS AD5755_WD_10MS AD5755_WD_100MS AD5755_WD_200MS