Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2105 | - | 1 | #ifndef _GPIO_H |
2 | #define _GPIO_H |
||
3 | |||
4 | #define BCM2708_PERI_BASE 0x20000000 |
||
5 | #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) // GPIO controller |
||
6 | #define BLOCK_SIZE (4*1024) |
||
7 | |||
8 | extern struct bcm2835_peripheral gpio; |
||
9 | |||
10 | // GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) |
||
11 | #define INP_GPIO(g) *(gpio.addr + ((g)/10)) &= ~(7<<(((g)%10)*3)) |
||
12 | #define OUT_GPIO(g) *(gpio.addr + ((g)/10)) |= (1<<(((g)%10)*3)) |
||
13 | #define SET_GPIO_ALT(g,a) *(gpio.addr + (((g)/10))) |= (((a)<=3?(a) + 4:(a)==4?3:2)<<(((g)%10)*3)) |
||
14 | #define GPIO_SET *(gpio.addr + 7) // sets bits which are 1 ignores bits which are 0 |
||
15 | #define GPIO_CLR *(gpio.addr + 10) // clears bits which are 1 ignores bits which are 0 |
||
16 | #define GPIO_READ(g) *(gpio.addr + 13) &= (1<<(g)) |
||
17 | |||
18 | // Exposes the physical address defined in the passed structure using mmap on /dev/mem |
||
19 | extern void gpio_init(); |
||
20 | extern void buzzer_short(int seq); |
||
21 | |||
22 | #endif //_GPIO_H |