/* This function performs an initialization of the CAD.  */
void CAD_Init(uint8_t PortNum, USBPD_SettingsTypeDef *Settings, USBPD_ParamsTypeDef *Params, void(*WakeUp)(void))
/* This function performs an initialization of the CAD.  */
void CAD_Init(uint8_t PortNum, USBPD_SettingsTypeDef *Settings, USBPD_ParamsTypeDef *Params, void(*WakeUp)(void))
{
  CAD_HW_HandleTypeDef *_handle = &CAD_HW_Handles[PortNum];
  _handle->params = Params;
  _handle->settings = Settings;
  _handle->state = USBPD_CAD_STATE_RESET;
  _handle->cc = CCNONE;
  _handle->CurrentHWcondition = _handle->OldHWCondtion = HW_Detachment;
  _handle->SNK_Source_Current_Adv = vRd_Undefined;
  if(_handle->params->PE_PowerRole == USBPD_PORTPOWERROLE_SRC)
  {
    USBPDM1_DeAssertRd(PortNum);
    USBPDM1_AssertRp(PortNum);
  }
  else
  {
    USBPDM1_DeAssertRp(PortNum);
    USBPDM1_AssertRd(PortNum);
  }
}