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

Header file of LTC2688 Driver. More...

#include "no-os/spi.h"
#include "no-os/util.h"
#include "no-os/delay.h"
#include "errno.h"
Include dependency graph for ltc2688.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ltc2688_span_tbl
 
struct  ltc2688_dev
 
struct  ltc2688_init_param
 

Macros

#define LTC2688_DAC_CHANNELS   16
 
#define LTC2688_CMD_CH_CODE(x)   (0x00 + x)
 
#define LTC2688_CMD_CH_SETTING(x)   (0x10 + x)
 
#define LTC2688_CMD_CH_OFFSET(x)   (0X20 + x)
 
#define LTC2688_CMD_CH_GAIN(x)   (0x30 + x)
 
#define LTC2688_CMD_CH_CODE_UPDATE(x)   (0x40 + x)
 
#define LTC2688_CMD_CH_CODE_UPDATE_ALL(x)   (0x50 + x)
 
#define LTC2688_CMD_CH_UPDATE(x)   (0x60 + x)
 
#define LTC2688_CMD_CONFIG_REG   0x70
 
#define LTC2688_CMD_POWERDOWN_REG   0x71
 
#define LTC2688_CMD_A_B_SELECT_REG   0x72
 
#define LTC2688_CMD_SW_TOGGLE_REG   0x73
 
#define LTC2688_CMD_TOGGLE_DITHER_EN_REG   0x74
 
#define LTC2688_CMD_MUX_CTRL_REG   0x75
 
#define LTC2688_CMD_FAULT_REG   0x76
 
#define LTC2688_CMD_CODE_ALL   0x78
 
#define LTC2688_CMD_CODE_UPDATE_ALL   0x79
 
#define LTC2688_CMD_SETTING_ALL   0x7A
 
#define LTC2688_CMD_SETTING_UPDATE_ALL   0x7B
 
#define LTC2688_CMD_UPDATE_ALL   0x7C
 
#define LTC2688_CMD_NOOP   0xFF
 
#define LTC2688_READ_OPERATION   0x80
 
#define LTC2688_CH_SPAN_MSK   GENMASK(3, 0)
 
#define LTC2688_CH_SPAN(x)   field_prep(LTC2688_CH_SPAN_MSK, x)
 
#define LTC2688_CH_TD_SEL_MSK   GENMASK(5, 4)
 
#define LTC2688_CH_TD_SEL(x)   field_prep(LTC2688_CH_TD_SEL_MSK, x)
 
#define LTC2688_CH_DIT_PER_MSK   GENMASK(8, 6)
 
#define LTC2688_CH_DIT_PER(x)   field_prep(LTC2688_CH_DIT_PER_MSK, x)
 
#define LTC2688_CH_DIT_PH_MSK   GENMASK(10, 9)
 
#define LTC2688_CH_DIT_PH(x)   field_prep(LTC2688_CH_DIT_PH_MSK, x)
 
#define LTC2688_CH_MODE   BIT(11)
 
#define LTC2688_CONFIG_RST   BIT(15)
 
#define LTC2688_PWDN(x)   (1 << ((x) & 0xF))
 
#define LTC2688_DITH_EN(x)   (1 << ((x) & 0xF))
 

Enumerations

enum  ltc2688_voltage_range {
  LTC2688_VOLTAGE_RANGE_0V_5V,
  LTC2688_VOLTAGE_RANGE_0V_10V,
  LTC2688_VOLTAGE_RANGE_M5V_5V,
  LTC2688_VOLTAGE_RANGE_M10V_10V,
  LTC2688_VOLTAGE_RANGE_M15V_15V
}
 
enum  ltc2688_dither_period {
  LTC2688_DITH_PERIOD_4,
  LTC2688_DITH_PERIOD_8,
  LTC2688_DITH_PERIOD_16,
  LTC2688_DITH_PERIOD_32,
  LTC2688_DITH_PERIOD_64
}
 
enum  ltc2688_dither_phase {
  LTC2688_DITH_PHASE_0,
  LTC2688_DITH_PHASE_90,
  LTC2688_DITH_PHASE_180,
  LTC2688_DITH_PHASE_270
}
 
enum  ltc2688_a_b_register {
  LTC2688_SELECT_A_REG,
  LTC2688_SELECT_B_REG
}
 
enum  ltc2688_clk_input {
  LTC2688_SOFT_TGL,
  LTC2688_TGP0,
  LTC2688_TGP1,
  LTC2688_TGP2
}
 

Functions

int32_t ltc2688_set_pwr_dac (struct ltc2688_dev *dev, uint16_t setting)
 
int32_t ltc2688_set_dither_toggle (struct ltc2688_dev *dev, uint16_t setting)
 
