no-OS
Loading...
Searching...
No Matches
ltc2672.h File Reference

Header file of ltc2672 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_error.h"
#include "no_os_units.h"
Include dependency graph for ltc2672.h:

Classes

struct  ltc2672_dev
 Structure holding ltc2672 descriptor. More...
 
struct  ltc2672_init_param
 Structure holding the parameters for ltc2672 initialization. More...
 

Macros

#define LTC2672_16_DONT_CARE   0xFFF0
 
#define LTC2672_MUX_DONT_CARE   0xFFFE0
 
#define LTC2672_DUMMY   0xFFFF
 
#define LTC2672_FAULT_REG_MASK   0xFF000000
 
#define LTC2672_COMMAND_MAX_BYTES   4
 
#define LTC2672_BASE_CURRENT   3.125
 
#define LTC2672_VMINUS_FIXED_CURRENT   -80
 
#define LTC2672_OFF_CURRENT   0
 
#define LTC2672_300MA_CURRENT   300
 
#define LTC2672_16BIT_RESO   65535
 
#define LTC2672_12BIT_RESO   4095
 
#define LTC2672_TOTAL_CHANNELS   5
 
#define LTC2672_MAX_CONFIG_MASK   15
 
#define LTC2672_MAX_TOGGLE_MASK   31
 
#define LTC2672_BIT_SHIFT_12BIT   4
 
#define LTC2672_NUM_CURRENT_SPANS   10
 
#define LTC2672_COMMAND32_GENERATE(comm, add, dat)
 
#define LTC2672_COMMAND24_GENERATE(comm, add, dat)
 
#define LTC2672_SPAN_SET(span_code)
 
#define LTC2672_MUX_SET(mux_code)
 
#define LTC2672_MUX32_GENERATE(comm, dat)
 
#define LTC2672_MUX24_GENERATE(comm, dat)
 

Enumerations

enum  ltc2672_commands {
  LTC2672_CODE_TO_CHANNEL_X ,
  LTC2672_PWRUP_UPD_CHANNEL_X ,
  LTC2672_CODE_TO_CHANNEL_X_PWRUP_UPD_CHANNEL_ALL ,
  LTC2672_CODE_PWRUP_UPD_CHANNEL_X ,
  LTC2672_PWRDWN_CHANNEL_X ,
  LTC2672_PWRDWN_DEV ,
  LTC2672_SPAN_TO_CHANNEL_X ,
  LTC2672_CNFG_CMD ,
  LTC2672_CODE_TO_CHANNEL_ALL ,
  LTC2672_PWRUP_UPD_CHANNEL_ALL ,
  LTC2672_CODE_PWRUP_UPD_CHANNEL_ALL ,
  LTC2672_MON_MUX ,
  LTC2672_TOGGLE_SEL ,
  LTC2672_TOGGLE_GLBL ,
  LTC2672_SPAN_TO_CHANNEL_ALL ,
  LTC2672_NO_OP
}
 
enum  ltc2672_device_id {
  LTC2662_12 ,
  LTC2662_16 ,
  LTC2672_12 ,
  LTC2672_16
}
 
enum  ltc2672_dac_ch {
  LTC2672_DAC0 ,
  LTC2672_DAC1 ,
  LTC2672_DAC2 ,
  LTC2672_DAC3 ,
  LTC2672_DAC4
}
 
enum  ltc2672_out_range {
  LTC2672_OFF ,
  LTC2672_50VREF ,
  LTC2672_100VREF ,
  LTC2672_200VREF ,
  LTC2672_400VREF ,
  LTC2672_800VREF ,
  LTC2672_1600VREF ,
  LTC2672_3200VREF ,
  LTC2672_VMINUS_VREF ,
  LTC2672_4800VREF = 0XF
}
 
enum  ltc2672_mux_commands {
  LTC2672_MUX_DISABLED ,
  LTC2672_MUX_IOUT0 ,
  LTC2672_MUX_IOUT1 ,
  LTC2672_MUX_IOUT2 ,
  LTC2672_MUX_IOUT3 ,
  LTC2672_MUX_IOUT4 ,
  LTC2672_MUC_VCC ,
  LTC2672_MUX_VREF = 0x08 ,
  LTC2672_MUX_VREF_LO ,
  LTC2672_MUX_DIE_TEMP ,
  LTC2672_MUX_VDD0 = 0x10 ,
  LTC2672_MUX_VDD1 ,
  LTC2672_MUX_VDD2 ,
  LTC2672_MUX_VDD3 ,
  LTC2672_MUX_VDD4 ,
  LTC2672_MUX_VPLUS ,
  LTC2672_MUX_VMINUS ,
  LTC2672_MUX_GND ,
  LTC2672_MUX_VOUT0 ,
  LTC2672_MUX_VOUT1 ,
  LTC2672_MUX_VOUT2 ,
  LTC2672_MUX_VOUT3 ,
  LTC2672_MUX_VOUT4
}
 
enum  ltc2672_faults {
  LTC2672_OPEN_OUT0 ,
  LTC2672_OPEN_OUT1 ,
  LTC2672_OPEN_OUT2 ,
  LTC2672_OPEN_OUT3 ,
  LTC2672_OPEN_OUT4 ,
  LTC2672_OVER_TEMP ,
  LTC2672_POW_LIM ,
  LTC2672_INV_LENGTH
}
 

Functions

int ltc2672_remove (struct ltc2672_dev *)
 Remove resources allocated by the init function.
 
int ltc2672_reset (struct ltc2672_dev *)
 Perform reset using clear GPIO.
 
int ltc2672_transaction (struct ltc2672_dev *device, uint32_t, bool)
 Write raw register value.
 
uint32_t ltc2672_current_to_code (struct ltc2672_dev *device, uint32_t, enum ltc2672_dac_ch)
 get dac code value from current of a selected DAC channel
 
int ltc2672_set_code_channel (struct ltc2672_dev *device, uint16_t code, enum ltc2672_dac_ch out_ch)
 sets the dac code for channel
 
int ltc2672_set_current_channel (struct ltc2672_dev *, uint32_t, enum ltc2672_dac_ch)
 set the current for a selected DAC channel
 
int ltc2672_set_code_all_channels (struct ltc2672_dev *device, uint16_t code)
 sets the same dac code for all channels
 
int ltc2672_set_current_all_channels (struct ltc2672_dev *, uint32_t)
 sets the same current for all channels
 
int ltc2672_set_span_channel (struct ltc2672_dev *, enum ltc2672_out_range, enum ltc2672_dac_ch)
 sets output span for channel
 
int ltc2672_set_span_all_channels (struct ltc2672_dev *, enum ltc2672_out_range)
 sets the same output span for all channels
 
int ltc2672_chip_power_down (struct ltc2672_dev *)
 power down ltc2672
 
int ltc2672_power_down_channel (struct ltc2672_dev *, enum ltc2672_dac_ch)
 power down a channel
 
int ltc2672_power_down_all_channels (struct ltc2672_dev *)
 power down ALL channels
 
int ltc2672_monitor_mux (struct ltc2672_dev *, enum ltc2672_mux_commands)
 configures mux output depending on target measurement
 
int ltc2672_setup_toggle_channel (struct ltc2672_dev *, enum ltc2672_dac_ch, uint32_t, uint32_t)
 setup toggle parameters for a channel
 
int ltc2672_write_input_register_channel (struct ltc2672_dev *, enum ltc2672_dac_ch, uint32_t, bool)
 writes to the input register of a channel
 
int ltc2672_write_input_register_all_channels (struct ltc2672_dev *, uint32_t, bool)
 writes to the input registers of all channels
 
int ltc2672_enable_toggle_channel (struct ltc2672_dev *, uint32_t)
 enables or disables selected channel/s for toggling
 
int ltc2672_global_toggle (struct ltc2672_dev *, bool)
 enables or disables global toggle bit
 
int ltc2672_config_command (struct ltc2672_dev *, uint8_t)
 configures the fault detection bits
 
int ltc2672_update_channel (struct ltc2672_dev *, enum ltc2672_dac_ch)
 updates the channel
 
int ltc2672_update_all_channels (struct ltc2672_dev *)
 updates all the channels
 
int ltc2672_hw_ldac_update (struct ltc2672_dev *)
 updates all the channels using the LDAC pin
 
int ltc2672_init (struct ltc2672_dev **, struct ltc2672_init_param *)
 Device and communication init function.
 

Detailed Description

Header file of ltc2672 Driver.

Author
JSanBuen (jose..nosp@m.sanb.nosp@m.uenav.nosp@m.entu.nosp@m.ra@an.nosp@m.alog.nosp@m..com)

