📄 artx_key_demo.lst
字号:
ARM COMPILER V2.42, ARTX_Key_Demo 17/01/06 16:24:22 PAGE 1
ARM COMPILER V2.42, COMPILATION OF MODULE ARTX_Key_Demo
OBJECT MODULE PLACED IN .\OBJ\ARTX_Key_Demo.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe ARTX_Key_Demo.c THUMB BROWSE DEBUG TABS(4) OBJECT(.\OBJ\ARTX_Key_Demo.obj)
stmt level source
1 /*----------------------------------------------------------------------------
2 * A R T X K e r n e l E x a m p l e
3 *----------------------------------------------------------------------------
4 * Name: BLINKY.C
5 * Purpose: Advanced RTX example program
6 * Rev.: V2.00 / 19-oct-2005
7 *----------------------------------------------------------------------------
8 * This code is part of the ARTX-ARM kernel package of Keil Software.
9 * Copyright (c) 2004-2005 Keil Software. All rights reserved.
10 *---------------------------------------------------------------------------*/
11
12 #include <ARTX.h>
13 #include <LPC21xx.H> /* LPC21xx definitions */
14
15
16 OS_TID t_GetKey; /* assigned task id of task: phase_a */
17 OS_TID t_clock; /* assigned task id of task: clock */
18 OS_TID t_phaseA;
19 #define LED_A 0x100000
20 #define LED_B 0x200000
21 #define LED_C 0x040000
22 #define LED_D 0x080000
23 #define LED_CLK 0x800000
24
25
26 #define KEY1 13
27 #define KEY2 15
28 #define KEY3 7
29 #define KEY4 6
30
31
32 void init_port(void)
33 {
34 1
35 1 //port initialized
36 1 IODIR1=0x00FF0000;
37 1 IODIR0=0x40600010;
38 1 IOSET1 = 0x00FF0000; //ALL LED OFF
39 1
40 1 }
41
42 unsigned char Scan_Key(void)
43 {
44 1 unsigned int k;
45 1 unsigned char key,i;
46 1
47 1 i=0;
48 1 key=0;
49 1
50 1 k=IOPIN0;
51 1 if((k&1<<KEY4)==0)key+=1;
52 1 key=key<<1;
53 1 if((k&1<<KEY3)==0)key+=1;
54 1 key=key<<1;
55 1 if((k&1<<KEY2)==0)key+=1;
56 1 key=key<<1;
57 1 if((k&1<<KEY1)==0)key+=1;
58 1 switch(key)
59 1 {
ARM COMPILER V2.42, ARTX_Key_Demo 17/01/06 16:24:22 PAGE 2
60 2 case 0x00:
61 2 i=0;
62 2 break;
63 2 case 0x08:
64 2 i=4;
65 2 break;
66 2
67 2 case 0x04:
68 2 i=3;
69 2 break;
70 2
71 2 case 0x02:
72 2 i=2;
73 2 break;
74 2
75 2 case 0x01:
76 2 i=1;
77 2 break;
78 2
79 2 case 0x0F: //复合键
80 2 i=0XF;
81 2 break;
82 2
83 2 case 0x0E:
84 2 i=0X0E;
85 2 break;
86 2 default:
87 2 i=0;
88 2 break;
89 2 }
90 1 return i;
91 1 }
92 /*----------------------------------------------------------------------------
93 * Function 'signal_func' called from multiple tasks
94 *---------------------------------------------------------------------------*/
95 void signal_func (OS_TID task) {
96 1 os_evt_set (0x0100, t_clock); /* send event signal to clock task */
97 1 os_dly_wait (9); /* delay 50 clock ticks */
98 1 // os_evt_set (0x0100, t_clock); /* send event signal to clock task */
99 1 // os_dly_wait (9); /* delay 50 clock ticks */
100 1 os_evt_set (0x0001, task); /* send event to task 'task' */
101 1 // os_dly_wait (10); /* delay 50 clock ticks */
102 1 }
103 /*----------------------------------------------------------------------------
104 * Task 1 'GetKey ':
105 *---------------------------------------------------------------------------*/
106 void phaseA (void) __task {
107 1 for (;;) {
108 2 os_evt_wait_and (0x0001, 0xffff); /* wait for an event flag 0x0001 */
109 2 IOCLR1 = LED_B;
110 2 signal_func (t_GetKey); /* call common signal function */
111 2 IOSET1 = LED_B;
112 2 }
113 1 }
114 void GetKey (void) __task {
115 1 unsigned char i;
116 1 for (;;) {
117 2 os_evt_wait_and (0x0001, 0xffff); /* wait for an event flag 0x0001 */
118 2 i=Scan_Key();
119 2 if(i!=0)IOCLR1 = (0x00008000<<i);
120 2 signal_func(t_phaseA);
121 2 //os_dly_wait (100);
122 2 if(i!=0)IOSET1 = (0x00008000<<i);
123 2 //IOSET1 = 0x006f0000; //ALL LED OFF
124 2 }
125 1 }
ARM COMPILER V2.42, ARTX_Key_Demo 17/01/06 16:24:22 PAGE 3
126
127 /*----------------------------------------------------------------------------
128 * Task 5 'clock': Signal Clock
129 *---------------------------------------------------------------------------*/
130 void clock (void) __task {
131 1 for (;;) {
132 2 os_evt_wait_and (0x0100, 0xffff); /* wait for an event flag 0x0100 */
133 2 IOSET1 = LED_CLK;
134 2 os_dly_wait (8); /* delay 8 clock ticks */
135 2 IOCLR1 = LED_CLK;
136 2
137 2 }
138 1 }
139
140 /*----------------------------------------------------------------------------
141 * Task 6 'init': Initialize
142 *---------------------------------------------------------------------------*/
143 void init (void) __task {
144 1
145 1 IODIR1 = 0xFF0000; /* P1.16..23 defined as Outputs */
146 1 init_port();
147 1 t_phaseA = os_tsk_create (phaseA, 0); /* start task phaseB */
148 1 t_GetKey = os_tsk_create (GetKey, 0); /* start task phaseA */
149 1
150 1 // t_phaseC = os_tsk_create (phaseC, 0); /* start task phaseC */
151 1 // t_phaseD = os_tsk_create (phaseD, 0); /* start task phaseD */
152 1 t_clock = os_tsk_create (clock, 0); /* start task clock */
153 1 os_evt_set (0x0001, t_phaseA); /* send signal event to task phaseA */
154 1 os_tsk_delete_self ();
155 1 }
156
157 /*----------------------------------------------------------------------------
158 * Main: Initialize and start ARTX Kernel
159 *---------------------------------------------------------------------------*/
160 void main (void) {
161 1 os_sys_init (init); /* Initialize ARTX and start init */
162 1 }
163
164 /*----------------------------------------------------------------------------
165 * end of file
166 *---------------------------------------------------------------------------*/
167
ARM COMPILER V2.42, ARTX_Key_Demo 17/01/06 16:24:22 PAGE 4
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (os_tsk_create_user?T)
EXTERN CODE16 (os_sys_init_user?T)
EXTERN CODE16 (os_tsk_delete?T)
EXTERN CODE16 (os_evt_wait?T)
EXTERN CODE16 (os_evt_set?T)
EXTERN CODE16 (os_dly_wait?T)
EXTERN NUMBER (__startup)
*** PUBLICS:
PUBLIC init_port?T
PUBLIC Scan_Key?T
PUBLIC signal_func?T
PUBLIC phaseA?T
PUBLIC GetKey?T
PUBLIC clock?T
PUBLIC init?T
PUBLIC main
PUBLIC t_GetKey
PUBLIC t_clock
PUBLIC t_phaseA
*** DATA SEGMENT '?DT0?ARTX_Key_Demo':
00000000 t_GetKey:
00000000 DS 4
00000004 t_clock:
00000004 DS 4
00000008 t_phaseA:
00000008 DS 4
*** CODE SEGMENT '?PR?init_port?T?ARTX_Key_Demo':
36: IODIR1=0x00FF0000;
00000000 4800 LDR R1,=0xFF0000
00000002 4800 LDR R0,=0xE0028018
00000004 6001 STR R1,[R0,#0x0]
37: IODIR0=0x40600010;
00000006 4800 LDR R2,=0x40600010
00000008 4800 LDR R0,=0xE0028008
0000000A 6002 STR R2,[R0,#0x0]
38: IOSET1 = 0x00FF0000; //ALL LED OFF
0000000C 4800 LDR R0,=0xE0028014
0000000E 6001 STR R1,[R0,#0x0]
40: }
00000010 4770 BX R14
00000012 ENDP ; 'init_port?T'
*** CODE SEGMENT '?PR?Scan_Key?T?ARTX_Key_Demo':
42: unsigned char Scan_Key(void)
00000000 B430 PUSH {R4-R5}
43: {
00000002 ; SCOPE-START
47: i=0;
00000002 2000 MOV R0,#0x0
00000004 1C01 MOV R1,R0 ; i
00000006 ---- Variable 'i' assigned to Register 'R1' ----
48: key=0;
00000006 1C03 MOV R3,R0 ; key
00000008 ---- Variable 'key' assigned to Register 'R3' ----
50: k=IOPIN0;
00000008 4800 LDR R2,=0xE0028000
0000000A 6815 LDR R5,[R2,#0x0]
0000000C ---- Variable 'k' assigned to Register 'R5' ----
51: if((k&1<<KEY4)==0)key+=1;
0000000C 1C2A MOV R2,R5 ; k
ARM COMPILER V2.42, ARTX_Key_Demo 17/01/06 16:24:22 PAGE 5
0000000E 2440 MOV R4,#0x40
00000010 4222 TST R2,R4 ; k
00000012 D102 BNE L_1 ; T=0x0000001A
00000014 3301 ADD R3,#0x1
00000016 061B LSL R3,R3,#0x18
00000018 0E1B LSR R3,R3,#0x18
0000001A L_1:
52: key=key<<1;
0000001A 1C1A MOV R2,R3 ; key
0000001C 0613 LSL R3,R2,#0x18 ; key
0000001E 0E1B LSR R3,R3,#0x18
00000020 005B LSL R3,R3,#0x1
00000022 061B LSL R3,R3,#0x18
00000024 0E1B LSR R3,R3,#0x18
53: if((k&1<<KEY3)==0)key+=1;
00000026 1C2A MOV R2,R5 ; k
00000028 2480 MOV R4,#0x80
0000002A 4222 TST R2,R4 ; k
0000002C D102 BNE L_2 ; T=0x00000034
0000002E 3301 ADD R3,#0x1
00000030 061B LSL R3,R3,#0x18
00000032 0E1B LSR R3,R3,#0x18
00000034 L_2:
54: key=key<<1;
00000034 1C1A MOV R2,R3 ; key
00000036 0613 LSL R3,R2,#0x18 ; key
00000038 0E1B LSR R3,R3,#0x18
0000003A 005B LSL R3,R3,#0x1
0000003C 061B LSL R3,R3,#0x18
0000003E 0E1B LSR R3,R3,#0x18
55: if((k&1<<KEY2)==0)key+=1;
00000040 1C2A MOV R2,R5 ; k
00000042 4800 LDR R4,=0x8000
00000044 4222 TST R2,R4 ; k
00000046 D102 BNE L_3 ; T=0x0000004E
00000048 3301 ADD R3,#0x1
0000004A 061B LSL R3,R3,#0x18
0000004C 0E1B LSR R3,R3,#0x18
0000004E L_3:
56: key=key<<1;
0000004E 1C1A MOV R2,R3 ; key
00000050 0613 LSL R3,R2,#0x18 ; key
00000052 0E1B LSR R3,R3,#0x18
00000054 005B LSL R3,R3,#0x1
00000056 061B LSL R3,R3,#0x18
00000058 0E1B LSR R3,R3,#0x18
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -