| | |
| | | DISCPOLL, |
| | | GETNEARMSG, |
| | | NEARPOLL, |
| | | }tag_state=GETNEARMSG; |
| | | }tag_state=NEARPOLL; |
| | | static dwt_config_t config = { |
| | | 5, /* Channel number. */ |
| | | DWT_PRF_64M, /* Pulse repetition frequency. */ |
| | |
| | | dwt_configcontinuousframemode(124800); |
| | | dwt_writetxfctrl(13, 0); |
| | | dwt_starttx(DWT_START_TX_IMMEDIATE); |
| | | while(GET_USERKEY) |
| | | while(GET_USERKEY) |
| | | { |
| | | IdleTask(); |
| | | } |
| | | dwt_forcetrxoff(); |
| | | Reset_DW1000();//重启DW1000 /* Target specific drive of RSTn line into DW1000 low for a period. */ |
| | | Spi_ChangePrescaler(SPIx_PRESCALER_SLOW); //设置为快速模式 |
| | | dwt_initialise(DWT_LOADUCODE);//初始化DW1000 |
| | | Spi_ChangePrescaler(SPIx_PRESCALER_FAST); //设置为快速模式 |
| | | |
| | | /* Configure DW1000. See NOTE 6 below. */ |
| | |
| | | int16_t offset=2700; |
| | | extern int16_t g_commap_antdelay; |
| | | u8 motor_state,rec_remotepara_state,rec_remotepara[80]; |
| | | u8 flag_uwbrange_ok; |
| | | int32_t uwb_dist; |
| | | void NearPoll(void) |
| | | { |
| | | |
| | |
| | | exsistbase_list[rec_nearbasepos]=KEEP_TIMES; |
| | | memcpy(&temp_dist,&rx_buffer[DIST_IDX],4); |
| | | nearbase_distlist[rec_nearbasepos]=temp_dist; |
| | | if(temp_dist!=0x1ffff) |
| | | {flag_uwbrange_ok = 1; |
| | | uwb_dist = temp_dist;} |
| | | if((rx_buffer[MOTORSTATE_INDEX]&0xf)!=3) |
| | | motor_state=rx_buffer[MOTORSTATE_INDEX]&0xf; |
| | | rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4; |
| | |
| | | } |
| | | } |
| | | #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); |
| | | // 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++) |