drivers: sensor: Migrate to new logger

Move all sensor drivers and samples to new logging system.

Signed-off-by: Punit Vara <punit.vara@intel.com>
This commit is contained in:
Punit Vara 2018-10-10 12:08:54 +05:30 committed by Anas Nashif
commit e5620a2b87
129 changed files with 928 additions and 798 deletions

View file

@ -12,9 +12,13 @@
#include <misc/util.h>
#include <sensor.h>
#include <misc/__assert.h>
#include <logging/log.h>
#include "ccs811.h"
#define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL
LOG_MODULE_REGISTER(CCS811);
static int ccs811_sample_fetch(struct device *dev, enum sensor_channel chan)
{
struct ccs811_data *drv_data = dev->driver_data;
@ -26,7 +30,7 @@ static int ccs811_sample_fetch(struct device *dev, enum sensor_channel chan)
while (tries-- > 0) {
if (i2c_reg_read_byte(drv_data->i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_STATUS, &status) < 0) {
SYS_LOG_ERR("Failed to read Status register");
LOG_ERR("Failed to read Status register");
return -EIO;
}
@ -38,13 +42,13 @@ static int ccs811_sample_fetch(struct device *dev, enum sensor_channel chan)
}
if (!(status & CCS811_STATUS_DATA_READY)) {
SYS_LOG_ERR("Sensor data not available");
LOG_ERR("Sensor data not available");
return -EIO;
}
if (i2c_burst_read(drv_data->i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_ALG_RESULT_DATA, (u8_t *)buf, 8) < 0) {
SYS_LOG_ERR("Failed to read conversion data.");
LOG_ERR("Failed to read conversion data.");
return -EIO;
}
@ -111,40 +115,40 @@ static int switch_to_app_mode(struct device *i2c)
{
u8_t status, buf;
SYS_LOG_DBG("Switching to Application mode...");
LOG_DBG("Switching to Application mode...");
if (i2c_reg_read_byte(i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_STATUS, &status) < 0) {
SYS_LOG_ERR("Failed to read Status register");
LOG_ERR("Failed to read Status register");
return -EIO;
}
/* Check for the application firmware */
if (!(status & CCS811_STATUS_APP_VALID)) {
SYS_LOG_ERR("No Application firmware loaded");
LOG_ERR("No Application firmware loaded");
return -EINVAL;
}
buf = CCS811_REG_APP_START;
/* Set the device to application mode */
if (i2c_write(i2c, &buf, 1, CONFIG_CCS811_I2C_ADDR) < 0) {
SYS_LOG_ERR("Failed to set Application mode");
LOG_ERR("Failed to set Application mode");
return -EIO;
}
if (i2c_reg_read_byte(i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_STATUS, &status) < 0) {
SYS_LOG_ERR("Failed to read Status register");
LOG_ERR("Failed to read Status register");
return -EIO;
}
/* Check for application mode */
if (!(status & CCS811_STATUS_FW_MODE)) {
SYS_LOG_ERR("Failed to start Application firmware");
LOG_ERR("Failed to start Application firmware");
return -EINVAL;
}
SYS_LOG_DBG("CCS811 Application firmware started!");
LOG_DBG("CCS811 Application firmware started!");
return 0;
}
@ -157,7 +161,7 @@ int ccs811_init(struct device *dev)
drv_data->i2c = device_get_binding(CONFIG_CCS811_I2C_MASTER_DEV_NAME);
if (drv_data->i2c == NULL) {
SYS_LOG_ERR("Failed to get pointer to %s device!",
LOG_ERR("Failed to get pointer to %s device!",
CONFIG_CCS811_I2C_MASTER_DEV_NAME);
return -EINVAL;
}
@ -165,7 +169,7 @@ int ccs811_init(struct device *dev)
#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!",
LOG_ERR("Failed to get pointer to %s device!",
CONFIG_CCS811_GPIO_DEV_NAME);
return -EINVAL;
}
@ -200,12 +204,12 @@ int ccs811_init(struct device *dev)
/* Check Hardware ID */
if (i2c_reg_read_byte(drv_data->i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_HW_ID, &hw_id) < 0) {
SYS_LOG_ERR("Failed to read Hardware ID register");
LOG_ERR("Failed to read Hardware ID register");
return -EIO;
}
if (hw_id != CCS881_HW_ID) {
SYS_LOG_ERR("Hardware ID mismatch!");
LOG_ERR("Hardware ID mismatch!");
return -EINVAL;
}
@ -213,19 +217,19 @@ int ccs811_init(struct device *dev)
if (i2c_reg_write_byte(drv_data->i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_MEAS_MODE,
CCS811_MODE_IAQ_1SEC) < 0) {
SYS_LOG_ERR("Failed to set Measurement mode");
LOG_ERR("Failed to set Measurement mode");
return -EIO;
}
/* Check for error */
if (i2c_reg_read_byte(drv_data->i2c, CONFIG_CCS811_I2C_ADDR,
CCS811_REG_STATUS, &status) < 0) {
SYS_LOG_ERR("Failed to read Status register");
LOG_ERR("Failed to read Status register");
return -EIO;
}
if (status & CCS811_STATUS_ERROR) {
SYS_LOG_ERR("Error occurred during sensor configuration");
LOG_ERR("Error occurred during sensor configuration");
return -EINVAL;
}