diff --git a/src/energenie/drv/build_rpi b/src/energenie/drv/build_rpi index 428b10d..dd89023 100755 --- a/src/energenie/drv/build_rpi +++ b/src/energenie/drv/build_rpi @@ -3,41 +3,41 @@ # build file for Raspberry Pi use # build gpio_test -gcc gpio_test.c gpio.c +gcc gpio_test.c gpio_rpi.c mv a.out gpio_test chmod u+x gpio_test # build spis_test (soft SPI tester) -gcc spi_test.c spis_rpi.c gpio.c +gcc spi_test.c spis_rpi.c gpio_rpi.c mv a.out spis_test chmod u+x spis_test # build spih_test (hard SPI tester) -gcc spi_test.c spih_rpi.c gpio.c +gcc spi_test.c spih_rpi.c gpio_rpi.c mv a.out spih_test chmod u+x spish_test # build hrf69_test -## gcc hrf69_test.c hrf69.c spis_rpi.c gpio.c +## gcc hrf69_test.c hrf69.c spis_rpi.c gpio_rpi.c ## mv a.out hrf69_test ## chmod u+x hrf69_test # build radio_test -## gcc radio_test.c radio.c hrf69.c spis_rpi.c gpio.c +## gcc radio_test.c radio.c hrf69.c spis_rpi.c gpio_rpi.c ## mv a.out radio_test ## chmod u+x radio_test # build spi .so library on Raspberry Pi -gcc -Wall -shared -o spi_rpi.so -fPIC spis_rpi.c gpio.c +gcc -Wall -shared -o spi_rpi.so -fPIC spis_rpi.c gpio_rpi.c # nm -D spi_rpi.so cp spi_rpi.so .. # radio spi .so library on Raspberry Pi -## gcc -Wall -shared -o radio_rpi.so -fPIC radio.c hrf69.c spis_rpi.c gpio.c +## gcc -Wall -shared -o radio_rpi.so -fPIC radio.c hrf69.c spis_rpi.c gpio_rpi.c ## nm -D radio_rpi.so ## cp radio_rpi.so .. diff --git a/src/energenie/drv/gpio.c b/src/energenie/drv/gpio.c deleted file mode 100644 index 7d9a144..0000000 --- a/src/energenie/drv/gpio.c +++ /dev/null @@ -1,182 +0,0 @@ -/* gpio.c D.J.Whale 8/07/2014 - * - * A very simple interface to the GPIO port on the Raspberry Pi. - */ - -/***** INCLUDES *****/ - -#include -#include -#include -#include -#include -#include -#include - -#include "gpio.h" - - -/***** CONFIGURATION *****/ - -/* uncomment to make this a simulated driver */ -//#define GPIO_SIMULATED - - -/***** CONSTANTS *****/ - -#define BCM2708_PERI_BASE 0x20000000 -//#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ -#define GPIO_BASE_OFFSET 0x200000 - -#define PAGE_SIZE (4*1024) -#define BLOCK_SIZE (4*1024) - - -/***** VARIABLES *****/ - -static int mem_fd; -static void *gpio_map; - -static volatile unsigned *gpio; - - -/****** MACROS *****/ - -#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3)) -#define OUT_GPIO(g) *(gpio+((g)/10)) |= (1<<(((g)%10)*3)) -#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3)) - -#define GPIO_SET *(gpio+7) // sets bits which are 1 ignores bits which are 0 -#define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0 - -#define GPIO_READ(g) ((*(gpio+13)&(1< +#include +#include +#include +#include +#include +#include + +#include "gpio.h" + + +/***** CONFIGURATION *****/ + +/* uncomment to make this a simulated driver */ +//#define GPIO_SIMULATED + + +/***** CONSTANTS *****/ + +#define BCM2708_PERI_BASE 0x20000000 +//#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */ +#define GPIO_BASE_OFFSET 0x200000 + +#define PAGE_SIZE (4*1024) +#define BLOCK_SIZE (4*1024) + + +/***** VARIABLES *****/ + +static int mem_fd; +static void *gpio_map; + +static volatile unsigned *gpio; + + +/****** MACROS *****/ + +#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3)) +#define OUT_GPIO(g) *(gpio+((g)/10)) |= (1<<(((g)%10)*3)) +#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3)) + +#define GPIO_SET *(gpio+7) // sets bits which are 1 ignores bits which are 0 +#define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0 + +#define GPIO_READ(g) ((*(gpio+13)&(1<