#include #include #include #include static volatile uint32_t *gpio; int main(int argc, char **argv) { int fd ; if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0) { printf("Unable to open /dev/mem\n"); return -1; } gpio = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x13400000); if (gpio < 0){ printf("Mmap failed.\n"); return -1; } // Print GPX1 configuration register. printf("GPX1CON register : 0x%08x\n", *(unsigned int *)(gpio + (0x0c20 >> 2))); // Set direction of GPX1.2 configuration register as out. *(gpio + (0x0c20 >> 2)) |= (0x1 << 8); printf("GPX1CON register : 0x%08x\n", *(unsigned int *)(gpio + (0x0c20 >> 2))); // GPX1.2 High *(gpio + (0x0c24 >> 2)) |= (1 << 2); printf("GPX1DAT register : 0x%08x\n", *(unsigned int *)(gpio + (0x0c24 >> 2))); // GPX1.2 Low *(gpio + (0x0c24 >> 2)) &= ~(1 << 2); printf("GPX1DAT register : 0x%08x\n", *(unsigned int *)(gpio + (0x0c24 >> 2))); return 0; }