From cb5ff916850a3ab91774f6125cc3e73a04e6d754 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期日, 17 四月 2022 17:26:15 +0800 Subject: [PATCH] v1.72 --- 源码/核心板/Src/application/dw_app.c | 87 +++++++++++++++++++++++++++++-------------- 1 files changed, 59 insertions(+), 28 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 3245d47..416923f 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" @@ -1,6 +1,12 @@ #include "dw_app.h" #include "ADC.h" -#define TDFILTER +#include "stm32f10x_it.h" +#include "serial_at_cmd_app.h" +#define STRX(x) #x +#define STR(x) STRX(x) +#define __debug_info__ __FILE__ ":" STR(__LINE__) +//#define TDFILTER +#define DBGMSG_OUTPUT enum enumtagstate { DISCPOLL, @@ -43,14 +49,14 @@ uint32_t tag_id = 0; uint32_t tag_id_recv = 0; uint32_t anc_id_recv = 0; -uint8_t random_delay_tim = 0; +uint8_t random_delay_tim = 0,dbgmsg_len; double distance, dist_no_bias, dist_cm; uint32_t g_UWB_com_interval = 0; float dis_after_filter; //当前距离值 LPFilter_Frac* p_Dis_Filter; //测距用的低通滤波器 int32_t g_Tagdist[TAG_NUM_IN_SYS]; uint8_t g_flag_Taggetdist[256],flag_tag_distsmooth[TAG_NUM_IN_SYS]; - +char dbgmsg[100]; static uint64_t get_tx_timestamp_u64(void) { uint8_t ts_tab[5]; @@ -318,7 +324,7 @@ u8 exsistbase_list[MAX_NEARBASE_NUM],report_num,get_newbase=0,uwbrec_userdata[20],uwbrec_userdatalen; u16 temp_sync_timer1,temp_sync_timer2; extern u8 usartrec_userdatalen,heartbeat_timer; - void NearPoll(void) +void NearPoll(void) { static u8 mainbase_lost_count=0,flag_finalsend,flag_rxon; uint32_t temp1,temp2,dw_systime; @@ -384,7 +390,14 @@ flag_rxon=0; dwt_forcetrxoff(); dwt_setdelayedtrxtime(final_tx_time); - result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送 + result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送 + if(result!=DWT_SUCCESS) + { + #ifdef DBGMSG_OUTPUT + dbgmsg_len = sprintf(dbgmsg,"%s status_reg:%x",__debug_info__,status_reg); + SendDbgMsg(dbgmsg,dbgmsg_len); + #endif + } break; } } @@ -424,22 +437,22 @@ memcpy(&tmp_time,&rx_buffer[ANCTIMEUS],2); - if(g_com_map[DEV_ROLE]!=0) - { - sync_timer=temp_sync_timer1; -//// memcpy(&tagslotpos,&rx_buffer[TAGSLOTPOS],2); +// if(g_com_map[DEV_ROLE]!=0) +// { +// sync_timer=temp_sync_timer1; +////// memcpy(&tagslotpos,&rx_buffer[TAGSLOTPOS],2); +//// // - - tmp_time=tmp_time+650; - if(tmp_time>999) - { - tmp_time-=999; - sync_timer++; - if(sync_timer>=1000) - {sync_timer=0;} - } - TIM3->CNT=tmp_time; - } +// tmp_time=tmp_time+650; +// if(tmp_time>999) +// { +// tmp_time-=999; +// sync_timer++; +// if(sync_timer>=1000) +// {sync_timer=0;} +// } +// TIM3->CNT=tmp_time; +// } current_slotnum=temp_sync_timer1/g_com_map[COM_INTERVAL]; // if(tagslotpos>max_slotpos) // tagslotpos=tagslotpos%(max_slotpos+1); @@ -560,7 +573,12 @@ }else{ dwt_write32bitreg(SYS_STATUS_ID,SYS_STATUS_RXFCG| SYS_STATUS_ALL_RX_ERR); if(flag_rxon) - {dwt_rxenable(0); + { + dwt_rxenable(0); + #ifdef DBGMSG_OUTPUT + dbgmsg_len = sprintf(dbgmsg,"%s status_reg:%x",__debug_info__,status_reg); + SendDbgMsg(dbgmsg,dbgmsg_len); + #endif } } } @@ -584,9 +602,10 @@ // temp_adc=Get_ADC_Value(); // random_value=random_value|((temp_adc&0x01)<<i); // } + pollsendtimer+=time32_incr%11; tagslotpos=GetRandomSlotPos(rec_tagpos_binary|tagpos_binary); tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; - tag_state=NEARPOLL; + tag_state=NEARPOLL; } // tyncpoll_time=0; next_nearbase_num=0; @@ -742,7 +761,6 @@ NearPoll(); break; } - SetNextPollTime(tyncpoll_time); g_start_send_flag = 0; GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_RESET); @@ -923,7 +941,7 @@ motorstate =0; } } - tx_nearresp_msg[GROUP_ID_IDX] = group_id; + tx_nearresp_msg[GROUP_ID_IDX] = group_id; tx_nearresp_msg[MAINBASE_INDEX]=flag_syncbase; tx_nearresp_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE; tx_nearresp_msg[MOTORSTATE_INDEX]=motorstate;//(remotesend_state<<4)|motorstate; @@ -944,12 +962,15 @@ result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收 - if(result==0) + if(result==DWT_SUCCESS) { while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR))&&!g_start_sync_flag)///不断查询芯片状态直到接收成功或者出现错误 { }; }else{ - result++; + #ifdef DBGMSG_OUTPUT + dbgmsg_len = sprintf(dbgmsg,"%s status_reg:%x",__debug_info__,status_reg); + SendDbgMsg(dbgmsg,dbgmsg_len); + #endif } if (status_reg & SYS_STATUS_RXFCG)//接收成功 @@ -1066,6 +1087,10 @@ } }else{ //printf("%x/n",status_reg); + #ifdef DBGMSG_OUTPUT + dbgmsg_len = sprintf(dbgmsg,"%s status_reg:%x",__debug_info__,status_reg); + SendDbgMsg(dbgmsg,dbgmsg_len); + #endif dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); } } @@ -1222,9 +1247,15 @@ break; } - }else{ + } +}else{ + #ifdef DBGMSG_OUTPUT + if(status_reg&SYS_STATUS_ALL_RX_ERR) + { dbgmsg_len = sprintf(dbgmsg,"%s status_reg:%x",__debug_info__,status_reg); + SendDbgMsg(dbgmsg,dbgmsg_len); + } + #endif dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); } -} } -- Gitblit v1.9.3