Hardware Reference
In-Depth Information
What this suggests is that GPIO 28 through 31 could be used, if you have higher
current driving requirements.
If you have a requirement to change these settings from within a C program, the
program pads.c can be easily modified. Use the macro GETPAD32 (line 16) for inspiration.
1 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
2
pads . c : Examine GPIO Pads Control
3
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <fcntl.h>
7 #include <sys/mman.h>
8 #include <unistd.h>
9
10 #define BCM2708_PERI_BASE 0x20000000
11 #define PADS_GPIO_BASE (BCM2708_PERI_BASE+0x100000)
12 #define PADS_GPIO_00_27 0x002C
13 #define PADS_GPIO_28_45 0x0030
14 #define PADS_GPIO_46_53 0x0034
15
16 #define GETPAD32(offset) \
(
(unsigned
) ((char
) (pads)+offset))
17
18 #define BLOCK_SIZE (4
1024)
19
20 volatile unsigned
pads ;
21
22 void
23 initialize(void) {
24 int mem_fd = open("/dev/mem",O_RDWR|O_SYNC);
25 char
pads_map;
26
27 if ( mem_fd <= 0 ) {
28 perror("Opening/dev/mem");
29 exit(1);
30 }
31
32 pads_map = (char
)mmap(
33 NULL, /
Any address
/
34 BLOCK_SIZE, /
Map length
/
35 PROT_READ|PROT_WRITE,
36 MAP_SHARED,
37 mem_fd, /
File to map
/
38 PADS_GPIO_BASE /
Offset to registers
/
39 );
40
41 if ( (long)pads_map == −1L ) {
42 perror("mmap failed.");
Search WWH ::




Custom Search