AG903ライブラリリファレンス
内容インデックスホーム
Body Source
本文ソース
1: uhs_status_t Usbh_Exit( void ) 2: { 3: uhs_status_t retval = UDI_OK; 4: int i = 0; 5: uhs_ubit32_t timeout = 0; 6: 7: 8: if( Usbh_susres_get_state() != USBH_SUSRES_STS_IDLE ){ 9: uhs_debug_print (DBG_ERR, ("ERROR : Don't Call Current State!!")); 10: return UDI_STAT_INVALID_STATE; 11: } 12: 13: if(g_usbh_status == USBHSTAT_RUN){ 14: g_usbh_status = USBHSTAT_TERMINATE; 15: 16: 17: for (i=1; i<=USB_HW_PORT_NUM; i++) { 18: Usbh_Api_SetPortPower( ehci_rh->usbdev, i, USBH_RH_PORT_POWER_OFF ); 19: } 20: 21: 22: 23: while ( !lists_ListEmpty(&g_apiwrap_info.usb_wrap_devinfo_list) ) { 24: kernel_wait(NULL, 10); 25: timeout++; 26: if ( timeout > USBH_EXIT_WAITNODEVICE_TIMEOUT ) { 27: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 28: break; 29: } 30: } 31: kernel_wait(NULL, 100); 32: 33: 34: g_apiwrap_info.bus_stat = USBWRAP_STAT_USBBUS_NON_ACTIVE; 35: 36: 37: Usbh_susres_ExitMainThread(); 38: 39: 42: 43: 44: Usbh_UnRegistAllAppCallback(); 45: 46: 47: 50: 51: 52: retval = Usb_Host_Controller_Exit(); 53: if ( retval != UDI_OK ) { 54: 55: 56: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 57: return UDI_STAT_INVALID_STATE; 58: } 59: 60: 61: retval = Usb_Host_Exit(); 62: if ( retval != UDI_OK ) { 63: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 64: return UDI_STAT_INVALID_STATE; 65: } 66: 67: 68: retval = kernel_delete_semaphore( &g_apiwrap_info.drvinfo_semid ); 69: if ( retval != UDI_OK ) { 70: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 71: return UDI_STAT_INVALID_STATE; 72: } 73: 74: 75: retval = Usb_Host_MemoryPoolRelease(); 76: if ( retval != UDI_OK ) { 77: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 78: return UDI_STAT_INVALID_STATE; 79: } 80: 81: 82: CORE_REPORT_MILESTONE( USBC_EXIT_COMP ); 83: kernel_wait( NULL , 100 ); 84: 85: 86: retval = Usbh_StatusMon_Exit(); 87: if ( retval != UDI_OK ) { 88: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 89: } 90: 91: 92: retval = kernel_terminate(&g_apiwrap_info.mpl_osc); 93: if ( retval != UDI_OK ) { 94: CORE_REPORT_ERROR( USBC_ILLEGAL_ERROR ); 95: return UDI_STAT_INVALID_STATE; 96: } 97: 98: 99: if( USBH_rsc_exit() != UDI_OK ){ 100: uhs_debug_print (DBG_ERR, ("USBH_rsc_exit() Error")); 101: return UDI_STAT_RESOURCE_UNAVAIL; 102: } 103: 104: 105: g_apiwrap_info.apiwrap_stat = USBWRAP_STAT_INIT_NOT_START; 106: 107: g_usbh_status = USBHSTAT_IDLE; 108: 109: 110: #ifdef USBH_OS_STACK_CHK 111: 112: USBH_stack_chk_stop(); 113: #endif 114: 115: 116: #ifdef USBH_MEM_LEAK_CHK 117: 118: USBH_memleak_chk_exit(); 119: #endif 120: 121: 122: }else{ 123: return UDI_STAT_INVALID_STATE; 124: } 125: 126: return UDI_OK; 127: }
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.