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

[mynewt-core] 08/08: [donotmerge] hw/util/i2cn: debug printouts

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

andk pushed a commit to branch bus-dev-test
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 563cea567138b7688fb5a09378c13236fd2a3291
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Jan 4 12:17:09 2019 +0100

    [donotmerge] hw/util/i2cn: debug printouts
---
 hw/util/i2cn/src/i2cn.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/util/i2cn/src/i2cn.c b/hw/util/i2cn/src/i2cn.c
index cd350c4..9c09c33 100644
--- a/hw/util/i2cn/src/i2cn.c
+++ b/hw/util/i2cn/src/i2cn.c
@@ -19,6 +19,7 @@
 
 #include "hal/hal_i2c.h"
 #include "i2cn/i2cn.h"
+#include "console/console.h"
 
 int
 i2cn_master_read(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
@@ -35,8 +36,17 @@ i2cn_master_read(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
     for (i = 0; i <= retries; i++) {
         rc = hal_i2c_master_read(i2c_num, pdata, timeout, last_op);
         if (rc == 0) {
+            if (i > 0) {
+                console_printf("\x1B[1;32m%s: attempt %d/%d addr %02x\x1B[0m\n", __func__, i + 1, retries + 1, pdata->address);
+            }
             break;
         }
+
+        if (i < retries) {
+            console_printf("\x1B[1;33m%s: attempt %d/%d addr %02x\x1B[0m\n", __func__, i + 1, retries + 1, pdata->address);
+        } else {
+            console_printf("\x1B[1;31m%s: attempt %d/%d addr %02x\x1B[0m\n", __func__, i + 1, retries + 1, pdata->address);
+        }
     }
 
     return rc;
@@ -57,8 +67,17 @@ i2cn_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
     for (i = 0; i <= retries; i++) {
         rc = hal_i2c_master_write(i2c_num, pdata, timeout, last_op);
         if (rc == 0) {
+            if (i > 0) {
+                console_printf("\x1B[1;32m%s: attempt %d/%d addr %02x\x1B[0m\n", __func__, i + 1, retries + 1, pdata->address);
+            }
             break;
         }
+
+        if (i < retries) {
+            console_printf("\x1B[1;33m%s: attempt %d/%d addr %02x\x1B[0m\n", __func__, i + 1, retries + 1, pdata->address);
+        } else {
+            console_printf("\x1B[1;31m%s: attempt %d/%d addr %02x\x1B[0m\n", __func__, i + 1, retries + 1, pdata->address);
+        }
     }
 
     return rc;