restore first circle algo + hostsim work
[aversive.git] / modules / devices / encoders / encoders_microb / test / main.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: main.c,v 1.4.4.2 2007-05-23 17:18:13 zer0 Exp $
19  *
20  */
21
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <aversive.h>
25 #include <aversive/wait.h>
26 #include <uart.h>
27 #include <scheduler.h>
28 #include <encoders_microb.h>
29
30 int main(void)
31 {
32   uint8_t i=0;
33   int32_t e0, e1, e2, e3;
34   DDRE=0x0C;
35
36   sbi(PORTE, 2);
37   uart_init();
38   scheduler_init();
39   fdevopen(uart0_dev_send, uart0_dev_recv);
40   encoders_microb_init();
41   
42   sei();
43
44   /* add microb encoders management */
45   scheduler_add_periodical_event(encoders_microb_manage, NULL, 1);
46
47   while(1) {
48     e0 = encoders_microb_get_value_adjusted((void *)0);
49     e1 = encoders_microb_get_value_adjusted((void *)1);
50     e2 = encoders_microb_get_value_adjusted((void *)2);
51     e3 = encoders_microb_get_value_adjusted((void *)3);
52
53     printf("%.8ld %.8ld %.8ld %.8ld\r\n", e0, e1, e2, e3);
54
55     if (i++ % 2)
56       sbi(PORTE, 2);
57     else
58       cbi(PORTE, 2);
59     wait_ms(100);
60   }
61   
62   return 0;
63   
64 }