Skip to content

Commit b330cb7

Browse files
committed
Merge branch 'Links2004-esp8266' into esp8266
* Links2004-esp8266: add hexdump function for easy debugging. add some notes to the SPI functions (aligned to 32Bit) - Fatal exception (9)
2 parents aacfd96 + 9f2c3a4 commit b330cb7

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

cores/esp8266/Arduino.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ long random(long, long);
229229
void randomSeed(unsigned int);
230230
long map(long, long, long, long, long);
231231

232+
// Debugging functions
233+
void hexdump(uint8_t *mem, uint32_t len, uint8_t cols = 16);
234+
232235
#endif
233236

234237
#include "pins_arduino.h"

cores/esp8266/debug.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* debug.c
3+
*
4+
* Created on: 13.05.2015
5+
* Author: Markus Sattler
6+
*/
7+
8+
#include "Arduino.h"
9+
10+
void ICACHE_RAM_ATTR hexdump(uint8_t *mem, uint32_t len, uint8_t cols) {
11+
os_printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", mem, len, len);
12+
for(uint32_t i = 0; i < len; i++) {
13+
if(i % cols == 0) {
14+
os_printf("\n[0x%08X] 0x%08X: ", mem, i);
15+
}
16+
os_printf("%02X ", *mem);
17+
mem++;
18+
}
19+
os_printf("\n");
20+
}
21+

libraries/SPI/SPI.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ void SPIClass::write32(uint32_t data, bool msb) {
308308
while(SPI1CMD & SPIBUSY) {}
309309
}
310310

311+
/**
312+
* Note:
313+
* data need to be aligned to 32Bit
314+
* or you get an Fatal exception (9)
315+
* @param data uint8_t *
316+
* @param size uint32_t
317+
*/
311318
void SPIClass::writeBytes(uint8_t * data, uint32_t size) {
312319
while(size) {
313320
if(size > 64) {
@@ -340,6 +347,15 @@ void SPIClass::writeBytes_(uint8_t * data, uint8_t size) {
340347
while(SPI1CMD & SPIBUSY) {}
341348
}
342349

350+
351+
/**
352+
* Note:
353+
* data need to be aligned to 32Bit
354+
* or you get an Fatal exception (9)
355+
* @param data uint8_t *
356+
* @param size uint8_t max for size is 64Byte
357+
* @param repeat uint32_t
358+
*/
343359
void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat) {
344360
if(size > 64) return; //max Hardware FIFO
345361

@@ -376,6 +392,14 @@ void SPIClass::writePattern_(uint8_t * data, uint8_t size, uint8_t repeat) {
376392
writeBytes(&buffer[0], bytes);
377393
}
378394

395+
/**
396+
* Note:
397+
* in and out need to be aligned to 32Bit
398+
* or you get an Fatal exception (9)
399+
* @param out uint8_t *
400+
* @param in uint8_t *
401+
* @param size uint32_t
402+
*/
379403
void SPIClass::transferBytes(uint8_t * out, uint8_t * in, uint32_t size) {
380404
while(size) {
381405
if(size > 64) {

0 commit comments

Comments
 (0)