Initial I2C Working

Dependencies:   mbed

Committer:
sk398
Date:
Thu Mar 30 06:27:48 2017 +0000
Revision:
3:c6aad2355a40
Parent:
2:832cb4376d2a
Working Version. By commenting out the required class decleration, the software is portable between the F042K6 and F446RE development boards

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 3:c6aad2355a40 4 ////F446RE Board
sk398 3:c6aad2355a40 5 //MCP9803 TempSensor(PB_9,PB_8,0x90,100000);
sk398 3:c6aad2355a40 6
sk398 3:c6aad2355a40 7 //F042K6 Board
sk398 3:c6aad2355a40 8 MCP9803 TempSensor(PB_7,PB_6,0x90,100000);
sk398 0:fbf82bf637bb 9
sk398 0:fbf82bf637bb 10 int main()
sk398 0:fbf82bf637bb 11 {
sk398 2:832cb4376d2a 12 // Example of how to Configure Sensor
sk398 0:fbf82bf637bb 13
sk398 2:832cb4376d2a 14 int configSuccess = TempSensor.ConfigSensor(0x00,0x01,0x00,0x02,0x03,0x00);
sk398 0:fbf82bf637bb 15
sk398 2:832cb4376d2a 16 // Print value returned from ConfigSensor
sk398 2:832cb4376d2a 17 // 0 indicates success, 1 indicates failure
sk398 2:832cb4376d2a 18 printf("CONFIG Success = %d\r\n\r\n",configSuccess);
sk398 1:444546e8cd20 19
sk398 2:832cb4376d2a 20 // Print raw temp value
sk398 2:832cb4376d2a 21 // Anything other than 0x0FF0 indicates success
sk398 2:832cb4376d2a 22 printf("Temp Raw = %04x\r\n",TempSensor.RawTempValue());
sk398 1:444546e8cd20 23
sk398 2:832cb4376d2a 24 // Print converted temp values
sk398 2:832cb4376d2a 25 // Anything other than -2000.000 indicates success
sk398 2:832cb4376d2a 26 printf("Temp C = %f\r\n",TempSensor.FormattedTempValue(CELCIUS));
sk398 2:832cb4376d2a 27 printf("Temp F = %f\r\n",TempSensor.FormattedTempValue(FARENHEIT));
sk398 2:832cb4376d2a 28 printf("Temp K = %f\r\n",TempSensor.FormattedTempValue(KELVIN));
sk398 2:832cb4376d2a 29
sk398 2:832cb4376d2a 30 // Example of failure from sending wrong format
sk398 2:832cb4376d2a 31 printf("Temp ? = %f\r\n",TempSensor.FormattedTempValue(0x0F));
sk398 0:fbf82bf637bb 32 }