| | |
| | | #define FINAL_MSG_FINAL_TX_TS_IDX 18 |
| | | #define FINAL_MSG_TS_LEN 4 |
| | | static dwt_config_t config = { |
| | | 2, /* Channel number. */ |
| | | 5, /* Channel number. */ |
| | | DWT_PRF_64M, /* Pulse repetition frequency. */ |
| | | DWT_PLEN_128, /* Preamble length. */ |
| | | DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ |
| | |
| | | freqlost_count = 0; |
| | | } |
| | | } |
| | | |
| | | u16 rec_nearbaseid,rec_nearbasepos; |
| | | void NearPoll(void) |
| | | { |
| | | |
| | |
| | | |
| | | tx_near_msg[TAGCONFIGSUCCESS_INDEX] =0; |
| | | para_update = 0; |
| | | get_newbase = 0; |
| | | flag_finalsend=0; |
| | | flag_rxon=1; |
| | | flag_getresponse=0; |
| | |
| | | dwt_setrxtimeout(0);//DELAY_BETWEEN_TWO_FRAME_UUS*(nearbase_num+1-recbase_num)+10);//设定接收超时时间,0位没有超时时间 |
| | | dwt_rxenable(0);//打开接收 |
| | | if (rx_buffer[MESSAGE_TYPE_IDX] == MBX_RESPONSE&&!memcmp(&rx_buffer[TAG_ID_IDX],&dev_id,2)&&rx_buffer[GROUP_ID_IDX]==group_id) //判断接收到的数据是否是response数据 |
| | | { u16 rec_nearbaseid,rec_nearbasepos; |
| | | { |
| | | poll_tx_ts = get_tx_timestamp_u64(); //获得POLL发送时间T1 |
| | | resp_rx_ts = get_rx_timestamp_u64(); //获得RESPONSE接收时间T4 |
| | | recbase_num++; |
| | |
| | | { |
| | | last_lpcount+= HAL_LPTIM_ReadCounter(&hlptim1)%(g_com_map[COM_INTERVAL]*16); |
| | | } |
| | | if(nearbase_num==4) |
| | | {nearbase_num=4;} |
| | | last_nearbase_num = next_nearbase_num; |
| | | for(i=0;i<last_nearbase_num-1;i++) |
| | | { |
| | |
| | | } |
| | | |
| | | report_num=0; |
| | | if(last_nearbase_num>4) |
| | | { |
| | | last_nearbase_num = 5; |
| | | } |
| | | for (i=0;i<last_nearbase_num;i++) |
| | | { |
| | | nearbaseid_list[i]=true_nearbase_idlist[i]; |
| | | nearbase_distlist[i]=true_nearbase_distlist[i]; |
| | | if(nearbase_distlist[i]!=0x1ffff&&true_exsistbase_list[i]==KEEP_TIMES) |
| | | { |
| | | memcpy(&usart_send[4+6*report_num],&nearbaseid_list[i],2); |
| | | memcpy(&usart_send[6+6*report_num],&nearbase_distlist[i],4); |
| | | report_num++; |
| | | } |
| | | } |
| | | #ifdef USART_INTEGRATE_OUTPUT |
| | | usart_send[0] = 0x55; |
| | | usart_send[1] = 0xAA; |
| | | usart_send[2] = 4;//正常模式 |
| | | usart_send[3] = report_num*6+2;//正常模式 |
| | | checksum = Checksum_u16(&usart_send[2],report_num*6+2); |
| | | memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | USART_puts(usart_send,6+report_num*6); |
| | | #endif |
| | | // #ifdef USART_INTEGRATE_OUTPUT |
| | | // usart_send[0] = 0x55; |
| | | // usart_send[1] = 0xAA; |
| | | // usart_send[2] = 4;//正常模式 |
| | | // usart_send[3] = report_num*6+2;//正常模式 |
| | | // checksum = Checksum_u16(&usart_send[2],report_num*6+2); |
| | | // memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | // USART_puts(usart_send,6+report_num*6); |
| | | // #endif |
| | | |
| | | for(i=0;i<MAX_NEARBASE_NUM;i++) |
| | | { |
| | |
| | | if(memcmp(&calCRC,&rec_remotepara[5],2)==0) |
| | | { uint8_t pack_msgtype,pack_index,pack_length; |
| | | pack_msgtype = rec_remotepara[0]; |
| | | pack_index = rec_remotepara[1]*2; |
| | | pack_index = rec_remotepara[1]; |
| | | pack_length = rec_remotepara[2]; |
| | | if(pack_msgtype==2) |
| | | { |
| | |
| | | { |
| | | |
| | | // motor_keeptime = rec_remotepara[3]; |
| | | }else{ |
| | | }else if(pack_index == CNT_UPDATE) |
| | | { |
| | | if(rec_remotepara[3]==2) |
| | | { |
| | | EnterUWBUpdateMode(); |
| | | } |
| | | } |
| | | else{ |
| | | if(pack_index<200) |
| | | { |
| | | memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length); |
| | |
| | | break; |
| | | } |
| | | } |
| | | delay_us(100); |
| | | g_Resttimer=0; |
| | | NearPoll(); |
| | | dwt_entersleep(); |