Mercurial > templog
annotate py/touch/touch.c @ 241:86e638d564b0
sha256 hash
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 19 May 2015 23:58:51 +0800 |
parents | bed65c321b46 |
children |
rev | line source |
---|---|
155 | 1 // |
2 // How to access GPIO registers from C-code on the Raspberry-Pi | |
3 // Example program | |
4 // 15-January-2012 | |
5 // Dom and Gert | |
6 // | |
7 | |
8 | |
9 // Access from ARM Running Linux | |
10 | |
11 #define BCM2708_PERI_BASE 0x20000000 | |
12 #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ | |
13 | |
14 | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
15 // for usleep |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
16 #define _BSD_SOURCE |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
17 |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
18 // clock_gettime |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
19 #define _POSIX_C_SOURCE 199309L |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
20 |
155 | 21 #include <stdio.h> |
22 #include <string.h> | |
23 #include <stdlib.h> | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
24 #include <stdint.h> |
155 | 25 #include <dirent.h> |
26 #include <fcntl.h> | |
27 #include <assert.h> | |
28 #include <sys/mman.h> | |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
31 #include <time.h> |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
32 #include <sched.h> |
155 | 33 |
34 #include <unistd.h> | |
35 | |
36 #define PAGE_SIZE (4*1024) | |
37 #define BLOCK_SIZE (4*1024) | |
38 | |
39 int mem_fd; | |
40 char *gpio_mem, *gpio_map; | |
41 char *spi0_mem, *spi0_map; | |
42 | |
43 | |
44 // I/O access | |
45 volatile unsigned *gpio; | |
46 | |
47 | |
48 // GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y) | |
49 #define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3)) | |
50 #define OUT_GPIO(g) *(gpio+((g)/10)) |= (1<<(((g)%10)*3)) | |
51 #define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3)) | |
52 | |
53 #define FSEL_OFFSET 0 // 0x0000 | |
54 #define SET_OFFSET 7 // 0x001c / 4 | |
55 #define CLR_OFFSET 10 // 0x0028 / 4 | |
56 #define PINLEVEL_OFFSET 13 // 0x0034 / 4 | |
57 #define EVENT_DETECT_OFFSET 16 // 0x0040 / 4 | |
58 #define RISING_ED_OFFSET 19 // 0x004c / 4 | |
59 #define FALLING_ED_OFFSET 22 // 0x0058 / 4 | |
60 #define HIGH_DETECT_OFFSET 25 // 0x0064 / 4 | |
61 #define LOW_DETECT_OFFSET 28 // 0x0070 / 4 | |
62 #define PULLUPDN_OFFSET 37 // 0x0094 / 4 | |
63 #define PULLUPDNCLK_OFFSET 38 // 0x0098 / 4 | |
64 | |
65 | |
66 #define GPIO_GET(g) ((*(gpio+PINLEVEL_OFFSET) & (1<<(g))) >> (g)) | |
67 #define GPIO_SET(g) (*(gpio+SET_OFFSET) = 1<<(g)) // sets bits which are 1 ignores bits which are 0 | |
68 #define GPIO_CLR(g) (*(gpio+CLR_OFFSET) = 1<<(g))// clears bits which are 1 ignores bits which are 0 | |
69 | |
70 #define TOUCH_IN 24 | |
71 #define TOUCH_OUT 25 | |
72 | |
73 void setup_io(); | |
74 | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
75 static int cmp_int(const void *a, const void *b) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
76 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
77 const int *ia = a; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
78 const int *ib = b; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
79 return (*ia - *ib); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
80 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
81 |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
82 static int clock_diff(struct timespec *t1, struct timespec *t2) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
83 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
84 uint64_t v1 = t1->tv_sec * 1000000000 + t1->tv_nsec; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
85 uint64_t v2 = t2->tv_sec * 1000000000 + t2->tv_nsec; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
86 return v2-v1; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
87 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
88 |
155 | 89 int main(int argc, char **argv) |
90 { | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
91 // Set up gpi pointer for direct register access |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
92 setup_io(); |
155 | 93 |
94 INP_GPIO(TOUCH_IN); | |
95 INP_GPIO(TOUCH_OUT); | |
96 OUT_GPIO(TOUCH_OUT); | |
97 | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
98 const int num = 200; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
99 const int margin = 30; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
100 int print = 0; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
101 if (argc > 1) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
102 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
103 print = 1; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
104 } |
155 | 105 |
106 while (1) | |
107 { | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
108 int vals[num]; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
109 int nsecs[num]; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
110 for (int n = 0; n < num; n++) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
111 { |
155 | 112 GPIO_CLR(TOUCH_OUT); |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
113 struct timespec t = {.tv_nsec=20}; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
114 nanosleep(&t, NULL); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
115 //sched_yield(); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
116 //usleep(1); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
117 if (GPIO_GET(TOUCH_IN)) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
118 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
119 printf("short "); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
120 } |
155 | 121 GPIO_SET(TOUCH_OUT); |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
122 int val = 0; |
155 | 123 while (GPIO_GET(TOUCH_IN) == 0) |
124 { | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
125 val++; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
126 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
127 |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
128 vals[n] = val; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
129 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
130 qsort(vals, num, sizeof(*vals), cmp_int); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
131 int sum = 0, count = 0; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
132 for (int n = 0; n < num; n++) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
133 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
134 if (print) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
135 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
136 printf("%3d ", vals[n]); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
137 if (n == num-1 || n % 10 == 9) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
138 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
139 printf("\n"); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
140 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
141 if (n == margin || n == num-margin) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
142 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
143 printf("#"); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
144 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
145 } |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
146 if (n >= margin && n < (num-margin)) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
147 { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
148 sum += vals[n]; |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
149 count ++; |
155 | 150 } |
151 } | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
152 printf("total %f from %d\n", (float)sum / count, count); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
153 usleep(500000); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
154 } |
155 | 155 return 0; |
156 | |
157 } // main | |
158 | |
159 | |
160 // | |
161 // Set up a memory regions to access GPIO | |
162 // | |
163 void setup_io() | |
164 { | |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
165 /* open /dev/mem */ |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
166 if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
167 printf("can't open /dev/mem \n"); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
168 exit (-1); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
169 } |
155 | 170 |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
171 /* mmap GPIO */ |
155 | 172 |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
173 // Allocate MAP block |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
174 if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
175 printf("allocation error \n"); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
176 exit (-1); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
177 } |
155 | 178 |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
179 // Make sure pointer is on 4K boundary |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
180 if ((unsigned long)gpio_mem % PAGE_SIZE) |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
181 gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE); |
155 | 182 |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
183 // Now map it |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
184 gpio_map = mmap( |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
185 (caddr_t)gpio_mem, |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
186 BLOCK_SIZE, |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
187 PROT_READ|PROT_WRITE, |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
188 MAP_SHARED|MAP_FIXED, |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
189 mem_fd, |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
190 GPIO_BASE |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
191 ); |
155 | 192 |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
193 if ((long)gpio_map < 0) { |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
194 printf("mmap error %d\n", (int)gpio_map); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
195 exit (-1); |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
196 } |
155 | 197 |
156
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
198 // Always use volatile pointer! |
bed65c321b46
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
155
diff
changeset
|
199 gpio = (volatile unsigned *)gpio_map; |
155 | 200 |
201 | |
202 } // setup_io |