Low Level Programming of the Raspberry Pi in C (2013)

Low Level Programming of the Raspberry Pi in C (2013)

For example, if we are interested in the GPIO peripheral (like in the example code above), we can find in the manual at page 90 that the virtual address is 0x7E200000. The GPSEL address containing the function select bits for gpio4 is = Inside this 32-bit register, the bits concerning gpio4 start from bit =12 If we bitshift binary 111 over 12 positions we get: We have to make those three bits zero in the GPFSEL register, so we have to invert that 32-bit string and perform an AND operation with the GPSEL register. (X = unknown) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X (GPFSEL old) AND X X X X X X X X X X X X X X X X X 0 0 0 X X X X X X X X X X X X (GPFSEL new)

In the datasheet on page 90, we seet that the GPSET register is located 7 32-bit registers further than the gpio base register.

Source: www.pieter-jan.com