Peripheral Pin Select
This information relates to ZPUino Alpha 3 release. Other releases might have different specs.
ZPUino includes a feature which is called Peripheral Pin Select (in short, PPS). PPS allows you to map every device input or output pin (such as SPI clock and SPI data lines) to each individual pin (GPIO), thus not requiring you to perform synthesis and P&R each time you want to use a device on a different IO pin.
To simplify things, three methods are supplied to manipulate PPS:
void pinModePPS(int pin, int value)
void outputPinForFunction(unsigned int pin,unsigned int function)
void inputPinForFunction(unsigned int pin,unsigned int function)
Three register blocks exist to configure how pin selection is done. These are called GPIOPPSIN, GPIOPPSOUT and GPIOPPSMAP. The above functions manipulate these registers.
Current IO pins
Here's a list of IO pins which can be mapped:
| Signal name | Module | Direction | Index | Notes |
| IOPIN_SPI_MISO | SPI | Output | 0 | On startup, this is mapped to platform SPI flash |
| IOPIN_SPI_MOSI | SPI | Input | 1 | On startup, this is mapped to platform SPI flash |
| IOPIN_SPI_SCK | SPI | Output | 2 | On startup, this is mapped to platform SPI flash |
| IOPIN_SIGMADELTA0 | SigmaDelta | Output | 3 | 1st Sigma-Delta channel. |
| IOPIN_TIMER0_OC | Timers(0) | Output | 4 | Output compare from timer 0 |
| IOPIN_TIMER1_OC | Timers(1) | Output | 5 | Output compare from timer 1 |
| IOPIN_USPI_MISO | USPI | Input | 6 | User SPI |
| IOPIN_USPI_MOSI | USPI | Output | 7 | User SPI |
| IOPIN_USPI_SCK | USPI | Output | 8 | User SPI |
| IOPIN_SIGMADELTA1 | SigmaDelta | Output | 13 | 2nd Sigma-Delta channel |
Redirecting output
In order to direct any peripheral output to a GPIO pin, you have to:
- Configure the GPIO pin as output;
- Enable PPS on selected GPIO pin;
- Configure GPIOPPSOUT (outputPinForFunction) to the peripheral signal;
The following example maps Sigma Delta 1st channel into GPIO pin number 30:
Redirecting input
In order to direct GPIO input into any peripheral, you have to:
- Configure the GPIO pin as input;
- Configure GPIOPPSIN (inputPinForFunction) to the peripheral signal;
Note that for input you don't need to enable PPS on the pin.
The following example maps USPI MISO signal (Master-In Slave-out) to GPIO pin number 10: