Loading...
Searching...
No Matches

Driver for the LM75 temperature sensor. More...

Detailed Description

Driver for the LM75 temperature sensor.

Author
Vitor Batista vitor.nosp@m..bat.nosp@m.ista@.nosp@m.ml-p.nosp@m.a.com

Definition in file lm75.h.

#include <stdbool.h>
#include "periph/i2c.h"
#include "periph/gpio.h"
+ Include dependency graph for lm75.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lm75_properties
 temperature reading properties/resolutions struct of the LM75 sensors More...
 
struct  lm75_params
 params required for initialization More...
 
struct  lm75
 lm75 device descriptor More...
 

LM75 return values

enum  { LM75_SUCCESS = 0 , LM75_ERROR_I2C , LM75_ERROR }
 
typedef struct lm75_properties lm75_properties_t
 temperature reading properties/resolutions struct of the LM75 sensors
 
typedef struct lm75_params lm75_params_t
 params required for initialization
 
typedef struct lm75 lm75_t
 lm75 device descriptor
 
lm75_properties_t lm75a_properties
 declaration present in lm75.c
 
lm75_properties_t tmp1075_properties
 declaration present in lm75.c
 
int lm75_init (lm75_t *dev, const lm75_params_t *params)
 Initialization of the LM75 sensor.
 
int lm75_get_temperature_raw (lm75_t *dev, int *temperature)
 Temperature values of LM75 sensor.
 
int lm75_get_temperature (lm75_t *dev, int *temperature)
 Temperature values of LM75 sensor.
 
int lm75_set_temp_limits (lm75_t *dev, int temp_hyst, int temp_os, gpio_cb_t cb, void *arg)
 Sets the values for Overtemperature shutdown(OS) and Hysteresis temperature(HYST).
 
int lm75_get_os_temp (lm75_t *dev, int *temperature)
 Overshutdown temperature value of LM75 sensor.
 
int lm75_get_hyst_temp (lm75_t *dev, int *temperature)
 Hysteresis temperature value of LM75 sensor.
 
int lm75_get_os_pin (lm75_t *dev, bool *os_pin_state)
 Read the current state of the OS pin to see if it's active.
 
int lm75_poweroff (lm75_t *dev)
 Activate the LM75 sensor shutdown mode.
 
int lm75_poweron (lm75_t *dev)
 Deactivate the LM75 sensor shutdown mode.
 
int tmp1075_one_shot (lm75_t *dev)
 Activates one shot conversion mode.
 
int lm75_low_power_mode (lm75_t *dev, uint16_t interval)
 Activates low power mode operation.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 40 of file lm75.h.

Function Documentation

◆ lm75_get_hyst_temp()

int lm75_get_hyst_temp ( lm75_t dev,
int *  temperature 
)

Hysteresis temperature value of LM75 sensor.

Reads the sensor hysteresis temperature value from THYST_REG in ºC.

Parameters
[in]devdevice structure
[out]temperaturebuffer where HYST temperature value will be written
Returns
LM75_SUCCESS, on success
LM75_ERROR_I2C, on I2C related error

◆ lm75_get_os_pin()

int lm75_get_os_pin ( lm75_t dev,
bool *  os_pin_state 
)

Read the current state of the OS pin to see if it's active.

Read the configuration register to see the OS pin's polarity and then reads its state. Then outputs if the pin is active and whether it's in the low and active or high and active.

Parameters
[in]devdevice structure
[out]os_pin_statepointer to the state of the OS pin - 0 for inactive and 1 for active
Returns
LM75_SUCCESS, on success
LM75_ERROR, on pin reading error

◆ lm75_get_os_temp()

int lm75_get_os_temp ( lm75_t dev,
int *  temperature 
)

Overshutdown temperature value of LM75 sensor.

Reads the sensor OS temperature value from TOS_REG in ºC.

Parameters
[in]devdevice structure
[out]temperaturebuffer where OS temperature value will be written
Returns
LM75_SUCCESS, on success
LM75_ERROR_I2C, on I2C related error

