STM32L4xx_HAL_Driver  1.14.0
Input and Output operation functions

Data transfers functions. More...

Functions

HAL_StatusTypeDef HAL_PCD_Start (PCD_HandleTypeDef *hpcd)
 Start the USB device. More...
 
HAL_StatusTypeDef HAL_PCD_Stop (PCD_HandleTypeDef *hpcd)
 Stop the USB device. More...
 
void HAL_PCD_IRQHandler (PCD_HandleTypeDef *hpcd)
 Handles PCD interrupt request. More...
 
void HAL_PCD_SOFCallback (PCD_HandleTypeDef *hpcd)
 USB Start Of Frame callback. More...
 
void HAL_PCD_SetupStageCallback (PCD_HandleTypeDef *hpcd)
 Setup stage callback. More...
 
void HAL_PCD_ResetCallback (PCD_HandleTypeDef *hpcd)
 USB Reset callback. More...
 
void HAL_PCD_SuspendCallback (PCD_HandleTypeDef *hpcd)
 Suspend event callback. More...
 
void HAL_PCD_ResumeCallback (PCD_HandleTypeDef *hpcd)
 Resume event callback. More...
 
void HAL_PCD_ConnectCallback (PCD_HandleTypeDef *hpcd)
 Connection event callback. More...
 
void HAL_PCD_DisconnectCallback (PCD_HandleTypeDef *hpcd)
 Disconnection event callback. More...
 
void HAL_PCD_DataOutStageCallback (PCD_HandleTypeDef *hpcd, uint8_t epnum)
 Data OUT stage callback. More...
 
void HAL_PCD_DataInStageCallback (PCD_HandleTypeDef *hpcd, uint8_t epnum)
 Data IN stage callback. More...
 
void HAL_PCD_ISOOUTIncompleteCallback (PCD_HandleTypeDef *hpcd, uint8_t epnum)
 Incomplete ISO OUT callback. More...
 
void HAL_PCD_ISOINIncompleteCallback (PCD_HandleTypeDef *hpcd, uint8_t epnum)
 Incomplete ISO IN callback. More...
 

Detailed Description

Data transfers functions.

 ===============================================================================
                      ##### IO operation functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to manage the PCD data
    transfers.

Function Documentation

◆ HAL_PCD_ConnectCallback()

__weak void HAL_PCD_ConnectCallback ( PCD_HandleTypeDef hpcd)

Connection event callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1679 of file stm32l4xx_hal_pcd.c.

1680 {
1681  /* Prevent unused argument(s) compilation warning */
1682  UNUSED(hpcd);
1683 
1684  /* NOTE : This function should not be modified, when the callback is needed,
1685  the HAL_PCD_ConnectCallback could be implemented in the user file
1686  */
1687 }

◆ HAL_PCD_DataInStageCallback()

__weak void HAL_PCD_DataInStageCallback ( PCD_HandleTypeDef hpcd,
uint8_t  epnum 
)

Data IN stage callback.

Parameters
hpcdPCD handle
epnumendpoint number
Return values
None

Definition at line 1555 of file stm32l4xx_hal_pcd.c.

1556 {
1557  /* Prevent unused argument(s) compilation warning */
1558  UNUSED(hpcd);
1559  UNUSED(epnum);
1560 
1561  /* NOTE : This function should not be modified, when the callback is needed,
1562  the HAL_PCD_DataInStageCallback could be implemented in the user file
1563  */
1564 }

◆ HAL_PCD_DataOutStageCallback()

__weak void HAL_PCD_DataOutStageCallback ( PCD_HandleTypeDef hpcd,
uint8_t  epnum 
)

Data OUT stage callback.

Parameters
hpcdPCD handle
epnumendpoint number
Return values
None

Definition at line 1538 of file stm32l4xx_hal_pcd.c.

1539 {
1540  /* Prevent unused argument(s) compilation warning */
1541  UNUSED(hpcd);
1542  UNUSED(epnum);
1543 
1544  /* NOTE : This function should not be modified, when the callback is needed,
1545  the HAL_PCD_DataOutStageCallback could be implemented in the user file
1546  */
1547 }

◆ HAL_PCD_DisconnectCallback()

__weak void HAL_PCD_DisconnectCallback ( PCD_HandleTypeDef hpcd)

Disconnection event callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1694 of file stm32l4xx_hal_pcd.c.

