no-OS
Classes | Macros | Enumerations | Functions
ltc268x.h File Reference

Header file of LTC2686/8 Driver. More...

#include "no_os_spi.h"
#include "no_os_util.h"
#include "no_os_delay.h"
#include "errno.h"
Include dependency graph for ltc268x.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ltc268x_span_tbl
 
struct  ltc268x_dev
 
struct  ltc268x_init_param
 

Macros

#define LTC268X_CHANNEL_SEL(x, id)   (id ? x : (x << 1))
 
#define LTC268X_CMD_CH_CODE(x, id)   (0x00 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CH_SETTING(x, id)   (0x10 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CH_OFFSET(x, id)   (0X20 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CH_GAIN(x, id)   (0x30 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CH_CODE_UPDATE(x, id)   (0x40 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CH_CODE_UPDATE_ALL(x, id)   (0x50 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CH_UPDATE(x, id)   (0x60 + LTC268X_CHANNEL_SEL(x, id))
 
#define LTC268X_CMD_CONFIG_REG   0x70
 
#define LTC268X_CMD_POWERDOWN_REG   0x71
 
#define LTC268X_CMD_A_B_SELECT_REG   0x72
 
#define LTC268X_CMD_SW_TOGGLE_REG   0x73
 
#define LTC268X_CMD_TOGGLE_DITHER_EN_REG   0x74
 
#define LTC268X_CMD_MUX_CTRL_REG   0x75
 
#define LTC268X_CMD_FAULT_REG   0x76
 
#define LTC268X_CMD_CODE_ALL   0x78
 
#define LTC268X_CMD_CODE_UPDATE_ALL   0x79
 
#define LTC268X_CMD_SETTING_ALL   0x7A
 
#define LTC268X_CMD_SETTING_UPDATE_ALL   0x7B
 
#define LTC268X_CMD_UPDATE_ALL   0x7C
 
#define LTC268X_CMD_NOOP   0xFF
 
#define LTC268X_READ_OPERATION   0x80
 
#define LTC268X_CH_SPAN_MSK   NO_OS_GENMASK(3, 0)
 
#define LTC268X_CH_SPAN(x)   no_os_field_prep(LTC268X_CH_SPAN_MSK, x)
 
#define LTC268X_CH_TD_SEL_MSK   NO_OS_GENMASK(5, 4)
 
#define LTC268X_CH_TD_SEL(x)   no_os_field_prep(LTC268X_CH_TD_SEL_MSK, x)
 
#define LTC268X_CH_DIT_PER_MSK   NO_OS_GENMASK(8, 6)
 
#define LTC268X_CH_DIT_PER(x)   no_os_field_prep(LTC268X_CH_DIT_PER_MSK, x)
 
#define LTC268X_CH_DIT_PH_MSK   NO_OS_GENMASK(10, 9)
 
#define LTC268X_CH_DIT_PH(x)   no_os_field_prep(LTC268X_CH_DIT_PH_MSK, x)
 
#define LTC268X_CH_MODE   NO_OS_BIT(11)
 
#define LTC268X_CONFIG_RST   NO_OS_BIT(15)
 
#define LTC268X_PWDN(x)   (1 << ((x) & 0xF))
 
#define LTC268X_DITH_EN(x)   (1 << ((x) & 0xF))
 

Enumerations

enum  ltc268x_voltage_range {
  LTC268X_VOLTAGE_RANGE_0V_5V,
  LTC268X_VOLTAGE_RANGE_0V_10V,
  LTC268X_VOLTAGE_RANGE_M5V_5V,
  LTC268X_VOLTAGE_RANGE_M10V_10V,
  LTC268X_VOLTAGE_RANGE_M15V_15V
}
 
enum  ltc268x_dither_period {
  LTC268X_DITH_PERIOD_4,
  LTC268X_DITH_PERIOD_8,
  LTC268X_DITH_PERIOD_16,
  LTC268X_DITH_PERIOD_32,
  LTC268X_DITH_PERIOD_64
}
 
