drivers/sensors: Run all sensor drivers through tools/nxstyle, correcting as many complaints as possible.

This commit is contained in:
Gregory Nutt 2019-12-06 19:07:34 -06:00
parent db6fe28fa6
commit d1584d60a2
53 changed files with 619 additions and 468 deletions

View File

@ -347,6 +347,7 @@ static int adt7320_open(FAR struct file *filep)
set_errno(ENODEV);
return -ENODEV;
}
return OK;
}

View File

@ -263,12 +263,15 @@ 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_y = adxl345_getreg8(priv, ADXL345_DATAY1);
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_x = adxl345_getreg8(priv, ADXL345_DATAX1);
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_z = adxl345_getreg8(priv, ADXL345_DATAZ1);
priv->sample.data_z = (priv->sample.data_z << 8) |
adxl345_getreg8(priv, ADXL345_DATAZ0);
}
/* Re-enable the ADXL345 GPIO interrupt */
@ -360,7 +363,7 @@ static void adxl345_reset(FAR struct adxl345_dev_s *priv)
/* Wait a bit to make the GOD of TIME happy */
nxsig_usleep(20*1000);
nxsig_usleep(20 * 1000);
}
/****************************************************************************

View File

@ -53,6 +53,10 @@
#if defined(CONFIG_SENSORS_ADXL345)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: adxl345_getreg8
*

View File

@ -266,10 +266,10 @@ static uint8_t adxl372_read_register(FAR struct adxl372_dev_s *dev,
* Name: adxl372_read_registerblk
******************************************************************************/
static void adxl372_read_registerblk(FAR struct adxl372_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
static void adxl372_read_registerblk(FAR struct adxl372_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
{
/* Lock the SPI bus so that only one device can access it at the same time */
@ -288,7 +288,7 @@ static uint8_t adxl372_read_register(FAR struct adxl372_dev_s *dev,
/* Write idle bytes while receiving the requested data */
while ( 0 != xfercnt-- )
while (0 != xfercnt--)
{
*reg_data++ = (uint8_t)SPI_SEND(dev->spi, 0xff);
}
@ -341,10 +341,10 @@ static void adxl372_write_register(FAR struct adxl372_dev_s *dev,
* Name: adxl372_write_registerblk
****************************************************************************/
static void adxl372_write_registerblk(FAR struct adxl372_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
static void adxl372_write_registerblk(FAR struct adxl372_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
{
/* Lock the SPI bus so that only one device can access it at the same time */
@ -363,7 +363,7 @@ static void adxl372_write_register(FAR struct adxl372_dev_s *dev,
/* Transmit the content which should be written in the register block */
while ( 0 != xfercnt-- )
while (0 != xfercnt--)
{
SPI_SEND(dev->spi, *reg_data++);
}
@ -408,7 +408,7 @@ static void adxl372_reset(FAR struct adxl372_dev_s *dev)
up_mdelay(5);
wdcnt = 10;
while (wdcnt>0 && (0 != adxl372_read_register(dev, ADXL372_RESET)))
while (wdcnt > 0 && (0 != adxl372_read_register(dev, ADXL372_RESET)))
{
up_mdelay(1);
}
@ -587,7 +587,7 @@ static ssize_t adxl372_dvr_read(FAR void *instance_handle, FAR char *buffer,
if (priv->seek_address == ADXL372_XDATA_H && buflen >= 6)
{
p1 = p2 = buffer;
for (i=0; i<3; i++)
for (i = 0; i < 3; i++)
{
un.d8[1] = *p1++;
un.d8[0] = *p1++;
@ -742,13 +742,13 @@ static void adxl372_dvr_exchange(FAR void *instance_handle,
/* Unlock the SPI bus */
SPI_LOCK(spi, false);
}
}
/****************************************************************************
* Name: adxl372_open
****************************************************************************/
static int adxl372_open(FAR struct file *filep)
static int adxl372_open(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct adxl372_dev_s *priv = inode->i_private;

View File

@ -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;
@ -333,7 +335,7 @@ void ak09912_delay_msek(uint16_t msek)
*
****************************************************************************/
static int ak09912_set_power_mode(FAR struct ak09912_dev_s* priv,
static int ak09912_set_power_mode(FAR struct ak09912_dev_s *priv,
uint32_t mode)
{
int ret = 0;
@ -350,8 +352,8 @@ static int ak09912_set_power_mode(FAR struct ak09912_dev_s* priv,
*
****************************************************************************/
static int ak09912_read_sensitivity_data(FAR struct ak09912_dev_s* priv,
FAR struct sensi_data_s* asa_data)
static int ak09912_read_sensitivity_data(FAR struct ak09912_dev_s *priv,
FAR struct sensi_data_s *asa_data)
{
int ret = 0;
uint8_t buffer[3];
@ -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;
}
@ -374,7 +377,7 @@ static int ak09912_read_sensitivity_data(FAR struct ak09912_dev_s* priv,
*
****************************************************************************/
static int ak09912_set_noice_suppr_flt(FAR struct ak09912_dev_s* priv,
static int ak09912_set_noice_suppr_flt(FAR struct ak09912_dev_s *priv,
uint32_t nsf)
{
int ret = 0;
@ -411,8 +414,8 @@ static void ak09912_wd_timeout(int argc, uint32_t arg, ...)
*
****************************************************************************/
static int ak09912_read_mag_uncomp_data(FAR struct ak09912_dev_s* priv,
FAR struct mag_data_s* mag_data)
static int ak09912_read_mag_uncomp_data(FAR struct ak09912_dev_s *priv,
FAR struct mag_data_s *mag_data)
{
int ret = 0;
uint8_t state = 0;
@ -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));
@ -443,8 +447,8 @@ static int ak09912_read_mag_uncomp_data(FAR struct ak09912_dev_s* priv,
*
****************************************************************************/
static int ak09912_read_mag_data(FAR struct ak09912_dev_s* priv,
FAR struct mag_data_s* mag_data)
static int ak09912_read_mag_data(FAR struct ak09912_dev_s *priv,
FAR struct mag_data_s *mag_data)
{
int ret = 0;
@ -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;
}
@ -569,10 +575,10 @@ static int ak09912_close(FAR struct file *filep)
static ssize_t ak09912_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct inode *inode = filep->f_inode;
FAR struct ak09912_dev_s *priv = inode->i_private;
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)
{

View File

@ -650,9 +650,9 @@ static bool apds9960_processgesture(FAR struct apds9960_dev_s *priv)
if (priv->gesture_data.total_gestures <= 4)
{
snerr("ERROR: We don't have enough gesture: %d\n",
priv->gesture_data.total_gestures);
return false;
snerr("ERROR: We don't have enough gesture: %d\n",
priv->gesture_data.total_gestures);
return false;
}
/* Check to make sure our data isn't out of bounds */
@ -711,144 +711,144 @@ static bool apds9960_processgesture(FAR struct apds9960_dev_s *priv)
}
}
/* Calculate the first vs. last ratio of up/down and left/right */
/* Calculate the first vs. last ratio of up/down and left/right */
ud_ratio_first = ((u_first - d_first) * 100) / (u_first + d_first);
lr_ratio_first = ((l_first - r_first) * 100) / (l_first + r_first);
ud_ratio_last = ((u_last - d_last) * 100) / (u_last + d_last);
lr_ratio_last = ((l_last - r_last) * 100) / (l_last + r_last);
ud_ratio_first = ((u_first - d_first) * 100) / (u_first + d_first);
lr_ratio_first = ((l_first - r_first) * 100) / (l_first + r_first);
ud_ratio_last = ((u_last - d_last) * 100) / (u_last + d_last);
lr_ratio_last = ((l_last - r_last) * 100) / (l_last + r_last);
sninfo("Last Values: \n");
sninfo("U: %03d\n", u_last);
sninfo("D: %03d\n", d_last);
sninfo("L: %03d\n", l_last);
sninfo("R: %03d\n", r_last);
sninfo("Last Values: \n");
sninfo("U: %03d\n", u_last);
sninfo("D: %03d\n", d_last);
sninfo("L: %03d\n", l_last);
sninfo("R: %03d\n", r_last);
sninfo("Ratios: \n");
sninfo("UD Fi: %03d\n", ud_ratio_first);
sninfo("UD La: %03d\n", ud_ratio_last);
sninfo("LR Fi: %03d\n", lr_ratio_first);
sninfo("LR La: %03d\n", lr_ratio_last);
sninfo("Ratios: \n");
sninfo("UD Fi: %03d\n", ud_ratio_first);
sninfo("UD La: %03d\n", ud_ratio_last);
sninfo("LR Fi: %03d\n", lr_ratio_first);
sninfo("LR La: %03d\n", lr_ratio_last);
/* Determine the difference between the first and last ratios */
/* Determine the difference between the first and last ratios */
ud_delta = ud_ratio_last - ud_ratio_first;
lr_delta = lr_ratio_last - lr_ratio_first;
ud_delta = ud_ratio_last - ud_ratio_first;
lr_delta = lr_ratio_last - lr_ratio_first;
sninfo("Deltas: \n");
sninfo("UD: %03d\n", ud_delta);
sninfo("LR: %03d\n", lr_delta);
sninfo("Deltas: \n");
sninfo("UD: %03d\n", ud_delta);
sninfo("LR: %03d\n", lr_delta);
/* Accumulate the UD and LR delta values */
/* Accumulate the UD and LR delta values */
priv->gesture_ud_delta += ud_delta;
priv->gesture_lr_delta += lr_delta;
priv->gesture_ud_delta += ud_delta;
priv->gesture_lr_delta += lr_delta;
sninfo("Accumulations: \n");
sninfo("UD: %03d\n", priv->gesture_ud_delta);
sninfo("LR: %03d\n", priv->gesture_lr_delta);
sninfo("Accumulations: \n");
sninfo("UD: %03d\n", priv->gesture_ud_delta);
sninfo("LR: %03d\n", priv->gesture_lr_delta);
/* Determine U/D gesture */
/* Determine U/D gesture */
if (priv->gesture_ud_delta >= GESTURE_SENSITIVITY_1)
{
priv->gesture_ud_count = 1;
}
else
{
if (priv->gesture_ud_delta <= -GESTURE_SENSITIVITY_1)
{
priv->gesture_ud_count = -1;
}
else
{
priv->gesture_ud_count = 0;
}
}
if (priv->gesture_ud_delta >= GESTURE_SENSITIVITY_1)
{
priv->gesture_ud_count = 1;
}
else
{
if (priv->gesture_ud_delta <= -GESTURE_SENSITIVITY_1)
{
priv->gesture_ud_count = -1;
}
else
{
priv->gesture_ud_count = 0;
}
}
/* Determine L/R gesture */
/* Determine L/R gesture */
if (priv->gesture_lr_delta >= GESTURE_SENSITIVITY_1)
{
priv->gesture_lr_count = 1;
}
else
{
if (priv->gesture_lr_delta <= -GESTURE_SENSITIVITY_1)
{
priv->gesture_lr_count = -1;
}
else
{
priv->gesture_lr_count = 0;
}
}
if (priv->gesture_lr_delta >= GESTURE_SENSITIVITY_1)
{
priv->gesture_lr_count = 1;
}
else
{
if (priv->gesture_lr_delta <= -GESTURE_SENSITIVITY_1)
{
priv->gesture_lr_count = -1;
}
else
{
priv->gesture_lr_count = 0;
}
}
/* Determine Near/Far gesture */
/* Determine Near/Far gesture */
if ((priv->gesture_ud_count == 0) && (priv->gesture_lr_count == 0))
{
if ((abs(ud_delta) < GESTURE_SENSITIVITY_2) && \
(abs(lr_delta) < GESTURE_SENSITIVITY_2))
{
if ((ud_delta == 0) && (lr_delta == 0))
{
priv->gesture_near_count++;
}
else
{
if ((ud_delta != 0) || (lr_delta != 0))
{
priv->gesture_far_count++;
}
}
if ((priv->gesture_ud_count == 0) && (priv->gesture_lr_count == 0))
{
if ((abs(ud_delta) < GESTURE_SENSITIVITY_2) && \
(abs(lr_delta) < GESTURE_SENSITIVITY_2))
{
if ((ud_delta == 0) && (lr_delta == 0))
{
priv->gesture_near_count++;
}
else
{
if ((ud_delta != 0) || (lr_delta != 0))
{
priv->gesture_far_count++;
}
}
if ((priv->gesture_near_count >= 10) && \
(priv->gesture_far_count >= 2))
{
if ((ud_delta == 0) && (lr_delta == 0))
{
priv->gesture_state = NEAR_STATE;
}
else
{
if ((ud_delta != 0) && (lr_delta != 0))
{
priv->gesture_state = FAR_STATE;
}
}
if ((priv->gesture_near_count >= 10) && \
(priv->gesture_far_count >= 2))
{
if ((ud_delta == 0) && (lr_delta == 0))
{
priv->gesture_state = NEAR_STATE;
}
else
{
if ((ud_delta != 0) && (lr_delta != 0))
{
priv->gesture_state = FAR_STATE;
}
}
return true;
}
}
}
else
{
if ((abs(ud_delta) < GESTURE_SENSITIVITY_2) && \
(abs(lr_delta) < GESTURE_SENSITIVITY_2))
{
if ((ud_delta == 0) && (lr_delta == 0))
{
priv->gesture_near_count++;
}
return true;
}
}
}
else
{
if ((abs(ud_delta) < GESTURE_SENSITIVITY_2) && \
(abs(lr_delta) < GESTURE_SENSITIVITY_2))
{
if ((ud_delta == 0) && (lr_delta == 0))
{
priv->gesture_near_count++;
}
if (priv->gesture_near_count >= 10)
{
priv->gesture_ud_count = 0;
priv->gesture_lr_count = 0;
priv->gesture_ud_delta = 0;
priv->gesture_lr_delta = 0;
}
}
}
if (priv->gesture_near_count >= 10)
{
priv->gesture_ud_count = 0;
priv->gesture_lr_count = 0;
priv->gesture_ud_delta = 0;
priv->gesture_lr_delta = 0;
}
}
}
sninfo(" UD_CT: %03d\n", priv->gesture_ud_count);
sninfo(" LR_CT: %03d\n", priv->gesture_lr_count);
sninfo(" NEAR_CT: %03d\n", priv->gesture_near_count);
sninfo(" FAR_CT: %03d\n", priv->gesture_far_count);
sninfo("----------------------\n");
sninfo(" UD_CT: %03d\n", priv->gesture_ud_count);
sninfo(" LR_CT: %03d\n", priv->gesture_lr_count);
sninfo(" NEAR_CT: %03d\n", priv->gesture_near_count);
sninfo(" FAR_CT: %03d\n", priv->gesture_far_count);
sninfo("----------------------\n");
return false;
return false;
}
/****************************************************************************
@ -1051,8 +1051,8 @@ static int apds9960_readgesture(FAR struct apds9960_dev_s *priv)
for (i = 0; i < fifo_level; i++)
{
sninfo("U: %03d | D: %03d | L: %03d | R: %03d\n",
fifo_data[i], fifo_data[i+1],
fifo_data[i+2], fifo_data[i+3]);
fifo_data[i], fifo_data[i + 1],
fifo_data[i + 2], fifo_data[i + 3]);
}
sninfo("\n");
@ -1085,7 +1085,7 @@ static int apds9960_readgesture(FAR struct apds9960_dev_s *priv)
{
if (apds9960_decodegesture(priv))
{
/* TODO: U-Turn Gestures */
/* TODO: U-Turn Gestures */
}
}

View File

@ -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 */

View File

@ -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;
@ -295,7 +296,7 @@ static void as726x_write8(FAR struct as726x_dev_s *priv, uint8_t regaddr,
status = read_register(priv, AS72XX_SLAVE_STATUS_REG);
if ((status & AS72XX_SLAVE_TX_VALID) == 0)
{
/* No inbound TX pending at slave. Okay to write now. */
/* No inbound TX pending at slave. Okay to write now. */
break;
}
@ -441,7 +442,7 @@ int as726x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c)
priv->i2c = i2c;
priv->addr = AS726X_I2C_ADDR;
/* Check HW version for AS7262 and AS7263 */
/* Check HW version for AS7262 and AS7263 */
_sensor_version = as726x_read8(priv, AS726x_HW_VERSION);
if (_sensor_version != 0x3e && _sensor_version != 0x3f)

View File

@ -149,7 +149,7 @@ static int bh1750fvi_read16(FAR struct bh1750fvi_dev_s *priv,
/* Copy the content of the buffer to the location of the uint16_t pointer */
*regval = (uint16_t)((buffer[0]<<8) | (buffer[1]));
*regval = (uint16_t)((buffer[0] << 8) | (buffer[1]));
sninfo("value: %08x ret: %d\n", *regval, ret);
return OK;
@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -384,12 +384,12 @@ static int bmp280_initialize(FAR struct bmp280_dev_s *priv)
return ret;
}
priv->calib.t1 = (uint16_t)buf[1] << 8 | buf[0];
priv->calib.t2 = (int16_t) buf[3] << 8 | buf[2];
priv->calib.t3 = (int16_t) buf[5] << 8 | buf[4];
priv->calib.t1 = (uint16_t)buf[1] << 8 | buf[0];
priv->calib.t2 = (int16_t) buf[3] << 8 | buf[2];
priv->calib.t3 = (int16_t) buf[5] << 8 | buf[4];
priv->calib.p1 = (uint16_t)buf[ 7] << 8 | buf[ 6];
priv->calib.p2 = (int16_t) buf[ 9] << 8 | buf[ 8];
priv->calib.p1 = (uint16_t)buf[7] << 8 | buf[6];
priv->calib.p2 = (int16_t) buf[9] << 8 | buf[8];
priv->calib.p3 = (int16_t) buf[11] << 8 | buf[10];
priv->calib.p4 = (int16_t) buf[13] << 8 | buf[12];
priv->calib.p5 = (int16_t) buf[15] << 8 | buf[14];
@ -486,10 +486,10 @@ static uint32_t bmp280_compensate_press(FAR struct bmp280_dev_s *priv,
(void) bmp280_compensate_temp(priv, temp);
var1 = (priv->tempfine >> 1) - 64000;
var2 = (((var1 >> 2) * (var1 >> 2)) >> 11 ) * ((int32_t)c->p6);
var2 = (((var1 >> 2) * (var1 >> 2)) >> 11) * ((int32_t)c->p6);
var2 = var2 + ((var1 * ((int32_t)c->p5)) << 1);
var2 = (var2 >> 2) + (((int32_t)c->p4) << 16);
var1 = (((c->p3 * (((var1 >> 2) * (var1 >> 2)) >> 13 )) >> 3) +
var1 = (((c->p3 * (((var1 >> 2) * (var1 >> 2)) >> 13)) >> 3) +
((((int32_t)c->p2) * var1) >> 1)) >> 18;
var1 = (((32768 + var1) * ((int32_t)c->p1)) >> 15);

View File

@ -108,7 +108,7 @@ static bool dht_verify_checksum(FAR struct dhtxx_dev_s *priv);
static bool dht_check_data(FAR struct dhtxx_sensor_data_s *data,
float min_hum, float max_hum,
float min_temp, float max_temp);
static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
FAR struct dhtxx_sensor_data_s *data);
/* Character driver methods */
@ -119,7 +119,7 @@ static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t dhtxx_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int dhtxx_ioctl(FAR struct file *filep, int cmd,
static int dhtxx_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
/****************************************************************************
@ -155,7 +155,7 @@ static const struct file_operations g_dhtxxfops =
static void dht_standby_mode(FAR struct dhtxx_dev_s *priv)
{
priv->config->config_data_pin(priv->config, false);
priv->config->set_data_pin(priv->config, true);
priv->config->set_data_pin(priv->config, true);
}
/****************************************************************************
@ -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. */
@ -312,8 +313,8 @@ 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;
sum = (priv->raw_data[0] + priv->raw_data[1] +
priv->raw_data[2] + priv->raw_data[3]) & 0xffu;
return (sum == priv->raw_data[4]);
}
@ -351,7 +352,7 @@ static bool dht_check_data(FAR struct dhtxx_sensor_data_s *data,
*
****************************************************************************/
static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
FAR struct dhtxx_sensor_data_s *data)
{
int ret = OK;
@ -371,14 +372,14 @@ static int dht_parse_data(FAR struct dhtxx_dev_s *priv,
{
ret = -1;
}
break;
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;
}
@ -467,15 +468,15 @@ static int dhtxx_close(FAR struct file *filep)
* Name: dhtxx_read
****************************************************************************/
static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer,
static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
int ret;
FAR struct inode *inode = filep->f_inode;
FAR struct dhtxx_dev_s *priv = inode->i_private;
FAR struct dhtxx_sensor_data_s *data =
FAR struct dhtxx_sensor_data_s *data =
(FAR struct dhtxx_sensor_data_s *)buffer;
if (!buffer)
{
snerr("ERROR: Buffer is null.\n");
@ -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 */

View File

@ -91,8 +91,8 @@ struct hcsr04_dev_s
};
/****************************************************************************
* Private Data
****************************************************************************/
* Private Data
****************************************************************************/
static const struct file_operations g_hcsr04ops =
{
@ -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

View File

@ -119,8 +119,8 @@
#define HTS221_I2C_RETRIES 10
/****************************************************************************
* Private Function Prototypes
*****************************************************************************/
* Private Function Prototypes
*****************************************************************************/
static int hts221_open(FAR struct file *filep);
static int hts221_close(FAR struct file *filep);
@ -133,8 +133,8 @@ static int hts221_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
/****************************************************************************
* Private Types
****************************************************************************/
* Private Types
****************************************************************************/
struct hts221_dev_s
{
@ -158,8 +158,8 @@ struct hts221_dev_s
};
/****************************************************************************
* Private Data
****************************************************************************/
* Private Data
****************************************************************************/
static const struct file_operations g_humidityops =
{
@ -176,8 +176,8 @@ static const struct file_operations g_humidityops =
};
/****************************************************************************
* Private Functions
****************************************************************************/
* Private Functions
****************************************************************************/
static int hts221_do_transfer(FAR struct hts221_dev_s *priv,
FAR struct i2c_msg_s *msgv,
@ -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, &regval);
@ -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, &regval);
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, &regval);
hts221_dbg("CTRL_REG%d: 0x%02X\n", 1, regval);
@ -434,8 +449,8 @@ static int hts221_config_ctrl_reg1(FAR struct hts221_dev_s *priv,
}
regval &= ~mask;
regval |= (uint8_t) (settings->odr & 0xFF);
regval |= (uint8_t) (settings->is_bdu ? HTS221_CTRL_REG1_BDU : 0);
regval |= (uint8_t)(settings->odr & 0xff);
regval |= (uint8_t)(settings->is_bdu ? HTS221_CTRL_REG1_BDU : 0);
data_to_write[0] = addr;
data_to_write[1] = regval;
@ -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;
@ -1064,9 +1080,9 @@ static bool hts221_sample(FAR struct hts221_dev_s *priv)
ret = hts221_check_status(priv, &status);
if (ret < 0)
{
return false;
}
{
return false;
}
return status.is_humid_ready || status.is_temp_ready;
}

View File

@ -145,7 +145,7 @@ static const struct file_operations g_ina219fops =
static int ina219_access(FAR struct ina219_dev_s *priv,
uint8_t start_register_address, bool reading,
FAR uint8_t* register_value, uint8_t data_length)
FAR uint8_t *register_value, uint8_t data_length)
{
struct i2c_msg_s msg[I2C_NOSTARTSTOP_MSGS];
int ret;
@ -167,13 +167,13 @@ 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;
}
static int ina219_read16(FAR struct ina219_dev_s *priv, uint8_t regaddr,
FAR uint16_t* regvalue)
FAR uint16_t *regvalue)
{
uint8_t buf[2];
@ -222,10 +222,10 @@ static int ina219_readpower(FAR struct ina219_dev_s *priv,
ret = ina219_read16(priv, INA219_REG_BUS_VOLTAGE, &reg);
if (ret < 0)
{
snerr("ERROR: ina219_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ina219_read16 failed: %d\n", ret);
return ret;
}
/* Convert register value to bus voltage */
@ -236,10 +236,10 @@ static int ina219_readpower(FAR struct ina219_dev_s *priv,
ret = ina219_read16(priv, INA219_REG_SHUNT_VOLTAGE, &reg);
if (ret < 0)
{
snerr("ERROR: ina219_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ina219_read16 failed: %d\n", ret);
return ret;
}
/* Convert register value to shunt voltage */

View File

@ -128,7 +128,7 @@ static const struct file_operations g_ina226fops =
static int ina226_access(FAR struct ina226_dev_s *priv,
uint8_t start_register_address, bool reading,
FAR uint8_t* register_value, uint8_t data_length)
FAR uint8_t *register_value, uint8_t data_length)
{
struct i2c_msg_s msg[I2C_NOSTARTSTOP_MSGS];
int ret;
@ -150,13 +150,13 @@ 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;
}
static int ina226_read16(FAR struct ina226_dev_s *priv, uint8_t regaddr,
FAR uint16_t* regvalue)
FAR uint16_t *regvalue)
{
uint8_t buf[2];
@ -205,10 +205,10 @@ static int ina226_readpower(FAR struct ina226_dev_s *priv,
ret = ina226_read16(priv, INA226_REG_BUS_VOLTAGE, &reg);
if (ret < 0)
{
snerr("ERROR: ina226_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ina226_read16 failed: %d\n", ret);
return ret;
}
/* Convert register value to bus voltage */
@ -218,10 +218,10 @@ static int ina226_readpower(FAR struct ina226_dev_s *priv,
ret = ina226_read16(priv, INA226_REG_SHUNT_VOLTAGE, &reg);
if (ret < 0)
{
snerr("ERROR: ina226_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ina226_read16 failed: %d\n", ret);
return ret;
}
tmp = ((int64_t)(int16_t)reg);
@ -229,9 +229,9 @@ static int ina226_readpower(FAR struct ina226_dev_s *priv,
* I(uA) = U(uV)/R(ohms)
* = U(uV)/(R(uohms)/1000000)
* = U(uV) * 1000000 / R(uohms)
*
*
* U(uV) = tmp*2,5
*
*
* We use a temporary 64-bit accumulator to avoid overflows.
*/
@ -394,10 +394,10 @@ int ina226_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
ret = ina226_write16(priv, INA226_REG_CONFIG,
priv->config | INA226_CONFIG_MODE_PWRDOWN);
if (ret < 0)
{
snerr("ERROR: Failed to apply config: %d\n", ret);
goto errout;
}
{
snerr("ERROR: Failed to apply config: %d\n", ret);
goto errout;
}
/* Register the character driver */

View File

@ -155,7 +155,7 @@ static const struct file_operations g_ina3221fops =
static int ina3221_access(FAR struct ina3221_dev_s *priv,
uint8_t start_register_address, bool reading,
FAR uint8_t* register_value, uint8_t data_length)
FAR uint8_t *register_value, uint8_t data_length)
{
struct i2c_msg_s msg[I2C_NOSTARTSTOP_MSGS];
int ret;
@ -177,13 +177,13 @@ 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;
}
static int ina3221_read16(FAR struct ina3221_dev_s *priv, uint8_t regaddr,
FAR uint16_t* regvalue)
FAR uint16_t *regvalue)
{
uint8_t buf[2];
@ -241,10 +241,10 @@ static int ina3221_readpower(FAR struct ina3221_dev_s *priv,
ret = ina3221_read16(priv, (INA3221_REG_CH1_BUS_VOLTAGE + i * 2),
&reg);
if (ret < 0)
{
snerr("ERROR: ina3221_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ina3221_read16 failed: %d\n", ret);
return ret;
}
/* Convert register value to bus voltage */
@ -258,10 +258,10 @@ static int ina3221_readpower(FAR struct ina3221_dev_s *priv,
ret = ina3221_read16(priv, (INA3221_REG_CH1_SHUNT_VOLTAGE + i * 2),
&reg);
if (ret < 0)
{
snerr("ERROR: ina3221_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ina3221_read16 failed: %d\n", ret);
return ret;
}
/* Convert register value to shunt voltage */
@ -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'

View File

@ -145,6 +145,7 @@ static const struct file_operations g_isl29023fops =
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: isl29023_i2c_write
*

View File

@ -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)

View File

@ -308,8 +308,8 @@ static void l3gd20_read_gyroscope_data(FAR struct l3gd20_dev_s *dev,
* Name: l3gd20_read_temperature
****************************************************************************/
static void l3gd20_read_temperature(FAR struct l3gd20_dev_s* dev,
uint8_t* temperature)
static void l3gd20_read_temperature(FAR struct l3gd20_dev_s *dev,
FAR uint8_t *temperature)
{
/* Lock the SPI bus so that only one device can access it at the same time */
@ -342,7 +342,7 @@ static void l3gd20_read_temperature(FAR struct l3gd20_dev_s* dev,
* Name: l3gd20_interrupt_handler
****************************************************************************/
static int l3gd20_interrupt_handler(int irq, FAR void* context)
static int l3gd20_interrupt_handler(int irq, FAR void *context)
{
/* This function should be called upon a rising edge on the L3GD20 new data
* interrupt pin since it signals that new data has been measured.
@ -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;

View File

@ -100,19 +100,19 @@ enum interrupts
struct lis2dh_dev_s
{
FAR struct i2c_master_s *i2c; /* I2C interface */
uint8_t addr; /* I2C address */
FAR struct lis2dh_config_s *config; /* Platform specific configuration */
struct lis2dh_setup *setup; /* User defined device operation mode setup */
struct lis2dh_vector_s vector_data; /* Latest read data read from lis2dh */
int scale; /* Full scale in milliG */
sem_t devsem; /* Manages exclusive access to this structure */
bool fifo_used; /* LIS2DH configured to use FIFO */
bool fifo_stopped;/* FIFO got full and has stopped. */
FAR struct i2c_master_s *i2c; /* I2C interface */
uint8_t addr; /* I2C address */
FAR struct lis2dh_config_s *config; /* Platform specific configuration */
struct lis2dh_setup *setup; /* User defined device operation mode setup */
struct lis2dh_vector_s vector_data; /* Latest read data read from lis2dh */
int scale; /* Full scale in milliG */
sem_t devsem; /* Manages exclusive access to this structure */
bool fifo_used; /* LIS2DH configured to use FIFO */
bool fifo_stopped; /* FIFO got full and has stopped. */
#ifdef LIS2DH_COUNT_INTS
volatile int16_t int_pending; /* Interrupt received but data not read, yet */
volatile int16_t int_pending; /* Interrupt received but data not read, yet */
#else
volatile bool int_pending; /* Interrupt received but data not read, yet */
volatile bool int_pending; /* Interrupt received but data not read, yet */
#endif
struct pollfd *fds[CONFIG_LIS2DH_NPOLLWAITERS];
};
@ -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;
}
@ -310,10 +312,11 @@ static int lis2dh_fifo_start(FAR struct lis2dh_dev_s *priv)
static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
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);
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);
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,10 +1853,14 @@ 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 |
dev->setup->int1_int_x_low_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)
{
goto error;
@ -1860,10 +1884,14 @@ 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 |
dev->setup->int2_int_x_low_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)
{
goto error;
@ -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;

View File

@ -185,25 +185,25 @@ static int lis331dl_access(FAR struct lis331dl_dev_s *dev, uint8_t subaddr,
subaddr |= 0x80;
}
/* Create message and send */
/* Create message and send */
struct i2c_msg_s msgv[2] =
struct i2c_msg_s msgv[2] =
{
{
{
.frequency = CONFIG_LIS331DL_I2C_FREQUENCY,
.addr = dev->address,
.flags = 0,
.buffer = &subaddr,
.length = 1
},
{
.frequency = CONFIG_LIS331DL_I2C_FREQUENCY,
.addr = dev->address,
.flags = flags,
.buffer = buf,
.length = length
}
};
.frequency = CONFIG_LIS331DL_I2C_FREQUENCY,
.addr = dev->address,
.flags = 0,
.buffer = &subaddr,
.length = 1
},
{
.frequency = CONFIG_LIS331DL_I2C_FREQUENCY,
.addr = dev->address,
.flags = flags,
.buffer = buf,
.length = length
}
};
retval = I2C_TRANSFER(dev->i2c, msgv, 2);
if (retval >= 0)
@ -326,9 +326,9 @@ int lis331dl_powerdown(FAR struct lis331dl_dev_s * dev)
dev->cr3 = 0;
if (lis331dl_access(dev, ST_LIS331DL_CTRL_REG1, &dev->cr1, -3) == 3)
{
return OK;
}
{
return OK;
}
return ERROR;
}
@ -359,10 +359,10 @@ int lis331dl_getprecision(FAR struct lis331dl_dev_s * dev)
{
if (dev->cr1 & ST_LIS331DL_CR1_FS)
{
return 9200/127; /* typ. 9.2g full scale */
return 9200 / 127; /* typ. 9.2g full scale */
}
return 2300/127; /* typ. 2.3g full scale */
return 2300 / 127; /* typ. 2.3g full scale */
}
/****************************************************************************

View File

@ -406,10 +406,10 @@ 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);
SPI_EXCHANGE(dev->spi, dev->fifobuf, dev->fifobuf, 1 + count * 6);
SPI_SELECT(dev->spi, dev->config->spi_devid, false);
/* Unlock the SPI bus */
@ -427,14 +427,14 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
int16_t y_acc;
int16_t z_acc;
x_raw = (uint16_t)dev->fifobuf[(i*6)+1] |
(uint16_t)dev->fifobuf[(i*6)+2] << 8;
x_raw = (uint16_t)dev->fifobuf[(i * 6) + 1] |
(uint16_t)dev->fifobuf[(i * 6) + 2] << 8;
y_raw = (uint16_t)dev->fifobuf[(i*6)+3] |
(uint16_t)dev->fifobuf[(i*6)+4] << 8;
y_raw = (uint16_t)dev->fifobuf[(i * 6) + 3] |
(uint16_t)dev->fifobuf[(i * 6) + 4] << 8;
z_raw = (uint16_t)dev->fifobuf[(i*6)+5] |
(uint16_t)dev->fifobuf[(i*6)+6] << 8;
z_raw = (uint16_t)dev->fifobuf[(i * 6) + 5] |
(uint16_t)dev->fifobuf[(i * 6) + 6] << 8;
/* The sensor left justifies the data in the register, so we must
* shift it to the right depending on the selected power mode
@ -875,9 +875,8 @@ static ssize_t lis3dh_read(FAR struct file *filep, FAR char *buffer,
data = (FAR struct lis3dh_sensor_data_s *)buffer;
for (remain=count;remain > 0;remain--)
for (remain = count; remain > 0; remain--)
{
/* Wait for data to be available in the queue */
nxsem_wait(&priv->readsem);

View File

@ -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,

View File

@ -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;

View File

@ -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

View File

@ -82,6 +82,7 @@ struct lm92_dev_s
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* I2C Helpers */
static int lm92_i2c_write(FAR struct lm92_dev_s *priv,

View File

@ -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;
}
@ -620,7 +622,7 @@ static int lps25h_one_shot(FAR struct lps25h_dev_s *dev)
if (ret != OK)
{
return -ETIMEDOUT;
return -ETIMEDOUT;
}
flags = enter_critical_section();

View File

@ -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)
{

View File

@ -246,9 +246,9 @@ static struct lsm330_reg_pair_s g_default_lsm330_aclcr_values[] =
/* 0000=Off 0 0 0 0=all disabled */
{
.addr = LSM330_ACL_CTRL_REG5,
.value = 0x00
},
.addr = LSM330_ACL_CTRL_REG5,
.value = 0x00
},
/* CR6 BW[2:1] FSCALE[2:0] - - SIM */
/* 00=800Hz 10 0=16g 0 0 0=4-wire */
@ -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] */
@ -401,12 +401,11 @@ static uint8_t lsm330_read_register(FAR struct lsm330_dev_s *dev,
* Name: lsm330_read_acl_registerblk
******************************************************************************/
static void lsm330_read_acl_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
static void lsm330_read_acl_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
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);
@ -426,7 +425,7 @@ static uint8_t lsm330_read_register(FAR struct lsm330_dev_s *dev,
/* Write idle bytes while receiving the requested data */
while ( 0 != xfercnt-- )
while (0 != xfercnt--)
{
*reg_data++ = (uint8_t)SPI_SEND(dev->spi, 0xff);
}
@ -444,10 +443,10 @@ static uint8_t lsm330_read_register(FAR struct lsm330_dev_s *dev,
* Name: lsm330_read_gyro_registerblk
******************************************************************************/
static void lsm330_read_gyro_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
static void lsm330_read_gyro_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
{
/* Lock the SPI bus so that only one device can access it at the same time */
@ -464,11 +463,12 @@ 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 */
while ( 0 != xfercnt-- )
while (0 != xfercnt--)
{
*reg_data++ = (uint8_t)SPI_SEND(dev->spi, 0xff);
}
@ -524,10 +524,10 @@ static void lsm330_write_register(FAR struct lsm330_dev_s *dev,
* Name: lsm330_write_acl_registerblk
****************************************************************************/
static void lsm330_write_acl_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
static void lsm330_write_acl_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
{
/* Lock the SPI bus so that only one device can access it at the same time */
@ -548,7 +548,7 @@ static void lsm330_write_register(FAR struct lsm330_dev_s *dev,
/* Transmit the content which should be written in the register block */
while ( 0 != xfercnt-- )
while (0 != xfercnt--)
{
SPI_SEND(dev->spi, *reg_data++);
}
@ -566,10 +566,10 @@ static void lsm330_write_register(FAR struct lsm330_dev_s *dev,
* Name: lsm330_write_gyro_registerblk
****************************************************************************/
static void lsm330_write_gyro_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
static void lsm330_write_gyro_registerblk(FAR struct lsm330_dev_s *dev,
uint8_t reg_addr,
FAR uint8_t *reg_data,
uint8_t xfercnt)
{
/* Lock the SPI bus so that only one device can access it at the same time */
@ -586,11 +586,12 @@ 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 */
while ( 0 != xfercnt-- )
while (0 != xfercnt--)
{
SPI_SEND(dev->spi, *reg_data++);
}
@ -682,7 +683,7 @@ static int lsm330acl_dvr_open(FAR void *instance_handle, int32_t arg)
sninfo("LSM330_ACL_IDREG = 0x%02x\n", reg_content);
if (reg_content!=LSM330_ACL_IDREG_VALUE)
if (reg_content != LSM330_ACL_IDREG_VALUE)
{
/* Made info log level to permit open being used as a device probe. */
@ -776,7 +777,7 @@ static int lsm330gyro_dvr_open(FAR void *instance_handle, int32_t arg)
sninfo("LSM330_GYRO_IDREG = 0x%02x\n", reg_content);
if (reg_content!=LSM330_GYRO_IDREG_VALUE)
if (reg_content != LSM330_GYRO_IDREG_VALUE)
{
/* Made warning log level to permit open being used as a device probe. */

View File

@ -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);
}

View File

@ -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,

View File

@ -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
@ -118,7 +121,7 @@ static const struct file_operations g_ltc4151fops =
static int ltc4151_read_reg(FAR struct ltc4151_dev_s *priv,
uint8_t start_register_address,
FAR uint8_t* register_value, uint8_t data_length)
FAR uint8_t *register_value, uint8_t data_length)
{
struct i2c_msg_s msg[I2C_NOSTARTSTOP_MSGS];
int ret;
@ -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)
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 */
@ -175,17 +178,17 @@ static int ltc4151_readpower(FAR struct ltc4151_dev_s *priv,
ret = ltc4151_read16(priv, LTC4151_CURR_REG, &current_reg);
if (ret < 0)
{
snerr("ERROR: ltc4151_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ltc4151_read16 failed: %d\n", ret);
return ret;
}
ret = ltc4151_read16(priv, LTC4151_VOLT_REG, &volt_reg);
if (ret < 0)
{
snerr("ERROR: ltc4151_read16 failed: %d\n", ret);
return ret;
}
{
snerr("ERROR: ltc4151_read16 failed: %d\n", ret);
return ret;
}
/* Current is passed as delta voltage, to get the current divide it by the
* used resistors resistance.

View File

@ -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);

View File

@ -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;
}

View File

@ -37,7 +37,7 @@
/* NOTE: Some Maxim MAX6675 chips have an issue it report value 25% lower
* of real temperature, for more info read this thread:
* http://www.eevblog.com/forum/projects/max6675-temperature-error/
*/
*/
/****************************************************************************
* Included Files
@ -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);

View File

@ -76,6 +76,7 @@ struct mb7040_dev_s
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* I2C Helpers */
static int mb7040_measurerange(FAR struct mb7040_dev_s *priv);

View File

@ -154,7 +154,7 @@ static int mcp9844_read_u16(FAR struct mcp9844_dev_s *priv,
/* Copy the content of the buffer to the location of the uint16_t pointer */
*value = (((uint16_t)(buffer[0]))<<8) + ((uint16_t)(buffer[1]));
*value = (((uint16_t)(buffer[0])) << 8) + ((uint16_t)(buffer[1]));
sninfo("addr: %02x value: %08x ret: %d\n", regaddr, *value, ret);
return OK;
@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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:
@ -492,7 +494,7 @@ static int ms58xx_setosr(FAR struct ms58xx_dev_s *priv, uint16_t osr)
{
case MS58XX_MODEL_MS5805_02:
case MS58XX_MODEL_MS5837_30:
ret = ms58xx_setosr_1(priv,osr);
ret = ms58xx_setosr_1(priv, osr);
break;
case MS58XX_MODEL_MS5803_02:
@ -501,7 +503,7 @@ static int ms58xx_setosr(FAR struct ms58xx_dev_s *priv, uint16_t osr)
case MS58XX_MODEL_MS5803_14:
case MS58XX_MODEL_MS5803_30:
case MS58XX_MODEL_MS5806_02:
ret = ms58xx_setosr_2(priv,osr);
ret = ms58xx_setosr_2(priv, osr);
break;
default:
@ -535,7 +537,7 @@ static int ms58xx_readprom(FAR struct ms58xx_dev_s *priv)
{
case MS58XX_MODEL_MS5805_02:
case MS58XX_MODEL_MS5837_30:
prom[MS58XX_PROM_LEN-1] = 0;
prom[MS58XX_PROM_LEN - 1] = 0;
len--;
crcindex = 0;
crcshift = 12;

View File

@ -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);
/****************************************************************************

View File

@ -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 */

View File

@ -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 */

View File

@ -99,6 +99,7 @@ struct sht21_dev_s
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* I2C Helpers */
static int sht21_access(FAR struct sht21_dev_s *priv,

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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, &regval, 3);
priv->sample.data_x = regval & 0xFFFFFF;
priv->sample.data_x = regval & 0xffffff;
SPI_RECVBLOCK(priv->spi, &regval, 3);
priv->sample.data_y = regval & 0xFFFFFF;
priv->sample.data_y = regval & 0xffffff;
SPI_RECVBLOCK(priv->spi, &regval, 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, &regval, 3);

View File

@ -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 */