AG903ライブラリリファレンス
内容インデックスホーム
Body Source
本文ソース
1: uhs_status_t Usbh_Cdc_SetControlLineState(void* pContext, 2: PCDC_CONTROL_LINE_STATE pstData) 3: { 4: PCDC_DEVICE pCdcDevice; 5: usb_device_request_t* pRequest; 6: CDC_FUNC_STATUS nRetval; 7: uhs_ubit8_t u8CntDeviceId; 8: uhs_status_t nRetStatus; 9: uhs_status_t nRetvalResorce; 10: 11: 12: 13: 14: if( pContext == NULL ){ 15: CIAPI_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: CIAPI_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_CLSREQ_DET); 32: if(nRetStatus != USBCDC_API_SUCCESS){ 33: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 34: return(nRetStatus); 35: } 36: 37: 38: 39: 40: if(pstData == NULL) { 41: 42: 43: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 44: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 45: return( USBCDC_API_PARAM_ERROR ); 46: } 47: if( pstData->u16Data > 3 ) { 48: 49: 50: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 51: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 52: return( USBCDC_API_PARAM_ERROR ); 53: } 54: 55: 56: 57: 58: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 59: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 60: 61: 62: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 63: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 64: return( USBCDC_API_NOT_READY ); 65: } 66: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 67: 68: 69: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 70: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 71: return( USBCDC_API_NO_SUPPORT ); 72: } 73: else { 74: ; 75: } 76: 77: 78: 79: 80: pRequest = CdcUtils_Malloc(sizeof(usb_device_request_t)); 81: if(pRequest == NULL) { 82: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 83: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 84: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 85: } 86: 87: 88: 89: 90: pRequest->bmRequestType = 0x21; 91: pRequest->bRequest = 0x22; 92: pRequest->wValue0 = UNPACK16_LITTLE_ENDIAN_LSB( pstData->u16Data ); 93: pRequest->wValue1 = UNPACK16_LITTLE_ENDIAN_MSB( pstData->u16Data ); 94: pRequest->wIndex0 = 0x00; 95: pRequest->wIndex1 = 0x00; 96: pRequest->wLength0 = UNPACK16_LITTLE_ENDIAN_LSB( 0x0000 ); 97: pRequest->wLength1 = UNPACK16_LITTLE_ENDIAN_MSB( 0x0000 ); 98: 99: 100: 101: 102: nRetval = Usbh_Cdc_ForCommand(pCdcDevice, pRequest, NULL, NULL); 103: if(nRetval != CDC_FUNC_STATUS_SUCCESS){ 104: CdcUtils_Free(pRequest); 105: 106: 107: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 108: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_CLSREQ ); 109: return( USBCDC_API_TRANS_CLSREQ_FAILED ); 110: } 111: 112: 113: 114: 115: CdcUtils_Free(pRequest); 116: 117: 118: 119: 120: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pClsReqDetAccessLock[u8CntDeviceId] ); 121: if(nRetvalResorce != TRUE){ 122: 123: CIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 124: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 125: } 126: 127: return( USBCDC_API_SUCCESS ); 128: }
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.