Initial I2C Working

Dependencies:   mbed

Committer:
sk398
Date:
Wed Mar 29 17:55:38 2017 +0000
Revision:
2:832cb4376d2a
Parent:
1:444546e8cd20
Child:
3:c6aad2355a40
Working version on the NUCLEO-F446RE board

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