Loading...
Searching...
No Matches
lm75.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 ML!PA Consulting GmbH
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
24
25#include <errno.h> /* IWYU pragma: keep needed for EIO etc. */
26#include <stdbool.h>
27
28#include "periph/gpio.h"
29#include "periph/i2c.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
40#define LM75_SUCCESS 0
41#define LM75_ERROR_I2C (-EIO)
42#define LM75_ERROR (-EINVAL)
44
48typedef struct lm75_properties {
49 uint16_t os_res;
50 uint16_t os_mult;
51 uint16_t temp_res;
52 uint16_t temp_mult;
53 uint8_t os_shift;
54 uint8_t temp_shift;
56
59
63typedef struct lm75_params {
70 uint16_t conv_rate;
71 gpio_t gpio_alarm;
73 uint8_t i2c_addr;
74 uint8_t shutdown_mode;
75 uint8_t tm_mode;
76 uint8_t polarity;
77 uint8_t fault_q;
78 /* only configurable for the TMP1075 */
79 uint8_t conv_rate_reg;
81
88
102int lm75_init(lm75_t *dev, const lm75_params_t *params);
103
119int lm75_get_temperature_raw(const lm75_t *dev, int32_t *temperature);
120
134int lm75_get_temperature(const lm75_t *dev, int32_t *temperature);
135
153int lm75_set_temp_limits(const lm75_t *dev, int32_t temp_hyst, int32_t temp_os,
154 gpio_cb_t cb, void *arg);
155
167int lm75_get_os_temp(const lm75_t *dev, int32_t *temperature);
168
180int lm75_get_hyst_temp(const lm75_t *dev, int32_t *temperature);
181
196int lm75_get_os_pin(const lm75_t *dev, bool *os_pin_state);
197
206int lm75_poweroff(const lm75_t *dev);
207
216int lm75_poweron(const lm75_t *dev);
217
230int tmp1075_one_shot(const lm75_t *dev);
231
252int lm75_low_power_mode(const lm75_t *dev, uint16_t interval);
253
254#ifdef __cplusplus
255}
256#endif
257
Low-level GPIO peripheral driver interface definitions.
void(* gpio_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition gpio.h:143
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
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_poweroff(const lm75_t *dev)
Activate the LM75 sensor shutdown mode.
int lm75_get_temperature(const lm75_t *dev, int32_t *temperature)
Temperature values of LM75 sensor.
int lm75_get_os_pin(const lm75_t *dev, bool *os_pin_state)
Read the current state of the OS pin to see if it's active.
int lm75_poweron(const lm75_t *dev)
Deactivate the LM75 sensor shutdown mode.
struct lm75 lm75_t
LM75 device descriptor.
int lm75_init(lm75_t *dev, const lm75_params_t *params)
Initialization of the LM75 sensor.
int lm75_set_temp_limits(const lm75_t *dev, int32_t temp_hyst, int32_t temp_os, gpio_cb_t cb, void *arg)
Sets the values for Overtemperature Shutdown (OS) and Hysteresis Temperature (HYST).
int lm75_get_os_temp(const lm75_t *dev, int32_t *temperature)
Overtemperature Shutdown (OS) value of the LM75 sensor.
lm75_properties_t lm75a_properties
declaration present in lm75.c
int tmp1075_one_shot(const lm75_t *dev)
Activates one shot conversion mode.
int lm75_get_hyst_temp(const lm75_t *dev, int32_t *temperature)
Hysteresis Temperature (HYST) value of the LM75 sensor.
struct lm75_params lm75_params_t
Parameters required for initialization.
int lm75_low_power_mode(const lm75_t *dev, uint16_t interval)
Activates low power mode operation.
int lm75_get_temperature_raw(const lm75_t *dev, int32_t *temperature)
Temperature values of LM75 sensor.
Parameters required for initialization.
Definition lm75.h:63
uint8_t shutdown_mode
Shutdown mode register.
Definition lm75.h:74
const lm75_properties_t * res
Temperature resolutions.
Definition lm75.h:64
gpio_t gpio_alarm
Over-temperature alarm.
Definition lm75.h:71
uint8_t fault_q
Fault Queue register.
Definition lm75.h:77
uint8_t conv_rate_reg
Device Conversion rate register.
Definition lm75.h:79
i2c_t i2c_bus
I2C Bus used.
Definition lm75.h:72
uint8_t i2c_addr
I2C address.
Definition lm75.h:73
uint8_t polarity
OS polarity register.
Definition lm75.h:76
uint16_t conv_rate
Device Conversion Rate register.
Definition lm75.h:70
uint8_t tm_mode
Thermistor Mode.
Definition lm75.h:75
Temperature reading properties/resolutions struct of the LM75 sensors.
Definition lm75.h:48
uint8_t os_shift
how many bits need to be shifted (2 bytes - any unused bits)
Definition lm75.h:53
uint16_t temp_mult
multiplier required for getting the temperature into ºC
Definition lm75.h:52
uint8_t temp_shift
how many bits need to be shifted (2 bytes - any unused bits)
Definition lm75.h:54
uint16_t os_res
resolution of the OS and HYST registers
Definition lm75.h:49
uint16_t os_mult
multiplier required for getting the OS and HYST into ºC
Definition lm75.h:50
uint16_t temp_res
resolution of the temperature register
Definition lm75.h:51
LM75 device descriptor.
Definition lm75.h:85
lm75_params_t lm75_params
Configuration Parameters.
Definition lm75.h:86