1695 {
1696  /* Prevent unused argument(s) compilation warning */
1697  UNUSED(hpcd);
1698 
1699  /* NOTE : This function should not be modified, when the callback is needed,
1700  the HAL_PCD_DisconnectCallback could be implemented in the user file
1701  */
1702 }

◆ HAL_PCD_IRQHandler()

void HAL_PCD_IRQHandler ( PCD_HandleTypeDef hpcd)

Handles PCD interrupt request.

This function handles PCD interrupt request.

Parameters
hpcdPCD handle
Return values
HALstatus

Definition at line 1046 of file stm32l4xx_hal_pcd.c.

1047 {
1048  USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
1049  uint32_t USBx_BASE = (uint32_t)USBx;
1050  uint32_t i, ep_intr, epint, epnum = 0U;
1051  uint32_t fifoemptymsk, temp;
1052  USB_OTG_EPTypeDef *ep;
1053 
1054  /* ensure that we are in device mode */
1055  if (USB_GetMode(hpcd->Instance) == USB_OTG_MODE_DEVICE)
1056  {
1057  /* avoid spurious interrupt */
1058  if (__HAL_PCD_IS_INVALID_INTERRUPT(hpcd))
1059  {
1060  return;
1061  }
1062 
1063  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_MMIS))
1064  {
1065  /* incorrect mode, acknowledge the interrupt */
1066  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_MMIS);
1067  }
1068 
1069  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_OEPINT))
1070  {
1071  epnum = 0U;
1072 
1073  /* Read in the device interrupt bits */
1074  ep_intr = USB_ReadDevAllOutEpInterrupt(hpcd->Instance);
1075 
1076  while (ep_intr != 0U)
1077  {
1078  if ((ep_intr & 0x1U) != 0U)
1079  {
1080  epint = USB_ReadDevOutEPInterrupt(hpcd->Instance, (uint8_t)epnum);
1081 
1082  if ((epint & USB_OTG_DOEPINT_XFRC) == USB_OTG_DOEPINT_XFRC)
1083  {
1084  CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_XFRC);
1085  (void)PCD_EP_OutXfrComplete_int(hpcd, epnum);
1086  }
1087 
1088  if ((epint & USB_OTG_DOEPINT_STUP) == USB_OTG_DOEPINT_STUP)
1089  {
1090  /* Class B setup phase done for previous decoded setup */
1091  (void)PCD_EP_OutSetupPacket_int(hpcd, epnum);
1092  CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_STUP);
1093  }
1094 
1095  if ((epint & USB_OTG_DOEPINT_OTEPDIS) == USB_OTG_DOEPINT_OTEPDIS)
1096  {
1097  CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_OTEPDIS);
1098  }
1099 
1100  /* Clear Status Phase Received interrupt */
1101  if ((epint & USB_OTG_DOEPINT_OTEPSPR) == USB_OTG_DOEPINT_OTEPSPR)
1102  {
1103  CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_OTEPSPR);
1104  }
1105 
1106  /* Clear OUT NAK interrupt */
1107  if ((epint & USB_OTG_DOEPINT_NAK) == USB_OTG_DOEPINT_NAK)
1108  {
1109  CLEAR_OUT_EP_INTR(epnum, USB_OTG_DOEPINT_NAK);
1110  }
1111  }
1112  epnum++;
1113  ep_intr >>= 1U;
1114  }
1115  }
1116 
1117  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_IEPINT))
1118  {
1119  /* Read in the device interrupt bits */
1120  ep_intr = USB_ReadDevAllInEpInterrupt(hpcd->Instance);
1121 
1122  epnum = 0U;
1123 
1124  while (ep_intr != 0U)
1125  {
1126  if ((ep_intr & 0x1U) != 0U) /* In ITR */
1127  {
1128  epint = USB_ReadDevInEPInterrupt(hpcd->Instance, (uint8_t)epnum);
1129 
1130  if ((epint & USB_OTG_DIEPINT_XFRC) == USB_OTG_DIEPINT_XFRC)
1131  {
1132  fifoemptymsk = (uint32_t)(0x1UL << (epnum & EP_ADDR_MSK));
1133  USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk;
1134 
1135  CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_XFRC);
1136 
1137 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1138  hpcd->DataInStageCallback(hpcd, (uint8_t)epnum);
1139 #else
1140  HAL_PCD_DataInStageCallback(hpcd, (uint8_t)epnum);
1141 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1142  }
1143  if ((epint & USB_OTG_DIEPINT_TOC) == USB_OTG_DIEPINT_TOC)
1144  {
1145  CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_TOC);
1146  }
1147  if ((epint & USB_OTG_DIEPINT_ITTXFE) == USB_OTG_DIEPINT_ITTXFE)
1148  {
1149  CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_ITTXFE);
1150  }
1151  if ((epint & USB_OTG_DIEPINT_INEPNE) == USB_OTG_DIEPINT_INEPNE)
1152  {
1153  CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_INEPNE);
1154  }
1155  if ((epint & USB_OTG_DIEPINT_EPDISD) == USB_OTG_DIEPINT_EPDISD)
1156  {
1157  CLEAR_IN_EP_INTR(epnum, USB_OTG_DIEPINT_EPDISD);
1158  }
1159  if ((epint & USB_OTG_DIEPINT_TXFE) == USB_OTG_DIEPINT_TXFE)
1160  {
1161  (void)PCD_WriteEmptyTxFifo(hpcd, epnum);
1162  }
1163  }
1164  epnum++;
1165  ep_intr >>= 1U;
1166  }
1167  }
1168 
1169  /* Handle Resume Interrupt */
1170  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_WKUINT))
1171  {
1172  /* Clear the Remote Wake-up Signaling */
1173  USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_RWUSIG;
1174 
1175  if (hpcd->LPM_State == LPM_L1)
1176  {
1177  hpcd->LPM_State = LPM_L0;
1178 
1179 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1180  hpcd->LPMCallback(hpcd, PCD_LPM_L0_ACTIVE);
1181 #else
1183 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1184  }
1185  else
1186  {
1187 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1188  hpcd->ResumeCallback(hpcd);
1189 #else
1190  HAL_PCD_ResumeCallback(hpcd);
1191 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1192  }
1193 
1194  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_WKUINT);
1195  }
1196 
1197  /* Handle Suspend Interrupt */
1198  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP))
1199  {
1200  if ((USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS) == USB_OTG_DSTS_SUSPSTS)
1201  {
1202 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1203  hpcd->SuspendCallback(hpcd);
1204 #else
1206 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1207  }
1208  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBSUSP);
1209  }
1210 
1211  /* Handle LPM Interrupt */
1212  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_LPMINT))
1213  {
1214  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_LPMINT);
1215 
1216  if (hpcd->LPM_State == LPM_L0)
1217  {
1218  hpcd->LPM_State = LPM_L1;
1219  hpcd->BESL = (hpcd->Instance->GLPMCFG & USB_OTG_GLPMCFG_BESL) >> 2U;
1220 
1221 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1222  hpcd->LPMCallback(hpcd, PCD_LPM_L1_ACTIVE);
1223 #else
1225 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1226  }
1227  else
1228  {
1229 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1230  hpcd->SuspendCallback(hpcd);
1231 #else
1233 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1234  }
1235  }
1236 
1237  /* Handle Reset Interrupt */
1238  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_USBRST))
1239  {
1240  USBx_DEVICE->DCTL &= ~USB_OTG_DCTL_RWUSIG;
1241  (void)USB_FlushTxFifo(hpcd->Instance, 0x10U);
1242 
1243  for (i = 0U; i < hpcd->Init.dev_endpoints; i++)
1244  {
1245  USBx_INEP(i)->DIEPINT = 0xFB7FU;
1246  USBx_INEP(i)->DIEPCTL &= ~USB_OTG_DIEPCTL_STALL;
1247  USBx_OUTEP(i)->DOEPINT = 0xFB7FU;
1248  USBx_OUTEP(i)->DOEPCTL &= ~USB_OTG_DOEPCTL_STALL;
1249  }
1250  USBx_DEVICE->DAINTMSK |= 0x10001U;
1251 
1252  if (hpcd->Init.use_dedicated_ep1 != 0U)
1253  {
1254  USBx_DEVICE->DOUTEP1MSK |= USB_OTG_DOEPMSK_STUPM |
1255  USB_OTG_DOEPMSK_XFRCM |
1256  USB_OTG_DOEPMSK_EPDM;
1257 
1258  USBx_DEVICE->DINEP1MSK |= USB_OTG_DIEPMSK_TOM |
1259  USB_OTG_DIEPMSK_XFRCM |
1260  USB_OTG_DIEPMSK_EPDM;
1261  }
1262  else
1263  {
1264  USBx_DEVICE->DOEPMSK |= USB_OTG_DOEPMSK_STUPM |
1265  USB_OTG_DOEPMSK_XFRCM |
1266  USB_OTG_DOEPMSK_EPDM |
1267  USB_OTG_DOEPMSK_OTEPSPRM |
1268  USB_OTG_DOEPMSK_NAKM;
1269 
1270  USBx_DEVICE->DIEPMSK |= USB_OTG_DIEPMSK_TOM |
1271  USB_OTG_DIEPMSK_XFRCM |
1272  USB_OTG_DIEPMSK_EPDM;
1273  }
1274 
1275  /* Set Default Address to 0 */
1276  USBx_DEVICE->DCFG &= ~USB_OTG_DCFG_DAD;
1277 
1278  /* setup EP0 to receive SETUP packets */
1279  (void)USB_EP0_OutStart(hpcd->Instance, (uint8_t *)hpcd->Setup);
1280 
1281  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_USBRST);
1282  }
1283 
1284  /* Handle Enumeration done Interrupt */
1285  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_ENUMDNE))
1286  {
1287  (void)USB_ActivateSetup(hpcd->Instance);
1288  hpcd->Init.speed = USB_GetDevSpeed(hpcd->Instance);
1289 
1290  /* Set USB Turnaround time */
1291  (void)USB_SetTurnaroundTime(hpcd->Instance,
1293  (uint8_t)hpcd->Init.speed);
1294 
1295 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1296  hpcd->ResetCallback(hpcd);
1297 #else
1298  HAL_PCD_ResetCallback(hpcd);
1299 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1300 
1301  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_ENUMDNE);
1302  }
1303 
1304  /* Handle RxQLevel Interrupt */
1305  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_RXFLVL))
1306  {
1307  USB_MASK_INTERRUPT(hpcd->Instance, USB_OTG_GINTSTS_RXFLVL);
1308 
1309  temp = USBx->GRXSTSP;
1310 
1311  ep = &hpcd->OUT_ep[temp & USB_OTG_GRXSTSP_EPNUM];
1312 
1313  if (((temp & USB_OTG_GRXSTSP_PKTSTS) >> 17) == STS_DATA_UPDT)
1314  {
1315  if ((temp & USB_OTG_GRXSTSP_BCNT) != 0U)
1316  {
1317  (void)USB_ReadPacket(USBx, ep->xfer_buff,
1318  (uint16_t)((temp & USB_OTG_GRXSTSP_BCNT) >> 4));
1319 
1320  ep->xfer_buff += (temp & USB_OTG_GRXSTSP_BCNT) >> 4;
1321  ep->xfer_count += (temp & USB_OTG_GRXSTSP_BCNT) >> 4;
1322  }
1323  }
1324  else if (((temp & USB_OTG_GRXSTSP_PKTSTS) >> 17) == STS_SETUP_UPDT)
1325  {
1326  (void)USB_ReadPacket(USBx, (uint8_t *)hpcd->Setup, 8U);
1327  ep->xfer_count += (temp & USB_OTG_GRXSTSP_BCNT) >> 4;
1328  }
1329  else
1330  {
1331  /* ... */
1332  }
1333  USB_UNMASK_INTERRUPT(hpcd->Instance, USB_OTG_GINTSTS_RXFLVL);
1334  }
1335 
1336  /* Handle SOF Interrupt */
1337  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_SOF))
1338  {
1339 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1340  hpcd->SOFCallback(hpcd);
1341 #else
1342  HAL_PCD_SOFCallback(hpcd);
1343 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1344 
1345  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_SOF);
1346  }
1347 
1348  /* Handle Incomplete ISO IN Interrupt */
1349  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_IISOIXFR))
1350  {
1351 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1352  hpcd->ISOINIncompleteCallback(hpcd, (uint8_t)epnum);
1353 #else
1354  HAL_PCD_ISOINIncompleteCallback(hpcd, (uint8_t)epnum);
1355 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1356 
1357  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_IISOIXFR);
1358  }
1359 
1360  /* Handle Incomplete ISO OUT Interrupt */
1361  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_PXFR_INCOMPISOOUT))
1362  {
1363 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1364  hpcd->ISOOUTIncompleteCallback(hpcd, (uint8_t)epnum);
1365 #else
1366  HAL_PCD_ISOOUTIncompleteCallback(hpcd, (uint8_t)epnum);
1367 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1368 
1369  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_PXFR_INCOMPISOOUT);
1370  }
1371 
1372  /* Handle Connection event Interrupt */
1373  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_SRQINT))
1374  {
1375 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1376  hpcd->ConnectCallback(hpcd);
1377 #else
1379 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1380 
1381  __HAL_PCD_CLEAR_FLAG(hpcd, USB_OTG_GINTSTS_SRQINT);
1382  }
1383 
1384  /* Handle Disconnection event Interrupt */
1385  if (__HAL_PCD_GET_FLAG(hpcd, USB_OTG_GINTSTS_OTGINT))
1386  {
1387  temp = hpcd->Instance->GOTGINT;
1388 
1389  if ((temp & USB_OTG_GOTGINT_SEDET) == USB_OTG_GOTGINT_SEDET)
1390  {
1391 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
1392  hpcd->DisconnectCallback(hpcd);
1393 #else
1395 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
1396  }
1397  hpcd->Instance->GOTGINT |= temp;
1398  }
1399  }
1400 }
static HAL_StatusTypeDef PCD_EP_OutSetupPacket_int(PCD_HandleTypeDef *hpcd, uint32_t epnum)
process EP OUT setup packet received interrupt.
uint32_t USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum)
Returns Device OUT EP Interrupt register.
void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
Resume event callback.
void * USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len)
USB_ReadPacket : read a packet from the RX FIFO.
HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup)
Prepare the EP0 to start the first control setup.
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
USB Start Of Frame callback.
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Incomplete ISO IN callback.
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Data IN stage callback.
HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx)
Activate EP0 for Setup transactions.
uint32_t USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx)
USB_ReadDevAllOutEpInterrupt: return the USB device OUT endpoints interrupt status.
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
USB Reset callback.
void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Incomplete ISO OUT callback.
static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t epnum)
Check FIFO for the next packet to be loaded.
uint32_t USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum)
Returns Device IN EP Interrupt register.
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
Suspend event callback.
uint32_t USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx)
USB_ReadDevAllInEpInterrupt: return the USB device IN endpoints interrupt status. ...
static HAL_StatusTypeDef PCD_EP_OutXfrComplete_int(PCD_HandleTypeDef *hpcd, uint32_t epnum)
process EP OUT transfer complete interrupt.
HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed)
Set the USB turnaround time.
uint32_t HAL_RCC_GetHCLKFreq(void)
Return the HCLK frequency.
void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
Send LPM message to user layer callback.
uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx)
USB_GetDevSpeed Return the Dev Speed.
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
Disconnection event callback.
HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num)
USB_OTG_FlushTxFifo : Flush a Tx FIFO.
void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
Connection event callback.
uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx)
Returns USB core mode.

