dep_bool 'Trajectory manager' CONFIG_MODULE_TRAJECTORY_MANAGER \
$CONFIG_MODULE_POSITION_MANAGER \
$CONFIG_MODULE_SCHEDULER \
- $CONFIG_MODULE_VECT2 \
- $CONFIG_MODULE_FIXED_POINT
+ $CONFIG_MODULE_VECT2
#### BLOCKING DETECTION MANAGER
bool 'Blocking detection manager' CONFIG_MODULE_BLOCKING_DETECTION_MANAGER
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <string.h>
typedef void prog_void;
typedef char prog_char;
#define PGM_P const char *
#define PSTR(x) x
#define PROGMEM
-#define printf_P(arg...) printf(args)
+#define printf_P(args...) printf(args)
#define sprintf_P(buf, args...) sprintf(buf, args)
#define snprintf_P(buf, n, args...) snprintf(buf, n, args)
*/
#include <aversive.h>
+#ifdef CONFIG_MODULE_ROBOT_SYSTEM_USE_F64
#include <f64.h>
-
+#endif
#include "angle_distance.h"
#ifndef _ROBOT_SYSTEM_H_
--- /dev/null
+#
+# 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_ATMEGA1281 is not set
+# CONFIG_MCU_AT90CAN128 is not set
+# CONFIG_MCU_AT94K is not set
+# CONFIG_MCU_AT90S1200 is not set
+# CONFIG_MCU_ATMEGA2560 is not set
+# CONFIG_MCU_ATMEGA256 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_NO_PRINTF 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=y
+# CONFIG_MODULE_GEOMETRY is not set
+CONFIG_MODULE_HOSTSIM=y
+CONFIG_MODULE_SCHEDULER=y
+# CONFIG_MODULE_SCHEDULER_STATS is not set
+CONFIG_MODULE_SCHEDULER_CREATE_CONFIG=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
+# CONFIG_MODULE_TIME_EXT is not set
+# CONFIG_MODULE_TIME_EXT_CREATE_CONFIG is not set
+
+#
+# Communication modules
+#
+CONFIG_MODULE_UART=y
+# CONFIG_MODULE_UART_9BITS is not set
+# CONFIG_MODULE_UART_CREATE_CONFIG is not set
+# CONFIG_MODULE_SPI is not set
+# CONFIG_MODULE_SPI_CREATE_CONFIG is not set
+# 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 is not set
+# CONFIG_MODULE_TIMER_DYNAMIC is not set
+# CONFIG_MODULE_PWM is not set
+# CONFIG_MODULE_PWM_CREATE_CONFIG is not set
+# CONFIG_MODULE_PWM_NG 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_VT100=y
+CONFIG_MODULE_RDLINE=y
+# CONFIG_MODULE_RDLINE_CREATE_CONFIG is not set
+CONFIG_MODULE_RDLINE_KILL_BUF=y
+CONFIG_MODULE_RDLINE_HISTORY=y
+CONFIG_MODULE_PARSE=y
+# CONFIG_MODULE_PARSE_NO_FLOAT 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
+# CONFIG_MODULE_AX12 is not set
+# CONFIG_MODULE_AX12_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 (you need comm/spi for encoders_spi)
+#
+# 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
+# CONFIG_MODULE_ENCODERS_SPI is not set
+# CONFIG_MODULE_ENCODERS_SPI_CREATE_CONFIG is not set
+
+#
+# Robot specific modules (fixed point lib may be needed)
+#
+CONFIG_MODULE_ROBOT_SYSTEM=y
+# CONFIG_MODULE_ROBOT_SYSTEM_USE_F64 is not set
+# CONFIG_MODULE_ROBOT_SYSTEM_MOT_AND_EXT is not set
+CONFIG_MODULE_POSITION_MANAGER=y
+CONFIG_MODULE_COMPENSATE_CENTRIFUGAL_FORCE=y
+CONFIG_MODULE_TRAJECTORY_MANAGER=y
+CONFIG_MODULE_BLOCKING_DETECTION_MANAGER=y
+# CONFIG_MODULE_OBSTACLE_AVOIDANCE is not set
+# CONFIG_MODULE_OBSTACLE_AVOIDANCE_CREATE_CONFIG is not set
+
+#
+# Control system modules
+#
+CONFIG_MODULE_CONTROL_SYSTEM_MANAGER=y
+CONFIG_MODULE_PID=y
+CONFIG_MODULE_PID_CREATE_CONFIG=y
+# CONFIG_MODULE_RAMP is not set
+CONFIG_MODULE_QUADRAMP=y
+# CONFIG_MODULE_QUADRAMP_DERIVATE is not set
+# CONFIG_MODULE_BIQUAD is not set
+
+#
+# Radio devices
+#
+# CONFIG_MODULE_CC2420 is not set
+# CONFIG_MODULE_CC2420_CREATE_CONFIG 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=y
+CONFIG_MODULE_ERROR_CREATE_CONFIG=y
+
+#
+# Programmer options
+#
+CONFIG_AVRDUDE=y
+# CONFIG_AVARICE is not set
+
+#
+# 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_PROG_AVR109 is not set
+CONFIG_AVRDUDE_PORT="/dev/parport0"
+CONFIG_AVRDUDE_BAUDRATE=19200
+
+#
+# Avarice
+#
+CONFIG_AVARICE_PORT="/dev/ttyS0"
+CONFIG_AVARICE_DEBUG_PORT=1234
+CONFIG_AVARICE_PROG_MKI=y
+# CONFIG_AVARICE_PROG_MKII is not set
+# CONFIG_AVRDUDE_CHECK_SIGNATURE is not set
--- /dev/null
+TARGET = main
+
+# Aversive root directory
+AVERSIVE_DIR = ../../../..
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c cs.c robotsim.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
+
--- /dev/null
+/*
+ * Copyright Droids Corporation
+ * Olivier Matz <zer0@droids-corp.org>
+ *
+ * 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: cs.c,v 1.9 2009-11-08 17:24:33 zer0 Exp $
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <aversive.h>
+#include <aversive/error.h>
+
+#include <timer.h>
+#include <scheduler.h>
+#include <time.h>
+
+#include <pid.h>
+#include <quadramp.h>
+#include <control_system_manager.h>
+#include <trajectory_manager.h>
+#include <blocking_detection_manager.h>
+#include <robot_system.h>
+#include <position_manager.h>
+
+#include <parse.h>
+#include <rdline.h>
+
+#include "robotsim.h"
+#include "main.h"
+
+/* called every 5 ms */
+static void do_cs(void *dummy)
+{
+ static uint16_t cpt = 0;
+ static int32_t old_a = 0, old_d = 0;
+
+ robotsim_update();
+
+#if 0
+ /* read encoders */
+ if (mainboard.flags & DO_ENCODERS) {
+ encoders_spi_manage(NULL);
+ }
+#endif
+
+ /* XXX there is an issue which is probably related to avr-libc
+ * 1.6.2 (debian): this code using fixed_point lib does not
+ * work with it */
+ /* robot system, conversion to angle,distance */
+ if (mainboard.flags & DO_RS) {
+ int16_t a,d;
+ rs_update(&mainboard.rs); /* takes about 0.5 ms */
+ /* process and store current speed */
+ a = rs_get_angle(&mainboard.rs);
+ d = rs_get_distance(&mainboard.rs);
+ mainboard.speed_a = a - old_a;
+ mainboard.speed_d = d - old_d;
+ old_a = a;
+ old_d = d;
+ }
+
+ /* control system */
+ if (mainboard.flags & DO_CS) {
+ if (mainboard.angle.on)
+ cs_manage(&mainboard.angle.cs);
+ if (mainboard.distance.on)
+ cs_manage(&mainboard.distance.cs);
+ }
+ if ((cpt & 1) && (mainboard.flags & DO_POS)) {
+ /* about 1.5ms (worst case without centrifugal force
+ * compensation) */
+ position_manage(&mainboard.pos);
+ }
+#if 0
+ if (mainboard.flags & DO_BD) {
+ bd_manage_from_cs(&mainboard.angle.bd, &mainboard.angle.cs);
+ bd_manage_from_cs(&mainboard.distance.bd, &mainboard.distance.cs);
+ }
+ if (mainboard.flags & DO_TIMER) {
+ uint8_t second;
+ /* the robot should stop correctly in the strat, but
+ * in some cases, we must force the stop from an
+ * interrupt */
+ second = time_get_s();
+ if (second >= MATCH_TIME + 2) {
+ pwm_ng_set(LEFT_PWM, 0);
+ pwm_ng_set(RIGHT_PWM, 0);
+ printf_P(PSTR("END OF TIME\r\n"));
+ while(1);
+ }
+ }
+ /* brakes */
+ if (mainboard.flags & DO_POWER)
+ BRAKE_OFF();
+ else
+ BRAKE_ON();
+#endif
+ cpt++;
+ //dump_cs("distance", &mainboard.distance.cs);
+ //dump_cs("angle", &mainboard.angle.cs);
+}
+
+void dump_cs_debug(const char *name, struct cs *cs)
+{
+ DEBUG(E_USER_CS, "%s cons=% .5"PRIi32" fcons=% .5"PRIi32" err=% .5"PRIi32" "
+ "in=% .5"PRIi32" out=% .5"PRIi32"",
+ name, cs_get_consign(cs), cs_get_filtered_consign(cs),
+ cs_get_error(cs), cs_get_filtered_feedback(cs),
+ cs_get_out(cs));
+}
+
+void dump_cs(const char *name, struct cs *cs)
+{
+ printf_P(PSTR("%s cons=% .5"PRIi32" fcons=% .5"PRIi32" err=% .5"PRIi32" "
+ "in=% .5"PRIi32" out=% .5"PRIi32"\r\n"),
+ name, cs_get_consign(cs), cs_get_filtered_consign(cs),
+ cs_get_error(cs), cs_get_filtered_feedback(cs),
+ cs_get_out(cs));
+}
+
+void dump_pid(const char *name, struct pid_filter *pid)
+{
+ printf_P(PSTR("%s P=% .8"PRIi32" I=% .8"PRIi32" D=% .8"PRIi32" out=% .8"PRIi32"\r\n"),
+ name,
+ pid_get_value_in(pid) * pid_get_gain_P(pid),
+ pid_get_value_I(pid) * pid_get_gain_I(pid),
+ pid_get_value_D(pid) * pid_get_gain_D(pid),
+ pid_get_value_out(pid));
+}
+
+void microb_cs_init(void)
+{
+ /* ROBOT_SYSTEM */
+ rs_init(&mainboard.rs);
+ rs_set_left_pwm(&mainboard.rs, robotsim_pwm, LEFT_PWM);
+ rs_set_right_pwm(&mainboard.rs, robotsim_pwm, RIGHT_PWM);
+ /* increase gain to decrease dist, increase left and it will turn more left */
+ rs_set_left_ext_encoder(&mainboard.rs, robotsim_encoder_get,
+ LEFT_ENCODER, IMP_COEF);
+ rs_set_right_ext_encoder(&mainboard.rs, robotsim_encoder_get,
+ RIGHT_ENCODER, IMP_COEF);
+ /* rs will use external encoders */
+ rs_set_flags(&mainboard.rs, RS_USE_EXT);
+
+ /* POSITION MANAGER */
+ position_init(&mainboard.pos);
+ position_set_physical_params(&mainboard.pos, VIRTUAL_TRACK_MM, DIST_IMP_MM);
+ position_set_related_robot_system(&mainboard.pos, &mainboard.rs);
+ //position_set_centrifugal_coef(&mainboard.pos, 0.000016);
+ position_use_ext(&mainboard.pos);
+
+ /* TRAJECTORY MANAGER */
+ trajectory_init(&mainboard.traj);
+ trajectory_set_cs(&mainboard.traj, &mainboard.distance.cs,
+ &mainboard.angle.cs);
+ trajectory_set_robot_params(&mainboard.traj, &mainboard.rs, &mainboard.pos);
+ trajectory_set_speed(&mainboard.traj, SPEED_DIST_FAST, SPEED_ANGLE_FAST); /* d, a */
+ /* distance window, angle window, angle start */
+ trajectory_set_windows(&mainboard.traj, 200., 5.0, 30.);
+
+ /* ---- CS angle */
+ /* PID */
+ pid_init(&mainboard.angle.pid);
+ pid_set_gains(&mainboard.angle.pid, 500, 10, 7000);
+ pid_set_maximums(&mainboard.angle.pid, 0, 20000, 4095);
+ pid_set_out_shift(&mainboard.angle.pid, 10);
+ pid_set_derivate_filter(&mainboard.angle.pid, 4);
+
+ /* QUADRAMP */
+ quadramp_init(&mainboard.angle.qr);
+ quadramp_set_1st_order_vars(&mainboard.angle.qr, 2000, 2000); /* set speed */
+ quadramp_set_2nd_order_vars(&mainboard.angle.qr, 13, 13); /* set accel */
+
+ /* CS */
+ cs_init(&mainboard.angle.cs);
+ cs_set_consign_filter(&mainboard.angle.cs, quadramp_do_filter, &mainboard.angle.qr);
+ cs_set_correct_filter(&mainboard.angle.cs, pid_do_filter, &mainboard.angle.pid);
+ cs_set_process_in(&mainboard.angle.cs, rs_set_angle, &mainboard.rs);
+ cs_set_process_out(&mainboard.angle.cs, rs_get_angle, &mainboard.rs);
+ cs_set_consign(&mainboard.angle.cs, 0);
+
+ /* Blocking detection */
+ bd_init(&mainboard.angle.bd);
+ bd_set_speed_threshold(&mainboard.angle.bd, 80);
+ bd_set_current_thresholds(&mainboard.angle.bd, 500, 8000, 1000000, 50);
+
+ /* ---- CS distance */
+ /* PID */
+ pid_init(&mainboard.distance.pid);
+ pid_set_gains(&mainboard.distance.pid, 500, 10, 7000);
+ pid_set_maximums(&mainboard.distance.pid, 0, 2000, 4095);
+ pid_set_out_shift(&mainboard.distance.pid, 10);
+ pid_set_derivate_filter(&mainboard.distance.pid, 6);
+
+ /* QUADRAMP */
+ quadramp_init(&mainboard.distance.qr);
+ quadramp_set_1st_order_vars(&mainboard.distance.qr, 2000, 2000); /* set speed */
+ quadramp_set_2nd_order_vars(&mainboard.distance.qr, 17, 17); /* set accel */
+
+ /* CS */
+ cs_init(&mainboard.distance.cs);
+ cs_set_consign_filter(&mainboard.distance.cs, quadramp_do_filter, &mainboard.distance.qr);
+ cs_set_correct_filter(&mainboard.distance.cs, pid_do_filter, &mainboard.distance.pid);
+ cs_set_process_in(&mainboard.distance.cs, rs_set_distance, &mainboard.rs);
+ cs_set_process_out(&mainboard.distance.cs, rs_get_distance, &mainboard.rs);
+ cs_set_consign(&mainboard.distance.cs, 0);
+
+ /* Blocking detection */
+ bd_init(&mainboard.distance.bd);
+ bd_set_speed_threshold(&mainboard.distance.bd, 60);
+ bd_set_current_thresholds(&mainboard.distance.bd, 500, 8000, 1000000, 50);
+
+ /* set them on !! */
+ mainboard.angle.on = 1;
+ mainboard.distance.on = 1;
+
+
+ scheduler_add_periodical_event_priority(do_cs, NULL,
+ 5000L / SCHEDULER_UNIT,
+ CS_PRIO);
+}
--- /dev/null
+/*
+ * Copyright Droids Corporation
+ * Olivier Matz <zer0@droids-corp.org>
+ *
+ * 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: cs.h,v 1.3 2009-03-29 18:42:41 zer0 Exp $
+ *
+ */
+
+void microb_cs_init(void);
+void dump_cs(const char *name, struct cs *cs);
+void dump_cs_debug(const char *name, struct cs *cs);
+void dump_pid(const char *name, struct pid_filter *pid);
--- /dev/null
+/*
+ * 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: error_config.h,v 1.1.2.1 2007-03-05 14:41:07 zer0 Exp $
+ *
+ */
+
+#ifndef _ERROR_CONFIG_
+#define _ERROR_CONFIG_
+
+/** enable the dump of the comment */
+#define ERROR_DUMP_TEXTLOG
+
+/** enable the dump of filename and line number */
+#define ERROR_DUMP_FILE_LINE
+
+#endif
--- /dev/null
+/* \r
+ * Copyright Droids Corporation, Microb Technology, Eirbot (2005)\r
+ * \r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * Revision : $Id: main.c,v 1.9.4.5 2007-06-01 09:37:22 zer0 Exp $\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#include <aversive.h>\r
+#include <aversive/error.h>\r
+#include <aversive/wait.h>\r
+\r
+#include <timer.h>\r
+#include <scheduler.h>\r
+#include <time.h>\r
+\r
+#include <pid.h>\r
+#include <quadramp.h>\r
+#include <control_system_manager.h>\r
+#include <trajectory_manager.h>\r
+#include <blocking_detection_manager.h>\r
+#include <robot_system.h>\r
+#include <position_manager.h>\r
+\r
+#include <parse.h>\r
+#include <rdline.h>\r
+\r
+#include <uart.h>\r
+//#include <timer.h>\r
+#include <hostsim.h>\r
+\r
+#include "cs.h"\r
+#include "main.h"\r
+\r
+struct genboard gen;\r
+struct mainboard mainboard;\r
+\r
+int main(void)\r
+{\r
+#ifndef HOST_VERSION\r
+ uart_init();\r
+ fdevopen(uart0_dev_send, uart0_dev_recv);\r
+ sei();\r
+#else\r
+ int i;\r
+#endif\r
+\r
+#ifdef CONFIG_MODULE_TIMER\r
+ timer_init();\r
+#endif\r
+ scheduler_init();\r
+ printf("init\n");\r
+\r
+#ifdef HOST_VERSION\r
+ hostsim_init();\r
+#endif\r
+ time_init(TIME_PRIO);\r
+\r
+\r
+ microb_cs_init();\r
+\r
+ gen.logs[0] = E_USER_CS;\r
+ gen.log_level = 5;\r
+\r
+ mainboard.flags = DO_ENCODERS | DO_RS |\r
+ DO_POS | DO_POWER | DO_BD | DO_CS;\r
+\r
+ trajectory_d_rel(&mainboard.traj, 100);\r
+\r
+ time_wait_ms(1000);\r
+ return 0;\r
+}\r
+\r
+\r
--- /dev/null
+/*
+ * Copyright Droids Corporation (2009)
+ *
+ * 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.h,v 1.10 2009-11-08 17:24:33 zer0 Exp $
+ *
+ */
+
+#define LED_TOGGLE(port, bit) do { \
+ if (port & _BV(bit)) \
+ port &= ~_BV(bit); \
+ else \
+ port |= _BV(bit); \
+ } while(0)
+
+#define LED1_ON()
+#define LED1_OFF()
+#define LED1_TOGGLE()
+
+#define LED2_ON()
+#define LED2_OFF()
+#define LED2_TOGGLE()
+
+#define LED3_ON()
+#define LED3_OFF()
+#define LED3_TOGGLE()
+
+#define LED4_ON()
+#define LED4_OFF()
+#define LED4_TOGGLE()
+
+#define BRAKE_DDR()
+#define BRAKE_ON()
+#define BRAKE_OFF()
+
+/* only 90 seconds, don't forget it :) */
+#define MATCH_TIME 89
+
+/* decrease track to decrease angle */
+#define EXT_TRACK_MM 302.0188
+#define VIRTUAL_TRACK_MM EXT_TRACK_MM
+
+#define ROBOT_LENGTH 320
+#define ROBOT_WIDTH 320
+
+/* it is a 2048 imps -> 8192 because we see 1/4 period
+ * and diameter: 55mm -> perimeter 173mm
+ * 8192/173 -> 473 */
+/* increase it to go further */
+#define IMP_ENCODERS 2048
+#define WHEEL_DIAMETER_MM 55.0
+#define WHEEL_PERIM_MM (WHEEL_DIAMETER_MM * M_PI)
+#define IMP_COEF 10.
+#define DIST_IMP_MM (((IMP_ENCODERS*4) / WHEEL_PERIM_MM) * IMP_COEF)
+
+#define LEFT_ENCODER ((void *)0)
+#define RIGHT_ENCODER ((void *)1)
+
+#define LEFT_PWM ((void *)0)
+#define RIGHT_PWM ((void *)1)
+
+/** ERROR NUMS */
+#define E_USER_STRAT 194
+#define E_USER_I2C_PROTO 195
+#define E_USER_SENSOR 196
+#define E_USER_CS 197
+
+#define LED_PRIO 170
+#define TIME_PRIO 160
+#define ADC_PRIO 120
+#define CS_PRIO 100
+#define STRAT_PRIO 30
+#define I2C_POLL_PRIO 20
+#define EEPROM_TIME_PRIO 10
+
+#define CS_PERIOD 5000L
+
+#define NB_LOGS 4
+
+/* generic to all boards */
+struct genboard {
+ /* command line interface */
+ struct rdline rdl;
+ char prompt[RDLINE_PROMPT_SIZE];
+
+ /* log */
+ uint8_t logs[NB_LOGS+1];
+ uint8_t log_level;
+ uint8_t debug;
+};
+
+struct cs_block {
+ uint8_t on;
+ struct cs cs;
+ struct pid_filter pid;
+ struct quadramp_filter qr;
+ struct blocking_detection bd;
+};
+
+/* mainboard specific */
+struct mainboard {
+#define DO_ENCODERS 1
+#define DO_CS 2
+#define DO_RS 4
+#define DO_POS 8
+#define DO_BD 16
+#define DO_TIMER 32
+#define DO_POWER 64
+ uint8_t flags; /* misc flags */
+
+ /* control systems */
+ struct cs_block angle;
+ struct cs_block distance;
+
+ /* x,y positionning */
+ struct robot_system rs;
+ struct robot_position pos;
+ struct trajectory traj;
+
+ /* robot status */
+ uint8_t our_color;
+ volatile int16_t speed_a; /* current angle speed */
+ volatile int16_t speed_d; /* current dist speed */
+ int32_t pwm_l; /* current left pwm */
+ int32_t pwm_r; /* current right pwm */
+ uint8_t enable_pickup_wheels; /* these PWM are on sensorboard */
+
+};
+
+extern struct genboard gen;
+extern struct mainboard mainboard;
+
+#define SPEED_DIST_FAST 2500
+#define SPEED_ANGLE_FAST 2000
+#define SPEED_DIST_SLOW 1000
+#define SPEED_ANGLE_SLOW 1000
+#define SPEED_DIST_VERY_SLOW 400
+#define SPEED_ANGLE_VERY_SLOW 400
+
+#define WAIT_COND_OR_TIMEOUT(cond, timeout) \
+({ \
+ microseconds __us = time_get_us2(); \
+ uint8_t __ret = 1; \
+ while(! (cond)) { \
+ if (time_get_us2() - __us > (timeout)*1000L) {\
+ __ret = 0; \
+ break; \
+ } \
+ } \
+ if (__ret) \
+ DEBUG(E_USER_STRAT, "cond is true at line %d",\
+ __LINE__); \
+ else \
+ DEBUG(E_USER_STRAT, "timeout at line %d", \
+ __LINE__); \
+ \
+ __ret; \
+})
--- /dev/null
+/*
+ * 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
+ *
+ *
+ *
+ */
+
+#ifndef PID_CONFIG_H
+#define PID_CONFIG_H
+
+/** the derivate term can be filtered to remove the noise. This value
+ * is the maxium sample count to keep in memory to do this
+ * filtering. For an instance of pid, this count is defined o*/
+#define PID_DERIVATE_FILTER_MAX_SIZE 4
+
+#endif
--- /dev/null
+/*
+ * 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: main.c,v 1.9.4.5 2007-06-01 09:37:22 zer0 Exp $
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <aversive.h>
+#include <aversive/error.h>
+
+#include <timer.h>
+#include <scheduler.h>
+#include <time.h>
+
+#include <pid.h>
+#include <quadramp.h>
+#include <control_system_manager.h>
+#include <trajectory_manager.h>
+#include <blocking_detection_manager.h>
+#include <robot_system.h>
+#include <position_manager.h>
+
+#include <parse.h>
+#include <rdline.h>
+
+#include "main.h"
+
+static int32_t l_pwm, r_pwm;
+static int32_t l_enc, r_enc;
+
+/* */
+#define FILTER 98
+#define FILTER2 (100-FILTER)
+
+/* must be called periodically */
+void robotsim_update(void)
+{
+ static int32_t l_speed, r_speed;
+
+ /* XXX should lock */
+ l_speed = ((l_speed * FILTER) / 100) + ((l_pwm * 1000 * FILTER2)/1000);
+ l_enc += (l_speed / 1000);
+ r_speed = ((r_speed * FILTER) / 100) + ((r_pwm * 1000 * FILTER2)/1000);
+ r_enc += (r_speed / 1000);
+}
+
+void robotsim_pwm(void *arg, int32_t val)
+{
+ // printf("%p, %d\n", arg, val);
+ if (arg == LEFT_PWM)
+ l_pwm = val;
+ else if (arg == RIGHT_PWM)
+ r_pwm = val;
+}
+
+int32_t robotsim_encoder_get(void *arg)
+{
+ if (arg == LEFT_ENCODER)
+ return l_enc;
+ else if (arg == RIGHT_ENCODER)
+ return r_enc;
+ return 0;
+}
--- /dev/null
+/*
+ * 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: main.c,v 1.9.4.5 2007-06-01 09:37:22 zer0 Exp $
+ *
+ */
+
+void robotsim_update(void);
+void robotsim_pwm(void *arg, int32_t val);
+int32_t robotsim_encoder_get(void *arg);
--- /dev/null
+/*
+ * 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.4.10.7 2007-11-27 23:16:15 zer0 Exp $
+ *
+ */
+
+#ifndef _SCHEDULER_CONFIG_H_
+#define _SCHEDULER_CONFIG_H_
+
+#define _SCHEDULER_CONFIG_VERSION_ 4
+
+/** maximum number of allocated events */
+#define SCHEDULER_NB_MAX_EVENT 5
+
+
+/* define it only if CONFIG_MODULE_SCHEDULER_USE_TIMERS is enabled. In
+ this case, precaler is defined in timers_config.h in your project
+ directory. */
+#ifdef CONFIG_MODULE_SCHEDULER_USE_TIMERS
+/** 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
+ 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) */
+#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_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
+ * 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_
--- /dev/null
+/*
+ * 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 2009-02-20 21:10:01 zer0 Exp $
+ *
+ */
+
+/** precision of the time processor, in us */
+#define TIME_PRECISION 25000l
--- /dev/null
+/*
+ * 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-12-06 08:58:00 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 */
--- /dev/null
+/* \r
+ * Copyright Droids Corporation, Microb Technology, Eirbot (2005)\r
+ * \r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * Revision : $Id: uart_config.h,v 1.1.2.1 2006-12-02 18:17:42 zer0 Exp $\r
+ *\r
+ */\r
+\r
+/* Droids-corp 2004 - Zer0\r
+ * config for uart module\r
+ */\r
+\r
+#ifndef UART_CONFIG_H\r
+#define UART_CONFIG_H\r
+\r
+/*\r
+ * UART0 definitions \r
+ */\r
+\r
+/* compile uart0 fonctions, undefine it to pass compilation */\r
+#define UART0_COMPILE \r
+\r
+/* enable uart0 if == 1, disable if == 0 */\r
+#define UART0_ENABLED 1\r
+\r
+/* enable uart0 interrupts if == 1, disable if == 0 */\r
+#define UART0_INTERRUPT_ENABLED 1\r
+\r
+#define UART0_BAUDRATE 57600\r
+\r
+/* \r
+ * if you enable this, the maximum baudrate you can reach is \r
+ * higher, but the precision is lower. \r
+ */\r
+#define UART0_USE_DOUBLE_SPEED 0\r
+//#define UART0_USE_DOUBLE_SPEED 1\r
+\r
+#define UART0_RX_FIFO_SIZE 4\r
+#define UART0_TX_FIFO_SIZE 16\r
+//#define UART0_NBITS 5\r
+//#define UART0_NBITS 6\r
+//#define UART0_NBITS 7\r
+#define UART0_NBITS 8\r
+//#define UART0_NBITS 9\r
+\r
+#define UART0_PARITY UART_PARTITY_NONE\r
+//#define UART0_PARITY UART_PARTITY_ODD\r
+//#define UART0_PARITY UART_PARTITY_EVEN\r
+\r
+#define UART0_STOP_BIT UART_STOP_BITS_1\r
+//#define UART0_STOP_BIT UART_STOP_BITS_2\r
+\r
+\r
+\r
+\r
+/* .... same for uart 1, 2, 3 ... */\r
+\r
+\r
+\r
+\r
+/*\r
+ * UART1 definitions \r
+ */\r
+\r
+/* compile uart0 fonctions, undefine it to pass compilation */\r
+#define UART1_COMPILE \r
+\r
+/* enable uart0 if == 1, disable if == 0 */\r
+#define UART1_ENABLED 1\r
+\r
+/* enable uart0 interrupts if == 1, disable if == 0 */\r
+#define UART1_INTERRUPT_ENABLED 1\r
+\r
+#define UART1_BAUDRATE 57600\r
+\r
+/* \r
+ * if you enable this, the maximum baudrate you can reach is \r
+ * higher, but the precision is lower. \r
+ */\r
+#define UART1_USE_DOUBLE_SPEED 0\r
+//#define UART1_USE_DOUBLE_SPEED 1\r
+\r
+#define UART1_RX_FIFO_SIZE 4\r
+#define UART1_TX_FIFO_SIZE 16\r
+//#define UART1_NBITS 5\r
+//#define UART1_NBITS 6\r
+//#define UART1_NBITS 7\r
+#define UART1_NBITS 8\r
+//#define UART1_NBITS 9\r
+\r
+#define UART1_PARITY UART_PARTITY_NONE\r
+//#define UART1_PARITY UART_PARTITY_ODD\r
+//#define UART1_PARITY UART_PARTITY_EVEN\r
+\r
+#define UART1_STOP_BIT UART_STOP_BITS_1\r
+//#define UART1_STOP_BIT UART_STOP_BITS_2\r
+\r
+\r
+\r
+#endif\r
+\r