1 | /* |
---|
2 | * Classic API Signal to Task from ISR |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | volatile bool signal_sent; |
---|
18 | volatile bool signal_processed; |
---|
19 | |
---|
20 | rtems_id main_task; |
---|
21 | |
---|
22 | void signal_handler( |
---|
23 | rtems_signal_set signals |
---|
24 | ) |
---|
25 | { |
---|
26 | signal_processed = TRUE; |
---|
27 | } |
---|
28 | |
---|
29 | rtems_timer_service_routine test_signal_from_isr( |
---|
30 | rtems_id timer, |
---|
31 | void *arg |
---|
32 | ) |
---|
33 | { |
---|
34 | rtems_status_code status; |
---|
35 | |
---|
36 | status = rtems_signal_send( main_task, 0x0a0b0c0d ); |
---|
37 | directive_failed_with_level( status, "rtems_signal_send", 1 ); |
---|
38 | |
---|
39 | signal_sent = TRUE; |
---|
40 | } |
---|
41 | |
---|
42 | rtems_task Init( |
---|
43 | rtems_task_argument argument |
---|
44 | ) |
---|
45 | { |
---|
46 | rtems_status_code status; |
---|
47 | rtems_id timer; |
---|
48 | rtems_interval start; |
---|
49 | rtems_interval now; |
---|
50 | |
---|
51 | puts( "\n\n*** TEST 38 ***" ); |
---|
52 | |
---|
53 | main_task = rtems_task_self(); |
---|
54 | |
---|
55 | /* |
---|
56 | * Timer used in multiple ways |
---|
57 | */ |
---|
58 | status = rtems_timer_create( 1, &timer ); |
---|
59 | directive_failed( status, "rtems_timer_create" ); |
---|
60 | |
---|
61 | /* |
---|
62 | * Get starting time |
---|
63 | */ |
---|
64 | status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start ); |
---|
65 | directive_failed( status, "rtems_clock_get start" ); |
---|
66 | |
---|
67 | status = rtems_signal_catch( signal_handler, RTEMS_DEFAULT_MODES ); |
---|
68 | directive_failed( status, "rtems_signal_catch" ); |
---|
69 | puts( "rtems_signal_catch - handler installed" ); |
---|
70 | |
---|
71 | /* |
---|
72 | * Test Signal from ISR |
---|
73 | */ |
---|
74 | signal_sent = FALSE; |
---|
75 | |
---|
76 | status = rtems_timer_fire_after( timer, 10, test_signal_from_isr, NULL ); |
---|
77 | directive_failed( status, "timer_fire_after failed" ); |
---|
78 | |
---|
79 | while (1) { |
---|
80 | status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now ); |
---|
81 | directive_failed( status, "rtems_clock_get now" ); |
---|
82 | if ( (now-start) > 100 ) { |
---|
83 | puts( "Signal from ISR did not get processed\n" ); |
---|
84 | rtems_test_exit( 0 ); |
---|
85 | } |
---|
86 | if ( signal_processed ) |
---|
87 | break; |
---|
88 | } |
---|
89 | |
---|
90 | puts( "Signal sent from ISR has been processed" ); |
---|
91 | puts( "*** END OF TEST 38 ***" ); |
---|
92 | rtems_test_exit( 0 ); |
---|
93 | } |
---|