From: zer0 Date: Wed, 20 Jan 2010 22:53:01 +0000 (+0100) Subject: first hostsim project X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=commitdiff_plain;h=1f8274e9bca0d2433f101f267b86bc70dc2ae8c4;ds=sidebyside first hostsim project --- diff --git a/config/config.in b/config/config.in index 305cb79..acaf2a2 100644 --- a/config/config.in +++ b/config/config.in @@ -382,8 +382,7 @@ dep_bool ' |-- Compensate centrifugal force' CONFIG_MODULE_COMPENSATE_CENTRIFUG 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 diff --git a/include/aversive/pgmspace.h b/include/aversive/pgmspace.h index ff37bdf..9ff8df4 100644 --- a/include/aversive/pgmspace.h +++ b/include/aversive/pgmspace.h @@ -39,6 +39,7 @@ #include #include #include +#include typedef void prog_void; typedef char prog_char; @@ -111,7 +112,7 @@ static inline int vsprintf_P(char *buf, const prog_char *s, #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) diff --git a/modules/devices/robot/robot_system/robot_system.h b/modules/devices/robot/robot_system/robot_system.h index ff868d3..afaa352 100755 --- a/modules/devices/robot/robot_system/robot_system.h +++ b/modules/devices/robot/robot_system/robot_system.h @@ -27,8 +27,9 @@ */ #include +#ifdef CONFIG_MODULE_ROBOT_SYSTEM_USE_F64 #include - +#endif #include "angle_distance.h" #ifndef _ROBOT_SYSTEM_H_ diff --git a/projects/microb2010/tests/hostsim/.config b/projects/microb2010/tests/hostsim/.config new file mode 100644 index 0000000..a5d281a --- /dev/null +++ b/projects/microb2010/tests/hostsim/.config @@ -0,0 +1,254 @@ +# +# 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 diff --git a/projects/microb2010/tests/hostsim/Makefile b/projects/microb2010/tests/hostsim/Makefile new file mode 100644 index 0000000..9fe84d3 --- /dev/null +++ b/projects/microb2010/tests/hostsim/Makefile @@ -0,0 +1,20 @@ +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 + diff --git a/projects/microb2010/tests/hostsim/cs.c b/projects/microb2010/tests/hostsim/cs.c new file mode 100644 index 0000000..7fb39f5 --- /dev/null +++ b/projects/microb2010/tests/hostsim/cs.c @@ -0,0 +1,238 @@ +/* + * Copyright Droids Corporation + * Olivier Matz + * + * 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 +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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); +} diff --git a/projects/microb2010/tests/hostsim/cs.h b/projects/microb2010/tests/hostsim/cs.h new file mode 100644 index 0000000..d3d1fa9 --- /dev/null +++ b/projects/microb2010/tests/hostsim/cs.h @@ -0,0 +1,26 @@ +/* + * Copyright Droids Corporation + * Olivier Matz + * + * 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); diff --git a/projects/microb2010/tests/hostsim/error_config.h b/projects/microb2010/tests/hostsim/error_config.h new file mode 100644 index 0000000..530acd3 --- /dev/null +++ b/projects/microb2010/tests/hostsim/error_config.h @@ -0,0 +1,31 @@ +/* + * 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 diff --git a/projects/microb2010/tests/hostsim/main.c b/projects/microb2010/tests/hostsim/main.c new file mode 100644 index 0000000..9f5a15f --- /dev/null +++ b/projects/microb2010/tests/hostsim/main.c @@ -0,0 +1,90 @@ +/* + * 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 +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +//#include +#include + +#include "cs.h" +#include "main.h" + +struct genboard gen; +struct mainboard mainboard; + +int main(void) +{ +#ifndef HOST_VERSION + uart_init(); + fdevopen(uart0_dev_send, uart0_dev_recv); + sei(); +#else + int i; +#endif + +#ifdef CONFIG_MODULE_TIMER + timer_init(); +#endif + scheduler_init(); + printf("init\n"); + +#ifdef HOST_VERSION + hostsim_init(); +#endif + time_init(TIME_PRIO); + + + microb_cs_init(); + + gen.logs[0] = E_USER_CS; + gen.log_level = 5; + + mainboard.flags = DO_ENCODERS | DO_RS | + DO_POS | DO_POWER | DO_BD | DO_CS; + + trajectory_d_rel(&mainboard.traj, 100); + + time_wait_ms(1000); + return 0; +} + + diff --git a/projects/microb2010/tests/hostsim/main.h b/projects/microb2010/tests/hostsim/main.h new file mode 100644 index 0000000..5f07ab4 --- /dev/null +++ b/projects/microb2010/tests/hostsim/main.h @@ -0,0 +1,171 @@ +/* + * 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; \ +}) diff --git a/projects/microb2010/tests/hostsim/pid_config.h b/projects/microb2010/tests/hostsim/pid_config.h new file mode 100755 index 0000000..fa95f08 --- /dev/null +++ b/projects/microb2010/tests/hostsim/pid_config.h @@ -0,0 +1,30 @@ +/* + * 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 diff --git a/projects/microb2010/tests/hostsim/robotsim.c b/projects/microb2010/tests/hostsim/robotsim.c new file mode 100644 index 0000000..6f4dbbf --- /dev/null +++ b/projects/microb2010/tests/hostsim/robotsim.c @@ -0,0 +1,81 @@ +/* + * 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 +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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; +} diff --git a/projects/microb2010/tests/hostsim/robotsim.h b/projects/microb2010/tests/hostsim/robotsim.h new file mode 100644 index 0000000..56415f9 --- /dev/null +++ b/projects/microb2010/tests/hostsim/robotsim.h @@ -0,0 +1,24 @@ +/* + * 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); diff --git a/projects/microb2010/tests/hostsim/scheduler_config.h b/projects/microb2010/tests/hostsim/scheduler_config.h new file mode 100644 index 0000000..8042648 --- /dev/null +++ b/projects/microb2010/tests/hostsim/scheduler_config.h @@ -0,0 +1,77 @@ +/* + * 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_ diff --git a/projects/microb2010/tests/hostsim/time_config.h b/projects/microb2010/tests/hostsim/time_config.h new file mode 100644 index 0000000..14db608 --- /dev/null +++ b/projects/microb2010/tests/hostsim/time_config.h @@ -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 2009-02-20 21:10:01 zer0 Exp $ + * + */ + +/** precision of the time processor, in us */ +#define TIME_PRECISION 25000l diff --git a/projects/microb2010/tests/hostsim/timer_config.h b/projects/microb2010/tests/hostsim/timer_config.h new file mode 100644 index 0000000..724e689 --- /dev/null +++ b/projects/microb2010/tests/hostsim/timer_config.h @@ -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-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 */ diff --git a/projects/microb2010/tests/hostsim/uart_config.h b/projects/microb2010/tests/hostsim/uart_config.h new file mode 100644 index 0000000..ba61726 --- /dev/null +++ b/projects/microb2010/tests/hostsim/uart_config.h @@ -0,0 +1,114 @@ +/* + * 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 2006-12-02 18:17:42 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 57600 + +/* + * 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 ... */ + + + + +/* + * UART1 definitions + */ + +/* compile uart0 fonctions, undefine it to pass compilation */ +#define UART1_COMPILE + +/* enable uart0 if == 1, disable if == 0 */ +#define UART1_ENABLED 1 + +/* enable uart0 interrupts if == 1, disable if == 0 */ +#define UART1_INTERRUPT_ENABLED 1 + +#define UART1_BAUDRATE 57600 + +/* + * if you enable this, the maximum baudrate you can reach is + * higher, but the precision is lower. + */ +#define UART1_USE_DOUBLE_SPEED 0 +//#define UART1_USE_DOUBLE_SPEED 1 + +#define UART1_RX_FIFO_SIZE 4 +#define UART1_TX_FIFO_SIZE 16 +//#define UART1_NBITS 5 +//#define UART1_NBITS 6 +//#define UART1_NBITS 7 +#define UART1_NBITS 8 +//#define UART1_NBITS 9 + +#define UART1_PARITY UART_PARTITY_NONE +//#define UART1_PARITY UART_PARTITY_ODD +//#define UART1_PARITY UART_PARTITY_EVEN + +#define UART1_STOP_BIT UART_STOP_BITS_1 +//#define UART1_STOP_BIT UART_STOP_BITS_2 + + + +#endif +