Loading...
Searching...
No Matches
lm75.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 ML!PA Consulting GmbH
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
26#ifndef LM75_H
27#define LM75_H
28
29#include <stdbool.h>
30#include "periph/i2c.h"
31#include "periph/gpio.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
40enum {
41 LM75_SUCCESS = 0,
42 LM75_ERROR_I2C,
43 LM75_ERROR
44};
45
49typedef struct lm75_properties {
50 uint16_t os_res;
51 uint16_t os_mult;
52 uint16_t temp_res;
53 uint16_t temp_mult;
54 uint8_t os_shift;
55 uint8_t temp_shift;
57
64typedef struct lm75_params {
66 uint16_t conv_rate;
67 gpio_t gpio_alarm;
69 uint8_t i2c_addr;
70 uint8_t shutdown_mode;
71 uint8_t tm_mode;
72 uint8_t polarity;
73 uint8_t fault_q;
74 /* only configurable for the TMP1075 */
75 uint8_t conv_rate_reg;
77
84
97int lm75_init(lm75_t *dev, const lm75_params_t *params);
98
114int lm75_get_temperature_raw(lm75_t *dev, int *temperature);
115
128int lm75_get_temperature(lm75_t *dev, int *temperature);
129
145int lm75_set_temp_limits(lm75_t *dev, int temp_hyst, int temp_os, gpio_cb_t cb, void *arg);
146
158int lm75_get_os_temp(lm75_t *dev, int *temperature);
159
171int lm75_get_hyst_temp(lm75_t *dev, int *temperature);
172
186int lm75_get_os_pin(lm75_t *dev, bool *os_pin_state);
187
197
207
220
239int lm75_low_power_mode(lm75_t *dev, uint16_t interval);
240
241#ifdef __cplusplus
242}
243#endif
244
245#endif /* LM75_H */
Low-level GPIO peripheral driver interface definitions.
void(* gpio_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition gpio.h:146
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
int lm75_get_hyst_temp(lm75_t *dev, int *temperature)
Hysteresis temperature value of LM75 sensor.
int tmp1075_one_shot(lm75_t *dev)
Activates one shot conversion mode.
struct lm75_properties lm75_properties_t
temperature reading properties/resolutions struct of the LM75 sensors
lm75_properties_t tmp1075_properties
declaration present in lm75.c
int lm75_poweron(lm75_t *dev)
Deactivate the LM75 sensor shutdown mode.
int lm75_low_power_mode(lm75_t *dev, uint16_t interval)
Activates low power mode operation.
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_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.
struct lm75 lm75_t
lm75 device descriptor
int lm75_init(lm75_t *dev, const lm75_params_t *params)
Initialization of the LM75 sensor.
lm75_properties_t lm75a_properties
declaration present in lm75.c
int lm75_poweroff(lm75_t *dev)
Activate the LM75 sensor shutdown mode.
struct lm75_params lm75_params_t
params required for initialization
int lm75_get_os_temp(lm75_t *dev, int *temperature)
Overshutdown temperature value 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).
params required for initialization
Definition lm75.h:64
uint8_t shutdown_mode
Shutdown mode register.
Definition lm75.h:70
const lm75_properties_t * res
Temperature resolutions.
Definition lm75.h:65
gpio_t gpio_alarm
Over-temperature alarm.
Definition lm75.h:67
uint8_t fault_q
Fault Queue register.
Definition lm75.h:73
uint8_t conv_rate_reg
Device Conversion rate register.
Definition lm75.h:75
i2c_t i2c_bus
I2C Bus used.
Definition lm75.h:68
uint8_t i2c_addr
i2c address
Definition lm75.h:69
uint8_t polarity
OS polarity register.
Definition lm75.h:72
uint16_t conv_rate
Conversion rate in ms.
Definition lm75.h:66
uint8_t tm_mode
Thermistor Mode.
Definition lm75.h:71
temperature reading properties/resolutions struct of the LM75 sensors
Definition lm75.h:49
uint8_t os_shift
how many bits need to be shifted (2 bytes - any unused bits)
Definition lm75.h:54
uint16_t temp_mult
multiplier required for getting the temperature into ºC
Definition lm75.h:53
uint8_t temp_shift
how many bits need to be shifted (2 bytes - any unused bits)
Definition lm75.h:55
uint16_t os_res
resolution of the OS and HYST registers
Definition lm75.h:50
uint16_t os_mult
multiplier required for getting the OS and HYST into ºC
Definition lm75.h:51
uint16_t temp_res
resolution of the temperature register
Definition lm75.h:52
lm75 device descriptor
Definition lm75.h:81
lm75_params_t lm75_params
Configuration Parameters.
Definition lm75.h:82