diff --git a/drivers/sensor/ccs811/Kconfig b/drivers/sensor/ccs811/Kconfig index 57b49c9cabd..5f33f1cef39 100644 --- a/drivers/sensor/ccs811/Kconfig +++ b/drivers/sensor/ccs811/Kconfig @@ -71,3 +71,20 @@ config CCS811_GPIO_WAKEUP_PIN_NUM help The number of the GPIO pin on which the WAKE pin of CCS811 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 diff --git a/drivers/sensor/ccs811/ccs811.c b/drivers/sensor/ccs811/ccs811.c index 6b3cbb13e5c..45c49e6e2f3 100644 --- a/drivers/sensor/ccs811/ccs811.c +++ b/drivers/sensor/ccs811/ccs811.c @@ -162,18 +162,28 @@ int ccs811_init(struct device *dev) return -EINVAL; } - /* - * 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 +#if defined(CONFIG_CCS811_GPIO_WAKEUP) || defined(CONFIG_CCS811_GPIO_RESET) drv_data->gpio = device_get_binding(CONFIG_CCS811_GPIO_DEV_NAME); if (drv_data->gpio == NULL) { SYS_LOG_ERR("Failed to get pointer to %s device!", CONFIG_CCS811_GPIO_DEV_NAME); 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_DIR_OUT); gpio_pin_write(drv_data->gpio, CONFIG_CCS811_GPIO_WAKEUP_PIN_NUM, 0);