Thanks for your help Pieter, and sorry for the delay. Got pulled away from this project for a bit and just came back to it. I decided to start by trying to compile the necessary files as C++ by editing the makefile as you suggested. It worked well until I started adding the Arduino-related Teensy Core files used by the Keypad library. I used the core files from my Teensyduino arduino IDE install located in C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy, however the moment I added in the keypad the compiler exploded with errors, with the first in the cascade being:
Code:
In file included from ./teensycore/Stream.h:24:0,
from ./teensycore/HardwareSerial.h:5,
from ./teensycore/WProgram.h:25,
from ./teensycore/Arduino.h:1,
from ./Keypad-master/src/Key.h:35,
from ./Keypad-master/src/Key.cpp:30:
./teensycore/Print.h:46:2: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++0x-compat]
constexpr Print() : write_error(0) {}
^
This pointed to a problem with print.cpp in the teensy core library. I added CPP_FLAGS = -std=c++11 to my make file, but this only led to further errors:
Code:
In file included from ./teensycore/Stream.h:24:0,
from ./teensycore/HardwareSerial.h:5,
from ./teensycore/WProgram.h:25,
from ./teensycore/Arduino.h:1,
from ./Keypad-master/src/Key.h:35,
from ./Keypad-master/src/Key.cpp:30:
./teensycore/Print.h:71:21: error: 'Printable' does not name a type
size_t print(const Printable &obj) { return obj.printTo(*this); }
^
To make sure I wasn't screwing up the makefile, I changed the core libraries to the default arduino ones and almost had success, except for the fact the the core arduino library does not contain the pin layout of the teensy (and the two libraries don't seem to be compabtible after copying and pasting the necessary files):
Code:
In file included from ./arduinocore/Print.cpp:27:0:
./arduinocore/Arduino.h:258:26: fatal error: pins_arduino.h: No such file or directory
#include "pins_arduino.h"
I'm at a loss at this point, so any advice would be much appreciated. Is there a better location from where I find Teensyduino files. It should be noted that installing software to my teensy from the arduino IDE (teensyduino) works like a charm, so I'm probably missing some important flags in my makefile. Here is the current state of my makefile:
Code:
#
# LUFA Library
# Copyright (C) Dean Camera, 2014.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
# Run "make help" for target help.
# Set the MCU accordingly to your device (e.g. at90usb1286 for a Teensy 2.0++, or atmega16u2 for an Arduino UNO R3)
MCU = at90usb1286
ARCH = AVR8
F_CPU = 16000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = Joystick
SRC = $(TARGET).c Descriptors.c main.cpp $(LUFA_SRC_USB)
LUFA_PATH = ./lufa/LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
LD_FLAGS =
#CPP_FLAGS = -std=c++11
ARDUINO_PATH = ./arduinocore
SRC += $(ARDUINO_PATH)/Print.cpp
SRC += $(ARDUINO_PATH)/HardwareSerial.cpp
CXX_FLAGS += -I$(ARDUINO_PATH)
CC_FLAGS += -I$(ARDUINO_PATH)
#TEENSY_PATH = ./teensycore
#CXX_FLAGS += -I$(TEENSY_PATH)
#CC_FLAGS += -I$(TEENSY_PATH)
KEYPAD_PATH = ./Keypad-master/src
SRC += $(KEYPAD_PATH)/Keypad.cpp
SRC += $(KEYPAD_PATH)/Key.cpp
CXX_FLAGS += -I$(KEYPAD_PATH)
CC_FLAGS += -I$(KEYPAD_PATH)
# Default target
all:
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_dfu.mk
include $(LUFA_PATH)/Build/lufa_hid.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk
# Target for LED/buzzer to alert when print is done
with-alert: all
with-alert: CC_FLAGS += -DALERT_WHEN_DONE