Initial I2C Working

Dependencies:   mbed

Committer:
sk398
Date:
Wed Mar 29 08:33:10 2017 +0000
Revision:
0:fbf82bf637bb
Child:
1:444546e8cd20
Initial version - I2C working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sk398 0:fbf82bf637bb 1 #include "mbed.h"
sk398 0:fbf82bf637bb 2 #include "MCP9803.h"
sk398 0:fbf82bf637bb 3
sk398 0:fbf82bf637bb 4 MCP9803 TempSensor(PB_9,PB_8,0x90,100000);
sk398 0:fbf82bf637bb 5
sk398 0:fbf82bf637bb 6 int main()
sk398 0:fbf82bf637bb 7 {
sk398 0:fbf82bf637bb 8 char data[2];
sk398 0:fbf82bf637bb 9
sk398 0:fbf82bf637bb 10 data[0] = 0x01;
sk398 0:fbf82bf637bb 11 data[1] = 0x72;
sk398 0:fbf82bf637bb 12
sk398 0:fbf82bf637bb 13 printf("Write Return Value = %d\r\n",TempSensor.I2C_Write(data,2));
sk398 0:fbf82bf637bb 14
sk398 0:fbf82bf637bb 15 data[0] = 0x01;
sk398 0:fbf82bf637bb 16
sk398 0:fbf82bf637bb 17 printf("Write Return Value = %d\r\n",TempSensor.I2C_Write(data,1));
sk398 0:fbf82bf637bb 18
sk398 0:fbf82bf637bb 19 TempSensor.I2C_Read(1);
sk398 0:fbf82bf637bb 20
sk398 0:fbf82bf637bb 21 data[0] = 0x00;
sk398 0:fbf82bf637bb 22 TempSensor.I2C_Write(data,1);
sk398 0:fbf82bf637bb 23
sk398 0:fbf82bf637bb 24 TempSensor.I2C_Read(2);
sk398 0:fbf82bf637bb 25
sk398 0:fbf82bf637bb 26
sk398 0:fbf82bf637bb 27
sk398 0:fbf82bf637bb 28 }