FreeCalypso > hg > leo2moko-debug
comparison chipsetsw/services/mks/tests/mks_test_misc.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /********************************************************************************/ | |
2 /* */ | |
3 /* File Name: mks_test_misc.c */ | |
4 /* */ | |
5 /* Purpose: This file gathers miscellaneous tests fot MKS. */ | |
6 /* */ | |
7 /* Notes: None. */ | |
8 /* */ | |
9 /* Revision History: */ | |
10 /* 10/29/01 Laurent Sollier Create. */ | |
11 /* */ | |
12 /* (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved */ | |
13 /* */ | |
14 /********************************************************************************/ | |
15 | |
16 /********************************************************************************/ | |
17 /* */ | |
18 /* Include files used for MKS testing. */ | |
19 /* */ | |
20 /********************************************************************************/ | |
21 | |
22 #include "tests/rv/rv_test_filter.h" | |
23 | |
24 #if (MKS_MISC == SW_COMPILED) | |
25 | |
26 #include "mks/mks_api.h" | |
27 #include "tests/rv/rv_test_misc.h" | |
28 #include "mks/tests/mks_test.h" | |
29 #include "r2d/lcd_messages_ti.h" | |
30 #include "r2d/lcd_messages.h" | |
31 #include "r2d/r2d.h" | |
32 | |
33 #include <stdio.h> | |
34 #include <string.h> | |
35 | |
36 | |
37 /********************************************************************************/ | |
38 /* */ | |
39 /* Function Name: mks_test_misc1 */ | |
40 /* */ | |
41 /* Notes: This function executes mks misc test 1. */ | |
42 /* */ | |
43 /* Revision History: */ | |
44 /* 11/05/01 Laurent Sollier Create. */ | |
45 /* */ | |
46 /********************************************************************************/ | |
47 T_RV_MISC_RET mks_test_misc1(void) | |
48 { | |
49 T_RV_MISC_RET test_verdict = TEST_PASSED; | |
50 T_MKS_INFOS_KEY_SEQUENCE infos_key_sequence; | |
51 UINT16 received_event; | |
52 T_RV_HDR* msg_p; | |
53 T_KPD_SUBSCRIBER subscriber_id; | |
54 T_KPD_VIRTUAL_KEY_TABLE notified_keys; | |
55 T_RV_RETURN kpd_return_path; | |
56 | |
57 BOOL exit = FALSE; | |
58 | |
59 /* Test definition */ | |
60 mks_test_trace("*** MKS TEST MISC1: Two magic key sequences"); | |
61 mks_test_trace("*** MKS TEST MISC1: The first sequence is (1-2-3) and display or hide a message"); | |
62 mks_test_trace("*** MKS TEST MISC1: The second sequence is (4-5-6) and wait for three keys"); | |
63 mks_test_trace("*** MKS TEST MISC1: Press DISC to exit the test"); | |
64 | |
65 /* Add key sequence 1 */ | |
66 infos_key_sequence.nb_key_of_sequence = 3; | |
67 infos_key_sequence.key_id[0] = KPD_KEY_1; | |
68 infos_key_sequence.key_id[1] = KPD_KEY_2; | |
69 infos_key_sequence.key_id[2] = KPD_KEY_3; | |
70 strcpy(infos_key_sequence.name, "TEST_SEQ1"); | |
71 infos_key_sequence.completion_type = MKS_SEQUENCE_COMPLETED; | |
72 infos_key_sequence.nb_key_for_post_sequence = 0; /* useless because completion_type=MKS_SEQUENCE_COMPLETED */ | |
73 infos_key_sequence.return_path.callback_func = 0; | |
74 infos_key_sequence.return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
75 | |
76 mks_add_key_sequence(&infos_key_sequence); | |
77 | |
78 /* Add key sequence 2 */ | |
79 infos_key_sequence.nb_key_of_sequence = 3; | |
80 infos_key_sequence.key_id[0] = KPD_KEY_4; | |
81 infos_key_sequence.key_id[1] = KPD_KEY_5; | |
82 infos_key_sequence.key_id[2] = KPD_KEY_6; | |
83 strcpy(infos_key_sequence.name, "TEST_SEQ2"); | |
84 infos_key_sequence.completion_type = MKS_POST_SEQUENCE; | |
85 infos_key_sequence.nb_key_for_post_sequence = 3; | |
86 infos_key_sequence.return_path.callback_func = 0; | |
87 infos_key_sequence.return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
88 | |
89 mks_add_key_sequence(&infos_key_sequence); | |
90 | |
91 /* Add keypad subscriber in order to be able to exit the test */ | |
92 kpd_return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
93 kpd_return_path.callback_func = 0; | |
94 notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS; | |
95 kpd_subscribe (&subscriber_id, KPD_DEFAULT_MODE, | |
96 ¬ified_keys, kpd_return_path); | |
97 | |
98 /* loop to process messages */ | |
99 while (!exit) | |
100 { | |
101 /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */ | |
102 received_event = rvf_wait(RVF_TASK_MBOX_0_EVT_MASK,0); | |
103 | |
104 if (received_event & RVF_TASK_MBOX_0_EVT_MASK) | |
105 { | |
106 /* Read the message */ | |
107 msg_p = (T_RV_HDR *) rvf_read_mbox(0); | |
108 | |
109 if (msg_p != 0) | |
110 { | |
111 switch (msg_p->msg_id) | |
112 { | |
113 case MKS_SEQUENCE_COMPLETED_MSG: | |
114 { | |
115 T_MKS_SEQUENCE_COMPLETED_MSG* msg_key_event_p = (T_MKS_SEQUENCE_COMPLETED_MSG*) msg_p; | |
116 | |
117 if (!(strcmp(msg_key_event_p->name, "TEST_SEQ1"))) | |
118 { | |
119 static UINT8 loop = 0; | |
120 if (loop == 0) | |
121 { | |
122 LCD_WriteString(2,0,"Key seq. 1 ", NORMAL); | |
123 loop++; | |
124 } | |
125 else | |
126 { | |
127 LCD_WriteString(2,0," ", NORMAL); | |
128 loop = 0; | |
129 } | |
130 } | |
131 else if (!(strcmp(msg_key_event_p->name, "TEST_SEQ2"))) | |
132 { | |
133 static char texte[10] = {0}; | |
134 static UINT8 pos = 0; | |
135 T_MKS_SEQUENCE_COMPLETED_MSG* msg_key_event_p = (T_MKS_SEQUENCE_COMPLETED_MSG*) msg_p; | |
136 char* caracter; | |
137 | |
138 kpd_get_ascii_key_code(msg_key_event_p->key_pressed, | |
139 KPD_DEFAULT_MODE, | |
140 &caracter); | |
141 texte[pos] = caracter[0]; | |
142 pos++; | |
143 if (pos == 3) | |
144 { | |
145 LCD_WriteString(3,0, texte, NORMAL); | |
146 pos = 0; | |
147 } | |
148 } | |
149 break; | |
150 } | |
151 | |
152 case KPD_KEY_EVENT_MSG : | |
153 { | |
154 T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p; | |
155 | |
156 if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_DISCONNECT) | |
157 { | |
158 kpd_unsubscribe(&subscriber_id); | |
159 mks_remove_key_sequence("TEST_SEQ1"); | |
160 mks_remove_key_sequence("TEST_SEQ2"); | |
161 /* Wait that MKS SWE has time to process the two messages */ | |
162 rvf_delay(RVF_MS_TO_TICKS(100)); | |
163 | |
164 exit = TRUE; | |
165 } | |
166 break; | |
167 } | |
168 | |
169 default : | |
170 break; | |
171 | |
172 } | |
173 rvf_free_buf(msg_p); | |
174 } | |
175 } | |
176 } | |
177 | |
178 | |
179 return test_verdict; | |
180 } | |
181 | |
182 | |
183 /********************************************************************************/ | |
184 /* */ | |
185 /* Function Name: mks_test_misc2 */ | |
186 /* */ | |
187 /* Notes: This function executes mks misc test 2. */ | |
188 /* */ | |
189 /* Revision History: */ | |
190 /* 11/05/01 Laurent Sollier Create. */ | |
191 /* */ | |
192 /********************************************************************************/ | |
193 T_RV_MISC_RET mks_test_misc2(void) | |
194 { | |
195 T_RV_MISC_RET test_verdict = TEST_PASSED; | |
196 T_MKS_INFOS_KEY_SEQUENCE infos_key_sequence; | |
197 UINT16 received_event; | |
198 T_RV_HDR* msg_p; | |
199 T_KPD_SUBSCRIBER subscriber_id; | |
200 T_KPD_VIRTUAL_KEY_TABLE notified_keys; | |
201 T_RV_RETURN kpd_return_path; | |
202 | |
203 BOOL exit = FALSE; | |
204 | |
205 /* Test definition */ | |
206 mks_test_trace("*** MKS TEST MISC1: Three magic key sequences"); | |
207 mks_test_trace("*** MKS TEST MISC1: The first sequence is (1-2-3) and display or hide a message"); | |
208 mks_test_trace("*** MKS TEST MISC1: The second sequence is (4-5-6) and wait for three keys"); | |
209 mks_test_trace("*** MKS TEST MISC1: The third sequence is (7-8-9) and remove the first key sequence"); | |
210 mks_test_trace("*** MKS TEST MISC1: Press DISC to exit the test"); | |
211 | |
212 | |
213 /* Add key sequence 1 */ | |
214 infos_key_sequence.nb_key_of_sequence = 3; | |
215 infos_key_sequence.key_id[0] = KPD_KEY_1; | |
216 infos_key_sequence.key_id[1] = KPD_KEY_2; | |
217 infos_key_sequence.key_id[2] = KPD_KEY_3; | |
218 strcpy(infos_key_sequence.name, "TEST_SEQ1"); | |
219 infos_key_sequence.completion_type = MKS_SEQUENCE_COMPLETED; | |
220 infos_key_sequence.nb_key_for_post_sequence = 0; /* useless because completion_type=MKS_SEQUENCE_COMPLETED */ | |
221 infos_key_sequence.return_path.callback_func = 0; | |
222 infos_key_sequence.return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
223 | |
224 mks_add_key_sequence(&infos_key_sequence); | |
225 | |
226 /* Add key sequence 2 */ | |
227 infos_key_sequence.nb_key_of_sequence = 3; | |
228 infos_key_sequence.key_id[0] = KPD_KEY_4; | |
229 infos_key_sequence.key_id[1] = KPD_KEY_5; | |
230 infos_key_sequence.key_id[2] = KPD_KEY_6; | |
231 strcpy(infos_key_sequence.name, "TEST_SEQ2"); | |
232 infos_key_sequence.completion_type = MKS_POST_SEQUENCE; | |
233 infos_key_sequence.nb_key_for_post_sequence = 3; | |
234 infos_key_sequence.return_path.callback_func = 0; | |
235 infos_key_sequence.return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
236 | |
237 mks_add_key_sequence(&infos_key_sequence); | |
238 | |
239 /* Add key sequence 3 */ | |
240 infos_key_sequence.nb_key_of_sequence = 3; | |
241 infos_key_sequence.key_id[0] = KPD_KEY_7; | |
242 infos_key_sequence.key_id[1] = KPD_KEY_8; | |
243 infos_key_sequence.key_id[2] = KPD_KEY_9; | |
244 strcpy(infos_key_sequence.name, "TEST_SEQ3"); | |
245 infos_key_sequence.completion_type = MKS_SEQUENCE_COMPLETED; | |
246 infos_key_sequence.nb_key_for_post_sequence = 0; /* useless because completion_type=MKS_SEQUENCE_COMPLETED */ | |
247 infos_key_sequence.return_path.callback_func = 0; | |
248 infos_key_sequence.return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
249 | |
250 mks_add_key_sequence(&infos_key_sequence); | |
251 | |
252 /* Add keypad subscriber in order to be able to exit the test */ | |
253 kpd_return_path.addr_id = (UINT16) (mks_test_path.addr_id); | |
254 kpd_return_path.callback_func = 0; | |
255 notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS; | |
256 kpd_subscribe (&subscriber_id, KPD_DEFAULT_MODE, | |
257 ¬ified_keys, kpd_return_path); | |
258 | |
259 | |
260 /* loop to process messages */ | |
261 while (!exit) | |
262 { | |
263 /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */ | |
264 received_event = rvf_wait(RVF_TASK_MBOX_0_EVT_MASK,0); | |
265 | |
266 if (received_event & RVF_TASK_MBOX_0_EVT_MASK) | |
267 { | |
268 /* Read the message */ | |
269 msg_p = (T_RV_HDR *) rvf_read_mbox(0); | |
270 | |
271 if (msg_p != 0) | |
272 { | |
273 switch (msg_p->msg_id) | |
274 { | |
275 case MKS_SEQUENCE_COMPLETED_MSG: | |
276 { | |
277 T_MKS_SEQUENCE_COMPLETED_MSG* msg_key_event_p = (T_MKS_SEQUENCE_COMPLETED_MSG*) msg_p; | |
278 | |
279 if (!(strcmp(msg_key_event_p->name, "TEST_SEQ1")) ) | |
280 { | |
281 static UINT8 loop = 0; | |
282 if (loop == 0) | |
283 { | |
284 LCD_WriteString(2,0,"Key seq. 1 ", NORMAL); | |
285 loop++; | |
286 } | |
287 else | |
288 { | |
289 LCD_WriteString(2,0," ", NORMAL); | |
290 loop = 0; | |
291 } | |
292 } | |
293 else if (!(strcmp(msg_key_event_p->name, "TEST_SEQ2")) ) | |
294 { | |
295 static char texte[10] = {0}; | |
296 static UINT8 pos = 0; | |
297 T_MKS_SEQUENCE_COMPLETED_MSG* msg_key_event_p = (T_MKS_SEQUENCE_COMPLETED_MSG*) msg_p; | |
298 char* caracter; | |
299 | |
300 kpd_get_ascii_key_code(msg_key_event_p->key_pressed, | |
301 KPD_DEFAULT_MODE, | |
302 &caracter); | |
303 texte[pos] = caracter[0]; | |
304 pos++; | |
305 if (pos == 3) | |
306 { | |
307 LCD_WriteString(3,0, texte, NORMAL); | |
308 pos = 0; | |
309 } | |
310 } | |
311 else if (!(strcmp(msg_key_event_p->name, "TEST_SEQ3")) ) | |
312 { | |
313 mks_remove_key_sequence("TEST_SEQ1"); | |
314 } | |
315 break; | |
316 } | |
317 | |
318 case KPD_KEY_EVENT_MSG : | |
319 { | |
320 T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p; | |
321 | |
322 if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_DISCONNECT) | |
323 { | |
324 kpd_unsubscribe(&subscriber_id); | |
325 mks_remove_key_sequence("TEST_SEQ1"); | |
326 mks_remove_key_sequence("TEST_SEQ2"); | |
327 mks_remove_key_sequence("TEST_SEQ3"); | |
328 /* Wait that MKS SWE has time to process the two messages */ | |
329 rvf_delay(RVF_MS_TO_TICKS(100)); | |
330 | |
331 exit = TRUE; | |
332 } | |
333 break; | |
334 } | |
335 | |
336 default : | |
337 break; | |
338 | |
339 } | |
340 rvf_free_buf(msg_p); | |
341 } | |
342 } | |
343 } | |
344 | |
345 | |
346 return test_verdict; | |
347 } | |
348 | |
349 | |
350 /********************************************************************************/ | |
351 /* */ | |
352 /* Function Name: mks_test_misc3 */ | |
353 /* */ | |
354 /* Notes: This function executes mks misc test 3. */ | |
355 /* */ | |
356 /* Revision History: */ | |
357 /* 11/05/01 Laurent Sollier Create. */ | |
358 /* */ | |
359 /********************************************************************************/ | |
360 T_RV_MISC_RET mks_test_misc3(void) | |
361 { | |
362 T_RV_MISC_RET test_verdict = TEST_PASSED; | |
363 | |
364 return test_verdict; | |
365 } | |
366 | |
367 | |
368 /********************************************************************************/ | |
369 /* */ | |
370 /* Function Name: mks_test_misc */ | |
371 /* */ | |
372 /* Notes: This function executes MKS misc tests. */ | |
373 /* */ | |
374 /* Revision History: */ | |
375 /* 10/29/01 Laurent Sollier Create. */ | |
376 /* */ | |
377 /********************************************************************************/ | |
378 | |
379 T_RV_MISC_RET mks_test_misc (T_RV_MISC_TEST_NBR test_number) | |
380 { | |
381 T_RV_MISC_RET test_verdict = TEST_PASSED; | |
382 | |
383 LCD_Clear (); | |
384 rvf_dump_mem(); | |
385 rvf_dump_tasks(); | |
386 | |
387 switch (test_number) | |
388 { | |
389 case 1: | |
390 test_verdict = mks_test_misc1(); | |
391 break; | |
392 | |
393 case 2: | |
394 test_verdict = mks_test_misc2(); | |
395 break; | |
396 | |
397 case 3: | |
398 test_verdict = mks_test_misc3(); | |
399 break; | |
400 | |
401 default: | |
402 mks_test_trace("Test not available"); | |
403 | |
404 } | |
405 rvf_dump_mem(); | |
406 rvf_dump_tasks(); | |
407 | |
408 return (test_verdict); | |
409 } | |
410 | |
411 /************************ Stop mks_test_misc function ***********************/ | |
412 | |
413 #endif /* #if (MKS_MISC == SW_COMPILED) */ |