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.
MCP4822 Class Reference
Interface to the 12-Bit DAC with internal Vref and SPI interface. More...
#include <MCP4822.h>
Public Member Functions | |
| MCP4822 (SPI &spi, PinName nLDAC, PinName nCs) | |
| Create an instance of the MCP4822 connected via specfied SPI instance. | |
| MCP4822 (PinName nLDAC, PinName mosi, PinName miso, PinName sck, PinName nCs) | |
| Create an instance of the MCP4261 connected with SPI pins. | |
| void | a (bool gain, int data) |
| Write to output A. | |
| void | b (bool gain, int data) |
| Write to output B. | |
| void | ldac (bool act) |
| Output Synchronization. | |
| void | shdn (bool output, bool act) |
| Output Shutdown. | |
Detailed Description
Interface to the 12-Bit DAC with internal Vref and SPI interface.
Using the driver:
- remenber to setup SPI in main routine or use pins instance.
Defaults in this driver on start up:
- Datasheet start up
Definition at line 51 of file MCP4822.h.
Constructor & Destructor Documentation
| MCP4822 | ( | SPI & | spi, |
| PinName | nLDAC, | ||
| PinName | nCs | ||
| ) |
Create an instance of the MCP4822 connected via specfied SPI instance.
- Parameters:
-
spi The mbed SPI instance (make in main routine) nLDAC The Latch DAC Synchronization pin nCs The SPI chip select pin.
Definition at line 30 of file MCP4822.cpp.
| MCP4822 | ( | PinName | nLDAC, |
| PinName | mosi, | ||
| PinName | miso, | ||
| PinName | sck, | ||
| PinName | nCs | ||
| ) |
Create an instance of the MCP4261 connected with SPI pins.
- Parameters:
-
nLDAC The Latch DAC Synchronization pin mosi The SPI Master Output, Slave Input pin. miso The SPI Master Input, Slave Output pin. sck The SPI Serial Clock pin. nCs The SPI chip select pin.
Definition at line 36 of file MCP4822.cpp.
Member Function Documentation
| void a | ( | bool | gain, |
| int | data | ||
| ) |
Write to output A.
- Parameters:
-
gain the gain is 2x = '0' and 1x = '1'. data The 12 bits value to write to the output.
Definition at line 41 of file MCP4822.cpp.
| void b | ( | bool | gain, |
| int | data | ||
| ) |
Write to output B.
- Parameters:
-
gain the gain is 2x = '0' and 1x = '1'. data The 12 bits value to write to the output.
Definition at line 46 of file MCP4822.cpp.
| void ldac | ( | bool | act ) |
Output Synchronization.
- Parameters:
-
act The LDAC is Active = true and Inactive = false.
Definition at line 51 of file MCP4822.cpp.
| void shdn | ( | bool | output, |
| bool | act | ||
| ) |
Output Shutdown.
- Parameters:
-
output A = '0' and B = '1'. act The SHDN is Active = true and Inactive = false.
Definition at line 56 of file MCP4822.cpp.
Generated on Sat Jul 16 2022 14:19:40 by
1.7.2