◆ lm75_get_temperature()

int lm75_get_temperature ( lm75_t dev,
int *  temperature 
)

Temperature values of LM75 sensor.

Gets the device's temperature register with the lm75_get_temperature_raw function and then returns the values in mºC, truncating values smaller than this, if available

Parameters
[in]devdevice structure
[in]temperaturebuffer where temperature value will be written in mºC
Returns
LM75_SUCCESS, on success
LM75_ERROR, on error

◆ lm75_get_temperature_raw()

int lm75_get_temperature_raw ( lm75_t dev,
int *  temperature 
)

Temperature values of LM75 sensor.

Reads the sensor temperature values from TEMP_REG the value is given with the full precision the device is capable of If divided by the device's mult property, the result will be the temperature in ºC and the remainder of that division will be the decimal part of the temperature, at the maximum resolution the device is capable of.

Parameters
[in]devdevice structure
[in]temperaturebuffer where temperature value will be written
Returns
LM75_SUCCESS, on success
LM75_ERROR_I2C, on I2C related error

◆ lm75_init()

int lm75_init ( lm75_t dev,
const lm75_params_t params 
)

Initialization of the LM75 sensor.

Initializes the sensor according to specific input parameters.

Parameters
[out]devdevice structure to initialize
[in]paramsinitialization parameters
Returns
LM75_SUCCESS, on success
LM75_ERROR_I2C, on I2C related error
LM75_ERROR, on initialization related error

◆ lm75_low_power_mode()

int lm75_low_power_mode ( lm75_t dev,
uint16_t  interval 
)

Activates low power mode operation.

This function makes the device measure temperatures in a strictly discrete way at a user definable rate, as opposed to performing continuous measurements at the device's conversion rate. It allows the device to stay in shutdown mode for the most part, therefore consuming less power. In the tmp1075 and other devices which have the one shot feature this is done automatically. In the LM75A sensor nd other sensors which lack the one shot mode feature this is done manually by switching the device to and from shutdown mode and staying awake at least long enough to perform one ne measurement.

Parameters
[in]devdevice structure
[in]intervaltime interval in ms between measurements
Returns
LM75_ERROR if unsuccessful
LM75_SUCCESS if successful

◆ lm75_poweroff()

int lm75_poweroff ( lm75_t dev)

Activate the LM75 sensor shutdown mode.

Parameters
[in]devdevice structure to set into shutdown mode
Returns
LM75_SUCCESS, on success
LM75_ERROR, on mode switching related error

◆ lm75_poweron()

int lm75_poweron ( lm75_t dev)

Deactivate the LM75 sensor shutdown mode.

Parameters
[in]devdevice structure to wake up from shutdown mode
Returns
LM75_SUCCESS, on success
LM75_ERROR, on mode switching related error

◆ lm75_set_temp_limits()

int lm75_set_temp_limits ( lm75_t dev,
int  temp_hyst,
int  temp_os,
gpio_cb_t  cb,
void *  arg 
)

Sets the values for Overtemperature shutdown(OS) and Hysteresis temperature(HYST).

OS gives the temperature's higher bound and HYST the lower bound values are rounded to the lowest value that the device supports,

Parameters
[in]devdevice structure
[in]temp_osdesired OS temperature in mºC
[in]temp_hystdesired HYST temperature in mºC
[in]cbcallback that is called from interrupt context
[in]*argoptional arguments for the gpio_init_int function
Returns
LM75_SUCCESS, on success
LM75_ERROR_I2C, on I2C related error
LM75_ERROR, on temperature setting related error

◆ tmp1075_one_shot()

int tmp1075_one_shot ( lm75_t dev)

Activates one shot conversion mode.

Wakes from shutdown mode, does a single temperature conversion and writes in into the temperature register and then goes back into shutdown

Parameters
[in]devdevice structure
Returns
LM75_ERROR if unsuccessful
LM75_SUCCESS if successful