Amine KHETTAT
/
test_I2C
programme test circuit I2C SLAVE sur ALtera
Revision 0:d70889176a8b, committed 2011-06-17
- Comitter:
- khettat
- Date:
- Fri Jun 17 11:38:49 2011 +0000
- Commit message:
- v1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r d70889176a8b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 17 11:38:49 2011 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); // tx, rx +I2C i2c(p28,p27); +char data[2]; +char num_reg[1]; +unsigned char x; + +int main() { + num_reg[0] = 3; + int adresse = 0xC8; + pc.printf("Nouvelle acqui : \r\n"); + while(1) { + i2c.write(adresse, num_reg, 1); + + i2c.read(adresse, data, 2); + // x = data[0]; + //data[0] = data[1]; + //data[1] = x; + wait(0.1); + pc.printf("%X\r\n",*((unsigned short*)data)); + wait(0.2); + } +}
diff -r 000000000000 -r d70889176a8b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 17 11:38:49 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912