| | |
| | | uint16_t warning_distance,prewarning_distance; |
| | | int16_t fVoltage_mv,first_search_flag; |
| | | uint8_t bat_percent,g_start_send_flag=1; |
| | | uint8_t LORA_REV_uwb_up =0; |
| | | uint8_t link_success_flag,motor_count; |
| | | uint16_t gps_wait_count; |
| | | uint8_t state5v = 1; |
| | |
| | | uint32_t successful_cnt=0; |
| | | uint8_t flag_4guart_needinit=0; |
| | | #define TX_LEN 10 |
| | | #define RX_LEN 10 |
| | | uint8_t tx_test_buf[TX_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| | | uint8_t RF_RX_temp[RX_LEN]={0}; |
| | | extern struct RxDoneMsg RxDoneParams; |
| | | static void Lora_irq_handler(enum IO_PIN_T pin) |
| | | { |
| | | ceshi++; |
| | | rf_irq_process(); |
| | | if(rf_get_transmit_flag() == RADIO_FLAG_TXDONE) |
| | | { |
| | | rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | rf_enter_continous_rx(); |
| | | // rf_delay_ms(1000); |
| | | // if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != OK) |
| | | // { |
| | | //// rf_enter_continous_rx(); |
| | | // } |
| | | // else |
| | | // { |
| | | // error_cnt ++; |
| | | // } |
| | | } |
| | | //g_start_send_flag=1; |
| | | // if(rf_get_transmit_flag() == RADIO_FLAG_TXDONE) |
| | | // { |
| | | // rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | // rf_enter_continous_rx(); |
| | | //// rf_delay_ms(1000); |
| | | //// if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != OK) |
| | | //// { |
| | | ////// rf_enter_continous_rx(); |
| | | //// } |
| | | //// else |
| | | //// { |
| | | //// error_cnt ++; |
| | | //// } |
| | | // } |
| | | if(rf_get_recv_flag() == RADIO_FLAG_RXDONE) |
| | | { |
| | | rf_set_recv_flag(RADIO_FLAG_IDLE); |
| | | memcpy(RF_RX_temp,RxDoneParams.Payload,RxDoneParams.Size); |
| | | if(RF_RX_temp[0]==0x48&&RF_RX_temp[1]==0x58) |
| | | { |
| | | LORA_REV_uwb_up=1; |
| | | |
| | | } |
| | | // rf_enter_continous_rx(); //重新进入接收模式 |
| | | //UwbRange(); |
| | | // DDL_Printf("Rx : SNR: %f ,RSSI: %d \r\n", RxDoneParams.Snr, RxDoneParams.Rssi); |
| | | int i=0; |
| | | //int i=0; |
| | | // for(i = 0; i < RxDoneParams.Size; i++) |
| | | // { |
| | | // printf("0x%02x ", RxDoneParams.Payload[i]); |
| | | // } |
| | | error_cnt ++; |
| | | // error_cnt ++; |
| | | } |
| | | if((rf_get_recv_flag() == RADIO_FLAG_RXTIMEOUT) || (rf_get_recv_flag() == RADIO_FLAG_RXERR)) |
| | | { |
| | |
| | | Lora_init(); |
| | | rf_set_default_para(); |
| | | // |
| | | rf_enter_continous_tx(); |
| | | rf_enter_continous_rx(); |
| | | // rf_set_transmit_flag(RADIO_FLAG_TXDONE); |
| | | // rf_set_transmit_flag(RADIO_FLAG_TXDONE); |
| | | if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != 0) |
| | | { |
| | | error_cnt++; |
| | | } |
| | | else |
| | | { |
| | | successful_cnt ++; |
| | | } |
| | | // if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != 0) |
| | | // { |
| | | // error_cnt++; |
| | | // } |
| | | // else |
| | | // { |
| | | // successful_cnt ++; |
| | | // } |
| | | |
| | | |
| | | // while (rf_get_transmit_flag() == RADIO_FLAG_IDLE) ; |
| | |
| | | // adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 |
| | | Program_Init(); |
| | | // uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); |
| | | // |
| | | // |
| | | //// Initialize low power mode |
| | | // power_init(); |
| | | // AIR780E_Reset(); //4G模块重启,耗时1.5秒,这个是无法同步的关键 |
| | | sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback); |
| | | |
| | | sleep_timer_start(__MS_TO_32K_CNT(1000));//测试 |
| | | |
| | | #ifdef DEBUG_BOXING |
| | | io_pin_mux_set(IO_PIN_5,IO_FUNC0); |
| | | gpio_pin_set_dir(IO_PIN_5,GPIO_DIR_OUT,0); |
| | | io_pull_set(IO_PIN_5,IO_PULL_DOWN,IO_PULL_UP_LEVEL4); |
| | | #endif |
| | | // board_acceleration_detection_init(move_handler); |
| | | Uwbinit(); |
| | | while (1) |
| | | { |
| | | if(LORA_REV_uwb_up) |
| | | { |
| | | LORA_REV_uwb_up=0; |
| | | UwbRange(); |
| | | } |
| | | if(g_start_send_flag) |
| | | { |
| | | g_start_send_flag=0; |
| | | |
| | | } |
| | | |
| | | |
| | | // UwbRange(); |
| | | // UwbRange(); |
| | | // rf_irq_process(); |
| | | // if(rf_get_transmit_flag() == RADIO_FLAG_TXDONE) |
| | | // { |