| | |
| | | #include "HIDO_Timer.h" |
| | | #include "TCPClient.h" |
| | | #include "mk_spi.h" |
| | | #include "pan_port.h" |
| | | //#include "pan_port.h" |
| | | #include "mk_timer.h" |
| | | //#include "pan_param.h" |
| | | //#include "pan_rf.h" |
| | | #include "lora_3029.h" |
| | | #include "pan_rf.h" |
| | | #include "lora_1268.h" |
| | | //#include "pan_rf.h" |
| | | #include "PCA9555.h" |
| | | #include "mk_phy.h" |
| | | #include "HIDO_Timer.h" |
| | | #define DEBUG_MODE |
| | | extern int simple_main(void); |
| | | extern int temp_main(void); |
| | |
| | | { |
| | | 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); |
| | | } |
| | | uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart0_receive_callback); |
| | | } |
| | | |
| | | |
| | | static void voltage_input_handler(enum IO_PIN_T pin) |
| | | { |
| | | |
| | |
| | | port = g_com_map[TCP_PORT]; |
| | | g_com_map[VERSION] = (1<<8)|11; |
| | | LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id); |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本:UWB-4G手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本:BGK-mk+蓝牙V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | LOG_INFO(TRACE_MODULE_APP,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port); |
| | | } |
| | | |
| | | |
| | | |
| | | void IdleTask(void) |
| | | { |
| | | if(gpio_pin_get_val(INPUT_5V_Pin)) |
| | | { |
| | | |
| | | if(state5v==0) |
| | | { |
| | | state5v=1; |
| | | state5V_prase_flag=state5v; |
| | | gps_prase_flag=0;//解除gps解析 |
| | | uart1_change_from_gps_to_debug();//测试 |
| | | // uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);//开启dma |
| | | //UartInit(); |
| | | } |
| | | |
| | | //UART_CheckSend(); |
| | | } else { |
| | | if(state5v==1) |
| | | { |
| | | g_com_map[MODBUS_MODE] = 0; |
| | | state5v=0; |
| | | state5V_prase_flag=state5v; |
| | | gps_prase_flag=1;//恢复gps解析 |
| | | uart1_change_from_debug_to_gps();//测试 |
| | | // uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);//开启dma |
| | | //UartDeinit(); |
| | | } |
| | | } |
| | | UART_CheckReceive(); |
| | | { |
| | | UART0_CheckReceive(); |
| | | } |
| | | |
| | | int bind_check(void) |
| | | { |
| | | if(g_com_map[BIND_DEV_ID]!=0x00) |
| | |
| | | #define TEST_SPI_INTERUPT_MODE 1 |
| | | #define TEST_SPI_DMA_MODE 2 |
| | | #define TEST_SPI_MODE TEST_SPI_POLL_MODE |
| | | //#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_CLK, IO_FUNC2); |
| | | 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); |
| | | |
| | | //串口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() |
| | | { |
| | |
| | | uint8_t flag_4guart_needinit=0; |
| | | #define TX_LEN 10 |
| | | #define RX_LEN 200 |
| | | uint8_t tx_test_buf[TX_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| | | |
| | | extern uint8_t RX_Buffer[RX_LEN]; |
| | | extern uint16_t BufferSize; |
| | | static uint16_t source_id; |
| | |
| | | /********************************************************************************************************/ |
| | | /********************************************************************************************************/ |
| | | /********************************************************************************************************/ |
| | | 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; |
| | | //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; |
| | | //uint16_t rec_wenjian_daxiao; |
| | | //uint16_t recnum[3]; |
| | | //uint16_t recv_flag=0; |
| | | //uint16_t tx_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; |
| | | wg_state_enum wg_state = WG_Lost; |
| | | uint16_t wangguan_up_id; |
| | | uint8_t LoraUp_flag; |
| | | uint16_t rec_wenjian_daxiao; |
| | | uint16_t recnum[3]; |
| | | uint16_t recv_flag=0; |
| | | uint16_t tx_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(); |
| | | // 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) |
| | | { |
| | | rf_set_recv_flag(RADIO_FLAG_IDLE); |
| | | |
| | | memcpy(RX_Buffer,RxDoneParams.Payload,RxDoneParams.Size); |
| | | BufferSize=RxDoneParams.Size; |
| | | lora_huanxing_count++; |
| | | 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(); |
| | | |
| | | 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); |
| | | |
| | | memcpy(&DEST_ID,&RX_Buffer[DEST_ID_IDX],2); |
| | | memcpy(&CRC16,&RX_Buffer[BufferSize-2],2); |
| | | if(!memcmp(&checksum1,&RX_Buffer[BufferSize-2],2)) |
| | | if(!memcmp(&dev_id,&RX_Buffer[DEST_ID_IDX],2)) |
| | | { |
| | | memcpy(&source_id,&RX_Buffer[SOURCE_ID_IDX],2); |
| | | if(wg_state==WG_Lost) |
| | | { |
| | | wg_state = WG_Connected; |
| | | wg_report_id = source_id; |
| | | } |
| | | if(!memcmp(&wg_report_id,&RX_Buffer[SOURCE_ID_IDX],2)) |
| | | { |
| | | wg_lost_count = 0; |
| | | switch(RX_Buffer[PWTAG_RW_FLAG_IDX]) |
| | | { |
| | | case WGRSP_RWTAG_NONE: |
| | | // current_count = HAL_LPTIM_ReadCounter(&hlptim1); |
| | | // 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; |
| | | case WGRSP_RWTAG_READ: |
| | | no_rx_flag = 1; |
| | | LoraSendComMap(WGRSP_RWTAG_READ); |
| | | break; |
| | | case WGRSP_RWTAG_WRITE: |
| | | rec_index = RX_Buffer[PWTAG_WRITE_IDX_IDX]; |
| | | switch(rec_index) |
| | | { |
| | | case 0xdd: //语音下发 |
| | | break; |
| | | // case 0x20: //蜂鸣 |
| | | // memcpy(&rec_value,&RX_Buffer[PWTAG_WRITE_VALUE_IDX],2); |
| | | // motor_keeptime = rec_value; |
| | | // break; |
| | | default : |
| | | memcpy(&rec_value,&RX_Buffer[PWTAG_WRITE_VALUE_IDX],2); |
| | | g_com_map[rec_index/2] = rec_value; |
| | | save_com_map_to_flash(); |
| | | LoraRspWriteCommap(SUBMSG_WRITE_ANCPARA); |
| | | //flag_writepara_needreset = 1; |
| | | no_rx_flag = 1; |
| | | } |
| | | |
| | | break; |
| | | case WGRSP_RWTAG_UPDATE: |
| | | rec_index = RX_Buffer[PWTAG_WRITE_IDX_IDX]; |
| | | switch(rec_index) |
| | | { |
| | | case 0xaa: //升级下发 |
| | | memcpy(&rec_wenjian_daxiao,&RX_Buffer[WRITEPARA_VALUE_IDX],2);//文件大小 |
| | | if(rec_wenjian_daxiao>0XAC00||rec_wenjian_daxiao==0) |
| | | {}//文件过大,超出范围 |
| | | else |
| | | { |
| | | memcpy(&wangguan_up_id,&RX_Buffer[SOURCE_ID_IDX],2);//网关ID 占用2个字节 |
| | | shengji_flag=1; |
| | | LoraUp_flag=1; |
| | | imu_enable=0; |
| | | } |
| | | // LoraUp_Poll(); |
| | | break; |
| | | } |
| | | 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++; |
| | | rf_enter_single_timeout_rx(100); |
| | | } |
| | | if((recv_flag == RADIO_FLAG_RXTIMEOUT)) |
| | | { |
| | | //这个超时接收是会自动重启的,所以必须将芯片状态置成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(); |
| | | } |
| | | } |
| | | |
| | | RadioIrqProcess(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // 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_LEVEL4); |
| | | io_pull_set(LORA_DIO, IO_HIGH_Z, IO_PULL_UP_NONE); |
| | | gpio_enable_irq(LORA_DIO, GPIO_IRQ_TYPE_RISING_EDGE, irq_handler); |
| | | } |
| | | extern uint8_t pca9555writedata_input[10];//暂存输入寄存器所有配置的数组 |
| | |
| | | int main(void) |
| | | { |
| | | board_clock_run(); |
| | | // boot_deinit(); |
| | | board_debug_console_open(TRACE_PORT_UART1); |
| | | // boot_deinit(); |
| | | // board_debug_console_open(TRACE_PORT_UART1); |
| | | // Reset reason |
| | | reset_cause_get(); |
| | | reset_cause_clear(); |
| | | // Chip calibration |
| | | calib_chip(); |
| | | |
| | | // Disable watchdog timer |
| | | wdt_close(WDT_ID0); |
| | | |
| | | gpio_open(); |
| | | |
| | | Board_gpio_init(); |
| | | //board_led_init(); |
| | | spi_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(); |
| | | rf_set_default_para(DEFAULT_WG_SET_FREQ,DEFAULT_WG_SET_SF); |
| | | // IIC2_Init(); |
| | | // Accelerometer_Init(); |
| | | //LIS3DH_Data_Init(); |
| | | // PCA9555_init(); |
| | | IIC2_Init(); |
| | | Accelerometer_Init(); |
| | | PCA9555_init(); |
| | | Lora_1268_Init(); |
| | | SwitchLoraSettings(478,7,22); |
| | | Program_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); |
| | | // |
| | | //// 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));//测试 |
| | | // 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) |
| | | { |
| | | // RED_LED_OFF; |
| | | // BT_LED_OFF; |
| | | // // gpio_pin_clr(IO_PIN_5); |
| | | Lora_Tx_Poll(); |
| | | |
| | | // UwbRange(); |
| | | |
| | | // if(flag_TCP_reconnectting||IfTCPConnected()) |
| | | // { |
| | | // |
| | | // // LOG_INFO(TRACE_MODULE_APP, "处理4G任务\r\n"); |
| | | // air780_led_on(); |
| | | // if(flag_4guart_needinit) |
| | | // { |
| | | // flag_4guart_needinit = 0; |
| | | // AIR780EUartInit(); |
| | | // } |
| | | // Internet_Poll(); |
| | | // HIDO_ATLitePoll(); |
| | | // HIDO_TimerPoll(); |
| | | // TCPClient_Poll(); |
| | | // air780_led_off(); |
| | | // } |
| | | // if(flag_secondtask) |
| | | // { |
| | | // flag_secondtask = 0; |
| | | // SecondTask(); |
| | | // } |
| | | // IdleTask(); |
| | | // //3种情况后都要发包和休眠 |
| | | // //if(send_flag){ |
| | | // //message_construct(); |
| | | // //send_udp; |
| | | // //air780_success_state=0;//关闭4G成功发送灯 |
| | | // //blink_led(&air780_success_state);//成功测距闪烁4G状态灯 |
| | | // //air780_success_state=0; |
| | | // //} |
| | | //#ifndef DEBUG_MODE |
| | | ////if(flag_sleeptimer) |
| | | // if(!gpio_pin_get_val(INPUT_5V_Pin)&&((IfTCPConnected()&&Socket_IsSendQueueEmpty(0))||!flag_TCP_reconnectting&&!IfTCPConnected())) //进入休眠条件(与关系,全满足才进):1.没有5V输入 2 TCP已连接时发送队列为空||TCP无连接时不在重连状态。 |
| | | // { |
| | | // if(!flag_4guart_needinit) |
| | | // { |
| | | // LOG_INFO(TRACE_MODULE_APP, "4G RX 中断打开\r\n"); |
| | | // board_4GUsart_detection_init(_4gUsart_handler); |
| | | |
| | | // } |
| | | // flag_sleeptimer =0; |
| | | // LOG_INFO(TRACE_MODULE_APP, "进入休眠\r\n"); |
| | | // flag_4guart_needinit = 1; |
| | | |
| | | // trace_flush(); |
| | | // uint32_t lock = int_lock(); |
| | | // //LOG_INFO(TRACE_MODULE_APP, "进入低功耗"); |
| | | // power_enter_power_down_mode(0); |
| | | // int_unlock(lock); |
| | | // } |
| | | //#endif |
| | | IdleTask(); |
| | | } |
| | | } |