From 0781da980b9359a5542bacba06b6a60b0508650c Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期四, 02 四月 2020 22:08:23 +0800 Subject: [PATCH] 增加标签随机位置模式 --- 源码/核心板/Src/application/dw_app.c | 46 +++++++++++++++++++++++++++++++++------------- 1 files changed, 33 insertions(+), 13 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 ee4639a..0b3b968 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" @@ -193,6 +193,7 @@ u8 nearbase_num; u16 nearbaseid_list[10],mainbase_id; int32_t mainbase_dist,nearbase_distlist[10]; +uint8_t trygetnearmsg_times; void Poll(void) { uint32_t frame_len; @@ -269,6 +270,8 @@ { memcpy(&minid, &rx_buffer[ANCHOR_ID_IDX], 4); tag_state=GETNEARMSG; + trygetnearmsg_times=5; + mindist=temp_dist; } if(result==0) {while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))//不断查询芯片状态直到发送完成 @@ -342,6 +345,7 @@ change_base_count=0; } } +u8 anclost_times=0; void NearPoll(void) { static u8 mainbase_lost_count=0,flag_finalsend; @@ -364,6 +368,9 @@ dwt_writetxfctrl(13+2*nearbase_num, 0);//设置超宽带发送数据长度 dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置 + for(i=0;i<nearbase_num;i++) + nearbase_distlist[i]=0xffff; + flag_finalsend=0; neartimout_timer=0; recbase_num=0; @@ -411,7 +418,7 @@ //////////////////////////////////时间同步 memcpy(&sync_timer,&rx_buffer[ANCTIMEMS],2); memcpy(&tmp_time,&rx_buffer[ANCTIMEUS],2); - memcpy(&tagslotpos,&rx_buffer[TAGSLOTPOS],2); +// memcpy(&tagslotpos,&rx_buffer[TAGSLOTPOS],2); tmp_time=tmp_time+450; if(tmp_time>999) { @@ -421,9 +428,9 @@ {sync_timer=0;} } TIM3->CNT=tmp_time; - if(tagslotpos>max_slotpos) - tagslotpos=tagslotpos%(max_slotpos+1); - tyncpoll_time=(tagslotpos-1)*slottime; +// if(tagslotpos>max_slotpos) +// tagslotpos=tagslotpos%(max_slotpos+1); +// tyncpoll_time=(tagslotpos-1)*slottime; //////////////////////////// mainbase_lost_count=0; flag_finalsend=1; @@ -483,15 +490,19 @@ tag_state=DISCPOLL; } NearAncSelect(); -// if(result==0) -// {while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))//不断查询芯片状态直到发送完成 -// { }; -// -// } -// else -// { + if(recbase_num<g_com_map[MIN_REPORT_ANC_NUM] ) + { + anclost_times++; + if(anclost_times>3) + { + tagslotpos=poll_tx_ts%(max_slotpos+1); + } + }else{ + anclost_times=0; + } + dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); -// } + } @@ -533,6 +544,7 @@ } } } + void Tag_App(void)//发送模式(TAG标签) { //LED0_ON; @@ -544,10 +556,18 @@ Poll(); break; case GETNEARMSG: - GetNearMsg(); + // if(trygetnearmsg_times--!=0) + {GetNearMsg(); + } +// else{ +// tag_state=DISCPOLL; +// } + break; case NEARPOLL: + //GPIO_WriteBit(EU_TX_GPIO, EU_RX_PIN, Bit_SET); NearPoll(); + //GPIO_WriteBit(EU_TX_GPIO, EU_RX_PIN, Bit_RESET); break; } } -- Gitblit v1.9.3