Amine KHETTAT
/
test_I2C
programme test circuit I2C SLAVE sur ALtera
Diff: main.cpp
- Revision:
- 0:d70889176a8b
--- /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); + } +}