From a17aded8d651757a884580c99f1a7480dd817304 Mon Sep 17 00:00:00 2001 From: Markus Sattler Date: Wed, 13 May 2015 22:54:09 +0200 Subject: [PATCH] add hexdump function for easy debugging. Output: [HEXDUMP] Address: 0x3FFF5188 len: 0x200 (512) [0x3FFF5188] 0x00000000: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 [0x3FFF5198] 0x00000010: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 [0x3FFF51A8] 0x00000020: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 [0x3FFF51B8] 0x00000030: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 [0x3FFF51C8] 0x00000040: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 [0x3FFF51D8] 0x00000050: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 [0x3FFF51E8] 0x00000060: E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 E6 D1 .... --- cores/esp8266/Arduino.h | 3 +++ cores/esp8266/debug.cpp | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 cores/esp8266/debug.cpp diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 6db13a088..9cc4ad08b 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -229,6 +229,9 @@ long random(long, long); void randomSeed(unsigned int); long map(long, long, long, long, long); +// Debugging functions +void hexdump(uint8_t *mem, uint32_t len, uint8_t cols = 16); + #endif #include "pins_arduino.h" diff --git a/cores/esp8266/debug.cpp b/cores/esp8266/debug.cpp new file mode 100644 index 000000000..c42016b04 --- /dev/null +++ b/cores/esp8266/debug.cpp @@ -0,0 +1,21 @@ +/* + * debug.c + * + * Created on: 13.05.2015 + * Author: Markus Sattler + */ + +#include "Arduino.h" + +void ICACHE_RAM_ATTR hexdump(uint8_t *mem, uint32_t len, uint8_t cols) { + os_printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", mem, len, len); + for(uint32_t i = 0; i < len; i++) { + if(i % cols == 0) { + os_printf("\n[0x%08X] 0x%08X: ", mem, i); + } + os_printf("%02X ", *mem); + mem++; + } + os_printf("\n"); +} +