Improve print command

This commit is contained in:
Jeremy Soller 2020-03-14 21:06:18 -06:00
parent d800af5ed6
commit 8a8ab165a7
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
4 changed files with 34 additions and 25 deletions

View File

@ -107,14 +107,17 @@ void smfi_init(void) {
FLHCTRL3 |= (1 << 3);
}
static enum Result cmd_debug(void) {
int i;
for (i = 2; i < ARRAY_SIZE(smfi_cmd); i++) {
uint8_t b = smfi_cmd[i];
if (b == 0) break;
putchar(b);
static enum Result cmd_print(void) {
uint8_t flags = smfi_cmd[2];
uint8_t len = smfi_cmd[3];
uint8_t i;
for (i = 0; (i < len) && ((i + 4) < ARRAY_SIZE(smfi_cmd)); i++) {
putchar(smfi_cmd[i + 4]);
}
smfi_cmd[3] = i;
return RES_OK;
}
@ -162,8 +165,8 @@ void smfi_event(void) {
// Always successful
smfi_cmd[1] = RES_OK;
break;
case CMD_DEBUG:
smfi_cmd[1] = cmd_debug();
case CMD_PRINT:
smfi_cmd[1] = cmd_print();
break;
case CMD_SPI:
smfi_cmd[1] = cmd_spi();

View File

@ -107,14 +107,17 @@ void smfi_init(void) {
FLHCTRL3 |= (1 << 3);
}
static enum Result cmd_debug(void) {
int i;
for (i = 2; i < ARRAY_SIZE(smfi_cmd); i++) {
uint8_t b = smfi_cmd[i];
if (b == 0) break;
putchar(b);
static enum Result cmd_print(void) {
uint8_t flags = smfi_cmd[2];
uint8_t len = smfi_cmd[3];
uint8_t i;
for (i = 0; (i < len) && ((i + 4) < ARRAY_SIZE(smfi_cmd)); i++) {
putchar(smfi_cmd[i + 4]);
}
smfi_cmd[3] = i;
return RES_OK;
}
@ -162,8 +165,8 @@ void smfi_event(void) {
// Always successful
smfi_cmd[1] = RES_OK;
break;
case CMD_DEBUG:
smfi_cmd[1] = cmd_debug();
case CMD_PRINT:
smfi_cmd[1] = cmd_print();
break;
case CMD_SPI:
smfi_cmd[1] = cmd_spi();

View File

@ -107,14 +107,17 @@ void smfi_init(void) {
FLHCTRL3 |= (1 << 3);
}
static enum Result cmd_debug(void) {
int i;
for (i = 2; i < ARRAY_SIZE(smfi_cmd); i++) {
uint8_t b = smfi_cmd[i];
if (b == 0) break;
putchar(b);
static enum Result cmd_print(void) {
uint8_t flags = smfi_cmd[2];
uint8_t len = smfi_cmd[3];
uint8_t i;
for (i = 0; (i < len) && ((i + 4) < ARRAY_SIZE(smfi_cmd)); i++) {
putchar(smfi_cmd[i + 4]);
}
smfi_cmd[3] = i;
return RES_OK;
}
@ -162,8 +165,8 @@ void smfi_event(void) {
// Always successful
smfi_cmd[1] = RES_OK;
break;
case CMD_DEBUG:
smfi_cmd[1] = cmd_debug();
case CMD_PRINT:
smfi_cmd[1] = cmd_print();
break;
case CMD_SPI:
smfi_cmd[1] = cmd_spi();

View File

@ -11,7 +11,7 @@ enum Command {
// Read version string
CMD_VERSION = 3,
// Write bytes to console
CMD_DEBUG = 4,
CMD_PRINT = 4,
// Access SPI chip
CMD_SPI = 5,
// Reset EC