Ignore:
Timestamp:
Apr 2, 2026, 3:56:21 PM (5 weeks ago)
Author:
f.jahn
Message:
  • USB-PD function was implemented;
  • HW parity check on RAM was activated;
  • USB Device CDC mode was activated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fw_g473rct/USBPD/App/usbpd_pwr_if.c

    r59 r65  
    121121
    122122/**
     123  * @brief  Sets the required power profile, now it works only with Fixed ones
     124  * @param  PortNum Port number
     125  * @retval USBPD status
     126*/
     127USBPD_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/**
    123142  * @brief  Checks if the power on a specified port is ready
    124143  * @param  PortNum Port number
     
    152171  return status;
    153172/* 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  */
     180USBPD_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  */
     193USBPD_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  */
     206USBPD_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;
    154210}
    155211
     
    207263void USBPD_PWR_IF_GetPortPDOs(uint8_t PortNum, USBPD_CORE_DataInfoType_TypeDef DataId, uint8_t *Ptr, uint32_t *Size)
    208264{
     265    if (DataId == USBPD_CORE_DATATYPE_SRC_PDO)
    209266    {
    210       *Size = PORT0_NB_SINKPDO;
    211       memcpy(Ptr,PORT0_PDO_ListSNK, sizeof(uint32_t) * PORT0_NB_SINKPDO);
     267      *Size = PORT0_NB_SOURCEPDO;
     268      memcpy(Ptr,PORT0_PDO_ListSRC, sizeof(uint32_t) * PORT0_NB_SOURCEPDO);
    212269    }
    213270/* USER CODE BEGIN USBPD_PWR_IF_GetPortPDOs */
     
    269326  switch(PowerTypeStatus)
    270327  {
    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;
    282345  }
    283346  return _status;
Note: See TracChangeset for help on using the changeset viewer.