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:08 UTC
[mynewt-core] 07/08: [donotmerge] hw/mcu/nordic: hal_i2c debug
printouts (w)
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 36f1ec0cc7e7a9825a945c0af243b2cc6da9223a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 12:16:36 2018 +0100
[donotmerge] hw/mcu/nordic: hal_i2c debug printouts (w)
---
hw/mcu/nordic/nrf52xxx/src/hal_i2c.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
index 88d9518..1f19be3 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
@@ -417,8 +417,10 @@ hal_i2c_config(uint8_t i2c_num, const struct hal_i2c_settings *cfg)
static inline void
hal_i2c_trigger_start(NRF_TWI_Type *twi, __O uint32_t *task)
{
+ static const int max_attempt = 2;
uint32_t end_ticks;
- int retry = 2;
+ char op = task == &twi->TASKS_STARTTX ? 't' : 'r';
+ int attempt = 1;
/*
* Some devices [1] can cause glitch on I2C bus which makes TWI controller
@@ -463,10 +465,20 @@ hal_i2c_trigger_start(NRF_TWI_Type *twi, __O uint32_t *task)
* writes.
*/
if (!hal_gpio_read(twi->PSELSCL) || twi->EVENTS_BB) {
+ if (attempt > 1) {
+ console_printf("\x1B[1;32m%s: op %cx attempt %d/%d addr %02x\x1B[0m\n", __func__, op, attempt, max_attempt, (unsigned)twi->ADDRESS);
+ }
return;
}
} while (CPUTIME_LT(os_cputime_get32(), end_ticks));
+ if (attempt == max_attempt) {
+ console_printf("\x1B[1;31m%s: op %cx attempt %d/%d addr %02x\x1B[0m\n", __func__, op, attempt, max_attempt, (unsigned)twi->ADDRESS);
+ } else {
+ console_printf("\x1B[1;33m%s: op %cx attempt %d/%d addr %02x\x1B[0m\n", __func__, op, attempt, max_attempt, (unsigned)twi->ADDRESS);
+ }
+ attempt++;
+
twi->ENABLE = TWI_ENABLE_ENABLE_Disabled;
/*
* This is to "clear" other devices on bus which may be affected by the
@@ -474,7 +486,7 @@ hal_i2c_trigger_start(NRF_TWI_Type *twi, __O uint32_t *task)
*/
hal_i2c_clear_bus(twi->PSELSCL, twi->PSELSDA);
twi->ENABLE = TWI_ENABLE_ENABLE_Enabled;
- } while (--retry);
+ } while (attempt <= max_attempt);
}
int