drivers/sensors: Run all sensor drivers through tools/nxstyle, correcting as many complaints as possible.
This commit is contained in:
parent
db6fe28fa6
commit
d1584d60a2
@ -347,6 +347,7 @@ static int adt7320_open(FAR struct file *filep)
|
||||
set_errno(ENODEV);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -264,11 +264,14 @@ static void adxl345_worker(FAR void *arg)
|
||||
/* Read accelerometer data to sample */
|
||||
|
||||
priv->sample.data_x = adxl345_getreg8(priv, ADXL345_DATAX1);
|
||||
priv->sample.data_x = (priv->sample.data_x << 8) | adxl345_getreg8(priv, ADXL345_DATAX0);
|
||||
priv->sample.data_x = (priv->sample.data_x << 8) |
|
||||
adxl345_getreg8(priv, ADXL345_DATAX0);
|
||||
priv->sample.data_y = adxl345_getreg8(priv, ADXL345_DATAY1);
|
||||
priv->sample.data_y = (priv->sample.data_y << 8) | adxl345_getreg8(priv, ADXL345_DATAY0);
|
||||
priv->sample.data_y = (priv->sample.data_y << 8) |
|
||||
adxl345_getreg8(priv, ADXL345_DATAY0);
|
||||
priv->sample.data_z = adxl345_getreg8(priv, ADXL345_DATAZ1);
|
||||
priv->sample.data_z = (priv->sample.data_z << 8) | adxl345_getreg8(priv, ADXL345_DATAZ0);
|
||||
priv->sample.data_z = (priv->sample.data_z << 8) |
|
||||
adxl345_getreg8(priv, ADXL345_DATAZ0);
|
||||
}
|
||||
|
||||
/* Re-enable the ADXL345 GPIO interrupt */
|
||||
|
@ -53,6 +53,10 @@
|
||||
|
||||
#if defined(CONFIG_SENSORS_ADXL345)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adxl345_getreg8
|
||||
*
|
||||
|
@ -271,6 +271,7 @@ static int ak09912_putreg8(FAR struct ak09912_dev_s *priv,
|
||||
{
|
||||
snerr("I2C_TRANSFER failed: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -283,7 +284,8 @@ static int ak09912_putreg8(FAR struct ak09912_dev_s *priv,
|
||||
****************************************************************************/
|
||||
|
||||
static int32_t ak09912_getreg(FAR struct ak09912_dev_s *priv,
|
||||
uint8_t regaddr, uint8_t* buffer, uint32_t cnt)
|
||||
uint8_t regaddr, FAR uint8_t *buffer,
|
||||
uint32_t cnt)
|
||||
{
|
||||
struct i2c_msg_s msg[2];
|
||||
int ret;
|
||||
@ -363,6 +365,7 @@ static int ak09912_read_sensitivity_data(FAR struct ak09912_dev_s* priv,
|
||||
asa_data->y = buffer[1];
|
||||
asa_data->z = buffer[2];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -425,6 +428,7 @@ static int ak09912_read_mag_uncomp_data(FAR struct ak09912_dev_s* priv,
|
||||
{
|
||||
sem_wait(&priv->wait);
|
||||
}
|
||||
|
||||
wd_cancel(priv->wd);
|
||||
ret = ak09912_getreg(priv, AK09912_HXL, buffer, sizeof(buffer));
|
||||
|
||||
@ -536,6 +540,7 @@ static int ak09912_open(FAR struct file *filep)
|
||||
snerr("Failed to set power mode to %d.\n", priv->mode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -559,6 +564,7 @@ static int ak09912_close(FAR struct file *filep)
|
||||
snerr("Failed to set power mode to %d.\n", AKM_POWER_DOWN_MODE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -572,7 +578,7 @@ static ssize_t ak09912_read(FAR struct file *filep, FAR char *buffer,
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct ak09912_dev_s *priv = inode->i_private;
|
||||
int32_t ret = 0;
|
||||
struct mag_data_s* mag_data = (struct mag_data_s*)buffer;
|
||||
FAR struct mag_data_s *mag_data = (FAR struct mag_data_s *)buffer;
|
||||
|
||||
if (! buffer)
|
||||
{
|
||||
|
@ -69,6 +69,7 @@ struct as5048b_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int as5048b_readu8(FAR struct as5048b_dev_s *priv, uint8_t regaddr,
|
||||
@ -168,7 +169,8 @@ static int as5048b_readu8(FAR struct as5048b_dev_s *priv, uint8_t regaddr,
|
||||
static int as5048b_readu16(FAR struct as5048b_dev_s *priv, uint8_t regaddrhi,
|
||||
uint8_t regaddrlo, FAR uint16_t *regval)
|
||||
{
|
||||
uint8_t hi, lo;
|
||||
uint8_t hi;
|
||||
uint8_t lo;
|
||||
int ret;
|
||||
|
||||
/* Read the high 8 bits of the 13-bit value */
|
||||
|
@ -268,6 +268,7 @@ static void write_register(FAR struct as726x_dev_s *priv, uint8_t addr,
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
int ret;
|
||||
|
||||
config.frequency = CONFIG_AS726X_I2C_FREQUENCY;
|
||||
|
@ -246,8 +246,8 @@ static ssize_t bh1750fvi_read(FAR struct file *filep, FAR char *buffer,
|
||||
return ret;
|
||||
}
|
||||
|
||||
buffer[0] = lux & 0xFF;
|
||||
buffer[1] = (lux & 0xFF00) >> 8;
|
||||
buffer[0] = lux & 0xff;
|
||||
buffer[1] = (lux & 0xff00) >> 8;
|
||||
|
||||
add_sensor_randomness(lux);
|
||||
|
||||
@ -357,7 +357,7 @@ static int bh1750fvi_ioctl(FAR struct file *filep, int cmd,
|
||||
uint8_t reg;
|
||||
DEBUGASSERT(ptr != NULL);
|
||||
|
||||
reg = BH1750FVI_MEASURE_TIMEH | ((*ptr & 0xE0) >> 5);
|
||||
reg = BH1750FVI_MEASURE_TIMEH | ((*ptr & 0xe0) >> 5);
|
||||
|
||||
ret = bh1750fvi_write8(priv, reg);
|
||||
if (ret < 0)
|
||||
@ -365,7 +365,7 @@ static int bh1750fvi_ioctl(FAR struct file *filep, int cmd,
|
||||
snerr("ERROR: Cannot Change Measure Time at MEASURE_TIMEH!\n");
|
||||
}
|
||||
|
||||
reg = BH1750FVI_MEASURE_TIMEL | (*ptr & 0x1F);
|
||||
reg = BH1750FVI_MEASURE_TIMEL | (*ptr & 0x1f);
|
||||
|
||||
ret = bh1750fvi_write8(priv, reg);
|
||||
if (ret < 0)
|
||||
|
@ -205,7 +205,7 @@ static void bmg160_write_register(FAR struct bmg160_dev_s *dev,
|
||||
|
||||
static void bmg160_reset(FAR struct bmg160_dev_s *dev)
|
||||
{
|
||||
bmg160_write_register(dev, BMG160_BGW_SOFTRESET_REG, 0xB6);
|
||||
bmg160_write_register(dev, BMG160_BGW_SOFTRESET_REG, 0xb6);
|
||||
|
||||
up_mdelay(100);
|
||||
}
|
||||
@ -220,7 +220,9 @@ static void bmg160_read_measurement_data(FAR struct bmg160_dev_s *dev)
|
||||
|
||||
/* Read Gyroscope */
|
||||
|
||||
uint16_t x_gyr = 0, y_gyr = 0, z_gyr = 0;
|
||||
uint16_t x_gyr = 0;
|
||||
uint16_t y_gyr = 0;
|
||||
uint16_t z_gyr = 0;
|
||||
|
||||
bmg160_read_gyroscope_data(dev, &x_gyr, &y_gyr, &z_gyr);
|
||||
|
||||
@ -588,7 +590,8 @@ int bmg160_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Since we support multiple BMG160 devices, we will need to add this new
|
||||
* instance to a list of device instances so that it can be found by the
|
||||
* interrupt handler based on the received IRQ number. */
|
||||
* interrupt handler based on the received IRQ number.
|
||||
*/
|
||||
|
||||
priv->flink = g_bmg160_list;
|
||||
g_bmg160_list = priv;
|
||||
|
@ -286,6 +286,7 @@ static const struct file_operations g_bmi160fops =
|
||||
* Description:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMI160_SPI
|
||||
static inline void bmi160_configspi(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
@ -647,6 +648,7 @@ static void bmi160_enable_stepcounter(FAR struct bmi160_dev_s *priv,
|
||||
{
|
||||
val &= ~STEP_CNT_EN;
|
||||
}
|
||||
|
||||
bmi160_putreg8(priv, BMI160_STEP_CONFIG_1, val);
|
||||
|
||||
sninfo("Step counter %sabled.\n", val & STEP_CNT_EN ? "en" : "dis");
|
||||
@ -755,6 +757,7 @@ int bmi160_register(FAR const char *devpath, FAR struct spi_dev_s *dev)
|
||||
snerr("Failed to allocate instance\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SENSORS_BMI160_I2C
|
||||
priv->i2c = dev;
|
||||
priv->addr = BMI160_I2C_ADDR;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/****************************************************************************
|
||||
* drivers/sensors/bmp180.c
|
||||
* Character driver for the Freescale BMP1801 Barometer Sensor
|
||||
@ -227,7 +226,8 @@ static uint8_t bmp180_getreg8(FAR struct bmp180_dev_s *priv, uint8_t regaddr)
|
||||
static uint16_t bmp180_getreg16(FAR struct bmp180_dev_s *priv, uint8_t regaddr)
|
||||
{
|
||||
struct i2c_config_s config;
|
||||
uint16_t msb, lsb;
|
||||
uint16_t msb;
|
||||
uint16_t lsb;
|
||||
uint16_t regval = 0;
|
||||
int ret;
|
||||
|
||||
@ -257,8 +257,8 @@ static uint16_t bmp180_getreg16(FAR struct bmp180_dev_s *priv, uint8_t regaddr)
|
||||
|
||||
/* MSB and LSB are inverted */
|
||||
|
||||
msb = (regval & 0xFF);
|
||||
lsb = (regval & 0xFF00) >> 8;
|
||||
msb = (regval & 0xff);
|
||||
lsb = (regval & 0xff00) >> 8;
|
||||
|
||||
regval = (msb << 8) | lsb;
|
||||
|
||||
|
@ -252,10 +252,11 @@ static int dht_read_raw_data(FAR struct dhtxx_dev_s *priv)
|
||||
int64_t start_time;
|
||||
int64_t end_time;
|
||||
int64_t current_time;
|
||||
uint8_t j, i;
|
||||
uint8_t i;
|
||||
uint8_t j;
|
||||
|
||||
j = 0U;
|
||||
for (i = 0U; i < DHTXX_RESPONSE_BITS; i++)
|
||||
j = 0u;
|
||||
for (i = 0u; i < DHTXX_RESPONSE_BITS; i++)
|
||||
{
|
||||
/* Start of transmission begins with a ~50uS low. */
|
||||
|
||||
@ -313,7 +314,7 @@ static bool dht_verify_checksum(FAR struct dhtxx_dev_s *priv)
|
||||
uint8_t sum;
|
||||
|
||||
sum = (priv->raw_data[0] + priv->raw_data[1] +
|
||||
priv->raw_data[2] + priv->raw_data[3]) & 0xFFU;
|
||||
priv->raw_data[2] + priv->raw_data[3]) & 0xffu;
|
||||
|
||||
return (sum == priv->raw_data[4]);
|
||||
}
|
||||
@ -377,8 +378,8 @@ static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
|
||||
case DHTXX_DHT12:
|
||||
data->hum = priv->raw_data[0] + priv->raw_data[1] * 0.1F;
|
||||
|
||||
data->temp = priv->raw_data[2] + (priv->raw_data[3] & 0x7FU) * 0.1F;
|
||||
if (priv->raw_data[3] & 0x80U)
|
||||
data->temp = priv->raw_data[2] + (priv->raw_data[3] & 0x7fu) * 0.1F;
|
||||
if (priv->raw_data[3] & 0x80u)
|
||||
{
|
||||
data->temp *= -1;
|
||||
}
|
||||
@ -395,11 +396,11 @@ static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
|
||||
case DHTXX_DHT22:
|
||||
case DHTXX_DHT33:
|
||||
case DHTXX_DHT44:
|
||||
data->hum = (priv->raw_data[0] << 8U | priv->raw_data[1]) * 0.1F;
|
||||
data->hum = (priv->raw_data[0] << 8u | priv->raw_data[1]) * 0.1F;
|
||||
|
||||
data->temp = (((priv->raw_data[2] & 0x7FU) << 8U) |
|
||||
data->temp = (((priv->raw_data[2] & 0x7fu) << 8u) |
|
||||
priv->raw_data[3]) * 0.1F;
|
||||
if (priv->raw_data[2] & 0x80U)
|
||||
if (priv->raw_data[2] & 0x80u)
|
||||
{
|
||||
data->temp *= -1;
|
||||
}
|
||||
@ -488,7 +489,7 @@ static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer,
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
memset(priv->raw_data, 0U, sizeof(priv->raw_data));
|
||||
memset(priv->raw_data, 0u, sizeof(priv->raw_data));
|
||||
|
||||
do
|
||||
{
|
||||
@ -530,6 +531,7 @@ static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer,
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
/* Done reading, set the sensor back to low mode. */
|
||||
|
||||
dht_standby_mode(priv);
|
||||
@ -608,6 +610,7 @@ int dhtxx_register(FAR const char *devpath, FAR struct dhtxx_config_s *config)
|
||||
snerr("ERROR: Failed to allocate instance\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
priv->config = config;
|
||||
|
||||
/* Register the character driver */
|
||||
|
@ -292,7 +292,6 @@ static int hcsr04_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
case SNIOC_READ_RAW_DATA:
|
||||
//ret = hcsr04_read_raw_data(priv, (FAR hcsr04_raw_data_t *) arg);
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_HCSR04_DEBUG
|
||||
|
@ -196,6 +196,7 @@ static int hts221_do_transfer(FAR struct hts221_dev_s *priv,
|
||||
else
|
||||
{
|
||||
/* Some error. Try to reset I2C bus and keep trying. */
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
if (retries == HTS221_I2C_RETRIES - 1)
|
||||
{
|
||||
@ -283,7 +284,11 @@ static int hts221_cfgr_resolution(FAR struct hts221_dev_s *priv,
|
||||
uint8_t value;
|
||||
const uint8_t addr = HTS221_AV_CONF;
|
||||
uint8_t regval = 0;
|
||||
uint8_t cmd[2] = { 0 };
|
||||
uint8_t cmd[2] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
const uint8_t mask = 0x3f;
|
||||
|
||||
ret = hts221_read_reg(priv, &addr, ®val);
|
||||
@ -315,7 +320,10 @@ static int hts221_config_ctrl_reg3(FAR struct hts221_dev_s *priv,
|
||||
uint8_t regval = 0;
|
||||
uint8_t addr = HTS221_CTRL_REG3;
|
||||
const uint8_t mask = 0xc4;
|
||||
uint8_t data_to_write[2] = { 0 };
|
||||
uint8_t data_to_write[2] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
ret = hts221_read_reg(priv, &addr, ®val);
|
||||
hts221_dbg("CTRL_REG%d: 0x%02X\n", 3, regval);
|
||||
@ -353,7 +361,11 @@ static int hts221_config_ctrl_reg2(FAR struct hts221_dev_s *priv,
|
||||
uint8_t regval = 0;
|
||||
uint8_t addr = HTS221_CTRL_REG2;
|
||||
const uint8_t mask = 0x80;
|
||||
uint8_t data_to_write[2] = { 0 };
|
||||
uint8_t data_to_write[2] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
int retries = 5;
|
||||
|
||||
if (!settings->is_boot)
|
||||
@ -424,7 +436,10 @@ static int hts221_config_ctrl_reg1(FAR struct hts221_dev_s *priv,
|
||||
uint8_t regval = 0;
|
||||
uint8_t addr = HTS221_CTRL_REG1;
|
||||
const uint8_t mask = 0x87;
|
||||
uint8_t data_to_write[2] = { 0 };
|
||||
uint8_t data_to_write[2] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
ret = hts221_read_reg(priv, &addr, ®val);
|
||||
hts221_dbg("CTRL_REG%d: 0x%02X\n", 1, regval);
|
||||
@ -434,7 +449,7 @@ static int hts221_config_ctrl_reg1(FAR struct hts221_dev_s *priv,
|
||||
}
|
||||
|
||||
regval &= ~mask;
|
||||
regval |= (uint8_t) (settings->odr & 0xFF);
|
||||
regval |= (uint8_t)(settings->odr & 0xff);
|
||||
regval |= (uint8_t)(settings->is_bdu ? HTS221_CTRL_REG1_BDU : 0);
|
||||
|
||||
data_to_write[0] = addr;
|
||||
@ -476,6 +491,7 @@ static int hts221_power_on_off(FAR struct hts221_dev_s *priv, bool on)
|
||||
{
|
||||
regval &= ~HTS221_CTRL_REG1_PD;
|
||||
}
|
||||
|
||||
data_to_write[0] = addr;
|
||||
data_to_write[1] = regval;
|
||||
|
||||
|
@ -167,7 +167,7 @@ static int ina219_access(FAR struct ina219_dev_s *priv,
|
||||
sninfo("start_register_address: "
|
||||
"0x%02X data_length: %d register_value: 0x%02x (0x%04x) ret: %d\n",
|
||||
start_register_address, data_length, *register_value,
|
||||
*((uint16_t*)register_value), ret);
|
||||
*((FAR uint16_t *)register_value), ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ static int ina226_access(FAR struct ina226_dev_s *priv,
|
||||
sninfo("start_register_address: "
|
||||
"0x%02X data_length: %d register_value: 0x%02x (0x%04x) ret: %d\n",
|
||||
start_register_address, data_length, *register_value,
|
||||
*((uint16_t*)register_value), ret);
|
||||
*((FAR uint16_t *)register_value), ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ static int ina3221_access(FAR struct ina3221_dev_s *priv,
|
||||
sninfo("start_register_address: "
|
||||
"0x%02X data_length: %d register_value: 0x%02x (0x%04x) ret: %d\n",
|
||||
start_register_address, data_length, *register_value,
|
||||
*((uint16_t*)register_value), ret);
|
||||
*((FAR uint16_t *)register_value), ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -392,8 +392,7 @@ static int ina3221_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ina3221_reCommits
|
||||
gister
|
||||
* Name: ina3221_register
|
||||
*
|
||||
* Description:
|
||||
* Register the INA3221 character device as 'devpath'
|
||||
|
@ -145,6 +145,7 @@ static const struct file_operations g_isl29023fops =
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: isl29023_i2c_write
|
||||
*
|
||||
|
@ -88,6 +88,7 @@
|
||||
#define PC1_ON (1 << 7)
|
||||
|
||||
/* CTRL_REG1: set resolution, g-range, data ready enable */
|
||||
|
||||
/* Output resolution: 8-bit valid or 12-bit valid */
|
||||
|
||||
#define RES_8BIT 0
|
||||
@ -104,6 +105,7 @@
|
||||
#define KXTJ9_G_8G (1 << 4)
|
||||
|
||||
/* Interrupt control register 1 bits */
|
||||
|
||||
/* Set these during probe if using irq mode */
|
||||
|
||||
#define KXTJ9_IEL (1 << 3)
|
||||
|
@ -309,7 +309,7 @@ static void l3gd20_read_gyroscope_data(FAR struct l3gd20_dev_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
static void l3gd20_read_temperature(FAR struct l3gd20_dev_s *dev,
|
||||
uint8_t* temperature)
|
||||
FAR uint8_t *temperature)
|
||||
{
|
||||
/* Lock the SPI bus so that only one device can access it at the same time */
|
||||
|
||||
@ -644,7 +644,8 @@ int l3gd20_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Since we support multiple L3GD20 devices, we will need to add this new
|
||||
* instance to a list of device instances so that it can be found by the
|
||||
* interrupt handler based on the received IRQ number. */
|
||||
* interrupt handler based on the received IRQ number.
|
||||
*/
|
||||
|
||||
priv->flink = g_l3gd20_list;
|
||||
g_l3gd20_list = priv;
|
||||
|
@ -221,7 +221,9 @@ static int lis2dh_open(FAR struct file *filep)
|
||||
if (regval == ST_LIS2DH_WHOAMI_VALUE)
|
||||
{
|
||||
priv->config->irq_enable(priv->config, true);
|
||||
|
||||
/* Normal exit point */
|
||||
|
||||
ret = lis2dh_clear_interrupts(priv, LIS2DH_INT1 | LIS2DH_INT2);
|
||||
return ret;
|
||||
}
|
||||
@ -313,7 +315,8 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct lis2dh_dev_s *priv = inode->i_private;
|
||||
FAR struct lis2dh_result *ptr;
|
||||
int readcount = (buflen - sizeof(struct lis2dh_res_header)) / sizeof(struct lis2dh_vector_s);
|
||||
int readcount = (buflen - sizeof(struct lis2dh_res_header)) /
|
||||
sizeof(struct lis2dh_vector_s);
|
||||
uint8_t buf;
|
||||
uint8_t int1_src = 0;
|
||||
uint8_t int2_src = 0;
|
||||
@ -321,7 +324,8 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
|
||||
int ret;
|
||||
|
||||
if (buflen < sizeof(struct lis2dh_result) ||
|
||||
(buflen - sizeof(struct lis2dh_res_header)) % sizeof(struct lis2dh_vector_s) != 0)
|
||||
(buflen - sizeof(struct lis2dh_res_header)) %
|
||||
sizeof(struct lis2dh_vector_s) != 0)
|
||||
{
|
||||
lis2dh_dbg("lis2dh: Illegal amount of bytes to read: %d\n", buflen);
|
||||
return -EINVAL;
|
||||
@ -474,6 +478,7 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
|
||||
lis2dh_dbg("lis2dh: Failed to read INT1_SRC_REG\n");
|
||||
ret = -EIO;
|
||||
}
|
||||
|
||||
if (buf & ST_LIS2DH_INT_SR_ACTIVE)
|
||||
{
|
||||
/* Interrupt has happened */
|
||||
@ -496,6 +501,7 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
|
||||
lis2dh_dbg("lis2dh: Failed to read INT2_SRC_REG\n");
|
||||
ret = -EIO;
|
||||
}
|
||||
|
||||
if (buf & ST_LIS2DH_INT_SR_ACTIVE)
|
||||
{
|
||||
/* Interrupt has happened */
|
||||
@ -507,6 +513,7 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
|
||||
{
|
||||
ptr->header.int2_occurred = false;
|
||||
}
|
||||
|
||||
ptr->header.int1_source = int1_src;
|
||||
ptr->header.int2_source = int2_src;
|
||||
|
||||
@ -814,7 +821,8 @@ static int lis2dh_int_handler(int irq, FAR void *context, FAR void *arg)
|
||||
|
||||
static int lis2dh_clear_registers(FAR struct lis2dh_dev_s *priv)
|
||||
{
|
||||
uint8_t i, buf = 0;
|
||||
uint8_t buf = 0;
|
||||
uint8_t i;
|
||||
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
@ -864,6 +872,7 @@ static int lis2dh_write_register(FAR struct lis2dh_dev_s *priv, uint8_t reg,
|
||||
value, reg);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1085,10 +1094,11 @@ static int lis2dh_handle_selftest(FAR struct lis2dh_dev_s *priv)
|
||||
}
|
||||
|
||||
/* 400Hz ODR all axes enabled
|
||||
FIFO overrun & DATA READY on INT1
|
||||
FIFO enabled and INT1 & INT2 latched
|
||||
FIFO mode, INT1 , THS 0
|
||||
OR combination, all events enabled */
|
||||
* FIFO overrun & DATA READY on INT1
|
||||
* FIFO enabled and INT1 & INT2 latched
|
||||
* FIFO mode, INT1 , THS 0
|
||||
* OR combination, all events enabled
|
||||
*/
|
||||
|
||||
if ((lis2dh_write_register(priv, ST_LIS2DH_CTRL_REG1, 0x77) != OK) ||
|
||||
(lis2dh_write_register(priv, ST_LIS2DH_CTRL_REG3, 0x12) != OK) ||
|
||||
@ -1219,6 +1229,7 @@ static bool lis2dh_data_available(FAR struct lis2dh_dev_s *dev)
|
||||
{
|
||||
return ((retval & ST_LIS2DH_SR_ZYXDA) != 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1398,6 +1409,7 @@ static unsigned int lis2dh_get_fifo_readings(FAR struct lis2dh_dev_s *priv,
|
||||
uint8_t raw[6];
|
||||
struct lis2dh_vector_s sample;
|
||||
} *buf = (void *)&res->measurements[res->header.meas_count];
|
||||
|
||||
bool xy_axis_fixup = priv->setup->xy_axis_fixup;
|
||||
size_t buflen = readcount * 6;
|
||||
int16_t x;
|
||||
@ -1491,7 +1503,10 @@ static inline int16_t lis2dh_raw_to_mg(uint8_t raw_hibyte, uint8_t raw_lobyte,
|
||||
static int lis2dh_read_temp(FAR struct lis2dh_dev_s *dev, FAR int16_t *temper)
|
||||
{
|
||||
int ret;
|
||||
uint8_t buf[2] = { 0 };
|
||||
uint8_t buf[2] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
ret = lis2dh_access(dev, ST_LIS2DH_OUT_TEMP_L_REG, buf, 2);
|
||||
if (ret < 0)
|
||||
@ -1564,6 +1579,7 @@ static int lis2dh_access(FAR struct lis2dh_dev_s *dev, uint8_t subaddr,
|
||||
if (subaddr == ST_LIS2DH_OUT_X_L_REG)
|
||||
{
|
||||
/* FIFO bulk read, length maximum 6*32 = 192 bytes. */
|
||||
|
||||
if (length > 6 * 32)
|
||||
{
|
||||
length = 6 * 32;
|
||||
@ -1617,6 +1633,7 @@ static int lis2dh_access(FAR struct lis2dh_dev_s *dev, uint8_t subaddr,
|
||||
else
|
||||
{
|
||||
/* Some error. Try to reset I2C bus and keep trying. */
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
int ret = I2C_RESET(dev->i2c);
|
||||
if (ret < 0)
|
||||
@ -1625,6 +1642,7 @@ static int lis2dh_access(FAR struct lis2dh_dev_s *dev, uint8_t subaddr,
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1646,7 +1664,8 @@ static int lis2dh_access(FAR struct lis2dh_dev_s *dev, uint8_t subaddr,
|
||||
|
||||
static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev)
|
||||
{
|
||||
struct timespec start, curr;
|
||||
struct timespec start;
|
||||
struct timespec curr;
|
||||
int32_t diff_msec;
|
||||
uint8_t value;
|
||||
|
||||
@ -1753,7 +1772,8 @@ static int lis2dh_setup(FAR struct lis2dh_dev_s * dev,
|
||||
|
||||
/* Clear old configuration. On first boot after power-loss, reboot bit does
|
||||
* not get cleared, and lis2dh_reboot() times out. Anyway, chip accepts
|
||||
* new configuration and functions correctly. */
|
||||
* new configuration and functions correctly.
|
||||
*/
|
||||
|
||||
(void)lis2dh_reboot(dev);
|
||||
|
||||
@ -1833,9 +1853,13 @@ static int lis2dh_setup(FAR struct lis2dh_dev_s * dev,
|
||||
|
||||
/* INT1_CFG */
|
||||
|
||||
value = dev->setup->int1_interrupt_mode | dev->setup->int1_enable_6d | dev->setup->int1_int_z_high_enable |
|
||||
dev->setup->int1_int_z_low_enable | dev->setup->int1_int_y_high_enable |
|
||||
dev->setup->int1_int_y_low_enable | dev->setup->int1_int_x_high_enable |
|
||||
value = dev->setup->int1_interrupt_mode |
|
||||
dev->setup->int1_enable_6d |
|
||||
dev->setup->int1_int_z_high_enable |
|
||||
dev->setup->int1_int_z_low_enable |
|
||||
dev->setup->int1_int_y_high_enable |
|
||||
dev->setup->int1_int_y_low_enable |
|
||||
dev->setup->int1_int_x_high_enable |
|
||||
dev->setup->int1_int_x_low_enable;
|
||||
if (lis2dh_access(dev, ST_LIS2DH_INT1_CFG_REG, &value, -1) != 1)
|
||||
{
|
||||
@ -1860,9 +1884,13 @@ static int lis2dh_setup(FAR struct lis2dh_dev_s * dev,
|
||||
|
||||
/* INT2_CFG */
|
||||
|
||||
value = dev->setup->int2_interrupt_mode | dev->setup->int2_enable_6d | dev->setup->int2_int_z_high_enable |
|
||||
dev->setup->int2_int_z_low_enable | dev->setup->int2_int_y_high_enable |
|
||||
dev->setup->int2_int_y_low_enable | dev->setup->int2_int_x_high_enable |
|
||||
value = dev->setup->int2_interrupt_mode |
|
||||
dev->setup->int2_enable_6d |
|
||||
dev->setup->int2_int_z_high_enable |
|
||||
dev->setup->int2_int_z_low_enable |
|
||||
dev->setup->int2_int_y_high_enable |
|
||||
dev->setup->int2_int_y_low_enable |
|
||||
dev->setup->int2_int_x_high_enable |
|
||||
dev->setup->int2_int_x_low_enable;
|
||||
if (lis2dh_access(dev, ST_LIS2DH_INT2_CFG_REG, &value, -1) != 1)
|
||||
{
|
||||
@ -2042,6 +2070,7 @@ int lis2dh_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
|
||||
{
|
||||
priv->config->irq_clear(config);
|
||||
}
|
||||
|
||||
priv->config->irq_attach(config, lis2dh_int_handler, priv);
|
||||
priv->config->irq_enable(config, false);
|
||||
return OK;
|
||||
|
@ -406,7 +406,7 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
|
||||
}
|
||||
|
||||
memset(dev->fifobuf, 0, LIS3DH_FIFOBUF_SIZE);
|
||||
dev->fifobuf[0] = LIS3DH_OUT_X_L | 0xC0;
|
||||
dev->fifobuf[0] = LIS3DH_OUT_X_L | 0xc0;
|
||||
|
||||
SPI_SELECT(dev->spi, dev->config->spi_devid, true);
|
||||
SPI_EXCHANGE(dev->spi, dev->fifobuf, dev->fifobuf, 1 + count * 6);
|
||||
@ -877,7 +877,6 @@ static ssize_t lis3dh_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
for (remain = count; remain > 0; remain--)
|
||||
{
|
||||
|
||||
/* Wait for data to be available in the queue */
|
||||
|
||||
nxsem_wait(&priv->readsem);
|
||||
|
@ -375,7 +375,8 @@ static int lis3dsh_open(FAR struct file *filep)
|
||||
|
||||
/* Enable - Measurement of X-, Y-, and Z-axis - Block data update for
|
||||
* accelerating data This should prevent race conditions when reading sensor
|
||||
* data - fastest output data rate (ODR = 1600 Hz) */
|
||||
* data - fastest output data rate (ODR = 1600 Hz).
|
||||
*/
|
||||
|
||||
lis3dsh_write_register(priv,
|
||||
LIS3DSH_CTRL_REG_4,
|
||||
|
@ -221,7 +221,9 @@ static void lis3mdl_read_measurement_data(FAR struct lis3mdl_dev_s *dev)
|
||||
{
|
||||
/* Magnetic data */
|
||||
|
||||
uint16_t x_mag = 0, y_mag = 0, z_mag = 0;
|
||||
uint16_t x_mag = 0;
|
||||
uint16_t y_mag = 0;
|
||||
uint16_t z_mag = 0;
|
||||
|
||||
lis3mdl_read_magnetic_data(dev, &x_mag, &y_mag, &z_mag);
|
||||
|
||||
@ -314,7 +316,8 @@ static void lis3mdl_read_temperature(FAR struct lis3mdl_dev_s *dev,
|
||||
|
||||
/* Transmit the register address from where we want to start reading 0x80 ->
|
||||
* MSB is set -> Read Indication 0x40 -> MSB-1 (MS-Bit) is set -> auto
|
||||
* increment of address when reading multiple bytes */
|
||||
* increment of address when reading multiple bytes.
|
||||
*/
|
||||
|
||||
SPI_SEND(dev->spi, (LIS3MDL_TEMP_OUT_L_REG | 0x80 | 0x40));
|
||||
|
||||
@ -339,7 +342,8 @@ static void lis3mdl_read_temperature(FAR struct lis3mdl_dev_s *dev,
|
||||
static int lis3mdl_interrupt_handler(int irq, FAR void *context)
|
||||
{
|
||||
/* This function should be called upon a rising edge on the LIS3MDL DRDY pin
|
||||
* since it signals that new data has been measured. */
|
||||
* since it signals that new data has been measured.
|
||||
*/
|
||||
|
||||
FAR struct lis3mdl_dev_s *priv = 0;
|
||||
int ret;
|
||||
@ -352,7 +356,8 @@ static int lis3mdl_interrupt_handler(int irq, FAR void *context)
|
||||
|
||||
/* Task the worker with retrieving the latest sensor data. We should not do
|
||||
* this in a interrupt since it might take too long. Also we cannot lock the
|
||||
* SPI bus from within an interrupt. */
|
||||
* SPI bus from within an interrupt.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(priv->work.worker == NULL);
|
||||
ret = work_queue(HPWORK, &priv->work, lis3mdl_worker, priv, 0);
|
||||
@ -384,6 +389,7 @@ static void lis3mdl_worker(FAR void *arg)
|
||||
/****************************************************************************
|
||||
* Name: lis3mdl_open
|
||||
****************************************************************************/
|
||||
|
||||
static int lis3mdl_open(FAR struct file *filep)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
@ -398,7 +404,8 @@ static int lis3mdl_open(FAR struct file *filep)
|
||||
lis3mdl_reset(priv);
|
||||
|
||||
/* Enable * - the maximum full scale mode. * Full scale = +/- 1.6 mT (16
|
||||
* Gauss) */
|
||||
* Gauss).
|
||||
*/
|
||||
|
||||
lis3mdl_write_register(priv,
|
||||
LIS3MDL_CTRL_REG_2,
|
||||
@ -407,7 +414,8 @@ static int lis3mdl_open(FAR struct file *filep)
|
||||
|
||||
/* Enable - temperature sensor - ultra high performance mode (UMP) for X and
|
||||
* Y - fast output data rates This results in a output data rate of 155 Hz
|
||||
* for X and Y */
|
||||
* for X and Y.
|
||||
*/
|
||||
|
||||
lis3mdl_write_register(priv,
|
||||
LIS3MDL_CTRL_REG_1,
|
||||
@ -416,7 +424,8 @@ static int lis3mdl_open(FAR struct file *filep)
|
||||
| LIS3MDL_CTRL_REG_1_FAST_ODR_bm);
|
||||
|
||||
/* Enable * - ultra high performance mode (UMP) for Z * This should result to
|
||||
* the same output data rate as for X and Y. */
|
||||
* the same output data rate as for X and Y.
|
||||
*/
|
||||
|
||||
lis3mdl_write_register(priv,
|
||||
LIS3MDL_CTRL_REG_4,
|
||||
@ -424,7 +433,8 @@ static int lis3mdl_open(FAR struct file *filep)
|
||||
LIS3MDL_CTRL_REG_4_OMZ_0_bm);
|
||||
|
||||
/* Enable * - block data update for magnetic sensor data * This should
|
||||
* prevent race conditions when reading sensor data. */
|
||||
* prevent race conditions when reading sensor data.
|
||||
*/
|
||||
|
||||
lis3mdl_write_register(priv, LIS3MDL_CTRL_REG_5, LIS3MDL_CTRL_REG_5_BDU_bm);
|
||||
|
||||
@ -627,7 +637,8 @@ int lis3mdl_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Since we support multiple LIS3MDL devices are supported, we will need to
|
||||
* add this new instance to a list of device instances so that it can be
|
||||
* found by the interrupt handler based on the received IRQ number. */
|
||||
* found by the interrupt handler based on the received IRQ number.
|
||||
*/
|
||||
|
||||
priv->flink = g_lis3mdl_list;
|
||||
g_lis3mdl_list = priv;
|
||||
|
@ -80,6 +80,7 @@ struct lm75_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int lm75_i2c_write(FAR struct lm75_dev_s *priv,
|
||||
@ -102,7 +103,8 @@ static ssize_t lm75_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t lm75_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static int lm75_ioctl(FAR struct file *filep,int cmd,unsigned long arg);
|
||||
static int lm75_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
@ -82,6 +82,7 @@ struct lm92_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int lm92_i2c_write(FAR struct lm92_dev_s *priv,
|
||||
|
@ -253,6 +253,7 @@ static int lps25h_do_transfer(FAR struct lps25h_dev_s *dev,
|
||||
else
|
||||
{
|
||||
/* Some error. Try to reset I2C bus and keep trying. */
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
if (retries == LPS25H_I2C_RETRIES - 1)
|
||||
{
|
||||
@ -450,6 +451,7 @@ static ssize_t lps25h_read(FAR struct file *filep, FAR char *buffer,
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
nxsem_post(&dev->devsem);
|
||||
return length;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ static bool lsm303agr_isbitset(int8_t b, int8_t m)
|
||||
|
||||
static int lsm303agr_sensor_start(FAR struct lsm303agr_dev_s *priv)
|
||||
{
|
||||
/* readreg8 is not necessary to modify. Clearbits can be 0x00 or 0xFF */
|
||||
/* readreg8 is not necessary to modify. Clearbits can be 0x00 or 0xff */
|
||||
|
||||
uint8_t value;
|
||||
|
||||
@ -441,15 +441,15 @@ static int lsm303agr_sensor_start(FAR struct lsm303agr_dev_s *priv)
|
||||
/* Accelerometer config registers Turn on the accelerometer: 833Hz, +- 16g */
|
||||
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CTRL_REG1_A, 0x77);
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CTRL_REG4_A, 0xB0);
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CTRL_REG4_A, 0xb0);
|
||||
g_accelerofactor = 11.72;
|
||||
|
||||
/* Gyro config registers Turn on the gyro: FS=2000dps, ODR=833Hz Not using
|
||||
* modifyreg with empty value!!!! Then read value first!!!
|
||||
* lsm303agr_modifyreg8(priv, lsm303agr_CTRL2_G, value, 0x7C);
|
||||
* lsm303agr_modifyreg8(priv, lsm303agr_CTRL2_G, value, 0x7c);
|
||||
*/
|
||||
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CFG_REG_A_M, 0x8C);
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CFG_REG_A_M, 0x8c);
|
||||
g_magnetofactor = 1.5;
|
||||
|
||||
return OK;
|
||||
@ -574,7 +574,7 @@ static int lsm303agr_selftest(FAR struct lsm303agr_dev_s *priv, uint32_t mode)
|
||||
else
|
||||
{
|
||||
registershift = 0x40;
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CFG_REG_A_M, 0x8C);
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CFG_REG_A_M, 0x8c);
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CFG_REG_B_M, 0x02);
|
||||
lsm303agr_writereg8(priv, LSM303AGR_CFG_REG_C_M, 0x10);
|
||||
g_magnetofactor = 1;
|
||||
@ -878,7 +878,6 @@ static int lsm303agr_selftest(FAR struct lsm303agr_dev_s *priv, uint32_t mode)
|
||||
static int lsm303agr_sensor_read(FAR struct lsm303agr_dev_s *priv,
|
||||
FAR struct lsm303agr_sensor_data_s *sensor_data)
|
||||
{
|
||||
|
||||
int16_t lo = 0;
|
||||
int16_t lox = 0;
|
||||
int16_t loxg = 0;
|
||||
@ -1078,7 +1077,8 @@ static ssize_t lsm303agr_read(FAR struct file *filep,
|
||||
}
|
||||
|
||||
/* The value is negative, so find its absolute value by taking the
|
||||
* two's complement */
|
||||
* two's complement.
|
||||
*/
|
||||
|
||||
else if (data > 0x8000)
|
||||
{
|
||||
@ -1087,7 +1087,8 @@ static ssize_t lsm303agr_read(FAR struct file *filep,
|
||||
}
|
||||
|
||||
/* The value is negative and can't be represented as a positive
|
||||
* int16_t value */
|
||||
* int16_t value.
|
||||
*/
|
||||
|
||||
else
|
||||
{
|
||||
@ -1270,6 +1271,7 @@ static int lsm303agr_register(FAR const char *devpath,
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lsm303agr_sensor_register(FAR const char *devpath,
|
||||
FAR struct i2c_master_s *i2c, uint8_t addr)
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ static struct lsm330_reg_pair_s g_default_lsm330_gyrocr_values[] =
|
||||
|
||||
{
|
||||
.addr = LSM330_GYRO_CTRL_REG1,
|
||||
.value = 0xFF
|
||||
.value = 0xff
|
||||
},
|
||||
|
||||
/* CR2 EXTRen LVLen HPM[1:0] HPCF[3:0] */
|
||||
@ -406,7 +406,6 @@ static uint8_t lsm330_read_register(FAR struct lsm330_dev_s *dev,
|
||||
FAR uint8_t *reg_data,
|
||||
uint8_t xfercnt)
|
||||
{
|
||||
|
||||
/* Lock the SPI bus so that only one device can access it at the same time */
|
||||
|
||||
SPI_LOCK(dev->spi, true);
|
||||
@ -464,7 +463,8 @@ static uint8_t lsm330_read_register(FAR struct lsm330_dev_s *dev,
|
||||
|
||||
/* Transmit the register address from where we want to start reading */
|
||||
|
||||
SPI_SEND(dev->spi, reg_addr | LSM330_READ | (xfercnt>1 ? LSM330_GYRO_AUTO : 0));
|
||||
SPI_SEND(dev->spi, reg_addr | LSM330_READ |
|
||||
(xfercnt > 1 ? LSM330_GYRO_AUTO : 0));
|
||||
|
||||
/* Write idle bytes while receiving the requested data */
|
||||
|
||||
@ -586,7 +586,8 @@ static void lsm330_write_register(FAR struct lsm330_dev_s *dev,
|
||||
|
||||
/* Transmit the register address to where we want to start writing */
|
||||
|
||||
SPI_SEND(dev->spi, reg_addr | LSM330_WRITE | (xfercnt>1 ? LSM330_GYRO_AUTO : 0));
|
||||
SPI_SEND(dev->spi, reg_addr | LSM330_WRITE |
|
||||
(xfercnt > 1 ? LSM330_GYRO_AUTO : 0));
|
||||
|
||||
/* Transmit the content which should be written in the register block */
|
||||
|
||||
|
@ -139,7 +139,7 @@ static const struct file_operations g_fops =
|
||||
# endif
|
||||
};
|
||||
|
||||
static const struct lsm6dsl_ops_s g_LSM6DSLsensor_ops =
|
||||
static const struct lsm6dsl_ops_s g_lsm6dsl_sensor_ops =
|
||||
{
|
||||
lsm6dsl_sensor_config,
|
||||
lsm6dsl_sensor_start,
|
||||
@ -439,7 +439,7 @@ static int lsm6dsl_sensor_start(FAR struct lsm6dsl_dev_s *priv)
|
||||
* modifyreg with empty value!!!! Then read value first!!!
|
||||
*/
|
||||
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL2_G, 0x7C);
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL2_G, 0x7c);
|
||||
g_gyrofactor = 70;
|
||||
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL6_C, 0x00);
|
||||
@ -493,7 +493,6 @@ static int lsm6dsl_sensor_stop(FAR struct lsm6dsl_dev_s *priv)
|
||||
|
||||
static int lsm6dsl_selftest(FAR struct lsm6dsl_dev_s *priv, uint32_t mode)
|
||||
{
|
||||
|
||||
int samples = 5;
|
||||
int i;
|
||||
int i2;
|
||||
@ -589,7 +588,7 @@ static int lsm6dsl_selftest(FAR struct lsm6dsl_dev_s *priv, uint32_t mode)
|
||||
/* Gyro; power down accelero CTRL1_XL FS=2000dps,208Hz 2000dps=65535 */
|
||||
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL1_XL, 0x00);
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL2_G, 0x5C);
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL2_G, 0x5c);
|
||||
lsm6dsl_writereg8(priv, LSM6DSL_CTRL3_C, 0x44);
|
||||
g_gyrofactor = (70 / 1000); /* 2000dps */
|
||||
}
|
||||
@ -898,7 +897,6 @@ static int lsm6dsl_selftest(FAR struct lsm6dsl_dev_s *priv, uint32_t mode)
|
||||
static int lsm6dsl_sensor_read(FAR struct lsm6dsl_dev_s *priv,
|
||||
FAR struct lsm6dsl_sensor_data_s *sensor_data)
|
||||
{
|
||||
|
||||
int16_t lo = 0;
|
||||
int16_t lox = 0;
|
||||
int16_t loxg = 0;
|
||||
@ -1337,7 +1335,7 @@ int lsm6dsl_sensor_register(FAR const char *devpath,
|
||||
|
||||
sninfo("Trying to register accel\n");
|
||||
|
||||
return lsm6dsl_register(devpath, i2c, addr, &g_LSM6DSLsensor_ops,
|
||||
return lsm6dsl_register(devpath, i2c, addr, &g_lsm6dsl_sensor_ops,
|
||||
LSM6DSL_OUTX_L_XL_SHIFT, sensor_data);
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@
|
||||
#endif
|
||||
|
||||
/* Register Addresses *******************************************************/
|
||||
|
||||
/* Accelerometer and gyroscope registers */
|
||||
|
||||
#define LSM9DS1_ACT_THS 0x04 /* Inactivity threshold */
|
||||
@ -143,6 +144,7 @@
|
||||
#define LSM9DS1_INT_THS_H_M 0x33 /* Interrupt threshold high byte */
|
||||
|
||||
/* Register Bit Definitions *************************************************/
|
||||
|
||||
/* Inactivity threshold register */
|
||||
|
||||
#define LSM9DS1_ACT_THS_ACT_THS_SHIFT 0 /* Inactivity threshold */
|
||||
@ -521,6 +523,7 @@ struct lsm9ds1_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int lsm9ds1_readreg8(FAR struct lsm9ds1_dev_s *priv, uint8_t regaddr,
|
||||
|
@ -78,6 +78,7 @@ struct ltc4151_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int ltc4151_read16(FAR struct ltc4151_dev_s *priv, uint8_t regaddr,
|
||||
@ -89,10 +90,12 @@ static int ltc4151_readpower(FAR struct ltc4151_dev_s *priv,
|
||||
|
||||
static int ltc4151_open(FAR struct file *filep);
|
||||
static int ltc4151_close(FAR struct file *filep);
|
||||
static ssize_t ltc4151_read(FAR struct file *filep, FAR char *buffer, size_t buflen);
|
||||
static ssize_t ltc4151_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t ltc4151_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static int ltc4151_ioctl(FAR struct file *filep,int cmd,unsigned long arg);
|
||||
static int ltc4151_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -137,14 +140,14 @@ static int ltc4151_read_reg(FAR struct ltc4151_dev_s *priv,
|
||||
sninfo("start_register_address: "
|
||||
"0x%02X data_length: %d register_value: 0x%02x (0x%04x) ret: %d\n",
|
||||
start_register_address, data_length, *register_value,
|
||||
*((uint16_t*)register_value), ret);
|
||||
*((FAR uint16_t *)register_value), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ltc4151_read16(FAR struct ltc4151_dev_s *priv, uint8_t regaddr,
|
||||
FAR uint16_t *regvalue)
|
||||
{
|
||||
int ret = ltc4151_read_reg(priv, regaddr, (uint8_t*)regvalue,
|
||||
int ret = ltc4151_read_reg(priv, regaddr, (FAR uint8_t *)regvalue,
|
||||
sizeof(*regvalue));
|
||||
|
||||
/* Bytes are 8bit_msb.4bit_0.4bit_lsb = 16bit */
|
||||
|
@ -70,8 +70,8 @@
|
||||
#define MAX31855_SHORT_VCC (1 << 2)
|
||||
#define MAX31855_SHORT_GND (1 << 1)
|
||||
#define MAX31855_OPEN_CIRCUIT (1 << 0)
|
||||
#define MAX31855_TEMP_COUPLE 0xFFFFC000
|
||||
#define MAX31855_TEMP_JUNCTION 0xFFF0
|
||||
#define MAX31855_TEMP_COUPLE 0xffffc000
|
||||
#define MAX31855_TEMP_JUNCTION 0xfff0
|
||||
|
||||
struct max31855_dev_s
|
||||
{
|
||||
@ -222,10 +222,10 @@ static ssize_t max31855_read(FAR struct file *filep, FAR char *buffer,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
regval = (regmsb & 0xFF000000) >> 24;
|
||||
regval |= (regmsb & 0xFF0000) >> 8;
|
||||
regval |= (regmsb & 0xFF00) << 8;
|
||||
regval |= (regmsb & 0xFF) << 24;
|
||||
regval = (regmsb & 0xff000000) >> 24;
|
||||
regval |= (regmsb & 0xff0000) >> 8;
|
||||
regval |= (regmsb & 0xff00) << 8;
|
||||
regval |= (regmsb & 0xff) << 24;
|
||||
|
||||
sninfo("Read from MAX31855 = 0x%08X\n", regval);
|
||||
|
||||
|
@ -714,7 +714,8 @@ static int max44009_read_data(FAR struct max44009_dev_s *priv,
|
||||
}
|
||||
|
||||
/* Merge HBYTE and LBYTE to 16-bit integer:
|
||||
* --.--.--.--.E3.E2.E1.E0.M7.M6.M5.M4.M3.M2.M1.M0 */
|
||||
* --.--.--.--.E3.E2.E1.E0.M7.M6.M5.M4.M3.M2.M1.M0
|
||||
*/
|
||||
|
||||
data->raw_value = (hvalue << 4) | (lvalue & 0xf);
|
||||
|
||||
@ -850,7 +851,8 @@ static int max44009_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
}
|
||||
|
||||
/* This is a request to set up the poll. Find an available slot for the
|
||||
* poll structure reference */
|
||||
* poll structure reference.
|
||||
*/
|
||||
|
||||
for (i = 0; i < CONFIG_MAX44009_NPOLLWAITERS; i++)
|
||||
{
|
||||
@ -872,6 +874,7 @@ static int max44009_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (priv->int_pending)
|
||||
{
|
||||
max44009_notify(priv);
|
||||
@ -889,7 +892,9 @@ static int max44009_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
*slot = NULL;
|
||||
fds->priv = NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
nxsem_post(&priv->dev_sem);
|
||||
return ret;
|
||||
}
|
||||
|
@ -208,8 +208,8 @@ static ssize_t max6675_read(FAR struct file *filep, FAR char *buffer, size_t buf
|
||||
SPI_SELECT(priv->spi, SPIDEV_TEMPERATURE(0), false);
|
||||
max6675_unlock(priv->spi);
|
||||
|
||||
regval = (regmsb & 0xFF00) >> 8;
|
||||
regval |= (regmsb & 0xFF) << 8;
|
||||
regval = (regmsb & 0xff00) >> 8;
|
||||
regval |= (regmsb & 0xff) << 8;
|
||||
|
||||
sninfo("Read from MAX6675 = 0x%04X\n", regval);
|
||||
|
||||
|
@ -76,6 +76,7 @@ struct mb7040_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int mb7040_measurerange(FAR struct mb7040_dev_s *priv);
|
||||
|
@ -284,11 +284,11 @@ static int mcp9844_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
* need to be masked out.
|
||||
*/
|
||||
|
||||
raw_temperature &= 0x0FFF; /* 0x0FFF = 0b 0000 1111 1111 1111 */
|
||||
raw_temperature &= 0x0fff; /* 0x0fff = 0b 0000 1111 1111 1111 */
|
||||
|
||||
/* The post comma temperature value is encoded in BIT3 to BIT0 */
|
||||
|
||||
temp_result->temp_post_comma = (uint8_t)(raw_temperature & 0x000F);
|
||||
temp_result->temp_post_comma = (uint8_t)(raw_temperature & 0x000f);
|
||||
|
||||
/* The pre comma temperature value is encoded in BIT11 to BIT4 */
|
||||
|
||||
@ -296,7 +296,8 @@ static int mcp9844_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
}
|
||||
else
|
||||
{
|
||||
snerr("ERROR: ioctl::SNIOC_READTEMP - mcp9844_read_u16 failed - no temperature retrieved\n");
|
||||
snerr("ERROR: ioctl::SNIOC_READTEMP - mcp9844_read_u16 failed"
|
||||
" - no temperature retrieved\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -306,7 +307,8 @@ static int mcp9844_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
ret = mcp9844_write_u16(priv, MCP9844_RESO_REG, (uint16_t)(arg));
|
||||
if (ret != OK)
|
||||
{
|
||||
snerr("ERROR: ioctl::SNIOC_SETRESOLUTION - mcp9844_write_u16 failed - no resolution set\n");
|
||||
snerr("ERROR: ioctl::SNIOC_SETRESOLUTION - mcp9844_write_u16 failed"
|
||||
" - no resolution set\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -334,11 +334,11 @@ static void mlx90393_write_register(FAR struct mlx90393_dev_s *dev,
|
||||
|
||||
/* Send the data high byte of the register */
|
||||
|
||||
SPI_SEND(dev->spi, (uint8_t) ((reg_data & 0xFF00) >> 8));
|
||||
SPI_SEND(dev->spi, (uint8_t) ((reg_data & 0xff00) >> 8));
|
||||
|
||||
/* Send the data low byte of the register */
|
||||
|
||||
SPI_SEND(dev->spi, (uint8_t) (reg_data & 0x00FF));
|
||||
SPI_SEND(dev->spi, (uint8_t) (reg_data & 0x00ff));
|
||||
|
||||
/* Send the register address which needs to be left shifted by 2 */
|
||||
|
||||
@ -616,7 +616,8 @@ int mlx90393_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Since we support multiple MLX90393 devices are supported, we will need to
|
||||
* add this new instance to a list of device instances so that it can be
|
||||
* found by the interrupt handler based on the received IRQ number. */
|
||||
* found by the interrupt handler based on the received IRQ number.
|
||||
*/
|
||||
|
||||
priv->flink = g_mlx90393_list;
|
||||
g_mlx90393_list = priv;
|
||||
|
@ -79,7 +79,8 @@ struct mpl115a_dev_s
|
||||
****************************************************************************/
|
||||
|
||||
static inline void mpl115a_configspi(FAR struct spi_dev_s *spi);
|
||||
static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv, uint8_t regaddr);
|
||||
static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv,
|
||||
uint8_t regaddr);
|
||||
static void mpl115a_updatecaldata(FAR struct mpl115a_dev_s *priv);
|
||||
static void mpl115a_read_press_temp(FAR struct mpl115a_dev_s *priv);
|
||||
static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv);
|
||||
@ -90,7 +91,8 @@ static int mpl115a_open(FAR struct file *filep);
|
||||
static int mpl115a_close(FAR struct file *filep);
|
||||
static ssize_t mpl115a_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t mpl115a_write(FAR struct file *filep, FAR const char *buffer, size_t buflen);
|
||||
static ssize_t mpl115a_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -176,26 +178,38 @@ static void mpl115a_updatecaldata(FAR struct mpl115a_dev_s *priv)
|
||||
{
|
||||
/* Get a0 coefficient */
|
||||
|
||||
priv->mpl115a_cal_a0 = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_A0_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_a0 |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_A0_LSB << 1));
|
||||
priv->mpl115a_cal_a0 =
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_A0_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_a0 |=
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_A0_LSB << 1));
|
||||
|
||||
sninfo("a0 = %d\n", priv->mpl115a_cal_a0);
|
||||
|
||||
/* Get b1 coefficient */
|
||||
|
||||
priv->mpl115a_cal_b1 = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B1_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_b1 |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B1_LSB << 1));
|
||||
priv->mpl115a_cal_b1 =
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B1_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_b1 |=
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B1_LSB << 1));
|
||||
|
||||
sninfo("b1 = %d\n", priv->mpl115a_cal_b1);
|
||||
|
||||
/* Get b2 coefficient */
|
||||
|
||||
priv->mpl115a_cal_b2 = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B2_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_b2 |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B2_LSB << 1));
|
||||
priv->mpl115a_cal_b2 =
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B2_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_b2 |=
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B2_LSB << 1));
|
||||
|
||||
sninfo("b2 = %d\n", priv->mpl115a_cal_b2);
|
||||
|
||||
/* Get c12 coefficient */
|
||||
|
||||
priv->mpl115a_cal_c12 = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_C12_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_c12 |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_C12_LSB << 1));
|
||||
priv->mpl115a_cal_c12 =
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_C12_MSB << 1)) << 8;
|
||||
priv->mpl115a_cal_c12 |=
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_C12_LSB << 1));
|
||||
|
||||
sninfo("c12 = %d\n", priv->mpl115a_cal_c12);
|
||||
}
|
||||
|
||||
@ -218,14 +232,18 @@ static void mpl115a_read_press_temp(FAR struct mpl115a_dev_s *priv)
|
||||
|
||||
nxsig_usleep(5000);
|
||||
|
||||
priv->mpl115a_pressure = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_MSB << 1)) << 8;
|
||||
priv->mpl115a_pressure |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_LSB << 1));
|
||||
priv->mpl115a_pressure =
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_MSB << 1)) << 8;
|
||||
priv->mpl115a_pressure |=
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_LSB << 1));
|
||||
priv->mpl115a_pressure >>= 6; /* Padc is 10bit unsigned */
|
||||
|
||||
sninfo("Pressure = %d\n", priv->mpl115a_pressure);
|
||||
|
||||
priv->mpl115a_temperature = mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_TADC_MSB << 1)) << 8;
|
||||
priv->mpl115a_temperature |= mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_TADC_LSB << 1));
|
||||
priv->mpl115a_temperature =
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_TADC_MSB << 1)) << 8;
|
||||
priv->mpl115a_temperature |=
|
||||
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_TADC_LSB << 1));
|
||||
priv->mpl115a_temperature >>= 6; /* Tadc is 10bit unsigned */
|
||||
|
||||
sninfo("Temperature = %d\n", priv->mpl115a_temperature);
|
||||
@ -247,8 +265,15 @@ static void mpl115a_read_press_temp(FAR struct mpl115a_dev_s *priv)
|
||||
|
||||
static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv)
|
||||
{
|
||||
int32_t c12x2, a1, a1x1, y1, a2x2, pcomp;
|
||||
uint16_t padc, tadc, pressure;
|
||||
int32_t c12x2;
|
||||
int32_t a1;
|
||||
int32_t a1x1;
|
||||
int32_t y1;
|
||||
int32_t a2x2;
|
||||
int32_t pcomp;
|
||||
uint16_t padc;
|
||||
uint16_t tadc;
|
||||
uint16_t pressure;
|
||||
|
||||
/* Check if coefficient data were read correctly */
|
||||
|
||||
|
@ -66,6 +66,7 @@
|
||||
#endif
|
||||
|
||||
/* Register Definitions *****************************************************/
|
||||
|
||||
/* Register Addresses */
|
||||
|
||||
#define MS58XX_RESET_REG 0x1e /* Reset Register */
|
||||
@ -138,6 +139,7 @@ struct ms58xx_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* CRC Calculation */
|
||||
|
||||
static uint8_t ms58xx_crc(FAR uint16_t *src, uint8_t crcndx, uint16_t crcmask);
|
||||
@ -234,7 +236,7 @@ static uint8_t ms58xx_crc(FAR uint16_t *src, uint8_t crcndx, uint16_t crcmask)
|
||||
}
|
||||
}
|
||||
|
||||
n_rem = (0x000F & (n_rem >> 12));
|
||||
n_rem = (0x000f & (n_rem >> 12));
|
||||
src[crcndx] = crc_read;
|
||||
return (n_rem ^ 0x00);
|
||||
}
|
||||
@ -417,7 +419,7 @@ static int ms58xx_setosr_1(FAR struct ms58xx_dev_s *priv, uint16_t osr)
|
||||
|
||||
case 8192:
|
||||
priv->delay = 18080;
|
||||
priv->osr = 0xA;
|
||||
priv->osr = 0xa;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -63,6 +63,7 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
@ -84,8 +85,10 @@ struct qe_upperhalf_s
|
||||
|
||||
static int qe_open(FAR struct file *filep);
|
||||
static int qe_close(FAR struct file *filep);
|
||||
static ssize_t qe_read(FAR struct file *filep, FAR char *buffer, size_t buflen);
|
||||
static ssize_t qe_write(FAR struct file *filep, FAR const char *buffer, size_t buflen);
|
||||
static ssize_t qe_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t qe_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static int qe_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -84,7 +84,7 @@
|
||||
#define SCD30_CMD_SET_FRC 0x5204
|
||||
#define SCD30_CMD_SET_TEMP_OFFSET 0x5403
|
||||
#define SCD30_CMD_SET_ALT_COMPENSATION 0x5102
|
||||
#define SCD30_CMD_SOFT_RESET 0xD304
|
||||
#define SCD30_CMD_SOFT_RESET 0xd304
|
||||
|
||||
#define SCD30_DEFAULT_MEASUREMENT_INTERVAL 2 /* seconds */
|
||||
#define SCD30_DEFAULT_PRESSURE_COMPENSATION 0
|
||||
@ -131,6 +131,7 @@ struct scd30_word_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* IO Helpers */
|
||||
|
||||
#ifdef CONFIG_SCD30_I2C
|
||||
@ -226,6 +227,7 @@ static int scd30_do_transfer(FAR struct i2c_master_s *i2c,
|
||||
else
|
||||
{
|
||||
/* Some error. Try to reset I2C bus and keep trying. */
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
if (retries == SCD30_I2C_RETRIES - 1)
|
||||
{
|
||||
@ -330,7 +332,8 @@ static uint8_t scd30_crc_word(uint16_t word)
|
||||
0x00, 0x31, 0x62, 0x53, 0xc4, 0xf5, 0xa6, 0x97,
|
||||
0xb9, 0x88, 0xdb, 0xea, 0x7d, 0x4c, 0x1f, 0x2e
|
||||
};
|
||||
uint8_t crc = 0xFF;
|
||||
|
||||
uint8_t crc = 0xff;
|
||||
|
||||
crc ^= word >> 8;
|
||||
crc = (crc << 4) ^ crc_table[crc >> 4];
|
||||
@ -1079,7 +1082,7 @@ int scd30_register_i2c(FAR const char *devpath, FAR struct i2c_master_s *i2c,
|
||||
|
||||
DEBUGASSERT(i2c != NULL);
|
||||
DEBUGASSERT(addr == CONFIG_SCD30_ADDR);
|
||||
DEBUGASSERT(scd30_crc_word(0xBEEF) == 0x92);
|
||||
DEBUGASSERT(scd30_crc_word(0xbeef) == 0x92);
|
||||
|
||||
/* Initialize the device structure */
|
||||
|
||||
|
@ -106,6 +106,7 @@ struct sgp30_cmd_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* IO Helpers */
|
||||
|
||||
static int sgp30_do_transfer(FAR struct i2c_master_s *i2c,
|
||||
@ -245,6 +246,7 @@ static int sgp30_do_transfer(FAR struct i2c_master_s *i2c,
|
||||
else
|
||||
{
|
||||
/* Some error. Try to reset I2C bus and keep trying. */
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
if (retries == SGP30_I2C_RETRIES - 1)
|
||||
{
|
||||
@ -359,7 +361,8 @@ static uint8_t sgp30_crc_word(uint16_t word)
|
||||
0x00, 0x31, 0x62, 0x53, 0xc4, 0xf5, 0xa6, 0x97,
|
||||
0xb9, 0x88, 0xdb, 0xea, 0x7d, 0x4c, 0x1f, 0x2e
|
||||
};
|
||||
uint8_t crc = 0xFF;
|
||||
|
||||
uint8_t crc = 0xff;
|
||||
|
||||
crc ^= word >> 8;
|
||||
crc = (crc << 4) ^ crc_table[crc >> 4];
|
||||
@ -556,7 +559,8 @@ static int sgp30_open(FAR struct file *filep)
|
||||
ret = sgp30_write_cmd(priv, SGP30_CMD_INIT_AIR_QUALITY, NULL, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY) failed, %d\n", ret);
|
||||
sgp30_dbg("sgp30_write_cmd(SGP30_CMD_INIT_AIR_QUALITY) failed, %d\n",
|
||||
ret);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -636,7 +640,8 @@ static ssize_t sgp30_read(FAR struct file *filep, FAR char *buffer,
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct sgp30_dev_s *priv = inode->i_private;
|
||||
ssize_t length = 0;
|
||||
struct timespec ts, ts_sleep;
|
||||
struct timespec ts;
|
||||
struct timespec ts_sleep;
|
||||
struct sgp30_conv_data_s data;
|
||||
int ret;
|
||||
|
||||
@ -893,7 +898,7 @@ static int sgp30_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
sgp30_dbg("crc error\n");
|
||||
ret = -EIO;
|
||||
}
|
||||
else if (sgp30_data_word_to_uint16(buf) != 0xD400)
|
||||
else if (sgp30_data_word_to_uint16(buf) != 0xd400)
|
||||
{
|
||||
sgp30_dbg("self-test failed, 0x%04x\n",
|
||||
sgp30_data_word_to_uint16(buf));
|
||||
@ -989,7 +994,7 @@ int sgp30_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
|
||||
|
||||
DEBUGASSERT(i2c != NULL);
|
||||
DEBUGASSERT(addr == CONFIG_SGP30_ADDR);
|
||||
DEBUGASSERT(sgp30_crc_word(0xBEEF) == 0x92);
|
||||
DEBUGASSERT(sgp30_crc_word(0xbeef) == 0x92);
|
||||
|
||||
/* Initialize the device structure */
|
||||
|
||||
|
@ -99,6 +99,7 @@ struct sht21_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* I2C Helpers */
|
||||
|
||||
static int sht21_access(FAR struct sht21_dev_s *priv,
|
||||
|
@ -306,6 +306,7 @@ static uint8_t sht3x_crc_word(uint16_t word)
|
||||
0x00, 0x31, 0x62, 0x53, 0xc4, 0xf5, 0xa6, 0x97,
|
||||
0xb9, 0x88, 0xdb, 0xea, 0x7d, 0x4c, 0x1f, 0x2e
|
||||
};
|
||||
|
||||
uint8_t crc = 0xff;
|
||||
|
||||
crc ^= word >> 8;
|
||||
|
@ -84,9 +84,9 @@
|
||||
#define SPS30_CMD_READ_MEASUREMENT 0x0300
|
||||
#define SPS30_CMD_SET_AUTO_CLEANING_INTERVAL 0x8004
|
||||
#define SPS30_CMD_START_FAN_CLEANING 0x5607
|
||||
#define SPS30_CMD_READ_ARTICLE_CODE 0xD025
|
||||
#define SPS30_CMD_READ_SERIAL_NUMBER 0xD033
|
||||
#define SPS30_CMD_SOFT_RESET 0xD304
|
||||
#define SPS30_CMD_READ_ARTICLE_CODE 0xd025
|
||||
#define SPS30_CMD_READ_SERIAL_NUMBER 0xd033
|
||||
#define SPS30_CMD_SOFT_RESET 0xd304
|
||||
|
||||
/****************************************************************************
|
||||
* Private
|
||||
@ -123,6 +123,7 @@ struct sps30_word_s
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* IO Helpers */
|
||||
|
||||
#ifdef CONFIG_SPS30_I2C
|
||||
@ -220,6 +221,7 @@ static int sps30_do_transfer(FAR struct i2c_master_s *i2c,
|
||||
else
|
||||
{
|
||||
/* Some error. Try to reset I2C bus and keep trying. */
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
if (retries == SPS30_I2C_RETRIES - 1)
|
||||
{
|
||||
@ -344,7 +346,8 @@ static uint8_t sps30_crc_word(uint16_t word)
|
||||
0x00, 0x31, 0x62, 0x53, 0xc4, 0xf5, 0xa6, 0x97,
|
||||
0xb9, 0x88, 0xdb, 0xea, 0x7d, 0x4c, 0x1f, 0x2e
|
||||
};
|
||||
uint8_t crc = 0xFF;
|
||||
|
||||
uint8_t crc = 0xff;
|
||||
|
||||
crc ^= word >> 8;
|
||||
crc = (crc << 4) ^ crc_table[crc >> 4];
|
||||
@ -667,6 +670,7 @@ static int sps30_open(FAR struct file *filep)
|
||||
uint32_t u32[8];
|
||||
char c[32];
|
||||
} code, sn;
|
||||
|
||||
int ret;
|
||||
|
||||
/* Get exclusive access */
|
||||
@ -1095,7 +1099,7 @@ int sps30_register_i2c(FAR const char *devpath, FAR struct i2c_master_s *i2c,
|
||||
|
||||
DEBUGASSERT(i2c != NULL);
|
||||
DEBUGASSERT(addr == CONFIG_SPS30_ADDR);
|
||||
DEBUGASSERT(sps30_crc_word(0xBEEF) == 0x92);
|
||||
DEBUGASSERT(sps30_crc_word(0xbeef) == 0x92);
|
||||
|
||||
/* Initialize the device structure */
|
||||
|
||||
|
@ -202,7 +202,11 @@ static int t67xx_read16(FAR struct t67xx_dev_s *priv, uint16_t regaddr,
|
||||
{
|
||||
struct i2c_config_s config;
|
||||
uint8_t buf[5];
|
||||
uint8_t rxbuf[4] = { 0 };
|
||||
uint8_t rxbuf[4] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
@ -222,8 +226,6 @@ static int t67xx_read16(FAR struct t67xx_dev_s *priv, uint16_t regaddr,
|
||||
buf[3] = 0;
|
||||
buf[4] = 1;
|
||||
|
||||
//sninfo("->[%d %d %d %d %d]\n", buf[0], buf[1], buf[2], buf[3], buf[4]);
|
||||
|
||||
/* Write the Modbus read request. */
|
||||
|
||||
ret = i2c_write(priv->i2c, &config, buf, sizeof(buf));
|
||||
@ -244,8 +246,6 @@ static int t67xx_read16(FAR struct t67xx_dev_s *priv, uint16_t regaddr,
|
||||
return ret;
|
||||
}
|
||||
|
||||
//sninfo("<-[%d %d %d %d]\n", rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3]);
|
||||
|
||||
if (rxbuf[0] != 4 || rxbuf[1] != 2)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG_SENSORS_ERROR
|
||||
@ -272,7 +272,11 @@ static int t67xx_write16(FAR struct t67xx_dev_s *priv, uint16_t regaddr,
|
||||
{
|
||||
struct i2c_config_s config;
|
||||
uint8_t buf[5];
|
||||
uint8_t rxbuf[5] = { 0 };
|
||||
uint8_t rxbuf[5] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
@ -291,8 +295,6 @@ static int t67xx_write16(FAR struct t67xx_dev_s *priv, uint16_t regaddr,
|
||||
buf[3] = (regvalue >> 8) & 0xff;
|
||||
buf[4] = regvalue & 0xff;
|
||||
|
||||
//sninfo("->[%d %d %d %d %d]\n", buf[0], buf[1], buf[2], buf[3], buf[4]);
|
||||
|
||||
/* Write the Modbus write request. */
|
||||
|
||||
ret = i2c_write(priv->i2c, &config, buf, sizeof(buf));
|
||||
@ -320,8 +322,6 @@ static int t67xx_write16(FAR struct t67xx_dev_s *priv, uint16_t regaddr,
|
||||
return ret;
|
||||
}
|
||||
|
||||
//sninfo("<-[%d %d %d %d %d]\n", rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3], rxbuf[4]);
|
||||
|
||||
if (memcmp(rxbuf, buf, sizeof(rxbuf)) != 0)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG_SENSORS_ERROR
|
||||
@ -426,7 +426,6 @@ static bool has_time_passed(struct timespec curr,
|
||||
return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: t67xx_read_gas_ppm
|
||||
*
|
||||
@ -439,7 +438,8 @@ static int t67xx_read_gas_ppm(FAR struct t67xx_dev_s *priv,
|
||||
FAR struct t67xx_value_s *buffer)
|
||||
{
|
||||
uint16_t ppm;
|
||||
bool warming_up, calibrating;
|
||||
bool warming_up;
|
||||
bool calibrating;
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
|
||||
|
@ -758,6 +758,7 @@ static void vl53l1x_calibrateoffset(FAR struct vl53l1x_dev_s *priv,
|
||||
|
||||
average_distance = average_distance + distance;
|
||||
}
|
||||
|
||||
vl53l1x_stopranging(priv);
|
||||
|
||||
average_distance = average_distance / 50;
|
||||
|
@ -310,6 +310,7 @@ XEN1210_HANDLE xen1210_instantiate(FAR struct spi_dev_s *dev,
|
||||
(FAR void *)priv);
|
||||
|
||||
/* Device initialization sequence */
|
||||
|
||||
/* Power off */
|
||||
|
||||
regval = (XEN1210_POWEROFF);
|
||||
@ -326,7 +327,7 @@ XEN1210_HANDLE xen1210_instantiate(FAR struct spi_dev_s *dev,
|
||||
/* Test */
|
||||
|
||||
regval = (XEN1210_TEST);
|
||||
regval |= 0x003A00;
|
||||
regval |= 0x003a00;
|
||||
|
||||
xen1210_putdata(priv, regval);
|
||||
|
||||
@ -421,13 +422,13 @@ void xen1210_getdata(FAR struct xen1210_dev_s *priv)
|
||||
/* Read three times 3 bytes = 24 bits * 3 */
|
||||
|
||||
SPI_RECVBLOCK(priv->spi, ®val, 3);
|
||||
priv->sample.data_x = regval & 0xFFFFFF;
|
||||
priv->sample.data_x = regval & 0xffffff;
|
||||
|
||||
SPI_RECVBLOCK(priv->spi, ®val, 3);
|
||||
priv->sample.data_y = regval & 0xFFFFFF;
|
||||
priv->sample.data_y = regval & 0xffffff;
|
||||
|
||||
SPI_RECVBLOCK(priv->spi, ®val, 3);
|
||||
priv->sample.data_z = regval & 0xFFFFFF;
|
||||
priv->sample.data_z = regval & 0xffffff;
|
||||
|
||||
/* Deselect the XEN1210 */
|
||||
|
||||
@ -472,6 +473,7 @@ void xen1210_putdata(FAR struct xen1210_dev_s *priv, uint32_t regval)
|
||||
SPI_SELECT(priv->spi, SPIDEV_ACCELEROMETER(0), true);
|
||||
|
||||
/* We need to write to 3 sensors in the daisy-chain */
|
||||
|
||||
/* Write three times 3 bytes */
|
||||
|
||||
(void)SPI_SNDBLOCK(priv->spi, ®val, 3);
|
||||
|
@ -77,7 +77,6 @@ struct zc_upperhalf_s
|
||||
*/
|
||||
|
||||
FAR struct zc_open_s *zu_open;
|
||||
|
||||
};
|
||||
|
||||
/* This structure describes the state of one open zero cross driver instance */
|
||||
|
Loading…
x
Reference in New Issue
Block a user