mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
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;
|
||||
|
||||
#if MODULE_CCS811_FULL
|
||||
if (dev->params.reset_pin != GPIO_UNDEF &&
|
||||
gpio_init(dev->params.reset_pin, GPIO_OUT) == 0) {
|
||||
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 */
|
||||
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 &&
|
||||
gpio_init(dev->params.wake_pin, GPIO_OUT) == 0) {
|
||||
gpio_clear(dev->params.wake_pin);
|
||||
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 */
|
||||
if ((res = _is_available(dev)) != CCS811_OK) {
|
||||
@ -370,14 +361,15 @@ int ccs811_power_down (ccs811_t *dev)
|
||||
{
|
||||
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;
|
||||
int res = ccs811_set_mode(dev, CCS811_MODE_IDLE);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -385,9 +377,9 @@ int ccs811_power_up (ccs811_t *dev)
|
||||
{
|
||||
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;
|
||||
if (dev->params.wake_pin != GPIO_UNDEF) {
|
||||
DEBUG_DEV("Setting nWAKE pin low", dev);
|
||||
gpio_clear(dev->params.wake_pin);
|
||||
}
|
||||
|
||||
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)
|
||||
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)]
|
||||
|
||||
@ -68,9 +68,9 @@ and ```ccs811_full``` are used.
|
||||
Feature | Module
|
||||
--------|-------
|
||||
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```
|
||||
power saving using sleep mode with wakeup | ```ccs811_full```
|
||||
ambient temperatur calculation with NTC | ```ccs811_full```
|
||||
compensate gas readings using an external sensor | ```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)]
|
||||
|
||||
The CCS811 offers a sleep mode with wake-up function. By using the active
|
||||
low **nWAKE** signal connected to a GPIO, power can be saved. If the
|
||||
The CCS811 offers a **sleep mode** with **wake-up** function. By using 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
|
||||
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.
|
||||
|
||||
The driver supports this feature when the **nWAKE** signal pin
|
||||
(#ccs811_params_t::wake_pin) is configured, see the
|
||||
[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
|
||||
no measurements are required. To re-enable the CCS811 in the previous
|
||||
measurement mode, the #ccs811_power_up function can be used.
|
||||
Additionally, CCS811 can be disabled with the #ccs811_power_down function
|
||||
function, when no measurements are required. For that purpose, the sensor is
|
||||
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
|
||||
generated when the sensor switches back from idle mode to the
|
||||
previous measurement mode.
|
||||
|
||||
The best power-saving solution in measurement modes is the use of the
|
||||
data-ready interrupt (#CCS811_INT_DATA_READY) in conjunction with
|
||||
the **nWAKE** signal as supported by the driver.
|
||||
Therefore, the best power-saving solution is to leave the sensor in any
|
||||
measurement mode and to use it with data-ready interrupt
|
||||
(#CCS811_INT_DATA_READY) in conjunction with the **nWAKE** signal pin.
|
||||
|
||||
## <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,
|
||||
(only with ```ccs811_full``` module),
|
||||
additional GPIOs have to be used. This is the most energy-efficient
|
||||
hardware configuration of the sensor but requires more GPIO pins.
|
||||
Used GPIOs must be configured accordingly in driver [configuration
|
||||
|
@ -52,6 +52,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef CCS811_PARAMS
|
||||
#ifdef MODULE_CCS811_FULL
|
||||
#define CCS811_PARAMS { .i2c_dev = CCS811_PARAM_I2C_DEV, \
|
||||
.i2c_addr = CCS811_PARAM_I2C_ADDR, \
|
||||
.mode = CCS811_PARAM_MODE, \
|
||||
@ -60,6 +61,14 @@ extern "C" {
|
||||
.wake_pin = CCS811_PARAM_WAKE_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
|
||||
#ifndef CCS811_SAUL_INFO
|
||||
#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)) */
|
||||
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) */
|
||||
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 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;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user