serial ice working after rework

Change-Id: I05e70ba1dfe5223040417742a18621d18b7431e8
This commit is contained in:
Alexander Couzens 2017-10-29 02:39:29 +01:00
parent e17cb22b97
commit a4468ea249
1 changed files with 32 additions and 20 deletions

View File

@ -24,6 +24,7 @@
#define VERSION "1.6"
/* Uart wrapper functions */
static void sio_putstring(const char *string);
static void sio_flush(void)
{
@ -35,12 +36,16 @@ static void sio_putc(u8 byte)
debug_tx_byte(byte);
}
static void sio_put8(u8 data);
static u8 sio_getc(void)
{
u8 val = 0;
val = debug_rx_byte();
if (val) {
sio_putstring("\n c: ");
sio_put8(val);
return val;
}
@ -171,7 +176,7 @@ static void serialice_read_memory(char *buffer, int len)
u32 *addr;
if (len < 13) {
sio_putstring("Wrong size\n");
sio_putstring("read memory short len\n");
}
// Format:
@ -378,12 +383,12 @@ static int sio_get_line(char *buffer, int len)
{
int i;
for (i=0; i<len; i++) {
*buffer = sio_getc();
if ((*buffer) == '\n')
for (i=0; i<(len - 1); i++) {
buffer[i] = sio_getc();
if (buffer[i] == '\n' || buffer[i] == '\r') {
buffer[i] = '\0';
return i;
buffer++;
}
}
return i;
@ -392,7 +397,7 @@ static int sio_get_line(char *buffer, int len)
void serialice_main(void)
{
u16 c;
char line[32];
char line[32] = { 0 };
int len;
serialice_version(line, 0);
@ -400,7 +405,13 @@ void serialice_main(void)
while (1) {
sio_putstring("\n> ");
len = sio_get_line(line, sizeof(line));
len = sio_get_line(line, 32);
sio_putstring("\ngot len ");
sio_put32(len);
sio_putstring("'");
sio_putstring(line);
sio_putstring("'");
sio_putstring("\n");
/* only new line read */
if (len == 0)
continue;
@ -439,18 +450,19 @@ void serialice_main(void)
case (('v' << 8)|'i'): // Read version info *vi
serialice_version(line, len);
break;
case ('?'):
sio_putstring(""
"rm - read memory\n"
"wm - write memory\n"
"ri - read io\n"
"wi - write io\n"
"ci - cpu info\n"
"mb - read mainboard\n"
"vi - show version\n");
break;
default:
sio_putstring("ERROR\n");
default:
if (line[1] == '?') {
sio_putstring(""
"rm - read memory\n"
"wm - write memory\n"
"ri - read io\n"
"wi - write io\n"
"ci - cpu info\n"
"mb - read mainboard\n"
"vi - show version\n");
} else {
sio_putstring("ERROR. Unknown command\n");
}
break;
}
}