Hello code for "Switch Science mbed LPC824"

Dependencies:   mbed

Fork of SwitchSciencembedLPC824_test by Mako SHIMURA

Revision:
1:3c29c04cfeb2
Parent:
0:f947ed831c67
Child:
2:482581f76a1d
--- a/main.cpp	Mon Nov 03 00:03:55 2014 +0000
+++ b/main.cpp	Mon Nov 03 00:06:59 2014 +0000
@@ -1,48 +1,13 @@
 #include "mbed.h"
-
-//  LM75B I2C slave address
-#define     ADDRESS_LM75B   0x90
+#include "test_LM75B.h"
 
-//  LM75B registers
-#define     LM75B_Conf      0x01
-#define     LM75B_Temp      0x00
-#define     LM75B_Tos       0x03
-#define     LM75B_Thyst     0x02
-
-I2C     i2c( p28, p27 );
-
-void    init( void );
-float   read_temp( void );
-
+test_LM75B  temp( p28, p27 );
 
 int main()
 {
-    init();
-
     while(1) {
-        printf( "temp = %7.3f\r\n", read_temp() );
+        printf( "temp = %7.3f\r\n", temp.read() );
         wait( 1 );
     }
 }
 
-void init( void )
-{
-    char    command[ 2 ];
-
-    command[ 0 ]    = LM75B_Conf;
-    command[ 1 ]    = 0x00;
-
-    i2c.write( ADDRESS_LM75B, command, 2 );
-}
-
-float read_temp( void )
-{
-    char    command[ 2 ];
-
-    command[ 0 ]    = LM75B_Temp;
-
-    i2c.write( ADDRESS_LM75B, command, 1 );  // Send command string
-    i2c.read(  ADDRESS_LM75B, command, 2 );  // read two bytes data
-
-    return ( (float)( (command[ 0 ] << 8)| command[1] ) / 256.0 );
-}