Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
31210b7
drivers/tmp117: TMP117 driver
leocordier May 19, 2026
33e7f11
Update drivers/include/tmp117.h
leocordier May 19, 2026
7f93db1
Update drivers/include/tmp117.h
leocordier May 19, 2026
53375b9
Update drivers/include/tmp117.h
leocordier May 19, 2026
41c205f
Update drivers/include/tmp117.h
leocordier May 19, 2026
0ad27c0
Update drivers/include/tmp117.h
leocordier May 19, 2026
b970951
Update drivers/include/tmp117.h
leocordier May 19, 2026
9b92f13
Update drivers/tmp117/tmp117.c
leocordier May 19, 2026
d8d4b5d
Update drivers/tmp117/tmp117.c
leocordier May 19, 2026
1a9a218
Update tests/drivers/tmp117/README.md
leocordier May 19, 2026
2c62eda
Update tests/drivers/tmp117/README.md
leocordier May 19, 2026
c1cd55e
Apply suggestion from @crasbe
leocordier May 19, 2026
0c89813
Apply suggestion from @crasbe
leocordier May 19, 2026
d74c5c6
Apply suggestion from @crasbe
leocordier May 19, 2026
3c372c9
Apply suggestion from @crasbe
leocordier May 19, 2026
92d730e
review of crasbe sugestions
leocordier May 19, 2026
ea621ff
uncrustify source file
leocordier May 19, 2026
952ca3c
drivers/tmp117/tmp117.c: change helper functions to static according …
leocordier May 20, 2026
2d7e7ed
uncrustify files and changing error values to errno according to basi…
leocordier May 20, 2026
e0ba063
adding saul support for tmp117 driver
leocordier May 21, 2026
9a52738
correct murdock errors
leocordier May 21, 2026
a03157b
drivers/saul/init_devs/auto_init_tmp117.c: change ARRAY_SIZE declarat…
leocordier May 25, 2026
928b221
proccessing basilfx review
leocordier May 26, 2026
59a3b64
remove tests/drivers/tmp117/Makefile.uncrustify
leocordier May 26, 2026
a98131f
drivers/tmp117/tmp117.c: change temperature conversion according to k…
leocordier May 26, 2026
b5212b6
change according to kfessel review
leocordier May 27, 2026
4703875
drivers/tmp117: add comments and removing whitespaces
leocordier Jun 22, 2026
9a69aac
correct review comments
leocordier Jun 25, 2026
54e8194
drivers/include/tmp117.h: remove tab line 9
leocordier Jun 29, 2026
24b10f1
drivers/tmp117/include/tmp117_params.h: remove defgroup
leocordier Jun 29, 2026
92ae0c0
drivers/tmp117/include/tmp117_regs.h: remove defgroup
leocordier Jun 29, 2026
177d1d3
tests/drivers/tmp117/main.c: remove tab line 9
leocordier Jun 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions drivers/include/tmp117.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* SPDX-FileCopyrightText: 2026 UGA
* SPDX-License-Identifier: LGPL-2.1-only
*/

#pragma once

/**
* @defgroup drivers_tmp117
* @ingroup drivers_sensors
* @brief Driver for TMP117 temperature sensor
*
* @{
* @file
* @brief Parameters definition for the TMP117 temperature sensor
* @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 */
};
Comment thread
leocordier marked this conversation as resolved.

/**
* @brief TMP117 conversion modes
*/
typedef enum {
TMP117_CONV_CC = 0, /**< continuous conversion mode */
TMP117_CONV_SD = 1, /**< shutdown conversion mode */
TMP117_CONV_OS = 3 /**< one shot conversion mode */
} tmp117_conv_mode_t;

/**
* @brief TMP117 conversion cycle
*/
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;

/**
* @brief TMP117 averaging value
*/
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;

/**
* @brief TMP117 parameters structure
*/
typedef struct {
i2c_t i2c; /**< i2c peripheral */
uint8_t addr; /**< i2c address */
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}tmp117_params_t;
} tmp117_params_t;


/**
* @brief TMP117 sensor structure
*/
typedef struct {
tmp117_params_t params;
bool is_initialized;
} tmp117_t;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many blank lines.

Static checks will highlight a few more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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
* @param[in,out] dev device descriptor
* @param[out] value read value in centi-celsius
*
* @retval TMP117_OK on success
* @retval TMP117_I2C if other error occurs

*/
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in, out] dev device descriptor
* @param[in] mode conversion mode value
*
* @return TMP117_OK on success
* @return TMP117_I2C if other error occurs
* @param[in,out] dev device descriptor
* @param[in] mode conversion mode value
*
* @retval TMP117_OK on success
* @retval TMP117_I2C if other error occurs

