Rev 1389 | Go to most recent revision | Details | 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 | * Copyright (C) 2000 Paolo Gai |
||
19 | * |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation; either version 2 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * This program is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program; if not, write to the Free Software |
||
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
33 | * |
||
34 | */ |
||
35 | |||
36 | #include <kernel/kern.h> |
||
37 | #include <kernel/func.h> |
||
38 | #include <stdlib.h> |
||
39 | #include <string.h> |
||
40 | |||
41 | #include <drivers/shark_linuxc26.h> |
||
42 | #include <drivers/shark_input26.h> |
||
43 | #include <drivers/shark_keyb26.h> |
||
44 | |||
45 | void my_sysclose(KEY_EVT *e) |
||
46 | { |
||
47 | KEYB26_close(); |
||
48 | INPUT26_close(); |
||
49 | |||
50 | kern_printf("S.Ha.R.K. closed.\n\n"); |
||
51 | sys_end(); |
||
52 | } |
||
53 | |||
54 | TASK my_getch(void *arg) { |
||
55 | |||
56 | BYTE ch; |
||
57 | |||
58 | while (1) { |
||
59 | ch = keyb_getch(NON_BLOCK); |
||
60 | if (ch) |
||
61 | printk ("%c", ch); |
||
62 | task_endcycle(); |
||
63 | } |
||
64 | } |
||
65 | |||
66 | void my_pause(KEY_EVT *e){ |
||
67 | |||
68 | TIME t; |
||
69 | |||
70 | printk("Start Pause.\n"); |
||
71 | keyb_disable(); |
||
72 | printk("Keyboard Disabled.\n"); |
||
73 | t = sys_gettime(NULL); |
||
74 | while ( ( (sys_gettime(NULL) -t) / 1000) < 5000); |
||
75 | keyb_enable(); |
||
76 | printk("Keyboard Enabled.\n"); |
||
77 | } |
||
78 | |||
79 | int main(int argc, char **argv) |
||
80 | { |
||
81 | SOFT_TASK_MODEL mp; |
||
82 | PID pid; |
||
83 | |||
84 | KEY_EVT ev; |
||
85 | |||
86 | ev.ascii = 'p'; |
||
87 | ev.scan = KEY_P; |
||
88 | ev.status = KEY_PRESSED; |
||
89 | ev.flag = CNTR_BIT; |
||
90 | keyb_hook(ev, my_pause, FALSE); |
||
91 | |||
92 | ev.ascii = 'c'; |
||
93 | ev.scan = KEY_C; |
||
94 | ev.status = KEY_PRESSED; |
||
95 | ev.flag = CNTR_BIT; |
||
96 | keyb_hook(ev, my_sysclose, FALSE); |
||
97 | ev.flag = CNTL_BIT; |
||
98 | keyb_hook(ev, my_sysclose, FALSE); |
||
99 | |||
100 | soft_task_default_model(mp); |
||
101 | soft_task_def_level(mp,2); |
||
102 | soft_task_def_ctrl_jet(mp); |
||
103 | soft_task_def_met(mp,700); |
||
104 | soft_task_def_period(mp,1000); |
||
105 | //soft_task_def_aperiodic(mp); |
||
106 | soft_task_def_usemath(mp); |
||
107 | pid = task_create("Keyb_Print", my_getch, &mp, NULL); |
||
108 | if (pid == NIL) { |
||
109 | perror("Could not create task <Keyb_Print>"); |
||
110 | sys_end(); |
||
111 | } else |
||
112 | task_activate(pid); |
||
113 | |||
114 | /*while ( (sys_gettime(NULL)/1000) < 20000); |
||
115 | my_sysclose(NULL);*/ |
||
116 | |||
117 | //while(1); |
||
118 | |||
119 | return 0; |
||
120 | } |