Commit from zer0 on branch b_zer0 (2007-10-28 23:26 CET)
=================================

Add some macros

  aversive  include/aversive/pgmspace.h  1.1.2.2


====================================
aversive/include/aversive/pgmspace.h  (1.1.2.1 -> 1.1.2.2)
====================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: pgmspace.h,v 1.1.2.1 2007-05-23 17:18:09 zer0 Exp $
+ *  Revision : $Id: pgmspace.h,v 1.1.2.2 2007-10-28 22:26:19 zer0 Exp $
  *
  */
 
@@ -33,11 +33,29 @@
 
 #else
 
+#include <stdint.h>
+
 #define printf_P printf
+#define memcmp_P memcmp
+#define strlen_P strlen
 #define vfprintf_P vfprintf
 #define vsprintf_P vsprintf
 #define PGM_P const char *
 #define PSTR(x) x
+#define PROGMEM
+#define pgm_read_word(x) (*(x))
+#define pgm_read_byte(x) (*(x))
+
+typedef void prog_void;
+typedef char prog_char;
+typedef unsigned char prog_uchar;
+typedef int8_t prog_int8_t;
+typedef uint8_t prog_uint8_t;
+typedef int16_t prog_int16_t;
+typedef uint16_t prog_uint16_t;
+typedef int32_t prog_int32_t;
+typedef uint32_t prog_uint32_t;
+typedef int64_t prog_int64_t;
 
 #endif /* HOST_VERSION */
 #endif /* _AVERSIVE_PGMSPACE_H_ */


Commit from zer0 on branch b_zer0 (2007-10-28 23:26 CET)
=================================

Better accuracy of scheduler.

  aversive  modules/base/scheduler/scheduler_interrupt.c  1.1.2.3
  aversive  modules/base/scheduler/scheduler.h            1.8.4.7


=====================================================
aversive/modules/base/scheduler/scheduler_interrupt.c  (1.1.2.2 -> 1.1.2.3)
=====================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: scheduler_interrupt.c,v 1.1.2.2 2007-05-23 17:18:11 zer0 
Exp $
+ *  Revision : $Id: scheduler_interrupt.c,v 1.1.2.3 2007-10-28 22:26:39 zer0 
Exp $
  *
  */
 
@@ -32,15 +32,16 @@
 static volatile uint8_t nb_stacking=0;
        
 
-/** this function is called from a timer interruption. If an event has
+/** 
+ *  this function is called from a timer interruption. If an event has
  *  to be scheduled, it will execute the fonction (IRQ are allowed
- *  during the execution of the function. This interruption can be
- *  interrupted by itself too, in this case it cannot executed events
- *  with a lower priority.  
+ *  during the execution of the function). This interruption can be
+ *  interrupted by itself too, in this case only events with a higher
+ *  priority can be scheduled.
  * 
  *  We assume that this function is called from a SIGNAL(), with
  *  global interrupt flag disabled --> that's why we can use cli() and
- *  sei() instead of IRQ_LOCK(f).
+ *  sei() instead of IRQ_LOCK(flags).
  */
 void
 scheduler_interrupt(void)
@@ -52,62 +53,75 @@
 
        /* maximize the number of imbrications */
        if (nb_stacking >= SCHEDULER_NB_STACKING_MAX) {
-               sei();
                return;
        }
        nb_stacking ++;
        sei();
 
