Blame |
Last modification |
View Log
| RSS feed
#ifndef _GPIO_H
#define _GPIO_H
#define BCM2708_PERI_BASE 0x20000000
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) // GPIO controller
#define BLOCK_SIZE (4*1024)
extern struct bcm2835_peripheral gpio;
//>> Makros for reading and writing GPIO registers
//------------------------------------------------------------------------------------------------------
#define INP_GPIO(g) *(gpio.addr + ((g)/10)) &= ~(7<<(((g)%10)*3))
#define OUT_GPIO(g) *(gpio.addr + ((g)/10)) |= (1<<(((g)%10)*3))
#define SET_GPIO_ALT(g,a) *(gpio.addr + (((g)/10))) |= (((a)<=3?(a) + 4:(a)==4?3:2)<<(((g)%10)*3))
#define GPIO_SET *(gpio.addr + 7) // sets bits which are 1 ignores bits which are 0
#define GPIO_CLR *(gpio.addr + 10) // clears bits which are 1 ignores bits which are 0
#define GPIO_READ(g) *(gpio.addr + 13) &= (1<<(g))
#define ULTRA_ECHO 24
#define ULTRA_TRIGGER 23
extern void gpio_init();
extern void buzzer_short(int seq);
extern int calculate_distance();
#endif //_GPIO_H