cnlohr / rv003usb

CH32V003 RISC-V Pure Software USB Controller
MIT License
436 stars 43 forks source link

Possible to use PD5/PD6? #28

Closed machdyne closed 8 months ago

machdyne commented 10 months ago

Hi. I made a custom board that uses PD5/PD6 for DM/DP (oops?) and set the config:

#define USB_DM 5
#define USB_DP 6
#define USB_DPU 4
#define USB_PORT D

This doesn't seem to work, when compiling the bootloader:

../rv003usb/rv003usb.S:56: Error: illegal operands `c.andi a0,((1<<(5))|1<<(6))'

I tried changing all of those instances to li t1, USB_DMASK; and a0, a0, t1 but it apparently doesn't fit in flash.

Any ideas?

mcu23 commented 10 months ago

PC1, PC2, PC4 Test OK.

usb_config.h

#define USB_DM 4
#define USB_DP 2
#define USB_DPU 1

#define USB_PORT C
cnlohr commented 10 months ago

I didn't realize until now that andi can't use pin numbers >= 6.

It should be possible to make this work, but it will be tricky. and I don't have availability any time soon.

I will keep that in mind for the future. I will update the readme. I'm very sorry for the pain this may cause.

machdyne commented 10 months ago

Thanks, I'll update this issue if I come up with a solution in the meantime.

cnlohr commented 8 months ago

Thank you. I am going to close this issue for now.

xsrf commented 6 months ago

I didn't realize until now that andi can't use pin numbers >= 6.

Just for the record if someone comes across this, it's actually >= 5.

Only Pins 0-4 can be used for D+/D-