Subversion Repositories shark

Rev

Rev 1347 | Rev 1399 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1347 giacomo 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_keyb26.h>
39
 
40
void my_sysclose(KEY_EVT *e)
41
{
42
        kern_printf("S.Ha.R.K. closed.\n\n");
43
        sys_end();
44
}
45
 
46
TASK my_getch(void *arg) {
47
 
48
        BYTE ch;
49
 
50
        while (1) {
51
                ch = keyb_getch(NON_BLOCK);
52
                if (ch)
53
                        printk ("%c", ch);
54
                task_endcycle();
55
        }
56
}
57
 
58
void my_pause(KEY_EVT *e){
59
 
60
        TIME t;
61
 
62
        printk("Start Pause.\n");
63
        keyb_disable();
64
        printk("Keyboard Disabled.\n");
65
        t = sys_gettime(NULL);
66
        while ( ( (sys_gettime(NULL) -t) / 1000) < 5000);
67
        keyb_enable();
68
        printk("Keyboard Enabled.\n");
69
}
70
 
71
int main(int argc, char **argv)
72
{
73
        SOFT_TASK_MODEL mp;
74
        PID pid;
75
 
76
        KEY_EVT ev;
77
 
78
        ev.ascii = 'p';
79
        ev.scan  = KEY_P;
80
        ev.status = KEY_PRESSED;
81
        ev.flag = CNTR_BIT;
82
        keyb_hook(ev, my_pause, FALSE);
83
 
84
        ev.ascii = 'c';
85
        ev.scan  = KEY_C;
86
        ev.status = KEY_PRESSED;
87
        ev.flag = CNTR_BIT;
88
        keyb_hook(ev, my_sysclose, FALSE);
89
        ev.flag = CNTL_BIT;
90
        keyb_hook(ev, my_sysclose, FALSE);
91
 
92
        soft_task_default_model(mp);
93
        soft_task_def_level(mp,2);
94
        soft_task_def_ctrl_jet(mp);
95
        soft_task_def_met(mp,700);
96
        soft_task_def_period(mp,1000);
97
        soft_task_def_usemath(mp);
98
        pid = task_create("Keyb_Print", my_getch, &mp, NULL);
99
        if (pid == NIL) {
100
                perror("Could not create task <Keyb_Print>");
101
                sys_end();
102
        } else
103
                task_activate(pid);
104
 
105
        return 0;
106
}