From dd981218e231280601596abd643669556b36c102 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期日, 27 九月 2020 10:22:52 +0800
Subject: [PATCH] 增加调试信息,调试标签DW芯片状态异常中

---
 源码/核心板/Src/application/dw_app.c |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
index 9218bde..6947fa8 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
@@ -120,7 +120,9 @@
      * For initialisation, DW1000 clocks must be temporarily set to crystal speed. After initialisation SPI rate can be increased for optimum
      * performance. */
     Reset_DW1000();//重启DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */
+	status_reg = dwt_read32bitreg(SYS_STATUS_ID);
     dwt_initialise(DWT_LOADUCODE);//初始化DW1000
+	status_reg = dwt_read32bitreg(SYS_STATUS_ID);
 	Spi_ChangePrescaler(SPIx_PRESCALER_FAST);	//设置为快速模式
 
     /* Configure DW1000. See NOTE 6 below. */
@@ -365,6 +367,9 @@
 								dwt_forcetrxoff();
 								dwt_setdelayedtrxtime(final_tx_time);
 								result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送	
+																		#ifdef DEBUG_INF
+									USART_putc(0x33);
+									#endif
 								break;
 							}
 						}
@@ -425,6 +430,9 @@
 //										tagslotpos=tagslotpos%(max_slotpos+1);
 //										tyncpoll_time=(tagslotpos-1)*slottime;
 									////////////////////////////
+																	#ifdef DEBUG_INF
+									USART_putc(0x31);
+									#endif
 									rec_nearbasepos=0;
 									
 									memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
@@ -465,7 +473,7 @@
 										usart_send[14] = button;
 										checksum = Checksum_u16(&usart_send[2],17);
 										memcpy(&usart_send[19],&checksum,2);
-										UART_PushFrame(usart_send,21);
+									//	UART_PushFrame(usart_send,21);
 										#endif
 
 									//dwt_setdelayedtrxtime(final_tx_time);//设置final包发送时间T5
@@ -483,7 +491,9 @@
 										nearbaseid_list[rec_nearbasepos] = rec_nearbaseid;
 										memcpy(&tx_nearfinal_msg[ANCHOR_ID_IDX],&rec_nearbaseid,2);
 									}
-									
+									#ifdef DEBUG_INF
+									USART_putc(0x32);
+									#endif
 									memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
 									nearbase_distlist[rec_nearbasepos]=temp_dist;
 									
@@ -515,7 +525,7 @@
 										usart_send[14] = button;
 										checksum = Checksum_u16(&usart_send[2],17);
 										memcpy(&usart_send[19],&checksum,2);
-										UART_PushFrame(usart_send,21);
+										//UART_PushFrame(usart_send,21);
 										#endif
 
 									//dwt_setdelayedtrxtime(final_tx_time);//设置final包发送时间T5
@@ -525,6 +535,9 @@
 							}									
 							}
 						}else{
+							 #ifdef DEBUG_INF
+								printf("response包失败:%x/n",status_reg);
+								#endif
 						dwt_write32bitreg(SYS_STATUS_ID,SYS_STATUS_RXFCG| SYS_STATUS_ALL_RX_ERR);
 						if(flag_rxon)
 							{dwt_rxenable(0);	
@@ -618,6 +631,9 @@
 				memcpy(&usart_send[4+report_num*6],&checksum,2);
 				UART_PushFrame(usart_send,6+report_num*6);
 			#endif
+			#ifdef DEBUG_INF
+				printf("序号:%d,基站数量:%d/n",(frame_seq_nb-1)&0xff,nearbase_num);
+				#endif
 //			if(mainbase_lost_count>5)
 //			{
 //				//tag_state=DISCPOLL;
@@ -971,6 +987,9 @@
 					memcpy(&usart_send_anc[6+6*anc_report_num],&tagdist_list[taglist_pos],4);
 					anc_report_num++;
 				#endif
+				 #ifdef DEBUG_INF
+				 printf("序号:%d\r\n",frame_seq_nb2);
+				 #endif
 					}else{
 					//	printf("%d",hex_dist);
 						misdist_num[taglist_pos]++;
@@ -990,7 +1009,9 @@
 					}
 			}
 			}else{
-					//printf("%x/n",status_reg);
+				 #ifdef DEBUG_INF
+					printf("final包失败:%x/n",status_reg);
+				#endif
 				dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR);
 			}
 }
@@ -1117,6 +1138,9 @@
 				break;		
 		}	
 	}else{
+		 #ifdef DEBUG_INF
+		printf("poll包失败:%x/n",status_reg);
+		#endif
 		dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR);
 	}
 }

--
Gitblit v1.9.3