LibDriver MCP4725
Loading...
Searching...
No Matches
mcp4725 base driver function

mcp4725 base driver modules More...

Collaboration diagram for mcp4725 base driver function:

Data Structures

struct  mcp4725_handle_s
 mcp4725 handle structure definition More...
struct  mcp4725_info_s
 mcp4725 information structure definition More...

Typedefs

typedef struct mcp4725_handle_s mcp4725_handle_t
 mcp4725 handle structure definition
typedef struct mcp4725_info_s mcp4725_info_t
 mcp4725 information structure definition

Enumerations

enum  mcp4725_address_t { MCP4725_ADDR_A0_GND = 0x00 , MCP4725_ADDR_A0_VCC = 0x01 }
 mcp4725 address enumeration definition More...
enum  mcp4725_mode_t { MCP4725_MODE_DAC = 0x00 , MCP4725_MODE_EEPROM = 0x03 }
 mcp4725 mode enumeration definition More...
enum  mcp4725_power_down_mode_t { MCP4725_POWER_DOWN_MODE_NORMAL = 0x00 , MCP4725_POWER_DOWN_MODE_1K_GND = 0x01 , MCP4725_POWER_DOWN_MODE_100K_GND = 0x02 , MCP4725_POWER_DOWN_MODE_500K_GND = 0x03 }
 mcp4725 power down enumeration definition More...

Functions

uint8_t mcp4725_info (mcp4725_info_t *info)
 get chip's information
uint8_t mcp4725_set_addr_pin (mcp4725_handle_t *handle, mcp4725_address_t addr_pin)
 set the chip address pin
uint8_t mcp4725_get_addr_pin (mcp4725_handle_t *handle, mcp4725_address_t *addr_pin)
 get the chip address pin
uint8_t mcp4725_init (mcp4725_handle_t *handle)
 initialize the chip
uint8_t mcp4725_deinit (mcp4725_handle_t *handle)
 close the chip
uint8_t mcp4725_write (mcp4725_handle_t *handle, uint16_t value)
 write the dac value
uint8_t mcp4725_read (mcp4725_handle_t *handle, uint16_t *value)
 read the dac value
uint8_t mcp4725_convert_to_register (mcp4725_handle_t *handle, float s, uint16_t *reg)
 convert the dac value to the register data
uint8_t mcp4725_convert_to_data (mcp4725_handle_t *handle, uint16_t reg, float *s)
 convert the register data to the dac value
uint8_t mcp4725_set_mode (mcp4725_handle_t *handle, mcp4725_mode_t mode)
 set the chip mode
uint8_t mcp4725_get_mode (mcp4725_handle_t *handle, mcp4725_mode_t *mode)
 get the chip mode
uint8_t mcp4725_set_power_mode (mcp4725_handle_t *handle, mcp4725_power_down_mode_t mode)
 set the chip power mode
uint8_t mcp4725_get_power_mode (mcp4725_handle_t *handle, mcp4725_power_down_mode_t *mode)
 get the chip power mode
uint8_t mcp4725_set_reference_voltage (mcp4725_handle_t *handle, float ref_voltage)
 set the chip reference voltage
uint8_t mcp4725_get_reference_voltage (mcp4725_handle_t *handle, float *ref_voltage)
 get the chip reference voltage

Detailed Description

mcp4725 base driver modules

Typedef Documentation

◆ mcp4725_handle_t

mcp4725 handle structure definition

◆ mcp4725_info_t

mcp4725 information structure definition

Enumeration Type Documentation

◆ mcp4725_address_t

mcp4725 address enumeration definition

Enumerator
MCP4725_ADDR_A0_GND 

A0 pin connected to GND

MCP4725_ADDR_A0_VCC 

A0 pin connected to VCC

Definition at line 63 of file driver_mcp4725.h.

◆ mcp4725_mode_t

mcp4725 mode enumeration definition

Enumerator
MCP4725_MODE_DAC 

DAC mode

MCP4725_MODE_EEPROM 

EEPROM mode

Definition at line 72 of file driver_mcp4725.h.

◆ mcp4725_power_down_mode_t

mcp4725 power down enumeration definition

Enumerator
MCP4725_POWER_DOWN_MODE_NORMAL 

power down normal mode

MCP4725_POWER_DOWN_MODE_1K_GND 

power down 1K GND

MCP4725_POWER_DOWN_MODE_100K_GND 

power down 100K GND

MCP4725_POWER_DOWN_MODE_500K_GND 

