drivers/ccs811: nWAKE and nRESET moved to base
This commit is contained in:
parent
f03fb32f88
commit
3181a2faa7
@ -75,7 +75,6 @@ int ccs811_init(ccs811_t *dev, const ccs811_params_t *params)
|
|||||||
|
|
||||||
int res = CCS811_OK;
|
int res = CCS811_OK;
|
||||||
|
|
||||||
#if MODULE_CCS811_FULL
|
|
||||||
if (dev->params.reset_pin != GPIO_UNDEF &&
|
if (dev->params.reset_pin != GPIO_UNDEF &&
|
||||||
gpio_init(dev->params.reset_pin, GPIO_OUT) == 0) {
|
gpio_init(dev->params.reset_pin, GPIO_OUT) == 0) {
|
||||||
DEBUG_DEV("nRESET pin configured", dev);
|
DEBUG_DEV("nRESET pin configured", dev);
|
||||||
@ -88,20 +87,12 @@ int ccs811_init(ccs811_t *dev, const ccs811_params_t *params)
|
|||||||
/* t_START after reset is 1 ms, we wait 1 further ms */
|
/* t_START after reset is 1 ms, we wait 1 further ms */
|
||||||
xtimer_usleep(1000);
|
xtimer_usleep(1000);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
dev->params.reset_pin = GPIO_UNDEF;
|
|
||||||
DEBUG_DEV("nRESET pin not configured or could not be used", dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev->params.wake_pin != GPIO_UNDEF &&
|
if (dev->params.wake_pin != GPIO_UNDEF &&
|
||||||
gpio_init(dev->params.wake_pin, GPIO_OUT) == 0) {
|
gpio_init(dev->params.wake_pin, GPIO_OUT) == 0) {
|
||||||
|
gpio_clear(dev->params.wake_pin);
|
||||||
DEBUG_DEV("nWAKE pin configured", dev);
|
DEBUG_DEV("nWAKE pin configured", dev);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
dev->params.wake_pin = GPIO_UNDEF;
|
|
||||||
DEBUG_DEV("nWAKE pin not configured or could not be used", dev);
|
|
||||||
}
|
|
||||||
#endif /* MODULE_CCS811_FULL */
|
|
||||||
|
|
||||||
/* check whether sensor is available including the check of the hardware id */
|
/* check whether sensor is available including the check of the hardware id */
|
||||||
if ((res = _is_available(dev)) != CCS811_OK) {
|
if ((res = _is_available(dev)) != CCS811_OK) {
|
||||||
@ -370,14 +361,15 @@ int ccs811_power_down (ccs811_t *dev)
|
|||||||
{
|
{
|
||||||
ASSERT_PARAM(dev != NULL);
|
ASSERT_PARAM(dev != NULL);
|
||||||
|
|
||||||
if (dev->params.wake_pin == GPIO_UNDEF) {
|
|
||||||
DEBUG_DEV("nWAKE signal pin not configured", dev);
|
|
||||||
return CCS811_ERROR_NO_WAKE_PIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccs811_mode_t tmp_mode = dev->params.mode;
|
ccs811_mode_t tmp_mode = dev->params.mode;
|
||||||
int res = ccs811_set_mode(dev, CCS811_MODE_IDLE);
|
int res = ccs811_set_mode(dev, CCS811_MODE_IDLE);
|
||||||
dev->params.mode = tmp_mode;
|
dev->params.mode = tmp_mode;
|
||||||
|
|
||||||
|
if (dev->params.wake_pin != GPIO_UNDEF) {
|
||||||
|
DEBUG_DEV("Setting nWAKE pin high", dev);
|
||||||
|
gpio_set(dev->params.wake_pin);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,9 +377,9 @@ int ccs811_power_up (ccs811_t *dev)
|
|||||||
{
|
{
|
||||||
ASSERT_PARAM(dev != NULL);
|
ASSERT_PARAM(dev != NULL);
|
||||||
|
|
||||||
if (dev->params.wake_pin == GPIO_UNDEF) {
|
if (dev->params.wake_pin != GPIO_UNDEF) {
|
||||||
DEBUG_DEV("nWAKE signal pin not configured", dev);
|
DEBUG_DEV("Setting nWAKE pin low", dev);
|
||||||
return CCS811_ERROR_NO_WAKE_PIN;
|
gpio_clear(dev->params.wake_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ccs811_set_mode(dev, dev->params.mode);
|
return ccs811_set_mode(dev, dev->params.mode);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ The driver is for the usage with [RIOT-OS](https://github.com/RIOT-OS/RIOT).
|
|||||||
1. [Hardware Configurations](#hardware_configuration)
|
1. [Hardware Configurations](#hardware_configuration)
|
||||||
2. [Driver Configuration Parameters](#driver_configuration)
|
2. [Driver Configuration Parameters](#driver_configuration)
|
||||||
|
|
||||||
### <a name="overview"> Overview </a> [[TOC](#toc)]
|
## <a name="overview"> Overview </a> [[TOC](#toc)]
|
||||||
|
|
||||||
### <a name="about"> About the sensor </a> [[TOC](#toc)]
|
### <a name="about"> About the sensor </a> [[TOC](#toc)]
|
||||||
|
|
||||||
@ -68,9 +68,9 @@ and ```ccs811_full``` are used.
|
|||||||
Feature | Module
|
Feature | Module
|
||||||
--------|-------
|
--------|-------
|
||||||
read raw and converted gas sensor data (eCO2, TVOC) | ```ccs811```
|
read raw and converted gas sensor data (eCO2, TVOC) | ```ccs811```
|
||||||
test for new sensor gas data | ```ccs811```
|
poling for new sensor gas data | ```ccs811```
|
||||||
|
power saving using sleep mode with wakeup | ```ccs811```
|
||||||
data ready and threshold interrupt handling | ```ccs811_full```
|
data ready and threshold interrupt handling | ```ccs811_full```
|
||||||
power saving using sleep mode with wakeup | ```ccs811_full```
|
|
||||||
ambient temperatur calculation with NTC | ```ccs811_full```
|
ambient temperatur calculation with NTC | ```ccs811_full```
|
||||||
compensate gas readings using an external sensor | ```ccs811_full```
|
compensate gas readings using an external sensor | ```ccs811_full```
|
||||||
manual baseline handling | ```ccs811_full```
|
manual baseline handling | ```ccs811_full```
|
||||||
@ -304,29 +304,31 @@ ccs811_set_int_mode (&sensor, CCS811_INT_THRESHOLD);
|
|||||||
|
|
||||||
## <a name="power saving"> Power Saving </a> [[TOC](#toc)]
|
## <a name="power saving"> Power Saving </a> [[TOC](#toc)]
|
||||||
|
|
||||||
The CCS811 offers a sleep mode with wake-up function. By using the active
|
The CCS811 offers a **sleep mode** with **wake-up** function. By using the
|
||||||
low **nWAKE** signal connected to a GPIO, power can be saved. If the
|
active low **nWAKE** signal connected to a GPIO, power can be saved. If the
|
||||||
**nWAKE** signal is low, the CCS811 is active and can communicate over
|
**nWAKE** signal is low, the CCS811 is active and can communicate over
|
||||||
I2C. When this signal is high, the CCS811 goes into sleep mode and can
|
I2C. When this signal is high, the CCS811 goes into sleep mode and can't
|
||||||
be reached via I2C. The measuring process is not affected.
|
be reached via I2C. The measuring process is not affected.
|
||||||
|
|
||||||
The driver supports this feature when the **nWAKE** signal pin
|
The driver supports this feature when the **nWAKE** signal pin
|
||||||
(#ccs811_params_t::wake_pin) is configured, see the
|
(#ccs811_params_t::wake_pin) is configured, see the
|
||||||
[Configuration](#Configuration) section.
|
[Configuration](#Configuration) section.
|
||||||
|
|
||||||
@note This feature can only be used with the ```ccs811_full``` module.
|
@note If the **nWAKE** signal pin is not used, it must be permanently pulled
|
||||||
|
down. Sleep mode/wake-up feature can not be used in this case.
|
||||||
|
|
||||||
With the function #ccs811_power_down the CCS811 can be disabled, when
|
Additionally, CCS811 can be disabled with the #ccs811_power_down function
|
||||||
no measurements are required. To re-enable the CCS811 in the previous
|
function, when no measurements are required. For that purpose, the sensor is
|
||||||
measurement mode, the #ccs811_power_up function can be used.
|
switched to the idle, low current mode (#CCS811_MODE_IDLE).
|
||||||
|
To reactivate the CCS811 in the previous measurement mode, the
|
||||||
|
#ccs811_power_up function has to be used.
|
||||||
|
|
||||||
@note It may take several minutes before accurate readings are
|
@note It may take several minutes before accurate readings are
|
||||||
generated when the sensor switches back from idle mode to the
|
generated when the sensor switches back from idle mode to the
|
||||||
previous measurement mode.
|
previous measurement mode.
|
||||||
|
Therefore, the best power-saving solution is to leave the sensor in any
|
||||||
The best power-saving solution in measurement modes is the use of the
|
measurement mode and to use it with data-ready interrupt
|
||||||
data-ready interrupt (#CCS811_INT_DATA_READY) in conjunction with
|
(#CCS811_INT_DATA_READY) in conjunction with the **nWAKE** signal pin.
|
||||||
the **nWAKE** signal as supported by the driver.
|
|
||||||
|
|
||||||
## <a name="baseline"> Baseline </a> [[TOC](#toc)]
|
## <a name="baseline"> Baseline </a> [[TOC](#toc)]
|
||||||
|
|
||||||
@ -378,7 +380,6 @@ the interrupt pin has to be connected to a GPIO pin.
|
|||||||
```
|
```
|
||||||
|
|
||||||
To use the hardware reset and/or the sleep mode with wake-up feature,
|
To use the hardware reset and/or the sleep mode with wake-up feature,
|
||||||
(only with ```ccs811_full``` module),
|
|
||||||
additional GPIOs have to be used. This is the most energy-efficient
|
additional GPIOs have to be used. This is the most energy-efficient
|
||||||
hardware configuration of the sensor but requires more GPIO pins.
|
hardware configuration of the sensor but requires more GPIO pins.
|
||||||
Used GPIOs must be configured accordingly in driver [configuration
|
Used GPIOs must be configured accordingly in driver [configuration
|
||||||
|
|||||||
@ -52,6 +52,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CCS811_PARAMS
|
#ifndef CCS811_PARAMS
|
||||||
|
#ifdef MODULE_CCS811_FULL
|
||||||
#define CCS811_PARAMS { .i2c_dev = CCS811_PARAM_I2C_DEV, \
|
#define CCS811_PARAMS { .i2c_dev = CCS811_PARAM_I2C_DEV, \
|
||||||
.i2c_addr = CCS811_PARAM_I2C_ADDR, \
|
.i2c_addr = CCS811_PARAM_I2C_ADDR, \
|
||||||
.mode = CCS811_PARAM_MODE, \
|
.mode = CCS811_PARAM_MODE, \
|
||||||
@ -60,6 +61,14 @@ extern "C" {
|
|||||||
.wake_pin = CCS811_PARAM_WAKE_PIN, \
|
.wake_pin = CCS811_PARAM_WAKE_PIN, \
|
||||||
.reset_pin = CCS811_PARAM_RESET_PIN \
|
.reset_pin = CCS811_PARAM_RESET_PIN \
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define CCS811_PARAMS { .i2c_dev = CCS811_PARAM_I2C_DEV, \
|
||||||
|
.i2c_addr = CCS811_PARAM_I2C_ADDR, \
|
||||||
|
.mode = CCS811_PARAM_MODE, \
|
||||||
|
.wake_pin = CCS811_PARAM_WAKE_PIN, \
|
||||||
|
.reset_pin = CCS811_PARAM_RESET_PIN \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef CCS811_SAUL_INFO
|
#ifndef CCS811_SAUL_INFO
|
||||||
#define CCS811_SAUL_INFO { .name = "ccs811" }
|
#define CCS811_SAUL_INFO { .name = "ccs811" }
|
||||||
|
|||||||
@ -94,13 +94,13 @@ typedef struct {
|
|||||||
|
|
||||||
i2c_t i2c_dev; /**< I2C device, clock stretching required (default I2C_DEV(0)) */
|
i2c_t i2c_dev; /**< I2C device, clock stretching required (default I2C_DEV(0)) */
|
||||||
uint8_t i2c_addr; /**< I2C address (default CCS811_I2C_ADDRESS_1) */
|
uint8_t i2c_addr; /**< I2C address (default CCS811_I2C_ADDRESS_1) */
|
||||||
|
ccs811_mode_t mode; /**< measurement mode used (default #CCS811_MODE_IDLE) */
|
||||||
|
#if MODULE_CCS811_FULL || DOXYGEN
|
||||||
gpio_t int_pin; /**< nINT signal pin (default GPIO_PIN(0, 0) */
|
gpio_t int_pin; /**< nINT signal pin (default GPIO_PIN(0, 0) */
|
||||||
|
ccs811_int_mode_t int_mode; /**< interrupt mode used (default #CCS811_INT_NONE) */
|
||||||
|
#endif
|
||||||
gpio_t wake_pin; /**< nWAKE signal pin (default GPIO_UNDEF) */
|
gpio_t wake_pin; /**< nWAKE signal pin (default GPIO_UNDEF) */
|
||||||
gpio_t reset_pin; /**< nRESET signal pin (default GPIO_UNDEF) */
|
gpio_t reset_pin; /**< nRESET signal pin (default GPIO_UNDEF) */
|
||||||
|
|
||||||
ccs811_mode_t mode; /**< measurement mode used (default #CCS811_MODE_IDLE) */
|
|
||||||
ccs811_int_mode_t int_mode; /**< interrupt mode used (default #CCS811_INT_NONE) */
|
|
||||||
} ccs811_params_t;
|
} ccs811_params_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user