*/
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in, out] dev device descriptor
* @param[in] cycle conversion cycle value
*
* @return TMP117_OK on success
* @return TMP117_I2C if other error occurs
* @param[in,out] dev device descriptor
* @param[in] cycle conversion cycle value
*
* @retval TMP117_OK on success
* @retval TMP117_I2C if other error occurs

*/
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in, out] dev device descriptor
* @param[in,out] dev device descriptor

* @param[in] avg averaging value
*
* @return TMP117_OK on success
* @return TMP117_I2C if other error occurs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return TMP117_OK on success
* @return TMP117_I2C if other error occurs
* @retval TMP117_OK on success
* @retval TMP117_I2C if other error occurs

*/
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param[in, out] dev device descriptor
* @param[in,out] dev device descriptor

*
* @return TMP117_DATAREADY a new data is available
* @return TMP117_OK no new data available
* @return TMP117_I2C if other error occurs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
* @retval TMP117_DATAREADY a new data is available
* @retval TMP117_OK no new data available
* @retval TMP117_I2C if other error occurs

*/
int tmp117_is_data_ready(tmp117_t *dev);

#ifdef __cplusplus
}
#endif

/** @} */
66 changes: 66 additions & 0 deletions drivers/saul/init_devs/auto_init_tmp117.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* SPDX-FileCopyrightText: 2026 UGA
* 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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @author léo cordier <leo.cordier@univ-grenoble-alpes.fr>
* @author Léo Cordier <leo.cordier@univ-grenoble-alpes.fr>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 "container.h"

#include "tmp117.h"
#include "tmp117_params.h"

/**
* @brief Define the number of configured sensors
*/
#define TMP117_NUM ARRAY_SIZE(tmp117_params)

/**
* @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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Define the number of saul info
* @brief Define the number of SAUL info

*/
#define TMP117_INFO_NUM ARRAY_SIZE(tmp117_saul_info)

/**
* @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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG_DEBUG("[auto_init_saul] initializing tmp117 #%u\n", i);
LOG_DEBUG("[auto_init_saul] initializing TMP117 #%u\n", i);


if (tmp117_init(&tmp117_devs[i], &tmp117_params[i]) != TMP117_OK) {
LOG_ERROR("[auto_init_saul] error initializing tmp117 #%u\n", i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG_ERROR("[auto_init_saul] error initializing tmp117 #%u\n", i);
LOG_ERROR("[auto_init_saul] error initializing TMP117 #%u\n", i);

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]));
}
}
4 changes: 4 additions & 0 deletions drivers/saul/init_devs/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ void saul_init_devs(void)
extern void auto_init_tmp00x(void);
auto_init_tmp00x();
}
if (IS_USED(MODULE_TMP117)) {
extern void auto_init_tmp117(void);
auto_init_tmp117();
}
if (IS_USED(MODULE_TSL2561)) {
extern void auto_init_tsl2561(void);
auto_init_tsl2561();
Expand Down
1 change: 1 addition & 0 deletions drivers/tmp117/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTMAKE)/driver_with_saul.mk
1 change: 1 addition & 0 deletions drivers/tmp117/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FEATURES_REQUIRED += periph_i2c
2 changes: 2 additions & 0 deletions drivers/tmp117/Makefile.include
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)
84 changes: 84 additions & 0 deletions drivers/tmp117/include/tmp117_params.h
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

Comment thread
leocordier marked this conversation as resolved.
/**
* @defgroup drivers_tmp117
* @ingroup drivers_sensors
* @brief Driver for TMP117 temperature sensor
*
* @{
* @file
* @brief Parameters definition for the TMP117 temperature sensor
* @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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
/**
#endif
/**

Double blank lines should be avoided in C code, usually the static test complains about this too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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)) /**< default TMP117 i2c peripheral */
#endif
#ifndef TMP117_PARAM_ADDR
# define TMP117_PARAM_ADDR (0x48) /**< default TMP117 i2c address */
#endif
#ifndef TMP117_PARAM_CONV_MODE
# define TMP117_PARAM_CONV_MODE TMP117_CONV_CC /**< default TMP117 conversion mode */
#endif
#ifndef TMP117_PARAM_CONV_CYCLE
# define TMP117_PARAM_CONV_CYCLE TMP117_CONV_CYCLE_1_S /**< default TMP117 conversion cycle */
#endif
#ifndef TMP117_PARAM_AVG
# define TMP117_PARAM_AVG TMP117_AVG_8 /**< default TMP117 averaging */
#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 } /**< default TMP117 parameters */
#endif
Comment on lines +46 to +52

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#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
#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

/** @} */

#ifndef TMP117_SAUL_INFO
/**
* @brief The SAUL info to register the TMP117 device driver instances with
*/
#define TMP117_SAUL_INFO { .name = "tmp117" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define TMP117_SAUL_INFO { .name = "tmp117" }
# define TMP117_SAUL_INFO { .name = "TMP117" }

#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

/** @} */
Loading