Skip to content
Snippets Groups Projects
Commit 8f761f8d authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Pekka Niemimaa
Browse files

sensors/lis2dh: do not reboot when powering off; minor coding-style and other fixes


Change-Id: I40f29740db7bcd97d9d9f99f68425cf6b017cd06
Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@haltian.com>
parent 7a2ca0cc
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,9 @@
*
* LIS2DH accelerometer driver
*
* Copyright (C) 2014 Haltian Ltd. All rights reserved.
* Copyright (C) 2014-2015 Haltian Ltd. All rights reserved.
* Authors: Timo Voutilainen <timo.voutilainen@haltian.com>
* Jussi Kivilinna <jussi.kivilinna@haltian.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -241,7 +242,6 @@ static int lis2dh_close(FAR struct file *filep)
FAR struct lis2dh_dev_s *priv = inode->i_private;
priv->config->irq_enable(priv->config, false);
lis2dh_reboot(priv);
return lis2dh_powerdown(priv);
}
......@@ -446,7 +446,7 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer, size_t bufl
lis2dh_dbg("lis2dh: Failed to read INT1_SRC_REG\n");
err = -EIO;
}
if (buf & 0x40)
if (buf & ST_LIS2DH_INT_SR_ACTIVE)
{
/* Interrupt has happened */
......@@ -467,7 +467,7 @@ static ssize_t lis2dh_read(FAR struct file *filep, FAR char *buffer, size_t bufl
lis2dh_dbg("lis2dh: Failed to read INT2_SRC_REG\n");
err = -EIO;
}
if (buf & 0x40)
if (buf & ST_LIS2DH_INT_SR_ACTIVE)
{
/* Interrupt has happened */
......@@ -1051,8 +1051,6 @@ static int lis2dh_get_reading(FAR struct lis2dh_dev_s * dev,
uint8_t retval[7];
int16_t x, y, z;
DEBUGASSERT(dev != NULL);
if (lis2dh_access(dev, ST_LIS2DH_STATUS_REG, retval, 7) == 7)
{
/* If result is not yet ready, return NULL */
......@@ -1411,7 +1409,9 @@ static int lis2dh_setup(FAR struct lis2dh_dev_s * dev, struct lis2dh_setup *new_
dev->setup = new_setup;
/* Clear old configuration. */
/* 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. */
(void)lis2dh_reboot(dev);
/* TEMP_CFG_REG */
......@@ -1610,7 +1610,6 @@ error:
/* Setup failed - power down */
lis2dh_reboot(dev);
lis2dh_powerdown(dev);
return -EIO;
}
......
......@@ -160,6 +160,13 @@ extern "C" {
#define ST_LIS2DH_INT_CFG_XLIE 0x01
#define ST_LIS2DH_INT1_SRC_REG 0x31
#define ST_LIS2DH_INT_SR_XLOW 0x01
#define ST_LIS2DH_INT_SR_XHIGH 0x02
#define ST_LIS2DH_INT_SR_YLOW 0x04
#define ST_LIS2DH_INT_SR_YHIGH 0x08
#define ST_LIS2DH_INT_SR_ZLOW 0x10
#define ST_LIS2DH_INT_SR_ZHIGH 0x20
#define ST_LIS2DH_INT_SR_ACTIVE 0x40
#define ST_LIS2DH_INT1_THS_REG 0x32 /* 7-bit value for threshold */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment