From fe73739d65fad38dd627f7ac18f382bba9d7cf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=90=83=E6=B2=B9=E7=82=B8=E9=B8=A1?= <1425962791@qq.com> Date: Mon, 22 Sep 2025 21:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A1=AC=E4=BB=B6=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E4=B8=AD=E9=98=9F=E5=88=97=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Power_Pico/User/Tasks/Src/user_HardwareInitTask.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Power_Pico/User/Tasks/Src/user_HardwareInitTask.c b/Power_Pico/User/Tasks/Src/user_HardwareInitTask.c index 80ecf33..fe44e73 100644 --- a/Power_Pico/User/Tasks/Src/user_HardwareInitTask.c +++ b/Power_Pico/User/Tasks/Src/user_HardwareInitTask.c @@ -15,6 +15,7 @@ #include "lcd.h" #include "lcd_init.h" #include "gate.h" +#include "data_queue.h" // ui #include "lvgl.h" @@ -48,10 +49,11 @@ void HardwareInitTask(void *argument) UART6_TX_Send((uint8_t *)"power-pico\r\n", 13); // HAL_UART_Transmit_DMA(&huart6,(uint8_t *)"power-pico\r\n",13); - // ADC - HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adc_packet.data, ADC_TIMES * ADC_CHANELS); /*启动ADC的DMA传输,配合定时器触发ADC转换 12位的ADC对应0-4095 */ - HAL_TIM_Base_Start(&htim2); /*开启定时器,用溢出时间来触发ADC*/ + // queue for voltage and current + global_voltage_queue = queue_create(8); + global_current_queue = queue_create(8); + // adc packet init adc_packet.header[0] = 0x55; adc_packet.header[1] = 0xAA; // 填充模式位 @@ -64,6 +66,10 @@ void HardwareInitTask(void *argument) // FUSB CC dis connect HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); + // ADC sample start + HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adc_packet.data, ADC_TIMES * ADC_CHANELS); /*启动ADC的DMA传输,配合定时器触发ADC转换 12位的ADC对应0-4095 */ + HAL_TIM_Base_Start(&htim2); /*开启定时器,用溢出时间来触发ADC*/ + // PWM Start for LCD backlight HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_3);