Minor changes in CCS811 driver (#542)
This commit is contained in:
parent
37230b2de6
commit
8325bb87c5
3 changed files with 11 additions and 3 deletions
|
@ -174,5 +174,7 @@ void user_init(void)
|
||||||
// start periodic measurement with one measurement per second
|
// start periodic measurement with one measurement per second
|
||||||
ccs811_set_mode (sensor, ccs811_mode_1s);
|
ccs811_set_mode (sensor, ccs811_mode_1s);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
printf("Could not initialize the CCS811 sensor\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,12 +305,14 @@ ccs811_set_mode (sensor, ccs811_mode_1s);
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
Last, the user task that uses the sensor has to be created.
|
Finally, a user task that uses the sensor has to be created.
|
||||||
|
|
||||||
```
|
```
|
||||||
xTaskCreate(user_task, "user_task", 256, NULL, 2, 0);
|
xTaskCreate(user_task, "user_task", 256, NULL, 2, 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Please note:** To avoid concurrency situations when driver functions are used to access the sensor, for example to read data, the user task must not be created until the sensor configuration is completed.
|
||||||
|
|
||||||
The user task can use different approaches to fetch new data. Either new data are fetched periodically or the interrupt signal *nINT* is used when new data are available or eCO2 value exceeds defined thresholds.
|
The user task can use different approaches to fetch new data. Either new data are fetched periodically or the interrupt signal *nINT* is used when new data are available or eCO2 value exceeds defined thresholds.
|
||||||
|
|
||||||
If new data are fetched **periodically** the implementation of the user task is quite simply and could look like following.
|
If new data are fetched **periodically** the implementation of the user task is quite simply and could look like following.
|
||||||
|
@ -564,6 +566,8 @@ void user_init(void)
|
||||||
// start periodic measurement with one measurement per second
|
// start periodic measurement with one measurement per second
|
||||||
ccs811_set_mode (sensor, ccs811_mode_1s);
|
ccs811_set_mode (sensor, ccs811_mode_1s);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
printf("Could not initialize CCS811 sensor\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -494,7 +494,8 @@ static bool ccs811_reg_read(ccs811_sensor_t* dev, uint8_t reg, uint8_t *data, ui
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef CCS811_DEBUG_LEVEL_2
|
# ifdef CCS811_DEBUG_LEVEL_2
|
||||||
printf("CCS811 %s: Read following bytes: ", __FUNCTION__);
|
printf("CCS811 %s: bus %d, addr %02x - Read following bytes: ",
|
||||||
|
__FUNCTION__, dev->bus, dev->addr);
|
||||||
printf("%0x: ", reg);
|
printf("%0x: ", reg);
|
||||||
for (int i=0; i < len; i++)
|
for (int i=0; i < len; i++)
|
||||||
printf("%0x ", data[i]);
|
printf("%0x ", data[i]);
|
||||||
|
@ -514,7 +515,8 @@ static bool ccs811_reg_write(ccs811_sensor_t* dev, uint8_t reg, uint8_t *data, u
|
||||||
# ifdef CCS811_DEBUG_LEVEL_2
|
# ifdef CCS811_DEBUG_LEVEL_2
|
||||||
if (data && len)
|
if (data && len)
|
||||||
{
|
{
|
||||||
printf("CCS811 %s: Write following bytes starting at reg addr %02x: ", __FUNCTION__, reg);
|
printf("CCS811 %s: bus %d, addr %02x - Write following bytes: ",
|
||||||
|
__FUNCTION__, dev->bus, dev->addr);
|
||||||
for (int i=0; i < len; i++)
|
for (int i=0; i < len; i++)
|
||||||
printf("%02x ", data[i]);
|
printf("%02x ", data[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
Loading…
Reference in a new issue