sensors: ccs811: Deassert the reset pin with GPIO

The driver releases the sensor from reset in case the reset pin is
driven by a GPIO.

Signed-off-by: Aapo Vienamo <aapo.vienamo@iki.fi>
This commit is contained in:
Aapo Vienamo 2018-03-15 18:16:38 +02:00 committed by Kumar Gala
commit fbd3c2f4e2
2 changed files with 32 additions and 5 deletions

View file

@ -71,3 +71,20 @@ config CCS811_GPIO_WAKEUP_PIN_NUM
help help
The number of the GPIO pin on which the WAKE pin of CCS811 The number of the GPIO pin on which the WAKE pin of CCS811
is connected is connected
config CCS811_GPIO_RESET
bool
prompt "Enable GPIO Reset for CCS811"
default n
depends on CCS811
help
Enable GPIO Reset support for CCS811
config CCS811_GPIO_RESET_PIN_NUM
int
prompt "GPIO Reset pin number"
default 0
depends on CCS811 && CCS811_GPIO_RESET
help
The number of the GPIO pin on which the RESET pin of CCS811
is connected

View file

@ -162,18 +162,28 @@ int ccs811_init(struct device *dev)
return -EINVAL; return -EINVAL;
} }
/* #if defined(CONFIG_CCS811_GPIO_WAKEUP) || defined(CONFIG_CCS811_GPIO_RESET)
* Wakeup pin should be pulled low before initiating any I2C transfer.
* If it has been tied to GND by default, skip this part.
*/
#ifdef CONFIG_CCS811_GPIO_WAKEUP
drv_data->gpio = device_get_binding(CONFIG_CCS811_GPIO_DEV_NAME); drv_data->gpio = device_get_binding(CONFIG_CCS811_GPIO_DEV_NAME);
if (drv_data->gpio == NULL) { if (drv_data->gpio == NULL) {
SYS_LOG_ERR("Failed to get pointer to %s device!", SYS_LOG_ERR("Failed to get pointer to %s device!",
CONFIG_CCS811_GPIO_DEV_NAME); CONFIG_CCS811_GPIO_DEV_NAME);
return -EINVAL; return -EINVAL;
} }
#endif
#ifdef CONFIG_CCS811_GPIO_RESET
gpio_pin_configure(drv_data->gpio, CONFIG_CCS811_GPIO_RESET_PIN_NUM,
GPIO_DIR_OUT);
gpio_pin_write(drv_data->gpio, CONFIG_CCS811_GPIO_RESET_PIN_NUM, 1);
k_sleep(1);
#endif
/*
* Wakeup pin should be pulled low before initiating any I2C transfer.
* If it has been tied to GND by default, skip this part.
*/
#ifdef CONFIG_CCS811_GPIO_WAKEUP
gpio_pin_configure(drv_data->gpio, CONFIG_CCS811_GPIO_WAKEUP_PIN_NUM, gpio_pin_configure(drv_data->gpio, CONFIG_CCS811_GPIO_WAKEUP_PIN_NUM,
GPIO_DIR_OUT); GPIO_DIR_OUT);
gpio_pin_write(drv_data->gpio, CONFIG_CCS811_GPIO_WAKEUP_PIN_NUM, 0); gpio_pin_write(drv_data->gpio, CONFIG_CCS811_GPIO_WAKEUP_PIN_NUM, 0);