Changeset 65 for trunk/fw_g473rct/USBPD/App
- Timestamp:
- Apr 2, 2026, 3:56:21 PM (5 weeks ago)
- Location:
- trunk/fw_g473rct/USBPD/App
- Files:
-
- 4 edited
-
usbpd_dpm_core.c (modified) (6 diffs)
-
usbpd_pdo_defs.h (modified) (3 diffs)
-
usbpd_pwr_if.c (modified) (4 diffs)
-
usbpd_pwr_if.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/USBPD/App/usbpd_dpm_core.c
r59 r65 96 96 static const USBPD_PE_Callbacks dpmCallbacks = 97 97 { 98 NULL,98 USBPD_DPM_SetupNewPower, 99 99 USBPD_DPM_HardReset, 100 100 NULL, … … 103 103 USBPD_DPM_GetDataInfo, 104 104 USBPD_DPM_SetDataInfo, 105 USBPD_DPM_EvaluateRequest, 105 106 NULL, 106 USBPD_DPM_SNK_EvaluateCapabilities,107 107 NULL, 108 108 USBPD_PE_TaskWakeUp, … … 244 244 UTIL_TIMER_Stop(&TimerPE0); 245 245 uint32_t _timing = 246 USBPD_PE_StateMachine_S NK(USBPD_PORT_0);246 USBPD_PE_StateMachine_SRC(USBPD_PORT_0); 247 247 if (_timing != 0xFFFFFFFF) 248 248 { … … 260 260 UTIL_TIMER_Stop(&TimerPE1); 261 261 uint32_t _timing = 262 USBPD_PE_StateMachine_S NK(USBPD_PORT_1);262 USBPD_PE_StateMachine_SRC(USBPD_PORT_1); 263 263 if (_timing != 0xFFFFFFFF) 264 264 { … … 320 320 { 321 321 DPM_Sleep_time[port] = 322 USBPD_PE_StateMachine_S NK(port);322 USBPD_PE_StateMachine_SRC(port); 323 323 DPM_Sleep_start[port] = HAL_GetTick(); 324 324 } … … 327 327 USBPD_DPM_UserExecute(NULL); 328 328 329 } while (1u == 1u);329 } while (1u != 1u); 330 330 #endif /* USE_STM32_UTILITY_OS */ 331 331 } -
trunk/fw_g473rct/USBPD/App/usbpd_pdo_defs.h
r59 r65 34 34 35 35 /* Define ------------------------------------------------------------------*/ 36 #define PORT0_NB_SOURCEPDO 0U /* Number of Source PDOs (applicable for port 0) */37 #define PORT0_NB_SINKPDO 1U /* Number of Sink PDOs (applicable for port 0) */36 #define PORT0_NB_SOURCEPDO 1U /* Number of Source PDOs (applicable for port 0) */ 37 #define PORT0_NB_SINKPDO 0U /* Number of Sink PDOs (applicable for port 0) */ 38 38 #define PORT1_NB_SOURCEPDO 0U /* Number of Source PDOs (applicable for port 1) */ 39 39 #define PORT1_NB_SINKPDO 0U /* Number of Sink PDOs (applicable for port 1) */ … … 85 85 uint32_t PORT0_PDO_ListSRC[USBPD_MAX_NB_PDO] = 86 86 { 87 /* PDO 1 */ (0x00000000U), 87 /* PDO 1 */ 88 ( 89 USBPD_PDO_TYPE_FIXED | /* Fixed supply PDO */ 90 91 USBPD_PDO_SRC_FIXED_SET_VOLTAGE(5000U) | /* Voltage in mV */ 92 USBPD_PDO_SRC_FIXED_SET_MAX_CURRENT(3000U) | /* Max current in mA */ 93 USBPD_PDO_SRC_FIXED_PEAKCURRENT_EQUAL | /* Peak Current info */ 94 95 /* Common definitions applicable to all PDOs, defined only in PDO 1 */ 96 USBPD_PDO_SRC_FIXED_UNCHUNK_NOT_SUPPORTED | /* Unchunked Extended Messages */ 97 USBPD_PDO_SRC_FIXED_DRD_SUPPORTED | /* Dual-Role Data */ 98 USBPD_PDO_SRC_FIXED_USBCOMM_SUPPORTED | /* USB Communications */ 99 USBPD_PDO_SRC_FIXED_EXT_POWER_NOT_AVAILABLE | /* External Power */ 100 USBPD_PDO_SRC_FIXED_USBSUSPEND_NOT_SUPPORTED | /* USB Suspend Supported */ 101 USBPD_PDO_SRC_FIXED_DRP_NOT_SUPPORTED /* Dual-Role Power */ 102 ), 88 103 89 104 /* PDO 2 */ (0x00000000U), … … 105 120 { 106 121 107 /* PDO 1 */ 108 ( 109 USBPD_PDO_TYPE_FIXED | /* Fixed supply PDO */ 110 111 USBPD_PDO_SNK_FIXED_SET_VOLTAGE(5000U) | /* Voltage in mV */ 112 USBPD_PDO_SNK_FIXED_SET_OP_CURRENT(500U) | /* Operating current in mA */ 113 114 /* Common definitions applicable to all PDOs, defined only in PDO 1 */ 115 USBPD_PDO_SNK_FIXED_FRS_NOT_SUPPORTED | /* Fast Role Swap */ 116 USBPD_PDO_SNK_FIXED_DRD_NOT_SUPPORTED | /* Dual-Role Data */ 117 USBPD_PDO_SNK_FIXED_USBCOMM_NOT_SUPPORTED | /* USB Communications */ 118 USBPD_PDO_SNK_FIXED_EXT_POWER_NOT_AVAILABLE | /* External Power */ 119 USBPD_PDO_SNK_FIXED_HIGHERCAPAB_NOT_SUPPORTED | /* Higher Capability */ 120 USBPD_PDO_SNK_FIXED_DRP_NOT_SUPPORTED /* Dual-Role Power */ 121 ), 122 /* PDO 1 */ (0x00000000U), 122 123 123 124 /* PDO 2 */ (0x00000000U), -
trunk/fw_g473rct/USBPD/App/usbpd_pwr_if.c
r59 r65 121 121 122 122 /** 123 * @brief Sets the required power profile, now it works only with Fixed ones 124 * @param PortNum Port number 125 * @retval USBPD status 126 */ 127 USBPD_StatusTypeDef USBPD_PWR_IF_SetProfile(uint8_t PortNum) 128 { 129 /* USER CODE BEGIN USBPD_PWR_IF_SetProfile */ 130 USBPD_StatusTypeDef _status = USBPD_ERROR; 131 PWR_IF_DEBUG_TRACE(PortNum, "ADVICE: update USBPD_PWR_IF_SetProfile"); 132 if (BSP_ERROR_NONE == BSP_USBPD_PWR_VBUSSetVoltage_Fixed(PortNum, 5000, 3000, 3000)) 133 { 134 _status = USBPD_OK; 135 } 136 137 return _status; 138 /* USER CODE END USBPD_PWR_IF_SetProfile */ 139 } 140 141 /** 123 142 * @brief Checks if the power on a specified port is ready 124 143 * @param PortNum Port number … … 152 171 return status; 153 172 /* USER CODE END USBPD_PWR_IF_SupplyReady */ 173 } 174 175 /** 176 * @brief Enables VBUS power on a specified port 177 * @param PortNum Port number 178 * @retval USBPD status 179 */ 180 USBPD_StatusTypeDef USBPD_PWR_IF_VBUSEnable(uint8_t PortNum) 181 { 182 /* USER CODE BEGIN USBPD_PWR_IF_VBUSEnable */ 183 USBPD_StatusTypeDef _status = (USBPD_StatusTypeDef)HW_IF_PWR_Enable(PortNum, USBPD_ENABLE, CCNONE, USBPD_FALSE, USBPD_PORTPOWERROLE_SRC); 184 return _status; 185 /* USER CODE END USBPD_PWR_IF_VBUSEnable */ 186 } 187 188 /** 189 * @brief Disable VBUS/VCONN the power on a specified port 190 * @param PortNum Port number 191 * @retval USBPD status 192 */ 193 USBPD_StatusTypeDef USBPD_PWR_IF_VBUSDisable(uint8_t PortNum) 194 { 195 /* USER CODE BEGIN USBPD_PWR_IF_VBUSDisable */ 196 USBPD_StatusTypeDef _status = (USBPD_StatusTypeDef)HW_IF_PWR_Enable(PortNum, USBPD_DISABLE, CCNONE, USBPD_FALSE, USBPD_PORTPOWERROLE_SRC); 197 return _status; 198 /* USER CODE END USBPD_PWR_IF_VBUSDisable */ 199 } 200 201 /** 202 * @brief Checks if the power on a specified port is enabled 203 * @param PortNum Port number 204 * @retval USBPD_ENABLE or USBPD_DISABLE 205 */ 206 USBPD_FunctionalState USBPD_PWR_IF_VBUSIsEnabled(uint8_t PortNum) 207 { 208 /* Get the Status of the port */ 209 return USBPD_PORT_IsValid(PortNum) ? (USBPD_FunctionalState)HW_IF_PWR_VBUSIsEnabled(PortNum) : USBPD_DISABLE; 154 210 } 155 211 … … 207 263 void USBPD_PWR_IF_GetPortPDOs(uint8_t PortNum, USBPD_CORE_DataInfoType_TypeDef DataId, uint8_t *Ptr, uint32_t *Size) 208 264 { 265 if (DataId == USBPD_CORE_DATATYPE_SRC_PDO) 209 266 { 210 *Size = PORT0_NB_S INKPDO;211 memcpy(Ptr,PORT0_PDO_ListS NK, sizeof(uint32_t) * PORT0_NB_SINKPDO);267 *Size = PORT0_NB_SOURCEPDO; 268 memcpy(Ptr,PORT0_PDO_ListSRC, sizeof(uint32_t) * PORT0_NB_SOURCEPDO); 212 269 } 213 270 /* USER CODE BEGIN USBPD_PWR_IF_GetPortPDOs */ … … 269 326 switch(PowerTypeStatus) 270 327 { 271 case USBPD_PWR_BELOWVSAFE0V : 272 if (_vbus < USBPD_PWR_LOW_VBUS_THRESHOLD) _status = USBPD_TRUE; 273 break; 274 case USBPD_PWR_VSAFE5V : 275 if (_vbus >= USBPD_PWR_HIGH_VBUS_THRESHOLD) _status = USBPD_TRUE; 276 break; 277 case USBPD_PWR_SNKDETACH: 278 if (_vbus < USBPD_PWR_HIGH_VBUS_THRESHOLD) _status = USBPD_TRUE; 279 break; 280 default : 281 break; 328 case USBPD_PWR_BELOWVSAFE0V : 329 // Here we must make sure that voltage on Vbus is lower than 750mV, 330 // but we do not monitor Vbus with ADC, so we just assume that voltage is Ok 331 _status = USBPD_TRUE; 332 break; 333 case USBPD_PWR_VSAFE5V : 334 // Here we must make sure that voltage on Vbus is higher than 2.8V, 335 // but we do not monitor Vbus with ADC, so we just assume that voltage is Ok 336 _status = USBPD_TRUE; 337 break; 338 case USBPD_PWR_SNKDETACH: 339 // Here we must make sure that voltage on Vbus is lower than 2.8V, 340 // but we do not monitor Vbus with ADC, so we just assume that voltage is Ok 341 _status = USBPD_TRUE; 342 break; 343 default : 344 break; 282 345 } 283 346 return _status; -
trunk/fw_g473rct/USBPD/App/usbpd_pwr_if.h
r59 r65 217 217 218 218 /** 219 * @brief Sets the required power profile 220 * @param PortNum Port number 221 * @retval USBPD status 222 */ 223 USBPD_StatusTypeDef USBPD_PWR_IF_SetProfile(uint8_t PortNum); 224 225 /** 219 226 * @brief Checks if the power on a specified port is ready 220 227 * @param PortNum Port number … … 223 230 */ 224 231 USBPD_StatusTypeDef USBPD_PWR_IF_SupplyReady(uint8_t PortNum, USBPD_VSAFE_StatusTypeDef Vsafe); 232 233 /** 234 * @brief Enable VBUS power on a specified port 235 * @param PortNum Port number 236 * @retval USBPD status 237 */ 238 USBPD_StatusTypeDef USBPD_PWR_IF_VBUSEnable(uint8_t PortNum); 239 240 /** 241 * @brief Disable VBUS power on a specified port 242 * @param PortNum Port number 243 * @retval USBPD status 244 */ 245 USBPD_StatusTypeDef USBPD_PWR_IF_VBUSDisable(uint8_t PortNum); 246 247 /** 248 * @brief Checks if the power on a specified port is enabled 249 * @param PortNum Port number 250 * @retval ENABLE or DISABLE 251 */ 252 USBPD_FunctionalState USBPD_PWR_IF_VBUSIsEnabled(uint8_t PortNum); 225 253 226 254 /**
Note:
See TracChangeset
for help on using the changeset viewer.
