diff --git a/src/energenie/drv/build_arduino b/src/energenie/drv/build_arduino deleted file mode 100755 index dd89023..0000000 --- a/src/energenie/drv/build_arduino +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/bash - -# build file for Raspberry Pi use - -# build gpio_test -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_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_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_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_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_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_rpi.c -## nm -D radio_rpi.so -## cp radio_rpi.so .. - -# END diff --git a/src/energenie/drv/gpio_arduino.c b/src/energenie/drv/gpio_arduino.c deleted file mode 100644 index f1f9bea..0000000 --- a/src/energenie/drv/gpio_arduino.c +++ /dev/null @@ -1,130 +0,0 @@ -/* 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 'Faster IO on the Arduino' on the SKPang blog: - * http://skpang.co.uk/blog/archives/323 - * - * 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. - */ - -#else if defined(ARDUINO) -#if defined(ARDUINO_PROMICRO) - -//TODO: there might be platform specific macros here to -//extract register address and bitmask -//really, what we want is to be able to pass in a uint8_t which is a GPIO number -//and this get converted (at compile time preferably) into the register access code -//required to read/write and configure that bit. The actual mapping shoudl probably -//be in the C code for gpio_arduino - -//something a bit like this, but this is not correct yet -//#define GPIO_0 PORTB,0x01 -//#define GPIO_1 PORTB,0x02 -//#define GPIO_2 PORTB,0x04 -//#define GPIO_3 PORTB,0x08 -//#define GPIO_4 PORTB,0x10 -//#define GPIO_5 PORTB,0x20 -//#define GPIO_6 PORTB,0x40 -//#define GPIO_7 PORTB,0x90 -//#define GPIO_8 PORTC,0x01 -//#define GPIO_9 PORTC,0x02 -//#define GPIO_10 PORTC,0x04 -//#define GPIO_14 PORTC,0x08 -//#define GPIO_15 PORTC,0x10 -//#define GPIO_16 PORTC,0x20 - -#else -//#error Unknown Arduino platform -#endif -#else -//#error Unknown platform -#endif - - -/***** 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) -//#define OUT_GPIO(g) - -//#define GPIO_SET -//#define GPIO_CLR - -//#define GPIO_READ(g) - -//#define GPIO_HIGH(g) -//#define GPIO_LOW(g) - - -void gpio_init() -{ - //TODO -} - - -void gpio_setin(int g) -{ - //TODO -} - - -void gpio_setout(int g) -{ - //TODO -} - - -void gpio_high(int g) -{ - //TODO -} - - -void gpio_low(int g) -{ - //TODO -} - - -void gpio_write(int g, int v) -{ - //TODO -} - - -int gpio_read(int g) -{ - //TODO -} - - -/***** END OF FILE *****/ diff --git a/src/energenie/drv/ino_ook/gpio_ino.c b/src/energenie/drv/ino_ook/gpio_ino.c new file mode 100644 index 0000000..c798e5e --- /dev/null +++ b/src/energenie/drv/ino_ook/gpio_ino.c @@ -0,0 +1,115 @@ +/* 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 'Faster IO on the Arduino' on the SKPang blog: + * http://skpang.co.uk/blog/archives/323 + * + * 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: there might be platform specific macros here to +//extract register address and bitmask +//really, what we want is to be able to pass in a uint8_t which is a GPIO number +//and this get converted (at compile time preferably) into the register access code +//required to read/write and configure that bit. The actual mapping shoudl probably +//be in the C code for gpio_arduino + +//something a bit like this, but this is not correct yet +//#define GPIO_0 PORTB,0x01 +//#define GPIO_1 PORTB,0x02 +//#define GPIO_2 PORTB,0x04 +//#define GPIO_3 PORTB,0x08 +//#define GPIO_4 PORTB,0x10 +//#define GPIO_5 PORTB,0x20 +//#define GPIO_6 PORTB,0x40 +//#define GPIO_7 PORTB,0x90 +//#define GPIO_8 PORTC,0x01 +//#define GPIO_9 PORTC,0x02 +//#define GPIO_10 PORTC,0x04 +//#define GPIO_14 PORTC,0x08 +//#define GPIO_15 PORTC,0x10 +//#define GPIO_16 PORTC,0x20 + + +/***** INCLUDES *****/ + +#include "gpio.h" +#include + +/***** CONFIGURATION *****/ + + +/***** CONSTANTS *****/ + + +/***** VARIABLES *****/ + +/****** MACROS *****/ + +//#define INP_GPIO(g) +//#define OUT_GPIO(g) + +//#define GPIO_SET +//#define GPIO_CLR + +//#define GPIO_READ(g) + +//#define GPIO_HIGH(g) +//#define GPIO_LOW(g) + + +void gpio_init() +{ + //TODO +} + + +void gpio_setin(uint8_t g) +{ + //TODO this is a temporary hack. Need to use PORT registers + pinMode(g, INPUT); +} + + +void gpio_setout(uint8_t g) +{ + //TODO this is a temporary hack. Need to use PORT registers + pinMode(g, OUTPUT); +} + + +void gpio_high(uint8_t g) +{ + //TODO this is a temporary hack. Need to use PORT registers + digitalWrite(g, 1); +} + + +void gpio_low(uint8_t g) +{ + //TODO this is a temporary hack. Need to use PORT registers + digitalWrite(g, 0); +} + + +void gpio_write(uint8_t g, uint8_t v) +{ + //TODO this is a temporary hack. Need to use PORT registers + digitalWrite(g, v); +} + + +uint8_t gpio_read(uint8_t g) +{ + //TODO this is a temporary hack. Need to use PORT registers + return digitalRead(g); +} + + +/***** END OF FILE *****/ diff --git a/src/energenie/drv/ino_ook/ino_ook.ino b/src/energenie/drv/ino_ook/ino_ook.ino new file mode 100644 index 0000000..33d2c0d --- /dev/null +++ b/src/energenie/drv/ino_ook/ino_ook.ino @@ -0,0 +1,59 @@ +#include "gpio.h" + +#define SPI_RESET 2 +#define SPI_CS 3 +#define SPI_SCLK 4 +#define SPI_MISO 5 +#define SPI_MOSI 6 + +static void delaysec(int s) +{ + for (int i=0; i