◆ HAL_PCD_ISOINIncompleteCallback()

__weak void HAL_PCD_ISOINIncompleteCallback ( PCD_HandleTypeDef hpcd,
uint8_t  epnum 
)

Incomplete ISO IN callback.

Parameters
hpcdPCD handle
epnumendpoint number
Return values
None

Definition at line 1663 of file stm32l4xx_hal_pcd.c.

1664 {
1665  /* Prevent unused argument(s) compilation warning */
1666  UNUSED(hpcd);
1667  UNUSED(epnum);
1668 
1669  /* NOTE : This function should not be modified, when the callback is needed,
1670  the HAL_PCD_ISOINIncompleteCallback could be implemented in the user file
1671  */
1672 }

◆ HAL_PCD_ISOOUTIncompleteCallback()

__weak void HAL_PCD_ISOOUTIncompleteCallback ( PCD_HandleTypeDef hpcd,
uint8_t  epnum 
)

Incomplete ISO OUT callback.

Parameters
hpcdPCD handle
epnumendpoint number
Return values
None

Definition at line 1646 of file stm32l4xx_hal_pcd.c.

1647 {
1648  /* Prevent unused argument(s) compilation warning */
1649  UNUSED(hpcd);
1650  UNUSED(epnum);
1651 
1652  /* NOTE : This function should not be modified, when the callback is needed,
1653  the HAL_PCD_ISOOUTIncompleteCallback could be implemented in the user file
1654  */
1655 }

