GPIO

General purpose input and output is used for Ibex to interact with the buttons and switches on the board. It is also used to drive the LEDs on the board. There are also the GPIO pins of the various headers.

For the input this module provides a raw value as well as a debounced value. Debouncing is useful to avoid counting a single button press multiple times. For more information on contact bounce, see this Wikipedia page.

OffsetRegister
0x0000Output
0x0004Input
0x0008Debounced input
0x000CDebounce threshold
0x6000R-Pi output
0x6004R-Pi input
0x6008R-pi debounced input
0x600CR-pi debounce threshold
0x7000Arduino output
0x7004Arduino input
0x7008Arduino debounced input
0x700CArduino debounce threshold
0x8000PMOD output
0x8004PMOD input
0x8008PMOD debounced input
0x800CPMOD debounce threshold

Output

The output register displays the specified value onto the boards output.

Bit offsetDescription
22mikroBUS reset
21mikroBUS SPI chip select
20Arduino SPI chip select
19R-Pi SPI1 chip select 0
18R-Pi SPI1 chip select 1
17R-Pi SPI1 chip select 2
16R-Pi SPI0 chip select 0
15R-Pi SPI0 chip select 1
14Ethernet reset
13Ethernet SPI chip select
12Flash SPI chip select
11-4LEDs
3LCD backlight
2LCD DC
1LCD reset
0LCD chip select

In this case writing a one will turn an LED on and a zero will turn the LED off.

Input

Both input registers have the same bit mapping. The only difference between the registers is that the latter has debounced signals.

Bit offsetDescription
16-14Software select switches (1, 2, 3)
13mikroBUS interrupt
12-5DIP switches
4-0Joystick (left, down, up, right, press)

The input registers are used to interact with the joystick, the button and the DIP switches that are available on the Sonata board.

Debounce threshold

Not implemented yet.

This register indicates how many clock cycles an input needs to be stable before it shows up on the output. The same threshold applies to all of the inputs.

Bit offsetDescription
31-0Threshold

Raspberry Pi HAT

The Raspberry Pi HAT header has 11 GPIO pins. When writing, it only writes the bits for which the output is set to enable. The input and output registers have the same bit mapping.

Bit offsetDescription
10GPIO 27
9GPIO 26
8GPIO 25
7GPIO 24
6GPIO 23
5GPIO 22
4GPIO 13
3GPIO 12
2GPIO 6
1GPIO 5
0GPIO 4

For the output register it is teh same order as above:

Bit offsetDescription
26-16Output enable
10-0Output value

When the output enable is set to zero it instead acts as an input pin.

Arduino Shield

The Arduino Shield header has 10 GPIO pins. When writing, it only writes the bits for which the output is set to enable. The input and output registers have the same bit mapping.

Bit offsetDescription
9GPIO 9
8GPIO 8
7GPIO 7
6GPIO 6
5GPIO 5
4GPIO 4
3GPIO 3
2GPIO 2
1GPIO 1
0GPIO 0

For the output register it is teh same order as above:

Bit offsetDescription
25-16Output enable
9-0Output value

When the output enable is set to zero it instead acts as an input pin.

PMOD

The two PMOD headers has 16 GPIO pins. When writing, it only writes the bits for which the output is set to enable. The input and output registers have the same bit mapping.

Bit offsetDescription
15-8PMOD 1
7-0PMOD 0

For the output register it is teh same order as above:

Bit offsetDescription
31-16Output enable
15-0Output value

When the output enable is set to zero it instead acts as an input pin.