no-OS
Functions
ltc2672.c File Reference

Implementation of ltc2672 Driver. More...

#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "ltc2672.h"
#include "no_os_spi.h"
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
Include dependency graph for ltc2672.c:

Functions

int ltc2672_init (struct ltc2672_dev **device, struct ltc2672_init_param *init_param)
 Device and communication init function. More...
 
int ltc2672_remove (struct ltc2672_dev *device)
 Remove resources allocated by the init function. More...
 
int ltc2672_transaction (struct ltc2672_dev *device, uint32_t comm, bool is_32)
 Write raw register value. More...
 
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 More...
 
int ltc2672_set_code_channel (struct ltc2672_dev *device, uint16_t code, enum ltc2672_dac_ch out_ch)
 sets the dac code for channel More...
 
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 More...
 
int ltc2672_set_code_all_channels (struct ltc2672_dev *device, uint16_t code)
 sets the same dac code for all channels More...
 
int ltc2672_set_current_all_channels (struct ltc2672_dev *device, uint32_t current)
 sets the same current for all channels More...
 
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 More...
 
int ltc2672_set_span_all_channels (struct ltc2672_dev *device, enum ltc2672_out_range ch_span)
 sets the same output span for all channels More...
 
int ltc2672_chip_power_down (struct ltc2672_dev *device)
 power down ltc2672 More...
 
int ltc2672_power_down_channel (struct ltc2672_dev *device, enum ltc2672_dac_ch out_ch)
 power down a channel More...
 
int ltc2672_power_down_all_channels (struct ltc2672_dev *device)
 power down ALL channels More...
 
int ltc2672_monitor_mux (struct ltc2672_dev *device, enum ltc2672_mux_commands mux_comm)
 configures mux output depending on target measurement More...
 
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 More...
 
int ltc2672_enable_toggle_channel (struct ltc2672_dev *device, uint32_t mask)
 enables or disables selected channel/s for toggling More...
 
int ltc2672_global_toggle (struct ltc2672_dev *device, bool is_enable)
 enables or disables global toggle bit More...
 
int ltc2672_config_command (struct ltc2672_dev *device, uint8_t mask)
 configures the fault detection bits More...
 

Detailed Description

Implementation 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.

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.

Function Documentation

◆ ltc2672_chip_power_down()

int ltc2672_chip_power_down ( struct ltc2672_dev device)

power down ltc2672

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ltc2672_config_command()

int ltc2672_config_command ( struct ltc2672_dev device,
uint8_t  mask 
)

configures the fault detection bits

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

Parameters
device- ltc2672 descriptor
dac_current- current in uA
out_ch- DAC channel
Returns
code value
Here is the caller graph for this function:

◆ ltc2672_enable_toggle_channel()

int ltc2672_enable_toggle_channel ( struct ltc2672_dev device,
uint32_t  mask 
)

enables or disables selected channel/s for toggling

Parameters
device- ltc2672 descriptor
mask- mask that describes which channel/s to toggle
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ltc2672_global_toggle()

int ltc2672_global_toggle ( struct ltc2672_dev device,
bool  is_enable 
)

enables or disables 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
Here is the caller graph for this function:

◆ ltc2672_init()

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

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
Here is the caller graph for this function:

◆ ltc2672_monitor_mux()

int ltc2672_monitor_mux ( struct ltc2672_dev device,
enum ltc2672_mux_commands  mux_comm 
)

configures mux output depending on target measurement

Parameters
device- ltc2672 descriptor
mux_comm- multiplexer command code
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ ltc2672_power_down_all_channels()

int ltc2672_power_down_all_channels ( struct ltc2672_dev device)

power down ALL 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

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.

Parameters
device- ltc2672 descriptor
Returns
0 in case of success, errno errors otherwise
Here is the caller graph for this function:

◆ 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

Parameters
device- ltc2672 descriptor
code- The code to be written
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ 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

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
Here is the caller graph for this function:

◆ 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

Parameters
device- ltc2672 descriptor
current- current to set in uA
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ 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

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

Parameters
device- ltc2672 descriptor
ch_span- max current span
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ 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

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

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
Here is the caller graph for this function:

◆ ltc2672_transaction()

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

Write raw register value.

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
Here is the caller graph for this function: