hostsim enhancements
[aversive.git] / projects / microb2010 / tests / hostsim / main.c
1 /*  \r
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)\r
3  * \r
4  *  This program is free software; you can redistribute it and/or modify\r
5  *  it under the terms of the GNU General Public License as published by\r
6  *  the Free Software Foundation; either version 2 of the License, or\r
7  *  (at your option) any later version.\r
8  *\r
9  *  This program is distributed in the hope that it will be useful,\r
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  *  GNU General Public License for more details.\r
13  *\r
14  *  You should have received a copy of the GNU General Public License\r
15  *  along with this program; if not, write to the Free Software\r
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
17  *\r
18  *  Revision : $Id: main.c,v 1.9.4.5 2007-06-01 09:37:22 zer0 Exp $\r
19  *\r
20  */\r
21 \r
22 #include <stdio.h>\r
23 #include <string.h>\r
24 \r
25 #include <aversive.h>\r
26 #include <aversive/error.h>\r
27 #include <aversive/wait.h>\r
28 \r
29 #include <timer.h>\r
30 #include <scheduler.h>\r
31 #include <time.h>\r
32 \r
33 #include <pid.h>\r
34 #include <quadramp.h>\r
35 #include <control_system_manager.h>\r
36 #include <trajectory_manager.h>\r
37 #include <blocking_detection_manager.h>\r
38 #include <robot_system.h>\r
39 #include <position_manager.h>\r
40 \r
41 #include <parse.h>\r
42 #include <rdline.h>\r
43 \r
44 #include <uart.h>\r
45 //#include <timer.h>\r
46 #include <hostsim.h>\r
47 \r
48 #include "cs.h"\r
49 #include "cmdline.h"\r
50 #include "main.h"\r
51 \r
52 struct genboard gen;\r
53 struct mainboard mainboard;\r
54 \r
55 int main(void)\r
56 {\r
57         uart_init();\r
58         uart_register_rx_event(CMDLINE_UART, emergency);\r
59 #ifndef HOST_VERSION\r
60         fdevopen(uart0_dev_send, uart0_dev_recv);\r
61         sei();\r
62 #endif\r
63 \r
64         memset(&gen, 0, sizeof(gen));\r
65         memset(&mainboard, 0, sizeof(mainboard));\r
66 \r
67         /* LOGS */\r
68         error_register_emerg(mylog);\r
69         error_register_error(mylog);\r
70         error_register_warning(mylog);\r
71         error_register_notice(mylog);\r
72         error_register_debug(mylog);\r
73 \r
74 #ifdef CONFIG_MODULE_TIMER\r
75         timer_init();\r
76 #endif\r
77         scheduler_init();\r
78         printf("init\n");\r
79 \r
80 #ifdef HOST_VERSION\r
81         hostsim_init();\r
82         robotsim_init();\r
83 #endif\r
84         microb_cs_init();\r
85 \r
86         time_init(TIME_PRIO);\r
87 \r
88         printf_P(PSTR("\r\n"));\r
89         printf_P(PSTR("Respect et robustesse.\r\n"));\r
90 \r
91         mainboard.flags = DO_ENCODERS | DO_RS |\r
92                 DO_POS | DO_POWER | DO_BD | DO_CS;\r
93         strat_reset_pos(1000, 1000, 0);\r
94 \r
95         cmdline_interact();\r
96 \r
97 /*      trajectory_d_rel(&mainboard.traj, 1000); */\r
98 /*      time_wait_ms(2000); */\r
99 /*      trajectory_circle_rel(&mainboard.traj, 1500, 1000, */\r
100 /*                            250, 360, 0); */\r
101 /*      time_wait_ms(15000); */\r
102         return 0;\r
103 }\r
104 \r
105 \r