/* It enables the data trasmission from microcontroller to STUSB1602 device.  */
USBPD_StatusTypeDef STUSB16xx_HW_IF_Send_Packet(uint8_t PortNum, uint8_t *pData, uint16_t Size)
/* It enables the data trasmission from microcontroller to STUSB1602 device.  */
USBPD_StatusTypeDef STUSB16xx_HW_IF_Send_Packet(uint8_t PortNum, uint8_t *pData, uint16_t Size)
{
  USBPD_StatusTypeDef ret = USBPD_ERROR;
  ret = HW_IF_check_bus_idle(PortNum);
  if (ret == USBPD_OK && 1)
  {
    Ports[PortNum].State = HAL_USBPD_PORT_STATE_BUSY_TX;
    STUSB16xx_HW_IF_Switch_Mode(PortNum, STUSB16xx_SPI_Mode_TX);
    HAL_SPI_DMAStop(&Ports[PortNum].hspi);
    __HAL_DMA_CLEAR_FLAG(hdma, 0x0FFFFFFF);
    HAL_SPI_Transmit_DMA(&Ports[PortNum].hspi, pData, Size);
    STUSB16xx_HW_IF_TX_EN_Status(PortNum, GPIO_PIN_SET);
  }
  else
  {
    __NOP();
  }
  return ret;
}