◆ HAL_PCD_ResetCallback()

__weak void HAL_PCD_ResetCallback ( PCD_HandleTypeDef hpcd)

USB Reset callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1600 of file stm32l4xx_hal_pcd.c.

1601 {
1602  /* Prevent unused argument(s) compilation warning */
1603  UNUSED(hpcd);
1604 
1605  /* NOTE : This function should not be modified, when the callback is needed,
1606  the HAL_PCD_ResetCallback could be implemented in the user file
1607  */
1608 }

◆ HAL_PCD_ResumeCallback()

__weak void HAL_PCD_ResumeCallback ( PCD_HandleTypeDef hpcd)

Resume event callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1630 of file stm32l4xx_hal_pcd.c.

1631 {
1632  /* Prevent unused argument(s) compilation warning */
1633  UNUSED(hpcd);
1634 
1635  /* NOTE : This function should not be modified, when the callback is needed,
1636  the HAL_PCD_ResumeCallback could be implemented in the user file
1637  */
1638 }

◆ HAL_PCD_SetupStageCallback()

__weak void HAL_PCD_SetupStageCallback ( PCD_HandleTypeDef hpcd)

Setup stage callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1570 of file stm32l4xx_hal_pcd.c.

1571 {
1572  /* Prevent unused argument(s) compilation warning */
1573  UNUSED(hpcd);
1574 
1575  /* NOTE : This function should not be modified, when the callback is needed,
1576  the HAL_PCD_SetupStageCallback could be implemented in the user file
1577  */
1578 }

