Commit from zer0 on branch b_zer0 (2007-11-28 00:16 CET) =================================
Allow scheduler to be scheduled manually aversive config/Configure.help 1.13.4.10 aversive config/config.in 1.42.4.12 aversive modules/base/scheduler/scheduler.c 1.9.4.4 aversive modules/base/scheduler/scheduler.h 1.8.4.8 aversive modules/base/scheduler/scheduler_private.h 1.1.2.7 aversive modules/base/scheduler/config/scheduler_config.h 1.1.10.8 aversive modules/base/scheduler/test/scheduler_config.h 1.4.10.7 aversive modules/base/time/time.c 1.4.4.2 ============================== aversive/config/Configure.help (1.13.4.9 -> 1.13.4.10) ============================== @@ -62,10 +62,14 @@ Create a scheduler_config.h file if it does not exist, with a default configuration. -CONFIG_MODULE_SCHEDULER_USE_TIMERS - Use the hardware/timer module to call the scheduler. Thanks to it, - it can support many archs and timers. If you don't enable it, you - must use TIMER0 overflow interrupt, and only some AVR are supported. +CONFIG_MODULE_SCHEDULER_TIMER0 + Use either the hardware/timer module, the timer0 or a manual call + for the to call the scheduler. The generic timer module support + many archs and timers. If you don't enable it, you must use TIMER0 + overflow interrupt, and only some AVR are supported, or you should + can call the scheduler manually. In this case, the SCHEDULER_UNIT + macro has to be defined in configuration file. + CONFIG_TIME This module can be used to get a human readable time. It uses the ========================= aversive/config/config.in (1.42.4.11 -> 1.42.4.12) ========================= @@ -129,9 +129,9 @@ dep_bool ' |-- Create Default scheduler config' CONFIG_MODULE_SCHEDULER_CREATE_CONFIG \ $CONFIG_MODULE_SCHEDULER -dep_bool ' |-- Use timer module (recommended)' CONFIG_MODULE_SCHEDULER_USE_TIMERS \ - $CONFIG_MODULE_TIMER \ - $CONFIG_MODULE_SCHEDULER +choice 'Scheduler config' "use_timer_module CONFIG_MODULE_SCHEDULER_USE_TIMERS\ + use_timer0 CONFIG_MODULE_SCHEDULER_TIMER0\ + manual CONFIG_MODULE_SCHEDULER_MANUAL" use_timer_module #### TIME dep_bool 'Time' CONFIG_MODULE_TIME \ =========================================== aversive/modules/base/scheduler/scheduler.c (1.9.4.3 -> 1.9.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: scheduler.c,v 1.9.4.3 2007-05-23 17:18:11 zer0 Exp $ + * Revision : $Id: scheduler.c,v 1.9.4.4 2007-11-27 23:16:14 zer0 Exp $ * */ @@ -41,7 +41,9 @@ #ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS SCHEDULER_TIMER_REGISTER(); -#else +#endif + +#ifdef CONFIG_MODULE_SCHEDULER_TIMER0 /* activation of corresponding interrupt */ sbi(TIMSK, TOIE0); @@ -51,7 +53,7 @@ } -#ifndef CONFIG_MODULE_SCHEDULER_USE_TIMERS +#ifdef CONFIG_MODULE_SCHEDULER_TIMER0 SIGNAL(SIG_OVERFLOW0) { scheduler_interrupt(); =========================================== aversive/modules/base/scheduler/scheduler.h (1.8.4.7 -> 1.8.4.8) =========================================== @@ -1,5 +1,5 @@ /* - * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * Copyright Droids Corporation (2007) * * 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 @@ -15,20 +15,15 @@ * 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.7 2007-10-28 22:26:39 zer0 Exp $ + * Revision : $Id: scheduler.h,v 1.8.4.8 2007-11-27 23:16:15 zer0 Exp $ * */ -/* Eirbot & Microb Technology 2005 - Zer0 +/* Olivier MATZ <[EMAIL PROTECTED]> * Interface of the SCHEDULER Module */ /** \file scheduler.h - * \brief Interface of the SCHEDULER Module - * - * \todo multi arch ? - * - * \test nothing done * * This module provides a function scheduler. You can call * scheduler_add_event for adding a function to the scheduler, and @@ -94,16 +89,21 @@ #else #error "Bad SCHEDULER_TIMER_NUM value in config file" #endif -#else /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ -#define SCHEDULER_TIMER_BITS 8 + #endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ +#ifdef CONFIG_MODULE_SCHEDULER_TIMER0 +#define SCHEDULER_TIMER_BITS 8 +#endif /* CONFIG_MODULE_SCHEDULER_TIMER0 */ + +#ifndef CONFIG_MODULE_SCHEDULER_MANUAL + /** TIME_UNIT is the number of microseconds between each interruption * if the prescaler equals 1 */ #if SCHEDULER_TIMER_BITS == 8 -#define TIMER_UNIT ( 256000000LL / (CONFIG_QUARTZ) ) +#define TIMER_UNIT_FLOAT ( 256000000.0 / (double)(CONFIG_QUARTZ) ) #else -#define TIMER_UNIT ( 65536000000LL / (CONFIG_QUARTZ) ) +#define TIMER_UNIT_FLOAT ( 65536000000.0 / (double)(CONFIG_QUARTZ) ) #endif /** SCHEDULER_UNIT is the number of microseconds between each @@ -111,7 +111,12 @@ * scheduler_add_periodical_event(f, 1000L/SCHEDULER_UNIT); * The function f will be called every ms. */ -#define SCHEDULER_UNIT ( TIMER_UNIT * (unsigned long)SCHEDULER_CLOCK_PRESCALER ) +#define SCHEDULER_UNIT_FLOAT ( TIMER_UNIT_FLOAT * (double)SCHEDULER_CLOCK_PRESCALER ) +#define SCHEDULER_UNIT ( (unsigned long) SCHEDULER_UNIT_FLOAT ) + +#endif /* ! CONFIG_MODULE_SCHEDULER_MANUAL */ + + #define SCHEDULER_PERIODICAL 0 #define SCHEDULER_SINGLE 1 =================================================== aversive/modules/base/scheduler/scheduler_private.h (1.1.2.6 -> 1.1.2.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_private.h,v 1.1.2.6 2007-06-24 17:30:13 zer0 Exp $ + * Revision : $Id: scheduler_private.h,v 1.1.2.7 2007-11-27 23:16:15 zer0 Exp $ * */ @@ -23,9 +23,9 @@ #define _SCHEDULER_PRIVATE_H_ /* sanity checks */ -#if _SCHEDULER_CONFIG_VERSION_ != 3 +#if _SCHEDULER_CONFIG_VERSION_ != 4 #warning "You are using an old version of scheduler_config.h file" -#warning "_SCHEDULER_CONFIG_VERSION_ is != 3" +#warning "_SCHEDULER_CONFIG_VERSION_ is != 4" #warning "Look in modules/base/scheduler/config directory to import changes" #warning "You should define SCHEDULER_NB_STACKING_MAX and SCHEDULER_CK" #endif ========================================================= aversive/modules/base/scheduler/config/scheduler_config.h (1.1.10.7 -> 1.1.10.8) ========================================================= @@ -15,14 +15,14 @@ * 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.10.7 2007-06-17 19:28:03 zer0 Exp $ + * Revision : $Id: scheduler_config.h,v 1.1.10.8 2007-11-27 23:16:15 zer0 Exp $ * */ #ifndef _SCHEDULER_CONFIG_H_ #define _SCHEDULER_CONFIG_H_ -#define _SCHEDULER_CONFIG_VERSION_ 3 +#define _SCHEDULER_CONFIG_VERSION_ 4 /** maximum number of allocated events */ #define SCHEDULER_NB_MAX_EVENT 5 @@ -40,16 +40,26 @@ you are using (look in include/aversive/parts.h). Obviously, the values of SCHEDULER_CK and SCHEDULER_CLOCK_PRESCALER must also be coherent (TIMER0_PRESCALER_DIV_VALUE and VALUE) */ -#else /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ +#endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ + +#ifdef CONFIG_MODULE_SCHEDULER_TIMER0 /* The 2 values below MUST be coherent: * if SCHEDULER_CK = TIMER0_PRESCALER_DIV_x, then * you must have SCHEDULER_CLOCK_PRESCALER = x too !!! */ #define SCHEDULER_CK TIMER0_PRESCALER_DIV_8 #define SCHEDULER_CLOCK_PRESCALER 8 -#endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ +#endif /* CONFIG_MODULE_SCHEDULER_TIMER0 */ + +/* last case, the scheduler is called manually. The user has to + define the period here */ +#ifdef CONFIG_MODULE_SCHEDULER_MANUAL + +#define SCHEDULER_UNIT_FLOAT 1000.0 +#define SCHEDULER_UNIT 1000UL +#endif /* CONFIG_MODULE_SCHEDULER_MANUAL */ /** number of allowed imbricated scheduler interrupts. The maximum * should be SCHEDULER_NB_MAX_EVENT since we never need to imbricate ======================================================= aversive/modules/base/scheduler/test/scheduler_config.h (1.4.10.6 -> 1.4.10.7) ======================================================= @@ -15,14 +15,14 @@ * 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.4.10.6 2007-06-17 19:28:03 zer0 Exp $ + * Revision : $Id: scheduler_config.h,v 1.4.10.7 2007-11-27 23:16:15 zer0 Exp $ * */ #ifndef _SCHEDULER_CONFIG_H_ #define _SCHEDULER_CONFIG_H_ -#define _SCHEDULER_CONFIG_VERSION_ 3 +#define _SCHEDULER_CONFIG_VERSION_ 4 /** maximum number of allocated events */ #define SCHEDULER_NB_MAX_EVENT 5 @@ -40,16 +40,26 @@ you are using (look in include/aversive/parts.h). Obviously, the values of SCHEDULER_CK and SCHEDULER_CLOCK_PRESCALER must also be coherent (TIMER0_PRESCALER_DIV_VALUE and VALUE) */ -#else /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ +#endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ + +#ifdef CONFIG_MODULE_SCHEDULER_TIMER0 /* The 2 values below MUST be coherent: * if SCHEDULER_CK = TIMER0_PRESCALER_DIV_x, then * you must have SCHEDULER_CLOCK_PRESCALER = x too !!! */ #define SCHEDULER_CK TIMER0_PRESCALER_DIV_8 #define SCHEDULER_CLOCK_PRESCALER 8 -#endif /* CONFIG_MODULE_SCHEDULER_USE_TIMERS */ +#endif /* CONFIG_MODULE_SCHEDULER_TIMER0 */ + +/* last case, the scheduler is called manually. The user has to + define the period here */ +#ifdef CONFIG_MODULE_SCHEDULER_MANUAL + +#define SCHEDULER_UNIT_FLOAT 1000.0 +#define SCHEDULER_UNIT 1000UL +#endif /* CONFIG_MODULE_SCHEDULER_MANUAL */ /** number of allowed imbricated scheduler interrupts. The maximum * should be SCHEDULER_NB_MAX_EVENT since we never need to imbricate ================================= aversive/modules/base/time/time.c (1.4.4.1 -> 1.4.4.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: time.c,v 1.4.4.1 2006-11-26 21:06:01 zer0 Exp $ + * Revision : $Id: time.c,v 1.4.4.2 2007-11-27 23:16:15 zer0 Exp $ * */ @@ -43,7 +43,7 @@ /**********************************************************/ -#define NB_SCHEDULER_UNIT ( ((float)(TIME_PRECISION)) / SCHEDULER_UNIT ) +#define NB_SCHEDULER_UNIT ( ((float)(TIME_PRECISION)) / SCHEDULER_UNIT_FLOAT ) #define NB_SCHEDULER_UNIT_NOT_NULL (NB_SCHEDULER_UNIT == 0 ? 1.0 : NB_SCHEDULER_UNIT) static volatile time_h t; Commit from zer0 (2007-11-28 00:16 CET) ================ - add log function - scheduler is trigged manually (not tested) aversive_projects microb2008/main/.config 1.8 aversive_projects microb2008/main/commands.c 1.4 aversive_projects microb2008/main/main.c 1.9 aversive_projects microb2008/main/main.h 1.4 aversive_projects microb2008/main/scheduler_config.h 1.2 ========================================= aversive_projects/microb2008/main/.config (1.7 -> 1.8) ========================================= @@ -1,5 +1,5 @@ # -# Automatically generated make config: don't edit +# Automatically generated by make menuconfig: don't edit # # @@ -70,27 +70,21 @@ # # Base modules # - -# -# Enable math library in generation options to see all modules -# CONFIG_MODULE_CIRBUF=y # CONFIG_MODULE_CIRBUF_LARGE is not set CONFIG_MODULE_FIXED_POINT=y CONFIG_MODULE_VECT2=y CONFIG_MODULE_SCHEDULER=y CONFIG_MODULE_SCHEDULER_CREATE_CONFIG=y -CONFIG_MODULE_SCHEDULER_USE_TIMERS=y +# CONFIG_MODULE_SCHEDULER_USE_TIMERS is not set +# CONFIG_MODULE_SCHEDULER_TIMER0 is not set +CONFIG_MODULE_SCHEDULER_MANUAL=y CONFIG_MODULE_TIME=y CONFIG_MODULE_TIME_CREATE_CONFIG=y # # Communication modules # - -# -# uart needs circular buffer, mf2 client may need scheduler -# CONFIG_MODULE_UART=y CONFIG_MODULE_UART_CREATE_CONFIG=y CONFIG_MODULE_I2C=y @@ -159,10 +153,6 @@ # Control system modules # CONFIG_MODULE_CONTROL_SYSTEM_MANAGER=y - -# -# Filters -# CONFIG_MODULE_PID=y # CONFIG_MODULE_RAMP is not set CONFIG_MODULE_QUADRAMP=y @@ -172,10 +162,6 @@ # # Crypto modules # - -# -# Crypto modules depend on utils module -# # CONFIG_MODULE_AES is not set # CONFIG_MODULE_AES_CTR is not set # CONFIG_MODULE_MD5 is not set @@ -185,20 +171,12 @@ # # Encodings modules # - -# -# Encoding modules depend on utils module -# # CONFIG_MODULE_BASE64 is not set # CONFIG_MODULE_HAMMING is not set # # Debug modules # - -# -# Debug modules depend on utils module -# # CONFIG_MODULE_DIAGNOSTIC is not set # CONFIG_MODULE_DIAGNOSTIC_CREATE_CONFIG is not set CONFIG_MODULE_ERROR=y ============================================ aversive_projects/microb2008/main/commands.c (1.3 -> 1.4) ============================================ @@ -636,6 +636,81 @@ }; +/**********************************************************/ +/* Start */ + +/* this structure is filled when cmd_start is parsed successfully */ +struct cmd_start_result { + fixed_string_t arg0; + fixed_string_t color; +}; + +/* function called when cmd_start is parsed successfully */ +static void cmd_start_parsed(void * parsed_result, void * data) +{ + printf_P(PSTR("Not implemented\n")); +} + +prog_char str_start_arg0[] = "start"; +parse_pgm_token_string_t cmd_start_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_start_result, arg0, str_start_arg0); +prog_char str_start_color[] = "blue#red"; +parse_pgm_token_string_t cmd_start_color = TOKEN_STRING_INITIALIZER(struct cmd_start_result, color, str_start_color); + +prog_char help_start[] = "Start the robot"; +parse_pgm_inst_t cmd_start = { + .f = cmd_start_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_start, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_start_arg0, + (prog_void *)&cmd_start_color, + NULL, + }, +}; + + +/**********************************************************/ +/* Log */ + +/* this structure is filled when cmd_log is parsed successfully */ +struct cmd_log_result { + fixed_string_t arg0; + fixed_string_t arg1; + uint8_t arg2; +}; + +/* function called when cmd_log is parsed successfully */ +static void cmd_log_parsed(void * parsed_result, void * data) +{ + struct cmd_log_result *res = (struct cmd_log_result *) parsed_result; + + if (!strcmp_P(res->arg1, PSTR("level"))) { + robot.log_level = res->arg2; + } + + else if (!strcmp_P(res->arg1, PSTR("type"))) { + robot.log_type = res->arg2; + } +} + +prog_char str_log_arg0[] = "log"; +parse_pgm_token_string_t cmd_log_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_log_result, arg0, str_log_arg0); +prog_char str_log_arg1[] = "level#type"; +parse_pgm_token_string_t cmd_log_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_log_result, arg1, str_log_arg1); +parse_pgm_token_num_t cmd_log_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_log_result, arg2, INT32); + +prog_char help_log[] = "Set log options: level (0 -> 5), type (0=all)"; +parse_pgm_inst_t cmd_log = { + .f = cmd_log_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_log, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_log_arg0, + (prog_void *)&cmd_log_arg1, + (prog_void *)&cmd_log_arg2, + NULL, + }, +}; /**********************************************************/ @@ -876,6 +951,8 @@ (parse_pgm_inst_t *)&cmd_position, (parse_pgm_inst_t *)&cmd_reset, (parse_pgm_inst_t *)&cmd_interact, + (parse_pgm_inst_t *)&cmd_log, + (parse_pgm_inst_t *)&cmd_start, (parse_pgm_inst_t *)&cmd_consign, (parse_pgm_inst_t *)&cmd_consign_all, (parse_pgm_inst_t *)&cmd_goto1, ======================================== aversive_projects/microb2008/main/main.c (1.8 -> 1.9) ======================================== @@ -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: main.c,v 1.8 2007-11-26 23:25:37 zer0 Exp $ + * Revision : $Id: main.c,v 1.9 2007-11-27 23:16:53 zer0 Exp $ * */ @@ -195,19 +195,39 @@ cpt++; } +void main_timer_interrupt(void) +{ + static uint8_t cpt = 0; + static uint8_t encoder_running = 0; + + cpt++; + + /* BAAAAd */ + if (encoder_running) + return; + + encoder_running = 1; + sei(); + + encoders_microb_manage(NULL); + encoder_running = 0; + + if (cpt%4) + scheduler_interrupt(); +} + /* log function, add a command to configure * it dynamically */ void mylog(struct error * e, ...) { va_list ap; u16 stream_flags = stdout->flags; - if (1) - /* if (e->err_num != E_TRAJECTORY) */ - // if (e->err_num != E_USER_NOTHING) + if (robot.log_level < e->severity) return; - /* if (e->severity > ERROR_SEVERITY_WARNING) */ - /* return; */ + if ( (robot.log_type != 0) && + (robot.log_type != e->err_num) ) + return; va_start(ap, e); printf_P(PSTR("[%d]: E%d "), e->severity, e->err_num); @@ -291,8 +311,16 @@ printf_P(PSTR("salut\n")); uart0_register_rx_event(emergency); + /* LOGS */ + error_register_emerg(mylog); + error_register_error(mylog); + error_register_warning(mylog); + error_register_notice(mylog); + error_register_debug(mylog); + /* TIMER */ timer_init(); + timer0_register_OV_intr(main_timer_interrupt); /* SCHEDULER */ scheduler_init(); ======================================== aversive_projects/microb2008/main/main.h (1.3 -> 1.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: main.h,v 1.3 2007-11-15 11:14:54 zer0 Exp $ + * Revision : $Id: main.h,v 1.4 2007-11-27 23:16:53 zer0 Exp $ * */ @@ -80,7 +80,7 @@ #define I2C_POLL_PRIO 20 struct robot { - s08 cs_events; + int8_t cs_events; struct robot_system rs; struct robot_position pos; @@ -95,7 +95,10 @@ struct trajectory traj; - u08 blocking; /* XXX ? */ + uint8_t log_level; + uint8_t log_type; + + uint8_t blocking; /* XXX ? */ }; extern struct robot robot; @@ -123,7 +126,7 @@ #define wait_cond_or_timeout(cond, timeout) \ ({ \ microseconds __us = time_get_us2(); \ - u08 __ret = 1; \ + uint8_t __ret = 1; \ while(! (cond)) { \ if (time_get_us2() - __us > (timeout)*1000L) {\ __ret = 0; \ ==================================================== aversive_projects/microb2008/main/scheduler_config.h (1.1 -> 1.2) ==================================================== @@ -15,21 +15,21 @@ * 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 2007-06-28 22:13:04 zer0 Exp $ + * Revision : $Id: scheduler_config.h,v 1.2 2007-11-27 23:16:53 zer0 Exp $ * */ #ifndef _SCHEDULER_CONFIG_H_ #define _SCHEDULER_CONFIG_H_ -#define _SCHEDULER_CONFIG_VERSION_ 3 +#define _SCHEDULER_CONFIG_VERSION_ 4 /** maximum number of allocated events */ #define SCHEDULER_NB_MAX_EVENT 7 -/** the num of the timer to use for the scheduler */ -#define SCHEDULER_TIMER_NUM 0 +#define SCHEDULER_UNIT_FLOAT 1000.0 +#define SCHEDULER_UNIT 1000L /** number of allowed imbricated scheduler interrupts. The maximum * should be SCHEDULER_NB_MAX_EVENT since we never need to imbricate _______________________________________________ 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