PCF8591 I2C _ADC read library for LPC11U24

Dependents:   mbed_PCF8591_LPC11U24_ADC_RAJESH_NIELIT_CALICUT

Revision:
0:3c4cd2f477ea
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCF8591_ADC.cpp	Wed Jun 15 21:31:05 2016 +0000
@@ -0,0 +1,27 @@
+
+    #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;
+
+};