Raphaël Drouin
/
I2C_SPI
I2C_comm
Fork of I2C_comm by
Diff: main.cpp
- Revision:
- 0:656742ec86ae
- Child:
- 1:7f23dfc59683
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 11 22:53:22 2017 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" + + //read register value + +I2C i2c(p9, p10); + +const char reg[1] = {0x0D}; +const char device = 0x3A; +char data[1]; + +int main() { + + i2c.write(device,reg,1,true); + i2c.read(device,data,1); + + printf("Result : %d \r\n", data[1]); + + + /*i2c.read(addr,); + + + cmd[0] = 0x01; + cmd[1] = 0x00; + i2c.write(addr, cmd, 2); + + wait(0.5); + + cmd[0] = 0x00; + i2c.write(addr, cmd, 1); + i2c.read(addr, cmd, 2); + + float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0); + printf("Temp = %.2f\n", tmp);*/ + +} \ No newline at end of file