I am looking at some code about which I am puzzled.
This snippet is in the header file, RPI.h:
#define BCM2708_PERI_BASE 0x20000000
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) // GPIO controller
// IO Access
struct bcm2835_peripheral {
unsigned long addr_p;
int mem_fd;
void *map;
volatile unsigned int *addr;
};
struct bcm2835_peripheral gpio = {GPIO_BASE};
extern struct bcm2835_peripheral gpio;
From the RPI.c file:
#include "RPI.h"
struct bcm2835_peripheral gpio = {GPIO_BASE};
I am puzzled by the line in both the .h and .c files:
struct bcm2835_peripheral gpio = {GPIO_BASE};
It looks to me that a new struct of type bcm2835_peripheral
named gpio
is being instantiated and set equal to GPIO_BASE
. However, the struct has four, public members. Are they all being set to GPIO_BASE
?
I only included the lines from the .h and .c files which were relevant. The lines are in the order they are in the original files.