| | |
| | | uint32_t ledontime; |
| | | void IMUTask(void) |
| | | { |
| | | if(nomove_count>g_com_map[NOMOVESLEEP_TIME]&&g_com_map[IMU_ENABLE]==1) |
| | | if(nomove_count>g_com_map[NOMOVESLEEP_TIME]&&g_com_map[IMU_ENABLE]==2) |
| | | {//power_wakeup_enable((enum POWER_WAKEUP_SOURCE_T)ACCLERATE_DETECT_Pin, POWER_WAKEUP_LEVEL_HIGH); |
| | | mcu_deep_sleep(); |
| | | } |
| | |
| | | uint8_t flag_sleeptimer,flag_secondtask,secondtask_count,log_4g_enable_flag; |
| | | uint8_t uwb_enable_flag=0; |
| | | uint8_t input5v_time; |
| | | uint8_t heart_upload_time=0; |
| | | extern uint8_t taglist_num; |
| | | extern uint8_t ceshidata[500]; |
| | | //extern uint8_t ceshidata[500]; |
| | | extern uint8_t fixed_solution_count_minute; |
| | | extern uint8_t ceshichangdu; |
| | | uint8_t gps_ntripsend; |
| | | extern uint8_t in_the_room_flag; |
| | | extern uint8_t lounei_flag; |
| | | extern uint16_t g_spsum_GSV,g_snum_GSV; |
| | | extern uint16_t g_spsum_GSV_sum; |
| | | extern uint16_t g_snum_GSV_sum; |
| | | extern uint8_t ceju_leave_flag; |
| | | static void sleep_timer_callback(void *dev, uint32_t time) |
| | | { |
| | | if(secondtask_count++%2==0) |
| | |
| | | { |
| | | CloseUWB(); |
| | | Uwb_init(); |
| | | OpenUWB(); |
| | | // OpenUWB(); |
| | | } |
| | | // in_the_room_flag=1; |
| | | if(ceju_leave_flag==1) |
| | | { |
| | | Receive_g_spsum_Data(g_spsum_GSV); |
| | | Receive_g_snum_Data(g_snum_GSV); |
| | | |
| | | if((g_spsum_GSV_sum<200&&g_snum_GSV_sum<3)||(fixed_solution_count_minute<30)) |
| | | // if((g_spsum_GSV_sum<200&&g_snum_GSV_sum<3)&&(ceju_leave_flag==1)) |
| | | { |
| | | lounei_flag=1; |
| | | Switch_low_power_mode(lounei_flag); |
| | | } |
| | | if((200<g_spsum_GSV_sum&&2<g_snum_GSV_sum)&&(fixed_solution_count_minute>30)) |
| | | // if((200<g_spsum_GSV_sum&&3<g_snum_GSV_sum)&&(ceju_leave_flag==1)) |
| | | { |
| | | lounei_flag=0; |
| | | Switch_low_power_mode(lounei_flag); |
| | | } |
| | | if(heart_upload_time==0||heart_upload_time==60) |
| | | { |
| | | TCPHeartBeatUpload(); |
| | | heart_upload_time=0; |
| | | if(lounei_flag==1) |
| | | { |
| | | // PCA9555_Set_One_Value_Output(LED_POWER,0); |
| | | PCA9555_Set_One_Value_Output(GPS_POWER,0); |
| | | } |
| | | if(heart_upload_time==60) |
| | | { |
| | | ceju_leave_flag=0; |
| | | fixed_solution_count_minute=0; |
| | | } |
| | | } |
| | | heart_upload_time++; |
| | | } |
| | | }else{ |
| | | flag_secondtask = 0; |
| | | } |
| | |
| | | Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为 |
| | | parameter_init_anchor();//g_com_map表初始化角色默认为基站 |
| | | dev_id=g_com_map[DEV_ID];//这里不太对 |
| | | // g_com_map[GROUP_ID]=9; |
| | | g_com_map[GROUP_ID]=9; |
| | | group_id=g_com_map[GROUP_ID];//组ID |
| | | memcpy(&disoffset,&g_com_map[DIST_OFFSET],2); |
| | | warning_distance=g_com_map[ALARM_DISTANCE1]; |
| | |
| | | // g_com_map[IP_1]=198; |
| | | // g_com_map[IP_2]=60; |
| | | // g_com_map[IP_3]=6; |
| | | // g_com_map[PORT]=6666; |
| | | // g_com_map[PORT]=1102; |
| | | |
| | | g_com_map[IP_0]=117; |
| | | g_com_map[IP_1]=72; |
| | | g_com_map[IP_2]=111; |
| | | g_com_map[IP_3]=237; |
| | | g_com_map[PORT]=7000; |
| | | |
| | | g_com_map[TCP_IP_0]=111; |
| | | g_com_map[TCP_IP_1]=198; |
| | | g_com_map[TCP_IP_2]=60; |
| | | g_com_map[TCP_IP_3]=6; |
| | | g_com_map[TCP_PORT]=1234; |
| | | // g_com_map[IP_0]=117; |
| | | // g_com_map[IP_1]=72; |
| | | // g_com_map[IP_2]=111; |
| | | // g_com_map[IP_3]=237; |
| | | // g_com_map[PORT]=7000; |
| | | // |
| | | // g_com_map[TCP_IP_0]=111; |
| | | // g_com_map[TCP_IP_1]=198; |
| | | // g_com_map[TCP_IP_2]=60; |
| | | // g_com_map[TCP_IP_3]=6; |
| | | // g_com_map[TCP_PORT]=1234; |
| | | /* |
| | | RTCMMODE_NONE, |
| | | RTCMMODE_TCP, |
| | | RTCMMODE_NTRIP, |
| | | */ |
| | | g_com_map[RTCMMODE_INDEX] = RTCMMODE_TCP; |
| | | // g_com_map[RTCMMODE_INDEX] = RTCMMODE_NTRIP; |
| | | |
| | | |
| | | snprintf((char *)&g_com_map[NTRIP_HOST_INDEX], 32, "140.143.212.42"); |
| | | g_com_map[NTRIP_PORT_INDEX] = HIDO_UtilStrToInt("8005"); |
| | | // snprintf((char *)&g_com_map[NTRIP_PORT_INDEX], 32, "8005"); |
| | | snprintf((char *)&g_com_map[NTRIP_USERNANME_INDEX], 32, "test005"); |
| | | snprintf((char *)&g_com_map[NTRIP_PASSWORD_INDEX], 32, "Hxzk0228"); |
| | | snprintf((char *)&g_com_map[NTRIP_SOURCENAME_INDEX], 32, "RTCM32_GNSS2"); |
| | | // snprintf((char *)&g_com_map[NTRIP_HOST_INDEX], 32, "140.143.212.42"); |
| | | // g_com_map[NTRIP_PORT_INDEX] = HIDO_UtilStrToInt("8005"); |
| | | //// snprintf((char *)&g_com_map[NTRIP_PORT_INDEX], 32, "8005"); |
| | | // snprintf((char *)&g_com_map[NTRIP_USERNANME_INDEX], 32, "test005"); |
| | | // snprintf((char *)&g_com_map[NTRIP_PASSWORD_INDEX], 32, "Hxzk0228"); |
| | | // snprintf((char *)&g_com_map[NTRIP_SOURCENAME_INDEX], 32, "RTCM32_GNSS2"); |
| | | |
| | | |
| | | if(g_com_map[BIND_DEV_ID]==0) |
| | |
| | | |
| | | |
| | | LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id); |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本:4G-GPS定位手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本: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",g_com_map[IP_0],g_com_map[IP_1],g_com_map[IP_2],g_com_map[IP_3],g_com_map[PORT]); |
| | | if(g_com_map[RTCMMODE_INDEX] == RTCMMODE_TCP) |
| | | { |
| | |
| | | { |
| | | LOG_INFO(TRACE_MODULE_APP,"单点定位模式模式. \r\n"); |
| | | } |
| | | delay_ms(500); |
| | | } |
| | | uint32_t adctick = 0; |
| | | uint8_t only_one_flag; |
| | | uint16_t chongman_time; |
| | | uint8_t bat_percent_old=100; |
| | | uint8_t input5vflag; |
| | | uint8_t kai_4g_flag; |
| | | void IdleTask(void) |
| | | { |
| | | if(read_5v_input_pca()) |
| | |
| | | } |
| | | if(DBG_GetMode() == DBG_MODE_SHELL) |
| | | { |
| | | if(kai_4g_flag==0) |
| | | { |
| | | kai_4g_flag=1; |
| | | // PCA9555_Set_One_Value_Output(AIR780E_ENBALE,1); |
| | | Shell_Init(); |
| | | } |
| | | if(g_com_map[RTCMMODE_INDEX] == RTCMMODE_TCP) |
| | | {TCPClient_Poll_1();} |
| | | HIDO_InputPoll(); |
| | | //HIDO_InputPoll(); |
| | | DBG_Poll(); |
| | | Internet_Poll(); |
| | | HIDO_TimerPoll(); |
| | | HIDO_ATLitePoll(); |
| | |
| | | if(DBG_GetMode() == DBG_MODE_SHELL) |
| | | { |
| | | Set4LEDColor(uwbled,rtkled,led4g,powerled); |
| | | if(g_com_map[CNT_RESTART]==1) |
| | | { |
| | | g_com_map[CNT_RESTART]=0; |
| | | save_com_map_to_flash(); |
| | | NVIC_SystemReset(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | state5V_prase_flag=state5v; |
| | | gps_prase_flag=1;//恢复gps解析 |
| | | uart1_change_from_debug_to_gps();//测试 |
| | | PCA9555_Set_One_Value_Output(MCU_A,0);//输出低电平切换为GPS |
| | | PCA9555_Set_One_Value_Output(MCU_A,1);//输出低电平切换为GPS |
| | | } |
| | | } |
| | | UART_CheckReceive(); |
| | |
| | | uart_close(UART_ID1);//解绑原来串口1 |
| | | uart_close(UART_ID0);//解绑原来串口0 |
| | | } |
| | | |
| | | uint8_t flag_4guart_needinit=0; |
| | | uint8_t index1,index2,index3; |
| | | int16_t Voltage_input; |
| | |
| | | board_clock_run(); |
| | | boot_deinit(); |
| | | board_pins_config(); |
| | | board_debug_console_open_baud(TRACE_PORT_UART1,BAUD_115200); |
| | | board_debug_console_open_baud(TRACE_PORT_UART1,BAUD_115200); |
| | | // Reset reason |
| | | reset_cause_get(); |
| | | reset_cause_clear(); |
| | |
| | | calib_chip(); |
| | | wdt_close(WDT_ID0); |
| | | Uart_Register(UART_ID_4G, UART_ID0); |
| | | // Uart_Register(UART_ID_DBG, UART_ID1); |
| | | Uart_Register(UART_ID_DBG_GPS, UART_ID1); |
| | | DBG_Init(); |
| | | |
| | | Program_Init(); |
| | | Internet_Init(); |
| | | TCPClient_Init(); |
| | |
| | | adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 |
| | | pca_input_detection_init(pca_handler);//pca检测输入 |
| | | Uwb_init(); |
| | | OpenUWB(); |
| | | DBG_Init(); |
| | | // OpenUWB(); |
| | | // DBG_SetMode(DBG_MODE_SHELL); |
| | | // Shell_Init(); |
| | | |
| | |
| | | PCA9555_Set_One_Value_Output(MCU_A,0);//输出低电平切换为GPS |
| | | while (1) |
| | | { |
| | | uwb_app_poll(); |
| | | uwb_app_poll(); |
| | | Internet_Poll(); |
| | | HIDO_TimerPoll(); |
| | | HIDO_ATLitePoll(); |
| | | TCPClient_Poll(); |
| | | if(g_com_map[RTCMMODE_INDEX] == RTCMMODE_TCP) |
| | | {TCPClient_Poll_1();} |
| | | // if(g_com_map[RTCMMODE_INDEX] == RTCMMODE_NTRIP&&gps_ntripsend==2) |
| | | // { |
| | | // gps_ntripsend=0; |
| | | // NTRIPApp_ReportGGA(YUANGPS_ParseGGA_data, YUANGPS_ParseGGA_changdu); |
| | | // memset(YUANGPS_ParseGGA_data,0,YUANGPS_ParseGGA_changdu); |
| | | // YUANGPS_ParseGGA_changdu=0; |
| | | // } |
| | | if(flag_secondtask) |
| | | { |
| | | flag_secondtask = 0; |