From 27e1254afc618ef34cf7d49c5158587da465b2be Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Mon, 2 Feb 2009 09:49:05 +0100 Subject: digital/avr/modules/trace: Ended the trace module to stop the traces when it rolls over the flash memory. (Closes #t60). --- .../avr/modules/trace/test/test_host/test-trace.c | 81 ++++++++++++++++++++-- 1 file changed, 75 insertions(+), 6 deletions(-) (limited to 'digital/avr/modules/trace/test/test_host/test-trace.c') diff --git a/digital/avr/modules/trace/test/test_host/test-trace.c b/digital/avr/modules/trace/test/test_host/test-trace.c index aabd8e16..59a82242 100644 --- a/digital/avr/modules/trace/test/test_host/test-trace.c +++ b/digital/avr/modules/trace/test/test_host/test-trace.c @@ -27,13 +27,13 @@ #include "modules/flash/flash.h" #include +#include #include "events.h" void flood (void) { uint8_t cmd; - uint32_t addr; uint32_t count; uint32_t speed; @@ -45,9 +45,9 @@ flood (void) uint32_t arg3; trace_init (); + flash_erase (FLASH_ERASE_FULL, 0); /* Flood the flash memory with traces. */ - /* A little more than 3 memory sectors, a sector is 4 kbytes. */ for (count = 0; count < 2000; count ++) { /* Right motor. */ @@ -64,9 +64,68 @@ flood (void) TRACE (cmd, speed, position, acc); cmd = TRACE_IA__IA_CMD; TRACE (cmd, arg1, arg2, arg3); + + if (trace_status () == TRACE_STATUS_OFF) + return; + } +} + +uint8_t +flood_overflow (void) +{ + uint8_t cmd; + uint32_t count; + uint32_t i; + + uint32_t speed; + uint32_t position; + uint16_t acc; + + uint16_t arg1; + uint8_t arg2; + uint32_t arg3; + uint32_t addr; + + if (trace_init () == TRACE_STATUS_OFF) + return TRACE_STATUS_OFF; + addr = trace_addr_current (); + printf ("Addr begin : %x\n", addr); + + for (i = 0; i < FLASH_ADDRESS_HIGH; i++) + { + /* Flood the flash memory with traces. */ + for (count = 0; count < 2000; count ++) + { + /* Right motor. */ + speed = 10; + position = 11; + acc = 12; + arg1 = 10; + arg2 = 11; + arg3 = 12; + + cmd = TRACE_ASSERV__RIGHT_MOTOR; + TRACE (cmd, speed, position, acc); + cmd = TRACE_ASSERV__LEFT_MOTOR; + TRACE (cmd, speed, position, acc); + cmd = TRACE_IA__IA_CMD; + TRACE (cmd, arg1, arg2, arg3); + } + + if (trace_status () == TRACE_STATUS_OFF) + { + addr = trace_addr_current (); + printf ("End address : %x\n", addr); + return TRACE_STATUS_OFF; + } } + + addr = trace_addr_current (); + printf ("End address : %x\n", addr); + return TRACE_STATUS_ON; } + void dump (void) { @@ -74,6 +133,8 @@ dump (void) uint32_t addr; status = flash_init (); + if (status == TRACE_STATUS_OFF) + return; for (addr = 0; addr < FLASH_ADDRESS_HIGH; addr ++) { @@ -82,14 +143,22 @@ dump (void) } int -main (void) +main (int argc, char **argv) { uint8_t i; - for (i = 0; i < 30; i++) - flood (); + if (strcmp (argv[1], "trace") == 0) + { + for (i = 0; i < 30; i++) + flood (); + } + else if (strcmp (argv[1], "overflow") == 0) + { + return flood_overflow (); + } + else if (strcmp (argv[1], "dump") == 0) + dump(); - dump(); return 0; } -- cgit v1.2.3