1 /* This test is designed to test the interrupt control service call avaialbe to the
2 application. */
3
4 #include <stdio.h>
5 #include "tx_api.h"
6
7 static unsigned long thread_0_counter = 0;
8 static TX_THREAD thread_0;
9
10
11 /* Define thread prototypes. */
12
13 static void thread_0_entry(ULONG thread_input);
14
15
16 /* Prototype for test control return. */
17 void test_control_return(UINT status);
18
19
20 /* Define what the initial system looks like. */
21
22 #ifdef CTEST
test_application_define(void * first_unused_memory)23 void test_application_define(void *first_unused_memory)
24 #else
25 void threadx_interrupt_control_application_define(void *first_unused_memory)
26 #endif
27 {
28
29 UINT status;
30 CHAR *pointer;
31
32
33 /* Put first available memory address into a character pointer. */
34 pointer = (CHAR *) first_unused_memory;
35
36 /* Put system definition stuff in here, e.g. thread creates and other assorted
37 create information. */
38
39 status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
40 pointer, TEST_STACK_SIZE_PRINTF,
41 17, 17, 100, TX_AUTO_START);
42 pointer = pointer + TEST_STACK_SIZE_PRINTF;
43
44 /* Check for status. */
45 if (status != TX_SUCCESS)
46 {
47
48 printf("Running Interrupt Control Test...................................... ERROR #1\n");
49 test_control_return(1);
50 }
51 }
52
53
54
55 /* Define the test threads. */
56
thread_0_entry(ULONG thread_input)57 static void thread_0_entry(ULONG thread_input)
58 {
59
60 UINT saved_interrupt_posture;
61
62
63 /* Inform user. */
64 printf("Running Interrupt Control Test...................................... ");
65
66 /* Lockout interrupts. */
67 saved_interrupt_posture = tx_interrupt_control(TX_INT_DISABLE);
68
69 /* Increment the thread counter. */
70 thread_0_counter++;
71
72 /* Restore interrupts. */
73 saved_interrupt_posture = tx_interrupt_control(saved_interrupt_posture);
74
75 /* Sleep to make sure interrupts now work. */
76 tx_thread_sleep(2);
77
78 /* Check to make sure the returned interrupt type works. */
79 if (saved_interrupt_posture != TX_INT_DISABLE)
80 {
81
82 /* Interrupt control error. */
83 printf("ERROR #2\n");
84 test_control_return(1);
85 }
86 else
87 {
88
89 /* Successful test. */
90 printf("SUCCESS!\n");
91 test_control_return(0);
92 }
93 }
94
95