Trivial changes from review of last PR.

This commit is contained in:
Gregory Nutt 2018-02-13 13:08:38 -06:00
parent e79e2e2d97
commit e07f12954c
2 changed files with 58 additions and 58 deletions

View File

@ -93,10 +93,10 @@ struct lis3dh_sample_s
****************************************************************************/
static void lis3dh_read_register(FAR struct lis3dh_dev_s *dev,
uint8_t const reg_addr, uint8_t *reg_data);
uint8_t const reg_addr, uint8_t *reg_data);
static void lis3dh_write_register(FAR struct lis3dh_dev_s *dev,
uint8_t const reg_addr,
uint8_t const reg_data);
uint8_t const reg_addr,
uint8_t const reg_data);
static void lis3dh_reset(FAR struct lis3dh_dev_s *dev);
static int lis3dh_ident(FAR struct lis3dh_dev_s *dev);
static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev);
@ -108,9 +108,9 @@ static int lis3dh_fifo_enable(FAR struct lis3dh_dev_s *dev);
static int lis3dh_open(FAR struct file *filep);
static int lis3dh_close(FAR struct file *filep);
static ssize_t lis3dh_read(FAR struct file *, FAR char *buffer,
size_t buflen);
size_t buflen);
static ssize_t lis3dh_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
size_t buflen);
static int lis3dh_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
/****************************************************************************
@ -133,10 +133,6 @@ static const struct file_operations g_lis3dh_fops =
#endif
};
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
@ -188,15 +184,15 @@ static void lis3dh_read_register(FAR struct lis3dh_dev_s *dev,
* Write a single register to the LIS3DH sensor.
*
* Input Parameters:
* dev - Pointer to device driver instance
* dev - Pointer to device driver instance
* reg_addr - LIS3DH register address
* reg_data - Value to write into the specified register address
*
****************************************************************************/
static void lis3dh_write_register(FAR struct lis3dh_dev_s *dev,
uint8_t const reg_addr,
uint8_t const reg_data)
uint8_t const reg_addr,
uint8_t const reg_data)
{
uint8_t buffer[2];
@ -258,14 +254,14 @@ static int lis3dh_ident(FAR struct lis3dh_dev_s *dev)
uint8_t reg;
lis3dh_read_register(dev, LIS3DH_WHO_AM_I, &reg);
if(reg == LIS3DH_DEVICE_ID)
if (reg == LIS3DH_DEVICE_ID)
{
return OK;
}
return -ENODEV;
}
/****************************************************************************
* Name: lis3dh_queue_lock
*
@ -320,7 +316,7 @@ static int lis3dh_queue_push(FAR struct lis3dh_dev_s *dev,
struct lis3dh_sensor_data_s *data)
{
lis3dh_queue_lock(dev);
if(dev->queue_count >= LIS3DH_QUEUE_MAX)
if (dev->queue_count >= LIS3DH_QUEUE_MAX)
{
lis3dh_queue_unlock(dev);
return -ENOMEM;
@ -354,7 +350,7 @@ static int lis3dh_queue_pop(FAR struct lis3dh_dev_s *dev,
struct lis3dh_sensor_data_s *data)
{
lis3dh_queue_lock(dev);
if(dev->queue_count == 0)
if (dev->queue_count == 0)
{
lis3dh_queue_unlock(dev);
return -EAGAIN;
@ -406,7 +402,7 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
count = fifosrc & 0x1f;
if(fifosrc & LIS3DH_FIFO_SRC_REG_OVRN_FIFO)
if (fifosrc & LIS3DH_FIFO_SRC_REG_OVRN_FIFO)
{
snerr("FIFO overrun\n");
}
@ -422,7 +418,7 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
SPI_LOCK(dev->spi, false);
for(i=0;i<count;i++)
for (i = 0; i < count; i++)
{
struct lis3dh_sensor_data_s data;
uint16_t x_raw;
@ -446,7 +442,7 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
* shift it to the right depending on the selected power mode
*/
switch(dev->power_mode)
switch (dev->power_mode)
{
case LIS3DH_POWER_LOW: /* 8 bit measurements */
x_acc = (int16_t)x_raw >> 8;
@ -456,8 +452,8 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
data.x_acc = (float)x_acc * 0.016;
data.y_acc = (float)y_acc * 0.016;
data.z_acc = (float)z_acc * 0.016;
break;
case LIS3DH_POWER_NORMAL: /* 10 bit measurements */
x_acc = (int16_t)x_raw >> 6;
y_acc = (int16_t)y_raw >> 6;
@ -466,8 +462,8 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
data.x_acc = (float)x_acc * 0.004;
data.y_acc = (float)y_acc * 0.004;
data.z_acc = (float)z_acc * 0.004;
break;
case LIS3DH_POWER_HIGH: /* 12 bit measurements */
x_acc = (int16_t)x_raw >> 4;
y_acc = (int16_t)y_raw >> 4;
@ -476,8 +472,8 @@ static int lis3dh_read_fifo(FAR struct lis3dh_dev_s *dev)
data.x_acc = (float)x_acc * 0.001;
data.y_acc = (float)y_acc * 0.001;
data.z_acc = (float)z_acc * 0.001;
break;
default:
snerr("Unknown power mode\n");
return -EINVAL;
@ -576,7 +572,7 @@ static int lis3dh_set_power_mode(FAR struct lis3dh_dev_s *dev,
uint8_t ctrl1;
uint8_t ctrl4;
switch(power_mode)
switch (power_mode)
{
case LIS3DH_POWER_LOW:
lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1);
@ -588,6 +584,7 @@ static int lis3dh_set_power_mode(FAR struct lis3dh_dev_s *dev,
lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1);
lis3dh_write_register(dev, LIS3DH_CTRL_REG4, ctrl4);
break;
case LIS3DH_POWER_NORMAL:
lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1);
lis3dh_read_register(dev, LIS3DH_CTRL_REG4, &ctrl4);
@ -598,6 +595,7 @@ static int lis3dh_set_power_mode(FAR struct lis3dh_dev_s *dev,
lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1);
lis3dh_write_register(dev, LIS3DH_CTRL_REG4, ctrl4);
break;
case LIS3DH_POWER_HIGH:
lis3dh_read_register(dev, LIS3DH_CTRL_REG1, &ctrl1);
lis3dh_read_register(dev, LIS3DH_CTRL_REG4, &ctrl4);
@ -608,6 +606,7 @@ static int lis3dh_set_power_mode(FAR struct lis3dh_dev_s *dev,
lis3dh_write_register(dev, LIS3DH_CTRL_REG1, ctrl1);
lis3dh_write_register(dev, LIS3DH_CTRL_REG4, ctrl4);
break;
default:
return -EINVAL;
break;
@ -677,7 +676,7 @@ static int lis3dh_irq_enable(FAR struct lis3dh_dev_s *dev, bool enable)
reg = 0;
if(enable == true)
if (enable == true)
{
reg = LIS3DH_CTRL_REG3_I1_WTM;
}
@ -705,7 +704,7 @@ static int lis3dh_fifo_enable(FAR struct lis3dh_dev_s *dev)
{
uint8_t reg;
lis3dh_write_register(dev, LIS3DH_FIFO_CTRL_REG,
LIS3DH_FIFO_CTRL_REG_MODE_STREAM | 28);
LIS3DH_FIFO_CTRL_REG_MODE_STREAM | 28);
lis3dh_read_register(dev, LIS3DH_CTRL_REG5, &reg);
reg |= LIS3DH_CTRL_REG5_FIFO_EN;
@ -765,7 +764,7 @@ static int lis3dh_enable(FAR struct lis3dh_dev_s *priv)
*
* Returned Value:
* -ENODEV - Device was not identified on the SPI bus.
* OK - Sensor device was opened successfully.
* OK - Sensor device was opened successfully.
*
****************************************************************************/
@ -779,7 +778,7 @@ static int lis3dh_open(FAR struct file *filep)
/* Perform a reset */
lis3dh_reset(priv);
if(lis3dh_ident(priv) < 0)
if (lis3dh_ident(priv) < 0)
{
snerr("ERROR: Failed to identify LIS3DH on SPI bus\n");
return -ENODEV;
@ -795,7 +794,7 @@ static int lis3dh_open(FAR struct file *filep)
/* Enable measurements on the sensor */
if(lis3dh_enable(priv) < 0)
if (lis3dh_enable(priv) < 0)
{
snerr("ERROR: Failed to enable LIS3DH\n");
return -ENODEV;
@ -891,6 +890,7 @@ static ssize_t lis3dh_read(FAR struct file *filep, FAR char *buffer,
data++;
}
return count * sizeof(struct lis3dh_sensor_data_s);
}
@ -901,7 +901,7 @@ static ssize_t lis3dh_read(FAR struct file *filep, FAR char *buffer,
* Character device write call. Not supported.
*
* Input Parameters:
* filep - Pointer to struct file
* filep - Pointer to struct file
* buffer - Pointer to user buffer
* buflen - Size of user buffer in bytes
*
@ -924,12 +924,12 @@ static ssize_t lis3dh_write(FAR struct file *filep, FAR const char *buffer,
*
* Input Parameters:
* filep - Pointer to struct file
* cmd - SNIOC_*
* arg - ioctl specific argument
* cmd - SNIOC_*
* arg - ioctl specific argument
*
* Returned Value:
* OK - The command was executed successfully.
* -ENOTTY - The request command is not applicible to the driver.
* -ENOTTY - The request command is not applicable to the driver.
*
****************************************************************************/

View File

@ -292,7 +292,7 @@ extern "C"
****************************************************************************/
int lis3dh_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
FAR struct lis3dh_config_s *);
FAR struct lis3dh_config_s *);
#undef EXTERN
#ifdef __cplusplus