int32_t ltc2688_set_dither_mode (struct ltc2688_dev *dev, uint8_t channel, bool en)
 
int32_t ltc2688_set_span (struct ltc2688_dev *dev, uint8_t channel, enum ltc2688_voltage_range range)
 
int32_t ltc2688_set_dither_phase (struct ltc2688_dev *dev, uint8_t channel, enum ltc2688_dither_phase phase)
 
int32_t ltc2688_set_dither_period (struct ltc2688_dev *dev, uint8_t channel, enum ltc2688_dither_period period)
 
int32_t ltc2688_select_tg_dith_clk (struct ltc2688_dev *dev, uint8_t channel, enum ltc2688_clk_input clk_input)
 
int32_t ltc2688_select_reg (struct ltc2688_dev *dev, uint8_t channel, enum ltc2688_a_b_register sel_reg)
 
int32_t ltc2688_software_reset (struct ltc2688_dev *dev)
 
int32_t ltc2688_set_voltage (struct ltc2688_dev *dev, uint8_t channel, float voltage)
 
int32_t ltc2688_software_toggle (struct ltc2688_dev *dev, uint8_t channel)
 
int32_t ltc2688_init (struct ltc2688_dev **device, struct ltc2688_init_param init_param)
 
int32_t ltc2688_remove (struct ltc2688_dev *dev)
 Free the resources allocated by ltc2688_init(). More...
 

Detailed Description

Header file of LTC2688 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.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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

◆ LTC2688_CH_DIT_PER

#define LTC2688_CH_DIT_PER (   x)    field_prep(LTC2688_CH_DIT_PER_MSK, x)

◆ LTC2688_CH_DIT_PER_MSK

#define LTC2688_CH_DIT_PER_MSK   GENMASK(8, 6)

◆ LTC2688_CH_DIT_PH

#define LTC2688_CH_DIT_PH (   x)    field_prep(LTC2688_CH_DIT_PH_MSK, x)

◆ LTC2688_CH_DIT_PH_MSK

#define LTC2688_CH_DIT_PH_MSK   GENMASK(10, 9)

◆ LTC2688_CH_MODE

#define LTC2688_CH_MODE   BIT(11)

◆ LTC2688_CH_SPAN

#define LTC2688_CH_SPAN (   x)    field_prep(LTC2688_CH_SPAN_MSK, x)

◆ LTC2688_CH_SPAN_MSK

#define LTC2688_CH_SPAN_MSK   GENMASK(3, 0)

◆ LTC2688_CH_TD_SEL

#define LTC2688_CH_TD_SEL (   x)    field_prep(LTC2688_CH_TD_SEL_MSK, x)

◆ LTC2688_CH_TD_SEL_MSK

#define LTC2688_CH_TD_SEL_MSK   GENMASK(5, 4)

◆ LTC2688_CMD_A_B_SELECT_REG

#define LTC2688_CMD_A_B_SELECT_REG   0x72

◆ LTC2688_CMD_CH_CODE

#define LTC2688_CMD_CH_CODE (   x)    (0x00 + x)

◆ LTC2688_CMD_CH_CODE_UPDATE

#define LTC2688_CMD_CH_CODE_UPDATE (   x)    (0x40 + x)

◆ LTC2688_CMD_CH_CODE_UPDATE_ALL

#define LTC2688_CMD_CH_CODE_UPDATE_ALL (   x)    (0x50 + x)

◆ LTC2688_CMD_CH_GAIN

#define LTC2688_CMD_CH_GAIN (   x)    (0x30 + x)

◆ LTC2688_CMD_CH_OFFSET

#define LTC2688_CMD_CH_OFFSET (   x)    (0X20 + x)

◆ LTC2688_CMD_CH_SETTING

#define LTC2688_CMD_CH_SETTING (   x)    (0x10 + x)

◆ LTC2688_CMD_CH_UPDATE

#define LTC2688_CMD_CH_UPDATE (   x)    (0x60 + x)

◆ LTC2688_CMD_CODE_ALL

#define LTC2688_CMD_CODE_ALL   0x78

◆ LTC2688_CMD_CODE_UPDATE_ALL

#define LTC2688_CMD_CODE_UPDATE_ALL   0x79

◆ LTC2688_CMD_CONFIG_REG

#define LTC2688_CMD_CONFIG_REG   0x70

◆ LTC2688_CMD_FAULT_REG

#define LTC2688_CMD_FAULT_REG   0x76

◆ LTC2688_CMD_MUX_CTRL_REG

#define LTC2688_CMD_MUX_CTRL_REG   0x75

◆ LTC2688_CMD_NOOP

#define LTC2688_CMD_NOOP   0xFF

