uli / basicengine-pcb

Schematics and PCB layout for the BASIC Engine home computer
46 stars 10 forks source link

USB controller support? #1

Open darkhog opened 6 years ago

darkhog commented 6 years ago

I think it'd be good if the PSX port would be replaced with a standard USB port or few. Not only USB is much more common than PSX and therefore the part would be cheaper, but also it's easy to find a cheap, DirectInput-based USB controllers for around $5. I know it's a big change and would require rewriting parts of the firmware as well, but in the coming years, original Playstation controllers will be harder and harder to come by, while there will be always some cheap USB dualshock clone in a store near you.

uli commented 6 years ago

It would obviously be a good thing to have that, but there are a few issues with it. The software side is actually not so much of a problem; I have working HID driver code for the CH376 USB host controller, for instance. The real problem is the hardware side. Let's review some potential approaches:

  1. Adding USB to the current design

The current BE design does not leave any resources that would allow hooking up a USB host controller. The CH376 that I have used in the predecessor to this project can be connected via UART or SPI. (Also via Motorola or Intel-style parallel memory bus, but let's not go there...)

We do not have any UARTs available, and we do not even have a free GPIO to use as a slave select. Using the I/O extender for the SS is not likely to perform well enough; IIRC, the CH376's SPI interface requires all commands to be delimited by a rising edge on the SS, so that pin would have to be toggled a lot, which is probably prohibitively slow via the I2C extender.

So even when considering it an external peripheral (and thus disregarding the cost), it would probably not work well enough.

  1. New design using an MCU with built-in USB host controller

The ESP32, a natural upgrade path from the ESP8266, does not feature any USB support. There is a number of MCUs featuring USB OTG or host support. The catch is that there aren't many, they are really expensive (the STM32F411RET6 typically has a street price around 4 Euros) and at the same time often underpowered in terms of RAM, not to mention the lack of wireless capabilities. I don't know for sure why they are so expensive, or why the ESP32 does not have USB support, but I suspect both have something to do with patent licenses...

  1. New design using an external USB host controller

On a platform not as hardware resource-constrained, incorporating a USB host controller such as the CH376 would be technically viable. While it would increase the complexity of the system, the whole USB subsystem can be declared optional, basically limiting the impact to having some extra pads on the PCB. That would also mean that the cost (ca. 0.76 Euros for the chip, plus 12 MHz crystal and some passives) would not have to be borne by those not in need of this feature.

The bottom line is: I think this is something to be considered for a next-generation design, but not something that can be added to the current platform.