enum  ltc268x_dither_phase {
  LTC268X_DITH_PHASE_0,
  LTC268X_DITH_PHASE_90,
  LTC268X_DITH_PHASE_180,
  LTC268X_DITH_PHASE_270
}
 
enum  ltc268x_a_b_register {
  LTC268X_SELECT_A_REG,
  LTC268X_SELECT_B_REG
}
 
enum  ltc268x_clk_input {
  LTC268X_SOFT_TGL,
  LTC268X_TGP0,
  LTC268X_TGP1,
  LTC268X_TGP2
}
 
enum  ltc268x_device_id {
  LTC2686 = 0,
  LTC2688 = 1
}
 

Functions

int32_t ltc268x_set_pwr_dac (struct ltc268x_dev *dev, uint16_t setting)
 
int32_t ltc268x_set_dither_toggle (struct ltc268x_dev *dev, uint16_t setting)
 
int32_t ltc268x_set_dither_mode (struct ltc268x_dev *dev, uint8_t channel, bool en)
 
int32_t ltc268x_set_span (struct ltc268x_dev *dev, uint8_t channel, enum ltc268x_voltage_range range)
 
int32_t ltc268x_set_dither_phase (struct ltc268x_dev *dev, uint8_t channel, enum ltc268x_dither_phase phase)
 
int32_t ltc268x_set_dither_period (struct ltc268x_dev *dev, uint8_t channel, enum ltc268x_dither_period period)
 
int32_t ltc268x_select_tg_dith_clk (struct ltc268x_dev *dev, uint8_t channel, enum ltc268x_clk_input clk_input)
 
int32_t ltc268x_select_reg (struct ltc268x_dev *dev, uint8_t channel, enum ltc268x_a_b_register sel_reg)
 
int32_t ltc268x_software_reset (struct ltc268x_dev *dev)
 
int32_t ltc268x_set_voltage (struct ltc268x_dev *dev, uint8_t channel, float voltage)
 
int32_t ltc268x_software_toggle (struct ltc268x_dev *dev, uint8_t channel)
 
int32_t ltc268x_init (struct ltc268x_dev **device, struct ltc268x_init_param init_param)
 
int32_t ltc268x_remove (struct ltc268x_dev *dev)
 Free the resources allocated by ltc268x_init(). More...
 

Detailed Description

Header file of LTC2686/8 Driver.

Author
Mircea Caprioru (mirce.nosp@m.a.ca.nosp@m.prior.nosp@m.u@an.nosp@m.alog..nosp@m.com)

Copyright 2021(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.

Macro Definition Documentation

◆ LTC268X_CH_DIT_PER

#define LTC268X_CH_DIT_PER (   x)    no_os_field_prep(LTC268X_CH_DIT_PER_MSK, x)

◆ LTC268X_CH_DIT_PER_MSK

#define LTC268X_CH_DIT_PER_MSK   NO_OS_GENMASK(8, 6)

◆ LTC268X_CH_DIT_PH

#define LTC268X_CH_DIT_PH (   x)    no_os_field_prep(LTC268X_CH_DIT_PH_MSK, x)

◆ LTC268X_CH_DIT_PH_MSK

#define LTC268X_CH_DIT_PH_MSK   NO_OS_GENMASK(10, 9)

◆ LTC268X_CH_MODE

#define LTC268X_CH_MODE   NO_OS_BIT(11)

◆ LTC268X_CH_SPAN

#define LTC268X_CH_SPAN (   x)    no_os_field_prep(LTC268X_CH_SPAN_MSK, x)

◆ LTC268X_CH_SPAN_MSK

#define LTC268X_CH_SPAN_MSK   NO_OS_GENMASK(3, 0)

◆ LTC268X_CH_TD_SEL

#define LTC268X_CH_TD_SEL (   x)    no_os_field_prep(LTC268X_CH_TD_SEL_MSK, x)

◆ LTC268X_CH_TD_SEL_MSK

#define LTC268X_CH_TD_SEL_MSK   NO_OS_GENMASK(5, 4)

◆ LTC268X_CHANNEL_SEL

#define LTC268X_CHANNEL_SEL (   x,
  id 
)    (id ? x : (x << 1))

