Files
Power-Pico/Power_Pico/User/Tasks/Src/user_PDUFPTask.c

41 lines
1.4 KiB
C
Raw Normal View History

2025-10-14 16:25:26 +08:00
/* Private includes -----------------------------------------------------------*/
//includes
#include "user_TasksInit.h"
#include "user_PDUFPTask.h"
#include "main.h"
#include "fusb302_dev.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/**
* @brief task for PD_UFP
* @param argument: Not used
* @retval None
*/
void PDUFPTask(void *argument)
{
2025-11-25 19:58:08 +08:00
// 快充诱骗时需要另外一个端口也供电,因为快充口会有可能断电
// FUSB CC pin connect
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET);
2025-10-14 16:25:26 +08:00
// set
2025-11-25 19:58:08 +08:00
PD_protocol_set_power_option(&app_pd.protocol, PD_POWER_OPTION_MAX_20V);
PD_protocol_set_PPS(&app_pd.protocol, PPS_V(5.0), PPS_A(1.0), false);
// 可以检测status_power来判断是否有PPS供电
2025-10-14 16:25:26 +08:00
while(1)
{
2025-10-19 21:17:15 +08:00
if (fusb302_timer() || HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) == GPIO_PIN_RESET) {
2025-10-14 16:25:26 +08:00
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);
}
}
2025-10-26 15:20:04 +08:00
osDelay(1);
2025-10-14 16:25:26 +08:00
}
}