| | |
| | | * For initialisation, DW1000 clocks must be temporarily set to crystal speed. After initialisation SPI rate can be increased for optimum |
| | | * performance. */ |
| | | Reset_DW1000();//éå¯DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */ |
| | | status_reg = dwt_read32bitreg(SYS_STATUS_ID); |
| | | dwt_initialise(DWT_LOADUCODE);//åå§åDW1000 |
| | | status_reg = dwt_read32bitreg(SYS_STATUS_ID); |
| | | Spi_ChangePrescaler(SPIx_PRESCALER_FAST); //è®¾ç½®ä¸ºå¿«éæ¨¡å¼ |
| | | |
| | | /* Configure DW1000. See NOTE 6 below. */ |
| | |
| | | dwt_forcetrxoff(); |
| | | dwt_setdelayedtrxtime(final_tx_time); |
| | | result=dwt_starttx(DWT_START_TX_DELAYED);//设å®ä¸ºå»¶è¿åé |
| | | #ifdef DEBUG_INF |
| | | USART_putc(0x33); |
| | | #endif |
| | | break; |
| | | } |
| | | } |
| | |
| | | // tagslotpos=tagslotpos%(max_slotpos+1); |
| | | // tyncpoll_time=(tagslotpos-1)*slottime; |
| | | //////////////////////////// |
| | | #ifdef DEBUG_INF |
| | | USART_putc(0x31); |
| | | #endif |
| | | rec_nearbasepos=0; |
| | | |
| | | memcpy(&temp_dist,&rx_buffer[DIST_IDX],4); |
| | |
| | | usart_send[14] = button; |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | UART_PushFrame(usart_send,21); |
| | | // UART_PushFrame(usart_send,21); |
| | | #endif |
| | | |
| | | //dwt_setdelayedtrxtime(final_tx_time);//设置finalå
åéæ¶é´T5 |
| | |
| | | nearbaseid_list[rec_nearbasepos] = rec_nearbaseid; |
| | | memcpy(&tx_nearfinal_msg[ANCHOR_ID_IDX],&rec_nearbaseid,2); |
| | | } |
| | | |
| | | #ifdef DEBUG_INF |
| | | USART_putc(0x32); |
| | | #endif |
| | | memcpy(&temp_dist,&rx_buffer[DIST_IDX],4); |
| | | nearbase_distlist[rec_nearbasepos]=temp_dist; |
| | | |
| | |
| | | usart_send[14] = button; |
| | | checksum = Checksum_u16(&usart_send[2],17); |
| | | memcpy(&usart_send[19],&checksum,2); |
| | | UART_PushFrame(usart_send,21); |
| | | //UART_PushFrame(usart_send,21); |
| | | #endif |
| | | |
| | | //dwt_setdelayedtrxtime(final_tx_time);//设置finalå
åéæ¶é´T5 |
| | |
| | | } |
| | | } |
| | | }else{ |
| | | #ifdef DEBUG_INF |
| | | printf("responseå
失败ï¼%x/n",status_reg); |
| | | #endif |
| | | dwt_write32bitreg(SYS_STATUS_ID,SYS_STATUS_RXFCG| SYS_STATUS_ALL_RX_ERR); |
| | | if(flag_rxon) |
| | | {dwt_rxenable(0); |
| | |
| | | memcpy(&usart_send[4+report_num*6],&checksum,2); |
| | | UART_PushFrame(usart_send,6+report_num*6); |
| | | #endif |
| | | #ifdef DEBUG_INF |
| | | printf("åºå·ï¼%d,åºç«æ°éï¼%d/n",(frame_seq_nb-1)&0xff,nearbase_num); |
| | | #endif |
| | | // if(mainbase_lost_count>5) |
| | | // { |
| | | // //tag_state=DISCPOLL; |
| | |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); |
| | | } |
| | | } |
| | | u8 misdist_num[TAG_NUM_IN_SYS],seize_anchor; |
| | | extern uint16_t configremotetagID; |
| | | extern u8 remotetag_paralen; |
| | | u8 misdist_num[TAG_NUM_IN_SYS],seize_anchor,waittagconfig_reponse; |
| | | u8 Anchor_RecNearPoll(u8 ancrec_nearbasepos) //0 mainbase 1 first near_base |
| | | { |
| | | u8 motorstate; |
| | |
| | | tx_nearresp_msg[MAINBASE_INDEX]=flag_syncbase; |
| | | tx_nearresp_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE; |
| | | tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate; |
| | | if(remotesend_state) |
| | | { |
| | | memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,REMOTEPARA_LEN); |
| | | dwt_writetxdata(22+REMOTEPARA_LEN, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22+REMOTEPARA_LEN, 0);//设å®åéé¿åº¦ |
| | | }else{ |
| | | dwt_writetxdata(22, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22, 0);//设å®åéé¿åº¦ |
| | | } |
| | | waittagconfig_reponse=0; |
| | | if(pwtag.remain_time>0) |
| | | {uint8_t i; |
| | | for(i=0;i<pwtag.groupnum;i++) |
| | | { |
| | | if(pwtag.groupid[i][0]<=tag_id_recv&&tag_id_recv<=pwtag.groupid[i][1]) |
| | | { |
| | | remotesend_state=1; |
| | | tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate; |
| | | remotetag_paralen = 2+3; |
| | | remotetag_para[0] = 2; |
| | | remotetag_para[1] = 6; |
| | | remotetag_para[2] = 2; |
| | | memcpy(&remotetag_para[3],&pwtag.group_interval[i],2); |
| | | memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,remotetag_paralen); |
| | | dwt_writetxdata(22+remotetag_paralen, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22+remotetag_paralen, 0);//设å®åéé¿åº¦ |
| | | remotesend_state=0; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | dwt_writetxdata(22, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(22, 0);//设å®åéé¿åº¦ |
| | | } |
| | | |
| | | // if(remotesend_state&&tag_id_recv==configremotetagID) |
| | | // { |
| | | // memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,remotetag_paralen); |
| | | // dwt_writetxdata(22+remotetag_paralen, tx_nearresp_msg, 0);//åå
¥åéæ°æ® |
| | | // dwt_writetxfctrl(22+remotetag_paralen, 0);//设å®åéé¿åº¦ |
| | | // waittagconfig_reponse=1; |
| | | // }else{ |
| | | |
| | | result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//å»¶è¿åéï¼çå¾
æ¥æ¶ |
| | | |
| | | battary = rx_buffer[BATTARY_IDX]; |
| | |
| | | memcpy(&usart_send_anc[6+6*anc_report_num],&tagdist_list[taglist_pos],4); |
| | | anc_report_num++; |
| | | #endif |
| | | #ifdef DEBUG_INF |
| | | printf("åºå·ï¼%d\r\n",frame_seq_nb2); |
| | | #endif |
| | | }else{ |
| | | // printf("%d",hex_dist); |
| | | misdist_num[taglist_pos]++; |
| | | } |
| | | } |
| | | if(rx_buffer[TAGCONFIGSUCCESS_INDEX]==1&&waittagconfig_reponse) |
| | | { |
| | | waittagconfig_reponse = 0; |
| | | remotesend_state = 0; |
| | | usart_send[2] = 7;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 5;//æ°æ®æ®µé¿åº¦ |
| | | memcpy(&usart_send[4],&tag_id_recv,2); |
| | | usart_send[6] = 1;//æ°æ®æ®µé¿åº¦ |
| | | checksum = Checksum_u16(&usart_send[2],5); |
| | | memcpy(&usart_send[7],&checksum,2); |
| | | UART_PushFrame(usart_send,9); |
| | | } |
| | | } |
| | | }else{ |
| | | //printf("%x/n",status_reg); |
| | | #ifdef DEBUG_INF |
| | | printf("finalå
失败ï¼%x/n",status_reg); |
| | | #endif |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); |
| | | } |
| | | } |
| | |
| | | break; |
| | | } |
| | | }else{ |
| | | #ifdef DEBUG_INF |
| | | printf("pollå
失败ï¼%x/n",status_reg); |
| | | #endif |
| | | dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); |
| | | } |
| | | } |