Subversion Repositories shark

Rev

Rev 1399 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1363 mauro 1
 
2
/*
3
 * Project: S.Ha.R.K.
4
 *
5
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
6
 *
7
 * Authors     : Mauro Marinoni <mauro.marinoni@unipv.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://shark.sssup.it
15
 */
16
 
17
/*
18
 * This program is free software; you can redistribute it and/or modify
19
 * it under the terms of the GNU General Public License as published by
20
 * the Free Software Foundation; either version 2 of the License, or
21
 * (at your option) any later version.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 * GNU General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU General Public License
29
 * along with this program; if not, write to the Free Software
30
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
 */
32
 
33
#include <kernel/kern.h>
34
#include <kernel/func.h>
35
#include <stdlib.h>
36
#include <string.h>
37
 
38
#include <drivers/shark_joy26.h>
39
 
40
TASK my_getjoy(void *arg) {
41
 
42
        int a0, a1, a2, a3, btn;
43
 
44
        while (1) {
45
                joy_getstatus(&a0, &a1, &a2, &a3, &btn);
1399 giacomo 46
                cprintf("(%6d %6d) %2x\n", a0, a1, btn);
1363 mauro 47
                task_endcycle();
48
                if (btn == 0xF)
1550 pj 49
                        exit(1);
1363 mauro 50
        }
51
}
52
 
53
int main(int argc, char **argv)
54
{
55
        SOFT_TASK_MODEL mp;
56
        PID pid;
57
 
1389 mauro 58
        if (!JOY26_installed()) {
1399 giacomo 59
                cprintf("No Joystick found.");
1550 pj 60
                exit(1);
1389 mauro 61
        }
1363 mauro 62
        soft_task_default_model(mp);
63
        soft_task_def_level(mp,2);
64
        soft_task_def_ctrl_jet(mp);
65
        soft_task_def_met(mp,700);
66
        soft_task_def_period(mp,10000);
67
        soft_task_def_usemath(mp);
68
        pid = task_create("Joy_Print", my_getjoy, &mp, NULL);
69
        if (pid == NIL) {
1399 giacomo 70
                sys_shutdown_message("Could not create task <Joy_Print>\n");
1550 pj 71
                exit(1);
1363 mauro 72
        } else
73
                task_activate(pid);
74
 
75
        return 0;
76
}