| | |
| | | u16 nearbaseid_list[MAX_NEARBASE_NUM],mainbase_id,true_nearbase_idlist[MAX_NEARBASE_NUM]; |
| | | int32_t mainbase_dist,nearbase_distlist[MAX_NEARBASE_NUM],true_nearbase_distlist[MAX_NEARBASE_NUM],true_exsistbase_list[MAX_NEARBASE_NUM]; |
| | | uint8_t trygetnearmsg_times; |
| | | u16 current_slotnum,total_slotnum,target_time; |
| | | void SetNextPollTime(u16 time) |
| | | { |
| | | if(current_slotnum>=total_slotnum) |
| | | current_slotnum-=total_slotnum; |
| | | //time=5; |
| | | target_time=((current_slotnum*g_com_map[COM_INTERVAL])+time); |
| | | if(target_time>=990&&target_time<1000) |
| | | { |
| | | current_slotnum++; |
| | | target_time+=g_com_map[COM_INTERVAL]; |
| | | } |
| | | if(target_time>=1000) |
| | | {target_time-=1000;} |
| | | if(target_time<0) |
| | | {target_time+=1000;} |
| | | |
| | | } |
| | | u8 FindNearBasePos(u16 baseid) |
| | | { |
| | | u8 i; |
| | |
| | | { |
| | | u8 i,temp_value; |
| | | temp_value = GetRandomValue(); |
| | | for(i=temp_value%32;i<max_slotpos;i++) |
| | | for(i=temp_value%max_slotpos;i<max_slotpos;i++) |
| | | { |
| | | if(((emptyslot>>i)&0x1)==0) |
| | | { |
| | |
| | | u8 exsistbase_list[MAX_NEARBASE_NUM],report_num,get_newbase=0; |
| | | u16 temp_sync_timer1,temp_sync_timer2; |
| | | u32 rec_tagpos_binary; |
| | | extern uint32_t tagpos_binary; |
| | | void NearPoll(void) |
| | | { |
| | | static u8 mainbase_lost_count=0,flag_finalsend,flag_rxon; |
| | |
| | | // temp_adc=Get_ADC_Value(); |
| | | // random_value=random_value|((temp_adc&0x01)<<i); |
| | | // } |
| | | tagslotpos=GetRandomSlotPos(rec_tagpos_binary); |
| | | tagslotpos=GetRandomSlotPos(rec_tagpos_binary|tagpos_binary); |
| | | tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; |
| | | } |
| | | // tyncpoll_time=0; |
| | |
| | | // }else{ |
| | | // anclost_times=0; |
| | | // } |
| | | |
| | | dwt_forcetrxoff(); |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG); |
| | | } |
| | | u8 nearmsg_mainbase=0,rec_tagpos_emptylist[32]; |
| | |
| | | }else{ |
| | | tyncpoll_time = (tagslotpos--%max_slotpos)*slottime; |
| | | } |
| | | |
| | | } |
| | | |
| | | void Tag_App(void)//å鿍¡å¼(TAGæ ç¾) |
| | |
| | | //LED0_ON; |
| | | dwt_forcetrxoff(); |
| | | g_Resttimer=0; |
| | | GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET); |
| | | switch(tag_state) |
| | | { |
| | | case DISCPOLL: |
| | |
| | | NearPoll(); |
| | | break; |
| | | } |
| | | |
| | | current_slotnum++; |
| | | SetNextPollTime(tyncpoll_time); |
| | | GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_RESET); |
| | | } |
| | | |
| | | int8_t correction_time,new_tagid=0; |
| | |
| | | } |
| | | uint32_t current_syncid=0xffffffff,synclost_timer; |
| | | extern u8 flag_syncbase; |
| | | extern uint32_t tagpos_binary; |
| | | u8 tagpos_rec[50],tagpos_send[50],ancidlist_num; |
| | | u16 ancidlist_rec[20],ancidlist_send[20]; |
| | | void Anchor_App(void) |
| | |
| | | u16 tempid; |
| | | uint32_t rec_syncid; |
| | | |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG); |
| | | g_start_sync_flag=0; |
| | | |
| | | dwt_setrxtimeout(0);//è®¾å®æ¥æ¶è¶
æ¶æ¶é´ï¼0使²¡æè¶
æ¶æ¶é´ |
| | | dwt_rxenable(0);//æå¼æ¥æ¶ |
| | | |
| | | // GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET); |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR))&&!g_start_send_flag&&!g_start_sync_flag)//䏿æ¥è¯¢è¯çç¶æç´å°æ¥æ¶æåæè
åºç°é误 |
| | | { |
| | | IdleTask(); |
| | | }; |
| | | |
| | | //GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_RESET); |
| | | if (status_reg & SYS_STATUS_RXFCG)//æåæ¥æ¶ |
| | | { u16 tag_recv_interval; |
| | | float temp_tagpos; |