| | |
| | | #define FINAL_MSG_FINAL_TX_TS_IDX 18 |
| | | #define FINAL_MSG_TS_LEN 4 |
| | | |
| | | #define STARTPOLL REGPOLL |
| | | #define SWITCHBASE_DIST |
| | | //#define SWITCHBASE_ZHUANDIAN |
| | | #define STARTPOLL REGPOLL//#define SWITCHBASE_DIST |
| | | #define SWITCHBASE_ZHUANDIAN |
| | | enum enumtagstate |
| | | { |
| | | REGPOLL, |
| | |
| | | u16 mainbase_id; |
| | | int32_t mainbase_dist; |
| | | uint8_t trygetnearmsg_times; |
| | | u16 nearbaseid_list[MAX_NEARBASE_NUM],mainbase_id,true_nearbase_idlist[MAX_NEARBASE_NUM]; |
| | | u16 mainbase_id,true_nearbase_idlist[MAX_NEARBASE_NUM],nearbaseid_list[MAX_NEARBASE_NUM],nearbaseid_list2[MAX_NEARBASE_NUM]; |
| | | u8 FindNearBasePos(u16 baseid) |
| | | { |
| | | u8 i; |
| | |
| | | // tagslotpos=GetRandomSlotPos(rec_tagpos_binary); |
| | | //tagslotpos=rx_buffer[TAGSLOTPOS]; |
| | | memcpy(nearbaseid_list,&rx_buffer[NEARBASEID_INDEX],nearbase_num*2); |
| | | memcpy(nearbaseid_list2,&rx_buffer[NEARBASEID_INDEX],nearbase_num*2); |
| | | //slottime=ceil((nearbase_num+2)*0.3)+1; |
| | | //tyncpoll_time=tagslotpos*slottime; |
| | | //tyncpoll_time=(g_com_map[DEV_ID]%max_slotpos)*slottime; |
| | |
| | | extern float motor_keeptime; |
| | | uint8_t changemainbase_count=0,gotosleep_flag; |
| | | uint32_t frame_len; |
| | | int32_t salvebase_mindist; |
| | | void NearPoll(void) |
| | | { |
| | | |
| | | uint32_t temp1,temp2,dw_systime,salvebase_mindist=999999,mindist_slavebaseid; |
| | | uint32_t temp1,temp2,dw_systime,mindist_slavebaseid; |
| | | |
| | | uint32_t final_tx_time; |
| | | u32 start_poll; |
| | |
| | | dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS); //设置发送后开启接收,并设定延迟时间 |
| | | dwt_setrxtimeout(RESP_RX_TIMEOUT_UUS); |
| | | tag_succ_times = 0; |
| | | |
| | | salvebase_mindist=999999; |
| | | if(next_nearbase_num>=MAX_NEARBASE_NUM) |
| | | { |
| | | next_nearbase_num = MAX_NEARBASE_NUM-1; |
| | |
| | | final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+nearbase_num*4], resp_rx_ts); |
| | | final_msg_set_ts(&tx_near_msg[FINAL_MSG_FINAL_TX_TS_IDX], final_tx_ts); |
| | | tx_near_msg[MESSAGE_TYPE_IDX]=NEAR_FINAL; |
| | | |
| | | if(rec_remotepara_state&&!memcmp(&rx_buffer[TAG_ID_IDX],&dev_id,2)) |
| | | { |
| | | para_update = 1; |
| | | tx_near_msg[TAGCONFIGSUCCESS_INDEX] = 1; |
| | | para_len = frame_len-22; |
| | | memcpy(rec_remotepara,&rx_buffer[REMOTEPARA_INDEX],para_len); |
| | | } |
| | | dwt_writetxdata(28+nearbase_num*4, tx_near_msg, 0);//将发送数据写入DW1000 |
| | | dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度 |
| | | dwt_setdelayedtrxtime(final_tx_time);//设置final包发送时间T5 |
| | |
| | | mainbase_lost_count=0; |
| | | flag_finalsend=1; |
| | | memcpy(&mainbase_dist,&rx_buffer[DIST_IDX],4); |
| | | |
| | | if(rec_remotepara_state&&!memcmp(&rx_buffer[TAG_ID_IDX],&dev_id,2)) |
| | | { |
| | | para_update = 1; |
| | | tx_near_msg[TAGCONFIGSUCCESS_INDEX] = 1; |
| | | para_len = frame_len-22; |
| | | memcpy(rec_remotepara,&rx_buffer[REMOTEPARA_INDEX],para_len); |
| | | } |
| | | |
| | | |
| | | flag_getresponse=1; |
| | | //时间同步 |
| | | tmp_time=tmp_time+450; |
| | |
| | | pack_length = rec_remotepara[2]; |
| | | if(pack_msgtype==2) |
| | | { |
| | | if( pack_index == 0x10) |
| | | if( pack_index == MOTOR_ONTIME_INDEX&&motor_keeptime==0) |
| | | { |
| | | motor_keeptime = rec_remotepara[3]; |
| | | }else{ |
| | |
| | | NVIC_SystemReset(); |
| | | } |
| | | } |
| | | } |
| | | for(i=0;i<nearbase_num;i++) |
| | | { |
| | | if(nearbaseid_list[i]!=nearbaseid_list2[i]) |
| | | { |
| | | tag_state = GETNEARMSG; |
| | | } |
| | | } |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG); |
| | | //HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_RESET); |
| | |
| | | mainbase_id=rec_nearbaseid; |
| | | nearbase_num=rx_buffer[NEARBASENUM_INDEX]; |
| | | memcpy(nearbaseid_list,&rx_buffer[NEARBASEID_INDEX],nearbase_num*2); |
| | | memcpy(nearbaseid_list2,&rx_buffer[NEARBASEID_INDEX],nearbase_num*2); |
| | | if(tagslotpos!=255) |
| | | tag_state = NEARPOLL; |
| | | } |