📄 uartdebug.lst
字号:
1 .file "uartDebug.c"
2 .arch atmega128
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
11 .text
12 .Ltext0:
75 .global uartDebug_init
77 uartDebug_init:
1:uartDebug.c **** /*
2:uartDebug.c **** ****************************************************************************
3:uartDebug.c **** * 宁波中科集成电路设计中心 版权所有 Copyright 2005
4:uartDebug.c **** * http:\\www.nbicc.com
5:uartDebug.c **** *文件名: fun.h
6:uartDebug.c **** *程序员: 夏鹏 xpsonny@nbicc.com
7:uartDebug.c **** *主要内容:常用函数
8:uartDebug.c **** *
9:uartDebug.c **** *如有问题或BUG,请登录www.wsn.net.cn 上的BBS到相关版面提问!
10:uartDebug.c **** *
11:uartDebug.c **** ****************************************************************************
12:uartDebug.c **** */
13:uartDebug.c ****
14:uartDebug.c **** #include "type.h"
15:uartDebug.c **** #include "uartDebug.h"
16:uartDebug.c **** #include "message.h"
17:uartDebug.c ****
18:uartDebug.c **** #define DBG_BUF_LEN 60
19:uartDebug.c **** #define UART_IDLE 0
20:uartDebug.c **** #define UART_BUSY 1
21:uartDebug.c ****
22:uartDebug.c **** char UARTState;
23:uartDebug.c **** char dbgBuf[DBG_BUF_LEN];
24:uartDebug.c **** uint8_t dbgHead;
25:uartDebug.c **** uint8_t dbgTail;
26:uartDebug.c **** uint8_t dbgBufCount;
27:uartDebug.c **** uint8_t appendByte;
28:uartDebug.c ****
29:uartDebug.c **** void uartDebug_init()
30:uartDebug.c **** {
79 .LM1:
80 /* prologue: frame size=0 */
81 /* prologue end (size=0) */
31:uartDebug.c **** UARTState = UART_IDLE;
83 .LM2:
84 0000 1092 0000 sts UARTState,__zero_reg__
32:uartDebug.c **** dbgBufCount = 0;
86 .LM3:
87 0004 1092 0000 sts dbgBufCount,__zero_reg__
33:uartDebug.c **** // dbgHead = 0;
34:uartDebug.c **** // dbgTail = 0;
35:uartDebug.c ****
36:uartDebug.c **** // initialize UART
37:uartDebug.c **** * (volatile unsigned char *)0x90 = 0; /* UBRR0H = 0 */
89 .LM4:
90 0008 1092 9000 sts 144,__zero_reg__
38:uartDebug.c **** * (volatile unsigned char *)(0x09 + 0x20) = 15; /* UBRR0L = 15 */
92 .LM5:
93 000c 8FE0 ldi r24,lo8(15)
94 000e 89B9 out 41-0x20,r24
39:uartDebug.c **** /* UCSR0A中的U2X0 = 1,即传输速率倍速 */
40:uartDebug.c **** * (volatile unsigned char *)(0x0B + 0x20) = 1 << 1;
96 .LM6:
97 0010 82E0 ldi r24,lo8(2)
98 0012 8BB9 out 43-0x20,r24
41:uartDebug.c **** /* UCSR0C中UCSZ1 = 1,UCSZ0 = 1,即传送或接收字符长为8bit */
42:uartDebug.c **** * (volatile unsigned char *)0x95 = (1 << 2) | (1 << 1);
100 .LM7:
101 0014 86E0 ldi r24,lo8(6)
102 0016 8093 9500 sts 149,r24
43:uartDebug.c **** /* UCSR0B中的RXCIE,TXCIE,RXEN和TXEN都置为1 */
44:uartDebug.c **** * (volatile unsigned char *)(0x0A + 0x20) = (((1 << 7) | (1 << 6)) | (1 << 4)) | (1 << 3);
104 .LM8:
105 001a 88ED ldi r24,lo8(-40)
106 001c 8AB9 out 42-0x20,r24
107 /* epilogue: frame size=0 */
108 001e 0895 ret
109 /* epilogue end (size=1) */
110 /* function uartDebug_init size 16 (15) */
114 .global uartDebug_txPacket
116 uartDebug_txPacket:
45:uartDebug.c **** }
46:uartDebug.c ****
47:uartDebug.c ****
48:uartDebug.c ****
49:uartDebug.c **** void uartDebug_txPacket(OSMACMsgPtr pMsg)
50:uartDebug.c **** {
118 .LM9:
119 /* prologue: frame size=0 */
120 0020 CF93 push r28
121 0022 DF93 push r29
122 /* prologue end (size=2) */
123 0024 DC01 movw r26,r24
51:uartDebug.c **** int i;
52:uartDebug.c **** if (UARTState == UART_IDLE)
125 .LM10:
126 0026 8091 0000 lds r24,UARTState
127 002a 8823 tst r24
128 002c 09F0 breq .+2
129 002e 56C0 rjmp .L2
53:uartDebug.c **** {
54:uartDebug.c **** UARTState = UART_BUSY;
131 .LM11:
132 0030 81E0 ldi r24,lo8(1)
133 0032 8093 0000 sts UARTState,r24
55:uartDebug.c **** dbgBuf[0] = 0x7E;
135 .LM12:
136 0036 8EE7 ldi r24,lo8(126)
137 0038 8093 0000 sts dbgBuf,r24
56:uartDebug.c **** dbgBuf[1] = 0x42;
139 .LM13:
140 003c 82E4 ldi r24,lo8(66)
141 003e 8093 0000 sts dbgBuf+1,r24
57:uartDebug.c **** dbgBuf[2] = pMsg->length;//
143 .LM14:
144 0042 8C91 ld r24,X
145 0044 8093 0000 sts dbgBuf+2,r24
58:uartDebug.c **** dbgBuf[3] = pMsg->type;
147 .LM15:
148 0048 ED01 movw r28,r26
149 004a 8981 ldd r24,Y+1
150 004c 8093 0000 sts dbgBuf+3,r24
59:uartDebug.c **** dbgBuf[4] = pMsg->toAddr;
152 .LM16:
153 0050 8A81 ldd r24,Y+2
154 0052 8093 0000 sts dbgBuf+4,r24
60:uartDebug.c **** dbgBuf[5] = pMsg->fromAddr;
156 .LM17:
157 0056 8B81 ldd r24,Y+3
158 0058 8093 0000 sts dbgBuf+5,r24
61:uartDebug.c **** dbgBuf[6] = pMsg->group;
160 .LM18:
161 005c 8C81 ldd r24,Y+4
162 005e 8093 0000 sts dbgBuf+6,r24
62:uartDebug.c **** ///////这里需要注意的是i < pMsg->length-7语句,因为一般来说uart只是在sink节点才会用到,对于sink节
63:uartDebug.c **** //////包括了mac头和数据部分的长度,但是如果想uart传送本地产生的数据,由于没有经过mac层,pMsg->len
64:uartDebug.c **** //////数据部分的长度如果使用pMsg->length-7就不对了
65:uartDebug.c **** for (i = 0; i < pMsg->length-7; i++)
164 .LM19:
165 0062 20E0 ldi r18,lo8(0)
166 0064 30E0 ldi r19,hi8(0)
167 0066 8C91 ld r24,X
168 0068 9927 clr r25
169 006a 0797 sbiw r24,7
170 006c 2817 cp r18,r24
171 006e 3907 cpc r19,r25
172 0070 74F4 brge .L9
173 0072 C0E0 ldi r28,lo8(dbgBuf+7)
174 0074 D0E0 ldi r29,hi8(dbgBuf+7)
175 0076 FD01 movw r30,r26
176 0078 3596 adiw r30,5
177 .L7:
66:uartDebug.c **** dbgBuf[7+i] = pMsg->data[i];
179 .LM20:
180 007a 8191 ld r24,Z+
181 007c 8993 st Y+,r24
183 .LM21:
184 007e 2F5F subi r18,lo8(-(1))
185 0080 3F4F sbci r19,hi8(-(1))
186 0082 8C91 ld r24,X
187 0084 9927 clr r25
188 0086 0797 sbiw r24,7
189 0088 2817 cp r18,r24
190 008a 3907 cpc r19,r25
191 008c B4F3 brlt .L7
192 .L9:
67:uartDebug.c **** dbgBuf[pMsg->length] = pMsg->crc >> 8 & 0xFF;
194 .LM22:
195 008e 8C91 ld r24,X
196 0090 E82F mov r30,r24
197 0092 FF27 clr r31
198 0094 E050 subi r30,lo8(-(dbgBuf))
199 0096 F040 sbci r31,hi8(-(dbgBuf))
200 0098 ED01 movw r28,r26
201 009a 8AAD ldd r24,Y+58
202 009c 9BAD ldd r25,Y+59
203 009e 892F mov r24,r25
204 00a0 990F lsl r25
205 00a2 990B sbc r25,r25
206 00a4 8083 st Z,r24
68:uartDebug.c **** dbgBuf[1+pMsg->length] = pMsg->crc & 0xFF;
208 .LM23:
209 00a6 8C91 ld r24,X
210 00a8 E82F mov r30,r24
211 00aa FF27 clr r31
212 00ac E050 subi r30,lo8(-(dbgBuf))
213 00ae F040 sbci r31,hi8(-(dbgBuf))
214 00b0 8AAD ldd r24,Y+58
215 00b2 8183 std Z+1,r24
69:uartDebug.c **** dbgBuf[2+pMsg->length] = 0x7E;
217 .LM24:
218 00b4 8C91 ld r24,X
219 00b6 E82F mov r30,r24
220 00b8 FF27 clr r31
221 00ba E050 subi r30,lo8(-(dbgBuf))
222 00bc F040 sbci r31,hi8(-(dbgBuf))
223 00be 8EE7 ldi r24,lo8(126)
224 00c0 8283 std Z+2,r24
70:uartDebug.c **** * (volatile unsigned char *)(0x0C + 0x20) = dbgBuf[0]; // 将data写入数据寄存器UDR0
226 .LM25:
227 00c2 8091 0000 lds r24,dbgBuf
228 00c6 8CB9 out 44-0x20,r24
71:uartDebug.c **** * (volatile unsigned char *)(0x0B + 0x20) |= 1 << 6; // 向TXC位写逻辑1,从而清零该位
230 .LM26:
231 00c8 5E9A sbi 43-0x20,6
72:uartDebug.c **** dbgBufCount = 1;
233 .LM27:
234 00ca 81E0 ldi r24,lo8(1)
235 00cc 8093 0000 sts dbgBufCount,r24
73:uartDebug.c **** dbgTail = 2 + pMsg->length;
237 .LM28:
238 00d0 8C91 ld r24,X
239 00d2 8E5F subi r24,lo8(-(2))
240 00d4 8093 0000 sts dbgTail,r24
74:uartDebug.c **** appendByte = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -