Un patch vite fait pas trop testé si y'a des amateurs, avant que je
commite.
Olivier
? test/.aversive_conf
? test/.gdb_history
? test/autoconf.h
? test/compiler_files
? test/main
? test/main.elf
? test/main.hex
? test/timer_config.h
Index: scheduler.h
===================================================================
RCS file: /var/lib/cvs/aversive/modules/base/scheduler/scheduler.h,v
retrieving revision 1.8.4.3
diff -u -p -I 'Revision :' -r1.8.4.3 scheduler.h
--- scheduler.h 23 May 2007 17:18:11 -0000 1.8.4.3
+++ scheduler.h 14 Jun 2007 09:55:04 -0000
@@ -49,14 +49,58 @@
#include <aversive.h>
#ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS
#include <timer.h>
-#endif
+#endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */
#include <scheduler_config.h>
-#define SCHEDULER_MCU_CLOCK (F_CPU / KHz)
+#ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS
+#if SCHEDULER_TIMER_NUM == 0
+#define SCHEDULER_TIMER_REGISTER() timer0_register_OV_intr(scheduler_interrupt)
+#define SCHEDULER_CLOCK_PRESCALER timer0_get_prescaler_div()
+#ifdef TCNT0H
+#define SCHEDULER_TIMER_BITS 16
+#else
+#define SCHEDULER_TIMER_BITS 8
+#endif
+
+#elif SCHEDULER_TIMER_NUM == 1
+#define SCHEDULER_TIMER_REGISTER() timer1_register_OV_intr(scheduler_interrupt)
+#define SCHEDULER_CLOCK_PRESCALER timer1_get_prescaler_div()
+#ifdef TCNT1H
+#define SCHEDULER_TIMER_BITS 16
+#else
+#define SCHEDULER_TIMER_BITS 8
+#endif
+
+#elif SCHEDULER_TIMER_NUM == 2
+#define SCHEDULER_TIMER_REGISTER() timer2_register_OV_intr(scheduler_interrupt)
+#define SCHEDULER_CLOCK_PRESCALER timer2_get_prescaler_div()
+#ifdef TCNT2H
+#define SCHEDULER_TIMER_BITS 16
+#else
+#define SCHEDULER_TIMER_BITS 8
+#endif
+
+#elif SCHEDULER_TIMER_NUM == 3
+#define SCHEDULER_TIMER_REGISTER() timer3_register_OV_intr(scheduler_interrupt)
+#define SCHEDULER_CLOCK_PRESCALER timer3_get_prescaler_div()
+#ifdef TCNT3H
+#define SCHEDULER_TIMER_BITS 16
+#else
+#define SCHEDULER_TIMER_BITS 8
+#endif
+
+#else
+#error "Bad SCHEDULER_TIMER_NUM value in config file"
+#endif
+#endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */
/** TIME_UNIT is the number of microseconds between each interruption
* if the prescaler equals 1 */
-#define TIMER_UNIT ( 256000l / (SCHEDULER_MCU_CLOCK) )
+#if SCHEDULER_TIMER_BITS == 8
+#define TIMER_UNIT ( 256000000LL / (CONFIG_QUARTZ) )
+#else
+#define TIMER_UNIT ( 65536000000LL / (CONFIG_QUARTZ) )
+#endif
/** SCHEDULER_UNIT is the REAL number of microseconds between each
* interruption. We can use it like this :
Index: scheduler_private.h
===================================================================
RCS file: /var/lib/cvs/aversive/modules/base/scheduler/scheduler_private.h,v
retrieving revision 1.1.2.4
diff -u -p -I 'Revision :' -r1.1.2.4 scheduler_private.h
--- scheduler_private.h 23 May 2007 17:18:11 -0000 1.1.2.4
+++ scheduler_private.h 14 Jun 2007 09:55:04 -0000
@@ -22,13 +22,22 @@
#ifndef _SCHEDULER_PRIVATE_H_
#define _SCHEDULER_PRIVATE_H_
-#if _SCHEDULER_CONFIG_VERSION_ != 2
+/* sanity checks */
+#if _SCHEDULER_CONFIG_VERSION_ != 3
#warning "You are using an old version of scheduler_config.h file"
-#warning "_SCHEDULER_CONFIG_VERSION_ is != 2"
+#warning "_SCHEDULER_CONFIG_VERSION_ is != 3"
#warning "Look in modules/base/scheduler/config directory to import changes"
#warning "You should define SCHEDULER_NB_STACKING_MAX and SCHEDULER_CK"
#endif
+#ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS
+#if defined SCHEDULER_TIMER_REGISTER || defined SCHEDULER_CLOCK_PRESCALER
+#warning "SCHEDULER_TIMER_REGISTER or SCHEDULER_CLOCK_PRESCALER is already"
+#warning "defined in your scheduler config file, and you are using the"
+#warning "timer module."
+#endif
+#endif
+
#include <stdint.h>
#include <aversive/queue.h>
Index: config/scheduler_config.h
===================================================================
RCS file: /var/lib/cvs/aversive/modules/base/scheduler/config/scheduler_config.h,v
retrieving revision 1.1.10.5
diff -u -p -I 'Revision :' -r1.1.10.5 scheduler_config.h
--- config/scheduler_config.h 23 May 2007 17:18:11 -0000 1.1.10.5
+++ config/scheduler_config.h 14 Jun 2007 09:55:04 -0000
@@ -22,7 +22,7 @@
#ifndef _SCHEDULER_CONFIG_H_
#define _SCHEDULER_CONFIG_H_
-#define _SCHEDULER_CONFIG_VERSION_ 2
+#define _SCHEDULER_CONFIG_VERSION_ 3
/** maximum number of allocated events */
#define SCHEDULER_NB_MAX_EVENT 5
@@ -32,9 +32,8 @@
this case, precaler is defined in timers_config.h in your project
directory. */
#ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS
-#define SCHEDULER_TIMER_REGISTER() timer0_register_OV_intr(scheduler_interrupt)
-#define SCHEDULER_CLOCK_PRESCALER timer0_get_prescaler_div()
-
+/** the num of the timer to use for the scheduler */
+#define SCHEDULER_TIMER_NUM 0
/* or set the prescaler manually (in this case, you use must TIMER0,
and the prescaler must be a correct value regarding the AVR device
Index: test/scheduler_config.h
===================================================================
RCS file: /var/lib/cvs/aversive/modules/base/scheduler/test/scheduler_config.h,v
retrieving revision 1.4.10.4
diff -u -p -I 'Revision :' -r1.4.10.4 scheduler_config.h
--- test/scheduler_config.h 23 May 2007 17:18:11 -0000 1.4.10.4
+++ test/scheduler_config.h 14 Jun 2007 09:55:04 -0000
@@ -22,7 +22,7 @@
#ifndef _SCHEDULER_CONFIG_H_
#define _SCHEDULER_CONFIG_H_
-#define _SCHEDULER_CONFIG_VERSION_ 2
+#define _SCHEDULER_CONFIG_VERSION_ 3
/** maximum number of allocated events */
#define SCHEDULER_NB_MAX_EVENT 5
@@ -32,9 +32,8 @@
this case, precaler is defined in timers_config.h in your project
directory. */
#ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS
-#define SCHEDULER_TIMER_REGISTER() timer0_register_OV_intr(scheduler_interrupt)
-#define SCHEDULER_CLOCK_PRESCALER timer0_get_prescaler_div()
-
+/** the num of the timer to use for the scheduler */
+#define SCHEDULER_TIMER_NUM 0
/* or set the prescaler manually (in this case, you use must TIMER0,
and the prescaler must be a correct value regarding the AVR device
_______________________________________________
Avr-list mailing list
[email protected]
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