| | |
| | | |
| | | charge_state_change();//充电状态判断 |
| | | |
| | | // //马达震动逻辑 |
| | | // if(g_com_map[MOTOR_ENABLE]) |
| | | // { |
| | | // if(motor_open_air_flag||moter_open_uwb_flag) |
| | | // { |
| | | // if (motor_count++%3!=0) |
| | | // { |
| | | // motor_power_state = 1; |
| | | // }else {//修改 |
| | | // motor_power_state = 0; |
| | | // } |
| | | // } else { |
| | | // motor_power_state=1; |
| | | // } |
| | | // }else{ |
| | | // motor_power_state=1; |
| | | // } |
| | | //马达震动逻辑 |
| | | if(g_com_map[MOTOR_ENABLE]) |
| | | { |
| | | if(motor_open_air_flag||moter_open_uwb_flag) |
| | | { |
| | | if (motor_count++%3!=0) |
| | | { |
| | | motor_power_state = 1; |
| | | }else {//修改 |
| | | motor_power_state = 0; |
| | | } |
| | | } else { |
| | | motor_power_state=1; |
| | | } |
| | | }else{ |
| | | motor_power_state=1; |
| | | } |
| | | |
| | | if(enbale_blink_flag) |
| | | { |
| | |
| | | ip2 = (g_com_map[TCP_IP_2]>>12&0xf)*1000+(g_com_map[TCP_IP_2]>>8&0xf)*100+(g_com_map[TCP_IP_2]>>4&0xf)*10+(g_com_map[TCP_IP_2]&0xf); |
| | | ip3 = (g_com_map[TCP_IP_3]>>12&0xf)*1000+(g_com_map[TCP_IP_3]>>8&0xf)*100+(g_com_map[TCP_IP_3]>>4&0xf)*10+(g_com_map[TCP_IP_3]&0xf); |
| | | port = g_com_map[TCP_PORT]; |
| | | g_com_map[VERSION] = (1<<8)|10; |
| | | 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,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port); |
| | |
| | | board_output_init(); |
| | | //board_led_init(); |
| | | //防止充电电流过低导致设备无法启动 |
| | | battery_monitor_open(); |
| | | Voltage_input=battery_monitor_get(); |
| | | battery_monitor_close(); |
| | | if(Voltage_input<=3270) |
| | | { |
| | | enable_system_function_flag=0;//供电不足不能启动4G和GPS |
| | | }else{ |
| | | enable_system_function_flag=1; |
| | | } |
| | | // battery_monitor_open(); |
| | | // Voltage_input=battery_monitor_get(); |
| | | // battery_monitor_close(); |
| | | // if(Voltage_input<=3270) |
| | | // { |
| | | // enable_system_function_flag=0;//供电不足不能启动4G和GPS |
| | | // }else{ |
| | | // enable_system_function_flag=1; |
| | | // } |
| | | //检测通过后改为正常adc采集模式 |
| | | adc_open(&usr_adc_cfg); |
| | | |
| | |
| | | #endif |
| | | gps_air780_power_change(0,1);//开启gps,4G |
| | | //加速度计初始化必须在IO_control_init之前因为复用SDA引脚 |
| | | tt1=gpio_pin_get_val(ADC_GND_ENABLE); |
| | | gpio_pin_clr(ADC_GND_ENABLE);//Ïȵ |
| | | adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 |
| | | Program_Init(); |
| | |
| | | index2=AIR780E_IsIPIdle(); |
| | | index3=Socket_IsSendQueueEmpty(0); |
| | | if(delaysleep_count==0) |
| | | if(!gps_power_state&&!gpio_pin_get_val(INPUT_5V_Pin)&&(IfTCPConnected()&&AIR780E_IsIPIdle()&&Socket_IsSendQueueEmpty(0))) |
| | | if(!gps_power_state&&!gpio_pin_get_val(INPUT_5V_Pin)&&((IfTCPConnected()&&AIR780E_IsIPIdle()&&Socket_IsSendQueueEmpty(0))||((!flag_TCP_reconnectting)&&!IfTCPConnected()))) |
| | | { |
| | | // test1=gpio_pin_get_val(_4G_USART_RX_Pin); |
| | | uint32_t lock; |