revk/SolarSystem

More GPIOs

Closed this issue · 3 comments

revk commented

The current design allows for GPIOs: 0, 2, 4, 5, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 32, 33, 34, 35, 36, and 39.

These specifically related to the ESP32 S1. However, with ESP32-S3 builds, this needs changing. The ESP32-S3 has GPIOs 0-48 (with some that are unusable).

GPIO 48

The current code uses an 8 bit value or GPIO, with top bit for set and next for inverted, leaving 0-63. This is enough for S3, except for the fact that the general inputs have special cases for GPIOs 48 to 63. GPIO 48-55 are mapped to the eight NFC GPIOPs, and 56-63 (as well as inverted 56-63) are mapped to logical inputs such as NFCFault, etc. This means GPIO 48 clashes.

The obvious change is to move to 16 bits, with top bit for set, and next for inverted we could add other port specific bits such as pull-down (which is currently bodged in to inputfunc) and so on. This would easily allow more than enough GPIOs, so suggesting at least 0-255 for future proofing. We could also make logical GPIOs a prefix such as L rather than simply using otherwise unused GPIO numbers.

The downside is this is a change to the PCB table and existing code all at the same time. We could, perhaps, map new GPIOs to old based on version number of device. This is probably worth doing in the long run.

Module table

Another change that makes sense is to have a table defining which GPIOs are usable for which module, and assigning a module to the PCB table entries. This would then restrict which PCBs are available to a device, so as to avoid mistakes, and keep the GPIO selections sensible.

Even so, the GPIO selection could be improved rather than just a big pull down.

Short term fix

One short term fix is don't use GPIO 48, but the current S3 Access board in production uses it for NFC.

A short term fix for now is allowing all GPIOs 0-47 everywhere, and allowing 48 for anything other than input. This would allow GPIO 48 for NFC.

revk commented

Database changes for all GPIOs done.

Internal port validity checks on module code for S1/S3 done.

Port duplicate checks will fall foul of P30 NFC clash with GPIO 48... Needs working out.

revk commented

Ready for testing on new S3 Access board later this week.

revk commented

OK, working now - but is the simple solution of allowing extra ports where there is no clash with special port functions.