◆ LTC2688_CMD_POWERDOWN_REG

#define LTC2688_CMD_POWERDOWN_REG   0x71

◆ LTC2688_CMD_SETTING_ALL

#define LTC2688_CMD_SETTING_ALL   0x7A

◆ LTC2688_CMD_SETTING_UPDATE_ALL

#define LTC2688_CMD_SETTING_UPDATE_ALL   0x7B

◆ LTC2688_CMD_SW_TOGGLE_REG

#define LTC2688_CMD_SW_TOGGLE_REG   0x73

◆ LTC2688_CMD_TOGGLE_DITHER_EN_REG

#define LTC2688_CMD_TOGGLE_DITHER_EN_REG   0x74

◆ LTC2688_CMD_UPDATE_ALL

#define LTC2688_CMD_UPDATE_ALL   0x7C

◆ LTC2688_CONFIG_RST

#define LTC2688_CONFIG_RST   BIT(15)

◆ LTC2688_DAC_CHANNELS

#define LTC2688_DAC_CHANNELS   16

◆ LTC2688_DITH_EN

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

◆ LTC2688_PWDN

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

◆ LTC2688_READ_OPERATION

#define LTC2688_READ_OPERATION   0x80

Enumeration Type Documentation

◆ ltc2688_a_b_register

Enumerator
LTC2688_SELECT_A_REG 
LTC2688_SELECT_B_REG 

◆ ltc2688_clk_input

Enumerator
LTC2688_SOFT_TGL 
LTC2688_TGP0 
LTC2688_TGP1 
LTC2688_TGP2 

◆ ltc2688_dither_period

Enumerator
LTC2688_DITH_PERIOD_4 
LTC2688_DITH_PERIOD_8 
LTC2688_DITH_PERIOD_16 
LTC2688_DITH_PERIOD_32 
LTC2688_DITH_PERIOD_64 

◆ ltc2688_dither_phase

Enumerator
LTC2688_DITH_PHASE_0 
LTC2688_DITH_PHASE_90 
LTC2688_DITH_PHASE_180 
LTC2688_DITH_PHASE_270 

◆ ltc2688_voltage_range

Enumerator
LTC2688_VOLTAGE_RANGE_0V_5V 
LTC2688_VOLTAGE_RANGE_0V_10V 
LTC2688_VOLTAGE_RANGE_M5V_5V 
LTC2688_VOLTAGE_RANGE_M10V_10V 
LTC2688_VOLTAGE_RANGE_M15V_15V 

Function Documentation

◆ ltc2688_init()

int32_t ltc2688_init ( struct ltc2688_dev **  device,
struct ltc2688_init_param  init_param 
)

Initialize the device.

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

◆ ltc2688_remove()

int32_t ltc2688_remove ( struct ltc2688_dev dev)

Free the resources allocated by ltc2688_init().

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

◆ ltc2688_select_reg()

int32_t ltc2688_select_reg ( struct ltc2688_dev dev,
uint8_t  channel,
enum ltc2688_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
SUCCESS in case of success, negative error code otherwise.

◆ ltc2688_select_tg_dith_clk()

int32_t ltc2688_select_tg_dith_clk ( struct ltc2688_dev dev,
uint8_t  channel,
enum ltc2688_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
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc2688_set_dither_mode()

int32_t ltc2688_set_dither_mode ( struct ltc2688_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
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc2688_set_dither_period()

int32_t ltc2688_set_dither_period ( struct ltc2688_dev dev,
uint8_t  channel,
enum ltc2688_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
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc2688_set_dither_phase()

int32_t ltc2688_set_dither_phase ( struct ltc2688_dev dev,
uint8_t  channel,
enum ltc2688_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
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ltc2688_set_dither_toggle()

int32_t ltc2688_set_dither_toggle ( struct ltc2688_dev dev,
uint16_t  setting 
)

Enable dither/toggle for selected channels.

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

◆ ltc2688_set_pwr_dac()

int32_t ltc2688_set_pwr_dac ( struct ltc2688_dev dev,
uint16_t  setting 
)

Power down the selected channels.

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

◆ ltc2688_set_span()

int32_t ltc2688_set_span ( struct ltc2688_dev dev,
uint8_t  channel,
enum ltc2688_voltage_range  range 
)

Set channel span.

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

◆ ltc2688_set_voltage()

int32_t ltc2688_set_voltage ( struct ltc2688_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.

◆ ltc2688_software_reset()

int32_t ltc2688_software_reset ( struct ltc2688_dev dev)

Software reset the device.

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

◆ ltc2688_software_toggle()

int32_t ltc2688_software_toggle ( struct ltc2688_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
SUCCESS in case of success, negative error code otherwise.