You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/03/27 18:52:02 UTC

[incubator-nuttx] 01/02: arch/arm/src/nrf52/nrf52_i2c.c: protect the I2C transfer with a semaphore

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fef7abb5989c9d9186f405e8d43209a7789f2bdf
Author: raiden00pl <ra...@gmail.com>
AuthorDate: Fri Mar 27 16:25:33 2020 +0100

    arch/arm/src/nrf52/nrf52_i2c.c: protect the I2C transfer with a semaphore
---
 arch/arm/src/nrf52/nrf52_i2c.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/nrf52/nrf52_i2c.c b/arch/arm/src/nrf52/nrf52_i2c.c
index 4da303f..0285d8e 100644
--- a/arch/arm/src/nrf52/nrf52_i2c.c
+++ b/arch/arm/src/nrf52/nrf52_i2c.c
@@ -223,6 +223,12 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
   uint32_t regval = 0;
   int      ret = OK;
 
+  ret = nxsem_wait(&priv->sem_excl);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
   /* Reset ptr and dcnt */
 
   priv->dcnt = 0;
@@ -397,7 +403,8 @@ static int nrf52_i2c_transfer(FAR struct i2c_master_s *dev,
 #endif
 
 errout:
-    return ret;
+  nxsem_post(&priv->sem_excl);
+  return ret;
 }
 
 /****************************************************************************