From 0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 20 Apr 2013 22:26:55 +0200 Subject: sachen rumgeschoben, leveldb: 32bit fix --- datasources/arduino/arduinoAnalogHTTP/.gitignore | 1 + datasources/arduino/arduinoAnalogHTTP/Arduino.mk | 720 +++++++++++++++++++++ datasources/arduino/arduinoAnalogHTTP/Makefile | 9 + .../arduino/arduinoAnalogHTTP/analogethernet.ino | 99 +++ .../arduino/arduinoAnalogHTTP/bin/ard-parse-boards | 261 ++++++++ .../arduinoAnalogHTTP/bin/ard-reset-arduino | 115 ++++ datasources/arduino/arduinoAnalogStomp/.gitignore | 1 + datasources/arduino/arduinoAnalogStomp/Arduino.mk | 720 +++++++++++++++++++++ datasources/arduino/arduinoAnalogStomp/Makefile | 9 + .../arduino/arduinoAnalogStomp/analogethernet.ino | 205 ++++++ .../arduinoAnalogStomp/bin/ard-parse-boards | 261 ++++++++ .../arduinoAnalogStomp/bin/ard-reset-arduino | 115 ++++ datasources/arduino/schaltung/Untitled Sketch.fzz | Bin 0 -> 32163 bytes .../schaltung/Untitled Sketch_Leiterplatte.pdf | Bin 0 -> 803541 bytes .../schaltung/Untitled Sketch_Schaltplan.pdf | Bin 0 -> 523589 bytes .../schaltung/Untitled Sketch_Steckplatine.pdf | Bin 0 -> 1317735 bytes .../Untitled Sketch_etch_copper_bottom.pdf" | Bin 0 -> 3764 bytes .../Untitled Sketch_etch_copper_bottom_mirror.pdf" | Bin 0 -> 3778 bytes .../Untitled Sketch_etch_copper_top.pdf" | Bin 0 -> 4202 bytes .../Untitled Sketch_etch_copper_top_mirror.pdf" | Bin 0 -> 4218 bytes .../Untitled Sketch_etch_mask_bottom.pdf" | Bin 0 -> 6993 bytes .../Untitled Sketch_etch_mask_bottom_mirror.pdf" | Bin 0 -> 7036 bytes .../Untitled Sketch_etch_mask_top.pdf" | Bin 0 -> 6993 bytes .../Untitled Sketch_etch_mask_top_mirror.pdf" | Bin 0 -> 7036 bytes .../Untitled Sketch_etch_paste_mask_bottom.pdf" | Bin 0 -> 1257 bytes ...itled Sketch_etch_paste_mask_bottom_mirror.pdf" | Bin 0 -> 1257 bytes .../Untitled Sketch_etch_paste_mask_top.pdf" | Bin 0 -> 1257 bytes ...Untitled Sketch_etch_paste_mask_top_mirror.pdf" | Bin 0 -> 1257 bytes .../Untitled Sketch_etch_silk_top.pdf" | Bin 0 -> 122482 bytes .../Untitled Sketch_etch_silk_top_mirror.pdf" | Bin 0 -> 122099 bytes 30 files changed, 2516 insertions(+) create mode 100644 datasources/arduino/arduinoAnalogHTTP/.gitignore create mode 100755 datasources/arduino/arduinoAnalogHTTP/Arduino.mk create mode 100755 datasources/arduino/arduinoAnalogHTTP/Makefile create mode 100755 datasources/arduino/arduinoAnalogHTTP/analogethernet.ino create mode 100755 datasources/arduino/arduinoAnalogHTTP/bin/ard-parse-boards create mode 100755 datasources/arduino/arduinoAnalogHTTP/bin/ard-reset-arduino create mode 100644 datasources/arduino/arduinoAnalogStomp/.gitignore create mode 100755 datasources/arduino/arduinoAnalogStomp/Arduino.mk create mode 100755 datasources/arduino/arduinoAnalogStomp/Makefile create mode 100755 datasources/arduino/arduinoAnalogStomp/analogethernet.ino create mode 100755 datasources/arduino/arduinoAnalogStomp/bin/ard-parse-boards create mode 100755 datasources/arduino/arduinoAnalogStomp/bin/ard-reset-arduino create mode 100644 datasources/arduino/schaltung/Untitled Sketch.fzz create mode 100644 datasources/arduino/schaltung/Untitled Sketch_Leiterplatte.pdf create mode 100644 datasources/arduino/schaltung/Untitled Sketch_Schaltplan.pdf create mode 100644 datasources/arduino/schaltung/Untitled Sketch_Steckplatine.pdf create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom_mirror.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top_mirror.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom_mirror.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top_mirror.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom_mirror.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top_mirror.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top.pdf" create mode 100644 "datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top_mirror.pdf" (limited to 'datasources') diff --git a/datasources/arduino/arduinoAnalogHTTP/.gitignore b/datasources/arduino/arduinoAnalogHTTP/.gitignore new file mode 100644 index 0000000..d900568 --- /dev/null +++ b/datasources/arduino/arduinoAnalogHTTP/.gitignore @@ -0,0 +1 @@ +build-uno diff --git a/datasources/arduino/arduinoAnalogHTTP/Arduino.mk b/datasources/arduino/arduinoAnalogHTTP/Arduino.mk new file mode 100755 index 0000000..09819ac --- /dev/null +++ b/datasources/arduino/arduinoAnalogHTTP/Arduino.mk @@ -0,0 +1,720 @@ +######################################################################## +# +# Arduino command line tools Makefile +# System part (i.e. project independent) +# +# Copyright (C) 2010,2011,2012 Martin Oldfield , based on +# work that is copyright Nicholas Zambetti, David A. Mellis & Hernando +# Barragan. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# Adapted from Arduino 0011 Makefile by M J Oldfield +# +# Original Arduino adaptation by mellis, eighthave, oli.keller +# +# Version 0.1 17.ii.2009 M J Oldfield +# +# 0.2 22.ii.2009 M J Oldfield +# - fixes so that the Makefile actually works! +# - support for uploading via ISP +# - orthogonal choices of using the Arduino for +# tools, libraries and uploading +# +# 0.3 21.v.2010 M J Oldfield +# - added proper license statement +# - added code from Philip Hands to reset +# Arduino prior to upload +# +# 0.4 25.v.2010 M J Oldfield +# - tweaked reset target on Philip Hands' advice +# +# 0.5 23.iii.2011 Stefan Tomanek +# - added ad-hoc library building +# 17.v.2011 M J Oldfield +# - grabbed said version from Ubuntu +# +# 0.6 22.vi.2011 M J Oldfield +# - added ard-parse-boards supports +# - added -lc to linker opts, +# on Fabien Le Lez's advice +# +# 0.7 12.vii.2011 M J Oldfield +# - moved -lm to the end of linker opts, +# to solve Frank Knopf's problem; +# - added -F to stty opts: Craig Hollabaugh +# reckons it's good for Ubuntu +# +# 0.8 12.ii.2012 M J Oldfield +# - Patches for Arduino 1.0 IDE: +# support .ino files; +# handle board 'variants'; +# tweaked compile flags. +# - Build a library from all the system +# supplied code rather than linking the .o +# files directly. +# - Let TARGET default to current directory +# as per Daniele Vergini's patch. +# - Add support for .c files in system +# libraries: Dirk-Willem van Gulik and Evan +# Goldenberg both reported this and +# provided patches in the same spirit. +# +# 0.9 26.iv.2012 M J Oldfield +# - Allow the punter to specify boards.txt +# file and parser independently (after +# Peplin and Brotchie on github) +# - Support user libraries (Peplin's patch) +# - Remove main.cpp if NO_CORE_MAIN_CPP is +# defined (ex Peplin) +# - Added a monitor target which talks to the +# Arduino serial port (Peplin's suggestion) +# - Rejigged PATH calculations for general +# tidiness (ex Peplin) +# - Moved the reset target to Perl for +# clarity and better error handling (ex +# Daniele Vergini) +# +# 0.10 17.ix.12 M J Oldfield +# - Added installation notes for Fedora (ex Rickard Lindberg). +# - Changed size target so that it looks at the ELF object, +# not the hexfile (ex Jared Szechy and Scott Howard). +# - Fixed ARDUNIO typo in README.md (ex Kalin Kozhuharov). +# - Tweaked OBJDIR handling (ex Matthias Urlichs and Scott Howard). +# - Changed the name of the Debian/Ubuntu package (ex +# Scott Howard). +# - Only set AVRDUDE_CONF if it's not set (ex Tom Hall). +# - Added support for USB_PID/VID used by the Leonardo (ex Dan +# Villiom Podlaski Christiansen and Marc Plano-Lesay). +# +######################################################################## +# +# PATHS YOU NEED TO SET UP +# +# I've reworked the way paths to executables are constructed in this +# version (0.9) of the Makefile. +# +# We need to worry about three different sorts of file: +# +# 1. Things which are included in this distribution e.g. ard-parse-boards +# => ARDMK_DIR +# +# 2. Things which are always in the Arduino distribution e.g. +# boards.txt, libraries, &c. +# => ARDUINO_DIR +# +# 3. Things which might be bundled with the Arduino distribution, but +# might come from the system. Most of the toolchain is like this: +# on Linux it's supplied by the system. +# => AVR_TOOLS_DIR +# +# Having set these three variables, we can work out the rest assuming +# that things are canonically arranged beneath the directories defined +# above. +# +# On the Mac you might want to set: +# +# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java +# ARDMK_DIR = /usr/local +# +# On Linux, you might prefer: +# +# ARDUINO_DIR = /usr/share/arduino +# ARDMK_DIR = /usr/local +# AVR_TOOLS_DIR = /usr +# +# You can either set these up in the Makefile, or put them in your +# environment e.g. in your .bashrc +# +# If you don't install the ard-... binaries to /usr/local/bin, but +# instead copy them to e.g. /home/mjo/arduino.mk/bin then set +# ARDML_DIR = /home/mjo/arduino.mk +# +######################################################################## +# +# DEPENDENCIES +# +# The Perl programs need a couple of libraries: +# YAML +# Device::SerialPort +# +######################################################################## +# +# STANDARD ARDUINO WORKFLOW +# +# Given a normal sketch directory, all you need to do is to create +# a small Makefile which defines a few things, and then includes this one. +# +# For example: +# +# ARDUINO_LIBS = Ethernet Ethernet/utility SPI +# BOARD_TAG = uno +# ARDUINO_PORT = /dev/cu.usb* +# +# include /usr/local/share/Arduino.mk +# +# Hopefully these will be self-explanatory but in case they're not: +# +# ARDUINO_LIBS - A list of any libraries used by the sketch (we +# assume these are in +# $(ARDUINO_DIR)/hardware/libraries +# +# ARDUINO_PORT - The port where the Arduino can be found (only needed +# when uploading +# +# BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega +# 'make show_boards' shows a list +# +# Once this file has been created the typical workflow is just +# +# $ make upload +# +# All of the object files are created in the build-cli subdirectory +# All sources should be in the current directory and can include: +# - at most one .pde or .ino file which will be treated as C++ after +# the standard Arduino header and footer have been affixed. +# - any number of .c, .cpp, .s and .h files +# +# Included libraries are built in the build-cli/libs subdirectory. +# +# Besides make upload you can also +# make - no upload +# make clean - remove all our dependencies +# make depends - update dependencies +# make reset - reset the Arduino by tickling DTR on the serial port +# make raw_upload - upload without first resetting +# make show_boards - list all the boards defined in boards.txt +# make monitor - connect to the Arduino's serial port +# +######################################################################## +# +# SERIAL MONITOR +# +# The serial monitor just invokes the GNU screen program with suitable +# options. For more information see screen (1) and search for +# 'character special device'. +# +# The really useful thing to know is that ^A-k gets you out! +# +# The fairly useful thing to know is that you can bind another key to +# escape too, by creating $HOME{.screenrc} containing e.g. +# +# bindkey ^C kill +# +# If you want to change the baudrate, just set MONITOR_BAUDRATE. If you +# don't set it, it defaults to 9600 baud. +# +######################################################################## +# +# PATHS +# +# I've reworked the way paths to executables are constructed in this +# version of Makefile. +# +# We need to worry about three different sorts of file: +# +# 1. Things which are included in this distribution e.g. ard-parse-boards +# => ARDMK_DIR +# +# 2. Things which are always in the Arduino distribution e.g. +# boards.txt, libraries, &c. +# => ARDUINO_DIR +# +# 3. Things which might be bundled with the Arduino distribution, but +# might come from the system. Most of the toolchain is like this: +# on Linux it's supplied by the system. +# => AVR_TOOLS_DIR +# +# Having set these three variables, we can work out the rest assuming +# that things are canonically arranged beneath the directories defined +# above. +# +# So, on the Mac you might want to set: +# +# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java +# ARDMK_DIR = /usr/local +# +# On Linux, you might prefer: +# +# ARDUINO_DIR = /usr/share/arduino +# ARDMK_DIR = /usr/local +# AVR_TOOLS_DIR = /usr +# +# +# +# +######################################################################## +# +# ARDUINO WITH ISP +# +# You need to specify some details of your ISP programmer and might +# also need to specify the fuse values: +# +# ISP_PROG = -c stk500v2 +# ISP_PORT = /dev/ttyACM0 +# +# You might also need to set the fuse bits, but typically they'll be +# read from boards.txt, based on the BOARD_TAG variable: +# +# ISP_LOCK_FUSE_PRE = 0x3f +# ISP_LOCK_FUSE_POST = 0xcf +# ISP_HIGH_FUSE = 0xdf +# ISP_LOW_FUSE = 0xff +# ISP_EXT_FUSE = 0x01 +# +# I think the fuses here are fine for uploading to the ATmega168 +# without bootloader. +# +# To actually do this upload use the ispload target: +# +# make ispload +# +# +######################################################################## + +######################################################################## +# +# Default TARGET to cwd (ex Daniele Vergini) +ifndef TARGET +TARGET = $(notdir $(CURDIR)) +endif + +######################################################################## + +# +# Arduino version number +ifndef ARDUINO_VERSION +ARDUINO_VERSION = 100 +endif + +######################################################################## +# Arduino and system paths +# +ifdef ARDUINO_DIR + +ifndef AVR_TOOLS_DIR +AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr +# The avrdude bundled with Arduino can't find its config +ifndef AVRDUDE_CONF +AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf +endif +endif + +ifndef AVR_TOOLS_PATH +AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin +endif + +ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries +ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino +ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants + +else + +echo $(error "ARDUINO_DIR is not defined") + +endif + +######################################################################## +# Makefile distribution path +# +ifdef ARDMK_DIR + +ifndef ARDMK_PATH +ARDMK_PATH = $(ARDMK_DIR)/bin +endif + +else + +echo $(error "ARDMK_DIR is not defined") + +endif + +######################################################################## +# Miscellanea +# +ifndef ARDUINO_SKETCHBOOK +ARDUINO_SKETCHBOOK = $(HOME)/sketchbook +endif + +ifndef USER_LIB_PATH +USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries +endif + +######################################################################## +# Serial monitor (just a screen wrapper) +# +# Quite how to construct the monitor command seems intimately tied +# to the command we're using (here screen). So, read the screen docs +# for more information (search for 'character special device'). +# +ifndef MONITOR_BAUDRATE +MONITOR_BAUDRATE = 9600 +endif + +ifndef MONITOR_CMD +MONITOR_CMD = screen +endif + +######################################################################## +# Reset +ifndef RESET_CMD +RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) +endif + +######################################################################## +# boards.txt parsing +# +ifndef BOARD_TAG +BOARD_TAG = uno +endif + +ifndef BOARDS_TXT +BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt +endif + +ifndef PARSE_BOARD +PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards +endif + +ifndef PARSE_BOARD_OPTS +PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT) +endif + +ifndef PARSE_BOARD_CMD +PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS) +endif + +# Which variant ? This affects the include path +ifndef VARIANT +VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant) +endif + +# processor stuff +ifndef MCU +MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu) +endif + +ifndef F_CPU +F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) +endif + +# USB IDs for the Leonardo +ifndef USB_VID +USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid) +endif + +ifndef USB_PID +USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid) +endif + +# normal programming info +ifndef AVRDUDE_ARD_PROGRAMMER +AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) +endif + +ifndef AVRDUDE_ARD_BAUDRATE +AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed) +endif + +# fuses if you're using e.g. ISP +ifndef ISP_LOCK_FUSE_PRE +ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits) +endif + +ifndef ISP_LOCK_FUSE_POST +ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits) +endif + +ifndef ISP_HIGH_FUSE +ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses) +endif + +ifndef ISP_LOW_FUSE +ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses) +endif + +ifndef ISP_EXT_FUSE +ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses) +endif + +# Everything gets built in here (include BOARD_TAG now) +ifndef OBJDIR +OBJDIR = build-$(BOARD_TAG) +endif + +######################################################################## +# Local sources +# +LOCAL_C_SRCS = $(wildcard *.c) +LOCAL_CPP_SRCS = $(wildcard *.cpp) +LOCAL_CC_SRCS = $(wildcard *.cc) +LOCAL_PDE_SRCS = $(wildcard *.pde) +LOCAL_INO_SRCS = $(wildcard *.ino) +LOCAL_AS_SRCS = $(wildcard *.S) +LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \ + $(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \ + $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) +LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) + +# Dependency files +DEPS = $(LOCAL_OBJS:.o=.d) + +# core sources +ifeq ($(strip $(NO_CORE)),) +ifdef ARDUINO_CORE_PATH +CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) +CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) + +ifneq ($(strip $(NO_CORE_MAIN_CPP)),) +CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) +endif + +CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) +CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ + $(OBJDIR)/%,$(CORE_OBJ_FILES)) +endif +endif + + +######################################################################## +# Rules for making stuff +# + +# The name of the main targets +TARGET_HEX = $(OBJDIR)/$(TARGET).hex +TARGET_ELF = $(OBJDIR)/$(TARGET).elf +TARGETS = $(OBJDIR)/$(TARGET).* +CORE_LIB = $(OBJDIR)/libcore.a + +# A list of dependencies +DEP_FILE = $(OBJDIR)/depends.mk + +# Names of executables +CC = $(AVR_TOOLS_PATH)/avr-gcc +CXX = $(AVR_TOOLS_PATH)/avr-g++ +OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy +OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump +AR = $(AVR_TOOLS_PATH)/avr-ar +SIZE = $(AVR_TOOLS_PATH)/avr-size +NM = $(AVR_TOOLS_PATH)/avr-nm +REMOVE = rm -f +MV = mv -f +CAT = cat +ECHO = echo + +# General arguments +SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)) +USER_LIBS = $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)) +SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) +USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) +LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS))) +LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS))) +USER_LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(USER_LIBS))) +USER_LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(USER_LIBS))) +LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \ + $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) +USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(USER_LIB_CPP_SRCS)) \ + $(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(USER_LIB_C_SRCS)) + +CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ + -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ + $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ + -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) \ + -ffunction-sections -fdata-sections + +CFLAGS = -std=gnu99 +CXXFLAGS = -fno-exceptions +ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp +LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os + +# Expand and pick the first port +ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) + +# Implicit rules for building everything (needed to get everything in +# the right directory) +# +# Rather than mess around with VPATH there are quasi-duplicate rules +# here for building e.g. a system C++ file and a local C++ +# file. Besides making things simpler now, this would also make it +# easy to change the build options in future + +# library sources +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +# normal local sources +# .o rules are for objects, .d for dependency tracking +# there seems to be an awful lot of duplication here!!! +$(OBJDIR)/%.o: %.c + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.cc + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.cpp + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.S + $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.s + $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ + +$(OBJDIR)/%.d: %.c + $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.cc + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.cpp + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.S + $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.s + $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) + +# the pde -> cpp -> o file +$(OBJDIR)/%.cpp: %.pde + $(ECHO) '#include "WProgram.h"' > $@ + $(CAT) $< >> $@ + +# the ino -> cpp -> o file +$(OBJDIR)/%.cpp: %.ino + $(ECHO) '#include ' > $@ + $(CAT) $< >> $@ + +$(OBJDIR)/%.o: $(OBJDIR)/%.cpp + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/%.d: $(OBJDIR)/%.cpp + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + +# core files +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +# various object conversions +$(OBJDIR)/%.hex: $(OBJDIR)/%.elf + $(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(OBJDIR)/%.eep: $(OBJDIR)/%.elf + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O ihex $< $@ + +$(OBJDIR)/%.lss: $(OBJDIR)/%.elf + $(OBJDUMP) -h -S $< > $@ + +$(OBJDIR)/%.sym: $(OBJDIR)/%.elf + $(NM) -n $< > $@ + +######################################################################## +# +# Avrdude +# +ifndef AVRDUDE +AVRDUDE = $(AVR_TOOLS_PATH)/avrdude +endif + +AVRDUDE_COM_OPTS = -q -V -p $(MCU) +ifdef AVRDUDE_CONF +AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) +endif + +AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT) + +ifndef ISP_PROG +ISP_PROG = -c stk500v2 +endif + +AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) + + +######################################################################## +# +# Explicit targets start here +# + +all: $(OBJDIR) $(TARGET_HEX) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) + $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm + +$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) + $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) + +$(DEP_FILE): $(OBJDIR) $(DEPS) + cat $(DEPS) > $(DEP_FILE) + +upload: reset raw_upload + +raw_upload: $(TARGET_HEX) + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ + -U flash:w:$(TARGET_HEX):i + +reset: + $(RESET_CMD) $(ARD_PORT) + +# stty on MacOS likes -F, but on Debian it likes -f redirecting +# stdin/out appears to work but generates a spurious error on MacOS at +# least. Perhaps it would be better to just do it in perl ? +reset_stty: + for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ + do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \ + done ;\ + $$STTYF $(ARD_PORT) hupcl ;\ + (sleep 0.1 || sleep 1) ;\ + $$STTYF $(ARD_PORT) -hupcl + +ispload: $(TARGET_HEX) + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ + -U lock:w:$(ISP_LOCK_FUSE_PRE):m \ + -U hfuse:w:$(ISP_HIGH_FUSE):m \ + -U lfuse:w:$(ISP_LOW_FUSE):m \ + -U efuse:w:$(ISP_EXT_FUSE):m + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \ + -U flash:w:$(TARGET_HEX):i + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \ + -U lock:w:$(ISP_LOCK_FUSE_POST):m + +clean: + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) + +depends: $(DEPS) + cat $(DEPS) > $(DEP_FILE) + +size: $(OBJDIR) $(TARGET_ELF) + $(SIZE) -C --mcu=$(MCU) $(TARGET_ELF) + +show_boards: + $(PARSE_BOARD_CMD) --boards + +monitor: + $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) + +.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor + +include $(DEP_FILE) diff --git a/datasources/arduino/arduinoAnalogHTTP/Makefile b/datasources/arduino/arduinoAnalogHTTP/Makefile new file mode 100755 index 0000000..4f66c20 --- /dev/null +++ b/datasources/arduino/arduinoAnalogHTTP/Makefile @@ -0,0 +1,9 @@ +ARDUINO_DIR= /usr/share/arduino +ARDMK_DIR= . +AVR_TOOLS_DIR = /usr + +BOARD_TAG = uno +ARDUINO_PORT = /dev/ttyACM0 +ARDUINO_LIBS = Ethernet Ethernet/utility SPI + +include Arduino.mk diff --git a/datasources/arduino/arduinoAnalogHTTP/analogethernet.ino b/datasources/arduino/arduinoAnalogHTTP/analogethernet.ino new file mode 100755 index 0000000..63c53e7 --- /dev/null +++ b/datasources/arduino/arduinoAnalogHTTP/analogethernet.ino @@ -0,0 +1,99 @@ +// vim: filetype=cpp +#include +#include + +byte mac[] = { 0xAD, 0xEE, 0x00, 0xEF, 0xFE, 0xED }; +const int ledPin = 13; // select the pin for the LED + +const long ADC_REF_MV = 3300; +const long ADC_MAX_STEP = 1024; +const long OV_FACTOR = 4; // Op. Verstärker Faktor = 4; 10mV = 1dB + +EthernetClient client; + +void sendKeyValue(const char *key, const char *value) { + char hdrbuf[512]; + snprintf(hdrbuf, 512, "Content-Length: %d\r\n", strlen(value)); + + if ( ! client.connect("10.1.0.1", 8080)) { + Serial.println("Failed to connect"); + delay(500); + return; + } + Serial.print("Send "); + Serial.print(key); + Serial.print("="); + Serial.println(value); + + client.write("PUT /api/value/"); + client.write(key); + client.write(" HTTP/1.1\r\n"); + client.write(hdrbuf); + client.write("\r\n"); + client.write(value); + + client.stop(); +} + +void sendPinValue() { + long sensorValue, + sensorValueMV, + sensorValueDBA, + pinnr; + char buf[12]; + char *sensorKey = "arduino.aX", + *sensorKeyMV = "arduino.aX.mv", + *sensorKeyDBA = "arduino.aX.dba"; + for (int i = A0; i <= A5; i++) { + pinnr = i - A0; + + sensorValue = analogRead(i); + sensorKey[9] = '0' + pinnr; + snprintf(buf, 8, "%u", sensorValue); + sendKeyValue(sensorKey, buf); + + sensorValueMV = sensorValue * (ADC_REF_MV*100/ADC_MAX_STEP); + sensorKeyMV[9] = '0' + pinnr; + snprintf(buf, 8, "%ld.%03ld", sensorValueMV/100, sensorValue%100); + sendKeyValue(sensorKeyMV, buf); + + sensorValueDBA = sensorValueMV / OV_FACTOR; + sensorKeyDBA[9] = '0' + pinnr; + snprintf(buf, 12, "%ld.%04ld", sensorValueDBA/1000, sensorValueDBA%1000); + sendKeyValue(sensorKeyDBA, buf); + } +} + + +void setup() { + Serial.begin(9600); + Serial.println("Begin init"); + + // declare the ledPin as an OUTPUT: + pinMode(ledPin, OUTPUT); + + // start the Ethernet and UDP: Use DHCP for IP-Configuration + Ethernet.begin(mac); + Serial.println("Ethernet init done"); + + analogReference(EXTERNAL); + delay(1000); + Serial.println("Start loop()"); +} + + + +char buf[512]; + +void loop() { + unsigned long dt = millis(); + digitalWrite(ledPin, HIGH); + + sendPinValue(); + + digitalWrite(ledPin, LOW); + + dt = (millis() - dt); + if (dt < 1000) delay(1000 - dt); +} + diff --git a/datasources/arduino/arduinoAnalogHTTP/bin/ard-parse-boards b/datasources/arduino/arduinoAnalogHTTP/bin/ard-parse-boards new file mode 100755 index 0000000..e2de71b --- /dev/null +++ b/datasources/arduino/arduinoAnalogHTTP/bin/ard-parse-boards @@ -0,0 +1,261 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +use Getopt::Long; +use Pod::Usage; +use YAML; + +my %Opt = + ( + boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', + ); + +GetOptions(\%Opt, + "boards_txt=s", # filename of the boards.txt file + "find!", # search for data + "dump!", # dump the whole database + "boards!", # dump a list of boards + "help!", + "info!", + ); + +if ($Opt{help} || $Opt{info}) + { + usage(); + } + +my $db = parse_boards($Opt{boards_txt}); + +if ($Opt{dump}) + { + dump_data("$Opt{boards_txt} contains:", $db); + } +elsif ($Opt{find}) + { + my @terms = @ARGV or usage(); + find_data($db, \@terms); + } +elsif ($Opt{boards}) + { + dump_boards($db); + } +else + { + my $tag = shift @ARGV or usage(); + + if (my $key = shift @ARGV) + { + die "$key isn't defined for the $tag board, " + unless $db->{$tag} && exists $db->{$tag}->{$key}; + + print $db->{$tag}->{$key}, "\n"; + } + else + { + die "The $tag board isn't defined, " + unless $db->{$tag}; + + dump_data("The $tag board:", $db->{$tag}); + } + } + +## here endeth the main + +sub usage + { + pod2usage(-verbose => 2); + } + +# return HoH: {board}->{field} = value +sub parse_boards + { + my $filename = shift; + + my %b; + + open(my $fh, '<', $filename) + or die "Can't open $filename, "; + + while(<$fh>) + { + my ($board, $key, $value) = /^\s*(\S+?)\.(\S+?)\s*=\s*(.+?)\s*$/ + or next; + + $b{$board}->{$key} = $value; + } + + return \%b; + } + +# A rudimentary search engine +sub find_data + { + my ($db, $term_list) = @_; + + my @q = map { qr/$_/i } @$term_list; + my $q = join(' && ', map { "/$_/i" } @$term_list); + + my %hit; + foreach my $b (keys %$db) + { + foreach my $k (keys %{$db->{$b}}) + { + my $v = $db->{$b}->{$k}; + $hit{$b}->{$k} = $v if !grep { $v !~ /$_/i } @q; + } + } + + dump_data("Matches for $q:", \%hit); + } + +# The list of boards... +sub dump_boards + { + my $db = shift or return; + + my %name; + my $max_l = 0; + foreach my $b (keys %$db) + { + $name{$b} = $db->{$b}->{name} || 'Anonymous'; + $max_l = length($b) if $max_l < length($b); + } + + my $fmt = sprintf("%%-%ds %%s\n", $max_l + 2); + + printf $fmt, "Tag", "Board Name"; + foreach my $b (sort keys %name) + { + printf $fmt, $b, $name{$b}; + } + } + + +# dump arbitrary data with a title +sub dump_data + { + my ($title, $data) = @_; + + print "# $title\n", Dump($data); + } + +__END__ + +=head1 NAME + +ard-parse-boards - Read data from the Arduino boards.txt file + +=head1 USAGE + + Dump all the data in the file: + $ ard-parse-boards --dump + + See which boards we know about: + $ ard-parse-boards --boards + + Look for a particular board... + $ ard-parse-boards --find uno + + ...multiple terms are implicitly ANDed: + $ ard-parse-boards --find duemil 328 + + Dump all the data for a particular board: + $ ard-parse-boards atmega328 + + Extract a particular field: + $ ard-parse-boards atmega328 build.f_cpu + +=head1 DESCRIPTION + +The Arduino software package ships with a boards.txt file which tells +the Arduino IDE details about particular hardware. So when the user +says he's got a shiny new Arduino Uno, boards.txt knows that it has a +16MHz ATmega328 on it. It would be nice to access these data from the +command line too. + +In normal operation you simply specify the tag given to the board in +the boards.txt file, and optionally a field name. This program then +extracts the data to STDOUT. + +Most boards have names which are quite unwieldy, so we always refer to +a board by a tag, not its name. Strictly the tag is the bit before the +first dot in the boards.txt key. You can see a list of board tags and +names with the C<--boards> option. + +=head1 OPTIONS + +=over + +=item --boards_txt=[file] + +Specify the full path to the boards.txt file. + +=back + +The following options all disable the normal 'lookup' operation. + +=over + +=item --dump + +Dump the complete database in YAML format. + +=item ---boards + +Print a list of the tag and name of every board in the file. + +=item --find [query] ... + +Find matching data. Strictly, return a list of values which match all +of the query terms, treating each term as a case-insensitive regexp. + +For example: + +=over + +=item --find 328 + +List data containing 328 (anywhere in the value). + +=item --find due + +List data containing 'due' (e.g. duemilanove). + +=item --find 328 due + +List data containing both 328 and due. + +=back + +=back + +=head1 BUGS AND LIMITATIONS + +There are no known bugs in this application. + +Please report problems to the author. + +Patches are welcome. + +=head1 AUTHOR + +Martin Oldfield, ex-atelier@mjo.tc + +Thanks to Mark Sproul who suggested doing something like this to me ages ago. + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2011, Martin Oldfield. All rights reserved. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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. + + diff --git a/datasources/arduino/arduinoAnalogHTTP/bin/ard-reset-arduino b/datasources/arduino/arduinoAnalogHTTP/bin/ard-reset-arduino new file mode 100755 index 0000000..22c7109 --- /dev/null +++ b/datasources/arduino/arduinoAnalogHTTP/bin/ard-reset-arduino @@ -0,0 +1,115 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +use Device::SerialPort; +use Getopt::Long; +use Pod::Usage; + +my %Opt = + ( + period => 0.1, + ); + +GetOptions(\%Opt, + "period=f", # width of reset pulse in seconds + "verbose!", + "help!", + "info!", + ); + +if ($Opt{help} || $Opt{info}) + { + usage(); + } + +die "No Arduinos found!\n" + unless @ARGV; + +foreach my $dev (@ARGV) + { + my $p = Device::SerialPort->new($dev) + or die "Unable to open $dev: $!\n"; + + my $dt = $Opt{period}; + + print STDERR "Setting DTR high for ${dt}s on $dev\n" + if $Opt{verbose}; + + die "Invalid pulse width ($dt), " + unless $dt > 0.0; + + $p->pulse_dtr_on($dt * 1000.0); + } + +## here endeth the main + +sub usage + { + pod2usage(-verbose => 2); + } + +__END__ + +=head1 NAME + +ard-reset-arduino - Reset an Arduino + +=head1 USAGE + + $ ard-reset-arduino /dev/cu.usb* + + $ ard-reset-arduino --verbose --period=0.1 /dev/cu.usb* + +=head1 DESCRIPTION + +To reset (most) Arduinos, it's enough to just pulse the DTR line. + +You can do that from the shell with stty, but there's an interesting +diversity of command flags. This little program gives a uniform interface +at the cost of requiring C. + +=head1 OPTIONS + +=over + +=item --verbose + +Watch what's going on on STDERR. + +=item --period=0.25 + +Specify the DTR pulse width in seconds. + +=back + +=head1 BUGS AND LIMITATIONS + +There are no known bugs in this application. + +Please report problems to the author. + +Patches are welcome. + +=head1 AUTHOR + +Martin Oldfield, ex-atelier@mjo.tc + +Thanks to Daniele Vergini who suggested this to me, and supplied +a command line version. + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2012, Martin Oldfield. All rights reserved. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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. + + diff --git a/datasources/arduino/arduinoAnalogStomp/.gitignore b/datasources/arduino/arduinoAnalogStomp/.gitignore new file mode 100644 index 0000000..d900568 --- /dev/null +++ b/datasources/arduino/arduinoAnalogStomp/.gitignore @@ -0,0 +1 @@ +build-uno diff --git a/datasources/arduino/arduinoAnalogStomp/Arduino.mk b/datasources/arduino/arduinoAnalogStomp/Arduino.mk new file mode 100755 index 0000000..09819ac --- /dev/null +++ b/datasources/arduino/arduinoAnalogStomp/Arduino.mk @@ -0,0 +1,720 @@ +######################################################################## +# +# Arduino command line tools Makefile +# System part (i.e. project independent) +# +# Copyright (C) 2010,2011,2012 Martin Oldfield , based on +# work that is copyright Nicholas Zambetti, David A. Mellis & Hernando +# Barragan. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# Adapted from Arduino 0011 Makefile by M J Oldfield +# +# Original Arduino adaptation by mellis, eighthave, oli.keller +# +# Version 0.1 17.ii.2009 M J Oldfield +# +# 0.2 22.ii.2009 M J Oldfield +# - fixes so that the Makefile actually works! +# - support for uploading via ISP +# - orthogonal choices of using the Arduino for +# tools, libraries and uploading +# +# 0.3 21.v.2010 M J Oldfield +# - added proper license statement +# - added code from Philip Hands to reset +# Arduino prior to upload +# +# 0.4 25.v.2010 M J Oldfield +# - tweaked reset target on Philip Hands' advice +# +# 0.5 23.iii.2011 Stefan Tomanek +# - added ad-hoc library building +# 17.v.2011 M J Oldfield +# - grabbed said version from Ubuntu +# +# 0.6 22.vi.2011 M J Oldfield +# - added ard-parse-boards supports +# - added -lc to linker opts, +# on Fabien Le Lez's advice +# +# 0.7 12.vii.2011 M J Oldfield +# - moved -lm to the end of linker opts, +# to solve Frank Knopf's problem; +# - added -F to stty opts: Craig Hollabaugh +# reckons it's good for Ubuntu +# +# 0.8 12.ii.2012 M J Oldfield +# - Patches for Arduino 1.0 IDE: +# support .ino files; +# handle board 'variants'; +# tweaked compile flags. +# - Build a library from all the system +# supplied code rather than linking the .o +# files directly. +# - Let TARGET default to current directory +# as per Daniele Vergini's patch. +# - Add support for .c files in system +# libraries: Dirk-Willem van Gulik and Evan +# Goldenberg both reported this and +# provided patches in the same spirit. +# +# 0.9 26.iv.2012 M J Oldfield +# - Allow the punter to specify boards.txt +# file and parser independently (after +# Peplin and Brotchie on github) +# - Support user libraries (Peplin's patch) +# - Remove main.cpp if NO_CORE_MAIN_CPP is +# defined (ex Peplin) +# - Added a monitor target which talks to the +# Arduino serial port (Peplin's suggestion) +# - Rejigged PATH calculations for general +# tidiness (ex Peplin) +# - Moved the reset target to Perl for +# clarity and better error handling (ex +# Daniele Vergini) +# +# 0.10 17.ix.12 M J Oldfield +# - Added installation notes for Fedora (ex Rickard Lindberg). +# - Changed size target so that it looks at the ELF object, +# not the hexfile (ex Jared Szechy and Scott Howard). +# - Fixed ARDUNIO typo in README.md (ex Kalin Kozhuharov). +# - Tweaked OBJDIR handling (ex Matthias Urlichs and Scott Howard). +# - Changed the name of the Debian/Ubuntu package (ex +# Scott Howard). +# - Only set AVRDUDE_CONF if it's not set (ex Tom Hall). +# - Added support for USB_PID/VID used by the Leonardo (ex Dan +# Villiom Podlaski Christiansen and Marc Plano-Lesay). +# +######################################################################## +# +# PATHS YOU NEED TO SET UP +# +# I've reworked the way paths to executables are constructed in this +# version (0.9) of the Makefile. +# +# We need to worry about three different sorts of file: +# +# 1. Things which are included in this distribution e.g. ard-parse-boards +# => ARDMK_DIR +# +# 2. Things which are always in the Arduino distribution e.g. +# boards.txt, libraries, &c. +# => ARDUINO_DIR +# +# 3. Things which might be bundled with the Arduino distribution, but +# might come from the system. Most of the toolchain is like this: +# on Linux it's supplied by the system. +# => AVR_TOOLS_DIR +# +# Having set these three variables, we can work out the rest assuming +# that things are canonically arranged beneath the directories defined +# above. +# +# On the Mac you might want to set: +# +# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java +# ARDMK_DIR = /usr/local +# +# On Linux, you might prefer: +# +# ARDUINO_DIR = /usr/share/arduino +# ARDMK_DIR = /usr/local +# AVR_TOOLS_DIR = /usr +# +# You can either set these up in the Makefile, or put them in your +# environment e.g. in your .bashrc +# +# If you don't install the ard-... binaries to /usr/local/bin, but +# instead copy them to e.g. /home/mjo/arduino.mk/bin then set +# ARDML_DIR = /home/mjo/arduino.mk +# +######################################################################## +# +# DEPENDENCIES +# +# The Perl programs need a couple of libraries: +# YAML +# Device::SerialPort +# +######################################################################## +# +# STANDARD ARDUINO WORKFLOW +# +# Given a normal sketch directory, all you need to do is to create +# a small Makefile which defines a few things, and then includes this one. +# +# For example: +# +# ARDUINO_LIBS = Ethernet Ethernet/utility SPI +# BOARD_TAG = uno +# ARDUINO_PORT = /dev/cu.usb* +# +# include /usr/local/share/Arduino.mk +# +# Hopefully these will be self-explanatory but in case they're not: +# +# ARDUINO_LIBS - A list of any libraries used by the sketch (we +# assume these are in +# $(ARDUINO_DIR)/hardware/libraries +# +# ARDUINO_PORT - The port where the Arduino can be found (only needed +# when uploading +# +# BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega +# 'make show_boards' shows a list +# +# Once this file has been created the typical workflow is just +# +# $ make upload +# +# All of the object files are created in the build-cli subdirectory +# All sources should be in the current directory and can include: +# - at most one .pde or .ino file which will be treated as C++ after +# the standard Arduino header and footer have been affixed. +# - any number of .c, .cpp, .s and .h files +# +# Included libraries are built in the build-cli/libs subdirectory. +# +# Besides make upload you can also +# make - no upload +# make clean - remove all our dependencies +# make depends - update dependencies +# make reset - reset the Arduino by tickling DTR on the serial port +# make raw_upload - upload without first resetting +# make show_boards - list all the boards defined in boards.txt +# make monitor - connect to the Arduino's serial port +# +######################################################################## +# +# SERIAL MONITOR +# +# The serial monitor just invokes the GNU screen program with suitable +# options. For more information see screen (1) and search for +# 'character special device'. +# +# The really useful thing to know is that ^A-k gets you out! +# +# The fairly useful thing to know is that you can bind another key to +# escape too, by creating $HOME{.screenrc} containing e.g. +# +# bindkey ^C kill +# +# If you want to change the baudrate, just set MONITOR_BAUDRATE. If you +# don't set it, it defaults to 9600 baud. +# +######################################################################## +# +# PATHS +# +# I've reworked the way paths to executables are constructed in this +# version of Makefile. +# +# We need to worry about three different sorts of file: +# +# 1. Things which are included in this distribution e.g. ard-parse-boards +# => ARDMK_DIR +# +# 2. Things which are always in the Arduino distribution e.g. +# boards.txt, libraries, &c. +# => ARDUINO_DIR +# +# 3. Things which might be bundled with the Arduino distribution, but +# might come from the system. Most of the toolchain is like this: +# on Linux it's supplied by the system. +# => AVR_TOOLS_DIR +# +# Having set these three variables, we can work out the rest assuming +# that things are canonically arranged beneath the directories defined +# above. +# +# So, on the Mac you might want to set: +# +# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java +# ARDMK_DIR = /usr/local +# +# On Linux, you might prefer: +# +# ARDUINO_DIR = /usr/share/arduino +# ARDMK_DIR = /usr/local +# AVR_TOOLS_DIR = /usr +# +# +# +# +######################################################################## +# +# ARDUINO WITH ISP +# +# You need to specify some details of your ISP programmer and might +# also need to specify the fuse values: +# +# ISP_PROG = -c stk500v2 +# ISP_PORT = /dev/ttyACM0 +# +# You might also need to set the fuse bits, but typically they'll be +# read from boards.txt, based on the BOARD_TAG variable: +# +# ISP_LOCK_FUSE_PRE = 0x3f +# ISP_LOCK_FUSE_POST = 0xcf +# ISP_HIGH_FUSE = 0xdf +# ISP_LOW_FUSE = 0xff +# ISP_EXT_FUSE = 0x01 +# +# I think the fuses here are fine for uploading to the ATmega168 +# without bootloader. +# +# To actually do this upload use the ispload target: +# +# make ispload +# +# +######################################################################## + +######################################################################## +# +# Default TARGET to cwd (ex Daniele Vergini) +ifndef TARGET +TARGET = $(notdir $(CURDIR)) +endif + +######################################################################## + +# +# Arduino version number +ifndef ARDUINO_VERSION +ARDUINO_VERSION = 100 +endif + +######################################################################## +# Arduino and system paths +# +ifdef ARDUINO_DIR + +ifndef AVR_TOOLS_DIR +AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr +# The avrdude bundled with Arduino can't find its config +ifndef AVRDUDE_CONF +AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf +endif +endif + +ifndef AVR_TOOLS_PATH +AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin +endif + +ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries +ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino +ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants + +else + +echo $(error "ARDUINO_DIR is not defined") + +endif + +######################################################################## +# Makefile distribution path +# +ifdef ARDMK_DIR + +ifndef ARDMK_PATH +ARDMK_PATH = $(ARDMK_DIR)/bin +endif + +else + +echo $(error "ARDMK_DIR is not defined") + +endif + +######################################################################## +# Miscellanea +# +ifndef ARDUINO_SKETCHBOOK +ARDUINO_SKETCHBOOK = $(HOME)/sketchbook +endif + +ifndef USER_LIB_PATH +USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries +endif + +######################################################################## +# Serial monitor (just a screen wrapper) +# +# Quite how to construct the monitor command seems intimately tied +# to the command we're using (here screen). So, read the screen docs +# for more information (search for 'character special device'). +# +ifndef MONITOR_BAUDRATE +MONITOR_BAUDRATE = 9600 +endif + +ifndef MONITOR_CMD +MONITOR_CMD = screen +endif + +######################################################################## +# Reset +ifndef RESET_CMD +RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) +endif + +######################################################################## +# boards.txt parsing +# +ifndef BOARD_TAG +BOARD_TAG = uno +endif + +ifndef BOARDS_TXT +BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt +endif + +ifndef PARSE_BOARD +PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards +endif + +ifndef PARSE_BOARD_OPTS +PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT) +endif + +ifndef PARSE_BOARD_CMD +PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS) +endif + +# Which variant ? This affects the include path +ifndef VARIANT +VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant) +endif + +# processor stuff +ifndef MCU +MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu) +endif + +ifndef F_CPU +F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) +endif + +# USB IDs for the Leonardo +ifndef USB_VID +USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid) +endif + +ifndef USB_PID +USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid) +endif + +# normal programming info +ifndef AVRDUDE_ARD_PROGRAMMER +AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) +endif + +ifndef AVRDUDE_ARD_BAUDRATE +AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed) +endif + +# fuses if you're using e.g. ISP +ifndef ISP_LOCK_FUSE_PRE +ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits) +endif + +ifndef ISP_LOCK_FUSE_POST +ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits) +endif + +ifndef ISP_HIGH_FUSE +ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses) +endif + +ifndef ISP_LOW_FUSE +ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses) +endif + +ifndef ISP_EXT_FUSE +ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses) +endif + +# Everything gets built in here (include BOARD_TAG now) +ifndef OBJDIR +OBJDIR = build-$(BOARD_TAG) +endif + +######################################################################## +# Local sources +# +LOCAL_C_SRCS = $(wildcard *.c) +LOCAL_CPP_SRCS = $(wildcard *.cpp) +LOCAL_CC_SRCS = $(wildcard *.cc) +LOCAL_PDE_SRCS = $(wildcard *.pde) +LOCAL_INO_SRCS = $(wildcard *.ino) +LOCAL_AS_SRCS = $(wildcard *.S) +LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \ + $(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \ + $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) +LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) + +# Dependency files +DEPS = $(LOCAL_OBJS:.o=.d) + +# core sources +ifeq ($(strip $(NO_CORE)),) +ifdef ARDUINO_CORE_PATH +CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) +CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) + +ifneq ($(strip $(NO_CORE_MAIN_CPP)),) +CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) +endif + +CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) +CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ + $(OBJDIR)/%,$(CORE_OBJ_FILES)) +endif +endif + + +######################################################################## +# Rules for making stuff +# + +# The name of the main targets +TARGET_HEX = $(OBJDIR)/$(TARGET).hex +TARGET_ELF = $(OBJDIR)/$(TARGET).elf +TARGETS = $(OBJDIR)/$(TARGET).* +CORE_LIB = $(OBJDIR)/libcore.a + +# A list of dependencies +DEP_FILE = $(OBJDIR)/depends.mk + +# Names of executables +CC = $(AVR_TOOLS_PATH)/avr-gcc +CXX = $(AVR_TOOLS_PATH)/avr-g++ +OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy +OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump +AR = $(AVR_TOOLS_PATH)/avr-ar +SIZE = $(AVR_TOOLS_PATH)/avr-size +NM = $(AVR_TOOLS_PATH)/avr-nm +REMOVE = rm -f +MV = mv -f +CAT = cat +ECHO = echo + +# General arguments +SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)) +USER_LIBS = $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)) +SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) +USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) +LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS))) +LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS))) +USER_LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(USER_LIBS))) +USER_LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(USER_LIBS))) +LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \ + $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) +USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(USER_LIB_CPP_SRCS)) \ + $(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(USER_LIB_C_SRCS)) + +CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ + -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ + $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ + -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) \ + -ffunction-sections -fdata-sections + +CFLAGS = -std=gnu99 +CXXFLAGS = -fno-exceptions +ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp +LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os + +# Expand and pick the first port +ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) + +# Implicit rules for building everything (needed to get everything in +# the right directory) +# +# Rather than mess around with VPATH there are quasi-duplicate rules +# here for building e.g. a system C++ file and a local C++ +# file. Besides making things simpler now, this would also make it +# easy to change the build options in future + +# library sources +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c + mkdir -p $(dir $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +# normal local sources +# .o rules are for objects, .d for dependency tracking +# there seems to be an awful lot of duplication here!!! +$(OBJDIR)/%.o: %.c + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.cc + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.cpp + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.S + $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ + +$(OBJDIR)/%.o: %.s + $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ + +$(OBJDIR)/%.d: %.c + $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.cc + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.cpp + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.S + $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) + +$(OBJDIR)/%.d: %.s + $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) + +# the pde -> cpp -> o file +$(OBJDIR)/%.cpp: %.pde + $(ECHO) '#include "WProgram.h"' > $@ + $(CAT) $< >> $@ + +# the ino -> cpp -> o file +$(OBJDIR)/%.cpp: %.ino + $(ECHO) '#include ' > $@ + $(CAT) $< >> $@ + +$(OBJDIR)/%.o: $(OBJDIR)/%.cpp + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +$(OBJDIR)/%.d: $(OBJDIR)/%.cpp + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + +# core files +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +# various object conversions +$(OBJDIR)/%.hex: $(OBJDIR)/%.elf + $(OBJCOPY) -O ihex -R .eeprom $< $@ + +$(OBJDIR)/%.eep: $(OBJDIR)/%.elf + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O ihex $< $@ + +$(OBJDIR)/%.lss: $(OBJDIR)/%.elf + $(OBJDUMP) -h -S $< > $@ + +$(OBJDIR)/%.sym: $(OBJDIR)/%.elf + $(NM) -n $< > $@ + +######################################################################## +# +# Avrdude +# +ifndef AVRDUDE +AVRDUDE = $(AVR_TOOLS_PATH)/avrdude +endif + +AVRDUDE_COM_OPTS = -q -V -p $(MCU) +ifdef AVRDUDE_CONF +AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) +endif + +AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT) + +ifndef ISP_PROG +ISP_PROG = -c stk500v2 +endif + +AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) + + +######################################################################## +# +# Explicit targets start here +# + +all: $(OBJDIR) $(TARGET_HEX) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) + $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm + +$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) + $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) + +$(DEP_FILE): $(OBJDIR) $(DEPS) + cat $(DEPS) > $(DEP_FILE) + +upload: reset raw_upload + +raw_upload: $(TARGET_HEX) + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ + -U flash:w:$(TARGET_HEX):i + +reset: + $(RESET_CMD) $(ARD_PORT) + +# stty on MacOS likes -F, but on Debian it likes -f redirecting +# stdin/out appears to work but generates a spurious error on MacOS at +# least. Perhaps it would be better to just do it in perl ? +reset_stty: + for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ + do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \ + done ;\ + $$STTYF $(ARD_PORT) hupcl ;\ + (sleep 0.1 || sleep 1) ;\ + $$STTYF $(ARD_PORT) -hupcl + +ispload: $(TARGET_HEX) + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ + -U lock:w:$(ISP_LOCK_FUSE_PRE):m \ + -U hfuse:w:$(ISP_HIGH_FUSE):m \ + -U lfuse:w:$(ISP_LOW_FUSE):m \ + -U efuse:w:$(ISP_EXT_FUSE):m + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \ + -U flash:w:$(TARGET_HEX):i + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \ + -U lock:w:$(ISP_LOCK_FUSE_POST):m + +clean: + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) + +depends: $(DEPS) + cat $(DEPS) > $(DEP_FILE) + +size: $(OBJDIR) $(TARGET_ELF) + $(SIZE) -C --mcu=$(MCU) $(TARGET_ELF) + +show_boards: + $(PARSE_BOARD_CMD) --boards + +monitor: + $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) + +.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor + +include $(DEP_FILE) diff --git a/datasources/arduino/arduinoAnalogStomp/Makefile b/datasources/arduino/arduinoAnalogStomp/Makefile new file mode 100755 index 0000000..e273ddf --- /dev/null +++ b/datasources/arduino/arduinoAnalogStomp/Makefile @@ -0,0 +1,9 @@ +ARDUINO_DIR= /usr/share/arduino +ARDMK_DIR= . +AVR_TOOLS_DIR = /usr + +BOARD_TAG = uno +ARDUINO_PORT = /dev/cu.usb* +ARDUINO_LIBS = Ethernet Ethernet/utility SPI + +include Arduino.mk diff --git a/datasources/arduino/arduinoAnalogStomp/analogethernet.ino b/datasources/arduino/arduinoAnalogStomp/analogethernet.ino new file mode 100755 index 0000000..09ee42b --- /dev/null +++ b/datasources/arduino/arduinoAnalogStomp/analogethernet.ino @@ -0,0 +1,205 @@ +// vim: filetype=cpp +#include +#include + +byte mac[] = { 0xAD, 0xEE, 0x00, 0xEF, 0xFE, 0xED }; +const char *serverHost = "stomp.xapek.org"; +const int serverPort = 61613; +const char *serverLogin = "arduino1"; +const char *serverPasscode = "arduino1"; +const char *serverQueue = "/queue/queue-put"; + +const int ledPin = 13; // select the pin for the LED + +struct StompHeader { + const char *name; + const char *value; +}; + +class StompClient; // Forward + +struct StompFrame { + const char *command; + struct StompHeader *headers = 0; + int headersPos = -1; + const char *body = 0; + void (*bodyFunc)(class StompClient&) = NULL; + void addHeader(const char *name, const char *value) { + headersPos++; + headers = (StompHeader*)realloc(headers, sizeof(StompHeader) * (headersPos+1)); + memset(headers + headersPos, 0, sizeof(StompHeader)); + (headers+(sizeof(StompHeader)*headersPos))->name = name; + (headers+(sizeof(StompHeader)*headersPos))->value = value; + } + void setBody(const char *b) { + body = strdup(b); + } + StompFrame(const char *command) : command(strdup(command)) {}; + ~StompFrame() { + if (headers != NULL) + delete headers; + delete command; + if (body) + delete body; + } +}; + +class StompClient : public EthernetClient { + const char *serverHost; + int serverPort; + const char *serverLogin = NULL; + const char *serverPasscode = NULL; +public: + StompClient(const char *serverHost, int serverPort, const char *serverLogin, const char *serverPasscode) : + serverHost(serverHost), serverPort(serverPort), serverLogin(serverLogin), serverPasscode(serverPasscode) {}; + int connect() { + int result = EthernetClient::connect(serverHost, serverPort); + if (result) { + StompFrame frame("CONNECT"); + frame.addHeader("host", serverHost); + if (serverLogin) frame.addHeader("login", serverLogin); + if (serverPasscode) frame.addHeader("passcode", serverPasscode); + + send(frame); + + StompFrame *answer = readFrame(); + if (strcmp(answer->command, "CONNECTED") != 0) { + Serial.print("Got no CONNECTED Frame, read: "); + Serial.println(answer->command); + stop(); + delete answer; + return false; + } else { + delete answer; + return true; + } + } else { + return result; + } + }; + void send(StompFrame &frame) { + EthernetClient::print(frame.command); + EthernetClient::print("\n"); + for (int i = 0; i<=frame.headersPos; i++) { + StompHeader *header = frame.headers+sizeof(StompHeader)*i; + EthernetClient::print(header->name); + EthernetClient::print(":"); + EthernetClient::print(header->value); + EthernetClient::print("\n"); + } + EthernetClient::print("\n"); + if (frame.bodyFunc) { + frame.bodyFunc(*this); + } if (frame.body) { + EthernetClient::print(frame.body); + } + EthernetClient::write((byte)0); + }; + + void sendKeyValue(const char *key, const char *value) { + EthernetClient::print(key); + EthernetClient::print("="); + EthernetClient::print(value); + EthernetClient::print("\n"); + } + StompFrame *readFrame() { + char buf[255]; + int i = readBytesUntil('\n', buf, 254); + buf[i] = '\0'; + StompFrame *frame = new StompFrame(buf); + + while (readBytesUntil('\n', buf, 255)) { + //read header + //ignore + } + readBytesUntil('\0', buf, 255); + frame->setBody(buf); + + flush(); + return frame; + } +}; + + + + + +const long ADC_REF_MV = 3300; +const long ADC_MAX_STEP = 1024; +const long OV_FACTOR = 4; // Op. Verstärker Faktor = 4; 10mV = 1dB + +void sendPinValue(class StompClient& c) { + long sensorValue, + sensorValueMV, + sensorValueDBA, + pinnr; + char buf[12]; + char *sensorKey = "arduino.aX", + *sensorKeyMV = "arduino.aX.mv", + *sensorKeyDBA = "arduino.aX.dba"; + for (int i = A0; i <= A5; i++) { + pinnr = i - A0; + + sensorValue = analogRead(i); + sensorKey[9] = '0' + pinnr; + snprintf(buf, 8, "%u", sensorValue); + c.sendKeyValue(sensorKey, buf); + + sensorValueMV = sensorValue * (ADC_REF_MV*100/ADC_MAX_STEP); + sensorKeyMV[9] = '0' + pinnr; + snprintf(buf, 8, "%ld.%03ld", sensorValueMV/100, sensorValue%100); + c.sendKeyValue(sensorKeyMV, buf); + + sensorValueDBA = sensorValueMV / OV_FACTOR; + sensorKeyDBA[9] = '0' + pinnr; + snprintf(buf, 12, "%ld.%04ld", sensorValueDBA/1000, sensorValueDBA%1000); + c.sendKeyValue(sensorKeyDBA, buf); + } +} + + +void setup() { + Serial.begin(9600); + + // declare the ledPin as an OUTPUT: + pinMode(ledPin, OUTPUT); + + // start the Ethernet and UDP: Use DHCP for IP-Configuration + Ethernet.begin(mac); + + analogReference(EXTERNAL); +} + + + +StompClient client(serverHost, serverPort, serverLogin, serverPasscode); + +void loop() { + unsigned long dt = millis(); + + digitalWrite(ledPin, HIGH); + if (client.connected()) { + Serial.println("Send packet"); + StompFrame frame("SEND"); + frame.addHeader("destination", serverQueue); + frame.bodyFunc = &sendPinValue; + client.send(frame); + } else { + Serial.println("connecting"); + client.stop(); + if (client.connect()) { + Serial.println("connected"); + } else { + Serial.println("connection failed"); + } + } + digitalWrite(ledPin, LOW); + + dt = (millis() - dt); + + if (dt < 500) { + Serial.println(String("sleep: ") + String((500-dt))); + delay(500 - dt); + } +} + diff --git a/datasources/arduino/arduinoAnalogStomp/bin/ard-parse-boards b/datasources/arduino/arduinoAnalogStomp/bin/ard-parse-boards new file mode 100755 index 0000000..e2de71b --- /dev/null +++ b/datasources/arduino/arduinoAnalogStomp/bin/ard-parse-boards @@ -0,0 +1,261 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +use Getopt::Long; +use Pod::Usage; +use YAML; + +my %Opt = + ( + boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', + ); + +GetOptions(\%Opt, + "boards_txt=s", # filename of the boards.txt file + "find!", # search for data + "dump!", # dump the whole database + "boards!", # dump a list of boards + "help!", + "info!", + ); + +if ($Opt{help} || $Opt{info}) + { + usage(); + } + +my $db = parse_boards($Opt{boards_txt}); + +if ($Opt{dump}) + { + dump_data("$Opt{boards_txt} contains:", $db); + } +elsif ($Opt{find}) + { + my @terms = @ARGV or usage(); + find_data($db, \@terms); + } +elsif ($Opt{boards}) + { + dump_boards($db); + } +else + { + my $tag = shift @ARGV or usage(); + + if (my $key = shift @ARGV) + { + die "$key isn't defined for the $tag board, " + unless $db->{$tag} && exists $db->{$tag}->{$key}; + + print $db->{$tag}->{$key}, "\n"; + } + else + { + die "The $tag board isn't defined, " + unless $db->{$tag}; + + dump_data("The $tag board:", $db->{$tag}); + } + } + +## here endeth the main + +sub usage + { + pod2usage(-verbose => 2); + } + +# return HoH: {board}->{field} = value +sub parse_boards + { + my $filename = shift; + + my %b; + + open(my $fh, '<', $filename) + or die "Can't open $filename, "; + + while(<$fh>) + { + my ($board, $key, $value) = /^\s*(\S+?)\.(\S+?)\s*=\s*(.+?)\s*$/ + or next; + + $b{$board}->{$key} = $value; + } + + return \%b; + } + +# A rudimentary search engine +sub find_data + { + my ($db, $term_list) = @_; + + my @q = map { qr/$_/i } @$term_list; + my $q = join(' && ', map { "/$_/i" } @$term_list); + + my %hit; + foreach my $b (keys %$db) + { + foreach my $k (keys %{$db->{$b}}) + { + my $v = $db->{$b}->{$k}; + $hit{$b}->{$k} = $v if !grep { $v !~ /$_/i } @q; + } + } + + dump_data("Matches for $q:", \%hit); + } + +# The list of boards... +sub dump_boards + { + my $db = shift or return; + + my %name; + my $max_l = 0; + foreach my $b (keys %$db) + { + $name{$b} = $db->{$b}->{name} || 'Anonymous'; + $max_l = length($b) if $max_l < length($b); + } + + my $fmt = sprintf("%%-%ds %%s\n", $max_l + 2); + + printf $fmt, "Tag", "Board Name"; + foreach my $b (sort keys %name) + { + printf $fmt, $b, $name{$b}; + } + } + + +# dump arbitrary data with a title +sub dump_data + { + my ($title, $data) = @_; + + print "# $title\n", Dump($data); + } + +__END__ + +=head1 NAME + +ard-parse-boards - Read data from the Arduino boards.txt file + +=head1 USAGE + + Dump all the data in the file: + $ ard-parse-boards --dump + + See which boards we know about: + $ ard-parse-boards --boards + + Look for a particular board... + $ ard-parse-boards --find uno + + ...multiple terms are implicitly ANDed: + $ ard-parse-boards --find duemil 328 + + Dump all the data for a particular board: + $ ard-parse-boards atmega328 + + Extract a particular field: + $ ard-parse-boards atmega328 build.f_cpu + +=head1 DESCRIPTION + +The Arduino software package ships with a boards.txt file which tells +the Arduino IDE details about particular hardware. So when the user +says he's got a shiny new Arduino Uno, boards.txt knows that it has a +16MHz ATmega328 on it. It would be nice to access these data from the +command line too. + +In normal operation you simply specify the tag given to the board in +the boards.txt file, and optionally a field name. This program then +extracts the data to STDOUT. + +Most boards have names which are quite unwieldy, so we always refer to +a board by a tag, not its name. Strictly the tag is the bit before the +first dot in the boards.txt key. You can see a list of board tags and +names with the C<--boards> option. + +=head1 OPTIONS + +=over + +=item --boards_txt=[file] + +Specify the full path to the boards.txt file. + +=back + +The following options all disable the normal 'lookup' operation. + +=over + +=item --dump + +Dump the complete database in YAML format. + +=item ---boards + +Print a list of the tag and name of every board in the file. + +=item --find [query] ... + +Find matching data. Strictly, return a list of values which match all +of the query terms, treating each term as a case-insensitive regexp. + +For example: + +=over + +=item --find 328 + +List data containing 328 (anywhere in the value). + +=item --find due + +List data containing 'due' (e.g. duemilanove). + +=item --find 328 due + +List data containing both 328 and due. + +=back + +=back + +=head1 BUGS AND LIMITATIONS + +There are no known bugs in this application. + +Please report problems to the author. + +Patches are welcome. + +=head1 AUTHOR + +Martin Oldfield, ex-atelier@mjo.tc + +Thanks to Mark Sproul who suggested doing something like this to me ages ago. + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2011, Martin Oldfield. All rights reserved. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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. + + diff --git a/datasources/arduino/arduinoAnalogStomp/bin/ard-reset-arduino b/datasources/arduino/arduinoAnalogStomp/bin/ard-reset-arduino new file mode 100755 index 0000000..22c7109 --- /dev/null +++ b/datasources/arduino/arduinoAnalogStomp/bin/ard-reset-arduino @@ -0,0 +1,115 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +use Device::SerialPort; +use Getopt::Long; +use Pod::Usage; + +my %Opt = + ( + period => 0.1, + ); + +GetOptions(\%Opt, + "period=f", # width of reset pulse in seconds + "verbose!", + "help!", + "info!", + ); + +if ($Opt{help} || $Opt{info}) + { + usage(); + } + +die "No Arduinos found!\n" + unless @ARGV; + +foreach my $dev (@ARGV) + { + my $p = Device::SerialPort->new($dev) + or die "Unable to open $dev: $!\n"; + + my $dt = $Opt{period}; + + print STDERR "Setting DTR high for ${dt}s on $dev\n" + if $Opt{verbose}; + + die "Invalid pulse width ($dt), " + unless $dt > 0.0; + + $p->pulse_dtr_on($dt * 1000.0); + } + +## here endeth the main + +sub usage + { + pod2usage(-verbose => 2); + } + +__END__ + +=head1 NAME + +ard-reset-arduino - Reset an Arduino + +=head1 USAGE + + $ ard-reset-arduino /dev/cu.usb* + + $ ard-reset-arduino --verbose --period=0.1 /dev/cu.usb* + +=head1 DESCRIPTION + +To reset (most) Arduinos, it's enough to just pulse the DTR line. + +You can do that from the shell with stty, but there's an interesting +diversity of command flags. This little program gives a uniform interface +at the cost of requiring C. + +=head1 OPTIONS + +=over + +=item --verbose + +Watch what's going on on STDERR. + +=item --period=0.25 + +Specify the DTR pulse width in seconds. + +=back + +=head1 BUGS AND LIMITATIONS + +There are no known bugs in this application. + +Please report problems to the author. + +Patches are welcome. + +=head1 AUTHOR + +Martin Oldfield, ex-atelier@mjo.tc + +Thanks to Daniele Vergini who suggested this to me, and supplied +a command line version. + +=head1 LICENCE AND COPYRIGHT + +Copyright (c) 2012, Martin Oldfield. All rights reserved. + +This file is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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. + + diff --git a/datasources/arduino/schaltung/Untitled Sketch.fzz b/datasources/arduino/schaltung/Untitled Sketch.fzz new file mode 100644 index 0000000..a324e62 Binary files /dev/null and b/datasources/arduino/schaltung/Untitled Sketch.fzz differ diff --git a/datasources/arduino/schaltung/Untitled Sketch_Leiterplatte.pdf b/datasources/arduino/schaltung/Untitled Sketch_Leiterplatte.pdf new file mode 100644 index 0000000..013da3c Binary files /dev/null and b/datasources/arduino/schaltung/Untitled Sketch_Leiterplatte.pdf differ diff --git a/datasources/arduino/schaltung/Untitled Sketch_Schaltplan.pdf b/datasources/arduino/schaltung/Untitled Sketch_Schaltplan.pdf new file mode 100644 index 0000000..f504844 Binary files /dev/null and b/datasources/arduino/schaltung/Untitled Sketch_Schaltplan.pdf differ diff --git a/datasources/arduino/schaltung/Untitled Sketch_Steckplatine.pdf b/datasources/arduino/schaltung/Untitled Sketch_Steckplatine.pdf new file mode 100644 index 0000000..2b974da Binary files /dev/null and b/datasources/arduino/schaltung/Untitled Sketch_Steckplatine.pdf differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom.pdf" new file mode 100644 index 0000000..b3fb204 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom_mirror.pdf" new file mode 100644 index 0000000..9e43de3 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_bottom_mirror.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top.pdf" new file mode 100644 index 0000000..9ab5881 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top_mirror.pdf" new file mode 100644 index 0000000..09bccb5 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_copper_top_mirror.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom.pdf" new file mode 100644 index 0000000..11329ce Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom_mirror.pdf" new file mode 100644 index 0000000..02a92f3 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_bottom_mirror.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top.pdf" new file mode 100644 index 0000000..11329ce Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top_mirror.pdf" new file mode 100644 index 0000000..02a92f3 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_mask_top_mirror.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom.pdf" new file mode 100644 index 0000000..479b7f1 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom_mirror.pdf" new file mode 100644 index 0000000..479b7f1 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_bottom_mirror.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top.pdf" new file mode 100644 index 0000000..479b7f1 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top_mirror.pdf" new file mode 100644 index 0000000..479b7f1 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_paste_mask_top_mirror.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top.pdf" new file mode 100644 index 0000000..e4f9090 Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top.pdf" differ diff --git "a/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top_mirror.pdf" "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top_mirror.pdf" new file mode 100644 index 0000000..e9558ba Binary files /dev/null and "b/datasources/arduino/schaltung/\303\244tzen/Untitled Sketch_etch_silk_top_mirror.pdf" differ -- cgit v1.2.1