📄 vcomuser.lst
字号:
314
315
316 /*
317 * USB Endpoint 3 Event Callback
318 * Parameter: event
319 */
320
321 void USB_EndPoint3 (DWORD event) {
322 1 event;
ARM COMPILER V2.31, VCOMuser 23/11/05 10:53:11 PAGE 6
323 1 }
324
325 /*
326 * USB Endpoint 4 Event Callback
327 * Parameter: event
328 */
329
330 void USB_EndPoint4 (DWORD event) {
331 1 event;
332 1 }
333
334 /*
335 * USB Endpoint 5 Event Callback
336 * Parameter: event
337 */
338
339 void USB_EndPoint5 (DWORD event) {
340 1 switch (event) {
341 2 case USB_EVT_IN:
342 2 Data2Host1 = 1;
343 2 break;
344 2 case USB_EVT_OUT:
345 2 DeviceData2UART( 1 );
346 2 break;
347 2 }
348 1 event;
349 1 }
350
351 /*
352 * USB Endpoint 6 Event Callback
353 * Parameter: event
354 */
355
356 void USB_EndPoint6 (DWORD event) {
357 1 event;
358 1 }
359
360
361 /*
362 * USB Endpoint 7 Event Callback
363 * Parameter: event
364 */
365
366 void USB_EndPoint7 (DWORD event) {
367 1 event;
368 1 }
369
370
371 /*
372 * USB Endpoint 8 Event Callback
373 * Parameter: event
374 */
375
376 void USB_EndPoint8 (DWORD event) {
377 1 event;
378 1 }
379
380
381 /*
382 * USB Endpoint 9 Event Callback
383 * Parameter: event
384 */
385
386 void USB_EndPoint9 (DWORD event) {
387 1 event;
388 1 }
ARM COMPILER V2.31, VCOMuser 23/11/05 10:53:11 PAGE 7
389
390
391 /*
392 * USB Endpoint 10 Event Callback
393 * Parameter: event
394 */
395
396 void USB_EndPoint10 (DWORD event) {
397 1 event;
398 1 }
399
400
401 /*
402 * USB Endpoint 11 Event Callback
403 * Parameter: event
404 */
405
406 void USB_EndPoint11 (DWORD event) {
407 1 event;
408 1 }
409
410 /*
411 * USB Endpoint 12 Event Callback
412 * Parameter: event
413 */
414
415 void USB_EndPoint12 (DWORD event) {
416 1 event;
417 1 }
418
419
420 /*
421 * USB Endpoint 13 Event Callback
422 * Parameter: event
423 */
424
425 void USB_EndPoint13 (DWORD event) {
426 1 event;
427 1 }
428
429
430 /*
431 * USB Endpoint 14 Event Callback
432 * Parameter: event
433 */
434
435 void USB_EndPoint14 (DWORD event) {
436 1 event;
437 1 }
438
439
440 /*
441 * USB Endpoint 15 Event Callback
442 * Parameter: event
443 */
444
445 void USB_EndPoint15 (DWORD event) {
446 1 event;
447 1 }
448
449
450
451 /* UART setup and simple putc() and getc() routine */
452 /* Default setting of CCLK is 60Mhz, VPBCLK is 1/4 = 15Mhz */
453
454 void init_serial (void) { /* Initialize Serial Interface */
ARM COMPILER V2.31, VCOMuser 23/11/05 10:53:11 PAGE 8
455 1
456 1 #if NO_UART_CABLE
#else
458 1 PINSEL0 = 0x00050005; /* Enable RxD1 and TxD1, RxD0 and TxD0 */
459 1 #endif
460 1
461 1 U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
462 1 U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
463 1 U0LCR = 0x03; /* DLAB = 0 */
464 1 U0FCR = 0x07; /* Enable and reset TX and RX FIFO. */
465 1
466 1 U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
467 1 U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
468 1 U1LCR = 0x03; /* DLAB = 0 */
469 1 U1FCR = 0x07; /* Enable and reset TX and RX FIFO. */
470 1 }
471
472 int putchar(BYTE portNum, int ch) { /* Write character to Serial Port */
473 1
474 1 if ( portNum == 0 ) {
475 2 if (ch == '\n') {
476 3 while (!(U0LSR & 0x20));
477 3 U0THR = CR; /* output CR */
478 3 }
479 2 while (!(U0LSR & 0x20));
480 2 return (U0THR = ch);
481 2 }
482 1 else {
483 2 if (ch == '\n') {
484 3 while (!(U1LSR & 0x20));
485 3 U1THR = CR; /* output CR */
486 3 }
487 2 while (!(U1LSR & 0x20));
488 2 return (U1THR = ch);
489 2 }
490 1 }
491
492 int getchar ( BYTE portNum ) { /* Read character from Serial Port */
493 1
494 1 if ( portNum == 0 ) {
495 2 while (!(U0LSR & 0x01));
496 2 return (U0RBR);
497 2 }
498 1 else {
499 2 while (!(U1LSR & 0x01));
500 2 return (U1RBR);
501 2 }
502 1 }
503
504 /* Setup SIO configuration based on the channel number */
505 void SetSIOBaudrate( BYTE channelNum, BYTE Data )
506 {
507 1 /* Data = 0x1 Baudrate = 115,200
508 1 Data = 0x2 Baudrate = 57,600
509 1 Data = 0x3 Baudrate = 38,400
510 1 Data = 0x6 Baudrate = 19,200
511 1 Data = 0x0C Baudrate = 9,600 */
512 1
513 1 /* PCLK is set the same as CCLK at 60Mhz */
514 1 if ( channelNum == 0 ) {
515 2 U0FCR = 0x07; /* Enable and reset TX and RX FIFO. */
516 2 U0LCR |= 0x80;
517 2 if ( Data == 0x01 ) {
518 3 U0DLL = 0x20;
519 3 U0DLM = 0x00;
520 3 }
ARM COMPILER V2.31, VCOMuser 23/11/05 10:53:11 PAGE 9
521 2 else if ( Data == 0x02 ) {
522 3 U0DLL = 0x41;
523 3 U0DLM = 0x00;
524 3 }
525 2 else if ( Data == 0x03 ) {
526 3 U0DLL = 0x61;
527 3 U0DLM = 0x00;
528 3 }
529 2 else if ( Data == 0x06 ) {
530 3 U0DLL = 0xC3;
531 3 U0DLM = 0x00;
532 3 }
533 2 else if ( Data == 0x0C ) {
534 3 U0DLL = 0x86;
535 3 U0DLM = 0x01;
536 3 }
537 2 U0LCR &= ~0x80;
538 2 }
539 1 else if ( channelNum == 1 ) {
540 2 U1FCR = 0x07; /* Enable and reset TX and RX FIFO. */
541 2 U1LCR |= 0x80;
542 2 if ( Data == 0x01 ) {
543 3 U1DLL = 0x20;
544 3 U1DLM = 0x00;
545 3 }
546 2 else if ( Data == 0x02 ) {
547 3 U1DLL = 0x41;
548 3 U1DLM = 0x00;
549 3 }
550 2 else if ( Data == 0x03 ) {
551 3 U1DLL = 0x61;
552 3 U1DLM = 0x00;
553 3 }
554 2 else if ( Data == 0x06 ) {
555 3 U1DLL = 0xC3;
556 3 U1DLM = 0x00;
557 3 }
558 2 else if ( Data == 0x0C ) {
559 3 U1DLL = 0x86;
560 3 U1DLM = 0x01;
561 3 }
562 2 U1LCR &= ~0x80;
563 2 }
564 1 }
565
566 void SetSIOStopBit( BYTE channelNum, BYTE ConfigValue )
567 {
568 1 BYTE lcr;
569 1
570 1 /* 0 is 1 stop bit, 1 is 2 stop bits, bit2 on LCR is stop bit setting */
571 1 if ( channelNum == 0 ) {
572 2 lcr = U0LCR & 0xFB;
573 2 U0LCR = lcr | (ConfigValue << 2);
574 2 }
575 1 else if ( channelNum == 1 ) {
576 2 lcr = U1LCR & 0xFB;
577 2 U1LCR = lcr | (ConfigValue << 2);
578 2 }
579 1 }
580
581 void SetSIODataBit( BYTE channelNum, BYTE ConfigValue )
582 {
583 1 BYTE lcr;
584 1
585 1 if ( channelNum == 0 ) {
586 2 lcr = U0LCR & 0xFC;
ARM COMPILER V2.31, VCOMuser 23/11/05 10:53:11 PAGE 10
587 2 U0LCR = lcr | ConfigValue;
588 2 }
589 1 else if ( channelNum == 1 ) {
590 2 lcr = U1LCR & 0xFC;
591 2 U1LCR = lcr | ConfigValue;
592 2 }
593 1 }
594
595 void SetSIOParity( BYTE channelNum, BYTE ConfigValue )
596 {
597 1 BYTE lcr;
598 1
599 1 if ( channelNum == 0 ) {
600 2 lcr = U0LCR & 0xCF;
601 2 U0LCR = lcr | (ConfigValue << 4);
602 2 }
603 1 else if ( channelNum == 1 ) {
604 2 lcr = U1LCR & 0xCF;
605 2 U1LCR = lcr | (ConfigValue << 4);
606 2 }
607 1 }
608
609 void SetSIOFlowControl( BYTE channelNum, BYTE ConfigValue )
610 {
611 1 /* NO flow control setting is neceaasry, unlike the UART on x51 */
612 1 if ( channelNum == 0 ) {
613 2 ConfigValue = ConfigValue;
614 2 }
615 1 else if ( channelNum == 1 ) {
616 2 ConfigValue = ConfigValue;
617 2 }
618 1 }
619
620 void SetSIODTR( BYTE channelNum, BYTE ConfigValue )
621 {
622 1 BYTE mcr;
623 1 /* only apply to channel 1 */
624 1 if ( channelNum == 1 ) {
625 2 mcr = U1MCR & 0xFE;
626 2 U1MCR = mcr | ConfigValue;
627 2 }
628 1 }
629
630 void SetSIORTS( BYTE channelNum, BYTE ConfigValue )
631 {
632 1 BYTE mcr;
633 1
634 1 /* only apply to channel 1 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -