summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-11-22 00:42:10 +0100
committerChristian Pointner <equinox@spreadspace.org>2018-11-22 00:42:10 +0100
commit8e811ef77b42ef1d62db2b19b642daac2acb8665 (patch)
tree3ab33f9f7fb2808cd04d4f04d895d6b686cdf400
parentadded RadioHead library (diff)
added basic environment for RadioHead lib - not working yet
-rw-r--r--include.mk31
-rw-r--r--lib/SPI.h37
-rw-r--r--lora-test/Makefile34
-rw-r--r--lora-test/lora-test.cpp45
-rw-r--r--radiohead.mk42
5 files changed, 188 insertions, 1 deletions
diff --git a/include.mk b/include.mk
index 66daa10..ffdab72 100644
--- a/include.mk
+++ b/include.mk
@@ -38,7 +38,7 @@ CXX_OBJ_LIB := $(CXX_LIBS:%=lib-%.o)
CXX_SRC_LIB := $(CXX_LIBS:%=$(LIB_DIR)/%.cpp)
CXX_DEP_LIB := $(CXX_LIBS:%=lib-%.d)
-.PHONY: prepare clean clean-external distclean clean-lufa clean-fastled clean-pjon clean-vusb program erase flash reset run
+.PHONY: prepare clean clean-external distclean clean-lufa clean-fastled clean-pjon clean-vusb clean-radiohead program erase flash reset run
ELFFILE := $(NAME).elf
HEXFILE := $(NAME).hex
@@ -79,6 +79,12 @@ CFLAGS += -DUSES_VUSB
CFLAGS += $(VUSB_OPTS)
endif
+ifdef RADIOHEAD_PATH
+CXXFLAGS += -I$(RADIOHEAD_PATH)
+CXXFLAGS += -DRH_PLATFORM=RH_PLATFORM_GENERIC_AVR8
+CXXFLAGS += $(RADIOHEAD_OPTS)
+endif
+
prepare: $(EXTERNAL_LIBS:%=build-%)
clean-external: $(EXTERNAL_LIBS:%=clean-%)
@@ -176,6 +182,29 @@ clean-vusb:
@echo "****************************************************"
+build-radiohead: libradiohead.a
+
+libradiohead.a: Makefile
+ @echo ""
+ @echo "****************************************************"
+ @echo "building external RadioHead lib ($(RADIOHEAD_PATH))"
+ @echo ""
+ make -f $(SPREADAVR_PATH)/radiohead.mk libradiohead.a
+ make -f $(SPREADAVR_PATH)/radiohead.mk clean
+ @echo ""
+ @echo "****************************************************"
+
+clean-radiohead:
+ @echo ""
+ @echo "****************************************************"
+ @echo "cleaning external RadioHead lib ($(RADIOHEAD_PATH))"
+ @echo ""
+ make -f $(SPREADAVR_PATH)/radiohead.mk clean
+ rm -f libradiohead.a
+ @echo ""
+ @echo "****************************************************"
+
+
## project-specific objects
%.d: %.c Makefile
@set -e; rm -f $@; \
diff --git a/lib/SPI.h b/lib/SPI.h
new file mode 100644
index 0000000..6b3264e
--- /dev/null
+++ b/lib/SPI.h
@@ -0,0 +1,37 @@
+/*
+ * spreadspace avr utils
+ *
+ *
+ * Copyright (C) 2013-2018 Christian Pointner <equinox@spreadspace.org>
+ *
+ * This file is part of spreadspace avr utils.
+ *
+ * spreadspace avr utils is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * spreadspace avr utils is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPREADAVR_SPI_h_INCLUDED
+#define SPREADAVR_SPI_h_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ // TODO: for now this is just a placeholder to make so we
+ // can compile RadioHead
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lora-test/Makefile b/lora-test/Makefile
new file mode 100644
index 0000000..8b2dc08
--- /dev/null
+++ b/lora-test/Makefile
@@ -0,0 +1,34 @@
+##
+## spreadspace avr utils
+##
+##
+## Copyright (C) 2013-2018 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace avr utils.
+##
+## spreadspace avr utils is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## spreadspace avr utils is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+NAME := lora-test
+BOARD_TYPE := elecrow32u4lora
+CXX_OBJ := $(NAME).o
+LIBS := util led
+EXTERNAL_LIBS := radiohead
+SPREADAVR_PATH := ..
+
+RADIOHEAD_PATH := $(SPREADAVR_PATH)/contrib/RadioHead
+
+RADIOHEAD_DRIVER := RF95
+
+include $(SPREADAVR_PATH)/include.mk
diff --git a/lora-test/lora-test.cpp b/lora-test/lora-test.cpp
new file mode 100644
index 0000000..665e762
--- /dev/null
+++ b/lora-test/lora-test.cpp
@@ -0,0 +1,45 @@
+/*
+ * spreadspace avr utils
+ *
+ *
+ * Copyright (C) 2013-2016 Christian Pointner <equinox@spreadspace.org>
+ *
+ * This file is part of spreadspace avr utils.
+ *
+ * spreadspace avr utils is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * spreadspace avr utils is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <avr/io.h>
+#include <avr/wdt.h>
+#include <avr/interrupt.h>
+#include <avr/power.h>
+#include <stdio.h>
+
+#include "util.h"
+#include "led.h"
+#include "RadioHead.h"
+
+int main(void)
+{
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
+
+ cpu_init();
+ led_init();
+ sei();
+
+ for(;;) {
+ // for now we don't do anything here...
+ }
+}
diff --git a/radiohead.mk b/radiohead.mk
new file mode 100644
index 0000000..f0aabca
--- /dev/null
+++ b/radiohead.mk
@@ -0,0 +1,42 @@
+##
+## spreadspace avr utils
+##
+##
+## Copyright (C) 2013-2018 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace avr utils.
+##
+## spreadspace avr utils is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## spreadspace avr utils is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+include $(SPREADAVR_PATH)/defines.mk
+
+RADIOHEAD_COMPONENTS := RH_$(RADIOHEAD_DRIVER) # TODO: added other components dependent on driver...
+
+SRC:=$(foreach COMP,$(RADIOHEAD_COMPONENTS),$(RADIOHEAD_PATH)/$(COMP).cpp)
+
+CXXFLAGS += -I$(RADIOHEAD_PATH)
+CXXFLAGS += -DRH_PLATFORM=RH_PLATFORM_GENERIC_AVR8
+CXXFLAGS += $(RADIOHEAD_OPTS)
+
+OBJ = $(SRC:%.cpp=%.o)
+
+libradiohead.a: $(OBJ)
+ $(AR) $@ $(OBJ)
+
+%.o: %.cpp
+ $(CXX) -c $(CXXFLAGS) $< -o $@
+
+clean:
+ rm -f $(SRC:%.cpp=%.o)