◆ HAL_PCD_SOFCallback()

__weak void HAL_PCD_SOFCallback ( PCD_HandleTypeDef hpcd)

USB Start Of Frame callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1585 of file stm32l4xx_hal_pcd.c.

1586 {
1587  /* Prevent unused argument(s) compilation warning */
1588  UNUSED(hpcd);
1589 
1590  /* NOTE : This function should not be modified, when the callback is needed,
1591  the HAL_PCD_SOFCallback could be implemented in the user file
1592  */
1593 }

◆ HAL_PCD_Start()

HAL_StatusTypeDef HAL_PCD_Start ( PCD_HandleTypeDef hpcd)

Start the USB device.

Parameters
hpcdPCD handle
Return values
HALstatus

Definition at line 999 of file stm32l4xx_hal_pcd.c.

1000 {
1001 #if defined (USB_OTG_FS)
1002  USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
1003 #endif /* defined (USB_OTG_FS) */
1004 
1005  __HAL_LOCK(hpcd);
1006 #if defined (USB_OTG_FS)
1007  if (hpcd->Init.battery_charging_enable == 1U)
1008  {
1009  /* Enable USB Transceiver */
1010  USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN;
1011  }
1012 #endif /* defined (USB_OTG_FS) */
1013  (void)USB_DevConnect(hpcd->Instance);
1014  __HAL_PCD_ENABLE(hpcd);
1015  __HAL_UNLOCK(hpcd);
1016  return HAL_OK;
1017 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx)
USB_DevConnect : Connect the USB device by enabling the pull-up/pull-down.

