Loading...
Searching...
No Matches
lm75_params.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
19#ifndef LM75_PARAMS_H
20#define LM75_PARAMS_H
21
22#include "board.h"
23#include "lm75.h"
24#include "lm75_regs.h"
25#include "kernel_defines.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#ifndef LM75_PARAM_I2C
32#define LM75_PARAM_I2C I2C_DEV(0)
33#endif
34
38#ifndef CONFIG_LM75_I2C_ADDR
39#define CONFIG_LM75_I2C_ADDR (0x48)
40#endif
41
42/* Device operation mode configuration - normal or shutdown */
43#if IS_ACTIVE(CONFIG_NORMAL_MODE)
44#define CONFIG_OPERATION_MODE NORMAL_MODE
45#elif IS_ACTIVE(CONFIG_SHUTDOWN_MODE)
46#define CONFIG_OPERATION_MODE SHUTDOWN_MODE
47#endif
48
49#ifndef CONFIG_OPERATION_MODE
50#define CONFIG_OPERATION_MODE NORMAL_MODE
52#endif
53
54/* Device Overtemperature Shutdown operation mode configuration - comparator or interrupt */
55#if IS_ACTIVE(CONFIG_COMPARATOR_MODE)
56#define CONFIG_THERMOSTAT_MODE COMPARATOR_MODE
57#elif IS_ACTIVE(CONFIG_INTERRUPT_MODE)
58#define CONFIG_THERMOSTAT_MODE INTERRUPT_MODE
59#endif
60
61#ifndef CONFIG_THERMOSTAT_MODE
62#define CONFIG_THERMOSTAT_MODE COMPARATOR_MODE
64#endif
65
66/* Device Overtemperature Shutdown polarity configuration - OS active low or high */
67#if IS_ACTIVE(CONFIG_OS_ACTIVE_LOW)
68#define CONFIG_OS_POLARITY OS_ACTIVE_LOW
69#elif IS_ACTIVE(CONFIG_OS_ACTIVE_HIGH)
70#define CONFIG_OS_POLARITY OS_ACTIVE_HIGH
71#endif
72
73#ifndef CONFIG_OS_POLARITY
74#define CONFIG_OS_POLARITY OS_ACTIVE_LOW
76#endif
77
78/* Device Overtemperatue Shutdown fault queue configuration -
79 * number of faults that must occur consecutively until OS goes active */
80#if IS_ACTIVE(CONFIG_FAULT_1)
81#define CONFIG_FAULT_QUEUE FAULT_1
82#elif IS_ACTIVE(CONFIG_FAULT_2)
83#define CONFIG_FAULT_QUEUE FAULT_2
84#elif (IS_ACTIVE(CONFIG_FAULT_3) && IS_USED(MODULE_TMP1075))
85#define CONFIG_FAULT_QUEUE FAULT_3
86#elif (IS_ACTIVE(CONFIG_FAULT_4) && IS_USED(MODULE_LM75A))
87#define CONFIG_FAULT_QUEUE FAULT_4
88#elif (IS_ACTIVE(CONFIG_FAULT_4) && IS_USED(MODULE_TMP1075))
89#define CONFIG_FAULT_QUEUE FAULT_4_TMP1075
90#elif (IS_ACTIVE(CONFIG_FAULT_6) && IS_USED(MODULE_LM75A))
91#define CONFIG_FAULT_QUEUE FAULT_6
92#endif
93
94#ifndef CONFIG_FAULT_QUEUE
95#define CONFIG_FAULT_QUEUE FAULT_1
97#endif
98
99#ifndef LM75_PARAM_INT
100#define LM75_PARAM_INT GPIO_UNDEF
101#endif
102
103#define LM75A_CONV_RATE (100)
105#define LM75A_OS_RES (5)
106#define LM75A_OS_MULT (10)
107#define LM75A_OS_SHIFT (7)
108#define LM75A_TEMP_RES (125)
109#define LM75A_TEMP_MULT (1000)
110#define LM75A_TEMP_SHIFT (5)
112#define TMP1075_OS_RES (625)
113#define TMP1075_OS_MULT (10000)
114#define TMP1075_OS_SHIFT (4)
115#define TMP1075_TEMP_RES (625)
116#define TMP1075_TEMP_MULT (10000)
117#define TMP1075_TEMP_SHIFT (4)
119/* Device conversion rate configuration - only available in the TMP1075 sensor */
120#if IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_27H)
121#define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_27H
122#define TMP1075_CONV_RATE (28)
123#elif IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_55)
124#define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_55
125#define TMP1075_CONV_RATE (55)
126#elif IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_110)
127#define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_110
128#define TMP1075_CONV_RATE (110)
129#elif IS_ACTIVE(CONFIG_TMP1075_CONV_RATE_REG_220)
130#define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_220
131#define TMP1075_CONV_RATE (220)
132#endif
133
134#ifndef CONFIG_TMP1075_CONV_RATE_REG
135#define CONFIG_TMP1075_CONV_RATE_REG TMP1075_CONV_RATE_REG_27H
136#define TMP1075_CONV_RATE (28)
137/* this was rounded up to 28ms to retain usage of integers and to keep all times in ms */
138#endif
139
140#ifndef LM75_PARAMS
141#if IS_USED(MODULE_LM75A)
142#define LM75_PARAMS { .res = &lm75a_properties, \
143 .gpio_alarm = LM75_PARAM_INT, \
144 .conv_rate = LM75A_CONV_RATE, \
145 .i2c_bus = LM75_PARAM_I2C, \
146 .i2c_addr = CONFIG_LM75_I2C_ADDR, \
147 .shutdown_mode = CONFIG_OPERATION_MODE, \
148 .tm_mode = CONFIG_THERMOSTAT_MODE, \
149 .polarity = CONFIG_OS_POLARITY, \
150 .fault_q = CONFIG_FAULT_QUEUE }
151
152#endif
153
154#if IS_USED(MODULE_TMP1075)
155#define LM75_PARAMS { .res = &tmp1075_properties, \
156 .gpio_alarm = LM75_PARAM_INT, \
157 .conv_rate = TMP1075_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 .conv_rate_reg = CONFIG_TMP1075_CONV_RATE_REG }
165#endif
166#endif /* LM75_PARAMS */
167
172{
173 LM75_PARAMS
174};
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif /* LM75_PARAMS_H */
Common macros and compiler attributes/pragmas configuration.
Driver for the LM75 temperature sensor.
Registers for the lm75 and derived (lm75a and tmp1075) temperature sensors.
params required for initialization
Definition lm75.h:64