test_simm30_dram
annotate 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 |
rev | line source |
---|---|
nuclear@0 | 1 #include <stdio.h> |
nuclear@0 | 2 #include <string.h> |
nuclear@0 | 3 #include <ctype.h> |
nuclear@0 | 4 #include <avr/io.h> |
nuclear@0 | 5 #include <avr/interrupt.h> |
nuclear@0 | 6 #include "serial.h" |
nuclear@0 | 7 |
nuclear@0 | 8 void procmd(const char *cmd); |
nuclear@0 | 9 |
nuclear@0 | 10 #define MAX_INPUT_SIZE 128 |
nuclear@0 | 11 static char input[MAX_INPUT_SIZE]; |
nuclear@0 | 12 static unsigned char inp_cidx; |
nuclear@0 | 13 |
nuclear@0 | 14 int main(void) |
nuclear@0 | 15 { |
nuclear@0 | 16 init_serial(38400); |
nuclear@0 | 17 sei(); |
nuclear@0 | 18 |
nuclear@0 | 19 printf("welcome!\n"); |
nuclear@0 | 20 |
nuclear@0 | 21 for(;;) { |
nuclear@0 | 22 while(have_input()) { |
nuclear@0 | 23 int c = getchar(); |
nuclear@0 | 24 putchar(c); |
nuclear@0 | 25 |
nuclear@0 | 26 if(c == '\r' || c == '\n') { |
nuclear@0 | 27 input[inp_cidx] = 0; |
nuclear@0 | 28 procmd(input); |
nuclear@0 | 29 inp_cidx = 0; |
nuclear@0 | 30 } else if(inp_cidx < sizeof input - 1) { |
nuclear@0 | 31 input[inp_cidx++] = c; |
nuclear@0 | 32 } |
nuclear@0 | 33 } |
nuclear@0 | 34 } |
nuclear@0 | 35 return 0; |
nuclear@0 | 36 } |
nuclear@0 | 37 |
nuclear@0 | 38 void procmd(const char *cmd) |
nuclear@0 | 39 { |
nuclear@0 | 40 if(strcmp(cmd, "info") == 0) { |
nuclear@0 | 41 printf("test firmware v0\n"); |
nuclear@0 | 42 } else { |
nuclear@0 | 43 printf("unknown command: %s\n", cmd); |
nuclear@0 | 44 } |
nuclear@0 | 45 } |