◆ HAL_PCD_Stop()

HAL_StatusTypeDef HAL_PCD_Stop ( PCD_HandleTypeDef hpcd)

Stop the USB device.

Parameters
hpcdPCD handle
Return values
HALstatus

Definition at line 1024 of file stm32l4xx_hal_pcd.c.

1025 {
1026  __HAL_LOCK(hpcd);
1027  __HAL_PCD_DISABLE(hpcd);
1028 
1029  if (USB_StopDevice(hpcd->Instance) != HAL_OK)
1030  {
1031  __HAL_UNLOCK(hpcd);
1032  return HAL_ERROR;
1033  }
1034 
1035  (void)USB_DevDisconnect(hpcd->Instance);
1036  __HAL_UNLOCK(hpcd);
1037 
1038  return HAL_OK;
1039 }
__HAL_UNLOCK(hrtc)
HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx)
USB_StopDevice : Stop the usb device mode.
__HAL_LOCK(hrtc)
return HAL_OK
HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx)
USB_DevDisconnect : Disconnect the USB device by disabling the pull-up/pull-down. ...

◆ HAL_PCD_SuspendCallback()

__weak void HAL_PCD_SuspendCallback ( PCD_HandleTypeDef hpcd)

Suspend event callback.

Parameters
hpcdPCD handle
Return values
None

Definition at line 1615 of file stm32l4xx_hal_pcd.c.

1616 {
1617  /* Prevent unused argument(s) compilation warning */
1618  UNUSED(hpcd);
1619 
1620  /* NOTE : This function should not be modified, when the callback is needed,
1621  the HAL_PCD_SuspendCallback could be implemented in the user file
1622  */
1623 }