check this, try to do sthg similar , access gpio fro user space is a good start. the register are for E9302, just check a particular datasheet and change them to be used with any uC.
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#define GPIO_BASE 0x80840000
/* GPIO memory mapped registers */
volatile unsigned int *PEDR;
volatile unsigned int *PEDDR;
int main (void)
{
//long delay=128000, delay2=100;
unsigned char *gpio;
int fd;
fd = open("/dev/mem", O_RDWR);
if (fd < 0)
{
perror("Failed to open /dev/mem");
return fd;
}
gpio = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_BASE);
PEDR = (unsigned int *)(gpio + 0x20);
PEDDR = (unsigned int *)(gpio + 0x24);
*PEDDR = 0xff;//set output
*PEDR = 0x02;// turn ON Red LED (port E1)
return 0;
}