@@ -454,7 +454,7 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
454
454
455
455
// Configuring Vbus sense and SOF output
456
456
match core_id {
457
- 0x0000_1200 | 0x0000_1100 => {
457
+ 0x0000_1000 | 0x0000_1200 | 0x0000_1100 => {
458
458
// F429-like chips have the GCCFG.NOVBUSSENS bit
459
459
460
460
//modify_reg!(otg_global, regs.global, GCCFG, NOVBUSSENS: 1);
@@ -633,20 +633,25 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
633
633
0b01 | 0b11 => {
634
634
// Full speed
635
635
636
- // From RM0431 (F72xx), RM0090 (F429)
637
- trdt = match self . peripheral . ahb_frequency_hz ( ) {
638
- 0 ..=14_199_999 => panic ! ( "AHB frequency is too low" ) ,
639
- 14_200_000 ..=14_999_999 => 0xF ,
640
- 15_000_000 ..=15_999_999 => 0xE ,
641
- 16_000_000 ..=17_199_999 => 0xD ,
642
- 17_200_000 ..=18_499_999 => 0xC ,
643
- 18_500_000 ..=19_999_999 => 0xB ,
644
- 20_000_000 ..=21_799_999 => 0xA ,
645
- 21_800_000 ..=23_999_999 => 0x9 ,
646
- 24_000_000 ..=27_499_999 => 0x8 ,
647
- 27_500_000 ..=31_999_999 => 0x7 , // 27.7..32 in code from CubeIDE
648
- 32_000_000 ..=u32:: MAX => 0x6 ,
649
- } ;
636
+ if core_id == 0x0000_1000 {
637
+ // From GD32VF103_Firmware_Library_V1.0.2.rar.
638
+ trdt = 0x05 ;
639
+ } else {
640
+ // From RM0431 (F72xx), RM0090 (F429)
641
+ trdt = match self . peripheral . ahb_frequency_hz ( ) {
642
+ 0 ..=14_199_999 => panic ! ( "AHB frequency is too low" ) ,
643
+ 14_200_000 ..=14_999_999 => 0xF ,
644
+ 15_000_000 ..=15_999_999 => 0xE ,
645
+ 16_000_000 ..=17_199_999 => 0xD ,
646
+ 17_200_000 ..=18_499_999 => 0xC ,
647
+ 18_500_000 ..=19_999_999 => 0xB ,
648
+ 20_000_000 ..=21_799_999 => 0xA ,
649
+ 21_800_000 ..=23_999_999 => 0x9 ,
650
+ 24_000_000 ..=27_499_999 => 0x8 ,
651
+ 27_500_000 ..=31_999_999 => 0x7 , // 27.7..32 in code from CubeIDE
652
+ 32_000_000 ..=u32:: MAX => 0x6 ,
653
+ } ;
654
+ }
650
655
}
651
656
_ => unimplemented ! ( ) ,
652
657
}
@@ -697,7 +702,10 @@ impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {
697
702
read_reg ! ( otg_global, regs. global( ) , GRXSTSP ) ; // pop GRXSTSP
698
703
699
704
// Re-enable the endpoint, F429-like chips only
700
- if core_id == 0x0000_1200 || core_id == 0x0000_1100 {
705
+ if core_id == 0x0000_1000
706
+ || core_id == 0x0000_1200
707
+ || core_id == 0x0000_1100
708
+ {
701
709
let ep = regs. endpoint_out ( epnum as usize ) ;
702
710
modify_reg ! ( endpoint_out, ep, DOEPCTL , CNAK : 1 , EPENA : 1 ) ;
703
711
}
0 commit comments