You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by bt...@apache.org on 2021/01/17 05:04:57 UTC

[incubator-nuttx] 05/07: nrf52 i2c: disable peripheral while configuring

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

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

commit 6f3f1c07fbd48a71133b6e5df64679f34c69a5e5
Author: Matias N <ma...@protobits.dev>
AuthorDate: Sat Jan 16 19:36:45 2021 -0300

    nrf52 i2c: disable peripheral while configuring
---
 arch/arm/src/nrf52/nrf52_i2c.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm/src/nrf52/nrf52_i2c.c b/arch/arm/src/nrf52/nrf52_i2c.c
index e8c7bad..eb55b8b 100644
--- a/arch/arm/src/nrf52/nrf52_i2c.c
+++ b/arch/arm/src/nrf52/nrf52_i2c.c
@@ -568,6 +568,10 @@ static int nrf52_i2c_init(FAR struct nrf52_i2c_priv_s *priv)
   int pin         = 0;
   int port        = 0;
 
+  /* Disable TWI interface */
+
+  nrf52_i2c_putreg(priv, NRF52_TWIM_ENABLE_OFFSET, TWIM_ENABLE_DIS);
+
   /* Configure SCL and SDA pins */
 
   nrf52_gpio_config(priv->scl_pin);
@@ -593,7 +597,7 @@ static int nrf52_i2c_init(FAR struct nrf52_i2c_priv_s *priv)
 
   /* Enable TWI interface */
 
-  nrf52_i2c_putreg(priv, NRF52_TWIS_ENABLE_OFFSET, TWIM_ENABLE_EN);
+  nrf52_i2c_putreg(priv, NRF52_TWIM_ENABLE_OFFSET, TWIM_ENABLE_EN);
 
 #ifndef CONFIG_I2C_POLLED
   /* Enable I2C interrupts */
@@ -671,9 +675,9 @@ static int nrf52_i2c_sem_destroy(FAR struct nrf52_i2c_priv_s *priv)
 
 static int nrf52_i2c_deinit(FAR struct nrf52_i2c_priv_s *priv)
 {
-  /* Enable TWI interface */
+  /* Disable TWI interface */
 
-  nrf52_i2c_putreg(priv, TWIM_ENABLE_DIS, NRF52_TWIS_ENABLE_OFFSET);
+  nrf52_i2c_putreg(priv, NRF52_TWIM_ENABLE_OFFSET, TWIM_ENABLE_DIS);
 
   /* Unconfigure GPIO pins */