Add missing stop and check errors.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 22 Jul 2010 15:17:46 +0000 (15:17 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 22 Jul 2010 15:17:46 +0000 (15:17 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4048 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/drv/lm75.c

index db8f8a9420c04755668c35bb07eb988cb604e556..5d24e0ae520224b348727e016982d0d1b7a2e64d 100644 (file)
@@ -62,10 +62,20 @@ deg_t lm75_read(uint8_t sens_addr)
        int16_t degree;
        int16_t deci_degree;
 
-       i2c_start_w(SELECT_ADDRESS(sens_addr));
-       i2c_put(LM75_PAD_BYTE);
-       i2c_start_r(SELECT_ADDRESS(sens_addr));
-       i2c_recv(data, sizeof(data));
+       if( !(i2c_start_w(SELECT_ADDRESS(sens_addr))
+               && i2c_put(LM75_PAD_BYTE)
+               && i2c_start_r(SELECT_ADDRESS(sens_addr))) )
+       {
+               i2c_stop();
+               return EOF;
+       }
+
+       if ( !i2c_recv(data, sizeof(data)) )
+       {
+               i2c_stop();
+               return EOF;
+       }
+       i2c_stop();
 
        degree = (int16_t)data[0];
        deci_degree = (int16_t)(((data[1] >> 7) & 1 ) * 5);