1: uhs_status_t Usbh_Cdc_StopBulkIN(
void* pContext)
2: {
3:
PCDC_DEVICE pCdcDevice;
4: uhs_status_t nRetvalResorce;
5: CDC_FUNC_STATUS nRetval;
6: uhs_ubit8_t u8CntDeviceId;
7: uhs_status_t nRetStatus;
8:
9:
10:
11:
12:
if( pContext == NULL ) {
13: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_PARAM_ERROR );
14:
return(
USBCDC_API_PARAM_ERROR );
15: }
16:
17:
18:
19:
20:
if( g_pCdcDriver == NULL ) {
21: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_INIT );
22:
return(
USBCDC_API_SYS_SYSTEM_ERROR );
23: }
24:
25:
26:
27:
28:
29:
30: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET);
31:
if(nRetStatus !=
USBCDC_API_SUCCESS){
32: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR );
33:
return(nRetStatus);
34: }
35:
36:
37:
38:
39: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER);
40:
if( nRetvalResorce != TRUE ){
41:
42:
43:
44: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
45:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
46: }
47:
48:
49:
50:
51:
if( (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CONNECTING) ||
52: (pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_REGIST) ) {
53:
54:
55:
56: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
57: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
58: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE );
59:
return(
USBCDC_API_NOT_READY );
60: }
61:
else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) {
62:
63:
64:
65: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
66: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
67:
68: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT );
69:
return(
USBCDC_API_NO_SUPPORT );
70: }
71:
else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) {
72:
73:
74:
75: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
76: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
77:
78: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN );
79:
return(
USBCDC_API_NOT_OPEN );
80: }
81:
else {
82: ;
83: }
84:
85:
86:
87:
88: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER);
89:
if( nRetvalResorce != TRUE ){
90:
91:
92:
93: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
94: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
95:
96:
97: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
98:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
99: }
100:
101:
102:
if( pCdcDevice->pBulkInBuff->isBulkINFlag == FALSE ) {
103:
104:
105: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock );
106:
107:
108:
109: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
110:
111:
112:
113: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
114:
115:
116: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_ALREADY_STOP_BULKIN );
117:
return(
USBCDC_API_ALREADY_STOP_BULKIN );
118: }
119:
120:
121:
122:
123: nRetval = Usbh_Cdc_StopBulkINMsg(pCdcDevice);
124:
if(nRetval != CDC_FUNC_STATUS_SUCCESS ) {
125:
126:
127: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock );
128:
129:
130:
131: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
132:
133:
134:
135: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
136:
137:
138: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK );
139:
return(
USBCDC_API_TRANS_DATA_FAILED );
140: }
141:
142:
143:
144:
145: pCdcDevice->pBulkInBuff->isBulkINFlag = FALSE;
146:
147:
148:
149: pCdcDevice->pBulkInBuff->isBulkINUserFlag = FALSE;
150:
151:
152:
153:
154: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock );
155:
if(nRetvalResorce != TRUE){
156:
157:
158:
159: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
160: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
161:
162:
163: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
164:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
165: }
166:
167:
168:
169:
170: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
171:
if(nRetvalResorce != TRUE){
172:
173:
174: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
175:
176:
177: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
178:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
179: }
180:
181:
182:
183:
184: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
185:
if(nRetvalResorce != TRUE){
186:
187: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
188:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
189: }
190:
191:
return(
USBCDC_API_SUCCESS );
192: }