| | |
| | | #include "lora_3029.h" |
| | | #include "pan_rf.h" |
| | | #include "PCA9555.h" |
| | | #include "mk_phy.h" |
| | | #define DEBUG_MODE |
| | | extern int simple_main(void); |
| | | extern int temp_main(void); |
| | |
| | | #define WARING_LIMIT_TIME 10 |
| | | #define UPDATE_TIME 10 |
| | | |
| | | /****************************************************************引脚宏定义**************************************************/ |
| | | #define ADC_PIN IO_PIN_0 |
| | | #define UART0_TX IO_PIN_5 |
| | | #define UART0_RX IO_PIN_6 |
| | | #define UART1_TX IO_PIN_1 |
| | | #define UART1_RX IO_PIN_14 |
| | | |
| | | |
| | | /****************************************************************引脚宏定义**************************************************/ |
| | | void test_Delay_us(uint16_t time); |
| | | void Lora_UploadHeartBeartPoll(void); |
| | | extern uint8_t mUsartReceivePack[100]; |
| | |
| | | { |
| | | uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); |
| | | } |
| | | |
| | | static void adc_callback(void *data, uint32_t number) |
| | | { |
| | | uint32_t *result = (uint32_t *)data; |
| | |
| | | //// gpio_pin_clr(IO_PIN_5);//测试 |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | // lora_wg_up=1; |
| | | |
| | | lora_tx_flag++; |
| | | // lora_qiehuan++; |
| | | // IO_control_init(); |
| | | // UWBPoll(); |
| | | // |
| | |
| | | //GPS工作逻辑 |
| | | |
| | | } |
| | | |
| | | void phy_timer_callback(uint32_t time) |
| | | { |
| | | lora_tx_flag++; |
| | | } |
| | | uint8_t DMA_RXBuf_BT[200]={0}; |
| | | void uart0_receive_callback() |
| | | { |
| | | uint8_t buff[200]={0}; |
| | | memcpy(buff,m_EUART_DMA_RXBuf,100); |
| | | if(buff[0]==0x55||buff[1]==0xAA||buff[2]==0x41) |
| | | { |
| | | uint8_t lenth=0; |
| | | lenth=((buff[4]*2)+(buff[4]*2)+1); |
| | | memcpy(DMA_RXBuf_BT,&buff[4],lenth); |
| | | } |
| | | } |
| | | static void voltage_input_handler(enum IO_PIN_T pin) |
| | | { |
| | | |
| | | } |
| | | static void move_handler(enum IO_PIN_T pin) |
| | | { |
| | | nomove_count=0; |
| | | } |
| | | |
| | | uint8_t flag_4G_recdata; |
| | | static void _4gUsart_handler(enum IO_PIN_T pin) |
| | | { |
| | |
| | | { |
| | | Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为 |
| | | parameter_init_anchor();//g_com_map表初始化角色默认为基站 |
| | | g_com_map[DEV_ID]=0x6789; |
| | | g_com_map[GROUP_ID]=1; |
| | | g_com_map[DEV_ID]=0x1234; |
| | | // g_com_map[GROUP_ID]=1; |
| | | dev_id=g_com_map[DEV_ID];//这里不太对 |
| | | group_id=g_com_map[GROUP_ID];//组ID |
| | | tag_frequency = 1000/g_com_map[COM_INTERVAL];//测距频率这个存的是测距时间 |
| | |
| | | #define TEST_SPI_INTERUPT_MODE 1 |
| | | #define TEST_SPI_DMA_MODE 2 |
| | | #define TEST_SPI_MODE TEST_SPI_POLL_MODE |
| | | void spi_gpio_init() |
| | | //#define ADC_PIN IO_PIN_0 |
| | | //#define UART0_TX IO_PIN_5 |
| | | //#define UART0_RX IO_PIN_6 |
| | | //#define UART1_TX IO_PIN_1 |
| | | //#define UART1_RX |
| | | void Board_gpio_init() |
| | | { |
| | | // SPI0 MOSI/MISO/CLK/CS |
| | | // SPI0 MOSI/MISO/CLK/CS |
| | | io_pin_mux_set(LORA_CS, IO_FUNC0); |
| | | gpio_pin_set_dir(LORA_CS , GPIO_DIR_OUT, 0); |
| | | io_pull_set(LORA_CS, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | |
| | | |
| | | io_pin_mux_set(LORA_MOSI, IO_FUNC2); |
| | | io_pin_mux_set(LORA_MISO, IO_FUNC2); |
| | | io_pin_mux_set(LORA_CLK, IO_FUNC2); |
| | | io_pin_mux_set(LORA_DIO, IO_FUNC0);//spi中断 |
| | | io_pin_mux_set(LORA_DIO, IO_FUNC0); |
| | | |
| | | // io_pin_mux_set(LORA_DIO, IO_FUNC0); |
| | | // gpio_pin_set_dir(LORA_DIO , GPIO_DIR_OUT, 0); |
| | | // io_pull_set(LORA_DIO, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | |
| | | |
| | | // io_pin_mux_set(LORA_CS2, IO_FUNC0); |
| | | // gpio_pin_set_dir(LORA_CS2 , GPIO_DIR_OUT, 0); |
| | | // io_pull_set(LORA_CS2, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | |
| | | // //ADC |
| | | // io_pin_mux_set(ADC_PIN, IO_FUNC1); |
| | | // io_pull_set(ADC_PIN, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | // //串口0 |
| | | // io_pin_mux_set(UART0_RX, IO_FUNC4); |
| | | // io_pin_mux_set(UART0_TX, IO_FUNC4); |
| | | // board_debug_console_open(TRACE_PORT_UART0); |
| | | // uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart0_receive_callback);//开启dma |
| | | // |
| | | // //串口1 |
| | | // io_pin_mux_set(UART1_RX, IO_FUNC4); |
| | | // io_pin_mux_set(UART1_TX, IO_FUNC4); |
| | | } |
| | | void spi_init() |
| | | { |
| | |
| | | extern uint16_t BufferSize; |
| | | static uint16_t source_id; |
| | | extern struct RxDoneMsg RxDoneParams; |
| | | uint32_t time_flag_lorarx=0; |
| | | uint32_t lora_huanxing_count=0; |
| | | uint16_t Lora_wangguanid=0; |
| | | extern uint16_t wg_report_freq,wg_report_id; |
| | | extern uint32_t wg_lost_count; |
| | | wg_state_enum wg_state = WG_Lost; |
| | | |
| | | |
| | | extern uint16_t current_count; |
| | | extern uint8_t rec_index,rec_secdelay; |
| | | extern uint8_t yuyin_no_sleep_flag,no_rx_flag; |
| | | |
| | | |
| | | /********************************************************************************************************/ |
| | | /********************************************************************************************************/ |
| | | /********************************************************************************************************/ |
| | | static uint16_t delaytime = 771; |
| | | extern uint16_t wg_report_freq,wg_report_id; |
| | | extern uint32_t wg_lost_count; |
| | | extern uint8_t shengji_flag; |
| | | extern uint8_t lora_jianting_flag,report_ancnum; |
| | | uint8_t imu_enable,motor_enable; |
| | | uint32_t time_flag_lorarx=0; |
| | | uint32_t lora_huanxing_count=0; |
| | | uint16_t Lora_wangguanid=0; |
| | | wg_state_enum wg_state = WG_Lost; |
| | | uint16_t wangguan_up_id; |
| | | uint8_t LoraUp_flag; |
| | | uint8_t imu_enable,motor_enable; |
| | | extern uint8_t shengji_flag; |
| | | uint16_t rec_wenjian_daxiao; |
| | | uint16_t recnum[3]; |
| | | uint16_t recv_flag=0; |
| | |
| | | uint16_t CRC16=0; |
| | | uint16_t DEST_ID=0; |
| | | uint16_t rec_value,rec_delaytime,rx_count,datalen_offset; |
| | | |
| | | // |
| | | uint16_t Loratx_flag=0; |
| | | uint16_t Lorarx_flag=0; |
| | | uint16_t Lorarx_time_out_flag=0; |
| | | uint8_t tx_buf[5]={0,1,0,1,1}; |
| | | uint32_t sleep_time_count=0; |
| | | uint32_t uwb_ceju_count=0; |
| | | |
| | | //ceshi |
| | | //uint8_t no_rx_flag=0; |
| | | //xtal_38m4_off_time(sleep_time_count); |
| | | /********************************************************************************************************/ |
| | | static void Lora_irq_handler(enum IO_PIN_T pin) |
| | | { |
| | | |
| | | uint16_t checksum1; |
| | | rf_irq_process(); |
| | | //这里根据SDK的那个逻辑 用你的接口看看 |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | no_rx_flag=0; |
| | | tx_flag=rf_get_transmit_flag(); |
| | | recv_flag=rf_get_recv_flag(); |
| | | if(recv_flag == RADIO_FLAG_RXDONE) |
| | |
| | | memcpy(RX_Buffer,RxDoneParams.Payload,RxDoneParams.Size); |
| | | BufferSize=RxDoneParams.Size; |
| | | lora_huanxing_count++; |
| | | if(RX_Buffer[0]==0x04&&RX_Buffer[1]=='I'&&RX_Buffer[2]=='N'&&RX_Buffer[3]=='G') |
| | | { |
| | | |
| | | time_flag_lorarx=phy_timer_count_get(); |
| | | if(RX_Buffer[MSG_TYPE_IDX]==LORA_MSGTYPE_RANGEPOLL) |
| | | { |
| | | |
| | | // time_flag_lorarx=phy_timer_count_get(); |
| | | uwb_open(); |
| | | //gpio_pin_clr(IO_PIN_5);//测试 |
| | | UwbRange(); |
| | | //rf_enter_continous_rx(); //重新进入接收模式 |
| | | //LORA_REV_uwb_up=1; |
| | | } |
| | | |
| | | uwb_ceju_count++; |
| | | } |
| | | // if(RX_Buffer[0]==0x04,RX_Buffer[1]=='O',RX_Buffer[2]=='N',RX_Buffer[3]=='G') |
| | | // { |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | //// time_flag_lorarx=phy_timer_count_get(); |
| | | // uwb_open(); |
| | | // gpio_pin_clr(IO_PIN_5); |
| | | // UwbRange(); |
| | | // |
| | | // uwb_ceju_count++; |
| | | // //rf_enter_continous_rx(); //重新进入接收模式 |
| | | // //LORA_REV_uwb_up=1; |
| | | // } |
| | | if(RX_Buffer[MSG_TYPE_IDX]==LORA_MSGTYPE_WGRESPTAG) |
| | | { |
| | | checksum1=Checksum_u16(RX_Buffer,BufferSize-2); |
| | |
| | | { |
| | | case WGRSP_RWTAG_NONE: |
| | | // current_count = HAL_LPTIM_ReadCounter(&hlptim1); |
| | | // wg_report_freq = RX_Buffer[POLL_FREQ_IDX]+400; |
| | | // memcpy(&rec_delaytime,&RX_Buffer[NEXTPOLL_TIME_IDX],2); |
| | | // if(report_ancnum<2) |
| | | // { |
| | | // datalen_offset = report_ancnum*85; |
| | | // }else{ |
| | | // datalen_offset = (report_ancnum-1)*46+85; |
| | | // } |
| | | // rec_secdelay = RX_Buffer[PWTAG_SECDELAY_IDX]; |
| | | // if(BufferSize!=13||rec_secdelay>20) |
| | | // { |
| | | // rec_secdelay = 0; |
| | | // } |
| | | // |
| | | // target_count = current_count + rec_delaytime*3.2768 - delaytime-datalen_offset; |
| | | // while(target_count>=32768) |
| | | // target_count-=32768; |
| | | // __HAL_LPTIM_COMPARE_SET(&hlptim1, target_count); |
| | | // sleep_time_count=xtal_38m4_off_time(); |
| | | wg_report_freq = RX_Buffer[POLL_FREQ_IDX]+400; |
| | | memcpy(&rec_delaytime,&RX_Buffer[NEXTPOLL_TIME_IDX],2); |
| | | if(report_ancnum<2) |
| | | { |
| | | datalen_offset = report_ancnum*85; |
| | | }else{ |
| | | datalen_offset = (report_ancnum-1)*46+85; |
| | | } |
| | | rec_secdelay = RX_Buffer[PWTAG_SECDELAY_IDX]; |
| | | if(BufferSize!=13||rec_secdelay>20) |
| | | { |
| | | rec_secdelay = 0; |
| | | } |
| | | |
| | | sleep_time_count = rec_delaytime*3.2768 - delaytime-datalen_offset; |
| | | while(sleep_time_count>=32768) |
| | | sleep_time_count-=32768; |
| | | sleep_timer_start(sleep_time_count); |
| | | //sleep_timer_start(sleep_time_count);sleep_timer_start(__MS_TO_32K_CNT(1000));//测试 |
| | | // #define __MS_TO_32K_CNT(ms) ((uint32_t)((float)(ms)*32768.0f / 1000.0f)) |
| | | // __HAL_LPTIM_COMPARE_SET(&hlptim1, target_count); |
| | | // rx_count = HAL_LPTIM_ReadCounter(&hlptim1); |
| | | // printf("tx %d,rx %d,delay %d",current_count>>5,rx_count>>5,rec_delaytime); |
| | | break; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if(!no_rx_flag) |
| | | { |
| | | if(lora_jianting_flag) |
| | | { |
| | | uint32_t para; |
| | | // SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); |
| | | rf_set_mode(RF_MODE_STB3); |
| | | para=(UWB_CHANNEL_FRQ+group_id)*1000000; |
| | | rf_set_freq(para); |
| | | rf_set_sf(UWB_CHANNEL_SF); |
| | | rf_enter_continous_rx(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | if(tx_flag == RADIO_FLAG_TXDONE) |
| | | { |
| | | //rf_set_mode(RF_MODE_STB3); |
| | | rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | Loratx_flag++; |
| | | |
| | | // #ifdef DEBUG_BOXING |
| | | // //gpio_pin_clr(IO_PIN_5);//测试 |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | // #endif |
| | | rf_enter_single_timeout_rx(100); |
| | | // rf_enter_single_rx(); |
| | | // rf_enter_continous_rx(); |
| | | |
| | | Loratx_flag++; |
| | | rf_enter_single_timeout_rx(100); |
| | | } |
| | | if((recv_flag == RADIO_FLAG_RXTIMEOUT)) |
| | | { |
| | | // #ifdef DEBUG_BOXING |
| | | // gpio_pin_clr(IO_PIN_5);//测试 |
| | | // // gpio_pin_set(IO_PIN_5);//测试 |
| | | // #endif |
| | | |
| | | //这个超时接收是会自动重启的,所以必须将芯片状态置成STB3这样就退出了连续接收状态 |
| | | rf_set_mode(RF_MODE_STB3); |
| | | //这个超时接收是会自动重启的,所以必须将芯片状态置成STB3这样就退出了连续接收状态 |
| | | |
| | | Lorarx_time_out_flag++; |
| | | rf_set_recv_flag(RADIO_FLAG_IDLE); |
| | | |
| | | rf_set_freq(UWB_CHANNEL_FRQ+group_id*10000000); |
| | | rf_set_sf(UWB_CHANNEL_SF); |
| | | if(lora_jianting_flag) |
| | | { |
| | | uint32_t para; |
| | | // SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); |
| | | rf_set_mode(RF_MODE_STB3); |
| | | para=(UWB_CHANNEL_FRQ+group_id)*1000000; |
| | | rf_set_freq(para); |
| | | rf_set_sf(UWB_CHANNEL_SF); |
| | | rf_enter_continous_rx(); |
| | | } |
| | | // rf_clr_irq(REG_IRQ_RX_TIMEOUT); |
| | | // rf_enter_single_timeout_rx(100); |
| | | } |
| | | if((recv_flag == RADIO_FLAG_RXERR)) |
| | | { |
| | | rf_set_recv_flag(RADIO_FLAG_IDLE); |
| | | if(lora_jianting_flag) |
| | | { |
| | | uint32_t para; |
| | | // SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); |
| | | rf_set_mode(RF_MODE_STB3); |
| | | para=(UWB_CHANNEL_FRQ+group_id)*1000000; |
| | | rf_set_freq(para); |
| | | rf_set_sf(UWB_CHANNEL_SF); |
| | | rf_enter_continous_rx(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | // io_pin_mux_set(_4G_USART_RX_Pin,IO_FUNC0);//把原先io 变为普通GPIO |
| | | gpio_pin_set_dir(LORA_DIO , GPIO_DIR_IN, 0); |
| | | io_pull_set(LORA_DIO, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | io_pull_set(LORA_DIO, IO_HIGH_Z, IO_PULL_UP_LEVEL4); |
| | | gpio_enable_irq(LORA_DIO, GPIO_IRQ_TYPE_RISING_EDGE, irq_handler); |
| | | } |
| | | |
| | | extern uint8_t pca9555writedata_input[10];//暂存输入寄存器所有配置的数组 |
| | | static void pca_handler(enum IO_PIN_T pin) |
| | | { |
| | | PCA9555_readdata(PCA9555_DEVICE_ADDR,pca9555writedata_input);//读输入寄存器的值 |
| | | check_input_change(); |
| | | } |
| | | uint8_t io14_state; |
| | | uint16_t lora_freq=0; |
| | | uint16_t lora_up_count=0; |
| | |
| | | int main(void) |
| | | { |
| | | board_clock_run(); |
| | | // boot_deinit(); |
| | | // board_pins_config(); |
| | | // boot_deinit(); |
| | | board_debug_console_open(TRACE_PORT_UART1); |
| | | // Reset reason |
| | | reset_cause_get(); |
| | | reset_cause_clear(); |
| | | |
| | | // Load calibration parameters from NVM |
| | | // uint32_t internal_flash = (REG_READ(0x40000018) >> 17) & 0x1; |
| | | // uint32_t external_flash = (REG_READ(0x40010030) >> 28) & 0x3; |
| | | // if (internal_flash || external_flash == 1) |
| | | // { |
| | | // WsfNvmInit(); |
| | | // board_calibration_params_load(); |
| | | // flash_close(FLASH_ID0); |
| | | // } |
| | | // else |
| | | // { |
| | | // board_calibration_params_default(); |
| | | // } |
| | | |
| | | reset_cause_clear(); |
| | | // Chip calibration |
| | | calib_chip(); |
| | | |
| | | // Disable watchdog timer |
| | | wdt_close(WDT_ID0); |
| | | // LOG_INFO(TRACE_MODULE_APP, "UWB simple example\r\n"); |
| | | |
| | | // open system timer |
| | | //sys_timer_open(); |
| | | |
| | | // // TODO 4G |
| | | // Uart_Register(UART_ID_4G, UART_ID0); |
| | | // Internet_Init(); |
| | | // TCPClient_Init(); |
| | | |
| | | gpio_open(); |
| | | |
| | | // struct TIMER_CFG_T timer_cfg = { |
| | | // .extin_type = TIMER_EXTIN_NONE, |
| | | // .load = 0x1000000, |
| | | // .int_en = true, |
| | | // .callback = timer_callback, |
| | | // }; |
| | | |
| | | // timer_open(TIMER_ID0, &timer_cfg); |
| | | spi_gpio_init(); |
| | | Board_gpio_init(); |
| | | //board_led_init(); |
| | | |
| | | spi_init(); |
| | | //PCA9555_init(); |
| | | // gpio_pin_clr(LORA_CS); |
| | | // gpio_pin_clr(LORA_MOSI); |
| | | // gpio_pin_clr(LORA_MISO); |
| | | // gpio_pin_clr(LORA_CLK); |
| | | // gpio_pin_set(LORA_CLK); |
| | | // gpio_pin_set(LORA_DIO); |
| | | |
| | | Board_LORA_NVIC_Init(Lora_irq_handler); |
| | | Lora_init(); |
| | | //lora_freq=DEFAULT_up_FREQ+g_com_map[GROUP_ID]; |
| | | // rf_set_default_para(DEFAULT_up_FREQ+g_com_map[GROUP_ID],DEFAULT_up_SF); |
| | | Lora_init(); |
| | | rf_set_default_para(DEFAULT_WG_SET_FREQ,DEFAULT_WG_SET_SF); |
| | | //rf_enter_continous_rx(); |
| | | // rf_enter_continous_rx(); |
| | | // if((rf_single_tx_data(TXBuffer,10,0))!= OK) |
| | | // { |
| | | // |
| | | // } |
| | | //rf_set_default_para(DEFAULT_WG_SET_FREQ,DEFAULT_WG_SET_SF); |
| | | // rf_set_default_para(DEFAULT_up_FREQ,DEFAULT_up_SF); |
| | | // |
| | | //rf_enter_continous_tx(); |
| | | // 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 ++; |
| | | // } |
| | | |
| | | |
| | | // while (rf_get_transmit_flag() == RADIO_FLAG_IDLE) ; |
| | | // |
| | | // rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | |
| | | // adc_open(&usr_adc_cfg); |
| | | // IIC2_Init(); |
| | | // IIC2_Init(); |
| | | // Accelerometer_Init(); |
| | | // IO_control_init(); |
| | | // io_pin_mux_set(SCL_PIN, IO_FUNC0);//测试测距波形 |
| | | // gpio_pin_set_dir(SCL_PIN , GPIO_DIR_OUT, 0); |
| | | // io_pull_set(SCL_PIN , IO_PULL_DOWN, IO_PULL_UP_LEVEL4); |
| | | // gps_air780_power_change(0,1);//开启gps,4G |
| | | ////加速度计初始化必须在IO_control_init之前因为复用SDA引脚 |
| | | //LIS3DH_Data_Init(); |
| | | // PCA9555_init(); |
| | | |
| | | // adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 |
| | | Program_Init(); |
| | | |
| | | //#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 |
| | | |
| | | // rf_single_tx_data(TXBuffer,10,2); |
| | | // uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); |
| | |
| | | // 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 |
| | | //rf_enter_single_timeout_rx(1000); |
| | | // board_acceleration_detection_init(move_handler); |
| | | //rf_enter_single_timeout_rx(900); |
| | | //rf_enter_single_timeout_rx(500); |
| | | //rf_enter_single_rx(); |
| | | // sleep_time_count=xtal_38m4_off_time(); |
| | | |
| | | |
| | | |
| | | // pca_input_detection_init(pca_handler); |
| | | //#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 |
| | | |
| | | Uwbinit(); |
| | | while (1) |
| | | { |
| | | // rf_irq_process(); |
| | | |
| | | //rf_enter_single_rx(); |
| | | |
| | | // RED_LED_OFF; |
| | | // BT_LED_OFF; |
| | | // // gpio_pin_clr(IO_PIN_5); |
| | | Lora_Tx_Poll(); |
| | | // if((rf_single_tx_data(TXBuffer,10,0))!= OK) |
| | | // { |
| | | // |
| | | // } |
| | | // #ifdef DEBUG_BOXING |
| | | // gpio_pin_clr(IO_PIN_5);//测试 |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | |
| | | // test_Delay_us(1000); |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | // test_Delay_us(100000); |
| | | // test_Delay_us(100000); |
| | | // test_Delay_us(100000); |
| | | // gpio_pin_clr(IO_PIN_5);//测试 |
| | | // test_Delay_us(2000); |
| | | // gpio_pin_set(IO_PIN_5);//测试 |
| | | // test_Delay_us(1000); |
| | | // gpio_pin_clr(IO_PIN_5);//测试 |
| | | // if(LORA_REV_uwb_up) |
| | | // { |
| | | // LORA_REV_uwb_up=0; |
| | | // UwbRange(); |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // UwbRange(); |
| | | // rf_irq_process(); |
| | | // if(rf_get_transmit_flag() == RADIO_FLAG_TXDONE) |
| | | // { |
| | | // rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | // rf_delay_ms(1000); |
| | | // if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != 0) |
| | | // { |
| | | // error_cnt++; |
| | | // } |
| | | // else |
| | | // { |
| | | // successful_cnt ++; |
| | | //// DDL_Printf("Tx cnt %d\r\n", cnt ); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | //// |
| | | // |
| | | //// io14_state=gpio_pin_get_val(LORA_DIO); |
| | | // rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | // rf_delay_ms(1000); |
| | | // rf_enter_continous_tx(); |
| | | //// rf_set_transmit_flag(RADIO_FLAG_TXDONE); |
| | | // if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != OK) |
| | | // { |
| | | //// rf_enter_continous_rx(); |
| | | // } |
| | | // else |
| | | // { |
| | | // successful_cnt ++; |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | // while (rf_get_transmit_flag() == RADIO_FLAG_IDLE) ; |
| | | // |
| | | // rf_set_transmit_flag(RADIO_FLAG_IDLE); |
| | | |
| | | |
| | | // if(flag_TCP_reconnectting||IfTCPConnected()) |
| | | // { |
| | | // |