PCF8591 I2C _ADC read library for LPC11U24

Dependents:   mbed_PCF8591_LPC11U24_ADC_RAJESH_NIELIT_CALICUT

PCF8591_ADC.cpp

Committer:
rajeshnielit
Date:
2016-06-15
Revision:
0:3c4cd2f477ea

File content as of revision 0:3c4cd2f477ea:


    #include "mbed.h"
#include "PCF8591.h"


/** Create a PCF8591 AD and DA object using a specified I2C bus and slaveaddress
  *
  * @param I2C &i2c the I2C port to connect to 
  * @param char deviceAddress the address of the PCF8591
  */  
PCF8591::PCF8591(I2C *i2c) : _i2c(i2c) {
    
  _slaveAddress = PCF8591_ADDR;

}


uint8_t PCF8591::ADC_read(uint8_t channel) {

char cmd;
    char anaval;
    cmd=channel;
    _i2c->write( _slaveAddress, &cmd, 1 );
    _i2c->read( _slaveAddress, &anaval, 1 );
    return anaval;

};