Mercurial > templog
annotate py/touch/touch.c @ 484:4a51e2bf689b
a few fixes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 06 Feb 2014 20:35:43 +0800 |
parents | e12d6d677320 |
children |
rev | line source |
---|---|
454 | 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 | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
15 // for usleep |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
16 #define _BSD_SOURCE |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
17 |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
18 // clock_gettime |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
19 #define _POSIX_C_SOURCE 199309L |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
20 |
454 | 21 #include <stdio.h> |
22 #include <string.h> | |
23 #include <stdlib.h> | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
24 #include <stdint.h> |
454 | 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> | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
31 #include <time.h> |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
32 #include <sched.h> |
454 | 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 | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
75 static int cmp_int(const void *a, const void *b) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
76 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
77 const int *ia = a; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
78 const int *ib = b; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
79 return (*ia - *ib); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
80 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
81 |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
82 static int clock_diff(struct timespec *t1, struct timespec *t2) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
83 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
84 uint64_t v1 = t1->tv_sec * 1000000000 + t1->tv_nsec; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
85 uint64_t v2 = t2->tv_sec * 1000000000 + t2->tv_nsec; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
86 return v2-v1; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
87 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
88 |
454 | 89 int main(int argc, char **argv) |
90 { | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
91 // Set up gpi pointer for direct register access |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
92 setup_io(); |
454 | 93 |
94 INP_GPIO(TOUCH_IN); | |
95 INP_GPIO(TOUCH_OUT); | |
96 OUT_GPIO(TOUCH_OUT); | |
97 | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
98 const int num = 200; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
99 const int margin = 30; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
100 int print = 0; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
101 if (argc > 1) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
102 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
103 print = 1; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
104 } |
454 | 105 |
106 while (1) | |
107 { | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
108 int vals[num]; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
109 int nsecs[num]; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
110 for (int n = 0; n < num; n++) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
111 { |
454 | 112 GPIO_CLR(TOUCH_OUT); |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
113 struct timespec t = {.tv_nsec=20}; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
114 nanosleep(&t, NULL); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
115 //sched_yield(); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
116 //usleep(1); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
117 if (GPIO_GET(TOUCH_IN)) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
118 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
119 printf("short "); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
120 } |
454 | 121 GPIO_SET(TOUCH_OUT); |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
122 int val = 0; |
454 | 123 while (GPIO_GET(TOUCH_IN) == 0) |
124 { | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
125 val++; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
126 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
127 |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
128 vals[n] = val; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
129 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
130 qsort(vals, num, sizeof(*vals), cmp_int); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
131 int sum = 0, count = 0; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
132 for (int n = 0; n < num; n++) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
133 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
134 if (print) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
135 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
136 printf("%3d ", vals[n]); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
137 if (n == num-1 || n % 10 == 9) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
138 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
139 printf("\n"); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
140 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
141 if (n == margin || n == num-margin) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
142 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
143 printf("#"); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
144 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
145 } |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
146 if (n >= margin && n < (num-margin)) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
147 { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
148 sum += vals[n]; |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
149 count ++; |
454 | 150 } |
151 } | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
152 printf("total %f from %d\n", (float)sum / count, count); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
153 usleep(500000); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
154 } |
454 | 155 return 0; |
156 | |
157 } // main | |
158 | |
159 | |
160 // | |
161 // Set up a memory regions to access GPIO | |
162 // | |
163 void setup_io() | |
164 { | |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
165 /* open /dev/mem */ |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
166 if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
167 printf("can't open /dev/mem \n"); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
168 exit (-1); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
169 } |
454 | 170 |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
171 /* mmap GPIO */ |
454 | 172 |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
173 // Allocate MAP block |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
174 if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
175 printf("allocation error \n"); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
176 exit (-1); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
177 } |
454 | 178 |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
179 // Make sure pointer is on 4K boundary |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
180 if ((unsigned long)gpio_mem % PAGE_SIZE) |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
181 gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE); |
454 | 182 |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
183 // Now map it |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
184 gpio_map = mmap( |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
185 (caddr_t)gpio_mem, |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
186 BLOCK_SIZE, |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
187 PROT_READ|PROT_WRITE, |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
188 MAP_SHARED|MAP_FIXED, |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
189 mem_fd, |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
190 GPIO_BASE |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
191 ); |
454 | 192 |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
193 if ((long)gpio_map < 0) { |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
194 printf("mmap error %d\n", (int)gpio_map); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
195 exit (-1); |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
196 } |
454 | 197 |
455
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
198 // Always use volatile pointer! |
e12d6d677320
Try some other ways with touch sensing. Linux scheduling isn't fast enough
Matt Johnston <matt@ucc.asn.au>
parents:
454
diff
changeset
|
199 gpio = (volatile unsigned *)gpio_map; |
454 | 200 |
201 | |
202 } // setup_io |