Andrew Bezzubtsev
Andrew Bezzubtsev

Reputation: 55

Working with GPIO on bcm2836

I am writing a GPIO-driver for my RPI2 OS. And I was surfing really long time about it, but I found only linux data. How should I do such functions as

void gpio_set(int pin);
void gpio_clr(int pin);

in C for the driver. Or, maybe it can be done due inline assembly?

Upvotes: 1

Views: 1192

Answers (2)

Clifford
Clifford

Reputation: 93476

As explained here

The underlying architecture in BCM2836 is identical to BCM2835. The only significant difference is the removal of the ARM1176JZF-S processor and replacement with a quad-core Cortex-A7 cluster.

The available documentation for the BCM2836 does not detail the peripheral hardare, only the A7. Instead you need the documentation for the BCM2835. The peripheral specification section 6 deals with the GPIO. The registers are memory mapped so you can write directly to them in C.

Upvotes: 3

Sajjad Ahmad
Sajjad Ahmad

Reputation: 431

It is very simple to implement in C. Keep in mind that the peripheral address RPi2 is 0x3F000000 instead of 0x20000000 (RPi). Documentation available is for RPi (BCM2835) but applicable on RPi2 as well with some memory address changes and processor change (Cortex-A7). For quick jump you can see valver's blog for bare-metal development.

Upvotes: 0

Related Questions