test_simm30_dram

view test.c @ 0:c47d05df0667

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 07 Mar 2017 23:50:45 +0200
parents
children 318a758ede82
line source
1 #include <stdio.h>
2 #include <string.h>
3 #include <ctype.h>
4 #include <avr/io.h>
5 #include <avr/interrupt.h>
6 #include "serial.h"
8 void procmd(const char *cmd);
10 #define MAX_INPUT_SIZE 128
11 static char input[MAX_INPUT_SIZE];
12 static unsigned char inp_cidx;
14 int main(void)
15 {
16 init_serial(38400);
17 sei();
19 printf("welcome!\n");
21 for(;;) {
22 while(have_input()) {
23 int c = getchar();
24 putchar(c);
26 if(c == '\r' || c == '\n') {
27 input[inp_cidx] = 0;
28 procmd(input);
29 inp_cidx = 0;
30 } else if(inp_cidx < sizeof input - 1) {
31 input[inp_cidx++] = c;
32 }
33 }
34 }
35 return 0;
36 }
38 void procmd(const char *cmd)
39 {
40 if(strcmp(cmd, "info") == 0) {
41 printf("test firmware v0\n");
42 } else {
43 printf("unknown command: %s\n", cmd);
44 }
45 }