Re-arrange distribution files, merge a2serclk into a2pid

This commit is contained in:
David Schmenk 2013-09-19 20:44:18 -07:00
parent aa4c9e9a2e
commit 92703806fc
8 changed files with 15 additions and 9 deletions

View File

@ -31,10 +31,11 @@
#define CM_GP0CTL (0x7E101070)
#define CM_GP0DIV (0x7E101074)
#define IOMAP_LEN 4096
//
// Set up a memory regions to access GPIO
//
volatile unsigned int *setup_io(reg_base)
volatile unsigned int *setup_io(int reg_base)
{
int mem_fd;
void *io_map;
@ -47,7 +48,7 @@ volatile unsigned int *setup_io(reg_base)
}
// mmap IO
io_map = mmap(NULL, //Any adddress in our space will do
4096, //Map length
IOMAP_LEN, //Map length
PROT_READ|PROT_WRITE,// Enable reading & writting to mapped memory
MAP_SHARED, //Shared with other processes
mem_fd, //File to map
@ -61,11 +62,15 @@ volatile unsigned int *setup_io(reg_base)
return (volatile unsigned *)io_map;
}
void release_io(volatile unsigned int *io_map)
{
munmap((void *)io_map, IOMAP_LEN);
}
void setserclk(void)
{
// I/O access
volatile unsigned *gpio, *cmgp;
int main(int argc, char **argv)
{
int g,rep;
// Set up gpi pointer for direct register access
@ -90,7 +95,8 @@ int main(int argc, char **argv)
// Set GCLK function (ALT0) for GPIO 4 (header pin #7)
INP_GPIO(4);
SET_GPIO_ALT(4, 0x00);
return 0;
// Release I/O space
release_io(gpio);
release_io(cmgp);
}