-
Notifications
You must be signed in to change notification settings - Fork 2.1k
drivers/tmp117: TMP117 driver #22310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 22 commits
31210b7
33e7f11
7f93db1
53375b9
41c205f
0ad27c0
b970951
9b92f13
d8d4b5d
1a9a218
2c62eda
c1cd55e
0c89813
d74c5c6
3c372c9
92d730e
ea621ff
952ca3c
2d7e7ed
e0ba063
9a52738
a03157b
928b221
59a3b64
a98131f
b5212b6
4703875
9a69aac
54e8194
24b10f1
92ae0c0
177d1d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,146 @@ | ||||||||||||||||||||||
| /* | ||||||||||||||||||||||
| * SPDX-FileCopyrightText: 2026 UGA | ||||||||||||||||||||||
| * SPDX-License-Identifier: LGPL-2.1-only | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #pragma once | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @defgroup driver_tmp117 | ||||||||||||||||||||||
| * @ingroup drivers_sensors | ||||||||||||||||||||||
| * @brief Device driver for TMP117 temperature sensor | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @{ | ||||||||||||||||||||||
| * @file | ||||||||||||||||||||||
| * @author Léo Cordier <leo.cordier@univ-grenoble-alpes.fr> | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #include "periph/i2c.h" | ||||||||||||||||||||||
| #include <errno.h> | ||||||||||||||||||||||
| #include <stdbool.h> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #ifdef __cplusplus | ||||||||||||||||||||||
| extern "C" { | ||||||||||||||||||||||
| #endif | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Named return values | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| enum { | ||||||||||||||||||||||
| TMP117_OK = 0, /**< everything was fine */ | ||||||||||||||||||||||
| TMP117_DATAREADY = 1, /**< data is ready to be read */ | ||||||||||||||||||||||
| TMP117_NOI2C = -EIO, /**< I2C communication failed */ | ||||||||||||||||||||||
| TMP117_NODEV = -ENODEV, /**< no TMP117 device found on the bus */ | ||||||||||||||||||||||
| TMP117_NODATA = -ENODATA /**< no data available */ | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
leocordier marked this conversation as resolved.
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| typedef enum { | ||||||||||||||||||||||
| TMP117_CONV_CC = 0, /**< continous conversion mode */ | ||||||||||||||||||||||
| TMP117_CONV_SD = 1, /**< shutdown conversion mode */ | ||||||||||||||||||||||
| TMP117_CONV_OS = 3 /**< one shot conversion mode */ | ||||||||||||||||||||||
| } tmp117_conv_mode_t; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| typedef enum { | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_15_MS = 0, /**< 15.5ms conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_125_MS = 1, /**< 125ms conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_250_MS = 2, /**< 250ms conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_500_MS = 3, /**< 500ms conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_1_S = 4, /**< 1s conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_4_S = 5, /**< 4s conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_8_S = 6, /**< 8s conversion cycle */ | ||||||||||||||||||||||
| TMP117_CONV_CYCLE_16_S = 7, /**< 16s conversion cycle */ | ||||||||||||||||||||||
| } tmp117_conv_cycle_t; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| typedef enum { | ||||||||||||||||||||||
| TMP117_NO_AVG = 0, /**< no averaging */ | ||||||||||||||||||||||
| TMP117_AVG_8 = 1, /**< 8 Averaged conversions */ | ||||||||||||||||||||||
| TMP117_AVG_32 = 2, /**< 32 Averaged conversions */ | ||||||||||||||||||||||
| TMP117_AVG_64 = 3, /**< 64 Averaged conversions */ | ||||||||||||||||||||||
| } tmp117_avg_t; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| typedef struct { | ||||||||||||||||||||||
| i2c_t i2c; | ||||||||||||||||||||||
| uint8_t addr; | ||||||||||||||||||||||
| tmp117_conv_mode_t conv_mode; /**< conversion mode */ | ||||||||||||||||||||||
| tmp117_conv_cycle_t conv_cycle; /**< conversion cycle time */ | ||||||||||||||||||||||
| tmp117_avg_t avg; /**< data averaging*/ | ||||||||||||||||||||||
| }tmp117_params_t; | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| typedef struct { | ||||||||||||||||||||||
| tmp117_params_t params; | ||||||||||||||||||||||
| bool is_initialized; | ||||||||||||||||||||||
| } tmp117_t; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too many blank lines. Static checks will highlight a few more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still more blank than needed
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Initializes a TMP117 device | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param[in,out] dev device descriptor | ||||||||||||||||||||||
| * @param[in] params device configuration | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @retval TMP117_OK on success | ||||||||||||||||||||||
| * @retval TMP117_NODEV if no device is found on the bus | ||||||||||||||||||||||
| * @retval TMP117_NOI2C if other error occurs | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| int tmp117_init(tmp117_t *dev, const tmp117_params_t *params); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Reads the temperature from the sensor. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param[in, out] dev device descriptor | ||||||||||||||||||||||
| * @param[out] value read value in centi-celsius | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @return TMP117_OK on success | ||||||||||||||||||||||
| * @return TMP117_I2C if other error occurs | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| int tmp117_read_temperature(tmp117_t *dev, int16_t *value); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Update the conversion mode of the sensor. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param[in, out] dev device descriptor | ||||||||||||||||||||||
| * @param[in] mode conversion mode value | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @return TMP117_OK on success | ||||||||||||||||||||||
| * @return TMP117_I2C if other error occurs | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| int tmp117_set_conversion_mode(tmp117_t *dev, tmp117_conv_mode_t mode); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Update the conversion cycle of the sensor. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param[in, out] dev device descriptor | ||||||||||||||||||||||
| * @param[in] cycle conversion cycle value | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @return TMP117_OK on success | ||||||||||||||||||||||
| * @return TMP117_I2C if other error occurs | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| int tmp117_set_conversion_cycle(tmp117_t *dev, tmp117_conv_cycle_t cycle); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Update the averaging value of the sensor. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param[in, out] dev device descriptor | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| * @param[in] avg averaging value | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @return TMP117_OK on success | ||||||||||||||||||||||
| * @return TMP117_I2C if other error occurs | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| int tmp117_set_averaging(tmp117_t *dev, tmp117_avg_t avg); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @brief Check if the sensor have a new temperature measure available. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param[in, out] dev device descriptor | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @return TMP117_DATAREADY a new data is available | ||||||||||||||||||||||
| * @return TMP117_OK no new data available | ||||||||||||||||||||||
| * @return TMP117_I2C if other error occurs | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| int tmp117_is_data_ready(tmp117_t *dev); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #ifdef __cplusplus | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| #endif | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** @} */ | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||
| /* | ||||||
| * SPDX-FileCopyrightText: 2026 LIG-Geopred | ||||||
| * SPDX-License-Identifier: LGPL-2.1-only | ||||||
| */ | ||||||
|
|
||||||
| /** | ||||||
| * @ingroup sys_auto_init_saul | ||||||
| * @{ | ||||||
| * | ||||||
| * @file | ||||||
| * @brief Auto initialization of TMP117 temperature sensor | ||||||
| * | ||||||
| * @author léo cordier <leo.cordier@univ-grenoble-alpes.fr> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @leocordier: please explain short if / why you want your name lower case? |
||||||
| * | ||||||
| * @} | ||||||
| */ | ||||||
| #include "assert.h" | ||||||
| #include "log.h" | ||||||
| #include "saul_reg.h" | ||||||
|
|
||||||
| #include "tmp117.h" | ||||||
| #include "tmp117_params.h" | ||||||
|
|
||||||
| /** | ||||||
| * @brief Define the number of configured sensors | ||||||
| */ | ||||||
| #define TMP117_NUM (unsigned)(sizeof((tmp117_params)) / sizeof((tmp117_params)[0])) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when i use ARRAY_SIZE the murdoc test fail on github
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you include I assume it is this run |
||||||
|
|
||||||
| /** | ||||||
| * @brief Allocate memory for the device descriptors | ||||||
| */ | ||||||
| static tmp117_t tmp117_devs[TMP117_NUM]; | ||||||
|
|
||||||
| /** | ||||||
| * @brief Memory for the SAUL registry entries | ||||||
| */ | ||||||
| static saul_reg_t saul_entries[TMP117_NUM]; | ||||||
|
|
||||||
| /** | ||||||
| * @brief Define the number of saul info | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| #define TMP117_INFO_NUM (unsigned)(sizeof((tmp117_saul_info)) / sizeof((tmp117_saul_info)[0])) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above |
||||||
|
|
||||||
| /** | ||||||
| * @brief Reference the driver struct | ||||||
| */ | ||||||
| extern const saul_driver_t tmp117_saul_driver; | ||||||
|
|
||||||
|
|
||||||
| void auto_init_tmp117(void) | ||||||
| { | ||||||
| assert(TMP117_NUM == TMP117_INFO_NUM); | ||||||
|
|
||||||
| for (unsigned i = 0; i < TMP117_NUM; i++) { | ||||||
| LOG_DEBUG("[auto_init_saul] initializing tmp117 #%u\n", i); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| if (tmp117_init(&tmp117_devs[i], &tmp117_params[i]) != TMP117_OK) { | ||||||
| LOG_ERROR("[auto_init_saul] error initializing tmp117 #%u\n", i); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| continue; | ||||||
| } | ||||||
| saul_entries[i].dev = &(tmp117_devs[i]); | ||||||
| saul_entries[i].name = tmp117_saul_info[i].name; | ||||||
| saul_entries[i].driver = &tmp117_saul_driver; | ||||||
| saul_reg_add(&(saul_entries[i])); | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include $(RIOTMAKE)/driver_with_saul.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| FEATURES_REQUIRED += periph_i2c | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing newline |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| USEMODULE_INCLUDES_tmp117 := $(LAST_MAKEFILEDIR)/include | ||
| USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_tmp117) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing newline |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||
| * SPDX-FileCopyrightText: 2026 UGA | ||||||||||||||||||||||||||||||
| * SPDX-License-Identifier: LGPL-2.1-only | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #pragma once | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
leocordier marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * @defgroup driver_tmp117 | ||||||||||||||||||||||||||||||
| * @ingroup drivers_sensors | ||||||||||||||||||||||||||||||
| * @brief Device driver parameters for TMP117 temperature sensor | ||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||
| * @{ | ||||||||||||||||||||||||||||||
| * @file | ||||||||||||||||||||||||||||||
| * @author Léo Cordier <leo.cordier@univ-grenoble-alpes.fr> | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #include "board.h" | ||||||||||||||||||||||||||||||
| #include "tmp117.h" | ||||||||||||||||||||||||||||||
| #include "saul_reg.h" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #ifdef __cplusplus | ||||||||||||||||||||||||||||||
| extern "C" { | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Double blank lines should be avoided in C code, usually the static test complains about this too.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, this should be applied to all files. |
||||||||||||||||||||||||||||||
| * @brief Default configuration parameters for TMP117 sensors | ||||||||||||||||||||||||||||||
| * @{ | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| #ifndef TMP117_PARAM_I2C | ||||||||||||||||||||||||||||||
| # define TMP117_PARAM_I2C (I2C_DEV(0)) | ||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align with the other values
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| #ifndef TMP117_PARAM_ADDR | ||||||||||||||||||||||||||||||
| # define TMP117_PARAM_ADDR (0x48) | ||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| #ifndef TMP117_PARAM_CONV_MODE | ||||||||||||||||||||||||||||||
| # define TMP117_PARAM_CONV_MODE TMP117_CONV_CC | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| #ifndef TMP117_PARAM_CONV_CYCLE | ||||||||||||||||||||||||||||||
| # define TMP117_PARAM_CONV_CYCLE TMP117_CONV_CYCLE_1_S | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| #ifndef TMP117_PARAM_AVG | ||||||||||||||||||||||||||||||
| # define TMP117_PARAM_AVG TMP117_AVG_8 | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #ifndef TMP117_PARAMS | ||||||||||||||||||||||||||||||
| # define TMP117_PARAMS { .i2c = TMP117_PARAM_I2C, \ | ||||||||||||||||||||||||||||||
| .addr = TMP117_PARAM_ADDR, \ | ||||||||||||||||||||||||||||||
| .conv_mode = TMP117_PARAM_CONV_MODE, \ | ||||||||||||||||||||||||||||||
| .conv_cycle = TMP117_PARAM_CONV_CYCLE, \ | ||||||||||||||||||||||||||||||
| .avg = TMP117_PARAM_AVG } | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
|
Comment on lines
+46
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| /** @} */ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #ifndef TMP117_SAUL_INFO | ||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * @brief The SAUL info to register the TMP117 device driver instances with | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| #define TMP117_SAUL_INFO { .name = "tmp117" } | ||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| /**@}*/ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * @brief Allocation of TMP117 configuration | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| static const tmp117_params_t tmp117_params[] = | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| TMP117_PARAMS | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * @brief Additional meta information to keep in the SAUL registry | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| static const saul_reg_info_t tmp117_saul_info[] = | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| TMP117_SAUL_INFO | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #ifdef __cplusplus | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||
| /* | ||||||||
| * SPDX-FileCopyrightText: 2026 UGA | ||||||||
| * SPDX-License-Identifier: LGPL-2.1-only | ||||||||
| */ | ||||||||
|
|
||||||||
| #pragma once | ||||||||
|
|
||||||||
| /** | ||||||||
| * @defgroup driver_tmp117 | ||||||||
| * @ingroup drivers_sensors | ||||||||
| * @brief Device driver parameters for TMP117 temperature sensor | ||||||||
| * | ||||||||
| * @{ | ||||||||
| * @file | ||||||||
| * @author Léo Cordier <leo.cordier@univ-grenoble-alpes.fr> | ||||||||
| */ | ||||||||
|
leocordier marked this conversation as resolved.
|
||||||||
|
|
||||||||
|
|
||||||||
| #ifdef __cplusplus | ||||||||
| extern "C" { | ||||||||
| #endif | ||||||||
|
|
||||||||
| /** | ||||||||
| * @name TMP117 registers | ||||||||
| * @{ | ||||||||
| */ | ||||||||
| #define TMP117_REG_TEMP_RESULT (0x00) /**< temperature register address */ | ||||||||
| #define TMP117_REG_CONFIG (0x01) /**< configuration register address */ | ||||||||
| #define TMP117_REG_TEMP_HIGH_LIMIT (0x02) /**< high temperature limit register address */ | ||||||||
| #define TMP117_REG_TEMP_LOW_LIMIT (0x03) /**< low temperature limit register address */ | ||||||||
| #define TMP117_REG_EEPROM_UNLOCK (0x04) /**< EEPROM unlock register address */ | ||||||||
| #define TMP117_REG_EEPROM_1 (0x05) /**< EEPROM 1 register address */ | ||||||||
| #define TMP117_REG_EEPROM_2 (0x06) /**< EEPROM 2 register address */ | ||||||||
| #define TMP117_REG_TEMP_OFFSET (0x07) /**< temperature offset register address */ | ||||||||
| #define TMP117_REG_EEPROM_3 (0x08) /**< EEPROM 3 register address */ | ||||||||
| #define TMP117_REG_DEVICE_ID (0x0F) /**< device ID register address */ | ||||||||
| /** @} */ | ||||||||
|
|
||||||||
|
|
||||||||
| /** | ||||||||
| * @name TMP117 shift mask | ||||||||
| * @{ | ||||||||
| */ | ||||||||
| #define TMP117_DATA_READY_SHIFT 13 /**< data ready bit shift in configuration register */ | ||||||||
| #define TMP117_CONV_MODE_SHIFT 10 /**< conversion mode bits shift in configuration register */ | ||||||||
| #define TMP117_CONV_CYCLE_SHIFT 7 /**< conversion cycle bits shift in configuration register */ | ||||||||
| #define TMP117_AVG_SHIFT 5 /**< averaging bits shift in configuration register */ | ||||||||
| /** @} */ | ||||||||
|
|
||||||||
| /** | ||||||||
| * @name TMP117 field mask | ||||||||
| * @{ | ||||||||
| */ | ||||||||
| #define TMP117_CONV_MODE_MASK (0x3 << TMP117_CONV_MODE_SHIFT) /**< conversion mode bits mask in configuration register */ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please adapt the following lines that are >100 characters long, accordingly. |
||||||||
| #define TMP117_CONV_CYCLE_MASK (0x7 << TMP117_CONV_CYCLE_SHIFT) /**< conversion cycle bits mask in configuration register */ | ||||||||
| #define TMP117_AVG_MASK (0x3 << TMP117_AVG_SHIFT) /**< averaging bits mask in configuration register */ | ||||||||
| #define TMP117_DATA_READY_MASK (0x1 << TMP117_DATA_READY_SHIFT) /**< data ready bit mask in configuration register */ | ||||||||
|
|
||||||||
| /** @} */ | ||||||||
|
|
||||||||
|
|
||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespaces |
||||||||
|
|
||||||||
|
|
||||||||
| /** | ||||||||
| * @name TMP117 registers - default values | ||||||||
| * @{ | ||||||||
| */ | ||||||||
|
|
||||||||
| #define TMP117_REG_DEVICE_ID_DEFAULT_VAL (0x0117) /**< default value of tmp117 device id register */ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| /** @} */ | ||||||||
|
|
||||||||
|
|
||||||||
| #ifdef __cplusplus | ||||||||
| } | ||||||||
| #endif | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other sensors use
drivers_XXX. This needs to be adapted in multiple files.