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 | //>> Makros for reading and writing GPIO registers |
||
11 | //------------------------------------------------------------------------------------------------------ |
||
12 | #define INP_GPIO(g) *(gpio.addr + ((g)/10)) &= ~(7<<(((g)%10)*3)) |
||
13 | #define OUT_GPIO(g) *(gpio.addr + ((g)/10)) |= (1<<(((g)%10)*3)) |
||
14 | #define SET_GPIO_ALT(g,a) *(gpio.addr + (((g)/10))) |= (((a)<=3?(a) + 4:(a)==4?3:2)<<(((g)%10)*3)) |
||
15 | #define GPIO_SET *(gpio.addr + 7) // sets bits which are 1 ignores bits which are 0 |
||
16 | #define GPIO_CLR *(gpio.addr + 10) // clears bits which are 1 ignores bits which are 0 |
||
17 | #define GPIO_READ(g) *(gpio.addr + 13) &= (1<<(g)) |
||
18 | |||
19 | #define ULTRA_ECHO 24 |
||
20 | #define ULTRA_TRIGGER 23 |
||
21 | |||
22 | extern void gpio_init(); |
||
23 | extern void buzzer_short(int seq); |
||
24 | extern int calculate_distance(); |
||
25 | |||
26 | #endif //_GPIO_H |