-
        SLIST_INIT(&event_list);
 
        /* browse events table to determine which events should be
         * scheduled */
        for (i=0 ; i<SCHEDULER_NB_MAX_EVENT ; i++) {
                cli();
-               /* decrement timer for event if it is active */
-               if (g_tab_event[i].state == SCHEDULER_EVENT_ACTIVE &&
-                   g_tab_event[i].current_time > 0) {
-                       g_tab_event[i].current_time --;
-                       
-                       /* don't need to schedule now */
-                       if ( g_tab_event[i].current_time != 0 ) {
-                               sei();
-                               continue;
-                       }
-                       
-                       /* time to schedule, but priority is too low,
-                          delay it */
-                       if (g_tab_event[i].priority < priority_running) {
-                               g_tab_event[i].current_time = 1;
-                               sei();
-                               continue;
-                       }
-                       
-                       /* schedule it, because timer reached 0 and
-                          priority is greater than the one of the
-                          running task */
-                       g_tab_event[i].state = SCHEDULER_EVENT_SCHEDULED;
+
+               /* the event is already present in a schedule list,
+                * only update its current time until it reaches 1 */
+               if (g_tab_event[i].state == SCHEDULER_EVENT_SCHEDULED &&
+                   g_tab_event[i].current_time > 1) {
+                       //                      g_tab_event[i].current_time --;
                        sei();
-                       
-                       /* insert it in the list (list is ordered).
-                          this should be quite fast since the list is
-                          expected to be small. */
-
-                       /* easy case : list is empty */
-                       if (SLIST_FIRST(&event_list) == NULL) {
-                               SLIST_INSERT_HEAD(&event_list, &g_tab_event[i], 
next);
-                               continue;
-                       }
+                       continue;
+               }
 
-                       /* harder : find the good place in list */
-                       SLIST_FOREACH(e, &event_list, next) {
-                               next_e = SLIST_NEXT(e, next);
-                               if (next_e == NULL || 
-                                   g_tab_event[i].priority >= 
next_e->priority) {
-                                       SLIST_INSERT_AFTER(e, &g_tab_event[i], 
next);
-                                       break;
-                               }
+               /* nothing to do with other unactive events */
+               if (g_tab_event[i].state != SCHEDULER_EVENT_ACTIVE) {
+                       sei();
+                       continue;
+               }
+
+               /* decrement current time (we know it is >0 if it is
+                * in SCHEDULER_EVENT_ACTIVE state */
+               g_tab_event[i].current_time --;
+               
+               /* don't need to schedule now */
+               if ( g_tab_event[i].current_time != 0 ) {
+                       sei();
+                       continue;
+               }
+               
+               /* time to schedule, but priority is too low,
+                * delay it */
+               if (g_tab_event[i].priority <= priority_running) {
+                       g_tab_event[i].current_time = 1;
+                       sei();
+                       continue;
+               }
+
+               /* reload event (it is 0 if it is non-periodical) */
+               g_tab_event[i].current_time = g_tab_event[i].period;
+
+               /* schedule it */
+               g_tab_event[i].state = SCHEDULER_EVENT_SCHEDULED;
+               sei();
+
+               /* insert it in the list (list is ordered).
+                  this should be quite fast since the list is
+                  expected to be small. */
+
+               /* easy case : list is empty */
+               if (SLIST_FIRST(&event_list) == NULL) {
+                       SLIST_INSERT_HEAD(&event_list, &g_tab_event[i], next);
+                       continue;
+               }
+
+               /* harder : find the good place in list */
+               SLIST_FOREACH(e, &event_list, next) {
+                       next_e = SLIST_NEXT(e, next);
+                       if (next_e == NULL || 
+                           g_tab_event[i].priority >= next_e->priority) {
+                               SLIST_INSERT_AFTER(e, &g_tab_event[i], next);
+                               break;
                        }
                }
        }
@@ -128,22 +142,17 @@
                sei();
 
                /* the following fields (f and data) can't be modified
-                * when an event is in state SCHEDULED */
+                * while an event is in state SCHEDULED */
                e->f(e->data);
 
-               /* reload event if necessary */
-               if (e->period) {
-                       e->current_time = e->period;
-               }
-               
-               /* free it if it is single */
-               else {
+               cli();
+               /* free it if it is single (non-periodical) */
+               if (!e->period) {
                        e->state = SCHEDULER_EVENT_FREE;
                }
 
                /* free event if someone asked for deletion during
                 * schedule */
-               cli();
                if (e->state == SCHEDULER_EVENT_DELETING) {
                        e->state = SCHEDULER_EVENT_FREE;
                }
@@ -161,5 +170,4 @@
 
        priority_running = priority_tmp;
        nb_stacking--;
-       sei();
 }


===========================================
aversive/modules/base/scheduler/scheduler.h  (1.8.4.6 -> 1.8.4.7)
===========================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: scheduler.h,v 1.8.4.6 2007-06-24 17:30:13 zer0 Exp $
+ *  Revision : $Id: scheduler.h,v 1.8.4.7 2007-10-28 22:26:39 zer0 Exp $
  *
  */
 
@@ -106,12 +106,12 @@
 #define TIMER_UNIT ( 65536000000LL / (CONFIG_QUARTZ) )
 #endif
 
-/** SCHEDULER_UNIT is the REAL number of microseconds between each
- *  interruption. We can use it like this :
- *    scheduler_add_periodical_event(f, 1000l/SCHEDULER_UNIT);
+/** SCHEDULER_UNIT is the number of microseconds between each
+ *  scheduler interruption. We can use it like this :
+ *    scheduler_add_periodical_event(f, 1000L/SCHEDULER_UNIT);
  *  The function f will be called every ms. 
  */
-#define SCHEDULER_UNIT ( TIMER_UNIT * SCHEDULER_CLOCK_PRESCALER )
+#define SCHEDULER_UNIT ( TIMER_UNIT * (unsigned long)SCHEDULER_CLOCK_PRESCALER 
)
 
 #define SCHEDULER_PERIODICAL 0
 #define SCHEDULER_SINGLE 1


Commit from zer0 on branch b_zer0 (2007-10-28 23:27 CET)
=================================

typo fix

  aversive  modules/devices/servo/multiservo/multiservo.c  1.5.4.4


======================================================
aversive/modules/devices/servo/multiservo/multiservo.c  (1.5.4.3 -> 1.5.4.4)
======================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: multiservo.c,v 1.5.4.3 2007-05-23 17:18:14 zer0 Exp $
+ *  Revision : $Id: multiservo.c,v 1.5.4.4 2007-10-28 22:27:03 zer0 Exp $
  *
  */
 
@@ -75,7 +75,9 @@
        while (g_multiservo.current_multiservo < MULTISERVO_NB_MAX) {
                port = g_multiservo.elts[g_multiservo.current_multiservo].port;
                if(port) {
-                       MULTISERVO_DEBUG(E_MULTISERVO, "set %d %d", 
g_multiservo.current_multiservo, 
g_multiservo.elts[g_multiservo.current_multiservo].value);
+                       MULTISERVO_DEBUG(E_MULTISERVO, "set %d %d", 
+                                        g_multiservo.current_multiservo, 
+                                        
g_multiservo.elts[g_multiservo.current_multiservo].value);
                        sbi(*port, 
g_multiservo.elts[g_multiservo.current_multiservo].bitnum);
                        g_multiservo.id_prev = g_multiservo.current_multiservo;
                        MULTISERVO_OCR = 
g_multiservo.elts[g_multiservo.current_multiservo].value;


Commit from zer0 on branch b_zer0 (2007-10-28 23:28 CET)
=================================

Add an profiling example program

+ aversive  projects/profiling_example/uart_config.h       1.1.2.1
+ aversive  projects/profiling_example/timer_config.h      1.1.2.1
+ aversive  projects/profiling_example/time_config.h       1.1.2.1
+ aversive  projects/profiling_example/scheduler_config.h  1.1.2.1
+ aversive  projects/profiling_example/parse_symbols.py    1.1.2.1
+ aversive  projects/profiling_example/main.c              1.1.2.1
+ aversive  projects/profiling_example/Makefile            1.1.2.1
+ aversive  projects/profiling_example/.config             1.1.2.1


=================================================
aversive/projects/profiling_example/uart_config.h  (1.1.2.1)
=================================================

@@ -0,0 +1,72 @@
+/*  
+ *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: uart_config.h,v 1.1.2.1 2007-10-28 22:28:19 zer0 Exp $
+ *
+ */
+
+/* Droids-corp 2004 - Zer0
+ * config for uart module
+ */
+
+#ifndef UART_CONFIG_H
+#define UART_CONFIG_H
+
+/*
+ * UART0 definitions 
+ */
+
+/* compile uart0 fonctions, undefine it to pass compilation */
+#define UART0_COMPILE  
+
+/* enable uart0 if == 1, disable if == 0 */
+#define UART0_ENABLED  1
+
+/* enable uart0 interrupts if == 1, disable if == 0 */
+#define UART0_INTERRUPT_ENABLED  1
+
+#define UART0_BAUDRATE 9600
+
+/* 
+ * if you enable this, the maximum baudrate you can reach is 
+ * higher, but the precision is lower. 
+ */
+#define UART0_USE_DOUBLE_SPEED 0
+//#define UART0_USE_DOUBLE_SPEED 1
+
+#define UART0_RX_FIFO_SIZE 4
+#define UART0_TX_FIFO_SIZE 16
+//#define UART0_NBITS 5
+//#define UART0_NBITS 6
+//#define UART0_NBITS 7
+#define UART0_NBITS 8
+//#define UART0_NBITS 9
+
+#define UART0_PARITY UART_PARTITY_NONE
+//#define UART0_PARITY UART_PARTITY_ODD
+//#define UART0_PARITY UART_PARTITY_EVEN
+
+#define UART0_STOP_BIT UART_STOP_BITS_1
+//#define UART0_STOP_BIT UART_STOP_BITS_2
+
+
+
+
+/* .... same for uart 1, 2, 3 ... */
+
+#endif
+


==================================================
aversive/projects/profiling_example/timer_config.h  (1.1.2.1)
==================================================

@@ -0,0 +1,39 @@
+/*  
+ *  Copyright Droids Corporation, Microb Technology, Eirbot (2006)
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: timer_config.h,v 1.1.2.1 2007-10-28 22:28:19 zer0 Exp $
+ *
+ */
+
+#define TIMER0_ENABLED
+
+/* #define TIMER1_ENABLED */
+/* #define TIMER1A_ENABLED */
+/* #define TIMER1B_ENABLED */
+/* #define TIMER1C_ENABLED */
+
+/* #define TIMER2_ENABLED */
+
+/* #define TIMER3_ENABLED */
+/* #define TIMER3A_ENABLED */
+/* #define TIMER3B_ENABLED */
+/* #define TIMER3C_ENABLED */
+
+#define TIMER0_PRESCALER_DIV 8
+/* #define TIMER1_PRESCALER_DIV 1 */
+/* #define TIMER2_PRESCALER_DIV 1 */
+/* #define TIMER3_PRESCALER_DIV 1 */


=================================================
aversive/projects/profiling_example/time_config.h  (1.1.2.1)
=================================================

@@ -0,0 +1,23 @@
+/*  
+ *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: time_config.h,v 1.1.2.1 2007-10-28 22:28:19 zer0 Exp $
+ *
+ */
+
+/** precision of the time processor, in us */
+#define TIME_PRECISION 10000l


======================================================
aversive/projects/profiling_example/scheduler_config.h  (1.1.2.1)
======================================================

@@ -0,0 +1,50 @@
+/*  
+ *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: scheduler_config.h,v 1.1.2.1 2007-10-28 22:28:19 zer0 Exp $
+ *
+ */
+
+#ifndef _SCHEDULER_CONFIG_H_
+#define _SCHEDULER_CONFIG_H_
+
+#define _SCHEDULER_CONFIG_VERSION_ 3
+
+/** maximum number of allocated events */
+#define SCHEDULER_NB_MAX_EVENT 2
+
+
+//#define SCHEDULER_CK TIMER0_PRESCALER_DIV_8
+//#define SCHEDULER_CLOCK_PRESCALER 8 
+
+/** the num of the timer to use for the scheduler */
+#define SCHEDULER_TIMER_NUM 0
+
+/** number of allowed imbricated scheduler interrupts. The maximum
+ * should be SCHEDULER_NB_MAX_EVENT since we never need to imbricate
+ * more than once per event. If it is less, it can avoid to browse the
+ * event table, events are delayed (we loose precision) but it takes
+ * less CPU */
+#define SCHEDULER_NB_STACKING_MAX SCHEDULER_NB_MAX_EVENT
+
+/** define it for debug infos (not recommended, because very slow on
+ *  an AVR, it uses printf in an interrupt). It can be useful if
+ *  prescaler is very high, making the timer interrupt period very
+ *  long in comparison to printf() */
+/* #define SCHEDULER_DEBUG */
+
+#endif // _SCHEDULER_CONFIG_H_


====================================================
aversive/projects/profiling_example/parse_symbols.py  (1.1.2.1)
====================================================

@@ -0,0 +1,65 @@
+#!/usr/bin/python
+
+import sys
+
+if len(sys.argv) != 2:
+    print "Bad arguments"
+    print "Usage: parse_symbols.py file.sym"
+    sys.exit(1)
+
+symlist=[]
+global_cpt=0
+
+f=open(sys.argv[1])
+
+# parse .sym file and fill a list
+while True:
+    l=f.readline()
+    if l=='':
+        break
+
+    address, type, name = l[:-1].split(' ')
+    if type != 'T':
+        continue
+
+    #    print "%x %s"%(int(address,16),name)
+    symlist.append([int(address, 16), name, 0])
+    
+f.close()
+
+
+while True:
+    l=sys.stdin.readline()
+    if l=='':
+        break
+
+    try:
+        add=int(l, 16)*2
+    except:
+        print "Bad value"
+        continue
+
+    prev = None
+    i=1
+    while i < len(symlist):
+        address, name, cpt = symlist[i]
+        if add < address:
+            symlist[i-1][2] += 1
+            global_cpt += 1
+            break
+        i+=1
+        
+    # address cannot be in last symbols, so we
+    # suppose it is not found
+    if i == len(symlist):
+        print "Cannot find symbol"
+        break
+
+symlist.sort(cmp=lambda x,y:x[2]<y[2] and 1 or -1)
+
+for sym in symlist:
+    address, name, cpt = sym
+    if not cpt:
+        continue
+    print "%2.2f%% (%.3d/%.3d) %s[%.8x]"%( (float(cpt)*100.)/global_cpt, cpt,
+                                           global_cpt, name, address)


==========================================
aversive/projects/profiling_example/main.c  (1.1.2.1)
==========================================

@@ -0,0 +1,176 @@
+/*  
+ *  Copyright Droids Corporation (2007)
+ *  Olivier MATZ <[EMAIL PROTECTED]>
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: main.c,v 1.1.2.1 2007-10-28 22:28:19 zer0 Exp $
+ *
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <aversive/wait.h>
+#include <scheduler.h>
+#include <timer.h>
+#include <time.h>
+#include <uart.h>
+
+
+#define PROFILE_TIME 10
+volatile int a = 0;
+
+void __attribute__ ((noinline)) dump_reg(uint16_t pc)
+{
+       static volatile uint8_t cpt = PROFILE_TIME;
+
+       if (cpt == 1) {
+               OCR2 = 0x80 + (rand()&0x7F);
+
+               TCCR2 = 2;
+               TCNT2 = 0;
+       }
+       else if (cpt == 0) {
+               OCR2 = 0;
+               TCCR2 = 4;
+               TCNT2 = 0;
+               cpt = PROFILE_TIME;
+               printf("%.4x\n", pc);
+       }
+       cpt--;
+}
+
+
+void SIG_OUTPUT_COMPARE2(void) __attribute__ ((signal , naked, __INTR_ATTRS));
+
+void SIG_OUTPUT_COMPARE2(void)
+{
+       asm volatile("push r1" "\n\t"
+                    "push __tmp_reg__" "\n\t"
+
+                    /* save sreg */
+                    "in __tmp_reg__,__SREG__" "\n\t"
+                    "push __tmp_reg__" "\n\t"
+                    "eor r1, r1" "\n\t"
+                    
+                    /* save used regs (see avr-gcc doc about used regs) */
+                    "push r18" "\n\t"
+                    "push r19" "\n\t"
+                    "push r20" "\n\t"
+                    "push r21" "\n\t"
+                    "push r22" "\n\t"
+                    "push r23" "\n\t"
+                    "push r24" "\n\t"
+                    "push r25" "\n\t"
+                    "push r26" "\n\t"
+                    "push r27" "\n\t"
+                    "push r30" "\n\t"
+                    "push r31" "\n\t"
+                    
+                    /* load sp in r30/r31 */
+                    "in r30, __SP_L__" "\n\t"
+                    "in r31, __SP_H__" "\n\t"
+
+                    /* point to saved PC */
+                    "subi r30, lo8(-16)" "\n\t"
+                    "sbci r31, hi8(-16)" "\n\t"
+
+                    /* load Program Counter into r24-r25 */
+                    "ldd r25, Z+0" "\n\t"
+                    "ldd r24, Z+1" "\n\t"
+       
+                    /* call dump_reg, params are in r24-25 */
+                    "call dump_reg" "\n\t"
+
+                    /* restore regs */
+                    "pop r31" "\n\t"
+                    "pop r30" "\n\t"
+                    "pop r27" "\n\t"
+                    "pop r26" "\n\t"
+                    "pop r25" "\n\t"
+                    "pop r24" "\n\t"
+                    "pop r23" "\n\t"
+                    "pop r22" "\n\t"
+                    "pop r21" "\n\t"
+                    "pop r20" "\n\t"
+                    "pop r19" "\n\t"
+                    "pop r18" "\n\t"
+
+                    /* sreg */
+                    "pop __tmp_reg__" "\n\t"
+                    "out __SREG__, __tmp_reg__" "\n\t"
+       
+                    /* tmp reg */
+                    "pop __tmp_reg__" "\n\t"
+                    "pop r1" "\n\t"
+
+                    "reti" "\n\t"
+                    :
+                    :
+                    );
+}
+
+
+void __attribute__((noinline)) test1(void)
+{
+       a=2;
+}
+
+void __attribute__((noinline)) test2(void)
+{
+       a=1;
+       a=2;
+       a=3;
+}
+
+void test_sched(void * dummy)
+{
+       time_wait_ms(50);
+}
+
+
+int main(void)
+{
+       uart_init();
+       fdevopen(uart0_dev_send, uart0_dev_recv);
+       timer_init();
+       scheduler_init();
+       time_init(200);
+
+       srand(0x1337);
+       sei();
+       printf("Start profiling during 10 secs\n");
+
+       scheduler_add_periodical_event(test_sched, NULL, 100000L / 
SCHEDULER_UNIT);
+
+       OCR2 = 0;
+       TCNT2 = 0; 
+       TCCR2 = 4;
+       sbi(TIMSK, OCIE2);
+
+       while(time_get_s() < 10) {
+               test1();
+               test2();
+       };
+
+       TCCR2=0;
+       printf("Finished\n");
+       while(1);
+
+       return 0;
+}


============================================
aversive/projects/profiling_example/Makefile  (1.1.2.1)
============================================

@@ -0,0 +1,21 @@
+TARGET = main
+
+# repertoire des modules
+AVERSIVE_DIR = ../..
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+# List Assembler source files here.
+# Make them always end in a capital .S.  Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC = 
+
+########################################
+
+-include .aversive_conf
+include $(AVERSIVE_DIR)/mk/aversive_project.mk


===========================================
aversive/projects/profiling_example/.config  (1.1.2.1)
===========================================

@@ -0,0 +1,217 @@
+#
+# Automatically generated by make menuconfig: don't edit
+#
+
+#
+# Hardware
+#
+# CONFIG_MCU_AT90S2313 is not set
+# CONFIG_MCU_AT90S2323 is not set
+# CONFIG_MCU_AT90S3333 is not set
+# CONFIG_MCU_AT90S2343 is not set
+# CONFIG_MCU_ATTINY22 is not set
+# CONFIG_MCU_ATTINY26 is not set
+# CONFIG_MCU_AT90S4414 is not set
+# CONFIG_MCU_AT90S4433 is not set
+# CONFIG_MCU_AT90S4434 is not set
+# CONFIG_MCU_AT90S8515 is not set
+# CONFIG_MCU_AT90S8534 is not set
+# CONFIG_MCU_AT90S8535 is not set
+# CONFIG_MCU_AT86RF401 is not set
+# CONFIG_MCU_ATMEGA103 is not set
+# CONFIG_MCU_ATMEGA603 is not set
+# CONFIG_MCU_AT43USB320 is not set
+# CONFIG_MCU_AT43USB355 is not set
+# CONFIG_MCU_AT76C711 is not set
+# CONFIG_MCU_ATMEGA8 is not set
+# CONFIG_MCU_ATMEGA48 is not set
+# CONFIG_MCU_ATMEGA88 is not set
+# CONFIG_MCU_ATMEGA8515 is not set
+# CONFIG_MCU_ATMEGA8535 is not set
+# CONFIG_MCU_ATTINY13 is not set
+# CONFIG_MCU_ATTINY2313 is not set
+# CONFIG_MCU_ATMEGA16 is not set
+# CONFIG_MCU_ATMEGA161 is not set
+# CONFIG_MCU_ATMEGA162 is not set
+# CONFIG_MCU_ATMEGA163 is not set
+# CONFIG_MCU_ATMEGA165 is not set
+# CONFIG_MCU_ATMEGA168 is not set
+# CONFIG_MCU_ATMEGA169 is not set
+# CONFIG_MCU_ATMEGA32 is not set
+# CONFIG_MCU_ATMEGA323 is not set
+# CONFIG_MCU_ATMEGA325 is not set
+# CONFIG_MCU_ATMEGA3250 is not set
+# CONFIG_MCU_ATMEGA64 is not set
+# CONFIG_MCU_ATMEGA645 is not set
+# CONFIG_MCU_ATMEGA6450 is not set
+CONFIG_MCU_ATMEGA128=y
+# CONFIG_MCU_AT90CAN128 is not set
+# CONFIG_MCU_AT94K is not set
+# CONFIG_MCU_AT90S1200 is not set
+CONFIG_QUARTZ=16000000
+
+#
+# Generation options
+#
+# CONFIG_OPTM_0 is not set
+# CONFIG_OPTM_1 is not set
+# CONFIG_OPTM_2 is not set
+# CONFIG_OPTM_3 is not set
+CONFIG_OPTM_S=y
+CONFIG_MATH_LIB=y
+# CONFIG_FDEVOPEN_COMPAT is not set
+# CONFIG_MINIMAL_PRINTF is not set
+CONFIG_STANDARD_PRINTF=y
+# CONFIG_ADVANCED_PRINTF is not set
+CONFIG_FORMAT_IHEX=y
+# CONFIG_FORMAT_SREC is not set
+# CONFIG_FORMAT_BINARY is not set
+
+#
+# Base modules
+#
+CONFIG_MODULE_CIRBUF=y
+# CONFIG_MODULE_CIRBUF_LARGE is not set
+# CONFIG_MODULE_FIXED_POINT is not set
+# CONFIG_MODULE_VECT2 is not set
+CONFIG_MODULE_SCHEDULER=y
+CONFIG_MODULE_SCHEDULER_CREATE_CONFIG=y
+CONFIG_MODULE_SCHEDULER_USE_TIMERS=y
+CONFIG_MODULE_TIME=y
+CONFIG_MODULE_TIME_CREATE_CONFIG=y
+
+#
+# Communication modules
+#
+CONFIG_MODULE_UART=y
+CONFIG_MODULE_UART_CREATE_CONFIG=y
+# CONFIG_MODULE_I2C is not set
+# CONFIG_MODULE_I2C_MASTER is not set
+# CONFIG_MODULE_I2C_MULTIMASTER is not set
+# CONFIG_MODULE_I2C_CREATE_CONFIG is not set
+# CONFIG_MODULE_MF2_CLIENT is not set
+# CONFIG_MODULE_MF2_CLIENT_USE_SCHEDULER is not set
+# CONFIG_MODULE_MF2_CLIENT_CREATE_CONFIG is not set
+# CONFIG_MODULE_MF2_SERVER is not set
+# CONFIG_MODULE_MF2_SERVER_CREATE_CONFIG is not set
+
+#
+# Hardware modules
+#
+CONFIG_MODULE_TIMER=y
+CONFIG_MODULE_TIMER_CREATE_CONFIG=y
+# CONFIG_MODULE_TIMER_DYNAMIC is not set
+# CONFIG_MODULE_PWM is not set
+# CONFIG_MODULE_PWM_CREATE_CONFIG is not set
+# CONFIG_MODULE_ADC is not set
+# CONFIG_MODULE_ADC_CREATE_CONFIG is not set
+
+#
+# IHM modules
+#
+# CONFIG_MODULE_MENU is not set
+# CONFIG_MODULE_RDLINE is not set
+# CONFIG_MODULE_RDLINE_CREATE_CONFIG is not set
+# CONFIG_MODULE_RDLINE_KILL_BUF is not set
+# CONFIG_MODULE_RDLINE_HISTORY is not set
+# CONFIG_MODULE_PARSE is not set
+
+#
+# External devices modules
+#
+# CONFIG_MODULE_LCD is not set
+# CONFIG_MODULE_LCD_CREATE_CONFIG is not set
+# CONFIG_MODULE_MULTISERVO is not set
+# CONFIG_MODULE_MULTISERVO_CREATE_CONFIG is not set
+
+#
+# Brushless motor drivers (you should enable pwm modules to see all)
+#
+# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL is not set
+# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_CREATE_CONFIG is not set
+# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_DOUBLE is not set
+# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_DOUBLE_CREATE_CONFIG is not set
+
+#
+# Encoders
+#
+# CONFIG_MODULE_ENCODERS_MICROB is not set
+# CONFIG_MODULE_ENCODERS_MICROB_CREATE_CONFIG is not set
+# CONFIG_MODULE_ENCODERS_EIRBOT is not set
+# CONFIG_MODULE_ENCODERS_EIRBOT_CREATE_CONFIG is not set
+
+#
+# Robot specific modules
+#
+# CONFIG_MODULE_ROBOT_SYSTEM is not set
+# CONFIG_MODULE_POSITION_MANAGER is not set
+# CONFIG_MODULE_TRAJECTORY_MANAGER is not set
+
+#
+# Control system modules
+#
+# CONFIG_MODULE_CONTROL_SYSTEM_MANAGER is not set
+# CONFIG_MODULE_PID is not set
+# CONFIG_MODULE_RAMP is not set
+# CONFIG_MODULE_QUADRAMP is not set
+# CONFIG_MODULE_QUADRAMP_DERIVATE is not set
+# CONFIG_MODULE_BIQUAD is not set
+
+#
+# Crypto modules
+#
+# CONFIG_MODULE_AES is not set
+# CONFIG_MODULE_AES_CTR is not set
+# CONFIG_MODULE_MD5 is not set
+# CONFIG_MODULE_MD5_HMAC is not set
+# CONFIG_MODULE_RC4 is not set
+
+#
+# Encodings modules
+#
+# CONFIG_MODULE_BASE64 is not set
+# CONFIG_MODULE_HAMMING is not set
+
+#
+# Debug modules
+#
+# CONFIG_MODULE_DIAGNOSTIC is not set
+# CONFIG_MODULE_DIAGNOSTIC_CREATE_CONFIG is not set
+# CONFIG_MODULE_ERROR is not set
+# CONFIG_MODULE_ERROR_CREATE_CONFIG is not set
+
+#
+# Programmer options
+#
+# CONFIG_AVRDUDE is not set
+CONFIG_AVARICE=y
+
+#
+# Avrdude
+#
+# CONFIG_AVRDUDE_PROG_FUTURELEC is not set
+# CONFIG_AVRDUDE_PROG_ABCMINI is not set
+# CONFIG_AVRDUDE_PROG_PICOWEB is not set
+# CONFIG_AVRDUDE_PROG_SP12 is not set
+# CONFIG_AVRDUDE_PROG_ALF is not set
+# CONFIG_AVRDUDE_PROG_BASCOM is not set
+# CONFIG_AVRDUDE_PROG_DT006 is not set
+# CONFIG_AVRDUDE_PROG_PONY_STK200 is not set
+CONFIG_AVRDUDE_PROG_STK200=y
+# CONFIG_AVRDUDE_PROG_PAVR is not set
+# CONFIG_AVRDUDE_PROG_BUTTERFLY is not set
+# CONFIG_AVRDUDE_PROG_AVR910 is not set
+# CONFIG_AVRDUDE_PROG_STK500 is not set
+# CONFIG_AVRDUDE_PROG_AVRISP is not set
+# CONFIG_AVRDUDE_PROG_BSD is not set
+# CONFIG_AVRDUDE_PROG_DAPA is not set
+# CONFIG_AVRDUDE_PROG_JTAG1 is not set
+CONFIG_AVRDUDE_PORT="/dev/parport0"
+
+#
+# Avarice
+#
+CONFIG_AVARICE_PORT="/dev/ttyS0"
+CONFIG_AVARICE_DEBUG_PORT=1234
+CONFIG_AVARICE_PROG_MKI=y
+# CONFIG_AVARICE_PROG_MKII is not set


Commit from zer0 on branch b_zer0 (2007-10-28 23:31 CET)
=================================

add a comment

  aversive  projects/profiling_example/main.c  1.1.2.2


==========================================
aversive/projects/profiling_example/main.c  (1.1.2.1 -> 1.1.2.2)
==========================================

@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: main.c,v 1.1.2.1 2007-10-28 22:28:19 zer0 Exp $
+ *  Revision : $Id: main.c,v 1.1.2.2 2007-10-28 22:31:58 zer0 Exp $
  *
  *
  */
@@ -31,6 +31,26 @@
 #include <time.h>
 #include <uart.h>
 
+/*
+ * The TIMER2 is used to randomly interrupt the running program and
+ * display the address of the interrupted function on the serial port.
+ *
+ * The addresses can be parsed using the python program in the same
+ * dir:
+ *    ./parse_symbols.py compiler_files/main.sym 
+ *
+ * The stdin of the python script is the list of addresses. Below is
+ * its output:
+ *
+ * 50.88% (145/285) time_wait_ms[00000b5a]
+ * 13.33% (038/285) test2[00000130]
+ * 11.23% (032/285) time_get_s[0000069e]
+ * 8.07% (023/285) main[00000156]
+ * 7.37% (021/285) test1[00000122]
+ * 4.56% (013/285) scheduler_interrupt[00000dcc]
+ * 4.56% (013/285) time_increment[000007e8]
+ */
+
 
 #define PROFILE_TIME 10
 volatile int a = 0;


Commit from zer0 on branch b_zer0 (2007-10-28 23:32 CET)
=================================

oops I forgot to remove the comment.

  aversive  modules/base/scheduler/scheduler_interrupt.c  1.1.2.4


=====================================================
aversive/modules/base/scheduler/scheduler_interrupt.c  (1.1.2.3 -> 1.1.2.4)
=====================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: scheduler_interrupt.c,v 1.1.2.3 2007-10-28 22:26:39 zer0 
Exp $
+ *  Revision : $Id: scheduler_interrupt.c,v 1.1.2.4 2007-10-28 22:32:27 zer0 
Exp $
  *
  */
 
@@ -69,7 +69,7 @@
                 * only update its current time until it reaches 1 */
                if (g_tab_event[i].state == SCHEDULER_EVENT_SCHEDULED &&
                    g_tab_event[i].current_time > 1) {
-                       //                      g_tab_event[i].current_time --;
+                       g_tab_event[i].current_time --;
                        sei();
                        continue;
                }

_______________________________________________
Avr-list mailing list
Avr-list@droids-corp.org
CVSWEB : http://cvsweb.droids-corp.org/cgi-bin/viewcvs.cgi/aversive
WIKI : http://wiki.droids-corp.org/index.php/Aversive
DOXYGEN : http://zer0.droids-corp.org/doxygen_aversive/html/
BUGZILLA : http://bugzilla.droids-corp.org
COMMIT LOGS : http://zer0.droids-corp.org/aversive_commitlog

Répondre à