Copyright 2023(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ LTC2672_12BIT_RESO

#define LTC2672_12BIT_RESO   4095

◆ LTC2672_16_DONT_CARE

#define LTC2672_16_DONT_CARE   0xFFF0

◆ LTC2672_16BIT_RESO

#define LTC2672_16BIT_RESO   65535

◆ LTC2672_300MA_CURRENT

#define LTC2672_300MA_CURRENT   300

◆ LTC2672_BASE_CURRENT

#define LTC2672_BASE_CURRENT   3.125

◆ LTC2672_BIT_SHIFT_12BIT

#define LTC2672_BIT_SHIFT_12BIT   4

◆ LTC2672_COMMAND24_GENERATE

#define LTC2672_COMMAND24_GENERATE ( comm,
add,
dat )
Value:
(comm << 20) | (add << 16) | (dat)

◆ LTC2672_COMMAND32_GENERATE

#define LTC2672_COMMAND32_GENERATE ( comm,
add,
dat )
Value:
(0xFF << 24) | (comm << 20) | (add << 16) | (dat)

◆ LTC2672_COMMAND_MAX_BYTES

#define LTC2672_COMMAND_MAX_BYTES   4

◆ LTC2672_DUMMY

#define LTC2672_DUMMY   0xFFFF

◆ LTC2672_FAULT_REG_MASK

#define LTC2672_FAULT_REG_MASK   0xFF000000

◆ LTC2672_MAX_CONFIG_MASK

#define LTC2672_MAX_CONFIG_MASK   15

◆ LTC2672_MAX_TOGGLE_MASK

#define LTC2672_MAX_TOGGLE_MASK   31

◆ LTC2672_MUX24_GENERATE

#define LTC2672_MUX24_GENERATE ( comm,
dat )
Value:
(comm << 20) | (dat)

◆ LTC2672_MUX32_GENERATE

#define LTC2672_MUX32_GENERATE ( comm,
dat )
Value:
(0xFF << 24) | (comm << 20) | (dat)

◆ LTC2672_MUX_DONT_CARE

#define LTC2672_MUX_DONT_CARE   0xFFFE0

◆ LTC2672_MUX_SET

#define LTC2672_MUX_SET ( mux_code)
Value:
#define LTC2672_MUX_DONT_CARE
Definition ltc2672.h:22

◆ LTC2672_NUM_CURRENT_SPANS

#define LTC2672_NUM_CURRENT_SPANS   10

◆ LTC2672_OFF_CURRENT

#define LTC2672_OFF_CURRENT   0

◆ LTC2672_SPAN_SET

#define LTC2672_SPAN_SET ( span_code)
Value:
#define LTC2672_16_DONT_CARE
Definition ltc2672.h:21

◆ LTC2672_TOTAL_CHANNELS

#define LTC2672_TOTAL_CHANNELS   5

◆ LTC2672_VMINUS_FIXED_CURRENT

#define LTC2672_VMINUS_FIXED_CURRENT   -80

Enumeration Type Documentation

◆ ltc2672_commands

Enumerator
LTC2672_CODE_TO_CHANNEL_X 
LTC2672_PWRUP_UPD_CHANNEL_X 
LTC2672_CODE_TO_CHANNEL_X_PWRUP_UPD_CHANNEL_ALL 
LTC2672_CODE_PWRUP_UPD_CHANNEL_X 
LTC2672_PWRDWN_CHANNEL_X 
LTC2672_PWRDWN_DEV 
LTC2672_SPAN_TO_CHANNEL_X 
LTC2672_CNFG_CMD 
LTC2672_CODE_TO_CHANNEL_ALL 
LTC2672_PWRUP_UPD_CHANNEL_ALL 
LTC2672_CODE_PWRUP_UPD_CHANNEL_ALL 
LTC2672_MON_MUX 
LTC2672_TOGGLE_SEL 
LTC2672_TOGGLE_GLBL 
LTC2672_SPAN_TO_CHANNEL_ALL 
LTC2672_NO_OP 

◆ ltc2672_dac_ch

Enumerator
LTC2672_DAC0 
LTC2672_DAC1 
LTC2672_DAC2 
LTC2672_DAC3 
LTC2672_DAC4 

◆ ltc2672_device_id

