mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 22:37:11 +02:00
43 lines
828 B
C
43 lines
828 B
C
|
/*
|
||
|
* gpio-xburst.c - Really primitive XBurst GPIO access
|
||
|
*
|
||
|
* Written 2010-2011 by Werner Almesberger
|
||
|
* Copyright 2010-2011 Werner Almesberger
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 2 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*/
|
||
|
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <sys/mman.h>
|
||
|
|
||
|
#include "gpio-xburst.h"
|
||
|
|
||
|
|
||
|
#define BASE 0x10010000
|
||
|
|
||
|
|
||
|
volatile void *mem;
|
||
|
|
||
|
|
||
|
void gpio_init(void)
|
||
|
{
|
||
|
int fd;
|
||
|
|
||
|
fd = open("/dev/mem", O_RDWR | O_SYNC);
|
||
|
if (fd < 0) {
|
||
|
perror("/dev/mem");
|
||
|
exit(1);
|
||
|
}
|
||
|
mem = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, BASE);
|
||
|
if (mem == MAP_FAILED) {
|
||
|
perror("mmap");
|
||
|
exit(1);
|
||
|
}
|
||
|
}
|