-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Low-speed game gamepad support (#23)
Add support for 2 usb gamepads based on hi631's ukp code. Add doc/usb_gamepad.md.
- Loading branch information
1 parent
d4f928d
commit adcb3cc
Showing
16 changed files
with
1,426 additions
and
40 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
## USB Gamepad Setup | ||
|
||
NESTang 0.6 now supports USB gamepads, allowing you to use your existing controllers without the need to purchase new ones. | ||
|
||
<img src="images/usb_gamepad2.jpg" width=400> | ||
<img src="images/usb_gamepad1.jpg" width=400> | ||
|
||
To enable this functionality, you will need the following, | ||
* Two USB-A Female to 2.54mm adapters, which can be found [here](https://www.aliexpress.us/item/2255800203914149.html?spm=a2g0o.productlist.main.17.6e617e229i3qAm&algo_pvid=89ee64ce-a2c8-41f6-9e3b-45e8396569fd&algo_exp_id=89ee64ce-a2c8-41f6-9e3b-45e8396569fd-8&pdp_npi=4%40dis%21USD%210.28%210.25%21%21%210.28%21%21%402132a25516924371147167093ec531%2110000001592482118%21sea%21US%214484896846%21A&curPageLogUid=dAeFgl6FWDAf). | ||
* Four 15K ohm resistors as USB pulldown resistor. | ||
|
||
Then wire things up correctly, refer to the image above and the [Tang Nano 20K pinout](https://wiki.sipeed.com/hardware/en/tang/tang-nano-20k/nano-20k.html)). Follow these steps, | ||
* Connect USB VBUS to the 5V pin of Tang Nano 20K, and USB GND to the Tang GND. | ||
* For controller 1, connect D+ to pin 42 and D- to pin 41. | ||
* For controller 2, connect D+ to pin 56 and D- to pin 54. | ||
* Connect four 15K ohm resistors from D-/D+ to GND. | ||
|
||
Please note that using the resistors is necessary for stability. | ||
|
||
That's all you need to do. | ||
|
||
**Limitation**: Note that only USB low-speed gamepads are currently supported. So controllers like PS5 or Xbox 360 pads are not compatible. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
module Gowin_rPLL_usb (clkout, clkoutp, lock, reset, clkin); | ||
|
||
output clkout; | ||
output clkoutp; | ||
output lock; | ||
input reset; | ||
input clkin; | ||
|
||
wire clkoutd_o; | ||
wire clkoutd3_o; | ||
wire gw_gnd; | ||
|
||
assign gw_gnd = 1'b0; | ||
|
||
rPLL rpll_inst ( | ||
.CLKOUT(clkout), | ||
.LOCK(lock), | ||
.CLKOUTP(clkoutp), | ||
.CLKOUTD(clkoutd_o), | ||
.CLKOUTD3(clkoutd3_o), | ||
.RESET(reset), | ||
.RESET_P(gw_gnd), | ||
.CLKIN(clkin), | ||
.CLKFB(gw_gnd), | ||
.FBDSEL({gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd}), | ||
.IDSEL({gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd}), | ||
.ODSEL({gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd,gw_gnd}), | ||
.PSDA({gw_gnd,gw_gnd,gw_gnd,gw_gnd}), | ||
.DUTYDA({gw_gnd,gw_gnd,gw_gnd,gw_gnd}), | ||
.FDLY({gw_gnd,gw_gnd,gw_gnd,gw_gnd}) | ||
); | ||
|
||
// 27 -> 12 Mhz low-speed USB clock | ||
defparam rpll_inst.FCLKIN = "27"; | ||
defparam rpll_inst.IDIV_SEL = 8; | ||
defparam rpll_inst.FBDIV_SEL = 3; | ||
defparam rpll_inst.ODIV_SEL = 64; | ||
|
||
defparam rpll_inst.DYN_IDIV_SEL = "false"; | ||
defparam rpll_inst.DYN_FBDIV_SEL = "false"; | ||
defparam rpll_inst.DYN_ODIV_SEL = "false"; | ||
defparam rpll_inst.PSDA_SEL = "1000"; | ||
defparam rpll_inst.DYN_DA_EN = "false"; | ||
defparam rpll_inst.DUTYDA_SEL = "1000"; | ||
defparam rpll_inst.CLKOUT_FT_DIR = 1'b1; | ||
defparam rpll_inst.CLKOUTP_FT_DIR = 1'b1; | ||
defparam rpll_inst.CLKOUT_DLY_STEP = 0; | ||
defparam rpll_inst.CLKOUTP_DLY_STEP = 0; | ||
defparam rpll_inst.CLKFB_SEL = "internal"; | ||
defparam rpll_inst.CLKOUT_BYPASS = "false"; | ||
defparam rpll_inst.CLKOUTP_BYPASS = "false"; | ||
defparam rpll_inst.CLKOUTD_BYPASS = "false"; | ||
defparam rpll_inst.DYN_SDIV_SEL = 2; | ||
defparam rpll_inst.CLKOUTD_SRC = "CLKOUT"; | ||
defparam rpll_inst.CLKOUTD3_SRC = "CLKOUT"; | ||
defparam rpll_inst.DEVICE = "GW2AR-18"; | ||
|
||
endmodule //Gowin_rPLL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.