AG903ライブラリリファレンス
内容インデックスホーム
前へ上へ次へ
usb_cdc_dataif_api.c

USBH CDC API

USBH CDC API

none

AXELL CORPORATION

2017_02_22 初版 

2017_10_26 Ver2.0

1: 9: 10: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: #include "usb_cdc_acm.h" 24: #include "usb_cdc_common.h" 25: #include "usb_cdc_osutils.h" 26: #include "usb_cdc_dataif_api.h" 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: #ifdef USBH_STACK_DEBUG_BUILD 60: static const char g_filename[] = __FILE__; 61: #endif 62: 63: 64: 65: 66: 67: 91: uhs_status_t Usbh_Cdc_Open(void* pContext) 92: { 93: PCDC_DEVICE pCdcDevice; 94: uhs_status_t nRetvalResorce; 95: CDC_FUNC_STATUS nRetval; 96: uhs_ubit8_t u8CntDeviceId; 97: uhs_status_t nRetStatus; 98: 99: 100: 101: 102: DIAPI_CDC_REPORT_MILESTONE( USBCDC_CHKPOINTS_API_OPEN ); 103: 104: 105: 106: 107: if( pContext == NULL) { 108: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 109: return( USBCDC_API_PARAM_ERROR ); 110: } 111: 112: 113: 114: 115: if( g_pCdcDriver == NULL ) { 116: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 117: return( USBCDC_API_SYS_SYSTEM_ERROR ); 118: } 119: 120: 121: 122: 123: 124: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 125: if(nRetStatus != USBCDC_API_SUCCESS){ 126: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 127: return(nRetStatus); 128: } 129: 130: 131: 132: 133: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER); 134: if( nRetvalResorce != TRUE ){ 135: 136: 137: 138: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 139: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 140: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 141: } 142: 143: 144: 145: 146: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 147: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 148: 149: 150: 151: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 152: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 153: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 154: return( USBCDC_API_NOT_READY ); 155: } 156: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 157: 158: 159: 160: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 161: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 162: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 163: return( USBCDC_API_NO_SUPPORT ); 164: } 165: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_OPEN ) { 166: 167: 168: 169: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 170: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 171: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_OPEN ); 172: return( USBCDC_API_ALREADY_OPEN ); 173: } 174: else { 175: ; 176: } 177: 178: 179: 180: 181: if( (pCdcDevice->pBulkInBuff->pu8StartBuff = (uhs_ubit8_t*)CdcUtils_BuffMalloc((uhs_size_t) (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024))) == NULL ) { 182: 183: 184: 185: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 186: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 187: 188: 189: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 190: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 191: } 192: pCdcDevice->pBulkInBuff->pu8EndBuff = (pCdcDevice->pBulkInBuff->pu8StartBuff + (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024)); 193: pCdcDevice->pBulkInBuff->pu8ReadPos = pCdcDevice->pBulkInBuff->pu8StartBuff; 194: pCdcDevice->pBulkInBuff->pu8WritePos = pCdcDevice->pBulkInBuff->pu8StartBuff; 195: pCdcDevice->pBulkInBuff->u32RemainBuffSize = (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024); 196: 197: 198: 199: 200: if( (pCdcDevice->pBulkInBuff->pu8TempBuff = (uhs_ubit8_t*)CdcUtils_BuffMalloc((uhs_size_t) (CDC_BULKIN_TEMP_BUFF_SIZE))) == NULL ) { 201: 202: 203: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ); 204: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 205: pCdcDevice->pBulkInBuff->pu8EndBuff = NULL; 206: pCdcDevice->pBulkInBuff->pu8ReadPos = NULL; 207: pCdcDevice->pBulkInBuff->pu8WritePos = NULL; 208: pCdcDevice->pBulkInBuff->u32RemainBuffSize = 0; 209: 210: 211: 212: 213: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 214: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 215: 216: 217: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 218: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 219: } 220: 221: 222: 223: 224: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 225: if( nRetvalResorce != TRUE ){ 226: 227: 228: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8TempBuff ); 229: pCdcDevice->pBulkInBuff->pu8TempBuff = NULL; 230: 231: 232: 233: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ); 234: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 235: pCdcDevice->pBulkInBuff->pu8EndBuff = NULL; 236: pCdcDevice->pBulkInBuff->pu8ReadPos = NULL; 237: pCdcDevice->pBulkInBuff->pu8WritePos = NULL; 238: pCdcDevice->pBulkInBuff->u32RemainBuffSize = 0; 239: 240: 241: 242: 243: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 244: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 245: 246: 247: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 248: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 249: } 250: 251: 252: 253: 254: nRetval = Usbh_Cdc_IssueBulkINMsg(pCdcDevice); 255: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 256: 257: 258: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8TempBuff ); 259: pCdcDevice->pBulkInBuff->pu8TempBuff = NULL; 260: 261: 262: 263: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ); 264: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 265: pCdcDevice->pBulkInBuff->pu8EndBuff = NULL; 266: pCdcDevice->pBulkInBuff->pu8ReadPos = NULL; 267: pCdcDevice->pBulkInBuff->pu8WritePos = NULL; 268: pCdcDevice->pBulkInBuff->u32RemainBuffSize = 0; 269: 270: 271: 272: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 273: 274: 275: 276: 277: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 278: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 279: 280: 281: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 282: return( USBCDC_API_TRANS_DATA_FAILED ); 283: } 284: 285: 286: 287: 288: pCdcDevice->nDeviceStat = CDC_DEVICE_STAT_OPEN; 289: 290: 291: 292: pCdcDevice->pBulkInBuff->isBulkINFlag = TRUE; 293: 294: 295: 296: pCdcDevice->pBulkInBuff->isBulkINUserFlag = TRUE; 297: 298: 299: 300: 301: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 302: if(nRetvalResorce != TRUE){ 303: 304: 305: (void)CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 306: 307: 308: 309: (void)Usbh_Cdc_StopBulkINMsg(pCdcDevice); 310: 311: pCdcDevice->nDeviceStat = CDC_DEVICE_STAT_CLOSE; 312: pCdcDevice->pBulkInBuff->isBulkINFlag = FALSE; 313: pCdcDevice->pBulkInBuff->isBulkINUserFlag = FALSE; 314: 315: 316: 317: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 318: 319: 320: 321: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8TempBuff ); 322: pCdcDevice->pBulkInBuff->pu8TempBuff = NULL; 323: 324: 325: 326: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ); 327: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 328: pCdcDevice->pBulkInBuff->pu8EndBuff = NULL; 329: pCdcDevice->pBulkInBuff->pu8ReadPos = NULL; 330: pCdcDevice->pBulkInBuff->pu8WritePos = NULL; 331: pCdcDevice->pBulkInBuff->u32RemainBuffSize = 0; 332: 333: 334: 335: 336: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 337: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 338: 339: 340: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 341: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 342: } 343: 344: 345: 346: 347: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 348: if(nRetvalResorce != TRUE){ 349: 350: 351: (void)CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 352: 353: 354: 355: (void)Usbh_Cdc_StopBulkINMsg(pCdcDevice); 356: 357: pCdcDevice->nDeviceStat = CDC_DEVICE_STAT_CLOSE; 358: pCdcDevice->pBulkInBuff->isBulkINFlag = FALSE; 359: pCdcDevice->pBulkInBuff->isBulkINUserFlag = FALSE; 360: 361: 362: 363: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 364: 365: 366: 367: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8TempBuff ); 368: pCdcDevice->pBulkInBuff->pu8TempBuff = NULL; 369: 370: 371: 372: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ); 373: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 374: pCdcDevice->pBulkInBuff->pu8EndBuff = NULL; 375: pCdcDevice->pBulkInBuff->pu8ReadPos = NULL; 376: pCdcDevice->pBulkInBuff->pu8WritePos = NULL; 377: pCdcDevice->pBulkInBuff->u32RemainBuffSize = 0; 378: 379: 380: 381: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 382: 383: 384: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 385: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 386: } 387: 388: 389: 390: 391: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 392: if(nRetvalResorce != TRUE){ 393: 394: 395: (void)CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 396: 397: 398: 399: (void)Usbh_Cdc_StopBulkINMsg(pCdcDevice); 400: 401: pCdcDevice->nDeviceStat = CDC_DEVICE_STAT_CLOSE; 402: pCdcDevice->pBulkInBuff->isBulkINFlag = FALSE; 403: pCdcDevice->pBulkInBuff->isBulkINUserFlag = FALSE; 404: 405: 406: 407: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 408: 409: 410: 411: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8TempBuff ); 412: pCdcDevice->pBulkInBuff->pu8TempBuff = NULL; 413: 414: 415: 416: (void)CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ); 417: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 418: pCdcDevice->pBulkInBuff->pu8EndBuff = NULL; 419: pCdcDevice->pBulkInBuff->pu8ReadPos = NULL; 420: pCdcDevice->pBulkInBuff->pu8WritePos = NULL; 421: pCdcDevice->pBulkInBuff->u32RemainBuffSize = 0; 422: 423: 424: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 425: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 426: } 427: 428: 429: 430: 431: DIAPI_CDC_REPORT_MILESTONE( USBCDC_CHKPOINTS_API_OPEN_FINISH ); 432: 433: return( USBCDC_API_SUCCESS ); 434: } 435: 436: 461: uhs_status_t Usbh_Cdc_Close(void* pContext) 462: { 463: PCDC_DEVICE pCdcDevice; 464: uhs_status_t nRetvalResorce; 465: CDC_FUNC_STATUS nRetval; 466: uhs_boolean_t isErr = FALSE; 467: uhs_ubit8_t u8CntDeviceId; 468: uhs_status_t nRetStatus; 469: 470: 471: 472: 473: DIAPI_CDC_REPORT_MILESTONE( USBCDC_CHKPOINTS_API_CLOSE ); 474: 475: 476: 477: 478: if( pContext == NULL ) { 479: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 480: return( USBCDC_API_PARAM_ERROR ); 481: } 482: 483: 484: 485: 486: if( g_pCdcDriver == NULL ) { 487: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 488: return( USBCDC_API_SYS_SYSTEM_ERROR ); 489: } 490: 491: 492: 493: 494: 495: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 496: if(nRetStatus != USBCDC_API_SUCCESS){ 497: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 498: return(nRetStatus); 499: } 500: 501: 502: 503: 504: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER); 505: if( nRetvalResorce != TRUE ){ 506: 507: 508: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 509: 510: 511: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 512: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 513: } 514: 515: 516: 517: 518: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 519: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 520: 521: 522: 523: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 524: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 525: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 526: return( USBCDC_API_NOT_READY ); 527: } 528: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 529: 530: 531: 532: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 533: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 534: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 535: return( USBCDC_API_NO_SUPPORT ); 536: } 537: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) { 538: 539: 540: 541: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 542: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 543: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_CLOSE ); 544: return( USBCDC_API_ALREADY_CLOSE ); 545: } 546: else { 547: ; 548: } 549: 550: 551: 552: 553: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 554: if( nRetvalResorce != TRUE ){ 555: 556: 557: 558: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 559: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 560: 561: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 562: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 563: } 564: 565: 566: 567: 568: nRetval = Usbh_Cdc_StopBulkINMsg(pCdcDevice); 569: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 570: 571: 572: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 573: 574: 575: 576: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 577: 578: 579: 580: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 581: 582: 583: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 584: return( USBCDC_API_TRANS_DATA_FAILED ); 585: } 586: 587: 588: 589: 590: pCdcDevice->nDeviceStat = CDC_DEVICE_STAT_CLOSE; 591: 592: 593: 594: pCdcDevice->pBulkInBuff->isBulkINFlag = FALSE; 595: 596: 597: 598: pCdcDevice->pBulkInBuff->isBulkINUserFlag = FALSE; 599: 600: 601: 602: 603: 604: if( pCdcDevice->pBulkInBuff->pu8TempBuff != NULL ) { 605: 606: 607: 608: if( CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8TempBuff ) == FALSE ){ 609: isErr = TRUE; 610: } 611: pCdcDevice->pBulkInBuff->pu8TempBuff = NULL; 612: } 613: 614: 615: 616: 617: 618: if( pCdcDevice->pBulkInBuff->pu8StartBuff != NULL ) { 619: 620: 621: 622: if( CdcUtils_BuffFree( pCdcDevice->pBulkInBuff->pu8StartBuff ) == FALSE ){ 623: isErr = TRUE; 624: } 625: pCdcDevice->pBulkInBuff->pu8StartBuff = NULL; 626: } 627: 628: 629: 630: 631: if( isErr == TRUE ) { 632: 633: 634: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 635: 636: 637: 638: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 639: 640: 641: 642: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 643: 644: 645: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 646: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 647: } 648: 649: 650: 651: 652: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 653: if(nRetvalResorce != TRUE){ 654: 655: 656: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 657: 658: 659: 660: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 661: 662: 663: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 664: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 665: } 666: 667: 668: 669: 670: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 671: if(nRetvalResorce != TRUE){ 672: 673: 674: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 675: 676: 677: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 678: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 679: } 680: 681: 682: 683: 684: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 685: if(nRetvalResorce != TRUE){ 686: 687: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 688: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 689: } 690: 691: 692: 693: 694: DIAPI_CDC_REPORT_MILESTONE( USBCDC_CHKPOINTS_API_CLOSE_FINISH ); 695: 696: return( USBCDC_API_SUCCESS ); 697: } 698: 699: 725: uhs_status_t Usbh_Cdc_ReadData(void* pContext, 726: PCDC_BUFF_INFO pstData, 727: uhs_ubit32_t* pu32RemainBuffSize) 728: { 729: PCDC_DEVICE pCdcDevice; 730: uhs_status_t nRetvalResorce; 731: CDC_FUNC_STATUS nRetval; 732: uhs_ubit8_t u8CntDeviceId; 733: uhs_status_t nRetStatus; 734: 735: 736: 737: 738: if( pContext == NULL) { 739: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 740: return( USBCDC_API_PARAM_ERROR ); 741: } 742: 743: 744: 745: 746: if( g_pCdcDriver == NULL ) { 747: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 748: return( USBCDC_API_SYS_SYSTEM_ERROR ); 749: } 750: 751: 752: 753: 754: 755: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 756: if(nRetStatus != USBCDC_API_SUCCESS){ 757: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 758: return(nRetStatus); 759: } 760: 761: 762: 763: 764: if( (pstData == NULL) || 765: (pstData->pu8Buff == NULL) || 766: (pstData->u32RequestLength == 0) || 767: (pu32RemainBuffSize == NULL) ) { 768: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 769: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 770: return( USBCDC_API_PARAM_ERROR ); 771: } 772: 773: 774: 775: 776: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER); 777: if( nRetvalResorce != TRUE ){ 778: 779: 780: 781: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 782: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 783: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 784: } 785: 786: 787: 788: 789: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 790: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 791: 792: 793: 794: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 795: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 796: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 797: return( USBCDC_API_NOT_READY ); 798: } 799: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 800: 801: 802: 803: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 804: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 805: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 806: return( USBCDC_API_NO_SUPPORT ); 807: } 808: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) { 809: 810: 811: 812: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 813: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 814: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN ); 815: return( USBCDC_API_NOT_OPEN ); 816: } 817: else { 818: ; 819: } 820: 821: 822: 823: 824: nRetval = Usbh_Cdc_ExeBulkInReadBuff(pCdcDevice, pstData, pu32RemainBuffSize); 825: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 826: 827: 828: 829: 830: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 831: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 832: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 833: return( USBCDC_API_TRANS_DATA_FAILED ); 834: } 835: 836: 837: 838: 839: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 840: if(nRetvalResorce != TRUE){ 841: 842: 843: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 844: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 845: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 846: } 847: 848: 849: 850: 851: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 852: if(nRetvalResorce != TRUE){ 853: 854: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 855: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 856: } 857: 858: return( USBCDC_API_SUCCESS ); 859: } 860: 861: 885: uhs_status_t Usbh_Cdc_WriteData(void* pContext, 886: PCDC_BUFF_INFO pstData) 887: { 888: PCDC_DEVICE pCdcDevice; 889: uhs_status_t nRetvalResorce; 890: CDC_FUNC_STATUS nRetval; 891: uhs_ubit8_t u8CntDeviceId; 892: uhs_status_t nRetStatus; 893: 894: 895: 896: 897: if( pContext == NULL) { 898: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 899: return( USBCDC_API_PARAM_ERROR ); 900: } 901: 902: 903: 904: 905: if( g_pCdcDriver == NULL ) { 906: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 907: return( USBCDC_API_SYS_SYSTEM_ERROR ); 908: } 909: 910: 911: 912: 913: 914: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 915: if(nRetStatus != USBCDC_API_SUCCESS){ 916: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 917: return(nRetStatus); 918: } 919: 920: 921: 922: 923: if( (pstData == NULL) || 924: (pstData->pu8Buff == NULL) || 925: (pstData->u32RequestLength == 0) ) { 926: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 927: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 928: return( USBCDC_API_PARAM_ERROR ); 929: } 930: 931: 932: 933: 934: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataOutExecuteLock, WAITFOREVER); 935: if( nRetvalResorce != TRUE ){ 936: 937: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 938: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 939: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 940: } 941: 942: 943: 944: 945: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 946: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 947: 948: 949: 950: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataOutExecuteLock ); 951: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 952: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 953: return( USBCDC_API_NOT_READY ); 954: } 955: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 956: 957: 958: 959: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataOutExecuteLock ); 960: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 961: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 962: return( USBCDC_API_NO_SUPPORT ); 963: } 964: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) { 965: 966: 967: 968: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataOutExecuteLock ); 969: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 970: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN ); 971: return( USBCDC_API_NOT_OPEN ); 972: } 973: else { 974: ; 975: } 976: 977: 978: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 979: 980: 981: 982: 983: nRetval = Usbh_Cdc_IssueSyncBulkOutMsg(pCdcDevice, pstData, 984: g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId], CDC_BULK_TIMEOUT); 985: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 986: 987: 988: 989: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataOutExecuteLock ); 990: 991: 992: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 993: if( nRetval == CDC_FUNC_STATUS_HALT_PIPE ) { 994: return( USBCDC_API_TRANS_HALT_PIPE ); 995: }else{ 996: return( USBCDC_API_TRANS_DATA_FAILED ); 997: } 998: } 999: 1000: 1001: 1002: 1003: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataOutExecuteLock ); 1004: if(nRetvalResorce != TRUE){ 1005: 1006: 1007: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1008: 1009: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1010: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1011: } 1012: 1013: return( USBCDC_API_SUCCESS ); 1014: } 1015: 1016: 1043: uhs_status_t Usbh_Cdc_RestartBulkIN(void* pContext) 1044: { 1045: PCDC_DEVICE pCdcDevice; 1046: uhs_status_t nRetvalResorce; 1047: CDC_FUNC_STATUS nRetval; 1048: uhs_ubit8_t u8CntDeviceId; 1049: uhs_status_t nRetStatus; 1050: 1051: 1052: 1053: 1054: if( pContext == NULL ) { 1055: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 1056: return( USBCDC_API_PARAM_ERROR ); 1057: } 1058: 1059: 1060: 1061: 1062: if( g_pCdcDriver == NULL ) { 1063: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 1064: return( USBCDC_API_SYS_SYSTEM_ERROR ); 1065: } 1066: 1067: 1068: 1069: 1070: 1071: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 1072: if(nRetStatus != USBCDC_API_SUCCESS){ 1073: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 1074: return(nRetStatus); 1075: } 1076: 1077: 1078: 1079: 1080: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER); 1081: if( nRetvalResorce != TRUE ){ 1082: 1083: 1084: 1085: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1086: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1087: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1088: } 1089: 1090: 1091: 1092: 1093: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 1094: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 1095: 1096: 1097: 1098: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1099: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1100: 1101: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 1102: return( USBCDC_API_NOT_READY ); 1103: } 1104: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 1105: 1106: 1107: 1108: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1109: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1110: 1111: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 1112: return( USBCDC_API_NO_SUPPORT ); 1113: } 1114: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) { 1115: 1116: 1117: 1118: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1119: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1120: 1121: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN ); 1122: return( USBCDC_API_NOT_OPEN ); 1123: } 1124: else { 1125: ; 1126: } 1127: 1128: 1129: 1130: 1131: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 1132: if( nRetvalResorce != TRUE ){ 1133: 1134: 1135: 1136: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1137: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1138: 1139: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1140: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1141: } 1142: 1143: 1144: if( pCdcDevice->pBulkInBuff->isBulkINFlag == TRUE ) { 1145: 1146: 1147: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 1148: 1149: 1150: 1151: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1152: 1153: 1154: 1155: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1156: 1157: 1158: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_START_BULKIN ); 1159: return( USBCDC_API_ALREADY_START_BULKIN ); 1160: } 1161: 1162: 1163: 1164: 1165: pCdcDevice->pBulkInBuff->pu8EndBuff = (pCdcDevice->pBulkInBuff->pu8StartBuff + (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024)); 1166: pCdcDevice->pBulkInBuff->pu8ReadPos = pCdcDevice->pBulkInBuff->pu8StartBuff; 1167: pCdcDevice->pBulkInBuff->pu8WritePos = pCdcDevice->pBulkInBuff->pu8StartBuff; 1168: pCdcDevice->pBulkInBuff->u32RemainBuffSize = (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024); 1169: 1170: 1171: 1172: 1173: nRetval = Usbh_Cdc_IssueBulkINMsg(pCdcDevice); 1174: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 1175: 1176: 1177: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 1178: 1179: 1180: 1181: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1182: 1183: 1184: 1185: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1186: 1187: 1188: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 1189: return( USBCDC_API_TRANS_DATA_FAILED ); 1190: } 1191: 1192: 1193: 1194: 1195: pCdcDevice->pBulkInBuff->isBulkINFlag = TRUE; 1196: 1197: 1198: 1199: pCdcDevice->pBulkInBuff->isBulkINUserFlag = TRUE; 1200: 1201: 1202: 1203: 1204: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 1205: if(nRetvalResorce != TRUE){ 1206: 1207: 1208: 1209: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1210: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1211: 1212: 1213: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1214: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1215: } 1216: 1217: 1218: 1219: 1220: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1221: if(nRetvalResorce != TRUE){ 1222: 1223: 1224: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1225: 1226: 1227: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1228: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1229: } 1230: 1231: 1232: 1233: 1234: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1235: if(nRetvalResorce != TRUE){ 1236: 1237: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1238: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1239: } 1240: 1241: return( USBCDC_API_SUCCESS ); 1242: } 1243: 1244: 1267: uhs_status_t Usbh_Cdc_StopBulkIN(void* pContext) 1268: { 1269: PCDC_DEVICE pCdcDevice; 1270: uhs_status_t nRetvalResorce; 1271: CDC_FUNC_STATUS nRetval; 1272: uhs_ubit8_t u8CntDeviceId; 1273: uhs_status_t nRetStatus; 1274: 1275: 1276: 1277: 1278: if( pContext == NULL ) { 1279: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 1280: return( USBCDC_API_PARAM_ERROR ); 1281: } 1282: 1283: 1284: 1285: 1286: if( g_pCdcDriver == NULL ) { 1287: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 1288: return( USBCDC_API_SYS_SYSTEM_ERROR ); 1289: } 1290: 1291: 1292: 1293: 1294: 1295: 1296: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 1297: if(nRetStatus != USBCDC_API_SUCCESS){ 1298: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 1299: return(nRetStatus); 1300: } 1301: 1302: 1303: 1304: 1305: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER); 1306: if( nRetvalResorce != TRUE ){ 1307: 1308: 1309: 1310: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1311: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1312: } 1313: 1314: 1315: 1316: 1317: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 1318: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 1319: 1320: 1321: 1322: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1323: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1324: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 1325: return( USBCDC_API_NOT_READY ); 1326: } 1327: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 1328: 1329: 1330: 1331: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1332: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1333: 1334: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 1335: return( USBCDC_API_NO_SUPPORT ); 1336: } 1337: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) { 1338: 1339: 1340: 1341: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1342: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1343: 1344: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN ); 1345: return( USBCDC_API_NOT_OPEN ); 1346: } 1347: else { 1348: ; 1349: } 1350: 1351: 1352: 1353: 1354: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER); 1355: if( nRetvalResorce != TRUE ){ 1356: 1357: 1358: 1359: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1360: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1361: 1362: 1363: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1364: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1365: } 1366: 1367: 1368: if( pCdcDevice->pBulkInBuff->isBulkINFlag == FALSE ) { 1369: 1370: 1371: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 1372: 1373: 1374: 1375: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1376: 1377: 1378: 1379: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1380: 1381: 1382: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_STOP_BULKIN ); 1383: return( USBCDC_API_ALREADY_STOP_BULKIN ); 1384: } 1385: 1386: 1387: 1388: 1389: nRetval = Usbh_Cdc_StopBulkINMsg(pCdcDevice); 1390: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 1391: 1392: 1393: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 1394: 1395: 1396: 1397: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1398: 1399: 1400: 1401: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1402: 1403: 1404: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK ); 1405: return( USBCDC_API_TRANS_DATA_FAILED ); 1406: } 1407: 1408: 1409: 1410: 1411: pCdcDevice->pBulkInBuff->isBulkINFlag = FALSE; 1412: 1413: 1414: 1415: pCdcDevice->pBulkInBuff->isBulkINUserFlag = FALSE; 1416: 1417: 1418: 1419: 1420: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock ); 1421: if(nRetvalResorce != TRUE){ 1422: 1423: 1424: 1425: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1426: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1427: 1428: 1429: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1430: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1431: } 1432: 1433: 1434: 1435: 1436: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock ); 1437: if(nRetvalResorce != TRUE){ 1438: 1439: 1440: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1441: 1442: 1443: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1444: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1445: } 1446: 1447: 1448: 1449: 1450: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1451: if(nRetvalResorce != TRUE){ 1452: 1453: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1454: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1455: } 1456: 1457: return( USBCDC_API_SUCCESS ); 1458: } 1459: 1460: 1483: uhs_status_t Usbh_Cdc_RestartIntIN(void* pContext) 1484: { 1485: PCDC_DEVICE pCdcDevice; 1486: uhs_status_t nRetvalResorce; 1487: CDC_FUNC_STATUS nRetval; 1488: uhs_ubit8_t u8CntDeviceId; 1489: uhs_status_t nRetStatus; 1490: 1491: 1492: 1493: 1494: if( pContext == NULL ) { 1495: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 1496: return( USBCDC_API_PARAM_ERROR ); 1497: } 1498: 1499: 1500: 1501: 1502: if( g_pCdcDriver == NULL ) { 1503: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 1504: return( USBCDC_API_SYS_SYSTEM_ERROR ); 1505: } 1506: 1507: 1508: 1509: 1510: 1511: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 1512: if(nRetStatus != USBCDC_API_SUCCESS){ 1513: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 1514: return(nRetStatus); 1515: } 1516: 1517: 1518: 1519: 1520: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pIntInExecuteLock, WAITFOREVER); 1521: if( nRetvalResorce != TRUE ){ 1522: 1523: 1524: 1525: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1526: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1527: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1528: } 1529: 1530: 1531: 1532: 1533: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 1534: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 1535: 1536: 1537: 1538: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1539: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1540: 1541: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 1542: return( USBCDC_API_NOT_READY ); 1543: } 1544: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 1545: 1546: 1547: 1548: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1549: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1550: 1551: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 1552: return( USBCDC_API_NO_SUPPORT ); 1553: } 1554: else { 1555: ; 1556: } 1557: 1558: 1559: if( pCdcDevice->pIntInBuff->isIntINUserFlag == TRUE ) { 1560: 1561: 1562: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1563: 1564: 1565: 1566: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1567: 1568: 1569: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_START_INTIN ); 1570: return( USBCDC_API_ALREADY_START_INTIN ); 1571: } 1572: 1573: 1574: 1575: 1576: nRetval = Usbh_Cdc_IssueIntInMsg(pCdcDevice); 1577: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 1578: 1579: 1580: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1581: 1582: 1583: 1584: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1585: 1586: 1587: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_INTERRUPT ); 1588: return( USBCDC_API_TRANS_INT_FAILED ); 1589: } 1590: 1591: 1592: 1593: 1594: pCdcDevice->pIntInBuff->isIntINUserFlag = TRUE; 1595: 1596: 1597: 1598: 1599: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1600: if(nRetvalResorce != TRUE){ 1601: 1602: 1603: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1604: 1605: 1606: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1607: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1608: } 1609: 1610: 1611: 1612: 1613: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1614: if(nRetvalResorce != TRUE){ 1615: 1616: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1617: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1618: } 1619: 1620: return( USBCDC_API_SUCCESS ); 1621: } 1622: 1623: 1648: uhs_status_t Usbh_Cdc_StopIntIN(void* pContext) 1649: { 1650: PCDC_DEVICE pCdcDevice; 1651: uhs_status_t nRetvalResorce; 1652: CDC_FUNC_STATUS nRetval; 1653: uhs_ubit8_t u8CntDeviceId; 1654: uhs_status_t nRetStatus; 1655: 1656: 1657: 1658: 1659: if( pContext == NULL ) { 1660: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR ); 1661: return( USBCDC_API_PARAM_ERROR ); 1662: } 1663: 1664: 1665: 1666: 1667: if( g_pCdcDriver == NULL ) { 1668: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT ); 1669: return( USBCDC_API_SYS_SYSTEM_ERROR ); 1670: } 1671: 1672: 1673: 1674: 1675: 1676: 1677: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET); 1678: if(nRetStatus != USBCDC_API_SUCCESS){ 1679: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR ); 1680: return(nRetStatus); 1681: } 1682: 1683: 1684: 1685: 1686: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pIntInExecuteLock, WAITFOREVER); 1687: if( nRetvalResorce != TRUE ){ 1688: 1689: 1690: 1691: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1692: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1693: } 1694: 1695: 1696: 1697: 1698: if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) || 1699: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) { 1700: 1701: 1702: 1703: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1704: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1705: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE ); 1706: return( USBCDC_API_NOT_READY ); 1707: } 1708: else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) { 1709: 1710: 1711: 1712: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1713: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1714: 1715: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT ); 1716: return( USBCDC_API_NO_SUPPORT ); 1717: } 1718: else { 1719: ; 1720: } 1721: 1722: 1723: if( pCdcDevice->pIntInBuff->isIntINUserFlag == FALSE ) { 1724: 1725: 1726: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1727: 1728: 1729: 1730: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1731: 1732: 1733: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_STOP_INTIN ); 1734: return( USBCDC_API_ALREADY_STOP_INTIN ); 1735: } 1736: 1737: 1738: 1739: 1740: nRetval = Usbh_Cdc_StopIntINMsg(pCdcDevice); 1741: if(nRetval != CDC_FUNC_STATUS_SUCCESS ) { 1742: 1743: 1744: (void)CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1745: 1746: 1747: 1748: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1749: 1750: 1751: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_INTERRUPT ); 1752: return( USBCDC_API_TRANS_INT_FAILED ); 1753: } 1754: 1755: 1756: 1757: 1758: pCdcDevice->pIntInBuff->isIntINUserFlag = FALSE; 1759: 1760: 1761: 1762: 1763: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pIntInExecuteLock ); 1764: if(nRetvalResorce != TRUE){ 1765: 1766: 1767: (void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1768: 1769: 1770: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1771: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1772: } 1773: 1774: 1775: 1776: 1777: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] ); 1778: if(nRetvalResorce != TRUE){ 1779: 1780: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE ); 1781: return( USBCDC_API_SYS_OUT_OF_RESOURCE ); 1782: } 1783: 1784: return( USBCDC_API_SUCCESS ); 1785: } 1786:
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.