diff --git a/src/energenie/drv/gpio_arduino.c b/src/energenie/drv/gpio_arduino.c new file mode 100644 index 0000000..589e77c --- /dev/null +++ b/src/energenie/drv/gpio_arduino.c @@ -0,0 +1,98 @@ +/* gpio_arduino.c D.J.Whale 04/04/2016 + * + * A very simple interface to the GPIO port on the Arduino. + * + * Arduino internally uses the 'wiring' library, but experiments have shown + * that it is really slow. + * + * (see blog by skpang) + * + * So this module uses direct register writes, and provides a placeholder for + * compile-time selection of bitmasks and bitpatterns to support more Arduino + * boards in the future. + */ + +//TODO GPIO_SIMULATED can be replaced with gpio_sim.c in future + +/***** INCLUDES *****/ + +//#include +//#include +//#include +//#include +//#include +//#include +//#include + +//#include "gpio.h" + + +/***** CONFIGURATION *****/ + +/* uncomment to make this a simulated driver */ +//#define GPIO_SIMULATED + + +/***** CONSTANTS *****/ + + +/***** VARIABLES *****/ + +/****** 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 "gpio.h" + + +/***** CONFIGURATION *****/ + + +/***** CONSTANTS *****/ + + +/***** VARIABLES *****/ + + +/****** 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<