◆ LTC268X_CMD_A_B_SELECT_REG

#define LTC268X_CMD_A_B_SELECT_REG   0x72

◆ LTC268X_CMD_CH_CODE

#define LTC268X_CMD_CH_CODE (   x,
  id 
)    (0x00 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CH_CODE_UPDATE

#define LTC268X_CMD_CH_CODE_UPDATE (   x,
  id 
)    (0x40 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CH_CODE_UPDATE_ALL

#define LTC268X_CMD_CH_CODE_UPDATE_ALL (   x,
  id 
)    (0x50 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CH_GAIN

#define LTC268X_CMD_CH_GAIN (   x,
  id 
)    (0x30 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CH_OFFSET

#define LTC268X_CMD_CH_OFFSET (   x,
  id 
)    (0X20 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CH_SETTING

#define LTC268X_CMD_CH_SETTING (   x,
  id 
)    (0x10 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CH_UPDATE

#define LTC268X_CMD_CH_UPDATE (   x,
  id 
)    (0x60 + LTC268X_CHANNEL_SEL(x, id))

◆ LTC268X_CMD_CODE_ALL

#define LTC268X_CMD_CODE_ALL   0x78

◆ LTC268X_CMD_CODE_UPDATE_ALL

#define LTC268X_CMD_CODE_UPDATE_ALL   0x79

◆ LTC268X_CMD_CONFIG_REG

#define LTC268X_CMD_CONFIG_REG   0x70

◆ LTC268X_CMD_FAULT_REG

#define LTC268X_CMD_FAULT_REG   0x76

◆ LTC268X_CMD_MUX_CTRL_REG

#define LTC268X_CMD_MUX_CTRL_REG   0x75

◆ LTC268X_CMD_NOOP

#define LTC268X_CMD_NOOP   0xFF

◆ LTC268X_CMD_POWERDOWN_REG

#define LTC268X_CMD_POWERDOWN_REG   0x71

◆ LTC268X_CMD_SETTING_ALL

#define LTC268X_CMD_SETTING_ALL   0x7A

◆ LTC268X_CMD_SETTING_UPDATE_ALL

#define LTC268X_CMD_SETTING_UPDATE_ALL   0x7B

◆ LTC268X_CMD_SW_TOGGLE_REG

#define LTC268X_CMD_SW_TOGGLE_REG   0x73

◆ LTC268X_CMD_TOGGLE_DITHER_EN_REG

#define LTC268X_CMD_TOGGLE_DITHER_EN_REG   0x74

◆ LTC268X_CMD_UPDATE_ALL

#define LTC268X_CMD_UPDATE_ALL   0x7C

◆ LTC268X_CONFIG_RST

#define LTC268X_CONFIG_RST   NO_OS_BIT(15)

◆ LTC268X_DITH_EN

#define LTC268X_DITH_EN (   x)    (1 << ((x) & 0xF))

◆ LTC268X_PWDN

#define LTC268X_PWDN (   x)    (1 << ((x) & 0xF))

◆ LTC268X_READ_OPERATION

#define LTC268X_READ_OPERATION   0x80

Enumeration Type Documentation

◆ ltc268x_a_b_register

Enumerator
LTC268X_SELECT_A_REG 
LTC268X_SELECT_B_REG 

◆ ltc268x_clk_input

Enumerator
LTC268X_SOFT_TGL 
LTC268X_TGP0 
LTC268X_TGP1 
LTC268X_TGP2 

◆ ltc268x_device_id

