parent
acd9c72eac
commit
609b8e836e
@ -0,0 +1,8 @@
|
|||||||
|
;; Object thermocouple
|
||||||
|
;; EDE project file.
|
||||||
|
(ede-proj-project "thermocouple"
|
||||||
|
:name "thermocouple"
|
||||||
|
:file "Project.ede"
|
||||||
|
:targets (list
|
||||||
|
)
|
||||||
|
)
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
#include "debug.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
char debugStr[DEBUGCHARS];
|
||||||
|
volatile char dbgCurChar;
|
||||||
|
volatile uint8_t dbgStrFill; // amount of available chars in debugStr
|
||||||
|
volatile uint8_t dbgHasNewSPI;
|
||||||
|
|
||||||
|
void dbgLog(const char* fmt, ...) {
|
||||||
|
uint8_t maxwrite = DEBUGCHARS - dbgStrFill;
|
||||||
|
va_list va;
|
||||||
|
va_start(va,fmt);
|
||||||
|
char* pos = debugStr + dbgStrFill;
|
||||||
|
dbgStrFill += vsnprintf(pos, maxwrite, fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t dbgHasNew() {
|
||||||
|
dbgHasNewSPI = (dbgStrFill > 0);
|
||||||
|
return (dbgStrFill > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char dbgReadChar() {
|
||||||
|
if(dbgHasNew()) {
|
||||||
|
char ret = debugStr[0];
|
||||||
|
for(int i=0; i<dbgStrFill-1; i++) {
|
||||||
|
debugStr[i] = debugStr[i+1];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbgAdvanceChar() {
|
||||||
|
dbgCurChar = dbgReadChar();
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __DEBUG_H
|
||||||
|
#define __DEBUG_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define DEBUGCHARS 100
|
||||||
|
extern char debugStr[];
|
||||||
|
extern volatile uint8_t dbgStrFill; // amount of available chars in debugStr
|
||||||
|
extern volatile uint8_t dbgHasNewSPI;
|
||||||
|
extern volatile char dbgCurChar;
|
||||||
|
|
||||||
|
|
||||||
|
void dbgLog(const char* fmt, ...);
|
||||||
|
uint8_t dbgHasNew();
|
||||||
|
char dbgReadChar();
|
||||||
|
void dbgAdvanceChar();
|
||||||
|
#endif
|
||||||
Loading…
Reference in new issue