The DRC SoC contains a GPIO controller that is used to control 8 external GPIO pins (of which 6 are used in the current firmware).
The following MMIO registers are used for GPIOs:
Address | Name | Connected to |
---|---|---|
F0005100 | GPIO0 | Unknown, used in the LCD driver. |
F0005108 | GPIO1 | Unknown, unused in the LVC firmware. |
F000510C | GPIO2 | Unknown, used in the NFC driver. |
F0005110 | GPIO3 | Unknown, called TRM_ENABLE_POWER_GPIO in the NFC driver. |
F0005114 | GPIO4 | Controls the rumble motor. |
F0005118 | GPIO5 | Controls the sensor bar power. |
F000511C | GPIO6 | Unknown, used in the CMOS driver. |
F0005098 | GPIO7 | Unknown, unused in the LVC firmware. |
To configure a GPIO, write a combination of the following flags to the GPIO register:
For example, to configure the rumble motor GPIO as an output GPIO with pull-up resistors:
write32(MMIO_GPIO4, 0x8200);
To configure it as an input GPIO with pull-up resistors:
write32(MMIO_GPIO4, 0x8800);
To set an output GPIO to 0/1, use the 0x100 bit:
// 0
write32(MMIO_GPIO4, read32(MMIO_GPIO4) & ~0x100);
// 1
write32(MMIO_GPIO4, read32(MMIO_GPIO4) | 0x100);
To read an input GPIO, use the 0x400 bit:
int x = read32(MMIO_GPIO4) & 0x400;