Raspberry Pi GPIO support
=========================

In keeping with the BBC Micro style of I/O ports being memory-mapped, if
Brandy is able to open /dev/gpiomem for read-write, then it'll mmap() it, and
the following code can be used to test whether it's available, and if so, where.

SYS "RaspberryPi_GPIOInfo" TO present%,gpiomem%

If /dev/gpiomem is available and usable, present% will be set to 1, and
gpiomem% set to the base of memory as addressed within Brandy. Otherwise,
present% will be set to 0, and gpiomem% to &FFFFFFFF. This will happen every
time Matrix Brandy is started.

With the exception of the above SYS call, all the other GPIO calls report the
error "Raspberry Pi GPIO not available" if present% is 0 (and it wasn't called
as an X call).

The remaining SYS calls all take the GPIO port number in R0 and the parameter,
if required, in R1. Those that return a value do so in R0.

The other GPIO calls are:
RaspberryPi_GetGPIOPortMode: R0=port
	Returns a value from 0 to 7:
		0: Input
		1: Output
		2: ALT5
		3: ALT4
		4: ALT0
		5: ALT1
		6: ALT2
		7: ALT3

RaspberryPi_SetGPIOPortMode: R0=port, R1=mode (as above).

RaspberryPi_SetGPIOPortPullUpDownMode: R0=port, R1=mode
		0: Off
		1: Down
		2: Up

RaspberryPi_ReadGPIOPort: R0=port. Value returned in R0.

RaspberryPi_WriteGPIOPort: R0=port, R1=value

As an alternative to the SYS calls, a slightly modified version of BBCSDL's
gpiolib.bbc by Richard Russell should also work, with the following change:
Replace FN_gpio_setup with the following:
  DEF FN_gpio_setup
  LOCAL present%
  SYS "RaspberryPi_GPIOInfo" TO present%,G%
  IF present%=0 THEN ERROR 0, "GPIO not present or usable"
  = G%

