-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebug.cpp
60 lines (53 loc) · 971 Bytes
/
Debug.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Debug.cpp - Library with tools for Debug Morse code.
Created by Cubiwan 2014
Released into the public domain.
*/
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
void stop(){
Serial.print("STOP!!!");
Serial.flush();
noInterrupts();
while(1){
delay(1000);
};
}
void softwareReset() {
Serial.print("RESET!!!");
Serial.flush();
asm volatile (" jmp 0");
}
void assert(bool t){
if(!t){
Serial.println("Fail");
stop();
} else {
Serial.println("Pass");
}
}
void assertNoNull(void* o){
if(o == ((void *)0)){
Serial.println("Fail");
stop();
} else {
Serial.println("Pass");
}
}
void test(bool t){
if(!t){
Serial.println("False");
} else {
Serial.println("True");
}
}
void testNull(void* o){
if(o == ((void *)0)){
Serial.println("is null");
} else {
Serial.println("is no null");
}
}