aboutsummaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-01-18 00:43:57 -0800
committerpx4dev <px4@purgatory.org>2013-01-18 00:43:57 -0800
commitbc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2 (patch)
treec84795237631635d6441c9a6d68f5e18527fee75 /nuttx/arch
parent7d7c352fb44b718cb96096a624a19b5225e39f92 (diff)
downloadpx4-firmware-bc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2.tar.gz
px4-firmware-bc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2.tar.bz2
px4-firmware-bc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2.zip
HOTFIX: disable interrupt-driven I2C mode, configure pessimistic I2C timeout, correct handling of the NAK generation for I2C master reads.
This looks like it addresses the recent I2C lockup issue, unfortunately it also increases CPU consumption by ~5% for the I2C sensor bus.
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_i2c.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c
index fd682cd5d..10e6cac65 100644
--- a/nuttx/arch/arm/src/stm32/stm32_i2c.c
+++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c
@@ -1245,11 +1245,11 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
/* Disable acknowledge when last byte is to be received */
+ priv->dcnt--;
if (priv->dcnt == 1)
{
stm32_i2c_modifyreg(priv, STM32_I2C_CR1_OFFSET, I2C_CR1_ACK, 0);
}
- priv->dcnt--;
#ifdef CONFIG_I2C_POLLED
irqrestore(state);
@@ -1985,7 +1985,6 @@ int up_i2creset(FAR struct i2c_dev_s * dev)
uint32_t scl_gpio;
uint32_t sda_gpio;
int ret = ERROR;
- irqstate_t state;
ASSERT(dev);
@@ -2010,6 +2009,9 @@ int up_i2creset(FAR struct i2c_dev_s * dev)
scl_gpio = MKI2C_OUTPUT(priv->config->scl_pin);
sda_gpio = MKI2C_OUTPUT(priv->config->sda_pin);
+ /* Let SDA go high */
+ stm32_gpiowrite(sda_gpio, 1);
+
/* Clock the bus until any slaves currently driving it let it go. */
clock_count = 0;
@@ -2017,7 +2019,7 @@ int up_i2creset(FAR struct i2c_dev_s * dev)
{
/* Give up if we have tried too hard */
- if (clock_count++ > 1000)
+ if (clock_count++ > 10)
{
goto out;
}
@@ -2032,7 +2034,7 @@ int up_i2creset(FAR struct i2c_dev_s * dev)
{
/* Give up if we have tried too hard */
- if (stretch_count++ > 1000)
+ if (stretch_count++ > 10)
{
goto out;
}