Enumerator
LTC2662_12 
LTC2662_16 
LTC2672_12 
LTC2672_16 

◆ ltc2672_faults

Enumerator
LTC2672_OPEN_OUT0 
LTC2672_OPEN_OUT1 
LTC2672_OPEN_OUT2 
LTC2672_OPEN_OUT3 
LTC2672_OPEN_OUT4 
LTC2672_OVER_TEMP 
LTC2672_POW_LIM 
LTC2672_INV_LENGTH 

◆ ltc2672_mux_commands

Enumerator
LTC2672_MUX_DISABLED 
LTC2672_MUX_IOUT0 
LTC2672_MUX_IOUT1 
LTC2672_MUX_IOUT2 
LTC2672_MUX_IOUT3 
LTC2672_MUX_IOUT4 
LTC2672_MUC_VCC 
LTC2672_MUX_VREF 
LTC2672_MUX_VREF_LO 
LTC2672_MUX_DIE_TEMP 
LTC2672_MUX_VDD0 
LTC2672_MUX_VDD1 
LTC2672_MUX_VDD2 
LTC2672_MUX_VDD3 
LTC2672_MUX_VDD4 
LTC2672_MUX_VPLUS 
LTC2672_MUX_VMINUS 
LTC2672_MUX_GND 
LTC2672_MUX_VOUT0 
LTC2672_MUX_VOUT1 
LTC2672_MUX_VOUT2 
LTC2672_MUX_VOUT3 
LTC2672_MUX_VOUT4 

◆ ltc2672_out_range

Enumerator
LTC2672_OFF 
LTC2672_50VREF 
LTC2672_100VREF 
LTC2672_200VREF 
LTC2672_400VREF 
LTC2672_800VREF 
LTC2672_1600VREF 
LTC2672_3200VREF 
LTC2672_VMINUS_VREF 
LTC2672_4800VREF 

Function Documentation

◆ ltc2672_chip_power_down()

int ltc2672_chip_power_down ( struct ltc2672_dev * device)

power down ltc2672

Power down the LTC2672-XX

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_config_command()

int ltc2672_config_command ( struct ltc2672_dev * device,
uint8_t mask )

configures the fault detection bits

Configures the fault/s to be detected

Parameters
device- ltc2672 descriptor
mask- mask that describes desired configuration
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_current_to_code()

uint32_t ltc2672_current_to_code ( struct ltc2672_dev * device,
uint32_t dac_current,
enum ltc2672_dac_ch out_ch )

get dac code value from current of a selected DAC channel

Convert current into dac code

Parameters
device- ltc2672 descriptor
dac_current- current in uA
out_ch- DAC channel
Returns
code value

◆ ltc2672_enable_toggle_channel()

int ltc2672_enable_toggle_channel ( struct ltc2672_dev * device,
uint32_t mask )

enables or disables selected channel/s for toggling

Enable channel/s to toggle

Parameters
device- ltc2672 descriptor
mask- mask that describes which channel/s to toggle
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_global_toggle()

int ltc2672_global_toggle ( struct ltc2672_dev * device,
bool is_enable )

enables or disables global toggle bit

Sets or resets the global toggle bit

Parameters
device- ltc2672 descriptor
is_enable- sets or resets the global toggle bit
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_hw_ldac_update()

int ltc2672_hw_ldac_update ( struct ltc2672_dev * device)

updates all the channels using the LDAC pin

Update all DAC channels using the LDAC pin

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_init()

int ltc2672_init ( struct ltc2672_dev ** device,
struct ltc2672_init_param * init_param )

Device and communication init function.

Device and communication init function

Parameters
device- ltc2672 descriptor to be initialized
init_param- Initial parameter for descriptor
Returns
0 in case of success, errno errors otherwise

◆ ltc2672_monitor_mux()

int ltc2672_monitor_mux ( struct ltc2672_dev * device,
enum ltc2672_mux_commands mux_comm )

configures mux output depending on target measurement

Configure the LTC2672-XX MUX pin output for selected measurement

Parameters
device- ltc2672 descriptor
mux_comm- multiplexer command code
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_power_down_all_channels()

int ltc2672_power_down_all_channels ( struct ltc2672_dev * device)

power down ALL channels

Power down all DAC channels

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_power_down_channel()

int ltc2672_power_down_channel ( struct ltc2672_dev * device,
enum ltc2672_dac_ch out_ch )

power down a channel

Power down a selected DAC channel

Parameters
device- ltc2672 descriptor
out_ch- DAC channel output to set
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_remove()

int ltc2672_remove ( struct ltc2672_dev * device)

Remove resources allocated by the init function.

Free resources allocated by the init function

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, errno errors otherwise

◆ ltc2672_reset()

int ltc2672_reset ( struct ltc2672_dev * device)

Perform reset using clear GPIO.

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, negative error code otherwise.

◆ ltc2672_set_code_all_channels()

int ltc2672_set_code_all_channels ( struct ltc2672_dev * device,
uint16_t code )

sets the same dac code for all channels

Set the dac code for all DAC channels

Parameters
device- ltc2672 descriptor
code- The code to be written
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_set_code_channel()

int ltc2672_set_code_channel ( struct ltc2672_dev * device,
uint16_t code,
enum ltc2672_dac_ch out_ch )

sets the dac code for channel

Set the dac code for a selected DAC channel

Parameters
device- ltc2672 descriptor
code- The code to be written
out_ch- channel to set the code
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_set_current_all_channels()

int ltc2672_set_current_all_channels ( struct ltc2672_dev * device,
uint32_t current )

sets the same current for all channels

Set the current for all DAC channels

Parameters
device- ltc2672 descriptor
current- current to set in uA
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_set_current_channel()

int ltc2672_set_current_channel ( struct ltc2672_dev * device,
uint32_t current,
enum ltc2672_dac_ch out_ch )

set the current for a selected DAC channel

Set the current for a selected DAC channel

Parameters
device- ltc2672 descriptor
current- current to set in uA
out_ch- channel to set the current
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_set_span_all_channels()

int ltc2672_set_span_all_channels ( struct ltc2672_dev * device,
enum ltc2672_out_range ch_span )

sets the same output span for all channels

Set the output span for all DAC channels

Parameters
device- ltc2672 descriptor
ch_span- max current span
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_set_span_channel()

int ltc2672_set_span_channel ( struct ltc2672_dev * device,
enum ltc2672_out_range ch_span,
enum ltc2672_dac_ch out_ch )

sets output span for channel

Set the output span for a selected DAC channel

Parameters
device- ltc2672 descriptor
ch_span- max current span
out_ch- DAC channel output to set
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_setup_toggle_channel()

int ltc2672_setup_toggle_channel ( struct ltc2672_dev * device,
enum ltc2672_dac_ch out_ch,
uint32_t current_reg_a,
uint32_t current_reg_b )

setup toggle parameters for a channel

Setup selected channel's reg A and B

Parameters
device- ltc2672 descriptor
out_ch- channel to toggle
current_reg_a- current to write in register A
current_reg_b- current to write in register B
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_transaction()

int ltc2672_transaction ( struct ltc2672_dev * device,
uint32_t comm,
bool is_32 )

Write raw register value.

Configure LTC2672 and get response

Parameters
device- ltc2672 descriptor
comm- command byte to send
is_32- flag if command is 32 bit (True) or 24 bit (False) format
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_update_all_channels()

int ltc2672_update_all_channels ( struct ltc2672_dev * device)

updates all the channels

Update all DAC channels

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_update_channel()

int ltc2672_update_channel ( struct ltc2672_dev * device,
enum ltc2672_dac_ch out_ch )

updates the channel

Update a selected DAC channel

Parameters
device- ltc2672 descriptor
out_ch- channel to update
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_write_input_register_all_channels()

int ltc2672_write_input_register_all_channels ( struct ltc2672_dev * device,
uint32_t current_reg,
bool is_reg_a )

writes to the input registers of all channels

Writes to the input register of all DAC channels

Parameters
device- ltc2672 descriptor
current_reg- current to write in register
is_reg_a- flag to select register A or B
Returns
0 in case of success, negative error code otherwise

◆ ltc2672_write_input_register_channel()

int ltc2672_write_input_register_channel ( struct ltc2672_dev * device,
enum ltc2672_dac_ch out_ch,
uint32_t current_reg,
bool is_reg_a )

writes to the input register of a channel

Writes to the input register of a selected DAC channel

Parameters
device- ltc2672 descriptor
out_ch- channel to set the current
current_reg- current to write in register
is_reg_a- flag to select register A or B
Returns
0 in case of success, negative error code otherwise