| | |
| | | #include "dw_app_anchor.h" |
| | | #include "global_param.h" |
| | | #include "board.h" |
| | | |
| | | #include "lib_aoa.h" |
| | | |
| | | extern int simple_main(void); |
| | | extern int temp_main(void); |
| | |
| | | #define RANGING_PERIOD_MS (1000) |
| | | |
| | | /* This is the delay from Frame RX POLL frame to send RESP Frame */ |
| | | #define POLL_RX_TO_RESP_TX_DLY_US 670U //yuan450 |
| | | #define POLL_RX_TO_RESP_TX_DLY_US 1000U //yuan670 with urt 3000success |
| | | |
| | | #define RESP_TX_TO_FINAL_RX_DLY_US 500U |
| | | |
| | |
| | | uint8_t phy_work_mode; /* PHY_TX / PHY_RX / PHT_TX|PHY_RX */ |
| | | struct UWB_CONFIG_T phy_cfg; |
| | | }; |
| | | /* Use the default key and IV specified in the IEEE 802.15.4z attachment */ |
| | | static struct UWB_STS_KEY_CONFIG_T sts_iv_key = { |
| | | .sts_vcounter = 0x1F9A3DE4, |
| | | .sts_vupper0 = 0xD37EC3CA, |
| | | .sts_vupper1 = 0xC44FA8FB, |
| | | .sts_vupper2 = 0x362EEB34, |
| | | .sts_key0 = 0x14EB220F, |
| | | .sts_key1 = 0xF86050A8, |
| | | .sts_key2 = 0xD1D336AA, |
| | | .sts_key3 = 0x14148674, |
| | | }; |
| | | |
| | | ///* Default communication configuration. */ |
| | | //static struct mk_uwb_configure config = {//原来的基站非110k代码 |
| | | // .phy_work_mode = (uint8_t)(PHY_TX | PHY_RX), |
| | |
| | | .phy_cfg.rx_ant_id = UWB_RX_ANT_3, /* UWB RX antenna port */ |
| | | }; |
| | | #endif |
| | | /* Use the default key and IV specified in the IEEE 802.15.4z attachment */ |
| | | static struct UWB_STS_KEY_CONFIG_T sts_iv_key = { |
| | | .sts_vcounter = 0x1F9A3DE4, |
| | | .sts_vupper0 = 0xD37EC3CA, |
| | | .sts_vupper1 = 0xC44FA8FB, |
| | | .sts_vupper2 = 0x362EEB34, |
| | | .sts_key0 = 0x14EB220F, |
| | | .sts_key1 = 0xF86050A8, |
| | | .sts_key2 = 0xD1D336AA, |
| | | .sts_key3 = 0x14148674, |
| | | }; |
| | | /* Buffer to store received frame */ |
| | | |
| | | /* Frames used in the ranging process |
| | |
| | | while(mac_is_busy()); |
| | | gpio_pin_clr(SCL_PIN); |
| | | } |
| | | uint32_t range_timeout_us = 5000; |
| | | uint32_t range_timeout_us = 1000000;//yuan5000 |
| | | uint16_t uwb_searchcount; |
| | | uint8_t flag_recsuccess; |
| | | uint8_t flag_temp2,flag_temp1; |
| | |
| | | flag_recsuccess = 0; |
| | | temp_count3=phy_timer_count_get(); |
| | | gpio_pin_set(SCL_PIN); |
| | | sts_lsp_store(); |
| | | flag_temp1=uwb_rx(0, 0, range_timeout_us);//开启接收 |
| | | |
| | | // while(mac_is_busy()); |
| | |
| | | break; |
| | | } |
| | | } |
| | | sts_lsp_store_stop(); |
| | | |
| | | |
| | | if(receive_flag==1)//成功接收 |
| | | { |
| | |
| | | } |
| | | recev_error_num=0; |
| | | range_timeout_us=5000;//恢复为5000进入range后 |
| | | LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度ANT0:%d,信号强度ANT2:%d\r\n",g_com_map[BIND_DEV_ID],distance,sts_rssi[0],sts_rssi[2]); |
| | | LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度ANT0: %f,信号强度ANT2: %f\r\n",g_com_map[BIND_DEV_ID],distance,sts_rssi[0],sts_rssi[2]); |
| | | gpio_pin_clr(SCL_PIN); |
| | | break; |
| | | } |
| | | } |
| | | sts_lsp_store(); |
| | | //失败或者接受被高发射机打断都会再次开启接收 |
| | | flag_temp1=uwb_rx(0, 0, range_timeout_us); |
| | | } |
| | |
| | | receive_flag = 0; |
| | | temp_count3=phy_timer_count_get(); |
| | | gpio_pin_set(SCL_PIN); |
| | | sts_lsp_store(); |
| | | flag_temp2=uwb_rx(0, 0, RX_SYNC_WIN_US_TEMP);//开启接收 |
| | | start_receive_count=phy_timer_count_get(); |
| | | poll_timeout=US_TO_PHY_TIMER_COUNT(2000000);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | sts_lsp_store_stop(); |
| | | |
| | | |
| | | temp_count2=phy_timer_count_get(); |
| | | if(receive_flag==1)//成功接收 |
| | | { |
| | |
| | | } |
| | | |
| | | gpio_pin_clr(SCL_PIN);//测试 |
| | | LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度ANT0:%d,信号强度ANT2:%d\r\n",g_com_map[BIND_DEV_ID],distance,sts_rssi[0],sts_rssi[2]); |
| | | LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度ANT0:%f,信号强度ANT2: %f\r\n",g_com_map[BIND_DEV_ID],distance,sts_rssi[0],sts_rssi[2]); |
| | | return 1;//返回发送成功标志 |
| | | } |
| | | |
| | | } |
| | | temp_count3=phy_timer_count_get(); |
| | | sts_lsp_store(); |
| | | flag_temp2=uwb_rx(0, 0, RX_SYNC_WIN_US_TEMP);//再次开启接收 |
| | | } |
| | | delay_us(2); |
| | | sts_lsp_store_stop(); |
| | | uwb_rx_force_off(1); |
| | | // LOG_INFO(TRACE_MODULE_APP,"超时定时器:%x,%x,%x\r\n",start_receive_count,end_receive_count,current_count); |
| | | gpio_pin_clr(SCL_PIN);//测试 |