zhyinch
2020-07-05 dd0d5d99bb183eeb6074f9bd4ddbff96104bd95d
Src/application/dw_app.c
@@ -266,7 +266,7 @@
u8 GetRandomSlotPos(uint32_t emptyslot)
{
   u8 i,temp_value;
   temp_value = GetRandomValue();
   temp_value = HAL_LPTIM_ReadCounter(&hlptim1);//GetRandomValue();
   for(i=temp_value%32;i<max_slotpos;i++)
   {
      if(((emptyslot>>i)&0x1)==0)
@@ -315,6 +315,7 @@
   last_nearbase_num=next_nearbase_num;
   nearbase_num=next_nearbase_num;
   recbase_num=0;
   motor_state=0;
   
   tx_near_msg[BATTARY_IDX] = Get_Battary();
   //tx_near_msg[BUTTON_IDX] = !READ_KEY0;
@@ -332,7 +333,7 @@
   flag_getresponse=0;
   start_count=HAL_LPTIM_ReadCounter(&hlptim1);
   recbase_num=0;
   timeout=ceil((float)nearbase_num*0.6)+2;
   timeout=ceil((float)nearbase_num*0.4)+2;
   end_count=start_count+(timeout<<5);
   if(end_count>=32768)
   {end_count-=32768;}
@@ -410,7 +411,8 @@
                           exsistbase_list[rec_nearbasepos]=KEEP_TIMES;
                           memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
                           nearbase_distlist[rec_nearbasepos]=temp_dist;
                           motor_state=rx_buffer[MOTORSTATE_INDEX]&0xf;
                           if((rx_buffer[MOTORSTATE_INDEX]&0xf)!=3)
                              motor_state=rx_buffer[MOTORSTATE_INDEX]&0xf;
                           rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4;
                           
                           mainbase_lost_count=0;
@@ -430,11 +432,11 @@
                           flag_getresponse=1;
                           memcpy(&rec_tagpos_binary,&rx_buffer[NEARMSG_EMPTYSLOTPOS_INDEX],4);
                           
                           tyncpoll_time=0;
                           //时间同步
                           ancsync_time=((sync_timer)*1000+tmp_time);   
                           last_slotnum=current_slotnum;
                           current_slotnum=round((float)sync_timer/g_com_map[COM_INTERVAL])+1;
                           current_slotnum=((float)sync_timer/g_com_map[COM_INTERVAL])+1;
                           if(current_slotnum==last_slotnum-1)
                           {flag_getresponse=1;}
                           lastsync_timer=sync_timer;
@@ -485,7 +487,7 @@
                           memcpy(&temp_dist,&rx_buffer[DIST_IDX],4);
                           nearbase_distlist[rec_nearbasepos]=temp_dist;
                           
                           if(motor_state<rx_buffer[MOTORSTATE_INDEX]&&rx_buffer[MOTORSTATE_INDEX]!=3)
                           if(motor_state<(rx_buffer[MOTORSTATE_INDEX]&0xf)&&(rx_buffer[MOTORSTATE_INDEX]&0xf)!=3)
                           {
                                 motor_state=rx_buffer[MOTORSTATE_INDEX];
                           }
@@ -523,7 +525,7 @@
//            }
            tagslotpos=GetRandomSlotPos(rec_tagpos_binary);
            tyncpoll_time = (tagslotpos--%max_slotpos)*slottime;   
      //      SetNextPollTime(tyncpoll_time);
            SetNextPollTime(tyncpoll_time);
         }
      //   tyncpoll_time=0;
         next_nearbase_num=0;
@@ -623,7 +625,7 @@
         tagslotpos=GetRandomSlotPos(rec_tagpos_binary);
         //tagslotpos=rx_buffer[TAGSLOTPOS];
         memcpy(nearbaseid_list,&rx_buffer[NEARBASEID_INDEX],nearbase_num*2);
         slottime=ceil((nearbase_num+2)*0.3)+1;
         //slottime=ceil((nearbase_num+2)*0.3)+1;
         tyncpoll_time=tagslotpos*slottime;
         tag_state=NEARPOLL;
      }