| | |
| | | #define FINAL_MSG_TS_LEN 4 |
| | | |
| | | #define STARTPOLL REGPOLL//#define SWITCHBASE_DIST |
| | | #define SWITCHBASE_ZHUANDIAN |
| | | //#define SWITCHBASE_ZHUANDIAN |
| | | #define SWITCHBASE_DIST |
| | | enum enumtagstate |
| | | { |
| | | REGPOLL, |
| | |
| | | GETNEARMSG, |
| | | NEARPOLL, |
| | | SINGLEPOLL, |
| | | }tag_state=SINGLEPOLL; |
| | | }tag_state=STARTPOLL; |
| | | static dwt_config_t config = { |
| | | 2, /* Channel number. */ |
| | | DWT_PRF_64M, /* Pulse repetition frequency. */ |
| | |
| | | u16 ancid_list[TAG_NUM_IN_SYS]; |
| | | u8 nearbase_num; |
| | | u16 mainbase_id; |
| | | int32_t mainbase_dist; |
| | | int32_t mainbase_dist,base_mindist; |
| | | uint8_t trygetnearmsg_times; |
| | | u16 mainbase_id,true_nearbase_idlist[MAX_NEARBASE_NUM],nearbaseid_list[MAX_NEARBASE_NUM],nearbaseid_list2[MAX_NEARBASE_NUM]; |
| | | u8 FindNearBasePos(u16 baseid) |
| | |
| | | { |
| | | u32 start_poll,frame_len; |
| | | |
| | | mainbase_id = 0x9724; |
| | | //mainbase_id = 0x9724; |
| | | memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2); |
| | | memcpy(&tx_near_msg[TAG_ID_IDX],&dev_id,2); |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_MSG; |
| | |
| | | memcpy(&temp_dist,&rx_buffer[DIST_IDX],4); |
| | | mainbase_dist=temp_dist; |
| | | nearbase_distlist[0] = temp_dist; |
| | | base_mindist = temp_dist; |
| | | if((rx_buffer[MOTORSTATE_INDEX]&0xf)!=3) |
| | | motor_state=rx_buffer[MOTORSTATE_INDEX]&0xf; |
| | | rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4; |
| | |
| | | mindist_slavebaseid = rec_nearbaseid; |
| | | } |
| | | #ifdef SWITCHBASE_ZHUANDIAN |
| | | if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]!=0&&temp_dist>0) |
| | | { |
| | | mainbase_id = rec_nearbaseid; |
| | | tag_state = GETNEARMSG; |
| | | } |
| | | #endif |
| | | if(temp_dist<nearbase_switchdistlist[rec_nearbasepos]&&nearbase_switchdistlist[rec_nearbasepos]!=0&&temp_dist>0) |
| | | { |
| | | mainbase_id = rec_nearbaseid; |
| | | tag_state = GETNEARMSG; |
| | | } |
| | | #endif |
| | | |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | } |
| | | for(i=0;i<nearbase_num;i++) |
| | | { |
| | | if(nearbaseid_list[i]!=nearbaseid_list2[i]) |
| | | { |
| | | tag_state = GETNEARMSG; |
| | | } |
| | | 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); |