Generally in C, pointers are assigned to the address of some variable. For instance:
Something different is needed if you want to point at a memory-mapped I/O location. Suppose the hardware/software interface manual for your system tells you that a memory-mapped I/O device is at address 0xDD800000 and that the device must be accessed with 32-bit bus transaction. A common idiom in C is:
- #define DEVICE_ADDR 0xDD800000
-
int32_t * const pDevice = ((int32_t*)DEVICE_ADDR);
The
#define associates a macro name with the address of the device. Thus, there is only one place in your code (the
#define itself) where the specific hex address of the device appears. Everywhere else reference that value with the descriptive macro name.
The next line defines a pointer to 32-bit memory and sets the pointer to the address of the device. The cast is needed to tell the compiler (and more importantly, the next person to read the code) that you meant to assign an integer value to a pointer. You can use this pointer to read from or write to the device.
The
const is positioned so that the value of the pointer cannot be changed - it always points to the device.
I'm only guessing this is what your code is doing; but it seems likely. GPIO might stand for "general purpose I/O".