Loading...
Searching...
No Matches
lm75_params.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
17
18#include "board.h" /* IWYU pragma: keep */
19#include "lm75.h"
20#include "lm75_regs.h"
21#include "modules.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#ifndef LM75_PARAM_I2C
28# define LM75_PARAM_I2C I2C_DEV(0)
29#endif
30
37#ifndef CONFIG_LM75_I2C_ADDR
38# define CONFIG_LM75_I2C_ADDR (0x48)
39#endif
40
41/* Device operation mode configuration - normal or shutdown */
42#if IS_ACTIVE(CONFIG_NORMAL_MODE)
43# define CONFIG_OPERATION_MODE NORMAL_MODE
44#elif IS_ACTIVE(CONFIG_SHUTDOWN_MODE)
45# define CONFIG_OPERATION_MODE SHUTDOWN_MODE
46#endif
47
48#ifndef CONFIG_OPERATION_MODE
49# define CONFIG_OPERATION_MODE NORMAL_MODE
50#endif
51
52/* Device Overtemperature Shutdown operation mode configuration - comparator or interrupt */
53#if IS_ACTIVE(CONFIG_COMPARATOR_MODE)
54# define CONFIG_THERMOSTAT_MODE COMPARATOR_MODE
55#elif IS_ACTIVE(CONFIG_INTERRUPT_MODE)
56# define CONFIG_THERMOSTAT_MODE INTERRUPT_MODE
57#endif
58
59#ifndef CONFIG_THERMOSTAT_MODE
60# define CONFIG_THERMOSTAT_MODE COMPARATOR_MODE
61
62#endif
63
64/* Device Overtemperature Shutdown polarity configuration - OS active low or high */
65#if IS_ACTIVE(CONFIG_OS_ACTIVE_LOW)
66# define CONFIG_OS_POLARITY OS_ACTIVE_LOW
67#elif IS_ACTIVE(CONFIG_OS_ACTIVE_HIGH)
68# define CONFIG_OS_POLARITY OS_ACTIVE_HIGH
69#endif
70
71#ifndef CONFIG_OS_POLARITY
72# define CONFIG_OS_POLARITY OS_ACTIVE_LOW
73
74#endif
75
76#if IS_ACTIVE(CONFIG_FAULT_1)
77# define CONFIG_FAULT_QUEUE FAULT_1
78#elif IS_ACTIVE(CONFIG_FAULT_2)
79# define CONFIG_FAULT_QUEUE FAULT_2
80#elif (IS_ACTIVE(CONFIG_FAULT_3) && IS_USED(MODULE_TMP1075))
81# define CONFIG_FAULT_QUEUE FAULT_3
82#elif (IS_ACTIVE(CONFIG_FAULT_4) && IS_USED(MODULE_LM75A))
83# define CONFIG_FAULT_QUEUE FAULT_4
84#elif (IS_ACTIVE(CONFIG_FAULT_4) && IS_USED(MODULE_TMP1075))
85# define CONFIG_FAULT_QUEUE FAULT_4_TMP1075
86#elif (IS_ACTIVE(CONFIG_FAULT_6) && IS_USED(MODULE_LM75A))
87# define CONFIG_FAULT_QUEUE FAULT_6
88#endif
89
97#ifndef CONFIG_FAULT_QUEUE
98# define CONFIG_FAULT_QUEUE FAULT_1
99#endif
100
101#ifndef LM75_PARAM_INT
102# define LM75_PARAM_INT GPIO_UNDEF
103#endif
104
105#define LM75A_CONV_RATE (100)
106
107#define LM75A_OS_RES (5)
108#define LM75A_OS_MULT (10)
109#define LM75A_OS_SHIFT (7)
110#define LM75A_TEMP_RES (125)
111#define LM75A_TEMP_MULT (1000)
112#define LM75A_TEMP_SHIFT (5)
113
114#define TMP1075_OS_RES (625)
115#define TMP1075_OS_MULT (10000)
116#define TMP1075_OS_SHIFT (4)
117#define TMP1075_TEMP_RES (625)
118#define TMP1075_TEMP_MULT (10000)
119#define TMP1075_TEMP_SHIFT (4)
120
121#if IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_27H)
122# define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_27H
123# define TMP1075_CONV_RATE (28)
124#elif IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_55)
125# define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_55
126# define TMP1075_CONV_RATE (55)
127#elif IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_110)
128# define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_110
129# define TMP1075_CONV_RATE (110)
130#elif IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_220)
131# define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_220
132# define TMP1075_CONV_RATE (220)
133#endif
134
135#ifndef CONFIG_TMP1075_CONV_RATE_REG
143# define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_27H
150# define TMP1075_CONV_RATE (28)
151#endif
152
153#ifndef LM75_PARAMS
154# if IS_USED(MODULE_LM75A)
155# define LM75_PARAMS { .res = &lm75a_properties, \
156 .gpio_alarm = LM75_PARAM_INT, \
157 .conv_rate = LM75A_CONV_RATE, \
158 .i2c_bus = LM75_PARAM_I2C, \
159 .i2c_addr = CONFIG_LM75_I2C_ADDR, \
160 .shutdown_mode = CONFIG_OPERATION_MODE, \
161 .tm_mode = CONFIG_THERMOSTAT_MODE, \
162 .polarity = CONFIG_OS_POLARITY, \
163 .fault_q = CONFIG_FAULT_QUEUE }
164
165# endif
166
167# if IS_USED(MODULE_TMP1075)
168# define LM75_PARAMS { .res = &tmp1075_properties, \
169 .gpio_alarm = LM75_PARAM_INT, \
170 .conv_rate = TMP1075_CONV_RATE, \
171 .i2c_bus = LM75_PARAM_I2C, \
172 .i2c_addr = CONFIG_LM75_I2C_ADDR, \
173 .shutdown_mode = CONFIG_OPERATION_MODE, \
174 .tm_mode = CONFIG_THERMOSTAT_MODE, \
175 .polarity = CONFIG_OS_POLARITY, \
176 .fault_q = CONFIG_FAULT_QUEUE, \
177 .conv_rate_reg = CONFIG_TMP1075_CONV_RATE_REG }
178# endif
179#endif /* LM75_PARAMS */
180
184static const lm75_params_t lm75_params[] = {
185 LM75_PARAMS
186};
187
188#ifdef __cplusplus
189}
190#endif
191
Driver for the LM75 and TMP1075 temperature sensors.
struct lm75_params lm75_params_t
Parameters required for initialization.
Registers for the lm75 and derived (lm75a and tmp1075) temperature sensors.
Common macros and compiler attributes/pragmas configuration.
Parameters required for initialization.
Definition lm75.h:63