summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-05-04 18:52:06 +0200
committerChristian Pointner <equinox@spreadspace.org>2016-05-04 18:52:06 +0200
commite3299142bc004c728209cf358950189f2831a1e5 (patch)
treea38369245fff0a813c3116c73a1848cb598d3ed5
parentadded external lib PJON - not working yet.. (diff)
arduino stub digitalWire... etc work now
-rw-r--r--defines.mk23
-rw-r--r--include.mk5
-rw-r--r--lib/Arduino.h8
-rw-r--r--lib/arduino-leonardo/arduino_pins.h (renamed from lib/arduino-pins/leonardo.h)0
-rw-r--r--lib/arduino-standard/arduino_pins.h (renamed from lib/arduino-pins/standard.h)0
-rw-r--r--pjon.mk3
-rw-r--r--usb-arduino-led/Makefile48
-rw-r--r--usb-arduino-led/usb-arduino-led.cpp71
8 files changed, 138 insertions, 20 deletions
diff --git a/defines.mk b/defines.mk
index 1791377..2db1482 100644
--- a/defines.mk
+++ b/defines.mk
@@ -35,7 +35,7 @@ ifeq ($(BOARD_TYPE),teensy2)
F_USB = $(F_CPU)
PROG := teensy
LUFA_BOARD = TEENSY2
- ARDUINO_BOARD = leonardo
+ ARDUINO_PINS = leonardo
endif
ifeq ($(BOARD_TYPE),teensy1pp)
MCU := at90usb646
@@ -80,7 +80,7 @@ ifeq ($(BOARD_TYPE),hhd70dongle)
F_USB = $(F_CPU)
PROG := DFU
LUFA_BOARD = NONE
- ARDUINO_BOARD = leonardo
+ ARDUINO_PINS = leonardo
endif
ifeq ($(BOARD_TYPE),rda1846dongle)
MCU := atmega32u4
@@ -89,7 +89,7 @@ ifeq ($(BOARD_TYPE),rda1846dongle)
F_USB = $(F_CPU)
PROG := DFU
LUFA_BOARD = NONE
- ARDUINO_BOARD = leonardo
+ ARDUINO_PINS = leonardo
endif
ifeq ($(BOARD_TYPE),culV3)
MCU := atmega32u4
@@ -98,7 +98,7 @@ ifeq ($(BOARD_TYPE),culV3)
F_USB = $(F_CPU)
PROG := DFU
LUFA_BOARD = CULV3
- ARDUINO_BOARD = leonardo
+ ARDUINO_PINS = leonardo
endif
ifeq ($(BOARD_TYPE),slowpandongle1)
MCU := at90usb162
@@ -115,7 +115,7 @@ ifeq ($(BOARD_TYPE),slowpandongle2)
F_USB = $(F_CPU)
PROG := DFU
LUFA_BOARD = NONE
- ARDUINO_BOARD = leonardo
+ ARDUINO_PINS = leonardo
endif
ifeq ($(BOARD_TYPE),teenstep)
MCU := atmega32u4
@@ -124,7 +124,7 @@ ifeq ($(BOARD_TYPE),teenstep)
F_USB = $(F_CPU)
PROG := DFU
LUFA_BOARD = NONE
- ARDUINO_BOARD = leonardo
+ ARDUINO_PINS = leonardo
endif
ifeq ($(BOARD_TYPE),rhmixxx)
MCU := at90usb1286
@@ -144,7 +144,7 @@ ifeq ($(BOARD_TYPE),arduinoUno)
AVRDUDE_PORT := /dev/ttyUSB0
RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_arduino
RESET_PARAM = $(AVRDUDE_PORT)
- ARDUINO_BOARD = standard
+ ARDUINO_PINS = standard
endif
ifeq ($(BOARD_TYPE),arduinoNano)
MCU := atmega328p
@@ -156,7 +156,7 @@ ifeq ($(BOARD_TYPE),arduinoNano)
AVRDUDE_PORT := /dev/ttyUSB0
RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_arduino
RESET_PARAM = $(AVRDUDE_PORT)
- ARDUINO_BOARD = standard
+ ARDUINO_PINS = standard
endif
ifeq ($(BOARD_TYPE),arduino2009v2)
MCU := atmega328p
@@ -168,7 +168,7 @@ ifeq ($(BOARD_TYPE),arduino2009v2)
AVRDUDE_PORT := /dev/ttyUSB0
RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_arduino
RESET_PARAM = $(AVRDUDE_PORT)
- ARDUINO_BOARD = standard
+ ARDUINO_PINS = standard
endif
ifeq ($(BOARD_TYPE),arduino2009)
MCU := atmega168
@@ -247,6 +247,11 @@ CFLAGS += -std=c99
## Compile options common for all C++ compilation units.
CXXFLAGS = $(COMMON)
+ifdef ARDUINO_PINS
+CXXFLAGS += -DARDUINO_PINS=$(ARDUINO_PINS)
+CXXFLAGS += -I$(LIB_DIR)/arduino-$(ARDUINO_PINS)
+endif
+
## Linker flags
LDFLAGS = -mmcu=$(MCU)
LDFLAGS += -Wl,--gc-sections
diff --git a/include.mk b/include.mk
index d467650..57e6fcd 100644
--- a/include.mk
+++ b/include.mk
@@ -68,10 +68,7 @@ endif
ifdef PJON_PATH
CXXFLAGS += -I$(PJON_PATH)
CXXFLAGS += -DUSES_PJON
-CXXFLAGS += -DARDUINO=101
-ifdef ARDUINO_BOARD
-CXXFLAGS += -DARDUINO_BOARD=$(ARDUINO_BOARD)
-endif
+CXXFLAGS += -DARDUINO=106
CXXFLAGS += $(PJON_OPTS)
endif
diff --git a/lib/Arduino.h b/lib/Arduino.h
index ce50ea8..16f8136 100644
--- a/lib/Arduino.h
+++ b/lib/Arduino.h
@@ -230,10 +230,10 @@ long random(long, long);
void randomSeed(unsigned long);
long map(long, long, long, long, long);
-#if ARDUINO_BOARD == standard
-#include "arduino-pins/standard.h"
-#elif ARDUINO_BOARD == leonardo
-#include "arduino-pins/leonardo.h"
+#ifdef ARDUINO_PINS
+#include "arduino_pins.h"
+#else
+#warning "no arduino pin definitions found....."
#endif
// this is from spreadspace utils to run call arduino's init function
diff --git a/lib/arduino-pins/leonardo.h b/lib/arduino-leonardo/arduino_pins.h
index 6027223..6027223 100644
--- a/lib/arduino-pins/leonardo.h
+++ b/lib/arduino-leonardo/arduino_pins.h
diff --git a/lib/arduino-pins/standard.h b/lib/arduino-standard/arduino_pins.h
index a3f349e..a3f349e 100644
--- a/lib/arduino-pins/standard.h
+++ b/lib/arduino-standard/arduino_pins.h
diff --git a/pjon.mk b/pjon.mk
index d3c9be0..8a80048 100644
--- a/pjon.mk
+++ b/pjon.mk
@@ -27,9 +27,6 @@ SRC:=$(wildcard $(PJON_PATH)/*.cpp)
CXXFLAGS += -I$(PJON_PATH)
CXXFLAGS += -DARDUINO=101
CXXFLAGS += $(PJON_OPTS)
-ifdef ARDUINO_BOARD
-CXXFLAGS += -DARDUINO_BOARD=$(ARDUINO_BOARD)
-endif
OBJ = $(SRC:%.cpp=%.o)
diff --git a/usb-arduino-led/Makefile b/usb-arduino-led/Makefile
new file mode 100644
index 0000000..3d86ec4
--- /dev/null
+++ b/usb-arduino-led/Makefile
@@ -0,0 +1,48 @@
+##
+## spreadspace avr utils
+##
+##
+## Copyright (C) 2013-2015 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 := usb-arduino-led
+BOARD_TYPE := teensy2
+CXX_OBJ := $(NAME).o
+LIBS := util lufa-descriptor-usbserial usbio
+CXX_LIBS := arduino-stub
+EXTERNAL_LIBS := lufa
+SPREADAVR_PATH := ..
+RESET_FUNC := $(SPREADAVR_PATH)/tools/reset_lufa_cdc_nowait
+RESET_PARAM := '!'
+
+LUFA_PATH := $(SPREADAVR_PATH)/contrib/lufa-LUFA-151115
+LUFA_OPTS = -D USB_DEVICE_ONLY
+LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
+LUFA_OPTS += -D ORDERED_EP_CONFIG
+LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
+LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
+LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
+LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
+LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT
+
+LUFA_OPTS += -D USB_MANUFACTURER="L\"equinox\""
+LUFA_OPTS += -D USB_PRODUCT="L\"spreadspace usb-arduino-led example\""
+
+LUFA_COMPONENTS := USB USBCLASS
+
+include $(SPREADAVR_PATH)/include.mk
diff --git a/usb-arduino-led/usb-arduino-led.cpp b/usb-arduino-led/usb-arduino-led.cpp
new file mode 100644
index 0000000..d07abcc
--- /dev/null
+++ b/usb-arduino-led/usb-arduino-led.cpp
@@ -0,0 +1,71 @@
+/*
+ * spreadspace avr utils
+ *
+ *
+ * Copyright (C) 2013-2015 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 "usbio.h"
+
+#include "Arduino.h"
+
+#define LED_PIN 12
+
+void handle_cmd(uint8_t cmd)
+{
+ switch(cmd) {
+ case '0': digitalWrite(LED_PIN, LOW); break;
+ case '1': digitalWrite(LED_PIN, HIGH); break;
+ case '!': reset2bootloader(); break;
+ default: printf("error\r\n"); return;
+ }
+ printf("ok\r\n");
+}
+
+int main(void)
+{
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
+
+ cpu_init();
+ usbio_init();
+ arduino_init();
+ sei();
+
+ pinMode(LED_PIN, OUTPUT);
+
+ for(;;) {
+ int16_t BytesReceived = usbio_bytes_received();
+ while(BytesReceived > 0) {
+ int ReceivedByte = fgetc(stdin);
+ if(ReceivedByte != EOF) {
+ handle_cmd(ReceivedByte);
+ }
+ BytesReceived--;
+ }
+
+ usbio_task();
+ }
+}