| | |
| | | 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; |
| | |
| | | { |
| | | 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))//䏿æ¥è¯¢è¯çç¶æç´å°åé宿 |
| | |
| | | change_base_count=0; |
| | | } |
| | | } |
| | | u8 anclost_times=0; |
| | | void NearPoll(void) |
| | | { |
| | | static u8 mainbase_lost_count=0,flag_finalsend; |
| | |
| | | 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; |
| | |
| | | //////////////////////////////////æ¶é´åæ¥ |
| | | 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) |
| | | { |
| | |
| | | {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; |
| | |
| | | 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); |
| | | // } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | void Tag_App(void)//å鿍¡å¼(TAGæ ç¾) |
| | | { |
| | | //LED0_ON; |
| | |
| | | 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; |
| | | } |
| | | } |