test PCF

Dependencies:   PCF8591 mbed

Committer:
fblanc
Date:
Tue Jul 22 13:36:50 2014 +0000
Revision:
1:e148be668cc9
Parent:
0:53700355bf8f
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fblanc 0:53700355bf8f 1 #include "mbed.h"
fblanc 0:53700355bf8f 2 #include "PCF8591.h"
fblanc 1:e148be668cc9 3 #define VERSION "22_07_2014"
fblanc 0:53700355bf8f 4 #define CIBLE "KL25Z"
fblanc 0:53700355bf8f 5 // I2C Communication
fblanc 0:53700355bf8f 6 I2C i2c_adcdac(PTC9,PTC8); // SDA, SCL for LPC1768
fblanc 0:53700355bf8f 7 //I2C i2c_adcdac(P0_10,P0_11); // SDA, SCL for LPC812
fblanc 0:53700355bf8f 8
fblanc 0:53700355bf8f 9 //Declare a composite ADC and DAC device that may be used through public methods
fblanc 0:53700355bf8f 10 PCF8591 capteur0(&i2c_adcdac,PCF8591_SA0); // I2C bus, Default PCF8591 Slaveaddress
fblanc 0:53700355bf8f 11
fblanc 0:53700355bf8f 12 //Declare independent ADC and DAC objects that may be used similar to mbed AnalogIn and AnalogOut pins
fblanc 0:53700355bf8f 13 //PCF8591_AnalogOut anaOut(&i2c_bus);
fblanc 0:53700355bf8f 14 //
fblanc 0:53700355bf8f 15 //PCF8591_AnalogIn anaIn(&i2c_bus, PCF8591_ADC0);
fblanc 0:53700355bf8f 16
fblanc 0:53700355bf8f 17
fblanc 0:53700355bf8f 18 int main() {
fblanc 0:53700355bf8f 19 uint8_t count = 0;
fblanc 0:53700355bf8f 20 uint8_t analog;
fblanc 0:53700355bf8f 21 printf("LAAS-CNRS ,PCF8591 ,%s ,%s\r\n",CIBLE,VERSION);
fblanc 0:53700355bf8f 22 while(1) {
fblanc 0:53700355bf8f 23 wait(1);
fblanc 0:53700355bf8f 24 count++;
fblanc 0:53700355bf8f 25
fblanc 0:53700355bf8f 26 // Composite device methods
fblanc 0:53700355bf8f 27 capteur0.write(count); // write D/A value
fblanc 0:53700355bf8f 28 analog = capteur0.read(PCF8591_ADC0); // read A/D value for Channel 0
fblanc 0:53700355bf8f 29 printf("AO=%d AI=%d \r\n",count,analog);
fblanc 0:53700355bf8f 30 // read A/D value for Channel 0 in (Volts*10)
fblanc 0:53700355bf8f 31 }
fblanc 0:53700355bf8f 32
fblanc 0:53700355bf8f 33 }