From d2b6098ba2aa18829e01c4a11d6c6a0619b30108 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期五, 20 六月 2025 18:10:40 +0800 Subject: [PATCH] 增加控制绑定flag,和flash的存入授权表逻辑。 --- keil/include/main/main.c | 46 +++++++++++++++------------------------------- 1 files changed, 15 insertions(+), 31 deletions(-) diff --git a/keil/include/main/main.c b/keil/include/main/main.c index d25232f..6c515de 100644 --- a/keil/include/main/main.c +++ b/keil/include/main/main.c @@ -294,6 +294,8 @@ // } } +#define BIND_COUNT_NUM 50 +uint8_t bind_flag,bind_count=BIND_COUNT_NUM; void SecondTask(void) {static uint8_t second_count; if(second_count++>60) @@ -301,6 +303,14 @@ second_count = 0; MinuteTask(); } + if(bind_flag) + { + if(bind_count--<=0) + { + bind_count=BIND_COUNT_NUM; + bind_flag=0; + } + } // //UWB状态检测 //if(!power_low_flag)//低供电下不需要检测重连 // { @@ -348,8 +358,10 @@ } //uart_change_check(gpio_state); } + static void sleep_timer_callback(void *dev, uint32_t time) { + if(secondtask_count++%2==0) { flag_secondtask = 1; @@ -380,6 +392,7 @@ extern uint16_t ip0,ip1,ip2,ip3,port; extern uint8_t gps_4g_flag; extern uint8_t gps_need_data_flag,gps_open_flag; + void Program_Init(void) { Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为 @@ -419,7 +432,7 @@ port = g_com_map[TCP_PORT]; g_com_map[VERSION] = (1<<8)|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",ip0,ip1,ip2,ip3,port); } @@ -525,32 +538,10 @@ // open system timer //sys_timer_open(); - // TODO 4G - Uart_Register(UART_ID_4G, UART_ID0); - Internet_Init(); - TCPClient_Init(); gpio_open(); LED_output_init();//配置彩色灯引脚 - IIC2_Init(); - Accelerometer_Init(); - PCA9555_init(); - - - //AIR780E_Reset(); adc_open(&usr_adc_cfg); - - if(!read_5v_input_pca()) - { - Set4LEDColor(BLUE,GREEN,WHITE,GREEN); - delay_ms(500); - Set4LEDColor(RED,WHITE,RED,WHITE); - delay_ms(500); - //Set4LEDColor(LEDOFF,LEDOFF,LEDOFF,LEDOFF); - } -// io_pin_mux_set(SCL_PIN, IO_FUNC0);//测试测距波形 -// gpio_pin_set_dir(SCL_PIN , GPIO_DIR_IN, 0); -// io_pull_set(SCL_PIN , IO_PULL_UP, IO_PULL_UP_LEVEL4); Program_Init(); //uart_open(UART_ID1, &test_uart_cfg); // uart1_change_from_gps_to_debug(); @@ -559,29 +550,22 @@ // 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(g_com_map[COM_INTERVAL]));//测试 sleep_timer_start(__MS_TO_32K_CNT(SLEEP_TIMER_NUM));//测试 - PCA9555_Set_One_Value_Output(ADC_MINIUS,0);//拉低 adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 //board_acceleration_detection_init(move_handler); - pca_input_detection_init(pca_handler);//pca检测输入 +// pca_input_detection_init(pca_handler);//pca检测输入 //board_4GUsart_detection_init(_4gUsart_handler); Uwb_init(); OpenUWB(); while (1) { uwb_app_poll(); - Air780eTask(); if(flag_secondtask) { flag_secondtask = 0; SecondTask(); } - PowerTask(); -// IMUTask(); - UserKeyTask(); IdleTask(); #ifndef DEBUG_MODE //if(flag_sleeptimer) -- Gitblit v1.9.3