AG903ライブラリリファレンス
内容インデックスホーム
Body Source
本文ソース
1: uhs_status_t Usbh_Cdc_ReadData(void* pContext, 2: PCDC_BUFF_INFO pstData, 3: uhs_ubit32_t* pu32RemainBuffSize) 4: { 5: PCDC_DEVICE pCdcDevice; 6: uhs_status_t nRetvalResorce; 7: CDC_FUNC_STATUS nRetval; 8: uhs_ubit8_t u8CntDeviceId; 9: uhs_status_t nRetStatus; 10: 11: 12: 13: 14: if( pContext == NULL) { 15: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 16: return( USBCDC_API_PARAM_ERROR ); 17: } 18: 19: 20: 21: 22: if( g_pCdcDriver == NULL ) { 23: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 24: return( USBCDC_API_SYS_SYSTEM_ERROR ); 25: } 26: 27: 28: 29: 30: 31: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 32: if(nRetStatus != USBCDC_API_SUCCESS){ 33: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 34: return(nRetStatus); 35: } 36: 37: 38: 39: 40: if( (pstData == NULL) || 41: (pstData->pu8Buff == NULL) || 42: (pstData->u32RequestLength == 0) || 43: (pu32RemainBuffSize == NULL) ) { 44: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 45: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 46: return( USBCDC_API_PARAM_ERROR ); 47: } 48: 49: 50: 51: 52: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER); 53: if( nRetvalResorce != TRUE ){ 54: 55: 56: 57: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 58: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 59: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 60: } 61: 62: 63: 64: 65: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 66: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 67: 68: 69: 70: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 71: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 72: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 73: return( USBCDC_API_NOT_READY ); 74: } 75: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 76: 77: 78: 79: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 80: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 81: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 82: return( USBCDC_API_NO_SUPPORT ); 83: } 84: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) { 85: 86: 87: 88: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 89: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 90: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN ); 91: return( USBCDC_API_NOT_OPEN ); 92: } 93: else { 94: ; 95: } 96: 97: 98: 99: 100: nRetval = Usbh_Cdc_ExeBulkInReadBuff(pCdcDevice, pstData, pu32RemainBuffSize); 101: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 102: 103: 104: 105: 106: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 107: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 108: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 109: return( USBCDC_API_TRANS_DATA_FAILED ); 110: } 111: 112: 113: 114: 115: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 116: if(nRetvalResorce != TRUE){ 117: 118: 119: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 120: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 121: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 122: } 123: 124: 125: 126: 127: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 128: if(nRetvalResorce != TRUE){ 129: 130: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 131: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 132: } 133: 134: return( USBCDC_API_SUCCESS ); 135: }
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.