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

View File

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

View File

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

View File

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