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/Target/usbpd_pwr_user.c

    r59 r65  
    2929/* USER CODE BEGIN include */
    3030
     31#include "gpio.h"
     32
    3133/* USER CODE END include */
    3234
     
    266268  else
    267269  {
     270        HAL_GPIO_WritePin(UCPD1_VBUS_GPIO_Port, UCPD1_VBUS_Pin, GPIO_PIN_RESET);
    268271    PWR_DEBUG_TRACE(Instance, "ADVICE: Update BSP_USBPD_PWR_VBUSInit");
     272        /* Need to keep DISCHARGE ON as soon as not powering VBUS on MB1397 */
     273        //DISCHARGE_SET_ON();
    269274  }
    270275
     
    306311  /* USER CODE BEGIN BSP_USBPD_PWR_VBUSOn */
    307312  /* Check if instance is valid       */
    308   int32_t ret;
    309 
    310   if (Instance >= USBPD_PWR_INSTANCES_NBR)
    311   {
    312     ret = BSP_ERROR_WRONG_PARAM;
    313   }
    314   else
    315   {
    316     ret = BSP_ERROR_FEATURE_NOT_SUPPORTED;
     313  int32_t ret = BSP_ERROR_NONE;
     314
     315  if (Instance >= USBPD_PWR_INSTANCES_NBR)
     316  {
     317    ret = BSP_ERROR_WRONG_PARAM;
     318  }
     319  else
     320  {
    317321    PWR_DEBUG_TRACE(Instance, "ADVICE: Update BSP_USBPD_PWR_VBUSOn");
     322        // Turning discharger off;
     323        HAL_GPIO_WritePin(UCPD1_VBUS_GPIO_Port, UCPD1_VBUS_Pin, GPIO_PIN_SET);          // Turning Power Source on;
    318324  }
    319325  return ret;
     
    332338  /* USER CODE BEGIN BSP_USBPD_PWR_VBUSOff */
    333339  /* Check if instance is valid       */
    334   int32_t ret;
    335 
    336   if (Instance >= USBPD_PWR_INSTANCES_NBR)
    337   {
    338     ret = BSP_ERROR_WRONG_PARAM;
    339   }
    340   else
    341   {
    342     ret = BSP_ERROR_FEATURE_NOT_SUPPORTED;
     340  int32_t ret = BSP_ERROR_NONE;
     341
     342  if (Instance >= USBPD_PWR_INSTANCES_NBR)
     343  {
     344    ret = BSP_ERROR_WRONG_PARAM;
     345  }
     346  else
     347  {
    343348    PWR_DEBUG_TRACE(Instance, "ADVICE: Update BSP_USBPD_PWR_VBUSOff");
     349        HAL_GPIO_WritePin(UCPD1_VBUS_GPIO_Port, UCPD1_VBUS_Pin, GPIO_PIN_RESET);        // Turning Power Source off
     350        // Turning on Discharge and waiting till Vbus voltage is at low level (750mV)
    344351  }
    345352  return ret;
     
    480487  else
    481488  {
    482     ret = BSP_ERROR_FEATURE_NOT_SUPPORTED;
    483489    PWR_DEBUG_TRACE(Instance, "ADVICE: Update BSP_USBPD_PWR_VBUSGetVoltage");
     490        val = 5000U;
    484491  }
    485492  *pVoltage = val;
     
    712719  /* USER CODE BEGIN BSP_USBPD_PWR_VBUSIsOn */
    713720  /* Check if instance is valid       */
    714   int32_t ret;
     721  int32_t ret = BSP_ERROR_NONE;
    715722  uint8_t state = 0U;
    716723
     
    721728  else
    722729  {
    723     ret = BSP_ERROR_FEATURE_NOT_SUPPORTED;
     730    if (HAL_GPIO_ReadPin(UCPD1_VBUS_GPIO_Port, UCPD1_VBUS_Pin) == GPIO_PIN_SET)
     731                state = 1U;
    724732    PWR_DEBUG_TRACE(Instance, "ADVICE: Update BSP_USBPD_PWR_VBUSIsOn");
    725733  }
Note: See TracChangeset for help on using the changeset viewer.