debug: Improve debugging API (#134)

* Allow DEBUG_LOG without DEBUG_LINK
* Move debugInt() to debug.c
pull/25/head
Saleem Rashid 8 years ago committed by Pavol Rusnak
parent 5c00b24307
commit 5f203d0a0c

@ -20,6 +20,7 @@
#include "trezor.h"
#include "debug.h"
#include "oled.h"
#include "util.h"
#if DEBUG_LOG
@ -50,4 +51,15 @@ void debugLog(int level, const char *bucket, const char *text)
oledDebug(text);
}
char *debugInt(const uint32_t i)
{
static uint8_t n = 0;
static char id[8][9];
uint32hex(i, id[n]);
debugLog(0, "", id[n]);
char *ret = (char *)id[n];
n = (n + 1) % 8;
return ret;
}
#endif

@ -21,14 +21,17 @@
#define __DEBUG_H__
#include "trezor.h"
#include <stdint.h>
#if DEBUG_LOG
void debugLog(int level, const char *bucket, const char *text);
char *debugInt(const uint32_t i);
#else
#define debugLog(L, B, T) do{}while(0)
#define debugInt(I) do{}while(0)
#endif

@ -99,8 +99,11 @@ int main(void)
timer_init();
#if DEBUG_LINK
#if DEBUG_LOG
oledSetDebug(1);
#endif
#if DEBUG_LINK
storage_reset(); // wipe storage if debug link
storage_reset_uuid();
storage_commit();

@ -92,22 +92,6 @@ typedef struct {
uint8_t chal[U2F_CHAL_SIZE];
} U2F_AUTHENTICATE_SIG_STR;
#if DEBUG_LOG
char *debugInt(const uint32_t i)
{
static uint8_t n = 0;
static char id[8][9];
uint32hex(i, id[n]);
debugLog(0, "", id[n]);
char *ret = (char *)id[n];
n = (n + 1) % 8;
return ret;
}
#else
#define debugInt(I) do{}while(0)
#endif
static uint32_t dialog_timeout = 0;
uint32_t next_cid(void)

Loading…
Cancel
Save