no-OS
Loading...
Searching...
No Matches
dpot.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "no_os_error.h"
Include dependency graph for dpot.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dpot_command
 Digital potentiometer command structure. More...
 
struct  dpot_init_param
 Digital potentiometer init parameters. More...
 
struct  dpot_dev
 Digital potentiometer device descriptor parameters. More...
 
struct  dpot_ops
 Digital potentiometer common APIs. More...
 

Macros

#define DPOT_NUM_SUPPORTED_DEVICES   DEV_AD5273+1
 

Enumerations

enum  dpot_dev_id {
  DEV_AD5121 ,
  DEV_AD5122 ,
  DEV_AD5122A ,
  DEV_AD5123 ,
  DEV_AD5124 ,
  DEV_AD5141 ,
  DEV_AD5142 ,
  DEV_AD5142A ,
  DEV_AD5143 ,
  DEV_AD5144 ,
  DEV_AD5160 ,
  DEV_AD5161 ,
  DEV_AD5165 ,
  DEV_AD5171 ,
  DEV_AD5241 ,
  DEV_AD5242 ,
  DEV_AD5245 ,
  DEV_AD5246 ,
  DEV_AD5258 ,
  DEV_AD5259 ,
  DEV_AD5273
}
 Digital potentiometer device IDs. More...
 
enum  dpot_intf_type {
  AD_SPI_INTERFACE = 0x1 ,
  AD_I2C_INTERFACE = 0x2
}
 digital potentiometer interface type. More...
 
enum  dpot_chn_type {
  DPOT_CHN_RDAC1 ,
  DPOT_CHN_RDAC2 ,
  DPOT_CHN_RDAC3 ,
  DPOT_CHN_RDAC4 ,
  DPOT_CHN_R_AW1 ,
  DPOT_CHN_R_WB1 ,
  DPOT_CHN_R_AW2 ,
  DPOT_CHN_R_WB2 ,
  DPOT_CHN_R_AW3 ,
  DPOT_CHN_R_WB3 ,
  DPOT_CHN_R_AW4 ,
  DPOT_CHN_R_WB4 ,
  NUM_OF_DPOT_CHN
}
 Digital potentiometer channel type. More...
 
enum  dpot_operating_mode {
  DPOT_POTENTIOMETER_MODE ,
  DPOT_LINEAR_GAIN_SETTING_MODE
}
 Digital potentiometer operating mode. More...
 
enum  dpot_rdac_linear_status {
  DPOT_RDAC_LINEAR_INCREMENT ,
  DPOT_RDAC_LINEAR_DECREMENT
}
 Digital potentiometer RDAC linear update status. More...
 
enum  dpot_rdac_6db_status {
  DPOT_RDAC_6DB_INCREMENT ,
  DPOT_RDAC_6DB_DECREMENT
}
 Digital potentiometer RDAC 6dB update status. More...
 

Functions

int dpot_init (struct dpot_dev **desc, struct dpot_init_param *pDpotInitParam)
 Initialize the digital potentiometer.
 
int dpot_remove (struct dpot_dev *desc)
 Free the memory allocated by dpot_init().
 
int dpot_reset (struct dpot_dev *desc)
 Reset the digital potentiometer.
 
int dpot_shutdown (struct dpot_dev *desc, enum dpot_chn_type chn, bool shutdown_enable)
 Shutdown the digital potentiometer channel.
 
int dpot_set_operating_mode (struct dpot_dev *desc, enum dpot_operating_mode operating_mode)
 Set the digital potentiometer operating mode.
 
int dpot_input_reg_read (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
 Read the digital potentiometer input register.
 
int dpot_input_reg_write (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t data)
 Write to the digital potentiometer input register.
 
int dpot_sw_lrdac_update (struct dpot_dev *desc, enum dpot_chn_type chn)
 Copy input register to RDAC (software LRDAC).
 
int dpot_chn_read (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
 Read the digital potentiometer channel.
 
int dpot_chn_write (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t data)
 Write to the digital potentiometer channel.
 
int dpot_nvm_read (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
 Read the NVM (non-volatile) memory data.
 
int dpot_nvm_write (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t data)
 Write data to NVM (non-volatile) memory.
 
int dpot_copy_rdac_to_nvm (struct dpot_dev *desc, enum dpot_chn_type chn)
 Copy RDAC register to NVM/EEPROM.
 
int dpot_copy_nvm_to_rdac (struct dpot_dev *desc, enum dpot_chn_type chn)
 Copy NVM/EEPROM data to RDAC.
 
int dpot_rdac_linear_update (struct dpot_dev *desc, enum dpot_chn_type chn, enum dpot_rdac_linear_status status)
 Perform RDAC linear increment/decrement.
 
int dpot_rdac_6db_update (struct dpot_dev *desc, enum dpot_chn_type chn, enum dpot_rdac_6db_status status)
 Perform RDAC 6dB increment/decrement.
 
int dpot_send_cmd (struct dpot_dev *desc, struct dpot_command *cmd)
 Send command word to the digital potentiometer.
 
int dpot_enable_top_scale (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t nEnter)
 Perform Enter/exit top scale.
 
int dpot_enable_bottom_scale (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t nEnter)
 Perform Enter/exit top scale.
 
int dpot_tolerance_read (struct dpot_dev *desc, enum dpot_chn_type chn, uint8_t *data)
 Send command word to the digital potentiometer.
 
int dpot_set_mid_scale (struct dpot_dev *desc, enum dpot_chn_type chn, bool shutdown_enable)
 Shutdown the digital potentiometer channel.
 

Macro Definition Documentation

◆ DPOT_NUM_SUPPORTED_DEVICES

#define DPOT_NUM_SUPPORTED_DEVICES   DEV_AD5273+1

Enumeration Type Documentation

◆ dpot_chn_type

Digital potentiometer channel type.

Enumerator
DPOT_CHN_RDAC1 
DPOT_CHN_RDAC2 
DPOT_CHN_RDAC3 
DPOT_CHN_RDAC4 
DPOT_CHN_R_AW1 
DPOT_CHN_R_WB1 
DPOT_CHN_R_AW2 
DPOT_CHN_R_WB2 
DPOT_CHN_R_AW3 
DPOT_CHN_R_WB3 
DPOT_CHN_R_AW4 
DPOT_CHN_R_WB4 
NUM_OF_DPOT_CHN 

◆ dpot_dev_id

Digital potentiometer device IDs.

Enumerator
DEV_AD5121 
DEV_AD5122 
DEV_AD5122A 
DEV_AD5123 
DEV_AD5124 
DEV_AD5141 
DEV_AD5142 
DEV_AD5142A 
DEV_AD5143 
DEV_AD5144 
DEV_AD5160 
DEV_AD5161 
DEV_AD5165 
DEV_AD5171 
DEV_AD5241 
DEV_AD5242 
DEV_AD5245 
DEV_AD5246 
DEV_AD5258 
DEV_AD5259 
DEV_AD5273 

◆ dpot_intf_type

digital potentiometer interface type.

Enumerator
AD_SPI_INTERFACE 
AD_I2C_INTERFACE 

◆ dpot_operating_mode

Digital potentiometer operating mode.

Note
Operating mode is applicable to only certain generics of digipots and not all.
Enumerator
DPOT_POTENTIOMETER_MODE 
DPOT_LINEAR_GAIN_SETTING_MODE 

◆ dpot_rdac_6db_status

Digital potentiometer RDAC 6dB update status.

Note
6dB update is applicable to only certain generics of digipots and not all.
Enumerator
DPOT_RDAC_6DB_INCREMENT 
DPOT_RDAC_6DB_DECREMENT 

◆ dpot_rdac_linear_status

Digital potentiometer RDAC linear update status.

Note
Linear update is applicable to only certain generics of digipots and not all.
Enumerator
DPOT_RDAC_LINEAR_INCREMENT 
DPOT_RDAC_LINEAR_DECREMENT 

Function Documentation

◆ dpot_chn_read()

int dpot_chn_read ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t * data )

Read the digital potentiometer channel.

Parameters
desc- digipot descriptor.
chn- digipot channel.
data- Channel data to be read.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_chn_write()

int dpot_chn_write ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t data )

Write to the digital potentiometer channel.

Parameters
desc- digipot descriptor.
chn- digipot channel.
data- Channel data to be written.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_copy_nvm_to_rdac()

int dpot_copy_nvm_to_rdac ( struct dpot_dev * desc,
enum dpot_chn_type chn )

Copy NVM/EEPROM data to RDAC.

Parameters
desc- digipot descriptor.
chn- digipot channel.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_copy_rdac_to_nvm()

int dpot_copy_rdac_to_nvm ( struct dpot_dev * desc,
enum dpot_chn_type chn )

Copy RDAC register to NVM/EEPROM.

Parameters
desc- digipot descriptor.
chn- digipot channel.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_enable_bottom_scale()

int dpot_enable_bottom_scale ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t nEnter )

Perform Enter/exit top scale.

Parameters
desc- digipot descriptor.
chn- digipot channel.
nEnter- Enter or exit the Bottom scake.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_enable_top_scale()

int dpot_enable_top_scale ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t nEnter )

Perform Enter/exit top scale.

Parameters
desc- digipot descriptor.
chn- digipot channel.
nEnter- Enter or exit the TS.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_init()

int dpot_init ( struct dpot_dev ** desc,
struct dpot_init_param * pdpot_init_param )

Initialize the digital potentiometer.

Parameters
desc- digipot descriptor.
pdpot_init_param- digipot init parameters.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_input_reg_read()

int dpot_input_reg_read ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t * data )

Read the digital potentiometer input register.

Parameters
desc- digipot descriptor.
chn- digipot channel.
data- input register data to be read.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_input_reg_write()

int dpot_input_reg_write ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t data )

Write to the digital potentiometer input register.

Parameters
desc- digipot descriptor.
chn- digipot channel.
data- input register data to be written.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_nvm_read()

int dpot_nvm_read ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t * data )

Read the NVM (non-volatile) memory data.

Parameters
desc- digipot descriptor.
chn- digipot channel.
data- NVM data to be read.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_nvm_write()

int dpot_nvm_write ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t data )

Write data to NVM (non-volatile) memory.

Parameters
desc- digipot descriptor.
chn- digipot channel.
data- NVM data to be written.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_rdac_6db_update()

int dpot_rdac_6db_update ( struct dpot_dev * desc,
enum dpot_chn_type chn,
enum dpot_rdac_6db_status status )

Perform RDAC 6dB increment/decrement.

Parameters
desc- digipot descriptor.
chn- digipot channel.
status- 6dB increment/decrement status.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_rdac_linear_update()

int dpot_rdac_linear_update ( struct dpot_dev * desc,
enum dpot_chn_type chn,
enum dpot_rdac_linear_status status )

Perform RDAC linear increment/decrement.

Parameters
desc- digipot descriptor.
chn- digipot channel.
status- linear increment/decrement status.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_remove()

int dpot_remove ( struct dpot_dev * desc)

Free the memory allocated by dpot_init().

Parameters
desc- digipot descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_reset()

int dpot_reset ( struct dpot_dev * desc)

Reset the digital potentiometer.

Parameters
desc- digipot descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_send_cmd()

int dpot_send_cmd ( struct dpot_dev * desc,
struct dpot_command * cmd )

Send command word to the digital potentiometer.

Parameters
desc- digipot descriptor.
cmd- digipot command word
Returns
0 in case of success, negative error code otherwise.

◆ dpot_set_mid_scale()

int dpot_set_mid_scale ( struct dpot_dev * desc,
enum dpot_chn_type chn,
bool shutdown_enable )

Shutdown the digital potentiometer channel.

Parameters
desc- digipot descriptor.
chn- digipot channel.
shutdown_enable- To set bid scaleenable mid scale .
Returns
0 in case of success, negative error code otherwise.

◆ dpot_set_operating_mode()

int dpot_set_operating_mode ( struct dpot_dev * desc,
enum dpot_operating_mode operating_mode )

Set the digital potentiometer operating mode.

Parameters
desc- digipot descriptor.
operating_mode- digipot operating mode.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_shutdown()

int dpot_shutdown ( struct dpot_dev * desc,
enum dpot_chn_type chn,
bool shutdown_enable )

Shutdown the digital potentiometer channel.

Parameters
desc- digipot descriptor.
chn- digipot channel.
shutdown_enable- Shutdown enable status flag.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_sw_lrdac_update()

int dpot_sw_lrdac_update ( struct dpot_dev * desc,
enum dpot_chn_type chn )

Copy input register to RDAC (software LRDAC).

Parameters
desc- digipot descriptor.
chn- digipot channel.
Returns
0 in case of success, negative error code otherwise.

◆ dpot_tolerance_read()

int dpot_tolerance_read ( struct dpot_dev * desc,
enum dpot_chn_type chn,
uint8_t * data )

Send command word to the digital potentiometer.

Parameters
desc- digipot descriptor.
chn- Channel type
data- Pointer to location where tolerance should be written.
Returns
0 in case of success, negative error code otherwise.