Lines Matching refs:otgInstance
30 static void _USB_OtgStartTimer(usb_otg_instance_t *otgInstance, uint32_t timeValue);
31 static void _USB_OtgCancelTimer(usb_otg_instance_t *otgInstance);
32 static void _USB_OtgEnterStateStart(usb_otg_instance_t *otgInstance);
33 static void _USB_OtgProcessStateStart(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint…
34 static void _USB_OtgEnterStateAIdle(usb_otg_instance_t *otgInstance);
35 static void _USB_OtgProcessStateAIdle(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint…
36 static void _USB_OtgEnterStateAWaitVrise(usb_otg_instance_t *otgInstance);
37 static void _USB_OtgProcessStateAWaitVrise(usb_otg_instance_t *otgInstance,
40 static void _USB_OtgEnterStateAWaitVfall(usb_otg_instance_t *otgInstance);
41 static void _USB_OtgProcessStateAWaitVfall(usb_otg_instance_t *otgInstance,
44 static void _USB_OtgEnterStateAWaitBcon(usb_otg_instance_t *otgInstance);
45 static void _USB_OtgProcessStateAWaitBcon(usb_otg_instance_t *otgInstance,
48 static void _USB_OtgEnterStateAHost(usb_otg_instance_t *otgInstance);
49 static void _USB_OtgProcessStateAHost(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint…
50 static void _USB_OtgEnterStateASuspend(usb_otg_instance_t *otgInstance);
51 static void _USB_OtgProcessStateASuspend(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, u…
52 static void _USB_OtgEnterStateAPeripheral(usb_otg_instance_t *otgInstance);
53 static void _USB_OtgProcessStateAPeripheral(usb_otg_instance_t *otgInstance,
56 static void _USB_OtgEnterStateAVbusErr(usb_otg_instance_t *otgInstance);
57 static void _USB_OtgProcessStateAVbusErr(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, u…
58 static void _USB_OtgEnterStateBIdle(usb_otg_instance_t *otgInstance);
59 static void _USB_OtgProcessStateBIdle(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint…
60 static void _USB_OtgEnterStateBSrpInit(usb_otg_instance_t *otgInstance);
61 static void _USB_OtgProcessStateBSrpInit(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, u…
62 static void _USB_OtgEnterStateBPeripheral(usb_otg_instance_t *otgInstance);
63 static void _USB_OtgProcessStateBPeripheral(usb_otg_instance_t *otgInstance,
66 static void _USB_OtgEnterStateBWaitAcon(usb_otg_instance_t *otgInstance);
67 static void _USB_OtgProcessStateBWaitAcon(usb_otg_instance_t *otgInstance,
70 static void _USB_OtgEnterStateBHost(usb_otg_instance_t *otgInstance);
71 static void _USB_OtgProcessStateBHost(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint…
95 static void _USB_OtgStartTimer(usb_otg_instance_t *otgInstance, uint32_t timeValue) in _USB_OtgStartTimer() argument
98 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgStartTimer()
104 static void _USB_OtgCancelTimer(usb_otg_instance_t *otgInstance) in _USB_OtgCancelTimer() argument
107 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgCancelTimer()
110 if (otgInstance->hasTimeOutMsg > 0U) in _USB_OtgCancelTimer()
112 otgInstance->cancelTime = 1U; in _USB_OtgCancelTimer()
116 static void _USB_OtgEnterStateStart(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateStart() argument
118 otgInstance->otgDeviceState = (uint8_t)kOtg_State_Start; in _USB_OtgEnterStateStart()
119 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgEnterStateStart()
122 (void)USB_OtgNotifyChange(otgInstance, (uint32_t)kOtg_StatusPowerUp, 1); in _USB_OtgEnterStateStart()
125 static void _USB_OtgProcessStateStart(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint… in _USB_OtgProcessStateStart() argument
128 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop))) /* a_bus_drop/ */ in _USB_OtgProcessStateStart()
139 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateStart()
141 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateStart()
146 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusId); in _USB_OtgProcessStateStart()
148 _USB_OtgEnterStateAIdle(otgInstance); /* go to a_idle */ in _USB_OtgProcessStateStart()
156 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusPowerUp; in _USB_OtgProcessStateStart()
166 static void _USB_OtgEnterStateAIdle(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAIdle() argument
168 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) in _USB_OtgEnterStateAIdle()
170 _USB_OtgEnterStateBIdle(otgInstance); in _USB_OtgEnterStateAIdle()
172 else if ((0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop))) && in _USB_OtgEnterStateAIdle()
173 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusPowerUp)))) in _USB_OtgEnterStateAIdle()
175 _USB_OtgEnterStateAWaitVrise(otgInstance); in _USB_OtgEnterStateAIdle()
179 otgInstance->otgDeviceState = (uint8_t)kOtg_State_AIdle; in _USB_OtgEnterStateAIdle()
180 otgInstance->otgControllerStatus &= (~((uint32_t)kOtg_StatusBConn)); /* clear b_conn */ in _USB_OtgEnterStateAIdle()
186 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAIdle()
187 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateAIdle()
191 otgInstance->otgCallback(otgInstance->otgCallbackParameter, (uint8_t)kOtg_EventStateChange, in _USB_OtgEnterStateAIdle()
194 if (0U != otgInstance->idChangeAsFalse) in _USB_OtgEnterStateAIdle()
196 otgInstance->idChangeAsFalse = 0U; in _USB_OtgEnterStateAIdle()
198 (void)USB_OtgNotifyChange(otgInstance, (uint32_t)kOtg_StatusBusReq, 1); in _USB_OtgEnterStateAIdle()
203 static void _USB_OtgProcessStateAIdle(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint… in _USB_OtgProcessStateAIdle() argument
212 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusReq; in _USB_OtgProcessStateAIdle()
214 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop))) in _USB_OtgProcessStateAIdle()
216 _USB_OtgEnterStateAWaitVrise(otgInstance); /* go to a_wait_vrise */ in _USB_OtgProcessStateAIdle()
222 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBusReq); in _USB_OtgProcessStateAIdle()
232 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop))) in _USB_OtgProcessStateAIdle()
234 _USB_OtgEnterStateAWaitVrise(otgInstance); /* go to a_wait_vrise */ in _USB_OtgProcessStateAIdle()
246 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop))) in _USB_OtgProcessStateAIdle()
248 _USB_OtgEnterStateAWaitVrise(otgInstance); /* go to a_wait_vrise */ in _USB_OtgProcessStateAIdle()
259 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusPowerUp); in _USB_OtgProcessStateAIdle()
261 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop))) in _USB_OtgProcessStateAIdle()
263 _USB_OtgEnterStateAWaitVrise(otgInstance); /* go to a_wait_vrise */ in _USB_OtgProcessStateAIdle()
272 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateAIdle()
274 _USB_OtgEnterStateBHost(otgInstance); /* go to b_host */ in _USB_OtgProcessStateAIdle()
282 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusDrop; in _USB_OtgProcessStateAIdle()
287 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBusDrop); in _USB_OtgProcessStateAIdle()
289 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusReq))) || in _USB_OtgProcessStateAIdle()
290 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSrpDet))) || in _USB_OtgProcessStateAIdle()
291 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusAdpChange)))) in _USB_OtgProcessStateAIdle()
293 _USB_OtgEnterStateAWaitVrise(otgInstance); /* go to a_wait_vrise */ in _USB_OtgProcessStateAIdle()
301 otgInstance->otgControllerStatus |= otgChangeType; in _USB_OtgProcessStateAIdle()
305 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateAIdle()
311 static void _USB_OtgEnterStateAWaitVrise(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAWaitVrise() argument
313 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateAWaitVrise()
314 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop)))) in _USB_OtgEnterStateAWaitVrise()
316 _USB_OtgEnterStateAWaitVfall(otgInstance); in _USB_OtgEnterStateAWaitVrise()
318 else if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAWaitVrise()
320 _USB_OtgEnterStateAWaitBcon(otgInstance); in _USB_OtgEnterStateAWaitVrise()
324 otgInstance->otgDeviceState = (uint8_t)kOtg_State_AWaitVrise; in _USB_OtgEnterStateAWaitVrise()
327 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAWaitVrise()
329 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusVbusVld; in _USB_OtgEnterStateAWaitVrise()
330 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAWaitVrise()
333 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAWaitVrise()
334 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateAWaitVrise()
337 otgInstance->otgCallback(otgInstance->otgCallbackParameter, (uint32_t)kOtg_EventStateChange, in _USB_OtgEnterStateAWaitVrise()
341 _USB_OtgStartTimer(otgInstance, USB_OTG_TIMER_A_WAIT_VRISE_TMR); in _USB_OtgEnterStateAWaitVrise()
345 static void _USB_OtgProcessStateAWaitVrise(usb_otg_instance_t *otgInstance, in _USB_OtgProcessStateAWaitVrise() argument
356 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusDrop; in _USB_OtgProcessStateAWaitVrise()
358 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateAWaitVrise()
359 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAWaitVrise()
367 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateAWaitVrise()
369 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateAWaitVrise()
370 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAWaitVrise()
377 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgProcessStateAWaitVrise()
379 _USB_OtgEnterStateAWaitBcon(otgInstance); /* go to a_wait_bcon */ in _USB_OtgProcessStateAWaitVrise()
383 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAWaitVrise()
391 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusVbusVld; in _USB_OtgProcessStateAWaitVrise()
393 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateAWaitVrise()
394 _USB_OtgEnterStateAWaitBcon(otgInstance); /* go to a_wait_bcon */ in _USB_OtgProcessStateAWaitVrise()
401 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateAWaitVrise()
405 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateAWaitVrise()
411 static void _USB_OtgEnterStateAWaitVfall(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAWaitVfall() argument
413 otgInstance->otgDeviceState = (uint8_t)kOtg_State_AWaitVfall; in _USB_OtgEnterStateAWaitVfall()
415 (void)USB_OtgKhciControl(otgInstance->controllerHandle, (uint32_t)kOtg_ControlPullUp, 0, 0); in _USB_OtgEnterStateAWaitVfall()
418 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBusReq); in _USB_OtgEnterStateAWaitVfall()
421 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAWaitVfall()
423 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgEnterStateAWaitVfall()
424 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAWaitVfall()
427 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgEnterStateAWaitVfall()
430 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_AWai… in _USB_OtgEnterStateAWaitVfall()
433 _USB_OtgStartTimer(otgInstance, USB_OTG_TIMER_A_WAIT_VFALL_TMR); in _USB_OtgEnterStateAWaitVfall()
436 static void _USB_OtgProcessStateAWaitVfall(usb_otg_instance_t *otgInstance, in _USB_OtgProcessStateAWaitVfall() argument
446 _USB_OtgEnterStateAIdle(otgInstance); /* go to a_idle */ in _USB_OtgProcessStateAWaitVfall()
452 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateAWaitVfall()
456 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateAWaitVfall()
462 static void _USB_OtgEnterStateAWaitBcon(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAWaitBcon() argument
464 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateAWaitBcon()
465 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop)))) in _USB_OtgEnterStateAWaitBcon()
467 _USB_OtgEnterStateAWaitVfall(otgInstance); in _USB_OtgEnterStateAWaitBcon()
469 else if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBConn))) in _USB_OtgEnterStateAWaitBcon()
471 _USB_OtgEnterStateAHost(otgInstance); in _USB_OtgEnterStateAWaitBcon()
473 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAWaitBcon()
475 _USB_OtgEnterStateAVbusErr(otgInstance); in _USB_OtgEnterStateAWaitBcon()
479 otgInstance->otgDeviceState = (uint8_t)kOtg_State_AWaitBcon; in _USB_OtgEnterStateAWaitBcon()
482 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAWaitBcon()
484 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusVbusVld; in _USB_OtgEnterStateAWaitBcon()
485 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAWaitBcon()
488 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAWaitBcon()
489 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateAWaitBcon()
493 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_AWai… in _USB_OtgEnterStateAWaitBcon()
497 _USB_OtgStartTimer(otgInstance, USB_OTG_TIMER_A_WAIT_BCON_TMR); in _USB_OtgEnterStateAWaitBcon()
502 static void _USB_OtgProcessStateAWaitBcon(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, … in _USB_OtgProcessStateAWaitBcon() argument
510 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAWaitBcon()
517 otgInstance->otgControllerStatus |= ((uint32_t)kOtg_StatusId); in _USB_OtgProcessStateAWaitBcon()
519 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAWaitBcon()
527 otgInstance->otgControllerStatus |= ((uint32_t)kOtg_StatusBusDrop); in _USB_OtgProcessStateAWaitBcon()
529 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAWaitBcon()
537 otgInstance->otgControllerStatus |= ((uint32_t)kOtg_StatusBConn); in _USB_OtgProcessStateAWaitBcon()
539 _USB_OtgEnterStateAHost(otgInstance); /* go to a_host */ in _USB_OtgProcessStateAWaitBcon()
547 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgProcessStateAWaitBcon()
549 _USB_OtgEnterStateAVbusErr(otgInstance); /* go to a_vbus_err */ in _USB_OtgProcessStateAWaitBcon()
556 otgInstance->otgControllerStatus |= ((uint32_t)otgChangeType); in _USB_OtgProcessStateAWaitBcon()
560 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateAWaitBcon()
566 static void _USB_OtgEnterStateAHost(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAHost() argument
568 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateAHost()
569 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop)))) in _USB_OtgEnterStateAHost()
571 _USB_OtgEnterStateAWaitVfall(otgInstance); in _USB_OtgEnterStateAHost()
573 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBConn))) in _USB_OtgEnterStateAHost()
575 _USB_OtgEnterStateAWaitBcon(otgInstance); in _USB_OtgEnterStateAHost()
583 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAHost()
585 _USB_OtgEnterStateAVbusErr(otgInstance); in _USB_OtgEnterStateAHost()
589 otgInstance->otgDeviceState = ((uint8_t)kOtg_State_AHost); in _USB_OtgEnterStateAHost()
590 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBHNPFeature); in _USB_OtgEnterStateAHost()
593 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAHost()
595 otgInstance->otgControllerStatus |= ((uint32_t)kOtg_StatusVbusVld); in _USB_OtgEnterStateAHost()
596 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAHost()
600 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgEnterStateAHost()
602 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAHost()
603 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateAHost()
607 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_AHos… in _USB_OtgEnterStateAHost()
610 otgInstance->waitInit = 1U; in _USB_OtgEnterStateAHost()
611 …_USB_OtgStartTimer(otgInstance, USB_OTG_TIME_WAIT_DEVICE_INIT); /* wait the B-Device init the devi… in _USB_OtgEnterStateAHost()
614 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, kOtg_StackHostIni… in _USB_OtgEnterStateAHost()
619 static void _USB_OtgExitHost(usb_otg_instance_t *otgInstance) in _USB_OtgExitHost() argument
621 otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, in _USB_OtgExitHost()
623 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgExitHost()
627 static void _USB_OtgProcessStateAHost(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint… in _USB_OtgProcessStateAHost() argument
634 if (0U != otgInstance->waitInit) /* init host */ in _USB_OtgProcessStateAHost()
637 otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, in _USB_OtgProcessStateAHost()
639 otgInstance->waitInit = 0U; in _USB_OtgProcessStateAHost()
648 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBConn); in _USB_OtgProcessStateAHost()
650 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateAHost()
651 _USB_OtgEnterStateAWaitBcon(otgInstance); /* go to a_wait_bcon */ in _USB_OtgProcessStateAHost()
659 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateAHost()
661 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateAHost()
662 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAHost()
670 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusDrop; in _USB_OtgProcessStateAHost()
672 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateAHost()
673 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAHost()
681 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBusReq); in _USB_OtgProcessStateAHost()
683 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateAHost()
685 _USB_OtgEnterStateASuspend(otgInstance); /* go to a_suspend */ in _USB_OtgProcessStateAHost()
692 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateAHost()
694 _USB_OtgEnterStateASuspend(otgInstance); /* go to a_suspend */ in _USB_OtgProcessStateAHost()
702 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgProcessStateAHost()
704 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateAHost()
705 _USB_OtgEnterStateAVbusErr(otgInstance); /* go to a_vbus_err */ in _USB_OtgProcessStateAHost()
712 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateAHost()
716 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateAHost()
722 static void _USB_OtgEnterStateASuspend(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateASuspend() argument
724 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateASuspend()
725 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop)))) in _USB_OtgEnterStateASuspend()
727 _USB_OtgEnterStateAWaitVfall(otgInstance); in _USB_OtgEnterStateASuspend()
729 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBConn))) in _USB_OtgEnterStateASuspend()
731 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBHNPFeature))) in _USB_OtgEnterStateASuspend()
733 _USB_OtgEnterStateAPeripheral(otgInstance); in _USB_OtgEnterStateASuspend()
737 _USB_OtgEnterStateAWaitBcon(otgInstance); in _USB_OtgEnterStateASuspend()
740 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateASuspend()
742 _USB_OtgEnterStateAVbusErr(otgInstance); in _USB_OtgEnterStateASuspend()
746 otgInstance->otgDeviceState = (uint8_t)kOtg_State_ASuspend; in _USB_OtgEnterStateASuspend()
749 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateASuspend()
751 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusVbusVld; in _USB_OtgEnterStateASuspend()
752 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateASuspend()
755 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateASuspend()
756 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateASuspend()
760 otgInstance->otgCallback(otgInstance->otgCallbackParameter, (uint32_t)kOtg_EventStateChange, in _USB_OtgEnterStateASuspend()
763 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBHNPFeature))) in _USB_OtgEnterStateASuspend()
766 _USB_OtgStartTimer(otgInstance, USB_OTG_TIMER_A_AIDL_BDIS_TMR); in _USB_OtgEnterStateASuspend()
771 static void _USB_OtgProcessStateASuspend(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, u… in _USB_OtgProcessStateASuspend() argument
780 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBConn); in _USB_OtgProcessStateASuspend()
781 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateASuspend()
782 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBHNPFeature))) in _USB_OtgProcessStateASuspend()
784 _USB_OtgEnterStateAWaitBcon(otgInstance); /* go to a_wait_bcon */ in _USB_OtgProcessStateASuspend()
788 _USB_OtgEnterStateAPeripheral(otgInstance); /* go to a_peripheral */ in _USB_OtgProcessStateASuspend()
794 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBHNPFeature))) in _USB_OtgProcessStateASuspend()
800 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateASuspend()
809 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusReq; in _USB_OtgProcessStateASuspend()
811 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateASuspend()
812 … (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgProcessStateASuspend()
815 _USB_OtgEnterStateAHost(otgInstance); /* go to a_host */ in _USB_OtgProcessStateASuspend()
823 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateASuspend()
825 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateASuspend()
826 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateASuspend()
834 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusDrop; in _USB_OtgProcessStateASuspend()
836 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateASuspend()
837 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateASuspend()
845 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgProcessStateASuspend()
847 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateASuspend()
848 _USB_OtgEnterStateAVbusErr(otgInstance); /* go to a_vbus_err */ in _USB_OtgProcessStateASuspend()
855 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateASuspend()
859 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateASuspend()
865 static void _USB_OtgEnterStateAPeripheral(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAPeripheral() argument
867 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateAPeripheral()
868 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop)))) in _USB_OtgEnterStateAPeripheral()
870 _USB_OtgEnterStateAWaitVfall(otgInstance); in _USB_OtgEnterStateAPeripheral()
872 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAPeripheral()
874 _USB_OtgEnterStateAVbusErr(otgInstance); in _USB_OtgEnterStateAPeripheral()
878 otgInstance->otgDeviceState = (uint8_t)kOtg_State_APeripheral; in _USB_OtgEnterStateAPeripheral()
879 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBConn); in _USB_OtgEnterStateAPeripheral()
882 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAPeripheral()
884 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAPeripheral()
887 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAPeripheral()
889 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusVbusVld; in _USB_OtgEnterStateAPeripheral()
890 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAPeripheral()
893 otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, in _USB_OtgEnterStateAPeripheral()
896 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAPeripheral()
897 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateAPeripheral()
900 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAPeripheral()
901 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateAPeripheral()
907 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_APer… in _USB_OtgEnterStateAPeripheral()
911 otgInstance->waitInit = 1; in _USB_OtgEnterStateAPeripheral()
912 _USB_OtgStartTimer(otgInstance, USB_OTG_TIME_WAIT_BHOST); in _USB_OtgEnterStateAPeripheral()
917 static void _USB_OtgExitDevice(usb_otg_instance_t *otgInstance) in _USB_OtgExitDevice() argument
919 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgExitDevice()
921 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgExitDevice()
924 otgInstance->otgCallback(otgInstance->otgCallbackParameter, (uint32_t)kOtg_EventStackInit, in _USB_OtgExitDevice()
928 static void _USB_OtgProcessStateAPeripheral(usb_otg_instance_t *otgInstance, in _USB_OtgProcessStateAPeripheral() argument
939 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusReq; in _USB_OtgProcessStateAPeripheral()
947 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateAPeripheral()
949 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateAPeripheral()
950 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateAPeripheral()
951 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAPeripheral()
959 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusDrop; in _USB_OtgProcessStateAPeripheral()
961 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateAPeripheral()
962 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateAPeripheral()
963 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAPeripheral()
969 if (0U != otgInstance->waitInit) /* wait init host */ in _USB_OtgProcessStateAPeripheral()
971 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgProcessStateAPeripheral()
972 … otgInstance->controllerHandle, kOtg_ControlRequestStatus, kOtg_StatusCheckIdleInAPeripheral, in _USB_OtgProcessStateAPeripheral()
974 otgInstance->waitInit = 0; in _USB_OtgProcessStateAPeripheral()
983 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateAPeripheral()
984 _USB_OtgEnterStateAWaitBcon(otgInstance); /* go to a_wait_bcon */ in _USB_OtgProcessStateAPeripheral()
995 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgProcessStateAPeripheral()
997 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateAPeripheral()
998 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateAPeripheral()
999 _USB_OtgEnterStateAVbusErr(otgInstance); /* go to a_vbus_err */ in _USB_OtgProcessStateAPeripheral()
1006 otgInstance->otgControllerStatus |= otgChangeType; in _USB_OtgProcessStateAPeripheral()
1010 otgInstance->otgControllerStatus &= (~otgChangeType); in _USB_OtgProcessStateAPeripheral()
1016 static void _USB_OtgEnterStateAVbusErr(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateAVbusErr() argument
1018 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateAVbusErr()
1019 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusDrop)))) in _USB_OtgEnterStateAVbusErr()
1021 _USB_OtgEnterStateAWaitVfall(otgInstance); in _USB_OtgEnterStateAVbusErr()
1025 otgInstance->otgDeviceState = (uint8_t)kOtg_State_AVbusErr; in _USB_OtgEnterStateAVbusErr()
1028 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateAVbusErr()
1030 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgEnterStateAVbusErr()
1031 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateAVbusErr()
1034 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateAVbusErr()
1035 … otgInstance->controllerHandle, kOtg_ControlRequestStatus, kOtg_StatusId, kOtg_State_AVbusErr); in _USB_OtgEnterStateAVbusErr()
1037 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_AVbu… in _USB_OtgEnterStateAVbusErr()
1041 static void _USB_OtgProcessStateAVbusErr(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, u… in _USB_OtgProcessStateAVbusErr() argument
1050 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusId; in _USB_OtgProcessStateAVbusErr()
1052 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAVbusErr()
1060 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusDrop; in _USB_OtgProcessStateAVbusErr()
1062 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAVbusErr()
1071 _USB_OtgEnterStateAWaitVfall(otgInstance); /* go to a_wait_vfall */ in _USB_OtgProcessStateAVbusErr()
1078 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateAVbusErr()
1082 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateAVbusErr()
1088 static void _USB_OtgEnterStateBIdle(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateBIdle() argument
1090 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) in _USB_OtgEnterStateBIdle()
1092 otgInstance->otgControllerStatus = 0U; /* default controller status */ in _USB_OtgEnterStateBIdle()
1093 _USB_OtgEnterStateAIdle(otgInstance); in _USB_OtgEnterStateBIdle()
1095 else if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSessVld))) in _USB_OtgEnterStateBIdle()
1097 otgInstance->otgControllerStatus = (uint32_t)kOtg_StatusId; in _USB_OtgEnterStateBIdle()
1098 _USB_OtgEnterStateBPeripheral(otgInstance); in _USB_OtgEnterStateBIdle()
1102 otgInstance->otgDeviceState = (uint8_t)kOtg_State_BIdle; in _USB_OtgEnterStateBIdle()
1103 otgInstance->otgControllerStatus = (uint32_t)kOtg_StatusId; in _USB_OtgEnterStateBIdle()
1109 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgEnterStateBIdle()
1111 …(void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, kOtg_Cont… in _USB_OtgEnterStateBIdle()
1113 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBIdle()
1114 otgInstance->controllerHandle, kOtg_ControlRequestStatus, in _USB_OtgEnterStateBIdle()
1119 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_BIdl… in _USB_OtgEnterStateBIdle()
1123 static void _USB_OtgProcessStateBIdle(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint… in _USB_OtgProcessStateBIdle() argument
1132 otgInstance->otgControllerStatus = 0U; /* default controller status */ in _USB_OtgProcessStateBIdle()
1134 _USB_OtgEnterStateAIdle(otgInstance); /* go to a_idle */ in _USB_OtgProcessStateBIdle()
1139 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusSsendSrp; in _USB_OtgProcessStateBIdle()
1140 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSe0Srp))) in _USB_OtgProcessStateBIdle()
1142 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusPowerUp))) || in _USB_OtgProcessStateBIdle()
1143 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusReq))) || in _USB_OtgProcessStateBIdle()
1144 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusAdpChange)))) in _USB_OtgProcessStateBIdle()
1146 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusPowerUp); in _USB_OtgProcessStateBIdle()
1147 _USB_OtgEnterStateBSrpInit(otgInstance); /* go to b_srp_init */ in _USB_OtgProcessStateBIdle()
1153 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusSe0Srp; in _USB_OtgProcessStateBIdle()
1154 if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSsendSrp))) in _USB_OtgProcessStateBIdle()
1156 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusPowerUp))) || in _USB_OtgProcessStateBIdle()
1157 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusReq))) || in _USB_OtgProcessStateBIdle()
1158 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusAdpChange)))) in _USB_OtgProcessStateBIdle()
1160 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusPowerUp); in _USB_OtgProcessStateBIdle()
1161 _USB_OtgEnterStateBSrpInit(otgInstance); /* go to b_srp_init */ in _USB_OtgProcessStateBIdle()
1170 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusPowerUp; in _USB_OtgProcessStateBIdle()
1172 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSsendSrp))) && in _USB_OtgProcessStateBIdle()
1173 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSe0Srp)))) in _USB_OtgProcessStateBIdle()
1175 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusPowerUp); in _USB_OtgProcessStateBIdle()
1176 _USB_OtgEnterStateBSrpInit(otgInstance); /* go to b_srp_init */ in _USB_OtgProcessStateBIdle()
1185 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusReq; in _USB_OtgProcessStateBIdle()
1187 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSsendSrp))) && in _USB_OtgProcessStateBIdle()
1188 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSe0Srp)))) in _USB_OtgProcessStateBIdle()
1190 _USB_OtgEnterStateBSrpInit(otgInstance); /* go to b_srp_init */ in _USB_OtgProcessStateBIdle()
1200 if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSsendSrp))) && in _USB_OtgProcessStateBIdle()
1201 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSe0Srp)))) in _USB_OtgProcessStateBIdle()
1203 _USB_OtgEnterStateBSrpInit(otgInstance); /* go to b_srp_init */ in _USB_OtgProcessStateBIdle()
1212 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusSessVld; in _USB_OtgProcessStateBIdle()
1214 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBIdle()
1221 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateBIdle()
1225 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateBIdle()
1231 static void _USB_OtgEnterStateBSrpInit(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateBSrpInit() argument
1233 otgInstance->otgControllerStatus = ~((uint32_t)kOtg_StatusBusReq); /* clear b_bus_req */ in _USB_OtgEnterStateBSrpInit()
1235 if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) in _USB_OtgEnterStateBSrpInit()
1237 _USB_OtgEnterStateBIdle(otgInstance); in _USB_OtgEnterStateBSrpInit()
1241 otgInstance->otgDeviceState = (uint8_t)kOtg_State_BSrpInit; in _USB_OtgEnterStateBSrpInit()
1243 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateBSrpInit()
1246 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBSrpInit()
1247 otgInstance->controllerHandle, (uint32_t)kOtg_ControlRequestStatus, in _USB_OtgEnterStateBSrpInit()
1252 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_BSrp… in _USB_OtgEnterStateBSrpInit()
1256 static void _USB_OtgProcessStateBSrpInit(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, u… in _USB_OtgProcessStateBSrpInit() argument
1265 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusId); in _USB_OtgProcessStateBSrpInit()
1267 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBSrpInit()
1276 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBSrpInit()
1286 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBSrpInit()
1294 otgInstance->otgControllerStatus |= kOtg_StatusSessVld; in _USB_OtgProcessStateBSrpInit()
1296 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateBSrpInit()
1297 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBSrpInit()
1305 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateBSrpInit()
1309 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateBSrpInit()
1315 static void _USB_OtgEnterStateBPeripheral(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateBPeripheral() argument
1317 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusAConn); in _USB_OtgEnterStateBPeripheral()
1319 if ((0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateBPeripheral()
1320 (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSessVld)))) in _USB_OtgEnterStateBPeripheral()
1322 _USB_OtgEnterStateBIdle(otgInstance); in _USB_OtgEnterStateBPeripheral()
1326 otgInstance->otgDeviceState = (uint8_t)kOtg_State_BPeripheral; in _USB_OtgEnterStateBPeripheral()
1327 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBHNPFeature); in _USB_OtgEnterStateBPeripheral()
1330 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBPeripheral()
1331 otgInstance->controllerHandle, (uint32_t)kOtg_ControlPullUp, (uint32_t)kOtg_PullDp, 0); in _USB_OtgEnterStateBPeripheral()
1332 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBPeripheral()
1333 … otgInstance->controllerHandle, (uint32_t)kOtg_ControlPullDown, (uint32_t)kOtg_PullDm, 0); in _USB_OtgEnterStateBPeripheral()
1334 otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, in _USB_OtgEnterStateBPeripheral()
1337 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBPeripheral()
1338 otgInstance->controllerHandle, (uint32_t)kOtg_ControlRequestStatus, in _USB_OtgEnterStateBPeripheral()
1342 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_BPer… in _USB_OtgEnterStateBPeripheral()
1346 static void _USB_OtgProcessStateBPeripheral(usb_otg_instance_t *otgInstance, in _USB_OtgProcessStateBPeripheral() argument
1357 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusId); in _USB_OtgProcessStateBPeripheral()
1359 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateBPeripheral()
1360 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBPeripheral()
1368 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusSessVld); in _USB_OtgProcessStateBPeripheral()
1370 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateBPeripheral()
1371 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBPeripheral()
1378 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgProcessStateBPeripheral()
1379 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateBPeripheral()
1380 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBPeripheral()
1384 otgInstance->otgControllerStatus |= (uint32_t)(kOtg_StatusVbusVld); in _USB_OtgProcessStateBPeripheral()
1392 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBusReq; in _USB_OtgProcessStateBPeripheral()
1401 … if ((0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBHNPFeature))) && in _USB_OtgProcessStateBPeripheral()
1402 (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusReq)))) in _USB_OtgProcessStateBPeripheral()
1404 … (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgProcessStateBPeripheral()
1406 _USB_OtgExitDevice(otgInstance); in _USB_OtgProcessStateBPeripheral()
1407 _USB_OtgEnterStateBWaitAcon(otgInstance); /* go to b_wait_acon */ in _USB_OtgProcessStateBPeripheral()
1415 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateBPeripheral()
1419 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateBPeripheral()
1425 static void _USB_OtgEnterStateBWaitAcon(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateBWaitAcon() argument
1427 if ((0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusId))) || in _USB_OtgEnterStateBWaitAcon()
1428 (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusSessVld)))) in _USB_OtgEnterStateBWaitAcon()
1430 _USB_OtgEnterStateBIdle(otgInstance); in _USB_OtgEnterStateBWaitAcon()
1432 else if (0U != (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusAConn))) in _USB_OtgEnterStateBWaitAcon()
1434 _USB_OtgEnterStateBHost(otgInstance); in _USB_OtgEnterStateBWaitAcon()
1438 otgInstance->otgDeviceState = (uint8_t)kOtg_State_BWaitAcon; in _USB_OtgEnterStateBWaitAcon()
1440 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateBWaitAcon()
1442 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBWaitAcon()
1443 otgInstance->controllerHandle, (uint32_t)kOtg_ControlRequestStatus, in _USB_OtgEnterStateBWaitAcon()
1446 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_BWai… in _USB_OtgEnterStateBWaitAcon()
1449 _USB_OtgStartTimer(otgInstance, USB_OTG_TIMER_B_ASE0_BRST_TMR); in _USB_OtgEnterStateBWaitAcon()
1453 static void _USB_OtgProcessStateBWaitAcon(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, … in _USB_OtgProcessStateBWaitAcon() argument
1462 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusAConn; in _USB_OtgProcessStateBWaitAcon()
1464 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateBWaitAcon()
1465 _USB_OtgEnterStateBHost(otgInstance); /* go to b_host */ in _USB_OtgProcessStateBWaitAcon()
1473 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusId); in _USB_OtgProcessStateBWaitAcon()
1475 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateBWaitAcon()
1476 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBWaitAcon()
1484 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusSessVld); in _USB_OtgProcessStateBWaitAcon()
1486 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateBWaitAcon()
1487 _USB_OtgEnterStateBIdle(otgInstance); /* go to b_idle */ in _USB_OtgProcessStateBWaitAcon()
1496 _USB_OtgCancelTimer(otgInstance); in _USB_OtgProcessStateBWaitAcon()
1497 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBWaitAcon()
1506 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBWaitAcon()
1513 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateBWaitAcon()
1517 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateBWaitAcon()
1523 static void _USB_OtgEnterStateBHost(usb_otg_instance_t *otgInstance) in _USB_OtgEnterStateBHost() argument
1525 if ((0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusAConn))) || in _USB_OtgEnterStateBHost()
1526 (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusBusReq)))) in _USB_OtgEnterStateBHost()
1528 _USB_OtgEnterStateBPeripheral(otgInstance); in _USB_OtgEnterStateBHost()
1530 else if (0U == (otgInstance->otgControllerStatus & ((uint32_t)kOtg_StatusVbusVld))) in _USB_OtgEnterStateBHost()
1532 _USB_OtgEnterStateBPeripheral(otgInstance); in _USB_OtgEnterStateBHost()
1536 otgInstance->otgDeviceState = (uint8_t)kOtg_State_BHost; in _USB_OtgEnterStateBHost()
1537 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBusReq); in _USB_OtgEnterStateBHost()
1538 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBHNPFeature; in _USB_OtgEnterStateBHost()
1540 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in _USB_OtgEnterStateBHost()
1544 (void)otgInstance->controllerInterface->controllerControl( in _USB_OtgEnterStateBHost()
1545 … otgInstance->controllerHandle, (uint32_t)kOtg_ControlRequestStatus, (uint32_t)kOtg_StatusADisconn, in _USB_OtgEnterStateBHost()
1548 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStateChange, kOtg_State_BHos… in _USB_OtgEnterStateBHost()
1551 otgInstance->waitInit = 1U; in _USB_OtgEnterStateBHost()
1552 _USB_OtgStartTimer(otgInstance, USB_OTG_TIME_WAIT_DEVICE_INIT); in _USB_OtgEnterStateBHost()
1555 …otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, kOtg_StackHostIni… in _USB_OtgEnterStateBHost()
1560 static void _USB_OtgProcessStateBHost(usb_otg_instance_t *otgInstance, uint32_t otgChangeType, uint… in _USB_OtgProcessStateBHost() argument
1567 if (0U != otgInstance->waitInit) /* wait device init */ in _USB_OtgProcessStateBHost()
1570 otgInstance->waitInit = 0; in _USB_OtgProcessStateBHost()
1571 otgInstance->otgCallback(otgInstance->otgCallbackParameter, kOtg_EventStackInit, in _USB_OtgProcessStateBHost()
1581 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBusReq); in _USB_OtgProcessStateBHost()
1583 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateBHost()
1584 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBHost()
1590 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateBHost()
1591 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBHost()
1599 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusAConn); in _USB_OtgProcessStateBHost()
1601 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateBHost()
1602 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBHost()
1610 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusVbusVld); in _USB_OtgProcessStateBHost()
1612 _USB_OtgExitHost(otgInstance); in _USB_OtgProcessStateBHost()
1613 _USB_OtgEnterStateBPeripheral(otgInstance); /* go to b_peripheral */ in _USB_OtgProcessStateBHost()
1620 otgInstance->otgControllerStatus |= (uint32_t)otgChangeType; in _USB_OtgProcessStateBHost()
1624 otgInstance->otgControllerStatus &= ~((uint32_t)otgChangeType); in _USB_OtgProcessStateBHost()
1635 usb_otg_instance_t *otgInstance = NULL; in USB_OtgInit() local
1643 otgInstance = (usb_otg_instance_t *)OSA_MemoryAllocate(sizeof(usb_otg_instance_t)); in USB_OtgInit()
1644 if (otgInstance == NULL) in USB_OtgInit()
1649 otgInstance->otgMsgHandle = (osa_msgq_handle_t)&otgInstance->otgMsgHandleBuffer[0]; in USB_OtgInit()
1650 …if (KOSA_StatusSuccess != OSA_MsgQCreate(otgInstance->otgMsgHandle, USB_OTG_MSG_COUNT, USB_OTG_MES… in USB_OtgInit()
1652 OSA_MemoryFree(otgInstance); in USB_OtgInit()
1656 otgInstance->otgControllerStatus = 0U; /* default controller status */ in USB_OtgInit()
1657 otgInstance->otgCallback = otgCallbackFn; in USB_OtgInit()
1658 otgInstance->otgCallbackParameter = callbackParameter; in USB_OtgInit()
1659 otgInstance->hasUpdateMsg = 0U; in USB_OtgInit()
1662 _USB_OtgGetControllerInterface(controllerId, &otgInstance->controllerInterface); in USB_OtgInit()
1663 …if ((otgInstance->controllerInterface == NULL) || (otgInstance->controllerInterface->controllerIni… in USB_OtgInit()
1664 (otgInstance->controllerInterface->controllerDeinit == NULL) || in USB_OtgInit()
1665 (otgInstance->controllerInterface->controllerControl == NULL)) in USB_OtgInit()
1667 (void)OSA_MsgQDestroy(otgInstance->otgMsgHandle); in USB_OtgInit()
1668 OSA_MemoryFree(otgInstance); in USB_OtgInit()
1671 …if (otgInstance->controllerInterface->controllerInit(controllerId, otgInstance, &otgInstance->cont… in USB_OtgInit()
1674 (void)OSA_MsgQDestroy(otgInstance->otgMsgHandle); in USB_OtgInit()
1675 OSA_MemoryFree(otgInstance); in USB_OtgInit()
1679 _USB_OtgEnterStateStart(otgInstance); in USB_OtgInit()
1681 *otgHandle = otgInstance; in USB_OtgInit()
1687 usb_otg_instance_t *otgInstance = (usb_otg_instance_t *)otgHandle; in USB_OtgDeinit() local
1695 (void)otgInstance->controllerInterface->controllerDeinit(otgInstance->controllerHandle); in USB_OtgDeinit()
1698 (void)OSA_MsgQDestroy(otgInstance->otgMsgHandle); in USB_OtgDeinit()
1699 OSA_MemoryFree(otgInstance); in USB_OtgDeinit()
1706 usb_otg_instance_t *otgInstance = (usb_otg_instance_t *)otgHandle; in USB_OtgTaskFunction() local
1716 …if (OSA_MsgQGet(otgInstance->otgMsgHandle, (osa_msg_handle_t)&otgMsg, USB_OSA_WAIT_TIMEOUT) == KOS… in USB_OtgTaskFunction()
1720 otgInstance->hasUpdateMsg = 0; in USB_OtgTaskFunction()
1721 (void)otgInstance->controllerInterface->controllerControl(otgInstance->controllerHandle, in USB_OtgTaskFunction()
1728 otgInstance->hasTimeOutMsg--; in USB_OtgTaskFunction()
1729 if (0U != otgInstance->cancelTime) in USB_OtgTaskFunction()
1731 otgInstance->cancelTime = 0; in USB_OtgTaskFunction()
1736 deviceState = (usb_otg_device_state_t)otgInstance->otgDeviceState; in USB_OtgTaskFunction()
1740 … _USB_OtgProcessStateStart(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1744 … _USB_OtgProcessStateAIdle(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1748 … _USB_OtgProcessStateAWaitVrise(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1752 … _USB_OtgProcessStateAWaitBcon(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1756 … _USB_OtgProcessStateAHost(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1760 … _USB_OtgProcessStateAWaitVfall(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1764 … _USB_OtgProcessStateASuspend(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1768 … _USB_OtgProcessStateAPeripheral(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1772 … _USB_OtgProcessStateAVbusErr(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1780 … _USB_OtgProcessStateBIdle(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1784 … _USB_OtgProcessStateBSrpInit(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1788 … _USB_OtgProcessStateBPeripheral(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1792 … _USB_OtgProcessStateBWaitAcon(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1796 … _USB_OtgProcessStateBHost(otgInstance, otgMsg.otgStatusType, otgMsg.otgStatusValue); in USB_OtgTaskFunction()
1809 usb_otg_instance_t *otgInstance = (usb_otg_instance_t *)otgHandle; in USB_OtgBusDrop() local
1816 if ((otgInstance->otgDeviceState >= (uint8_t)kOtg_State_AIdle) && in USB_OtgBusDrop()
1817 (otgInstance->otgDeviceState <= (uint8_t)kOtg_State_AVbusErr)) in USB_OtgBusDrop()
1849 usb_otg_instance_t *otgInstance = (usb_otg_instance_t *)otgHandle; in USB_OtgClearError() local
1856 if (otgInstance->otgDeviceState == (uint8_t)kOtg_State_AVbusErr) in USB_OtgClearError()
1869 usb_otg_instance_t *otgInstance = (usb_otg_instance_t *)otgHandle; in USB_OtgNotifyChange() local
1878 otgInstance->hasTimeOutMsg++; in USB_OtgNotifyChange()
1882 if (otgInstance->hasUpdateMsg == 1U) in USB_OtgNotifyChange()
1891 otgInstance->otgControllerStatus |= (uint32_t)kOtg_StatusBHNPFeature; in USB_OtgNotifyChange()
1895 otgInstance->otgControllerStatus &= ~((uint32_t)kOtg_StatusBHNPFeature); in USB_OtgNotifyChange()
1902 otgInstance->idChangeAsFalse = 1U; in USB_OtgNotifyChange()
1911 if (OSA_MsgQPut(otgInstance->otgMsgHandle, (osa_msg_handle_t)&otgMsg) == KOSA_StatusSuccess) in USB_OtgNotifyChange()
1915 otgInstance->hasUpdateMsg = 1; in USB_OtgNotifyChange()