test_simm30_dram
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test.c Tue Mar 07 23:50:45 2017 +0200 1.3 @@ -0,0 +1,45 @@ 1.4 +#include <stdio.h> 1.5 +#include <string.h> 1.6 +#include <ctype.h> 1.7 +#include <avr/io.h> 1.8 +#include <avr/interrupt.h> 1.9 +#include "serial.h" 1.10 + 1.11 +void procmd(const char *cmd); 1.12 + 1.13 +#define MAX_INPUT_SIZE 128 1.14 +static char input[MAX_INPUT_SIZE]; 1.15 +static unsigned char inp_cidx; 1.16 + 1.17 +int main(void) 1.18 +{ 1.19 + init_serial(38400); 1.20 + sei(); 1.21 + 1.22 + printf("welcome!\n"); 1.23 + 1.24 + for(;;) { 1.25 + while(have_input()) { 1.26 + int c = getchar(); 1.27 + putchar(c); 1.28 + 1.29 + if(c == '\r' || c == '\n') { 1.30 + input[inp_cidx] = 0; 1.31 + procmd(input); 1.32 + inp_cidx = 0; 1.33 + } else if(inp_cidx < sizeof input - 1) { 1.34 + input[inp_cidx++] = c; 1.35 + } 1.36 + } 1.37 + } 1.38 + return 0; 1.39 +} 1.40 + 1.41 +void procmd(const char *cmd) 1.42 +{ 1.43 + if(strcmp(cmd, "info") == 0) { 1.44 + printf("test firmware v0\n"); 1.45 + } else { 1.46 + printf("unknown command: %s\n", cmd); 1.47 + } 1.48 +}