From 2e2c365223a49baa0c0ef1bb50f0212fc1cac247 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: Tue, 14 Oct 2025 16:25:26 +0800 Subject: [PATCH] add pd ufp task --- Power_Pico/User/Tasks/Src/user_PDUFPTask.c | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Power_Pico/User/Tasks/Src/user_PDUFPTask.c diff --git a/Power_Pico/User/Tasks/Src/user_PDUFPTask.c b/Power_Pico/User/Tasks/Src/user_PDUFPTask.c new file mode 100644 index 0000000..02a9ec0 --- /dev/null +++ b/Power_Pico/User/Tasks/Src/user_PDUFPTask.c @@ -0,0 +1,42 @@ +/* Private includes -----------------------------------------------------------*/ +//includes +#include "user_TasksInit.h" +#include "user_PDUFPTask.h" +#include "main.h" +#include "fusb302_dev.h" +/* Private typedef -----------------------------------------------------------*/ + +/* Private define ------------------------------------------------------------*/ + +/* Private variables ---------------------------------------------------------*/ + +uint8_t timer_flag = 0; + +/* Private function prototypes -----------------------------------------------*/ + +/** + * @brief task for PD_UFP + * @param argument: Not used + * @retval None + */ +void PDUFPTask(void *argument) +{ + // FUSB init + fusb302_dev_init(); + // set + PD_protocol_set_power_option(&pd_protocol, PD_POWER_OPTION_MAX_9V); + PD_protocol_set_PPS(&pd_protocol, PD_V(8.4), PD_A(2.0), true); + while(1) + { + timer_flag = fusb302_timer(); + if (timer_flag) { + FUSB302_event_t FUSB302_events = 0; + for (uint8_t i = 0; i < 3 && FUSB302_alert(&fusb302_dev, &FUSB302_events) != FUSB302_SUCCESS; i++) {} + if (FUSB302_events) { + handle_FUSB302_event(FUSB302_events); + } + } + + osDelay(100); + } +}