Skip to content
Permalink
Browse files

sensors: renamed hdc1008 driver into ti_hdc

Hdc1008 driver is renamed into ti_hdc to prepare it to support all
available Texas Instruments HDC sensors (e.g. hdc1080, hdc2080).

Signed-off-by: Nikos Oikonomou <nikoikonomou92@gmail.com>
  • Loading branch information...
nikooiko authored and MaureenHelm committed Feb 12, 2019
1 parent 8e2b9b4 commit 4a38cae2af5dc89aafe2ce19540e8822f2c52d23
@@ -94,8 +94,8 @@
int2-gpios = <&gpio0 25 0>;
};

hdc1008@43 {
compatible = "ti,hdc1008","ti,hdc1010";
ti_hdc@43 {
compatible = "ti,hdc","ti,hdc1010";
reg = <0x43>;
label = "HDC1010";
drdy-gpios = <&gpio0 22 GPIO_PUD_PULL_UP>;
@@ -20,7 +20,7 @@ add_subdirectory_ifdef(CONFIG_ENS210 ens210)
add_subdirectory_ifdef(CONFIG_FXAS21002 fxas21002)
add_subdirectory_ifdef(CONFIG_FXOS8700 fxos8700)
add_subdirectory(grove)
add_subdirectory_ifdef(CONFIG_HDC1008 hdc1008)
add_subdirectory_ifdef(CONFIG_TI_HDC ti_hdc)
add_subdirectory_ifdef(CONFIG_HMC5883L hmc5883l)
add_subdirectory_ifdef(CONFIG_HP206C hp206c)
add_subdirectory_ifdef(CONFIG_HTS221 hts221)
@@ -65,7 +65,7 @@ source "drivers/sensor/fxos8700/Kconfig"

source "drivers/sensor/grove/Kconfig"

source "drivers/sensor/hdc1008/Kconfig"
source "drivers/sensor/ti_hdc/Kconfig"

source "drivers/sensor/hmc5883l/Kconfig"

This file was deleted.

This file was deleted.

@@ -2,4 +2,4 @@

zephyr_library()

zephyr_library_sources_ifdef(CONFIG_HDC1008 hdc1008.c)
zephyr_library_sources_ifdef(CONFIG_TI_HDC ti_hdc.c)
@@ -0,0 +1,13 @@
# Kconfig - TI_HDC temperature and humidity sensor configuration options

#
# Copyright (c) 2016 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#

menuconfig TI_HDC
bool "Texas Instruments Temperature and Humidity Sensor (e.g. HDC1008)"
depends on I2C && HAS_DTS_I2C && GPIO && HAS_DTS_GPIO
help
Enable driver for TI temperature and humidity sensors.
@@ -13,43 +13,43 @@
#include <misc/__assert.h>
#include <logging/log.h>

#include "hdc1008.h"
#include "ti_hdc.h"

#define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL
LOG_MODULE_REGISTER(HDC1008);
LOG_MODULE_REGISTER(TI_HDC);

static void hdc1008_gpio_callback(struct device *dev,
static void ti_hdc_gpio_callback(struct device *dev,
struct gpio_callback *cb, u32_t pins)
{
struct hdc1008_data *drv_data =
CONTAINER_OF(cb, struct hdc1008_data, gpio_cb);
struct ti_hdc_data *drv_data =
CONTAINER_OF(cb, struct ti_hdc_data, gpio_cb);

ARG_UNUSED(pins);

gpio_pin_disable_callback(dev, DT_TI_HDC1008_0_DRDY_GPIOS_PIN);
gpio_pin_disable_callback(dev, DT_TI_HDC_0_DRDY_GPIOS_PIN);
k_sem_give(&drv_data->data_sem);
}

static int hdc1008_sample_fetch(struct device *dev, enum sensor_channel chan)
static int ti_hdc_sample_fetch(struct device *dev, enum sensor_channel chan)
{
struct hdc1008_data *drv_data = dev->driver_data;
struct ti_hdc_data *drv_data = dev->driver_data;
u8_t buf[4];

__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL);

gpio_pin_enable_callback(drv_data->gpio,
DT_TI_HDC1008_0_DRDY_GPIOS_PIN);
DT_TI_HDC_0_DRDY_GPIOS_PIN);

buf[0] = HDC1008_REG_TEMP;
buf[0] = TI_HDC_REG_TEMP;
if (i2c_write(drv_data->i2c, buf, 1,
DT_TI_HDC1008_0_BASE_ADDRESS) < 0) {
DT_TI_HDC_0_BASE_ADDRESS) < 0) {
LOG_DBG("Failed to write address pointer");
return -EIO;
}

k_sem_take(&drv_data->data_sem, K_FOREVER);

if (i2c_read(drv_data->i2c, buf, 4, DT_TI_HDC1008_0_BASE_ADDRESS) < 0) {
if (i2c_read(drv_data->i2c, buf, 4, DT_TI_HDC_0_BASE_ADDRESS) < 0) {
LOG_DBG("Failed to read sample data");
return -EIO;
}
@@ -61,11 +61,11 @@ static int hdc1008_sample_fetch(struct device *dev, enum sensor_channel chan)
}


static int hdc1008_channel_get(struct device *dev,
static int ti_hdc_channel_get(struct device *dev,
enum sensor_channel chan,
struct sensor_value *val)
{
struct hdc1008_data *drv_data = dev->driver_data;
struct ti_hdc_data *drv_data = dev->driver_data;
u64_t tmp;

/*
@@ -92,9 +92,9 @@ static int hdc1008_channel_get(struct device *dev,
return 0;
}

static const struct sensor_driver_api hdc1008_driver_api = {
.sample_fetch = hdc1008_sample_fetch,
.channel_get = hdc1008_channel_get,
static const struct sensor_driver_api ti_hdc_driver_api = {
.sample_fetch = ti_hdc_sample_fetch,
.channel_get = ti_hdc_channel_get,
};

static u16_t read16(struct device *dev, u8_t a, u8_t d)
@@ -106,25 +106,25 @@ static u16_t read16(struct device *dev, u8_t a, u8_t d)
return (buf[0] << 8 | buf[1]);
}

static int hdc1008_init(struct device *dev)
static int ti_hdc_init(struct device *dev)
{
struct hdc1008_data *drv_data = dev->driver_data;
struct ti_hdc_data *drv_data = dev->driver_data;

drv_data->i2c = device_get_binding(DT_TI_HDC1008_0_BUS_NAME);
drv_data->i2c = device_get_binding(DT_TI_HDC_0_BUS_NAME);

if (drv_data->i2c == NULL) {
LOG_DBG("Failed to get pointer to %s device!",
DT_TI_HDC1008_0_BUS_NAME);
DT_TI_HDC_0_BUS_NAME);
return -EINVAL;
}

if (read16(drv_data->i2c, DT_TI_HDC1008_0_BASE_ADDRESS,
HDC1008_REG_MANUFID) != HDC1008_MANUFID) {
if (read16(drv_data->i2c, DT_TI_HDC_0_BASE_ADDRESS,
TI_HDC_REG_MANUFID) != TI_HDC_MANUFID) {
LOG_ERR("Failed to get correct manufacturer ID");
return -EINVAL;
}
if (read16(drv_data->i2c, DT_TI_HDC1008_0_BASE_ADDRESS,
HDC1008_REG_DEVICEID) != HDC1008_DEVICEID) {
if (read16(drv_data->i2c, DT_TI_HDC_0_BASE_ADDRESS,
TI_HDC_REG_DEVICEID) != TI_HDC_DEVICEID) {
LOG_ERR("Failed to get correct device ID");
return -EINVAL;
}
@@ -133,23 +133,23 @@ static int hdc1008_init(struct device *dev)

/* setup data ready gpio interrupt */
drv_data->gpio = device_get_binding(
DT_TI_HDC1008_0_DRDY_GPIOS_CONTROLLER);
DT_TI_HDC_0_DRDY_GPIOS_CONTROLLER);
if (drv_data->gpio == NULL) {
LOG_DBG("Failed to get pointer to %s device",
DT_TI_HDC1008_0_DRDY_GPIOS_CONTROLLER);
DT_TI_HDC_0_DRDY_GPIOS_CONTROLLER);
return -EINVAL;
}

gpio_pin_configure(drv_data->gpio, DT_TI_HDC1008_0_DRDY_GPIOS_PIN,
gpio_pin_configure(drv_data->gpio, DT_TI_HDC_0_DRDY_GPIOS_PIN,
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
#if defined(DT_TI_HDC1008_0_DRDY_GPIOS_FLAGS)
DT_TI_HDC1008_0_DRDY_GPIOS_FLAGS |
#if defined(DT_TI_HDC_0_DRDY_GPIOS_FLAGS)
DT_TI_HDC_0_DRDY_GPIOS_FLAGS |
#endif
GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE);

gpio_init_callback(&drv_data->gpio_cb,
hdc1008_gpio_callback,
BIT(DT_TI_HDC1008_0_DRDY_GPIOS_PIN));
ti_hdc_gpio_callback,
BIT(DT_TI_HDC_0_DRDY_GPIOS_PIN));

if (gpio_add_callback(drv_data->gpio, &drv_data->gpio_cb) < 0) {
LOG_DBG("Failed to set GPIO callback");
@@ -159,8 +159,8 @@ static int hdc1008_init(struct device *dev)
return 0;
}

static struct hdc1008_data hdc1008_data;
static struct ti_hdc_data ti_hdc_data;

DEVICE_AND_API_INIT(hdc1008, DT_TI_HDC1008_0_LABEL, hdc1008_init, &hdc1008_data,
DEVICE_AND_API_INIT(ti_hdc, DT_TI_HDC_0_LABEL, ti_hdc_init, &ti_hdc_data,
NULL, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
&hdc1008_driver_api);
&ti_hdc_driver_api);
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_DRIVERS_SENSOR_TI_HDC_TI_HDC_H_
#define ZEPHYR_DRIVERS_SENSOR_TI_HDC_TI_HDC_H_

#include <kernel.h>

#define TI_HDC_I2C_ADDRESS 0x40

#define TI_HDC_REG_TEMP 0x0
#define TI_HDC_REG_HUMIDITY 0x1
#define TI_HDC_REG_MANUFID 0xFE
#define TI_HDC_REG_DEVICEID 0xFF

#define TI_HDC_MANUFID 0x5449
#define TI_HDC_DEVICEID 0x1000

struct ti_hdc_data {
struct device *i2c;
struct device *gpio;
struct gpio_callback gpio_cb;
u16_t t_sample;
u16_t rh_sample;
struct k_sem data_sem;
};

#endif
@@ -4,18 +4,18 @@
# SPDX-License-Identifier: Apache-2.0
#
---
title: HDC1008 Temperature and Humidity Sensor
title: Texas Instruments Temperature and Humidity Sensor
version: 0.1

description: >
This is a representation of the HDC1008 Temperature and Humidity sensor
This is a representation of the TI Temperature and Humidity sensor (e.g. HDC1008)
inherits:
!include i2c-device.yaml

properties:
compatible:
constraint: "ti,hdc1008"
constraint: "ti,hdc"

drdy-gpios:
type: compound
@@ -7,8 +7,8 @@

&i2c0 {

hdc1008: hdc1008@40 {
compatible = "ti,hdc1008";
ti_hdc: ti_hdc@40 {
compatible = "ti,hdc","ti,hdc1008";
reg = <0x40>;
label = "HDC1008";
drdy-gpios = <&gpio0 3 0>;
@@ -15,4 +15,4 @@ CONFIG_GROVE_LCD_RGB=y

# change these configs if you want to use different sensors
CONFIG_BME280=y
CONFIG_HDC1008=y
CONFIG_TI_HDC=y
@@ -50,7 +50,7 @@ CONFIG_SENSOR=y

CONFIG_APDS9960=y

CONFIG_HDC1008=y
CONFIG_TI_HDC=y

CONFIG_FXOS8700=y
CONFIG_FXOS8700_MODE_ACCEL=y

0 comments on commit 4a38cae

Please sign in to comment.
You can’t perform that action at this time.