From 82ec6d36b83dab7d034cb78c13523e47f05c6c39 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Thu, 19 Jun 2014 16:46:38 +0200 Subject: [PATCH] This driver is specific to TMP101 sensor, reflect this in files and functions names --- drivers/{temp.c => tmp101_temp_sensor.c} | 20 +++++++++---------- .../drivers/{temp.h => tmp101_temp_sensor.h} | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) rename drivers/{temp.c => tmp101_temp_sensor.c} (93%) rename include/drivers/{temp.h => tmp101_temp_sensor.h} (94%) diff --git a/drivers/temp.c b/drivers/tmp101_temp_sensor.c similarity index 93% rename from drivers/temp.c rename to drivers/tmp101_temp_sensor.c index 902aa91..ec07658 100644 --- a/drivers/temp.c +++ b/drivers/tmp101_temp_sensor.c @@ -26,7 +26,7 @@ #include "core/lpc_core_cm0.h" #include "core/system.h" #include "drivers/i2c.h" -#include "drivers/temp.h" +#include "drivers/tmp101_temp_sensor.h" /***************************************************************************** */ @@ -70,7 +70,7 @@ static int last_accessed_register = 0; /* Check the sensor presence, return 1 if sensor was found. * This is a basic check, it could be anything with the same address ... */ -int probe_sensor(void) +int tmp101_probe_sensor(void) { static int ret = -1; char cmd_buf[1] = { (TMP101_ADDR | I2C_READ_BIT), }; @@ -87,7 +87,7 @@ int probe_sensor(void) * into a decimal integer value of ten times the actual temperature. * The value returned is thus in tenth of degrees centigrade. */ -int convert_to_deci_degrees(uint16_t raw) +int tmp101_convert_to_deci_degrees(uint16_t raw) { return (((int16_t)raw * 10) >> 8); } @@ -105,14 +105,14 @@ int convert_to_deci_degrees(uint16_t raw) * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine */ #define CMD_BUF_SIZE 3 -int temp_read(uint16_t* raw, int* deci_degrees) +int tmp101_temp_read(uint16_t* raw, int* deci_degrees) { int ret = 0; uint16_t temp = 0; char cmd_buf[CMD_BUF_SIZE] = { TMP101_ADDR, TMP_REG_TEMPERATURE, (TMP101_ADDR | I2C_READ_BIT), }; char ctrl_buf[CMD_BUF_SIZE] = { I2C_CONT, I2C_DO_REPEATED_START, I2C_CONT, }; - if (probe_sensor() != 1) { + if (tmp101_probe_sensor() != 1) { return -ENODEV; } @@ -130,7 +130,7 @@ int temp_read(uint16_t* raw, int* deci_degrees) *raw = byte_swap_16(temp); } if (deci_degrees != NULL) { - *deci_degrees = convert_to_deci_degrees(byte_swap_16(temp)); + *deci_degrees = tmp101_convert_to_deci_degrees(byte_swap_16(temp)); } return 0; } @@ -155,12 +155,12 @@ int temp_read(uint16_t* raw, int* deci_degrees) */ static uint8_t actual_config = 0; #define CONF_BUF_SIZE 4 -int sensor_config(uint32_t resolution) +int tmp101_sensor_config(uint32_t resolution) { int ret = 0; char cmd[CONF_BUF_SIZE] = { TMP101_ADDR, TMP_REG_CONFIG, }; - if (probe_sensor() != 1) { + if (tmp101_probe_sensor() != 1) { return -ENODEV; } @@ -177,12 +177,12 @@ int sensor_config(uint32_t resolution) } /* Start a conversion when the sensor is in shutdown mode. */ -int sensor_start_conversion(void) +int tmp101_sensor_start_conversion(void) { int ret = 0; char cmd[CONF_BUF_SIZE] = { TMP101_ADDR, TMP_REG_CONFIG, }; - if (probe_sensor() != 1) { + if (tmp101_probe_sensor() != 1) { return -ENODEV; } diff --git a/include/drivers/temp.h b/include/drivers/tmp101_temp_sensor.h similarity index 94% rename from include/drivers/temp.h rename to include/drivers/tmp101_temp_sensor.h index 10fd4ea..a3f4369 100644 --- a/include/drivers/temp.h +++ b/include/drivers/tmp101_temp_sensor.h @@ -51,7 +51,7 @@ /* Check the sensor presence, return 1 if found * This is a basic check, it could be anything with the same address ... */ -int probe_sensor(void); +int tmp101_probe_sensor(void); /* Convert raw temperature data (expressed as signed value of 16 times the @@ -59,7 +59,7 @@ int probe_sensor(void); * into a decimal interger value of ten times the actual temperature. * The value returned is thus in tenth of degrees centigrade. */ -int convert_to_deci_degrees(uint16_t raw); +int tmp101_convert_to_deci_degrees(uint16_t raw); /* Temp Read @@ -75,7 +75,7 @@ int convert_to_deci_degrees(uint16_t raw); * -EREMOTEIO : Device did not acknowledge : Any device present ? * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine */ -int temp_read(uint16_t* raw, int* deci_degrees); +int tmp101_sensor_read(uint16_t* raw, int* deci_degrees); /* Sensor config @@ -93,10 +93,10 @@ int temp_read(uint16_t* raw, int* deci_degrees); * -EREMOTEIO : Device did not acknowledge : Any device present ? * -EIO : Bad one: Illegal start or stop, or illegal state in i2c state machine */ -int sensor_config(uint32_t resolution); +int tmp101_sensor_config(uint32_t resolution); /* Start a conversion when the sensor is in shutdown mode. */ -int sensor_start_conversion(void); +int tmp101_sensor_start_conversion(void); #endif /* DRIVERS_TEMP_H */ -- 2.43.0