La Suno / Mbed 2 deprecated afero_poc15_180216

Dependencies:   UniGraphic mbed vt100

Embed: (wiki syntax)

« Back to documentation index

LM75B Class Reference

LM75B Class Reference

NXP LM75B Digital temperature sensor and thermal watchdog. More...

#include <LM75B.h>

Public Member Functions

 LM75B (I2C *i2c, int addr)
 LM75B constructor.
 ~LM75B ()
 LM75B destructor.
int temp (int8_t *temp)
 get temperature as one byte (signed)
int getTemp (float *temp)
 get temperature as 11 bit (float)
int getConfig (uint8_t ptr_byte, uint8_t *config_data)
 get configuration register
int setConfig (uint8_t ptr_byte, uint8_t config_data)
 set configuration register

Detailed Description

NXP LM75B Digital temperature sensor and thermal watchdog.

#include "mbed.h"
#include "LM75B.h"
#define LM75B_I2C_ADDRESS (0x48)

#if defined (TARGET_KL25Z)
#define PIN_SCL  PTE1
#define PIN_SDA  PTE0
#elif defined (TARGET_KL46Z)
#define PIN_SCL  PTE1
#define PIN_SDA  PTE0
#elif defined (TARGET_K64F)
#define PIN_SCL  PTE24
#define PIN_SDA  PTE25
#elif defined (TARGET_K22F)
#define PIN_SCL  PTE1
#define PIN_SDA  PTE0
#elif defined (TARGET_KL05Z)
#define PIN_SCL  PTB3
#define PIN_SDA  PTB4
#elif defined (TARGET_NUCLEO_F411RE)
#define PIN_SCL  PB_8
#define PIN_SDA  PB_9
#else
 #error TARGET NOT DEFINED
#endif

int main() {
    int8_t itemp = 0 ;
    float ftemp = 0.0 ;
    LM75B lm75b(PIN_SDA, PIN_SCL, LM75B_I2C_ADDRESS) ;
    
    while(1) {
        itemp = lm75b.temp() ;
        lm75b.getTemp(&ftemp) ;
        printf("Temp = %d C degree,  %.3f C degree\n", itemp, ftemp) ;
        wait(1) ;
    }
}

Definition at line 50 of file LM75B.h.


Constructor & Destructor Documentation

LM75B ( I2C *  i2c,
int  addr 
)

LM75B constructor.

Parameters:
i2cpointer to the I2C object
addraddr of the I2C peripheral

Definition at line 40 of file LM75B.cpp.

~LM75B (  )

LM75B destructor.

Definition at line 46 of file LM75B.cpp.


Member Function Documentation

int getConfig ( uint8_t  ptr_byte,
uint8_t *  config_data 
)

get configuration register

Parameters:
ptr_byteuint8_t pointer value for the register
*config_datauint8_t value of the config register
Returns:
0: success non-0: failure

Definition at line 79 of file LM75B.cpp.

int getTemp ( float *  temp )

get temperature as 11 bit (float)

Parameters:
*tempfloat returns the temperature as float
Returns:
0: success not-0: failure

Definition at line 62 of file LM75B.cpp.

int setConfig ( uint8_t  ptr_byte,
uint8_t  config_data 
)

set configuration register

Parameters:
ptr_byteuint8_t pointer value for the register
config_datauint8_t value to set in the config register
Returns:
0: success non-0: failure

Definition at line 93 of file LM75B.cpp.

int temp ( int8_t *  temp )

get temperature as one byte (signed)

Parameters:
*tempint8_t returns integer part of the temperature
Returns:
0: success not-0: failure

Definition at line 48 of file LM75B.cpp.