From 2579ae36869acdc7bfa06deb97d2293ecb31f910 Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 23 Sep 2021 22:47:17 +0200 Subject: [PATCH] Print actual status and data on TWI error The contents of `TWSR` (TWI Status Register) and `TWDR` (TWI Data Register) are printed when an error occured. --- firmware/src/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/firmware/src/main.c b/firmware/src/main.c index 037a8f0..fd8062a 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -336,6 +336,20 @@ static void lcd_splash(void) { static void twi_error(void) { lcd_fill(0xFF); + for (uint8_t i = 0; i < 2; i++) { + lcd_move_cursor(0, i); + lcd_write_string_page("TW_STATUS:\0", i, true); + lcd_write_kerning(2, true); + lcd_write_integer_page(TW_STATUS, 3, i, true); + } + + for (uint8_t i = 0; i < 2; i++) { + lcd_move_cursor(0, i + 2); + lcd_write_string_page("TW_DATA:\0", i, true); + lcd_write_kerning(16, true); + lcd_write_integer_page(TWDR, 3, i, true); + } + for (;;); }