1: uhs_status_t Usbh_Cdc_RestartBulkIN(
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: nRetStatus = Usbh_Cdc_CheckDeviceStatus(pContext, &pCdcDevice, &u8CntDeviceId, ID_API_DET);
30:
if(nRetStatus !=
USBCDC_API_SUCCESS){
31: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_SYSTEM_ERROR );
32:
return(nRetStatus);
33: }
34:
35:
36:
37:
38: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pDataInExecuteLock, WAITFOREVER);
39:
if( nRetvalResorce != TRUE ){
40:
41:
42:
43: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
44: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
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:
59: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_USE );
60:
return(
USBCDC_API_NOT_READY );
61: }
62:
else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_NO_SUPPORT ) {
63:
64:
65:
66: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
67: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
68:
69: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NO_SUPPORT );
70:
return(
USBCDC_API_NO_SUPPORT );
71: }
72:
else if( pCdcDevice->nDeviceStat == CDC_DEVICE_STAT_CLOSE ) {
73:
74:
75:
76: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
77: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
78:
79: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_NOT_OPEN );
80:
return(
USBCDC_API_NOT_OPEN );
81: }
82:
else {
83: ;
84: }
85:
86:
87:
88:
89: nRetvalResorce = CdcUtils_AcquisitionSemaphore(pCdcDevice->pBulkINBuffAccessLock, WAITFOREVER);
90:
if( nRetvalResorce != TRUE ){
91:
92:
93:
94: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
95: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
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 == TRUE ) {
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_START_BULKIN );
117:
return(
USBCDC_API_ALREADY_START_BULKIN );
118: }
119:
120:
121:
122:
123: pCdcDevice->pBulkInBuff->pu8EndBuff = (pCdcDevice->pBulkInBuff->pu8StartBuff + (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024));
124: pCdcDevice->pBulkInBuff->pu8ReadPos = pCdcDevice->pBulkInBuff->pu8StartBuff;
125: pCdcDevice->pBulkInBuff->pu8WritePos = pCdcDevice->pBulkInBuff->pu8StartBuff;
126: pCdcDevice->pBulkInBuff->u32RemainBuffSize = (pCdcDevice->pBulkInBuff->u8TotalBuffSize * 1024);
127:
128:
129:
130:
131: nRetval = Usbh_Cdc_IssueBulkINMsg(pCdcDevice);
132:
if(nRetval != CDC_FUNC_STATUS_SUCCESS ) {
133:
134:
135: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock );
136:
137:
138:
139: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
140:
141:
142:
143: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
144:
145:
146: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_FAILED_BULK );
147:
return(
USBCDC_API_TRANS_DATA_FAILED );
148: }
149:
150:
151:
152:
153: pCdcDevice->pBulkInBuff->isBulkINFlag = TRUE;
154:
155:
156:
157: pCdcDevice->pBulkInBuff->isBulkINUserFlag = TRUE;
158:
159:
160:
161:
162: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pBulkINBuffAccessLock );
163:
if(nRetvalResorce != TRUE){
164:
165:
166:
167: (
void)CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
168: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
169:
170:
171: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
172:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
173: }
174:
175:
176:
177:
178: nRetvalResorce = CdcUtils_ReleaseSemaphore( pCdcDevice->pDataInExecuteLock );
179:
if(nRetvalResorce != TRUE){
180:
181:
182: (
void)CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
183:
184:
185: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
186:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
187: }
188:
189:
190:
191:
192: nRetvalResorce = CdcUtils_ReleaseSemaphore( g_pCdcDriver->pApiDetAccessLock[u8CntDeviceId] );
193:
if(nRetvalResorce != TRUE){
194:
195: DIAPI_CDC_REPORT_SUMMARY( USBCDC_LOG_SYS_OUT_OF_RESOURCE );
196:
return(
USBCDC_API_SYS_OUT_OF_RESOURCE );
197: }
198:
199:
return(
USBCDC_API_SUCCESS );
200: }