Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MCP4725 Class Reference
Example: More...
#include <MCP4725.h>
Public Types | |
| enum | MCP4725_address_t { MCP4725_ADDRESS_LOW = ( 0x62 << 1 ), MCP4725_ADDRESS_HIGH = ( 0x63 << 1 ) } |
DEFAULT ADDRESSES ( NOTE1: The A2 and A1 are programmed to '00' (default), if not requested by customer. More... | |
| enum | MCP4725_write_command_type_t { FAST_MODE = 0, WRITE_DAC_REGISTER_MODE = 1, WRITE_DAC_AND_EEPROM_REGISTER_MODE = 2 } |
WRITE COMMAND TYPE. More... | |
| enum | MCP4725_operation_mode_t { NORMAL_MODE = 0, POWER_DOWN_1KOHM_RESISTIVE_LOAD_MODE = 1, POWER_DOWN_100KOHM_RESISTIVE_LOAD_MODE = 2, POWER_DOWN_500KOHM_RESISTIVE_LOAD_MODE = 3 } |
POWER-DOWN MODE. More... | |
| enum | MCP4725_eeprom_status_t { EEPROM_BUSY = 0, EEPROM_READY = 1 } |
READY/BUSY BIT. More... | |
| enum | MCP4725_status_t { , I2C_SUCCESS = 0 } |
INTERNAL CONSTANTS. More... | |
Public Member Functions | |
| MCP4725 (PinName sda, PinName scl, uint32_t addr, uint32_t freq) | |
| Create an MCP4725 object connected to the specified I2C pins. | |
| ~MCP4725 () | |
| Delete MCP4725 object. | |
| MCP4725_status_t | MCP4725_Reset (void) |
| It performs an internal reset similar to a power-on-reset ( POR ). | |
| MCP4725_status_t | MCP4725_WakeUp (void) |
| The power-down bits of the DAC register are set to a normal operation. | |
| MCP4725_status_t | MCP4725_PowerMode (MCP4725_write_command_type_t myWriteCMD, MCP4725_operation_mode_t myPowerMode) |
| It configures the power mode of the device. | |
| MCP4725_status_t | MCP4725_SetNewValue (MCP4725_write_command_type_t myWriteCMD, Vector_new_dac_value_t myDACNewValue) |
| It sets a new output value. | |
| MCP4725_status_t | MCP4725_EEPROM_Status (MCP4725_eeprom_status_t *myEEPROM_Status) |
| It gets the eeprom status. | |
| MCP4725_status_t | MCP4725_GetEEPROM_Data (Vector_data_t *myEEPROMData) |
| It gets the last eeprom stored value. | |
| MCP4725_status_t | MCP4725_GetDAC_Data (Vector_data_t *myDACData) |
| It gets the last dac stored value. | |
Detailed Description
Example:
include "mbed.h" include "MCP4725.h"
MCP4725 myDACSensor ( I2C_SDA, I2C_SCL, MCP4725::MCP4725_ADDRESS_LOW, 400000 );
Ticker newDACOutput; DigitalOut myled(LED1);
MCP4725::MCP4725_status_t aux; uint8_t myState = 0;
void changeDATA ( void ) { MCP4725::Vector_new_dac_value_t myNewDAC_Value;
myled = 1;
switch ( myState ) { default: case 0: Vout ~ 0V myNewDAC_Value.DAC_New_Value = 0; aux = myDACSensor.MCP4725_SetNewValue ( MCP4725::FAST_MODE, myNewDAC_Value );
myState = 1; break;
case 1: Vout = ~ ( Vref * 0.5 ) myNewDAC_Value.DAC_New_Value = 2048; aux = myDACSensor.MCP4725_SetNewValue ( MCP4725::WRITE_DAC_AND_EEPROM_REGISTER_MODE, myNewDAC_Value );
myState = 2; break;
case 2: Vout ~ Vref myNewDAC_Value.DAC_New_Value = 4095; aux = myDACSensor.MCP4725_SetNewValue ( MCP4725::WRITE_DAC_REGISTER_MODE, myNewDAC_Value );
myState = 0; break; }
myled = 0; }
int main() { MCP4725::Vector_data_t myDefaultData;
Reset and wake the device up aux = myDACSensor.MCP4725_Reset (); aux = myDACSensor.MCP4725_WakeUp ();
Read the default data in both EEPROM and DAC aux = myDACSensor.MCP4725_GetDAC_Data ( &myDefaultData ); aux = myDACSensor.MCP4725_GetEEPROM_Data ( &myDefaultData );
newDACOutput.attach( &changeDATA, 0.5 ); // the address of the function to be attached ( changeDATA ) and the interval ( 0.5s )
Let the callbacks take care of everything while(1) sleep(); }
Library for the MCP4725 12-Bit Digital-to-Analog Converter with EEPROM Memory.
Definition at line 100 of file MCP4725.h.
Member Enumeration Documentation
| enum MCP4725_address_t |
POWER-DOWN MODE.
| enum MCP4725_status_t |
WRITE COMMAND TYPE.
Constructor & Destructor Documentation
| MCP4725 | ( | PinName | sda, |
| PinName | scl, | ||
| uint32_t | addr, | ||
| uint32_t | freq | ||
| ) |
Create an MCP4725 object connected to the specified I2C pins.
MCP4725.c.
- Parameters:
-
sda I2C data pin scl I2C clock pin addr I2C slave address freq I2C frequency in Hz.
12-Bit Digital-to-Analog Converter with EEPROM Memory. Functions file.
- Returns:
- NA
- Date:
- 7/September/2017
- Version:
- 7/September/2017 The ORIGIN
- Precondition:
- NaN.
- Warning:
- NaN
- Precondition:
- This code belongs to AqueronteBlog ( http://unbarquero.blogspot.com ).
Definition at line 20 of file MCP4725.cpp.
| ~MCP4725 | ( | ) |
Delete MCP4725 object.
Definition at line 28 of file MCP4725.cpp.
Member Function Documentation
| MCP4725::MCP4725_status_t MCP4725_EEPROM_Status | ( | MCP4725_eeprom_status_t * | myEEPROM_Status ) |
It gets the eeprom status.
MCP4725_EEPROM_Status ( MCP4725_eeprom_status_t )
It gets the eeprom status.
- Parameters:
-
[in] myEEPROM_Status,: EEPROM status. [out] NaN.
- Returns:
- Status of MCP4725_EEPROM_Status.
- Date:
- 7/September/2017
- Version:
- 7/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 285 of file MCP4725.cpp.
| MCP4725::MCP4725_status_t MCP4725_GetDAC_Data | ( | Vector_data_t * | myDACData ) |
It gets the last dac stored value.
MCP4725_GetDAC_Data ( Vector_data_t* )
It gets the DAC value.
- Parameters:
-
[in] myDACData,: DAC value. [out] NaN.
- Returns:
- Status of MCP4725_GetDAC_Data.
- Date:
- 8/September/2017
- Version:
- 8/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 365 of file MCP4725.cpp.
| MCP4725::MCP4725_status_t MCP4725_GetEEPROM_Data | ( | Vector_data_t * | myEEPROMData ) |
It gets the last eeprom stored value.
MCP4725_GetEEPROM_Data ( Vector_data_t* )
It gets the eeprom value.
- Parameters:
-
[in] myEEPROMData,: EEPROM value. [out] NaN.
- Returns:
- Status of MCP4725_GetEEPROM_Data.
- Date:
- 8/September/2017
- Version:
- 8/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 325 of file MCP4725.cpp.
| MCP4725::MCP4725_status_t MCP4725_PowerMode | ( | MCP4725_write_command_type_t | myWriteCMD, |
| MCP4725_operation_mode_t | myPowerMode | ||
| ) |
It configures the power mode of the device.
MCP4725_PowerMode ( MCP4725_write_command_type_t , MCP4725_operation_mode_t )
It configures the power mode of the device.
- Parameters:
-
[in] myWriteCMD,: It writes the command into the DAC or EEPROM/DAC. [in] myPowerMode,: Normal Mode or one of the Power-Down available modes. [out] NaN.
- Returns:
- Status of MCP4725_PowerMode.
- Date:
- 7/September/2017
- Version:
- 7/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 128 of file MCP4725.cpp.
| MCP4725::MCP4725_status_t MCP4725_Reset | ( | void | ) |
It performs an internal reset similar to a power-on-reset ( POR ).
MCP4725_Reset ( void )
It performs an internal reset similar to a power-on-reset ( POR ).
- Parameters:
-
[in] NaN. [out] NaN.
- Returns:
- Status of MCP4725_Reset.
- Date:
- 7/September/2017
- Version:
- 7/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- The user MUST respect the time it takes this instruction to be performed ( max. 50ms ).
Definition at line 54 of file MCP4725.cpp.
| MCP4725::MCP4725_status_t MCP4725_SetNewValue | ( | MCP4725_write_command_type_t | myWriteCMD, |
| Vector_new_dac_value_t | myDACNewValue | ||
| ) |
It sets a new output value.
MCP4725_SetNewValue ( MCP4725_write_command_type_t , uint32_t )
It sends a new output value.
- Parameters:
-
[in] myWriteCMD,: It writes the command into the DAC or EEPROM/DAC. [in] myDACNewValue,: New output value. [out] NaN.
- Returns:
- Status of MCP4725_SetNewValue.
- Date:
- 7/September/2017
- Version:
- 7/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 218 of file MCP4725.cpp.
| MCP4725::MCP4725_status_t MCP4725_WakeUp | ( | void | ) |
The power-down bits of the DAC register are set to a normal operation.
MCP4725_WakeUp ( void )
The power-down bits of the DAC register are set to a normal operation.
- Parameters:
-
[in] NaN. [out] NaN.
- Returns:
- Status of MCP4725_WakeUp.
- Date:
- 7/September/2017
- Version:
- 7/September/2017 The ORIGIN
- Precondition:
- NaN
- Warning:
- NaN.
Definition at line 91 of file MCP4725.cpp.
Generated on Wed Jul 20 2022 10:49:43 by
1.7.2