| [59] | 1 | /* USER CODE BEGIN Header */
|
|---|
| 2 | /**
|
|---|
| 3 | ******************************************************************************
|
|---|
| 4 | * @file usbpd_vdm_user.c
|
|---|
| 5 | * @author MCD Application Team
|
|---|
| 6 | * @brief USBPD provider demo file
|
|---|
| 7 | ******************************************************************************
|
|---|
| 8 | * @attention
|
|---|
| 9 | *
|
|---|
| 10 | * Copyright (c) 2026 STMicroelectronics.
|
|---|
| 11 | * All rights reserved.
|
|---|
| 12 | *
|
|---|
| 13 | * This software is licensed under terms that can be found in the LICENSE file
|
|---|
| 14 | * in the root directory of this software component.
|
|---|
| 15 | * If no LICENSE file comes with this software, it is provided AS-IS.
|
|---|
| 16 | *
|
|---|
| 17 | ******************************************************************************
|
|---|
| 18 | */
|
|---|
| 19 | /* USER CODE END Header */
|
|---|
| 20 |
|
|---|
| 21 | /* Includes ------------------------------------------------------------------*/
|
|---|
| 22 | #include "usbpd_core.h"
|
|---|
| 23 | #include "usbpd_dpm_conf.h"
|
|---|
| 24 | #include "usbpd_vdm_user.h"
|
|---|
| 25 | #include "usbpd_dpm_user.h"
|
|---|
| 26 | /* USER CODE BEGIN Includes */
|
|---|
| 27 |
|
|---|
| 28 | /* USER CODE END Includes */
|
|---|
| 29 |
|
|---|
| 30 | /** @addtogroup STM32_USBPD_APPLICATION
|
|---|
| 31 | * @{
|
|---|
| 32 | */
|
|---|
| 33 |
|
|---|
| 34 | /** @addtogroup STM32_USBPD_APPLICATION_VDM_USER
|
|---|
| 35 | * @{
|
|---|
| 36 | */
|
|---|
| 37 |
|
|---|
| 38 | /* Private define ------------------------------------------------------------*/
|
|---|
| 39 | /* USER CODE BEGIN Private_define */
|
|---|
| 40 |
|
|---|
| 41 | /* USER CODE END Private_define */
|
|---|
| 42 |
|
|---|
| 43 | /* Private typedef -----------------------------------------------------------*/
|
|---|
| 44 | /* USER CODE BEGIN Private_typedef */
|
|---|
| 45 |
|
|---|
| 46 | /* USER CODE END Private_typedef */
|
|---|
| 47 |
|
|---|
| 48 | /* Private macro -------------------------------------------------------------*/
|
|---|
| 49 | /* USER CODE BEGIN Private_macro */
|
|---|
| 50 |
|
|---|
| 51 | /* USER CODE END Private_macro */
|
|---|
| 52 |
|
|---|
| 53 | /* Private function prototypes -----------------------------------------------*/
|
|---|
| 54 | static USBPD_StatusTypeDef USBPD_VDM_DiscoverIdentity(uint8_t PortNum, USBPD_DiscoveryIdentity_TypeDef *pIdentity);
|
|---|
| 55 | static USBPD_StatusTypeDef USBPD_VDM_DiscoverSVIDs(uint8_t PortNum, uint16_t **p_SVID_Info, uint8_t *nb);
|
|---|
| 56 | static USBPD_StatusTypeDef USBPD_VDM_DiscoverModes(uint8_t PortNum, uint16_t SVID, uint32_t **p_ModeInfo, uint8_t *nbMode);
|
|---|
| 57 | static USBPD_StatusTypeDef USBPD_VDM_ModeEnter(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex);
|
|---|
| 58 | static USBPD_StatusTypeDef USBPD_VDM_ModeExit(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex);
|
|---|
| 59 | static void USBPD_VDM_SendAttention(uint8_t PortNum, uint8_t *NbData, uint32_t *VDO);
|
|---|
| 60 | static void USBPD_VDM_ReceiveAttention(uint8_t PortNum, uint8_t NbData, uint32_t VDO);
|
|---|
| 61 | static USBPD_StatusTypeDef USBPD_VDM_ReceiveSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *NbData, uint32_t *VDO);
|
|---|
| 62 | static void USBPD_VDM_InformIdentity(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_DiscoveryIdentity_TypeDef *pIdentity);
|
|---|
| 63 | static void USBPD_VDM_InformSVID(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_SVIDInfo_TypeDef *pListSVID);
|
|---|
| 64 | static void USBPD_VDM_InformMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_ModeInfo_TypeDef *pModesInfo);
|
|---|
| 65 | static void USBPD_VDM_InformModeEnter(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex);
|
|---|
| 66 | static void USBPD_VDM_InformModeExit(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex);
|
|---|
| 67 | static void USBPD_VDM_InformSpecific(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *NbData, uint32_t *VDO);
|
|---|
| 68 | static void USBPD_VDM_SendSpecific(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *NbData, uint32_t *VDO);
|
|---|
| 69 | static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO);
|
|---|
| 70 | static USBPD_StatusTypeDef USBPD_VDM_ReceiveUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef UVDM_Header, uint8_t *pNbData, uint32_t *pVDO);
|
|---|
| 71 |
|
|---|
| 72 | /* USER CODE BEGIN Private_prototypes */
|
|---|
| 73 |
|
|---|
| 74 | /* USER CODE END Private_prototypes */
|
|---|
| 75 |
|
|---|
| 76 | /* Private variables ---------------------------------------------------------*/
|
|---|
| 77 | USBPD_VDM_SettingsTypeDef DPM_VDM_Settings[USBPD_PORT_COUNT] =
|
|---|
| 78 | {
|
|---|
| 79 | {
|
|---|
| 80 | .VDM_XID_SOP = USBPD_XID, /*!< A decimal number assigned by USB-IF before certification */
|
|---|
| 81 | .VDM_USB_VID_SOP = USBPD_VID, /*!< A decimal number assigned by USB-IF before certification */
|
|---|
| 82 | .VDM_PID_SOP = USBPD_PID, /*!< A unique number assigned by the Vendor ID holder identifying the product. */
|
|---|
| 83 | .VDM_ModalOperation = MODAL_OPERATION_NONSUPP, /*!< Product support Modes based on @ref USBPD_ModalOp_TypeDef */
|
|---|
| 84 | .VDM_bcdDevice_SOP = 0xAAAA, /*!< A unique number assigned by the Vendor ID holder containing identity information relevant to the release version of the product. */
|
|---|
| 85 | .VDM_USBHostSupport = USB_NOTCAPABLE, /*!< Indicates whether the UUT is capable of enumerating USB Host */
|
|---|
| 86 | .VDM_USBDeviceSupport = USB_NOTCAPABLE, /*!< Indicates whether the UUT is capable of enumerating USB Devices */
|
|---|
| 87 | .VDM_ProductTypeUFPorCP = PRODUCT_TYPE_UNDEFINED, /*!< Product type UFP or CablePlug of the UUT based on @ref USBPD_ProductType_TypeDef */
|
|---|
| 88 | }
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | /* USER CODE BEGIN Private_variables */
|
|---|
| 92 | const USBPD_VDM_Callbacks vdmCallbacks =
|
|---|
| 93 | {
|
|---|
| 94 | USBPD_VDM_DiscoverIdentity,
|
|---|
| 95 | USBPD_VDM_DiscoverSVIDs,
|
|---|
| 96 | USBPD_VDM_DiscoverModes,
|
|---|
| 97 | USBPD_VDM_ModeEnter,
|
|---|
| 98 | USBPD_VDM_ModeExit,
|
|---|
| 99 | USBPD_VDM_InformIdentity,
|
|---|
| 100 | USBPD_VDM_InformSVID,
|
|---|
| 101 | USBPD_VDM_InformMode,
|
|---|
| 102 | USBPD_VDM_InformModeEnter,
|
|---|
| 103 | USBPD_VDM_InformModeExit,
|
|---|
| 104 | USBPD_VDM_SendAttention,
|
|---|
| 105 | USBPD_VDM_ReceiveAttention,
|
|---|
| 106 | USBPD_VDM_SendSpecific,
|
|---|
| 107 | USBPD_VDM_ReceiveSpecific,
|
|---|
| 108 | USBPD_VDM_InformSpecific,
|
|---|
| 109 | USBPD_VDM_SendUVDM,
|
|---|
| 110 | USBPD_VDM_ReceiveUVDM,
|
|---|
| 111 | };
|
|---|
| 112 | /* USER CODE END Private_variables */
|
|---|
| 113 |
|
|---|
| 114 | /* Private functions ---------------------------------------------------------*/
|
|---|
| 115 | /**
|
|---|
| 116 | * @brief VDM Discovery identity callback
|
|---|
| 117 | * @note Function is called to get Discovery identity information linked to the device and answer
|
|---|
| 118 | * to SVDM Discovery identity init message sent by port partner
|
|---|
| 119 | * @param PortNum current port number
|
|---|
| 120 | * @param pIdentity Pointer on @ref USBPD_DiscoveryIdentity_TypeDef structure
|
|---|
| 121 | * @retval USBPD status: @ref USBPD_ACK or @ref USBPD_BUSY
|
|---|
| 122 | */
|
|---|
| 123 | static USBPD_StatusTypeDef USBPD_VDM_DiscoverIdentity(uint8_t PortNum, USBPD_DiscoveryIdentity_TypeDef *pIdentity)
|
|---|
| 124 | {
|
|---|
| 125 | /* USER CODE BEGIN USBPD_VDM_DiscoverIdentity */
|
|---|
| 126 | return USBPD_NAK;
|
|---|
| 127 | /* USER CODE END USBPD_VDM_DiscoverIdentity */
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | /**
|
|---|
| 131 | * @brief VDM Discover SVID callback
|
|---|
| 132 | * @note Function is called to retrieve SVID supported by device and answer
|
|---|
| 133 | * to SVDM Discovery SVID init message sent by port partner
|
|---|
| 134 | * @param PortNum current port number
|
|---|
| 135 | * @param p_SVID_Info Pointer on @ref USBPD_SVIDInfo_TypeDef structure
|
|---|
| 136 | * @param pNbSVID Pointer on number of SVID
|
|---|
| 137 | * @retval USBPD status @ref USBPD_BUSY or @ref USBPD_ACK or @ref USBPD_NAK
|
|---|
| 138 | */
|
|---|
| 139 | static USBPD_StatusTypeDef USBPD_VDM_DiscoverSVIDs(uint8_t PortNum, uint16_t **p_SVID_Info, uint8_t *pNbSVID)
|
|---|
| 140 | {
|
|---|
| 141 | /* USER CODE BEGIN USBPD_VDM_DiscoverSVIDs */
|
|---|
| 142 | return USBPD_NAK;
|
|---|
| 143 | /* USER CODE END USBPD_VDM_DiscoverSVIDs */
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | /**
|
|---|
| 147 | * @brief VDM Discover Mode callback (report all the modes supported by SVID)
|
|---|
| 148 | * @note Function is called to report all the modes supported by selected SVID and answer
|
|---|
| 149 | * to SVDM Discovery Mode init message sent by port partner
|
|---|
| 150 | * @param PortNum current port number
|
|---|
| 151 | * @param SVID SVID value
|
|---|
| 152 | * @param p_ModeTab Pointer on the mode value
|
|---|
| 153 | * @param NumberOfMode Number of mode available
|
|---|
| 154 | * @retval USBPD status
|
|---|
| 155 | */
|
|---|
| 156 | static USBPD_StatusTypeDef USBPD_VDM_DiscoverModes(uint8_t PortNum, uint16_t SVID, uint32_t **p_ModeTab, uint8_t *NumberOfMode)
|
|---|
| 157 | {
|
|---|
| 158 | /* USER CODE BEGIN USBPD_VDM_DiscoverModes */
|
|---|
| 159 | return USBPD_NAK;
|
|---|
| 160 | /* USER CODE END USBPD_VDM_DiscoverModes */
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | /**
|
|---|
| 164 | * @brief VDM Mode enter callback
|
|---|
| 165 | * @note Function is called to check if device can enter in the mode received for the selected SVID in the
|
|---|
| 166 | * SVDM enter mode init message sent by port partner
|
|---|
| 167 | * @param PortNum current port number
|
|---|
| 168 | * @param SVID SVID value
|
|---|
| 169 | * @param ModeIndex Index of the mode to be entered
|
|---|
| 170 | * @retval USBPD status @ref USBPD_ACK/@ref USBPD_NAK
|
|---|
| 171 | */
|
|---|
| 172 | static USBPD_StatusTypeDef USBPD_VDM_ModeEnter(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex)
|
|---|
| 173 | {
|
|---|
| 174 | /* USER CODE BEGIN USBPD_VDM_ModeEnter */
|
|---|
| 175 | return USBPD_NAK;
|
|---|
| 176 | /* USER CODE END USBPD_VDM_ModeEnter */
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | /**
|
|---|
| 180 | * @brief VDM Mode exit callback
|
|---|
| 181 | * @note Function is called to check if device can exit from the mode received for the selected SVID in the
|
|---|
| 182 | * SVDM exit mode init message sent by port partner
|
|---|
| 183 | * @param PortNum current port number
|
|---|
| 184 | * @param SVID SVID value
|
|---|
| 185 | * @param ModeIndex Index of the mode to be exited
|
|---|
| 186 | * @retval USBPD status @ref USBPD_ACK/@ref USBPD_NAK
|
|---|
| 187 | */
|
|---|
| 188 | static USBPD_StatusTypeDef USBPD_VDM_ModeExit(uint8_t PortNum, uint16_t SVID, uint32_t ModeIndex)
|
|---|
| 189 | {
|
|---|
| 190 | /* USER CODE BEGIN USBPD_VDM_ModeExit */
|
|---|
| 191 | return USBPD_NAK;
|
|---|
| 192 | /* USER CODE END USBPD_VDM_ModeExit */
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | /**
|
|---|
| 196 | * @brief Send VDM Attention message callback
|
|---|
| 197 | * @note Function is called when device wants to send a SVDM attention message to port partner
|
|---|
| 198 | * (for instance DP status can be filled through this function)
|
|---|
| 199 | * @param PortNum current port number
|
|---|
| 200 | * @param pNbData Pointer of number of VDO to send
|
|---|
| 201 | * @param pVDO Pointer of VDO to send
|
|---|
| 202 | * @retval None
|
|---|
| 203 | */
|
|---|
| 204 | static void USBPD_VDM_SendAttention(uint8_t PortNum, uint8_t *pNbData, uint32_t *pVDO)
|
|---|
| 205 | {
|
|---|
| 206 | /* USER CODE BEGIN USBPD_VDM_SendAttention */
|
|---|
| 207 |
|
|---|
| 208 | /* USER CODE END USBPD_VDM_SendAttention */
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | /**
|
|---|
| 212 | * @brief Receive VDM Attention callback
|
|---|
| 213 | * @note Function is called when a SVDM attention init message has been received from port partner
|
|---|
| 214 | * (for instance, save DP status data through this function)
|
|---|
| 215 | * @param PortNum current port number
|
|---|
| 216 | * @param NbData Number of received VDO
|
|---|
| 217 | * @param VDO Received VDO
|
|---|
| 218 | * @retval None
|
|---|
| 219 | */
|
|---|
| 220 | static void USBPD_VDM_ReceiveAttention(uint8_t PortNum, uint8_t NbData, uint32_t VDO)
|
|---|
| 221 | {
|
|---|
| 222 | /* USER CODE BEGIN USBPD_VDM_ReceiveAttention */
|
|---|
| 223 |
|
|---|
| 224 | /* USER CODE END USBPD_VDM_ReceiveAttention */
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | /**
|
|---|
| 228 | * @brief VDM Receive Specific message callback
|
|---|
| 229 | * @note Function is called to answer to a SVDM specific init message received by port partner.
|
|---|
| 230 | * (for instance, retrieve DP status or DP configure data through this function)
|
|---|
| 231 | * @param PortNum Current port number
|
|---|
| 232 | * @param VDMCommand VDM command based on @ref USBPD_VDM_Command_Typedef
|
|---|
| 233 | * @param pNbData Pointer of number of received VDO and used for the answer
|
|---|
| 234 | * @param pVDO Pointer of received VDO and use for the answer
|
|---|
| 235 | * @retval USBPD Status
|
|---|
| 236 | */
|
|---|
| 237 | static USBPD_StatusTypeDef USBPD_VDM_ReceiveSpecific(uint8_t PortNum, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO)
|
|---|
| 238 | {
|
|---|
| 239 | /* USER CODE BEGIN USBPD_VDM_ReceiveSpecific */
|
|---|
| 240 | return USBPD_NAK;
|
|---|
| 241 | /* USER CODE END USBPD_VDM_ReceiveSpecific */
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 | /**
|
|---|
| 245 | * @brief Inform identity callback
|
|---|
| 246 | * @note Function is called to save Identity information received in Discovery identity from port partner
|
|---|
| 247 | (answer to SVDM discovery identity sent by device)
|
|---|
| 248 | * @param PortNum current port number
|
|---|
| 249 | * @param SOPType SOP type
|
|---|
| 250 | * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
|
|---|
| 251 | * @param pIdentity Pointer on the discovery identity information based on @ref USBPD_DiscoveryIdentity_TypeDef
|
|---|
| 252 | * @retval None
|
|---|
| 253 | */
|
|---|
| 254 | static void USBPD_VDM_InformIdentity(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_DiscoveryIdentity_TypeDef *pIdentity)
|
|---|
| 255 | {
|
|---|
| 256 | /* USER CODE BEGIN USBPD_VDM_InformIdentity */
|
|---|
| 257 | switch(CommandStatus)
|
|---|
| 258 | {
|
|---|
| 259 | case SVDM_RESPONDER_ACK :
|
|---|
| 260 | break;
|
|---|
| 261 | case SVDM_RESPONDER_NAK :
|
|---|
| 262 | break;
|
|---|
| 263 | case SVDM_RESPONDER_BUSY :
|
|---|
| 264 | break;
|
|---|
| 265 | default :
|
|---|
| 266 | break;
|
|---|
| 267 | }
|
|---|
| 268 | /* USER CODE END USBPD_VDM_InformIdentity */
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | /**
|
|---|
| 272 | * @brief Inform SVID callback
|
|---|
| 273 | * @note Function is called to save list of SVID received in Discovery SVID from port partner
|
|---|
| 274 | (answer to SVDM discovery SVID sent by device)
|
|---|
| 275 | * @param PortNum current port number
|
|---|
| 276 | * @param SOPType SOP type
|
|---|
| 277 | * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
|
|---|
| 278 | * @param pListSVID Pointer of list of SVID based on @ref USBPD_SVIDInfo_TypeDef
|
|---|
| 279 | * @retval None
|
|---|
| 280 | */
|
|---|
| 281 | static void USBPD_VDM_InformSVID(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_SVIDInfo_TypeDef *pListSVID)
|
|---|
| 282 | {
|
|---|
| 283 | /* USER CODE BEGIN USBPD_VDM_InformSVID */
|
|---|
| 284 | switch(CommandStatus)
|
|---|
| 285 | {
|
|---|
| 286 | case SVDM_RESPONDER_ACK :
|
|---|
| 287 | break;
|
|---|
| 288 | case SVDM_RESPONDER_NAK :
|
|---|
| 289 | break;
|
|---|
| 290 | case SVDM_RESPONDER_BUSY :
|
|---|
| 291 | break;
|
|---|
| 292 | default :
|
|---|
| 293 | break;
|
|---|
| 294 | }
|
|---|
| 295 | /* USER CODE END USBPD_VDM_InformSVID */
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | /**
|
|---|
| 299 | * @brief Inform Mode callback ( received in Discovery Modes ACK)
|
|---|
| 300 | * @note Function is called to save list of modes linked to SVID received in Discovery mode from port partner
|
|---|
| 301 | (answer to SVDM discovery mode sent by device)
|
|---|
| 302 | * @param PortNum current port number
|
|---|
| 303 | * @param SOPType SOP type
|
|---|
| 304 | * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
|
|---|
| 305 | * @param pModesInfo Pointer of Modes info based on @ref USBPD_ModeInfo_TypeDef
|
|---|
| 306 | * @retval None
|
|---|
| 307 | */
|
|---|
| 308 | static void USBPD_VDM_InformMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_ModeInfo_TypeDef *pModesInfo)
|
|---|
| 309 | {
|
|---|
| 310 | /* USER CODE BEGIN USBPD_VDM_InformMode */
|
|---|
| 311 | switch(CommandStatus)
|
|---|
| 312 | {
|
|---|
| 313 | case SVDM_RESPONDER_ACK :
|
|---|
| 314 | break;
|
|---|
| 315 | case SVDM_RESPONDER_NAK :
|
|---|
| 316 | break;
|
|---|
| 317 | case SVDM_RESPONDER_BUSY :
|
|---|
| 318 | break;
|
|---|
| 319 | default :
|
|---|
| 320 | break;
|
|---|
| 321 | }
|
|---|
| 322 | /* USER CODE END USBPD_VDM_InformMode */
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | /**
|
|---|
| 326 | * @brief Inform Mode enter callback
|
|---|
| 327 | * @note Function is called to inform if port partner accepted or not to enter in the mode
|
|---|
| 328 | * specified in the SVDM enter mode sent by the device
|
|---|
| 329 | * @param PortNum current port number
|
|---|
| 330 | * @param SOPType SOP type
|
|---|
| 331 | * @param CommandStatus Command status based on @ref USBPD_VDM_CommandType_Typedef
|
|---|
| 332 | * @param SVID SVID ID
|
|---|
| 333 | * @param ModeIndex Index of the mode to be entered
|
|---|
| 334 | * @retval None
|
|---|
| 335 | */
|
|---|
| 336 | static void USBPD_VDM_InformModeEnter(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex)
|
|---|
| 337 | {
|
|---|
| 338 | /* USER CODE BEGIN USBPD_VDM_InformModeEnter */
|
|---|
| 339 | switch(CommandStatus)
|
|---|
| 340 | {
|
|---|
| 341 | case SVDM_RESPONDER_ACK :
|
|---|
| 342 | break;
|
|---|
| 343 | case SVDM_RESPONDER_NAK :
|
|---|
| 344 | break;
|
|---|
| 345 | case SVDM_RESPONDER_BUSY :
|
|---|
| 346 | /* retry in 50ms */
|
|---|
| 347 | break;
|
|---|
| 348 | default :
|
|---|
| 349 | break;
|
|---|
| 350 | }
|
|---|
| 351 | /* USER CODE END USBPD_VDM_InformModeEnter */
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 | /**
|
|---|
| 355 | * @brief Inform Exit enter callback
|
|---|
| 356 | * @param PortNum current port number
|
|---|
| 357 | * @param SVID SVID ID
|
|---|
| 358 | * @param ModeIndex Index of the mode to be entered
|
|---|
| 359 | * @retval None
|
|---|
| 360 | */
|
|---|
| 361 | static void USBPD_VDM_InformModeExit(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, uint16_t SVID, uint32_t ModeIndex)
|
|---|
| 362 | {
|
|---|
| 363 | /* USER CODE BEGIN USBPD_VDM_InformModeExit */
|
|---|
| 364 | switch(CommandStatus)
|
|---|
| 365 | {
|
|---|
| 366 | case SVDM_RESPONDER_ACK :
|
|---|
| 367 | break;
|
|---|
| 368 | case SVDM_RESPONDER_NAK :
|
|---|
| 369 | break;
|
|---|
| 370 | case SVDM_RESPONDER_BUSY :
|
|---|
| 371 | /* retry in 50ms */
|
|---|
| 372 | break;
|
|---|
| 373 | default :
|
|---|
| 374 | break;
|
|---|
| 375 | }
|
|---|
| 376 | /* USER CODE END USBPD_VDM_InformModeExit */
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | /**
|
|---|
| 380 | * @brief VDM Send Specific message callback
|
|---|
| 381 | * @note Function is called when device wants to send a SVDM specific init message to port partner
|
|---|
| 382 | * (for instance DP status or DP configure can be filled through this function)
|
|---|
| 383 | * @param PortNum current port number
|
|---|
| 384 | * @param SOPType SOP type
|
|---|
| 385 | * @param VDMCommand VDM command based on @ref USBPD_VDM_Command_Typedef
|
|---|
| 386 | * @param pNbData Pointer of number of VDO to send
|
|---|
| 387 | * @param pVDO Pointer of VDO to send
|
|---|
| 388 | * @retval None
|
|---|
| 389 | */
|
|---|
| 390 | static void USBPD_VDM_SendSpecific(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO)
|
|---|
| 391 | {
|
|---|
| 392 | /* USER CODE BEGIN USBPD_VDM_SendSpecific */
|
|---|
| 393 |
|
|---|
| 394 | /* USER CODE END USBPD_VDM_SendSpecific */
|
|---|
| 395 | }
|
|---|
| 396 |
|
|---|
| 397 | /**
|
|---|
| 398 | * @brief VDM Specific message callback to inform user of reception of VDM specific message
|
|---|
| 399 | * @note Function is called when answer from SVDM specific init message has been received by the device
|
|---|
| 400 | * (for instance, save DP status and DP configure data through this function)
|
|---|
| 401 | * @param PortNum current port number
|
|---|
| 402 | * @param SOPType SOP type
|
|---|
| 403 | * @param VDMCommand VDM command based on @ref USBPD_VDM_Command_Typedef
|
|---|
| 404 | * @param pNbData Pointer of number of received VDO
|
|---|
| 405 | * @param pVDO Pointer of received VDO
|
|---|
| 406 | * @retval None
|
|---|
| 407 | */
|
|---|
| 408 | static void USBPD_VDM_InformSpecific(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_Command_Typedef VDMCommand, uint8_t *pNbData, uint32_t *pVDO)
|
|---|
| 409 | {
|
|---|
| 410 | /* USER CODE BEGIN USBPD_VDM_InformSpecific */
|
|---|
| 411 |
|
|---|
| 412 | /* USER CODE END USBPD_VDM_InformSpecific */
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | /**
|
|---|
| 416 | * @brief VDM Send Unstructured message callback
|
|---|
| 417 | * @note Aim of this function is to fill the UVDM message which contains 1 VDM Header + 6 VDO
|
|---|
| 418 | * This callback will be called when user requests to send a UVDM message thanks
|
|---|
| 419 | * to USBPD_DPM_RequestUVDMMessage function
|
|---|
| 420 | * @param PortNum current port number
|
|---|
| 421 | * @param pUVDM_Header Pointer on UVDM header based on @ref USBPD_UVDMHeader_TypeDef
|
|---|
| 422 | * @param pNbData Pointer of number of VDO to send (max size must be equal to 6)
|
|---|
| 423 | * @param pVDO Pointer of VDO to send (up to 6 x uint32_t)
|
|---|
| 424 | * @retval None
|
|---|
| 425 | */
|
|---|
| 426 | static void USBPD_VDM_SendUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef *pUVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
|
|---|
| 427 | {
|
|---|
| 428 | /* USER CODE BEGIN USBPD_VDM_SendUVDM */
|
|---|
| 429 |
|
|---|
| 430 | /* USER CODE END USBPD_VDM_SendUVDM */
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | /**
|
|---|
| 434 | * @brief Unstructured VDM message callback to inform user of reception of UVDM message
|
|---|
| 435 | * @param PortNum current port number
|
|---|
| 436 | * @param UVDM_Header UVDM header based on @ref USBPD_UVDMHeader_TypeDef
|
|---|
| 437 | * @param pNbData Pointer of number of received VDO
|
|---|
| 438 | * @param pVDO Pointer of received VDO
|
|---|
| 439 | * @retval USBPD Status
|
|---|
| 440 | */
|
|---|
| 441 | static USBPD_StatusTypeDef USBPD_VDM_ReceiveUVDM(uint8_t PortNum, USBPD_UVDMHeader_TypeDef UVDM_Header, uint8_t *pNbData, uint32_t *pVDO)
|
|---|
| 442 | {
|
|---|
| 443 | /* USER CODE BEGIN USBPD_VDM_ReceiveUVDM */
|
|---|
| 444 | return USBPD_ERROR;
|
|---|
| 445 | /* USER CODE END USBPD_VDM_ReceiveUVDM */
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | /* USER CODE BEGIN Private_functions */
|
|---|
| 449 |
|
|---|
| 450 | /* USER CODE END Private_functions */
|
|---|
| 451 |
|
|---|
| 452 | /* Exported functions ---------------------------------------------------------*/
|
|---|
| 453 | /**
|
|---|
| 454 | * @brief VDM Initialization function
|
|---|
| 455 | * @param PortNum Index of current used port
|
|---|
| 456 | * @retval status
|
|---|
| 457 | */
|
|---|
| 458 | USBPD_StatusTypeDef USBPD_VDM_UserInit(uint8_t PortNum)
|
|---|
| 459 | {
|
|---|
| 460 | /* USER CODE BEGIN USBPD_VDM_UserInit */
|
|---|
| 461 | return USBPD_OK;
|
|---|
| 462 | /* USER CODE END USBPD_VDM_UserInit */
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | /**
|
|---|
| 466 | * @brief VDM Reset function
|
|---|
| 467 | * @param PortNum Index of current used port
|
|---|
| 468 | * @retval status
|
|---|
| 469 | */
|
|---|
| 470 | void USBPD_VDM_UserReset(uint8_t PortNum)
|
|---|
| 471 | {
|
|---|
| 472 | /* USER CODE BEGIN USBPD_VDM_UserReset */
|
|---|
| 473 |
|
|---|
| 474 | /* USER CODE END USBPD_VDM_UserReset */
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | /* USER CODE BEGIN Exported_functions */
|
|---|
| 478 |
|
|---|
| 479 | /* USER CODE END Exported_functions */
|
|---|
| 480 |
|
|---|
| 481 | /**
|
|---|
| 482 | * @}
|
|---|
| 483 | */
|
|---|
| 484 |
|
|---|
| 485 | /**
|
|---|
| 486 | * @}
|
|---|
| 487 | */
|
|---|
| 488 |
|
|---|