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