core: Added a log level
authorMichel Pollet <buserror@gmail.com>
Wed, 14 Sep 2011 08:18:13 +0000 (09:18 +0100)
committerMichel Pollet <buserror@gmail.com>
Wed, 14 Sep 2011 08:18:13 +0000 (09:18 +0100)
added log_level to avr_t to control the output of the
simavr library (minimal usage)

Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/sim_avr.c
simavr/sim/sim_avr.h

index 885bbdc..dab66e2 100644 (file)
@@ -52,6 +52,7 @@ int avr_init(avr_t * avr)
        avr->run = avr_callback_run_raw;
        avr->sleep = avr_callback_sleep_raw;
        avr->state = cpu_Running;
+       avr->log = 1;
        avr_reset(avr); 
        return 0;
 }
@@ -210,7 +211,8 @@ void avr_callback_run_gdb(avr_t * avr)
 
        if (avr->state == cpu_Sleeping) {
                if (!avr->sreg[S_I]) {
-                       if ( avr->log_level) printf("simavr: sleeping with interrupts off, quitting gracefully\n");
+                       if (avr->log)
+                               printf("simavr: sleeping with interrupts off, quitting gracefully\n");
                        avr_terminate(avr);
                        avr->state = cpu_Done;
                        return;
@@ -263,7 +265,8 @@ void avr_callback_run_raw(avr_t * avr)
 
        if (avr->state == cpu_Sleeping) {
                if (!avr->sreg[S_I]) {
-                       if ( avr->log_level) printf("simavr: sleeping with interrupts off, quitting gracefully\n");
+                       if (avr->log)
+                               printf("simavr: sleeping with interrupts off, quitting gracefully\n");
                        avr_terminate(avr);
                        avr->state = cpu_Done;
                        return;
index b8091b6..bc895aa 100644 (file)
@@ -249,7 +249,8 @@ typedef struct avr_t {
        uint32_t        pending[2];             // pending interrupts
 
        // DEBUG ONLY -- value ignored if CONFIG_SIMAVR_TRACE = 0
-       int             trace;
+       int             trace : 1,
+                       log : 2; // log level, default to 1
 
        // Only used if CONFIG_SIMAVR_TRACE is defined
        struct avr_trace_data_t *trace_data;