probe_com.txt
来自「针对STM32F103的UCOS移植」· 文本 代码 · 共 1,157 行 · 第 1/4 页
TXT
1,157 行
; generated by ARM/Thumb C/C++ Compiler with , RVCT3.1 [Build 942] for uVision
; commandline ArmCC [--debug -c --asm --interleave -o.\rvmdk\probe_com.o --depend=.\rvmdk\probe_com.d --device=DARMSTM --apcs=interwork -O1 -Otime -I. -I..\BSP -I..\..\..\..\..\uCOS-II\Ports\arm-cortex-m3\Generic\RealView -I..\..\..\..\..\uCOS-II\Source -I..\..\..\..\..\CPU\ST\STM32\inc -I..\..\..\..\..\uC-CPU -I..\..\..\..\..\uC-CPU\Arm-Cortex-M3\RealView -I..\..\..\..\..\uC-LIB -I..\..\..\..\..\uC-Probe\Target\Plugins\uCOS-II -I..\..\..\..\..\uC-Probe\Target\Communication\Generic\Source -I..\..\..\..\..\uC-Probe\Target\Communication\Generic\RS-232\Ports\ST\STM32 -I..\..\..\..\..\uC-Probe\Target\Communication\Generic\RS-232\Source -IC:\Keil\ARM\INC\ST\STM32F10x ..\..\..\..\..\uC-Probe\Target\Communication\Generic\Source\probe_com.c]
THUMB
AREA ||.text||, CODE, READONLY, ALIGN=2
ProbeCom_Init PROC
;;;312 void ProbeCom_Init (void)
;;;313 {
000000 b570 PUSH {r4-r6,lr}
;;;314 #if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
;;;315 ProbeComStrBufWrIx = 0;
000002 4df9 LDR r5,|L1.1000|
000004 2400 MOVS r4,#0
000006 61ac STR r4,[r5,#0x18] ; ProbeComStrBufWrIx
;;;316 ProbeComStrBufRdIx = 0;
000008 61ec STR r4,[r5,#0x1c] ; ProbeComStrBufRdIx
;;;317
;;;318 ProbeCom_OS_Init();
00000a f7fffffe BL ProbeCom_OS_Init
;;;319 #endif
;;;320
;;;321 #if (PROBE_COM_STAT_EN == DEF_ENABLED)
;;;322 ProbeCom_RxPktCtr = 0;
00000e 602c STR r4,[r5,#0] ; ProbeCom_RxPktCtr
;;;323 ProbeCom_TxPktCtr = 0;
000010 606c STR r4,[r5,#4] ; ProbeCom_TxPktCtr
;;;324 ProbeCom_TxSymByteCtr = 0;
000012 60ec STR r4,[r5,#0xc] ; ProbeCom_TxSymByteCtr
;;;325 ProbeCom_TxSymCtr = 0;
000014 60ac STR r4,[r5,#8] ; ProbeCom_TxSymCtr
;;;326 ProbeCom_ErrPktCtr = 0;
000016 612c STR r4,[r5,#0x10] ; ProbeCom_ErrPktCtr
;;;327
;;;328 #if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
;;;329 ProbeCom_TxStrCtr = 0;
000018 616c STR r4,[r5,#0x14] ; ProbeCom_TxStrCtr
;;;330 #endif
;;;331 #endif
;;;332 }
00001a bd70 POP {r4-r6,pc}
;;;333
ENDP
ProbeCom_StrRdy PROC
;;;556
;;;557 wr_ix = ProbeComStrBufWrIx;
00001c 49f2 LDR r1,|L1.1000|
00001e 6988 LDR r0,[r1,#0x18] ; ProbeComStrBufWrIx
;;;558 rd_ix = ProbeComStrBufRdIx;
000020 69c9 LDR r1,[r1,#0x1c] ; ProbeComStrBufRdIx
;;;559
;;;560 if (wr_ix == rd_ix) {
000022 4288 CMP r0,r1
000024 d101 BNE |L1.42|
;;;561 rdy = DEF_FALSE;
000026 2000 MOVS r0,#0
;;;562 } else {
;;;563 rdy = DEF_TRUE;
;;;564 }
;;;565
;;;566 return (rdy);
;;;567 }
000028 4770 BX lr
|L1.42|
00002a 2001 MOVS r0,#1 ;563
00002c 4770 BX lr
;;;568 #endif
ENDP
ProbeCom_PktModifier PROC
;;;579 static CPU_INT08U ProbeCom_PktModifier (void)
;;;580 {
00002e b500 PUSH {lr}
;;;581 #if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
;;;582
;;;583 if (ProbeCom_StrRdy() == DEF_TRUE) {
000030 f7fffffe BL ProbeCom_StrRdy
000034 2801 CMP r0,#1
000036 d101 BNE |L1.60|
;;;584 return (PROBE_COM_MODIFIER_STR_HAVE);
000038 2001 MOVS r0,#1
;;;585 } else {
;;;586 return (PROBE_COM_MODIFIER_NONE);
;;;587 }
;;;588
;;;589 #else
;;;590
;;;591 return (PROBE_COM_MODIFIER_NONE);
;;;592
;;;593 #endif
;;;594 }
00003a bd00 POP {pc}
|L1.60|
00003c 2000 MOVS r0,#0 ;586
00003e bd00 POP {pc}
;;;595
ENDP
ProbeCom_StoINT8U PROC
;;;1346 {
;;;1347 *((*buf)++) = data;
000040 6802 LDR r2,[r0,#0]
000042 1c53 ADDS r3,r2,#1
000044 6003 STR r3,[r0,#0]
000046 7011 STRB r1,[r2,#0]
;;;1348 }
000048 4770 BX lr
;;;1349
ENDP
ProbeCom_StoINT16U PROC
;;;1351 static void ProbeCom_StoINT16U (CPU_INT08U **buf, CPU_INT16U data)
;;;1352 {
00004a b530 PUSH {r4,r5,lr}
00004c 4605 MOV r5,r0
00004e 460c MOV r4,r1
;;;1353 ProbeCom_StoINT8U(buf, data & 0x00FF);
000050 b2e1 UXTB r1,r4
000052 4628 MOV r0,r5
000054 f7fffffe BL ProbeCom_StoINT8U
;;;1354 ProbeCom_StoINT8U(buf, data >> 8);
000058 0a21 LSRS r1,r4,#8
00005a 4628 MOV r0,r5
00005c e8bd4030 POP {r4,r5,lr}
000060 e7fe B ProbeCom_StoINT8U
;;;1355 }
;;;1356
ENDP
ProbeCom_CmdError PROC
;;;625 CPU_INT16U com_error)
;;;626 {
000062 b513 PUSH {r0,r1,r4,lr}
000064 460c MOV r4,r1
;;;627 #if (PROBE_COM_STAT_EN == DEF_ENABLED)
;;;628 ProbeCom_ErrPktCtr++;
000066 48e0 LDR r0,|L1.1000|
000068 6901 LDR r1,[r0,#0x10] ; ProbeCom_ErrPktCtr
00006a 1c49 ADDS r1,r1,#1
00006c 6101 STR r1,[r0,#0x10] ; ProbeCom_ErrPktCtr
;;;629 #endif
;;;630
;;;631 ProbeCom_StoINT16U(&tx_buf, PROBE_COM_FMT_TX_ERROR); /* (a) TX packet format */
00006e f44f4100 MOV r1,#0x8000
000072 4668 MOV r0,sp
000074 f7fffffe BL ProbeCom_StoINT16U
;;;632 ProbeCom_StoINT8U( &tx_buf, com_error); /* (b) Target status */
000078 b2e1 UXTB r1,r4
00007a 4668 MOV r0,sp
00007c f7fffffe BL ProbeCom_StoINT8U
;;;633 ProbeCom_StoINT8U( &tx_buf, ProbeCom_PktModifier()); /* (c) Modifier */
000080 f7fffffe BL ProbeCom_PktModifier
000084 4601 MOV r1,r0
000086 4668 MOV r0,sp
000088 f7fffffe BL ProbeCom_StoINT8U
;;;634 return (PROBE_COM_SIZE_TX_HEADER); /* (d) Return TX data segment size */
00008c 2004 MOVS r0,#4
;;;635 /* = 4 (= Tx header size) */
;;;636 }
00008e b002 ADD sp,sp,#8
000090 bd10 POP {r4,pc}
;;;637
ENDP
ProbeCom_CmdStrGet PROC
;;;1157 CPU_INT16U tx_buf_sz)
;;;1158 {
000092 e92d5fff PUSH {r0-r12,lr}
000096 461f MOV r7,r3
;;;1159 CPU_INT08U error;
;;;1160 CPU_INT32U wr_ix;
;;;1161 CPU_INT32U rd_ix;
;;;1162 CPU_INT16U nbytes;
;;;1163
;;;1164 CPU_INT32U nbytes_rd;
;;;1165 CPU_INT32U rd_ix_n;
;;;1166 CPU_INT08U *tx_buf_p;
;;;1167
;;;1168
;;;1169 error = PROBE_COM_STATUS_OK;
000098 2101 MOVS r1,#1
;;;1170 wr_ix = ProbeComStrBufWrIx;
00009a f8df834c LDR r8,|L1.1000|
00009e f8d85018 LDR r5,[r8,#0x18] ; ProbeComStrBufWrIx
;;;1171 rd_ix = ProbeComStrBufRdIx;
0000a2 f8d8401c LDR r4,[r8,#0x1c] ; ProbeComStrBufRdIx
;;;1172 nbytes = 0;
;;;1173
;;;1174 if (rx_pkt_sz == 4) { /* If RX data segment is the expected size */
0000a6 2a04 CMP r2,#4
0000a8 d103 BNE |L1.178|
;;;1175 /* = 2 (= Rx header size) */
;;;1176 /* + 2 (= Padding ) */
;;;1177
;;;1178 if (wr_ix == rd_ix) { /* (a) If there is NO string, then error */
0000aa 42a5 CMP r5,r4
0000ac d102 BNE |L1.180|
;;;1179 error = PROBE_COM_STATUS_STR_NONE;
0000ae 21f8 MOVS r1,#0xf8
0000b0 e000 B |L1.180|
|L1.178|
;;;1180 }
;;;1181
;;;1182 } else { /* If RX data segment is NOT the expected size */
;;;1183
;;;1184 error = PROBE_COM_STATUS_RX_PKT_WRONG_SIZE;
0000b2 21fe MOVS r1,#0xfe
|L1.180|
;;;1185 }
;;;1186
;;;1187 if (error != PROBE_COM_STATUS_OK) { /* Error */
0000b4 2901 CMP r1,#1
0000b6 d005 BEQ |L1.196|
;;;1188 return (ProbeCom_CmdError(tx_buf, error));
0000b8 9801 LDR r0,[sp,#4]
0000ba f7fffffe BL ProbeCom_CmdError
;;;1189
;;;1190 } else { /* No error */
;;;1191 /* (a) Save TX data segment header */
;;;1192 ProbeCom_StoINT16U(&tx_buf, PROBE_COM_FMT_TX_STR_GET); /* (i) TX packet format */
;;;1193 ProbeCom_StoINT8U( &tx_buf, PROBE_COM_STATUS_OK); /* (ii) Target status */
;;;1194 ProbeCom_StoINT8U( &tx_buf, 0); /* (iii) Modifier */
;;;1195
;;;1196 tx_buf_p = tx_buf;
;;;1197
;;;1198 if (wr_ix > rd_ix) { /* (b) If wr_ix > rd_ix */
;;;1199 /* ... Store in pkt the bytes [rd_ix, wr_ix) */
;;;1200
;;;1201 nbytes_rd = wr_ix - rd_ix; /* (i) Calculate num. bytes to read */
;;;1202
;;;1203 if (nbytes_rd >= tx_buf_sz - PROBE_COM_SIZE_TX_HEADER - 1) { /* (ii) If too much to fit in packet */
;;;1204 /* .... Store only [rd_ix,rd_ix + tx_buf_sz - 5)*/
;;;1205 /* .... Where 5 = 1 (NULL byte) */
;;;1206 /* + 4 (TX header) */
;;;1207 nbytes_rd = tx_buf_sz - PROBE_COM_SIZE_TX_HEADER - 1;
;;;1208 rd_ix_n = rd_ix + tx_buf_sz - PROBE_COM_SIZE_TX_HEADER;
;;;1209
;;;1210 } else {
;;;1211 rd_ix_n = wr_ix;
;;;1212 }
;;;1213
;;;1214 nbytes = nbytes_rd; /* (iii) Store number of bytes read */
;;;1215 /* (iv) Read from the string buffer */
;;;1216 Mem_Copy((void *)tx_buf, (void *)&ProbeComStrBuf[rd_ix], nbytes_rd);
;;;1217
;;;1218 ProbeComStrBufRdIx = rd_ix_n; /* (v) Update global read index */
;;;1219
;;;1220 } else { /* (c) If wr_ix < rd_ix */
;;;1221 /* ... Store in pkt the bytes [rd_ix, end_ix) */
;;;1222 /* ... Then store in pkt the bytes [0, wr_ix) */
;;;1223
;;;1224 nbytes_rd = PROBE_COM_STR_BUF_SIZE - rd_ix; /* (i) Calculate num. bytes to read */
;;;1225
;;;1226 if (nbytes_rd >= tx_buf_sz - PROBE_COM_SIZE_TX_HEADER - 1) { /* (ii) If to much to fit in packet */
;;;1227 /* .... Store only [rd_ix, rd_ix + tx_buf_sz) */
;;;1228
;;;1229 nbytes = tx_buf_sz - PROBE_COM_SIZE_TX_HEADER - 1; /* (A) Store number of bytes read */
;;;1230 rd_ix_n = rd_ix + tx_buf_sz - PROBE_COM_SIZE_TX_HEADER;
;;;1231 /* (B) Read from string buffer */
;;;1232 Mem_Copy((void *)tx_buf, (void *)&ProbeComStrBuf[rd_ix], nbytes);
;;;1233
;;;1234 ProbeComStrBufRdIx = rd_ix_n; /* (C) Update global read index */
;;;1235
;;;1236 } else { /* (iii) If not too much for packet */
;;;1237
;;;1238 /* ------- [rd_ix, end_ix) ------ */
;;;1239
;;;1240 nbytes = nbytes_rd; /* (A) Store number of bytes read */
;;;1241 rd_ix_n = 0; /* (B) Buffer read ix after read */
;;;1242
;;;1243 /* (C) Read from the string buffer */
;;;1244 Mem_Copy((void *)tx_buf, (void *)&ProbeComStrBuf[rd_ix], nbytes_rd);
;;;1245 rd_ix = rd_ix_n; /* (D) Update local read index */
;;;1246
;;;1247 /* --------- [0, wr_ix) --------- */
;;;1248 tx_buf += nbytes_rd;
;;;1249 nbytes_rd = wr_ix; /* (E) Number of bytes to read */
;;;1250
;;;1251 /* (F) Too much to fit in packet */
;;;1252 if (nbytes_rd + nbytes >= tx_buf_sz - PROBE_COM_SIZE_TX_HEADER - 1) {
;;;1253 /* ... Store only [0, tx_buf_sz - 5] */
;;;1254 nbytes_rd = tx_buf_sz - nbytes - PROBE_COM_SIZE_TX_HEADER - 1;
;;;1255 }
;;;1256
;;;1257 nbytes += nbytes_rd; /* (G) Update total num. bytes read */
;;;1258 rd_ix_n = rd_ix + nbytes_rd; /* (H) Buffer read ix after read */
;;;1259
;;;1260 /* (I) Read from the string buffer */
;;;1261 Mem_Copy((void *)tx_buf, (void *)&ProbeComStrBuf[rd_ix], nbytes_rd);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?