Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
1 | /* |
2 | * gpio-xburst.c - Really primitive XBurst GPIO access |
3 | * |
4 | * Written 2010-2011 by Werner Almesberger |
5 | * Copyright 2010-2011 Werner Almesberger |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | */ |
12 | |
13 | |
14 | #include <stdlib.h> |
15 | #include <stdio.h> |
16 | #include <fcntl.h> |
17 | #include <sys/mman.h> |
18 | |
19 | #include "gpio-xburst.h" |
20 | |
21 | |
22 | #define BASE 0x10010000 |
23 | |
24 | |
25 | volatile void *mem; |
26 | |
27 | |
28 | void gpio_init(void) |
29 | { |
30 | int fd; |
31 | |
32 | fd = open("/dev/mem", O_RDWR | O_SYNC); |
33 | if (fd < 0) { |
34 | perror("/dev/mem"); |
35 | exit(1); |
36 | } |
37 | mem = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, BASE); |
38 | if (mem == MAP_FAILED) { |
39 | perror("mmap"); |
40 | exit(1); |
41 | } |
42 | } |
43 |
Branches:
master