-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
55 lines (47 loc) · 1022 Bytes
/
main.c
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
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "terminal.h"
#define FSTR(X) ((const __flash char[]) { X } )
const __flash char * const __flash myCommandList [] =
{
FSTR ("help"), FSTR ("cmd1"), FSTR ("cmd2")
};
const __flash char * const __flash messages[] =
{
FSTR ("Welcome to tinyavrterm!"), FSTR ("Command not found."), FSTR ("Boom!")
};
int main(void)
{
termInit(myCommandList,sizeof(myCommandList)/2); //initialize uart and pass command list
sei(); //enable interrupts globally
while(1) {
if(termPoll()) {
termPutByte(0x0A);
termPutByte(0x0D);
switch(termCmd) {
case 0: {
// do sth
termPutFlash(messages[0]);
}
break;
case 1: {
// do sth else
termPutFlash(messages[2]);
}
break;
case 2: {
// do sth else..
termPutFlash(messages[2]);
}
break;
default: {
// display command not found message
termPutFlash(messages[1]);
}
break;
}
termReturn();
}
}
}