📄 d12impl.lst
字号:
203
204 void D12_SetMode(u8 bConfig, u8 bClkDiv)
205 {
206 1 if(bEppflags.flags.in_isr == 0)
207 1 DISABLE_INTERRUPT;
208 1 D12_WritePort(D12_COMMAND, D12CMD_SET_MODE);
209 1 D12_WritePort(D12_DATA, bConfig);
210 1 D12_WritePort(D12_DATA, bClkDiv);
211 1 if(bEppflags.flags.in_isr == 0)
212 1 ENABLE_INTERRUPT;
213 1 }
214
215 u16 D12_ReadInterruptRegister(void)
216 {
217 1 u8 b1;
218 1 u16 j;
219 1 D12_WritePort(D12_COMMAND, D12CMD_READ_INTREG);
220 1 b1 = D12_ReadPort();
221 1 j = D12_ReadPort();
222 1 j <<= 8;
223 1 j += b1;
224 1 return j;
225 1 }
226
227 u8 D12_SelectEndpoint(u8 bEndp)
228 {
229 1 u8 c;
230 1 if(bEppflags.flags.in_isr == 0)
231 1 DISABLE_INTERRUPT;
232 1 D12_WritePort(D12_COMMAND, D12CMD_SEL_EPCTLOUT+bEndp);
233 1 c = D12_ReadPort();
234 1 if(bEppflags.flags.in_isr == 0)
235 1 ENABLE_INTERRUPT;
236 1 return c;
237 1 }
238
239 u8 D12_ReadLastTransactionStatus(u8 bEndp)
240 {
241 1 u8 ret;
C51 COMPILER V7.01 D12IMPL 06/30/2007 11:42:51 PAGE 5
242 1 D12_WritePort(D12_COMMAND,
243 1 D12CMD_GETLASTSTATUS_EPCTLOUT + bEndp);
244 1 ret = D12_ReadPort();
245 1 return ret;
246 1 }
247
248
249 u8 D12_ReadEndpointStatus(u8 bEndp)
250 {
251 1 u8 c;
252 1 if(bEppflags.flags.in_isr == 0)
253 1 DISABLE_INTERRUPT;
254 1 D12_WritePort(D12_COMMAND, D12CMD_GETEPSTATUS_EPCTLOUT + bEndp);
255 1 c = D12_ReadPort();
256 1 if(bEppflags.flags.in_isr == 0)
257 1 ENABLE_INTERRUPT;
258 1 return c;
259 1 }
260
261 void D12_SetEndpointStatus(u8 bEndp, u8 bStalled)
262 {
263 1 if(bEppflags.flags.in_isr == 0)
264 1 DISABLE_INTERRUPT;
265 1 D12_WritePort(D12_COMMAND, D12CMD_SETSTATUS_EPCTLOUT + bEndp);
266 1 D12_WritePort(D12_DATA, bStalled);
267 1 if(bEppflags.flags.in_isr == 0)
268 1 ENABLE_INTERRUPT;
269 1 }
270
271 /*
272 void D12_SendResume(void)
273 {
274 D12_WritePort(D12_COMMAND, D12CMD_SEND_RESUME);
275 }
276 */
277
278 /*
279 u16 D12_ReadCurrentFrameNumber(void)
280 {
281 u16 i,j;
282 if(bEppflags.flags.in_isr == 0)
283 DISABLE_INTERRUPT;
284 D12_WritePort(D12_COMMAND, D12CMD_READ_FRAME);
285 i= D12_ReadPort();
286 j = D12_ReadPort();
287 i += (j<<8);
288 if(bEppflags.flags.in_isr == 0)
289 ENABLE_INTERRUPT;
290 return i;
291 }
292
293 u16 D12_ReadChipID(void)
294 {
295 u16 i=0,j=0;
296 if(bEppflags.flags.in_isr == 0)
297 DISABLE_INTERRUPT;
298 D12_WritePort(D12_COMMAND, 0xFD);
299 i=D12_ReadPort();
300 j=D12_ReadPort();
301 i += (j<<8);
302 if(bEppflags.flags.in_isr == 0)
303 ENABLE_INTERRUPT;
C51 COMPILER V7.01 D12IMPL 06/30/2007 11:42:51 PAGE 6
304 return i;
305 }
306 */
307
308 #define D12_FULLEMPTY 1 //ep buffer is empty
309
310 // D12_ReadMainEndpoint() added by V2.2 to support double-buffering.
311 // Caller should assume maxium 128 bytes of returned data.
312 /*
313 u8 D12_ReadMainEndpoint(u8 * buf)
314 {
315 u8 i, j, k = 0, bDblBuf = 1;
316 if(bEppflags.flags.in_isr == 0)
317 DISABLE_INTERRUPT;
318 D12_WritePort(D12_COMMAND, 0x84);
319 if( (D12_ReadPort() & 0x60) == 0x60)
320 bDblBuf = 2;
321 while(bDblBuf)
322 {
323 D12_WritePort(D12_COMMAND, 4);
324 if((D12_ReadPort() & D12_FULLEMPTY) == 0)
325 break;
326 D12_WritePort(D12_COMMAND, 0xF0);
327 j = D12_ReadPort();
328 j = D12_ReadPort();
329 for(i=0; i<j; i++)
330 *(buf+i+k) = D12_ReadPort();
331 k += j;
332 D12_WritePort(D12_COMMAND, 0xF2);
333 bDblBuf --;
334 }
335 if(bEppflags.flags.in_isr == 0)
336 ENABLE_INTERRUPT;
337 return k;
338 }
339 */
340
341 u8 D12_ReadEndpointBuffer(u8 endp, u8 * buf, u8 len)
342 {
343 1 u8 i, j;
344 1 if(bEppflags.flags.in_isr == 0)
345 1 DISABLE_INTERRUPT;
346 1 D12_WritePort(D12_COMMAND, endp);
347 1 if((D12_ReadPort() & D12_FULLEMPTY) == 0)
348 1 {
349 2 if(bEppflags.flags.in_isr == 0)
350 2 ENABLE_INTERRUPT;
351 2 return 0;
352 2 }
353 1 D12_WritePort(D12_COMMAND, D12CMD_READ_BUFFER);//0xF0);
354 1 j = D12_ReadPort();
355 1 j = D12_ReadPort();
356 1 if(j > len)
357 1 j = len;
358 1 for(i=0; i<j; i++)
359 1 *(buf+i) = D12_ReadPort();
360 1 D12_WritePort(D12_COMMAND, 0xF2);
361 1 if(bEppflags.flags.in_isr == 0)
362 1 ENABLE_INTERRUPT;
363 1 return j;
364 1 }
365
C51 COMPILER V7.01 D12IMPL 06/30/2007 11:42:51 PAGE 7
366 u8 D12_WriteEndpointBuffer(u8 endp, u8 * buf, u8 len) reentrant
367 {
368 1 u8 i;
369 1
370 1 if (endp == D12_EP2IN)
371 1 {
372 2 while (Ep2SendBufferFul == true); //wait previous data to be processed
373 2 Ep2SendBufferFul = true;
374 2 }
375 1
376 1 if(bEppflags.flags.in_isr == 0)
377 1 DISABLE_INTERRUPT;
378 1 D12_WritePort(D12_COMMAND, endp);
379 1 D12_ReadPort();
380 1 D12_WritePort(D12_COMMAND, D12CMD_WRITE_BUFFER);//0xF0);
381 1 D12_WritePort(D12_DATA, 0);
382 1 D12_WritePort(D12_DATA, len);
383 1 for(i=0; i<len; i++)
384 1 D12_WritePort(D12_DATA, *(buf+i));
385 1 D12_WritePort(D12_COMMAND, 0xFA);
386 1 if(bEppflags.flags.in_isr == 0)
387 1 ENABLE_INTERRUPT;
388 1
389 1 return len;
390 1 }
391
392 void D12_AcknowledgeEndpoint(u8 endp)
393 {
394 1 D12_WritePort(D12_COMMAND, endp);
395 1 D12_WritePort(D12_COMMAND, 0xF1);
396 1 if(endp == 0)
397 1 D12_WritePort(D12_COMMAND, 0xF2);
398 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 793 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 144 5
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -