Lines Matching refs:hpcd

90 static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd);
92 static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd, PCD_EPTypeDef *ep, uint16_…
93 static uint16_t HAL_PCD_EP_DB_Receive(PCD_HandleTypeDef *hpcd, PCD_EPTypeDef *ep, uint16_t wEPVal);
124 HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd) in HAL_PCD_Init() argument
129 if (hpcd == NULL) in HAL_PCD_Init()
135 assert_param(IS_PCD_ALL_INSTANCE(hpcd->Instance)); in HAL_PCD_Init()
137 if (hpcd->State == HAL_PCD_STATE_RESET) in HAL_PCD_Init()
140 hpcd->Lock = HAL_UNLOCKED; in HAL_PCD_Init()
143 hpcd->SOFCallback = HAL_PCD_SOFCallback; in HAL_PCD_Init()
144 hpcd->SetupStageCallback = HAL_PCD_SetupStageCallback; in HAL_PCD_Init()
145 hpcd->ResetCallback = HAL_PCD_ResetCallback; in HAL_PCD_Init()
146 hpcd->SuspendCallback = HAL_PCD_SuspendCallback; in HAL_PCD_Init()
147 hpcd->ResumeCallback = HAL_PCD_ResumeCallback; in HAL_PCD_Init()
148 hpcd->ConnectCallback = HAL_PCD_ConnectCallback; in HAL_PCD_Init()
149 hpcd->DisconnectCallback = HAL_PCD_DisconnectCallback; in HAL_PCD_Init()
150 hpcd->DataOutStageCallback = HAL_PCD_DataOutStageCallback; in HAL_PCD_Init()
151 hpcd->DataInStageCallback = HAL_PCD_DataInStageCallback; in HAL_PCD_Init()
152 hpcd->ISOOUTIncompleteCallback = HAL_PCD_ISOOUTIncompleteCallback; in HAL_PCD_Init()
153 hpcd->ISOINIncompleteCallback = HAL_PCD_ISOINIncompleteCallback; in HAL_PCD_Init()
154 hpcd->LPMCallback = HAL_PCDEx_LPM_Callback; in HAL_PCD_Init()
155 hpcd->BCDCallback = HAL_PCDEx_BCD_Callback; in HAL_PCD_Init()
157 if (hpcd->MspInitCallback == NULL) in HAL_PCD_Init()
159 hpcd->MspInitCallback = HAL_PCD_MspInit; in HAL_PCD_Init()
163 hpcd->MspInitCallback(hpcd); in HAL_PCD_Init()
166 HAL_PCD_MspInit(hpcd); in HAL_PCD_Init()
170 hpcd->State = HAL_PCD_STATE_BUSY; in HAL_PCD_Init()
173 __HAL_PCD_DISABLE(hpcd); in HAL_PCD_Init()
176 for (i = 0U; i < hpcd->Init.dev_endpoints; i++) in HAL_PCD_Init()
179 hpcd->IN_ep[i].is_in = 1U; in HAL_PCD_Init()
180 hpcd->IN_ep[i].num = i; in HAL_PCD_Init()
182 hpcd->IN_ep[i].type = EP_TYPE_CTRL; in HAL_PCD_Init()
183 hpcd->IN_ep[i].maxpacket = 0U; in HAL_PCD_Init()
184 hpcd->IN_ep[i].xfer_buff = 0U; in HAL_PCD_Init()
185 hpcd->IN_ep[i].xfer_len = 0U; in HAL_PCD_Init()
188 for (i = 0U; i < hpcd->Init.dev_endpoints; i++) in HAL_PCD_Init()
190 hpcd->OUT_ep[i].is_in = 0U; in HAL_PCD_Init()
191 hpcd->OUT_ep[i].num = i; in HAL_PCD_Init()
193 hpcd->OUT_ep[i].type = EP_TYPE_CTRL; in HAL_PCD_Init()
194 hpcd->OUT_ep[i].maxpacket = 0U; in HAL_PCD_Init()
195 hpcd->OUT_ep[i].xfer_buff = 0U; in HAL_PCD_Init()
196 hpcd->OUT_ep[i].xfer_len = 0U; in HAL_PCD_Init()
200 (void)USB_DevInit(hpcd->Instance, hpcd->Init); in HAL_PCD_Init()
202 hpcd->USB_Address = 0U; in HAL_PCD_Init()
203 hpcd->State = HAL_PCD_STATE_READY; in HAL_PCD_Init()
206 if (hpcd->Init.lpm_enable == 1U) in HAL_PCD_Init()
208 (void)HAL_PCDEx_ActivateLPM(hpcd); in HAL_PCD_Init()
219 HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd) in HAL_PCD_DeInit() argument
222 if (hpcd == NULL) in HAL_PCD_DeInit()
227 hpcd->State = HAL_PCD_STATE_BUSY; in HAL_PCD_DeInit()
230 if (USB_StopDevice(hpcd->Instance) != HAL_OK) in HAL_PCD_DeInit()
236 if (hpcd->MspDeInitCallback == NULL) in HAL_PCD_DeInit()
238 hpcd->MspDeInitCallback = HAL_PCD_MspDeInit; /* Legacy weak MspDeInit */ in HAL_PCD_DeInit()
242 hpcd->MspDeInitCallback(hpcd); in HAL_PCD_DeInit()
245 HAL_PCD_MspDeInit(hpcd); in HAL_PCD_DeInit()
248 hpcd->State = HAL_PCD_STATE_RESET; in HAL_PCD_DeInit()
258 __weak void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) in HAL_PCD_MspInit() argument
261 UNUSED(hpcd); in HAL_PCD_MspInit()
273 __weak void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd) in HAL_PCD_MspDeInit() argument
276 UNUSED(hpcd); in HAL_PCD_MspDeInit()
302 HAL_StatusTypeDef HAL_PCD_RegisterCallback(PCD_HandleTypeDef *hpcd, in HAL_PCD_RegisterCallback() argument
311 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterCallback()
315 __HAL_LOCK(hpcd); in HAL_PCD_RegisterCallback()
317 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterCallback()
322 hpcd->SOFCallback = pCallback; in HAL_PCD_RegisterCallback()
326 hpcd->SetupStageCallback = pCallback; in HAL_PCD_RegisterCallback()
330 hpcd->ResetCallback = pCallback; in HAL_PCD_RegisterCallback()
334 hpcd->SuspendCallback = pCallback; in HAL_PCD_RegisterCallback()
338 hpcd->ResumeCallback = pCallback; in HAL_PCD_RegisterCallback()
342 hpcd->ConnectCallback = pCallback; in HAL_PCD_RegisterCallback()
346 hpcd->DisconnectCallback = pCallback; in HAL_PCD_RegisterCallback()
350 hpcd->MspInitCallback = pCallback; in HAL_PCD_RegisterCallback()
354 hpcd->MspDeInitCallback = pCallback; in HAL_PCD_RegisterCallback()
359 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterCallback()
365 else if (hpcd->State == HAL_PCD_STATE_RESET) in HAL_PCD_RegisterCallback()
370 hpcd->MspInitCallback = pCallback; in HAL_PCD_RegisterCallback()
374 hpcd->MspDeInitCallback = pCallback; in HAL_PCD_RegisterCallback()
379 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterCallback()
388 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterCallback()
394 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterCallback()
415 HAL_StatusTypeDef HAL_PCD_UnRegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef Cal… in HAL_PCD_UnRegisterCallback() argument
420 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterCallback()
423 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterCallback()
428 hpcd->SOFCallback = HAL_PCD_SOFCallback; in HAL_PCD_UnRegisterCallback()
432 hpcd->SetupStageCallback = HAL_PCD_SetupStageCallback; in HAL_PCD_UnRegisterCallback()
436 hpcd->ResetCallback = HAL_PCD_ResetCallback; in HAL_PCD_UnRegisterCallback()
440 hpcd->SuspendCallback = HAL_PCD_SuspendCallback; in HAL_PCD_UnRegisterCallback()
444 hpcd->ResumeCallback = HAL_PCD_ResumeCallback; in HAL_PCD_UnRegisterCallback()
448 hpcd->ConnectCallback = HAL_PCD_ConnectCallback; in HAL_PCD_UnRegisterCallback()
452 hpcd->DisconnectCallback = HAL_PCD_DisconnectCallback; in HAL_PCD_UnRegisterCallback()
456 hpcd->MspInitCallback = HAL_PCD_MspInit; in HAL_PCD_UnRegisterCallback()
460 hpcd->MspDeInitCallback = HAL_PCD_MspDeInit; in HAL_PCD_UnRegisterCallback()
465 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterCallback()
472 else if (hpcd->State == HAL_PCD_STATE_RESET) in HAL_PCD_UnRegisterCallback()
477 hpcd->MspInitCallback = HAL_PCD_MspInit; in HAL_PCD_UnRegisterCallback()
481 hpcd->MspDeInitCallback = HAL_PCD_MspDeInit; in HAL_PCD_UnRegisterCallback()
486 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterCallback()
496 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterCallback()
503 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterCallback()
514 HAL_StatusTypeDef HAL_PCD_RegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd, in HAL_PCD_RegisterDataOutStageCallback() argument
522 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterDataOutStageCallback()
528 __HAL_LOCK(hpcd); in HAL_PCD_RegisterDataOutStageCallback()
530 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterDataOutStageCallback()
532 hpcd->DataOutStageCallback = pCallback; in HAL_PCD_RegisterDataOutStageCallback()
537 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterDataOutStageCallback()
544 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterDataOutStageCallback()
555 HAL_StatusTypeDef HAL_PCD_UnRegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_UnRegisterDataOutStageCallback() argument
560 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterDataOutStageCallback()
562 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterDataOutStageCallback()
564hpcd->DataOutStageCallback = HAL_PCD_DataOutStageCallback; /* Legacy weak DataOutStageCallback */ in HAL_PCD_UnRegisterDataOutStageCallback()
569 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterDataOutStageCallback()
576 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterDataOutStageCallback()
588 HAL_StatusTypeDef HAL_PCD_RegisterDataInStageCallback(PCD_HandleTypeDef *hpcd, in HAL_PCD_RegisterDataInStageCallback() argument
596 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterDataInStageCallback()
602 __HAL_LOCK(hpcd); in HAL_PCD_RegisterDataInStageCallback()
604 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterDataInStageCallback()
606 hpcd->DataInStageCallback = pCallback; in HAL_PCD_RegisterDataInStageCallback()
611 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterDataInStageCallback()
618 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterDataInStageCallback()
629 HAL_StatusTypeDef HAL_PCD_UnRegisterDataInStageCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_UnRegisterDataInStageCallback() argument
634 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterDataInStageCallback()
636 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterDataInStageCallback()
638 hpcd->DataInStageCallback = HAL_PCD_DataInStageCallback; /* Legacy weak DataInStageCallback */ in HAL_PCD_UnRegisterDataInStageCallback()
643 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterDataInStageCallback()
650 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterDataInStageCallback()
662 HAL_StatusTypeDef HAL_PCD_RegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd, in HAL_PCD_RegisterIsoOutIncpltCallback() argument
670 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterIsoOutIncpltCallback()
676 __HAL_LOCK(hpcd); in HAL_PCD_RegisterIsoOutIncpltCallback()
678 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterIsoOutIncpltCallback()
680 hpcd->ISOOUTIncompleteCallback = pCallback; in HAL_PCD_RegisterIsoOutIncpltCallback()
685 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterIsoOutIncpltCallback()
692 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterIsoOutIncpltCallback()
704 HAL_StatusTypeDef HAL_PCD_UnRegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_UnRegisterIsoOutIncpltCallback() argument
709 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterIsoOutIncpltCallback()
711 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterIsoOutIncpltCallback()
713hpcd->ISOOUTIncompleteCallback = HAL_PCD_ISOOUTIncompleteCallback; /* Legacy weak ISOOUTIncomplete… in HAL_PCD_UnRegisterIsoOutIncpltCallback()
718 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterIsoOutIncpltCallback()
725 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterIsoOutIncpltCallback()
737 HAL_StatusTypeDef HAL_PCD_RegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd, in HAL_PCD_RegisterIsoInIncpltCallback() argument
745 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterIsoInIncpltCallback()
751 __HAL_LOCK(hpcd); in HAL_PCD_RegisterIsoInIncpltCallback()
753 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterIsoInIncpltCallback()
755 hpcd->ISOINIncompleteCallback = pCallback; in HAL_PCD_RegisterIsoInIncpltCallback()
760 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterIsoInIncpltCallback()
767 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterIsoInIncpltCallback()
779 HAL_StatusTypeDef HAL_PCD_UnRegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_UnRegisterIsoInIncpltCallback() argument
784 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterIsoInIncpltCallback()
786 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterIsoInIncpltCallback()
788hpcd->ISOINIncompleteCallback = HAL_PCD_ISOINIncompleteCallback; /* Legacy weak ISOINIncompleteCal… in HAL_PCD_UnRegisterIsoInIncpltCallback()
793 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterIsoInIncpltCallback()
800 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterIsoInIncpltCallback()
812 HAL_StatusTypeDef HAL_PCD_RegisterBcdCallback(PCD_HandleTypeDef *hpcd, pPCD_BcdCallbackTypeDef pCal… in HAL_PCD_RegisterBcdCallback() argument
819 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterBcdCallback()
825 __HAL_LOCK(hpcd); in HAL_PCD_RegisterBcdCallback()
827 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterBcdCallback()
829 hpcd->BCDCallback = pCallback; in HAL_PCD_RegisterBcdCallback()
834 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterBcdCallback()
841 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterBcdCallback()
852 HAL_StatusTypeDef HAL_PCD_UnRegisterBcdCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_UnRegisterBcdCallback() argument
857 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterBcdCallback()
859 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterBcdCallback()
861 hpcd->BCDCallback = HAL_PCDEx_BCD_Callback; /* Legacy weak HAL_PCDEx_BCD_Callback */ in HAL_PCD_UnRegisterBcdCallback()
866 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterBcdCallback()
873 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterBcdCallback()
885 HAL_StatusTypeDef HAL_PCD_RegisterLpmCallback(PCD_HandleTypeDef *hpcd, pPCD_LpmCallbackTypeDef pCal… in HAL_PCD_RegisterLpmCallback() argument
892 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterLpmCallback()
898 __HAL_LOCK(hpcd); in HAL_PCD_RegisterLpmCallback()
900 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_RegisterLpmCallback()
902 hpcd->LPMCallback = pCallback; in HAL_PCD_RegisterLpmCallback()
907 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_RegisterLpmCallback()
914 __HAL_UNLOCK(hpcd); in HAL_PCD_RegisterLpmCallback()
925 HAL_StatusTypeDef HAL_PCD_UnRegisterLpmCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_UnRegisterLpmCallback() argument
930 __HAL_LOCK(hpcd); in HAL_PCD_UnRegisterLpmCallback()
932 if (hpcd->State == HAL_PCD_STATE_READY) in HAL_PCD_UnRegisterLpmCallback()
934 hpcd->LPMCallback = HAL_PCDEx_LPM_Callback; /* Legacy weak HAL_PCDEx_LPM_Callback */ in HAL_PCD_UnRegisterLpmCallback()
939 hpcd->ErrorCode |= HAL_PCD_ERROR_INVALID_CALLBACK; in HAL_PCD_UnRegisterLpmCallback()
946 __HAL_UNLOCK(hpcd); in HAL_PCD_UnRegisterLpmCallback()
976 HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd) in HAL_PCD_Start() argument
978 __HAL_LOCK(hpcd); in HAL_PCD_Start()
979 __HAL_PCD_ENABLE(hpcd); in HAL_PCD_Start()
980 (void)USB_DevConnect(hpcd->Instance); in HAL_PCD_Start()
981 __HAL_UNLOCK(hpcd); in HAL_PCD_Start()
991 HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd) in HAL_PCD_Stop() argument
993 __HAL_LOCK(hpcd); in HAL_PCD_Stop()
994 __HAL_PCD_DISABLE(hpcd); in HAL_PCD_Stop()
995 (void)USB_DevDisconnect(hpcd->Instance); in HAL_PCD_Stop()
996 __HAL_UNLOCK(hpcd); in HAL_PCD_Stop()
1007 void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) in HAL_PCD_IRQHandler() argument
1009 uint32_t wIstr = USB_ReadInterrupts(hpcd->Instance); in HAL_PCD_IRQHandler()
1015 (void)PCD_EP_ISR_Handler(hpcd); in HAL_PCD_IRQHandler()
1022 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_RESET); in HAL_PCD_IRQHandler()
1025 hpcd->ResetCallback(hpcd); in HAL_PCD_IRQHandler()
1027 HAL_PCD_ResetCallback(hpcd); in HAL_PCD_IRQHandler()
1030 (void)HAL_PCD_SetAddress(hpcd, 0U); in HAL_PCD_IRQHandler()
1037 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_PMAOVR); in HAL_PCD_IRQHandler()
1044 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_ERR); in HAL_PCD_IRQHandler()
1051 hpcd->Instance->CNTR &= (uint16_t) ~(USB_CNTR_LPMODE); in HAL_PCD_IRQHandler()
1052 hpcd->Instance->CNTR &= (uint16_t) ~(USB_CNTR_FSUSP); in HAL_PCD_IRQHandler()
1054 if (hpcd->LPM_State == LPM_L1) in HAL_PCD_IRQHandler()
1056 hpcd->LPM_State = LPM_L0; in HAL_PCD_IRQHandler()
1058 hpcd->LPMCallback(hpcd, PCD_LPM_L0_ACTIVE); in HAL_PCD_IRQHandler()
1060 HAL_PCDEx_LPM_Callback(hpcd, PCD_LPM_L0_ACTIVE); in HAL_PCD_IRQHandler()
1065 hpcd->ResumeCallback(hpcd); in HAL_PCD_IRQHandler()
1067 HAL_PCD_ResumeCallback(hpcd); in HAL_PCD_IRQHandler()
1070 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_WKUP); in HAL_PCD_IRQHandler()
1078 hpcd->Instance->CNTR |= (uint16_t)USB_CNTR_FSUSP; in HAL_PCD_IRQHandler()
1081 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_SUSP); in HAL_PCD_IRQHandler()
1083 hpcd->Instance->CNTR |= (uint16_t)USB_CNTR_LPMODE; in HAL_PCD_IRQHandler()
1086 hpcd->SuspendCallback(hpcd); in HAL_PCD_IRQHandler()
1088 HAL_PCD_SuspendCallback(hpcd); in HAL_PCD_IRQHandler()
1097 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_L1REQ); in HAL_PCD_IRQHandler()
1098 if (hpcd->LPM_State == LPM_L0) in HAL_PCD_IRQHandler()
1101 hpcd->Instance->CNTR |= (uint16_t)USB_CNTR_LPMODE; in HAL_PCD_IRQHandler()
1102 hpcd->Instance->CNTR |= (uint16_t)USB_CNTR_FSUSP; in HAL_PCD_IRQHandler()
1104 hpcd->LPM_State = LPM_L1; in HAL_PCD_IRQHandler()
1105 hpcd->BESL = ((uint32_t)hpcd->Instance->LPMCSR & USB_LPMCSR_BESL) >> 2; in HAL_PCD_IRQHandler()
1107 hpcd->LPMCallback(hpcd, PCD_LPM_L1_ACTIVE); in HAL_PCD_IRQHandler()
1109 HAL_PCDEx_LPM_Callback(hpcd, PCD_LPM_L1_ACTIVE); in HAL_PCD_IRQHandler()
1115 hpcd->SuspendCallback(hpcd); in HAL_PCD_IRQHandler()
1117 HAL_PCD_SuspendCallback(hpcd); in HAL_PCD_IRQHandler()
1126 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_SOF); in HAL_PCD_IRQHandler()
1129 hpcd->SOFCallback(hpcd); in HAL_PCD_IRQHandler()
1131 HAL_PCD_SOFCallback(hpcd); in HAL_PCD_IRQHandler()
1140 __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_ESOF); in HAL_PCD_IRQHandler()
1153 __weak void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) in HAL_PCD_DataOutStageCallback() argument
1156 UNUSED(hpcd); in HAL_PCD_DataOutStageCallback()
1170 __weak void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) in HAL_PCD_DataInStageCallback() argument
1173 UNUSED(hpcd); in HAL_PCD_DataInStageCallback()
1185 __weak void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_SetupStageCallback() argument
1188 UNUSED(hpcd); in HAL_PCD_SetupStageCallback()
1200 __weak void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_SOFCallback() argument
1203 UNUSED(hpcd); in HAL_PCD_SOFCallback()
1215 __weak void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_ResetCallback() argument
1218 UNUSED(hpcd); in HAL_PCD_ResetCallback()
1230 __weak void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_SuspendCallback() argument
1233 UNUSED(hpcd); in HAL_PCD_SuspendCallback()
1245 __weak void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_ResumeCallback() argument
1248 UNUSED(hpcd); in HAL_PCD_ResumeCallback()
1261 __weak void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) in HAL_PCD_ISOOUTIncompleteCallback() argument
1264 UNUSED(hpcd); in HAL_PCD_ISOOUTIncompleteCallback()
1278 __weak void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) in HAL_PCD_ISOINIncompleteCallback() argument
1281 UNUSED(hpcd); in HAL_PCD_ISOINIncompleteCallback()
1294 __weak void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_ConnectCallback() argument
1297 UNUSED(hpcd); in HAL_PCD_ConnectCallback()
1309 __weak void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) in HAL_PCD_DisconnectCallback() argument
1312 UNUSED(hpcd); in HAL_PCD_DisconnectCallback()
1343 HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd) in HAL_PCD_DevConnect() argument
1345 __HAL_LOCK(hpcd); in HAL_PCD_DevConnect()
1346 (void)USB_DevConnect(hpcd->Instance); in HAL_PCD_DevConnect()
1347 __HAL_UNLOCK(hpcd); in HAL_PCD_DevConnect()
1357 HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd) in HAL_PCD_DevDisconnect() argument
1359 __HAL_LOCK(hpcd); in HAL_PCD_DevDisconnect()
1360 (void)USB_DevDisconnect(hpcd->Instance); in HAL_PCD_DevDisconnect()
1361 __HAL_UNLOCK(hpcd); in HAL_PCD_DevDisconnect()
1372 HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address) in HAL_PCD_SetAddress() argument
1374 __HAL_LOCK(hpcd); in HAL_PCD_SetAddress()
1375 hpcd->USB_Address = address; in HAL_PCD_SetAddress()
1376 (void)USB_SetDevAddress(hpcd->Instance, address); in HAL_PCD_SetAddress()
1377 __HAL_UNLOCK(hpcd); in HAL_PCD_SetAddress()
1389 HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, in HAL_PCD_EP_Open() argument
1397 ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Open()
1402 ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Open()
1416 __HAL_LOCK(hpcd); in HAL_PCD_EP_Open()
1417 (void)USB_ActivateEndpoint(hpcd->Instance, ep); in HAL_PCD_EP_Open()
1418 __HAL_UNLOCK(hpcd); in HAL_PCD_EP_Open()
1429 HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) in HAL_PCD_EP_Close() argument
1435 ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Close()
1440 ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Close()
1445 __HAL_LOCK(hpcd); in HAL_PCD_EP_Close()
1446 (void)USB_DeactivateEndpoint(hpcd->Instance, ep); in HAL_PCD_EP_Close()
1447 __HAL_UNLOCK(hpcd); in HAL_PCD_EP_Close()
1460 HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint3… in HAL_PCD_EP_Receive() argument
1464 ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Receive()
1473 (void)USB_EPStartXfer(hpcd->Instance, ep); in HAL_PCD_EP_Receive()
1484 uint32_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) in HAL_PCD_EP_GetRxCount() argument
1486 return hpcd->OUT_ep[ep_addr & EP_ADDR_MSK].xfer_count; in HAL_PCD_EP_GetRxCount()
1496 HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint… in HAL_PCD_EP_Transmit() argument
1500 ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Transmit()
1511 (void)USB_EPStartXfer(hpcd->Instance, ep); in HAL_PCD_EP_Transmit()
1522 HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) in HAL_PCD_EP_SetStall() argument
1526 if (((uint32_t)ep_addr & EP_ADDR_MSK) > hpcd->Init.dev_endpoints) in HAL_PCD_EP_SetStall()
1533 ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_SetStall()
1538 ep = &hpcd->OUT_ep[ep_addr]; in HAL_PCD_EP_SetStall()
1545 __HAL_LOCK(hpcd); in HAL_PCD_EP_SetStall()
1547 (void)USB_EPSetStall(hpcd->Instance, ep); in HAL_PCD_EP_SetStall()
1549 __HAL_UNLOCK(hpcd); in HAL_PCD_EP_SetStall()
1560 HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) in HAL_PCD_EP_ClrStall() argument
1564 if (((uint32_t)ep_addr & 0x0FU) > hpcd->Init.dev_endpoints) in HAL_PCD_EP_ClrStall()
1571 ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_ClrStall()
1576 ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_ClrStall()
1583 __HAL_LOCK(hpcd); in HAL_PCD_EP_ClrStall()
1584 (void)USB_EPClearStall(hpcd->Instance, ep); in HAL_PCD_EP_ClrStall()
1585 __HAL_UNLOCK(hpcd); in HAL_PCD_EP_ClrStall()
1596 HAL_StatusTypeDef HAL_PCD_EP_Abort(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) in HAL_PCD_EP_Abort() argument
1603 ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Abort()
1607 ep = &hpcd->OUT_ep[ep_addr & EP_ADDR_MSK]; in HAL_PCD_EP_Abort()
1611 ret = USB_EPStopXfer(hpcd->Instance, ep); in HAL_PCD_EP_Abort()
1622 HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) in HAL_PCD_EP_Flush() argument
1625 UNUSED(hpcd); in HAL_PCD_EP_Flush()
1636 HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd) in HAL_PCD_ActivateRemoteWakeup() argument
1638 return (USB_ActivateRemoteWakeup(hpcd->Instance)); in HAL_PCD_ActivateRemoteWakeup()
1646 HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd) in HAL_PCD_DeActivateRemoteWakeup() argument
1648 return (USB_DeActivateRemoteWakeup(hpcd->Instance)); in HAL_PCD_DeActivateRemoteWakeup()
1675 PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd) in HAL_PCD_GetState() argument
1677 return hpcd->State; in HAL_PCD_GetState()
1699 static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd) in PCD_EP_ISR_Handler() argument
1713 while ((hpcd->Instance->ISTR & USB_ISTR_CTR) != 0U) in PCD_EP_ISR_Handler()
1715 wIstr = hpcd->Instance->ISTR; in PCD_EP_ISR_Handler()
1731 PCD_CLEAR_TX_EP_CTR(hpcd->Instance, PCD_ENDP0); in PCD_EP_ISR_Handler()
1732 ep = &hpcd->IN_ep[0]; in PCD_EP_ISR_Handler()
1734 ep->xfer_count = PCD_GET_EP_TX_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1739 hpcd->DataInStageCallback(hpcd, 0U); in PCD_EP_ISR_Handler()
1741 HAL_PCD_DataInStageCallback(hpcd, 0U); in PCD_EP_ISR_Handler()
1744 if ((hpcd->USB_Address > 0U) && (ep->xfer_len == 0U)) in PCD_EP_ISR_Handler()
1746 hpcd->Instance->DADDR = ((uint16_t)hpcd->USB_Address | USB_DADDR_EF); in PCD_EP_ISR_Handler()
1747 hpcd->USB_Address = 0U; in PCD_EP_ISR_Handler()
1756 ep = &hpcd->OUT_ep[0]; in PCD_EP_ISR_Handler()
1757 wEPVal = PCD_GET_ENDPOINT(hpcd->Instance, PCD_ENDP0); in PCD_EP_ISR_Handler()
1762 ep->xfer_count = PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1764 USB_ReadPMA(hpcd->Instance, (uint8_t *)hpcd->Setup, in PCD_EP_ISR_Handler()
1768 PCD_CLEAR_RX_EP_CTR(hpcd->Instance, PCD_ENDP0); in PCD_EP_ISR_Handler()
1772 hpcd->SetupStageCallback(hpcd); in PCD_EP_ISR_Handler()
1774 HAL_PCD_SetupStageCallback(hpcd); in PCD_EP_ISR_Handler()
1779 PCD_CLEAR_RX_EP_CTR(hpcd->Instance, PCD_ENDP0); in PCD_EP_ISR_Handler()
1782 ep->xfer_count = PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1786 USB_ReadPMA(hpcd->Instance, ep->xfer_buff, in PCD_EP_ISR_Handler()
1793 hpcd->DataOutStageCallback(hpcd, 0U); in PCD_EP_ISR_Handler()
1795 HAL_PCD_DataOutStageCallback(hpcd, 0U); in PCD_EP_ISR_Handler()
1799 wEPVal = (uint16_t)PCD_GET_ENDPOINT(hpcd->Instance, PCD_ENDP0); in PCD_EP_ISR_Handler()
1803 PCD_SET_EP_RX_CNT(hpcd->Instance, PCD_ENDP0, ep->maxpacket); in PCD_EP_ISR_Handler()
1804 PCD_SET_EP_RX_STATUS(hpcd->Instance, PCD_ENDP0, USB_EP_RX_VALID); in PCD_EP_ISR_Handler()
1813 wEPVal = PCD_GET_ENDPOINT(hpcd->Instance, epindex); in PCD_EP_ISR_Handler()
1818 PCD_CLEAR_RX_EP_CTR(hpcd->Instance, epindex); in PCD_EP_ISR_Handler()
1819 ep = &hpcd->OUT_ep[epindex]; in PCD_EP_ISR_Handler()
1824 count = (uint16_t)PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1828 USB_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaadress, count); in PCD_EP_ISR_Handler()
1837 count = HAL_PCD_EP_DB_Receive(hpcd, ep, wEPVal); in PCD_EP_ISR_Handler()
1842 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 0U); in PCD_EP_ISR_Handler()
1844 if ((PCD_GET_ENDPOINT(hpcd->Instance, ep->num) & USB_EP_DTOG_RX) != 0U) in PCD_EP_ISR_Handler()
1847 count = (uint16_t)PCD_GET_EP_DBUF0_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1851 USB_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr0, count); in PCD_EP_ISR_Handler()
1857 count = (uint16_t)PCD_GET_EP_DBUF1_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1861 USB_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr1, count); in PCD_EP_ISR_Handler()
1876 hpcd->DataOutStageCallback(hpcd, ep->num); in PCD_EP_ISR_Handler()
1878 HAL_PCD_DataOutStageCallback(hpcd, ep->num); in PCD_EP_ISR_Handler()
1883 (void)USB_EPStartXfer(hpcd->Instance, ep); in PCD_EP_ISR_Handler()
1889 ep = &hpcd->IN_ep[epindex]; in PCD_EP_ISR_Handler()
1892 PCD_CLEAR_TX_EP_CTR(hpcd->Instance, epindex); in PCD_EP_ISR_Handler()
1903 PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, 0U); in PCD_EP_ISR_Handler()
1907 PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, 0U); in PCD_EP_ISR_Handler()
1914 hpcd->DataInStageCallback(hpcd, ep->num); in PCD_EP_ISR_Handler()
1916 HAL_PCD_DataInStageCallback(hpcd, ep->num); in PCD_EP_ISR_Handler()
1925 TxPctSize = (uint16_t)PCD_GET_EP_TX_CNT(hpcd->Instance, ep->num); in PCD_EP_ISR_Handler()
1941 hpcd->DataInStageCallback(hpcd, ep->num); in PCD_EP_ISR_Handler()
1943 HAL_PCD_DataInStageCallback(hpcd, ep->num); in PCD_EP_ISR_Handler()
1951 (void)USB_EPStartXfer(hpcd->Instance, ep); in PCD_EP_ISR_Handler()
1958 (void)HAL_PCD_EP_DB_Transmit(hpcd, ep, wEPVal); in PCD_EP_ISR_Handler()
1978 static uint16_t HAL_PCD_EP_DB_Receive(PCD_HandleTypeDef *hpcd, in HAL_PCD_EP_DB_Receive() argument
1987 count = (uint16_t)PCD_GET_EP_DBUF0_CNT(hpcd->Instance, ep->num); in HAL_PCD_EP_DB_Receive()
2001 PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_NAK); in HAL_PCD_EP_DB_Receive()
2007 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 0U); in HAL_PCD_EP_DB_Receive()
2012 USB_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr0, count); in HAL_PCD_EP_DB_Receive()
2019 count = (uint16_t)PCD_GET_EP_DBUF1_CNT(hpcd->Instance, ep->num); in HAL_PCD_EP_DB_Receive()
2033 PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_NAK); in HAL_PCD_EP_DB_Receive()
2039 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 0U); in HAL_PCD_EP_DB_Receive()
2044 USB_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr1, count); in HAL_PCD_EP_DB_Receive()
2059 static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd, in HAL_PCD_EP_DB_Transmit() argument
2069 TxPctSize = (uint16_t)PCD_GET_EP_DBUF0_CNT(hpcd->Instance, ep->num); in HAL_PCD_EP_DB_Transmit()
2083 PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, 0U); in HAL_PCD_EP_DB_Transmit()
2084 PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, 0U); in HAL_PCD_EP_DB_Transmit()
2088 hpcd->DataInStageCallback(hpcd, ep->num); in HAL_PCD_EP_DB_Transmit()
2090 HAL_PCD_DataInStageCallback(hpcd, ep->num); in HAL_PCD_EP_DB_Transmit()
2095 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U); in HAL_PCD_EP_DB_Transmit()
2103 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U); in HAL_PCD_EP_DB_Transmit()
2132 PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, len); in HAL_PCD_EP_DB_Transmit()
2135 USB_WritePMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr0, (uint16_t)len); in HAL_PCD_EP_DB_Transmit()
2142 TxPctSize = (uint16_t)PCD_GET_EP_DBUF1_CNT(hpcd->Instance, ep->num); in HAL_PCD_EP_DB_Transmit()
2156 PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, 0U); in HAL_PCD_EP_DB_Transmit()
2157 PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, 0U); in HAL_PCD_EP_DB_Transmit()
2161 hpcd->DataInStageCallback(hpcd, ep->num); in HAL_PCD_EP_DB_Transmit()
2163 HAL_PCD_DataInStageCallback(hpcd, ep->num); in HAL_PCD_EP_DB_Transmit()
2169 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U); in HAL_PCD_EP_DB_Transmit()
2177 PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U); in HAL_PCD_EP_DB_Transmit()
2205 PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, len); in HAL_PCD_EP_DB_Transmit()
2208 USB_WritePMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr1, (uint16_t)len); in HAL_PCD_EP_DB_Transmit()
2214 PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_VALID); in HAL_PCD_EP_DB_Transmit()