From 5e7b2ec568c4fd0497564e6f45a482a4e0f33b33 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期三, 23 七月 2025 11:12:51 +0800 Subject: [PATCH] 1.1,加入灯跟宏定义控制1hz 5hz --- keil/include/main/main.c | 70 +++++++++-------------------------- 1 files changed, 18 insertions(+), 52 deletions(-) diff --git a/keil/include/main/main.c b/keil/include/main/main.c index 6895540..7c5518d 100644 --- a/keil/include/main/main.c +++ b/keil/include/main/main.c @@ -420,7 +420,7 @@ 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)|0; + g_com_map[VERSION] = (1<<8)|1; 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,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port); @@ -449,7 +449,7 @@ // } // pwm_ch_enable(PWM_ID0, &usr_pwm_ch0_cfg); // delay_ms(10000); - pwm_ch_disable(PWM_ID0); + pwm_ch_disable(PWM_ID3); break; case 1: // if(current_time<MOTOR_ONTIME) @@ -477,7 +477,7 @@ // { // HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3); // } - pwm_ch_enable(PWM_ID0, &usr_pwm_ch0_cfg); + pwm_ch_enable(PWM_ID3, &usr_pwm_ch0_cfg); break; case 3: // if(hardware_type==NSH1) @@ -659,16 +659,11 @@ board_clock_run(); boot_deinit(); board_pins_config(); - board_debug_console_open_baud(TRACE_PORT_UART0,BAUD_115200); + board_debug_console_open_baud(TRACE_PORT_UART0,BAUD_115200); // Reset reason reset_cause_get(); reset_cause_clear(); Program_Init(); -// sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback); -// sleep_timer_start(__MS_TO_32K_CNT(500));//测试 -// Chuanshuwenjian_Poll(); -//注意串口一波特率改为9600了为了能和GPS通信上 - // 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) @@ -681,10 +676,8 @@ { board_calibration_params_default(); } - // Chip calibration calib_chip(); - // Disable watchdog timer wdt_close(WDT_ID0); LOG_INFO(TRACE_MODULE_APP, "UWB simple example\r\n"); @@ -697,56 +690,27 @@ pwm_open(&usr_pwm_cfg); // pwm_ch_enable(PWM_ID0, &usr_pwm_ch0_cfg); gpio_open(); - LED_output_init();//配置adcGND引脚 -// battery_monitor_open(); -// Voltage_input=battery_monitor_get(); -// battery_monitor_close(); - + LED_output_init();//配置adcGND引脚 adc_open(&usr_adc_cfg); IIC2_Init(); SC7A22H_Motion_Detection_Init(); -// PCA9555_init(); -// 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_control_init(); -// 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); - //gps_air780_power_change(0,1);//开启gps,4G -//加速度计初始化必须在IO_control_init之前因为复用SDA引脚 - gpio_pin_clr(ADC_GND_ENABLE); - Program_Init(); - //uart_open(UART_ID1, &test_uart_cfg); - // uart1_change_from_gps_to_debug(); - //Uart1GpsRecDebugSend(); + gpio_pin_clr(ADC_GND_ENABLE); + Program_Init(); uart_receive(UART_ID0,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); + + #ifdef _UWB_1HZ + sleep_timer_start(__MS_TO_32K_CNT(1000));//测试 + #else sleep_timer_start(__MS_TO_32K_CNT(5000));//测试 - //sleep_timer_start(__MS_TO_32K_CNT(SLEEP_TIMER_NUM));//测试 - board_5V_input_init(voltage_input_handler); -// PCA9555_Set_One_Value_Output(ADC_MINIUS,0);//拉低 - adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 + #endif + board_5V_input_init(voltage_input_handler); + adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 board_acceleration_detection_init(move_handler); -// pca_input_detection_init(pca_handler);//pca检测输入 - Uwb_init(); -// OpenUWB(); -// LOG_INFO(TRACE_MODULE_APP,"初始化_uwb_rx打开\r\n"); - Dw1000_App_Init(); - //board_4GUsart_detection_init(_4gUsart_handler); -//pwm_ch_enable(PWM_ID0, &usr_pwm_ch0_cfg); -// delay_ms(10000); -//pwm_ch_disable(PWM_ID0); + Uwb_init(); + Dw1000_App_Init(); while (1) { if(flag_secondtask) @@ -757,7 +721,9 @@ if(g_start_send_flag) { g_start_send_flag = 0; + gpio_pin_set(IO_PIN_7);//亮 SwitchTagState(); + gpio_pin_clr(IO_PIN_7);//灭 } // PowerTask(); IMUTask(); -- Gitblit v1.9.3