

If ((gpio_mem = (unsigned char*)malloc(BLOCK_SIZE + (PAGE_SIZE-1))) = NULL) Set up a memory regions to access GPIO INP_GPIO(7) // must use INP_GPIO before we can use OUT_GPIO Set up gpi pointer for direct register access #define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0 #define GPIO_SET *(gpio+7) // sets bits which are 1 ignores bits which are 0 Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y) #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ Based on the example GPIO in C program by Dom and Gert.

RC Mains socket control program by Geoff Johnson. Code: Select all // g++ -o switch switch.cpp
