12-Bit, 8-Channel, ADC System Monitor w/ Temp Sensor, Internal/External Reference, & I2C Interface
Dependents: ADC128D818_HelloWorld
ADC128D818 Class Reference
ADC128D818 class. More...
#include <ADC128D818.h>
Public Member Functions | |
ADC128D818 (PinName sda, PinName scl, PinName adc_int) | |
Constructor. | |
~ADC128D818 () | |
Destructor. | |
int | read_channel (char channel) |
read_channel | |
char | read_register (char Register) |
read_register | |
int | init (char address, char mode, char vref, char rate, char mask_channel, char mask_int) |
init | |
int | init_limit (char channel, char limit, char high_low) |
init_limit | |
void | start () |
start | |
void | stop () |
stop |
Detailed Description
ADC128D818 class.
Used for controlling a ADC128D818 adc connected via I2C.
Example:
#include "mbed.h" #include "ADC128D818.h" Serial pc(USBTX, USBRX); ADC128D818 adc(p9,p10,p26); AnalogOut dac(p18); int main() { dac=0.5; printf("helloword_ADC128D818\r\n"); wait_ms(100); int err=adc.init(ADC_ADDRESS_LOW_LOW, ADC_MODE_0, ADC_VREF_INT, ADC_RATE_CONTINUOUS, ADC_ENABLE_TEMP & ADC_ENABLE_IN1, ADC_INT_TEMP); switch (err) { case -1: printf("No Device\r\n"); break; case -2: printf("Busy\r\n"); break; } adc.init_limit(ADC_CHANNEL_IN0, 0x80, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_IN1, 0xA6, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_IN2, 0x80, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_IN3, 0x80, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_IN4, 0x80, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_IN5, 0x80, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_IN6, 0x80, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_TEMP, 30, ADC_LIMIT_HIGH); adc.init_limit(ADC_CHANNEL_TEMP, 29, ADC_LIMIT_LOW); char reg; reg=ADC_REG_Advanced_Configuration_Register; printf("reg %02X=%02X\r\n",reg,adc.read_register(reg)); printf("reg %02X=%02X\r\n",0x2C,adc.read_channel(0x0C)); adc.start(); for(int i=0; i<1000; ++i) { wait(1); printf("ch0:%d : %d\r\n",i,adc.read_channel(ADC_CHANNEL_IN0)); for( char c=1; c<7 ;++c) printf("ch%d:%d : %04X\r\n",c,i,adc.read_channel(c)); printf("temp:%d : %f\r\n",i,(adc.read_channel(ADC_CHANNEL_TEMP)>>7)/2.0); reg=0x01; printf("reg %02X=%02X\r\n",reg,adc.read_register(reg)); } }
Definition at line 149 of file ADC128D818.h.
Constructor & Destructor Documentation
ADC128D818 | ( | PinName | sda, |
PinName | scl, | ||
PinName | adc_int | ||
) |
Constructor.
ADC128D818 12-Bit, 8-Channel, ADC System Monitor w/ Temp Sensor, Internal/External Reference, & I2C Interfac http://www.ti.com/product/adc128d818/.
- Parameters:
-
sda I2C scl I2C adc_int
- Date:
- 02/09/2013
- Parameters:
-
sda I2C scl I2C adc_int
Definition at line 18 of file ADC128D818.cpp.
~ADC128D818 | ( | ) |
Destructor.
Definition at line 25 of file ADC128D818.cpp.
Member Function Documentation
int init | ( | char | address, |
char | mode, | ||
char | vref, | ||
char | rate, | ||
char | mask_channel, | ||
char | mask_int | ||
) |
init
- Parameters:
-
address I2C (7bits) ADC_ADDRESS_LOW_LOW ADC_ADDRESS_LOW_MID ADC_ADDRESS_LOW_HIGH ADC_ADDRESS_MID_LOW ADC_ADDRESS_MID_MID ADC_ADDRESS_MID_HIGH ADC_ADDRESS_HIGH_LOW ADC_ADDRESS_HIGH_MID ADC_ADDRESS_HIGH_HIGH mode : ADC_MODE_0 ADC_MODE_1 ADC_MODE_2 ADC_MODE_3 vref ADC_VREF_INT ADC_VREF_EXT rate ADC_RATE_LOW_POWER ADC_RATE_CONTINUOUS mask_channel mask_int
- Returns:
- error 0 OK, -1 NO DEVICE, -2 ADC is BUSY
- Date:
- 02/09/2013
Definition at line 58 of file ADC128D818.cpp.
int init_limit | ( | char | channel, |
char | limit, | ||
char | high_low | ||
) |
init_limit
- Parameters:
-
limit high_low ADC_LIMIT_HIGH ADC_LIMIT_LOW
- Returns:
- error 0 OK
- Date:
- 02/09/2013
Definition at line 157 of file ADC128D818.cpp.
int read_channel | ( | char | channel ) |
read_channel
- Parameters:
-
channel
- Returns:
- u32_data
- Date:
- 02/09/2013
Definition at line 176 of file ADC128D818.cpp.
char read_register | ( | char | Register ) |
read_register
- Parameters:
-
Register
- Returns:
- u8_data
- Date:
- 02/09/2013
Definition at line 199 of file ADC128D818.cpp.
void start | ( | ) |
void stop | ( | ) |
Generated on Mon Jul 18 2022 15:31:51 by 1.7.2