flash based config testing

Dependencies:   mbed

Committer:
bwang
Date:
Thu Mar 02 07:04:47 2017 +0000
Revision:
1:df6bbacb7bb9
Parent:
0:941e150e78b6
Child:
2:cfc39b0843ae
now with configuration terminal!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 0:941e150e78b6 1 #include "mbed.h"
bwang 1:df6bbacb7bb9 2
bwang 0:941e150e78b6 3 #include "PreferenceWriter.h"
bwang 0:941e150e78b6 4 #include "FlashWriter.h"
bwang 1:df6bbacb7bb9 5 #include "CommandProcessor.h"
bwang 0:941e150e78b6 6
bwang 0:941e150e78b6 7 Serial pc(USBTX, USBRX);
bwang 0:941e150e78b6 8 PreferenceWriter pref(6);
bwang 0:941e150e78b6 9
bwang 1:df6bbacb7bb9 10 int index = 0;
bwang 1:df6bbacb7bb9 11 char linebuf[128];
bwang 1:df6bbacb7bb9 12
bwang 1:df6bbacb7bb9 13 void rxCallback() {
bwang 1:df6bbacb7bb9 14 while (pc.readable()) {
bwang 1:df6bbacb7bb9 15 char c = pc.getc();
bwang 1:df6bbacb7bb9 16 if (c != 127 && c != '\r' && c != '\t') {
bwang 1:df6bbacb7bb9 17 linebuf[index] = c;
bwang 1:df6bbacb7bb9 18 index++;
bwang 1:df6bbacb7bb9 19 pc.putc(c);
bwang 1:df6bbacb7bb9 20 } else if (c == 127) {
bwang 1:df6bbacb7bb9 21 if (index > 0) {
bwang 1:df6bbacb7bb9 22 index--;
bwang 1:df6bbacb7bb9 23 pc.putc(c);
bwang 1:df6bbacb7bb9 24 }
bwang 1:df6bbacb7bb9 25 } else if (c == '\r') {
bwang 1:df6bbacb7bb9 26 linebuf[index] = 0;
bwang 1:df6bbacb7bb9 27 pc.putc(c);
bwang 1:df6bbacb7bb9 28 processCmd(&pc, &pref, linebuf);
bwang 1:df6bbacb7bb9 29 index = 0;
bwang 1:df6bbacb7bb9 30 pc.putc('>');
bwang 1:df6bbacb7bb9 31 }
bwang 1:df6bbacb7bb9 32 }
bwang 1:df6bbacb7bb9 33 }
bwang 1:df6bbacb7bb9 34
bwang 0:941e150e78b6 35 int main() {
bwang 0:941e150e78b6 36 pc.baud(115200);
bwang 1:df6bbacb7bb9 37 pc.attach(rxCallback);
bwang 0:941e150e78b6 38 pc.printf("%s\n", "Serial Configuration Test");
bwang 1:df6bbacb7bb9 39 pc.printf("%s", ">");
bwang 0:941e150e78b6 40
bwang 0:941e150e78b6 41 for(;;) {
bwang 0:941e150e78b6 42 }
bwang 0:941e150e78b6 43 }