Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LM75B by
LM75B.cpp
00001 #include "LM75B.h" 00002 00003 00004 LM75B::LM75B(PinName sda, PinName scl) : i2c(sda, scl) 00005 { 00006 char cmd[2]; 00007 cmd[0] = LM75B_Conf; 00008 cmd[1] = 0x0; 00009 i2c.write( LM75B_ADDR, cmd, 2); 00010 } 00011 00012 00013 00014 LM75B::~LM75B () 00015 { 00016 00017 } 00018 00019 float LM75B::read() 00020 { 00021 char cmd[2]; 00022 cmd[0] = LM75B_Temp; 00023 00024 i2c.write( LM75B_ADDR, cmd, 1); // Send command string 00025 i2c.read( LM75B_ADDR, cmd, 2); // Send command string 00026 return ( float((cmd[0]<<8)|cmd[1]) / 256.0 ); 00027 } 00028 00029 00030 void LM75B::readRaw(int* a,int* b){ 00031 char cmd[2]; 00032 cmd[0] = LM75B_Temp; 00033 00034 i2c.write( LM75B_ADDR, cmd, 1); // Send command string 00035 i2c.read( LM75B_ADDR, cmd, 2); // Send command string 00036 if(cmd[1]&&0xf8>0) cmd[1]=cmd[1]||0xf8; 00037 *a = cmd[0]; 00038 *b = cmd[1]; 00039 00040 }
Generated on Sat Jul 23 2022 00:05:14 by
1.7.2
