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"); +} + diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index be4627740..c96c4fcb8 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -308,6 +308,13 @@ void SPIClass::write32(uint32_t data, bool msb) { while(SPI1CMD & SPIBUSY) {} } +/** + * Note: + * data need to be aligned to 32Bit + * or you get an Fatal exception (9) + * @param data uint8_t * + * @param size uint32_t + */ void SPIClass::writeBytes(uint8_t * data, uint32_t size) { while(size) { if(size > 64) { @@ -340,6 +347,15 @@ void SPIClass::writeBytes_(uint8_t * data, uint8_t size) { while(SPI1CMD & SPIBUSY) {} } + +/** + * Note: + * data need to be aligned to 32Bit + * or you get an Fatal exception (9) + * @param data uint8_t * + * @param size uint8_t max for size is 64Byte + * @param repeat uint32_t + */ void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat) { if(size > 64) return; //max Hardware FIFO @@ -376,6 +392,14 @@ void SPIClass::writePattern_(uint8_t * data, uint8_t size, uint8_t repeat) { writeBytes(&buffer[0], bytes); } +/** + * Note: + * in and out need to be aligned to 32Bit + * or you get an Fatal exception (9) + * @param out uint8_t * + * @param in uint8_t * + * @param size uint32_t + */ void SPIClass::transferBytes(uint8_t * out, uint8_t * in, uint32_t size) { while(size) { if(size > 64) {