You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2019/07/01 20:27:49 UTC

[mynewt-core] branch master updated: hw/mcu/da1469x: Fix i2c master probe (#1839)

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

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 48a69f9  hw/mcu/da1469x: Fix i2c master probe  (#1839)
48a69f9 is described below

commit 48a69f9b4fa8a1a2ab266a517f5471c82d7476b0
Author: pshah111 <49...@users.noreply.github.com>
AuthorDate: Mon Jul 1 13:27:43 2019 -0700

    hw/mcu/da1469x: Fix i2c master probe  (#1839)
    
    * Fixed a bug in i2c_check_tx_is_empty() function and hal_i2c_master_probe() function in hal_i2c.c file.
---
 hw/mcu/dialog/da1469x/src/hal_i2c.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/hal_i2c.c b/hw/mcu/dialog/da1469x/src/hal_i2c.c
index 6cec6d8..a5517a8 100644
--- a/hw/mcu/dialog/da1469x/src/hal_i2c.c
+++ b/hw/mcu/dialog/da1469x/src/hal_i2c.c
@@ -238,7 +238,7 @@ i2c_check_tx_is_not_full(const struct da1469x_hal_i2c *i2c)
 static bool
 i2c_check_tx_is_empty(const struct da1469x_hal_i2c *i2c)
 {
-    return i2c->regs->I2C_STATUS_REG & I2C_I2C_STATUS_REG_TFNF_Msk;
+    return i2c->regs->I2C_STATUS_REG & I2C_I2C_STATUS_REG_TFE_Msk;
 }
 
 static bool
@@ -442,12 +442,16 @@ done:
 int
 hal_i2c_master_probe(uint8_t i2c_num, uint8_t address, uint32_t timo)
 {
-    struct hal_i2c_master_data rx;
-    uint8_t buf;
-
-    rx.address = address;
-    rx.buffer = &buf;
-    rx.len = 1;
-
-    return hal_i2c_master_read(i2c_num, &rx, timo, 1);
+    struct hal_i2c_master_data tx;
+    uint8_t buf = 0;
+
+    tx.address = address;
+    tx.buffer = &buf;
+    tx.len = 1;
+
+    /* 
+    * Using a i2c write instead of a i2c read because i2c read does not detect any i2c device on bus.
+    * Also, i2c read before i2c write causes i2c bus to hang up sometimes. 
+    */
+    return hal_i2c_master_write(i2c_num, &tx, timo, 1);
 }