Enumerator
LTC2686 
LTC2688 

◆ ltc268x_dither_period

Enumerator
LTC268X_DITH_PERIOD_4 
LTC268X_DITH_PERIOD_8 
LTC268X_DITH_PERIOD_16 
LTC268X_DITH_PERIOD_32 
LTC268X_DITH_PERIOD_64 

◆ ltc268x_dither_phase

Enumerator
LTC268X_DITH_PHASE_0 
LTC268X_DITH_PHASE_90 
LTC268X_DITH_PHASE_180 
LTC268X_DITH_PHASE_270 

◆ ltc268x_voltage_range

Enumerator
LTC268X_VOLTAGE_RANGE_0V_5V 
LTC268X_VOLTAGE_RANGE_0V_10V 
LTC268X_VOLTAGE_RANGE_M5V_5V 
LTC268X_VOLTAGE_RANGE_M10V_10V 
LTC268X_VOLTAGE_RANGE_M15V_15V 

Function Documentation

◆ ltc268x_init()

int32_t ltc268x_init ( struct ltc268x_dev **  device,
struct ltc268x_init_param  init_param 
)

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.

◆ ltc268x_remove()

int32_t ltc268x_remove ( struct ltc268x_dev dev)

Free the resources allocated by ltc268x_init().

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

◆ ltc268x_select_reg()

int32_t ltc268x_select_reg ( struct ltc268x_dev dev,
uint8_t  channel,
enum ltc268x_a_b_register  sel_reg 
)

Select register A or B for value.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
sel_reg- Select register A or B to store DAC output value.
Returns
0 in case of success, negative error code otherwise.

◆ ltc268x_select_tg_dith_clk()

int32_t ltc268x_select_tg_dith_clk ( struct ltc268x_dev dev,
uint8_t  channel,
enum ltc268x_clk_input  clk_input 
)

Select dither/toggle clock input.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
clk_input- Select the source for the clock input.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_dither_mode()

int32_t ltc268x_set_dither_mode ( struct ltc268x_dev dev,
uint8_t  channel,
bool  en 
)

Set channel to dither mode.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
en- enable or disable dither mode
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_dither_period()

int32_t ltc268x_set_dither_period ( struct ltc268x_dev dev,
uint8_t  channel,
enum ltc268x_dither_period  period 
)

Set channel dither period.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
period- Dither period.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_dither_phase()

int32_t ltc268x_set_dither_phase ( struct ltc268x_dev dev,
uint8_t  channel,
enum ltc268x_dither_phase  phase 
)

Set channel dither phase.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
phase- Dither phase.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_dither_toggle()

int32_t ltc268x_set_dither_toggle ( struct ltc268x_dev dev,
uint16_t  setting 
)

Enable dither/toggle for selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: LTC268X_DITH_EN(x) | LTC268X_DITH_EN(y) | ...
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_pwr_dac()

int32_t ltc268x_set_pwr_dac ( struct ltc268x_dev dev,
uint16_t  setting 
)

Power down the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: LTC268X_PWDN(x) | LTC268X_PWDN(y) | ...
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_span()

int32_t ltc268x_set_span ( struct ltc268x_dev dev,
uint8_t  channel,
enum ltc268x_voltage_range  range 
)

Set channel span.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
range- Voltage range.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_set_voltage()

int32_t ltc268x_set_voltage ( struct ltc268x_dev dev,
uint8_t  channel,
float  voltage 
)

Sets the output voltage of a channel.

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

◆ ltc268x_software_reset()

int32_t ltc268x_software_reset ( struct ltc268x_dev dev)

Software reset the device.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc268x_software_toggle()

int32_t ltc268x_software_toggle ( struct ltc268x_dev dev,
uint8_t  channel 
)

Toggle the software source for dither/toggle.

Parameters
dev- The device structure.
channel- The channel for which to change the mode.
Returns
0 in case of success, negative error code otherwise.