sw: minor formatting improvements for tester

Add the version number, and make the final "Pass" text be more easily
parsed by a simple grep.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-05-23 17:30:11 +08:00
parent 8b2241a9e6
commit 372ab22b10
2 changed files with 19 additions and 14 deletions

View File

@ -49,7 +49,7 @@ CFLAGS := $(ADD_CFLAGS) \
-ffunction-sections -fdata-sections -fno-common \ -ffunction-sections -fdata-sections -fno-common \
-fomit-frame-pointer -Os \ -fomit-frame-pointer -Os \
-march=rv32i \ -march=rv32i \
-DGIT_VERSION=u\"$(GIT_VERSION)\" -std=gnu11 -DGIT_VERSION=\"$(GIT_VERSION)\" -std=gnu11
CXXFLAGS := $(CFLAGS) -std=c++11 -fno-rtti -fno-exceptions CXXFLAGS := $(CFLAGS) -std=c++11 -fno-rtti -fno-exceptions
LFLAGS := $(CFLAGS) $(ADD_LFLAGS) -L$(LD_DIR) \ LFLAGS := $(CFLAGS) $(ADD_LFLAGS) -L$(LD_DIR) \
-nostartfiles \ -nostartfiles \

View File

@ -78,22 +78,25 @@ static uint32_t test_one_pad(uint8_t src, uint8_t dest)
unsigned int matches = 0; unsigned int matches = 0;
const unsigned int loop_max = 10; const unsigned int loop_max = 10;
put_char('0'+src); put_char('0' + src);
put_char('>'); put_char('>');
put_char('0'+dest); put_char('0' + dest);
put_char(':'); put_char(':');
for (loops = 0; loops < loop_max; loops++) { for (loops = 0; loops < loop_max; loops++)
{
// Set pin 2 as output, and pin 0 as input, and see if it loops back. // Set pin 2 as output, and pin 0 as input, and see if it loops back.
touch_oe_write((1 << src) | (0 << dest)); touch_oe_write((1 << src) | (0 << dest));
touch_o_write((loops&1) << src); touch_o_write((loops & 1) << src);
if ((loops&1) == !!((touch_i_read() & (1 << dest)))) if ((loops & 1) == !!((touch_i_read() & (1 << dest))))
matches++; matches++;
} }
if (matches == loop_max) { if (matches == loop_max)
{
put_string("OK "); put_string("OK ");
return 0; return 0;
} }
else { else
{
put_string("FAIL("); put_string("FAIL(");
put_hex_byte(loop_max); put_hex_byte(loop_max);
put_char('!'); put_char('!');
@ -107,7 +110,7 @@ static uint32_t test_touch(void)
{ {
uint32_t error_count = 0; uint32_t error_count = 0;
put_string("Touch: "); put_string("TOUCH: ");
error_count += test_one_pad(0, 2); error_count += test_one_pad(0, 2);
error_count += test_one_pad(0, 3); error_count += test_one_pad(0, 3);
@ -159,7 +162,7 @@ static uint32_t test_one_color(int color)
uint32_t ratio = ((detected_pulses * 100) / sent_pulses); uint32_t ratio = ((detected_pulses * 100) / sent_pulses);
put_string("Ratio: 0x"); put_string("Ratio: 0x");
put_hex(ratio); put_hex_byte(ratio);
put_string(" / "); put_string(" / ");
if (ratio > 60) if (ratio > 60)
{ {
@ -188,18 +191,20 @@ static uint32_t test_led(void)
void tester_poll(void) void tester_poll(void)
{ {
int error_count = 0; int error_count = 0;
put_string("\nHello, world!\n"); put_char('\n');
flush_serial();
put_string("\nFomu Tester " GIT_VERSION "\n");
error_count += test_spi(); error_count += test_spi();
error_count += test_led(); error_count += test_led();
error_count += test_touch(); error_count += test_touch();
put_string("FOMU: "); put_string("FOMU: (0x");
put_hex(error_count); put_hex(error_count);
put_string(" errors "); put_string(" errors) ");
if (error_count) if (error_count)
put_string("FAIL!\n"); put_string("FAIL!\n");
else else
put_string("Pass\n"); put_string("ALL_PASS\n");
while (1) while (1)
{ {
usb_poll(); usb_poll();