@@ -511,12 +511,25 @@ static void handleErr(uint8_t len)
511
511
if (len == 0xff ) {
512
512
USBCore ().logStatus (" Error" );
513
513
} else {
514
- Serial1.println ((uint16_t )USBD_EPxCS (0 ), 16 );
515
- uint8_t buf[64 ] = {0 };
514
+ // Serial1.println((uint16_t)USBD_EPxCS(0), 16);
516
515
USBCore ().logEP (' !' , 0 , ' <' , len);
517
- len = USBCore ().usbDev ().drv_handler ->ep_read (buf, 0 , (uint8_t )EP_BUF_SNG);
518
- USBCore ().hexDump (' !' , buf, 64 );
519
- USBCore ().logEP (' .' , 0 , ' !' , len);
516
+ usbd_ep_ram *btable_ep = (usbd_ep_ram *)(USBD_RAM + 2 * (BTABLE_OFFSET & 0xFFF8 ));
517
+ uint32_t *p = (uint32_t *)(USBD_RAM + 2U * EP0_RX_ADDR);
518
+ Serial1.print (' !' );
519
+ for (int i = 0 ; i < USBD_EP0_MAX_SIZE/2 ; i++) {
520
+ uint16_t x = p[i];
521
+ Serial1.print ((x >> 4 ) & 0x0f , 16 );
522
+ Serial1.print (x & 0x0f , 16 );
523
+ // Serial1.print(' ');
524
+ Serial1.print ((x >> 12 ) & 0x0f , 16 );
525
+ Serial1.print ((x >> 8 ) & 0x0f , 16 );
526
+ // Serial1.print(' ');
527
+ }
528
+ Serial1.println ();
529
+ // len = USBCore().usbDev().drv_handler->ep_read(buf, 0, (uint8_t)EP_BUF_SNG);
530
+ // USBCore().hexDump('!', buf, 64);
531
+ auto bytes = (uint16_t )(btable_ep[0 ].rx_count & EPRCNT_CNT);
532
+ USBCore ().logEP (' .' , 0 , ' !' , bytes);
520
533
}
521
534
}
522
535
@@ -569,11 +582,14 @@ USBCore_::USBCore_()
569
582
570
583
void USBCore_::logEP (char kind, uint8_t ep, char dir, size_t len)
571
584
{
585
+ Serial1.print (USBD_EPxCS (ep), 16 );
572
586
Serial1.print (kind);
573
587
Serial1.print (ep);
574
588
Serial1.print (dir);
575
- Serial1.println (len);
576
- // Serial1.flush();
589
+ Serial1.print (len);
590
+ Serial1.print (' ' );
591
+ Serial1.println (USBD_EPxCS (ep), 16 );
592
+ Serial1.flush ();
577
593
}
578
594
579
595
void USBCore_::hexDump (char prefix, const uint8_t *buf, size_t len)
@@ -585,13 +601,13 @@ void USBCore_::hexDump(char prefix, const uint8_t *buf, size_t len)
585
601
Serial1.print (' ' );
586
602
}
587
603
Serial1.println ();
588
- // Serial1.flush();
604
+ Serial1.flush ();
589
605
}
590
606
591
607
void USBCore_::logStatus (const char *status)
592
608
{
593
609
Serial1.println (status);
594
- // Serial1.flush();
610
+ Serial1.flush ();
595
611
}
596
612
597
613
void USBCore_::connect ()
@@ -666,6 +682,7 @@ int USBCore_::recvControl(void* data, int len)
666
682
this ->ctlOutBuf = (uint8_t *)data;
667
683
this ->ctlOutLen = len;
668
684
usb_transc_config (&USBCore ().usbDev ().transc_out [0 ], this ->ctlBuf , len, 0 );
685
+ // Serial1.println((uint16_t)USBD_EPxCS(0), 16);
669
686
USBCore ().logEP (' _' , 0 , ' <' , len);
670
687
return len;
671
688
}
@@ -723,7 +740,7 @@ int USBCore_::send(uint8_t ep, const void* data, int len)
723
740
auto usbd = &USBCore ().usbDev ();
724
741
725
742
usb_disable_interrupts ();
726
- USBCore ().logEP (' +' , ep, ' >' , len);
743
+ // USBCore().logEP('+', ep, '>', len);
727
744
usb_enable_interrupts ();
728
745
#ifdef USBD_REMOTE_WAKEUP
729
746
usb_disable_interrupts ();
@@ -791,7 +808,7 @@ int USBCore_::flush(uint8_t ep)
791
808
usbd->transc_in [0 ].xfer_buf = ctlBuf;
792
809
usbd->transc_in [0 ].xfer_len = ctlIdx;
793
810
USBCore ().logEP (' _' , 0 , ' >' , ctlIdx);
794
- USBCore ().hexDump (' >' , ctlBuf, ctlIdx);
811
+ // USBCore().hexDump('>', ctlBuf, ctlIdx);
795
812
} else {
796
813
EPBuffers ().buf (ep).flush ();
797
814
}
@@ -838,6 +855,7 @@ void USBCore_::transcOut(usb_dev* usbd, uint8_t ep)
838
855
{
839
856
auto transc = &usbd->transc_out [ep];
840
857
auto count = transc->xfer_count ;
858
+ USBCore ().logEP (' :' , ep, ' <' , count);
841
859
if (ep == 0 ) {
842
860
this ->oldTranscOut (usbd, ep);
843
861
} else {
@@ -850,13 +868,16 @@ void USBCore_::transcOut(usb_dev* usbd, uint8_t ep)
850
868
void USBCore_::transcIn (usb_dev* usbd, uint8_t ep)
851
869
{
852
870
auto transc = &usbd->transc_in [ep];
853
- USBCore (). logEP ( ' . ' , ep, ' > ' , transc->xfer_count ) ;
854
-
855
- if (ep == 0 ) {
871
+ auto count = transc->xfer_count ;
872
+ USBCore (). logEP ( ' : ' , ep, ' > ' , transc-> xfer_count );
873
+ if (ep == 0 ) {
856
874
this ->oldTranscIn (usbd, ep);
857
875
} else {
858
876
EPBuffers ().buf (ep).transcIn ();
859
877
}
878
+ if (usbd->control .ctl_state != USBD_CTL_STATUS_OUT) {
879
+ USBCore ().logEP (' .' , ep, ' >' , transc->xfer_count );
880
+ }
860
881
transc->xfer_count = 0 ;
861
882
}
862
883
0 commit comments