power down 500K GND

Definition at line 81 of file driver_mcp4725.h.

Function Documentation

◆ mcp4725_convert_to_data()

uint8_t mcp4725_convert_to_data ( mcp4725_handle_t * handle,
uint16_t reg,
float * s )

convert the register data to the dac value

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]regregister data
[out]*spointer to a converted dac value buffer
Returns
status code
  • 0 success
  • 1 convert to data failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 508 of file driver_mcp4725.c.

◆ mcp4725_convert_to_register()

uint8_t mcp4725_convert_to_register ( mcp4725_handle_t * handle,
float s,
uint16_t * reg )

convert the dac value to the register data

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]sconverted dac value
[out]*regpointer to a register data buffer
Returns
status code
  • 0 success
  • 1 convert to register failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 474 of file driver_mcp4725.c.

◆ mcp4725_deinit()

uint8_t mcp4725_deinit ( mcp4725_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an mcp4725 handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 125 of file driver_mcp4725.c.

◆ mcp4725_get_addr_pin()

uint8_t mcp4725_get_addr_pin ( mcp4725_handle_t * handle,
mcp4725_address_t * addr_pin )

get the chip address pin

Parameters
[in]*handlepointer to an mcp4725 handle structure
[out]*addr_pinpointer to an address pin buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 177 of file driver_mcp4725.c.

◆ mcp4725_get_mode()

uint8_t mcp4725_get_mode ( mcp4725_handle_t * handle,
mcp4725_mode_t * mode )

get the chip mode

Parameters
[in]*handlepointer to an mcp4725 handle structure
[out]*modepointer to a chip mode buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 232 of file driver_mcp4725.c.

◆ mcp4725_get_power_mode()

uint8_t mcp4725_get_power_mode ( mcp4725_handle_t * handle,
mcp4725_power_down_mode_t * mode )

get the chip power mode

Parameters
[in]*handlepointer to an mcp4725 handle structure
[out]*modepointer to a chip power down mode buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 284 of file driver_mcp4725.c.

◆ mcp4725_get_reference_voltage()

uint8_t mcp4725_get_reference_voltage ( mcp4725_handle_t * handle,
float * ref_voltage )

get the chip reference voltage

Parameters
[in]*handlepointer to an mcp4725 handle structure
[out]*ref_voltagepointer to a chip reference voltage buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 336 of file driver_mcp4725.c.

◆ mcp4725_info()

uint8_t mcp4725_info ( mcp4725_info_t * info)

get chip's information

Parameters
[out]*infopointer to an mcp4725 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 584 of file driver_mcp4725.c.

◆ mcp4725_init()

uint8_t mcp4725_init ( mcp4725_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to an mcp4725 handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 63 of file driver_mcp4725.c.

◆ mcp4725_read()

uint8_t mcp4725_read ( mcp4725_handle_t * handle,
uint16_t * value )

read the dac value

Parameters
[in]*handlepointer to an mcp4725 handle structure
[out]*valuepointer to a dac buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 363 of file driver_mcp4725.c.

◆ mcp4725_set_addr_pin()

uint8_t mcp4725_set_addr_pin ( mcp4725_handle_t * handle,
mcp4725_address_t addr_pin )

set the chip address pin

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]addr_pinaddress pin
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 156 of file driver_mcp4725.c.

◆ mcp4725_set_mode()

uint8_t mcp4725_set_mode ( mcp4725_handle_t * handle,
mcp4725_mode_t mode )

set the chip mode

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]modechip mode
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 206 of file driver_mcp4725.c.

◆ mcp4725_set_power_mode()

uint8_t mcp4725_set_power_mode ( mcp4725_handle_t * handle,
mcp4725_power_down_mode_t mode )

set the chip power mode

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]modechip power down mode
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 258 of file driver_mcp4725.c.

◆ mcp4725_set_reference_voltage()

uint8_t mcp4725_set_reference_voltage ( mcp4725_handle_t * handle,
float ref_voltage )

set the chip reference voltage

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]ref_voltagechip reference voltage
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 310 of file driver_mcp4725.c.

◆ mcp4725_write()

uint8_t mcp4725_write ( mcp4725_handle_t * handle,
uint16_t value )

write the dac value

Parameters
[in]*handlepointer to an mcp4725 handle structure
[in]valuedac value
Returns
status code
  • 0 success
  • 1 write failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 414 of file driver_mcp4725.c.