From d8ced7ba2fc2a990ccb5f3a4bf611c068311a0ac Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Thu, 13 Sep 2012 11:41:46 -0700 Subject: [PATCH 001/344] Initial commit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5880d4 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Nanpy +===== + +Program your Arduino prototypes using Python \ No newline at end of file From d269555b05a96c42a5d8eb1fa57a8c301bd9b6a8 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 14 Sep 2012 14:24:34 +0200 Subject: [PATCH 002/344] Initial import of what I've done this summer. Really unstable stuff --- .gitignore | 11 + LICENSE | 21 ++ Makefile | 373 +++++++++++++++++++++++++ README.md | 26 +- buildfirmware.sh | 5 + examples/clock.py | 0 examples/helloworld.py | 0 examples/lcdanimation.py | 0 examples/temperature.py | 0 firmware/.dep/MethodDescriptor.cpp.dep | 5 + firmware/.dep/Nanpy.ino.dep | 48 ++++ firmware/.dep/PyLiquidCrystal.cpp.dep | 42 +++ firmware/.dep/PyOneWire.cpp.dep | 40 +++ firmware/.dep/Utilities.cpp.dep | 21 ++ firmware/MethodDescriptor.cpp | 62 ++++ firmware/MethodDescriptor.h | 28 ++ firmware/Nanpy.ino | 92 ++++++ firmware/PyLiquidCrystal.cpp | 34 +++ firmware/PyLiquidCrystal.h | 29 ++ firmware/PyOneWire.cpp | 80 ++++++ firmware/PyOneWire.h | 32 +++ firmware/Utilities.cpp | 21 ++ firmware/Utilities.h | 7 + firmware/Vector.h | 83 ++++++ nanpy/Arduino.py | 28 ++ nanpy/ArduinoObject.py | 50 ++++ nanpy/DallasTemperature.py | 71 +++++ nanpy/IdGenerator.py | 9 + nanpy/Lcd.py | 15 + nanpy/OneWire.py | 48 ++++ nanpy/SerialManager.py | 16 ++ nanpy/Singleton.py | 13 + nanpy/__init__.py | 3 + test.py | 24 ++ 34 files changed, 1336 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100755 buildfirmware.sh create mode 100644 examples/clock.py create mode 100644 examples/helloworld.py create mode 100644 examples/lcdanimation.py create mode 100644 examples/temperature.py create mode 100644 firmware/.dep/MethodDescriptor.cpp.dep create mode 100644 firmware/.dep/Nanpy.ino.dep create mode 100644 firmware/.dep/PyLiquidCrystal.cpp.dep create mode 100644 firmware/.dep/PyOneWire.cpp.dep create mode 100644 firmware/.dep/Utilities.cpp.dep create mode 100644 firmware/MethodDescriptor.cpp create mode 100644 firmware/MethodDescriptor.h create mode 100644 firmware/Nanpy.ino create mode 100644 firmware/PyLiquidCrystal.cpp create mode 100644 firmware/PyLiquidCrystal.h create mode 100644 firmware/PyOneWire.cpp create mode 100644 firmware/PyOneWire.h create mode 100644 firmware/Utilities.cpp create mode 100644 firmware/Utilities.h create mode 100644 firmware/Vector.h create mode 100644 nanpy/Arduino.py create mode 100644 nanpy/ArduinoObject.py create mode 100644 nanpy/DallasTemperature.py create mode 100644 nanpy/IdGenerator.py create mode 100644 nanpy/Lcd.py create mode 100644 nanpy/OneWire.py create mode 100644 nanpy/SerialManager.py create mode 100644 nanpy/Singleton.py create mode 100644 nanpy/__init__.py create mode 100644 test.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f242b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +#General +*~ + +#Arduino +*.o +*.hex +*/.deb +*/.lib +#Python +*.pyc + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4182601 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2012 Octan (https://github.com/Octan) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..050a9d7 --- /dev/null +++ b/Makefile @@ -0,0 +1,373 @@ +#_______________________________________________________________________________ +# +# edam's Arduino makefile +#_______________________________________________________________________________ +# version 0.3 +# +# Copyright (C) 2011, 1012 Tim Marston . +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +#_______________________________________________________________________________ +# +# +# This is a general purpose makefile for use with Arduino hardware and +# software. It works with the arduino-1.0 software release. To download the +# latest version of this makefile, visit the following website, where you can +# also find more information and documentation on it's use. The following text +# can only really be considered a reference to it's use. +# +# http://ed.am/dev/make/arduino-mk +# +# This makefile can be used as a drop-in replacement for the Arduino IDE's +# build system. To use it, save arduino.mk somewhere (I keep mine at +# ~/src/arduino.mk) and create a symlink to it in your project directory named +# "Makefile". For example: +# +# $ ln -s ~/src/arduino.mk Makefile +# +# The Arduino software (version 1.0 or later) is required. If you are using +# Debian (or a derivative), type `apt-get install arduino`. Otherwise, you +# will have to download the Arduino software manually from http://arduino.cc/. +# It is suggested that you install it at ~/opt/arduino if you are unsure. +# +# If you downloaded the Arduino software manually and unpacked it somewhere +# other than ~/opt/arduino, you will need to set up ARDUINODIR to be the path +# where you unpacked it. (If unset, ARDUINODIR defaults to ~/opt/arduino and +# then /usr/share/arduino, in that order.) You might be best to set this in +# your ~/.profile by adding something like this: +# +# export ARDUINODIR=~/somewhere/arduino-1.0 +# +# You will also need to set BOARD to the type of Arduino you're building for. +# Type `make boards` for a list of acceptable values. You could set a default +# in your ~/.profile if you want, but it is suggested that you specify this at +# build time, especially if you work with different types of Arduino. For +# example: +# +# $ export BOARD=uno +# $ make +# +# You may also need to set SERIALDEV if it is not detected correctly. +# +# The presence of a .ino (or .pde) file causes the arduino.mk to automatically +# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp +# files in the project directory (or any "util" or "utility" subdirectories) +# are automatically included in the build and are scanned for Arduino libraries +# that have been #included. Note, there can only be one .ino (or .pde) file. +# +# Alternatively, if you want to manually specify build variables, create a +# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. +# (There is no need to define TARGET). Here is an example Makefile: +# +# SOURCES := main.cc other.cc +# LIBRARIES := EEPROM +# include ~/src/arduino.mk +# +# Here is a complete list of configuration parameters: +# +# ARDUINODIR The path where the Arduino software is installed on your system. +# +# ARDUINOCONST The Arduino software version, as an integer, used to define the +# ARDUINO version constant. This defaults to 100 if undefined. +# +# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess +# based on where the avrdude in use is. If empty, no avrdude.conf +# is passed to avrdude (to the system default is used). +# +# AVRTOOLSPATH A space-separated list of directories to search in order when +# looking for the avr build tools. This defaults to the system PATH +# followed by subdirectories in ARDUINODIR if undefined. +# +# BOARD Specify a target board type. Run `make boards` to see available +# board types. +# +# LIBRARIES A list of Arduino libraries to build and include. This is set +# automatically if a .ino (or .pde) is found. +# +# SERIALDEV The unix device name of the serial device that is the Arduino. +# If unspecified, an attempt is made to determine the name of a +# connected Arduino's serial device. +# +# SOURCES A list of all source files of whatever language. The language +# type is determined by the file extension. This is set +# automatically if a .ino (or .pde) is found. +# +# TARGET The name of the target file. This is set automatically if a +# .ino (or .pde) is found, but it is not necessary to set it +# otherwise. +# +# This makefile also defines the following goals for use on the command line +# when you run make: +# +# all This is the default if no goal is specified. It builds the +# target. +# +# target Builds the target. +# +# upload Uploads the last built target to an attached Arduino. +# +# clean Deletes files created during the build. +# +# boards Display a list of available board names, so that you can set the +# BOARD environment variable appropriately. +# +# monitor Start `screen` on the serial device. This is meant to be an +# equivalent to the Arduino serial monitor. +# +# size Displays size information about the bulit target. +# +# Builds the specified file, either an object file or the target, +# from those that that would be built for the project. +#_______________________________________________________________________________ +# + +# default arduino software directory, check software exists +ifndef ARDUINODIR +ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino)) +endif +ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" +$(error ARDUINODIR is not set correctly; arduino software not found) +endif + +# default arduino version +ARDUINOCONST ?= 100 + +# default path for avr tools +ifndef AVRTOOLSPATH +AVRTOOLSPATH := $(subst :, , $(PATH)) +AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools +AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools/avr/bin +endif + +# auto mode? +INOFILE := $(wildcard *.ino *.pde) +ifdef INOFILE +ifneq "$(words $(INOFILE))" "1" +$(error There is more than one .pde or .ino file in this directory!) +endif + +# automatically determine sources and targeet +TARGET := $(basename $(INOFILE)) +SOURCES := $(INOFILE) \ + $(wildcard *.c *.cc *.cpp) \ + $(wildcard $(addprefix util/, *.c *.cc *.cpp)) \ + $(wildcard $(addprefix utility/, *.c *.cc *.cpp)) + +# automatically determine included libraries +LIBRARIES := $(filter $(notdir $(wildcard $(ARDUINODIR)/libraries/*)), \ + $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) + +endif + +# no serial device? make a poor attempt to detect an arduino +SERIALDEVGUESS := 0 +ifeq "$(SERIALDEV)" "" +SERIALDEV := $(firstword $(wildcard \ + /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) +SERIALDEVGUESS := 1 +endif + +# software +findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) +CC := $(call findsoftware,avr-gcc) +CXX := $(call findsoftware,avr-g++) +LD := $(call findsoftware,avr-ld) +AR := $(call findsoftware,avr-ar) +OBJCOPY := $(call findsoftware,avr-objcopy) +AVRDUDE := $(call findsoftware,avrdude) +AVRSIZE := $(call findsoftware,avr-size) + +# files +TARGET := $(if $(TARGET),$(TARGET),a.out) +OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) +DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) +ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino +ARDUINOLIB := .lib/arduino.a +ARDUINOLIBLIBSDIR := $(ARDUINODIR)/libraries +ARDUINOLIBLIBSPATH := $(foreach lib, $(LIBRARIES), \ + $(ARDUINODIR)/libraries/$(lib)/ $(ARDUINODIR)/libraries/$(lib)/utility/ ) +ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(ARDUINOLIBLIBSPATH), \ + $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) +ifeq "$(AVRDUDECONF)" "" +ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" +AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf +else +AVRDUDECONF := $(wildcard $(AVRDUDE).conf) +endif +endif + +# no board? +ifndef BOARD +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is unset. Type 'make boards' to see possible values) +endif +endif +endif + +# obtain board parameters from the arduino boards.txt file +BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt +BOARD_BUILD_MCU := \ + $(shell sed -ne "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_BUILD_FCPU := \ + $(shell sed -ne "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_BUILD_VARIANT := \ + $(shell sed -ne "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_UPLOAD_SPEED := \ + $(shell sed -ne "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_UPLOAD_PROTOCOL := \ + $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE)) + +# invalid board? +ifeq "$(BOARD_BUILD_MCU)" "" +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is invalid. Type 'make boards' to see possible values) +endif +endif +endif + +# flags +CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections +CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) +CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) +CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) +CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ +CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES)) +CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) +CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep +CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h +AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV +AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) +AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) +LINKFLAGS := -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) + +# figure out which arg to use with stty +STTYFARG := $(shell stty --help > /dev/null 2>&1 && echo -F || echo -f) + +# include dependencies +ifneq "$(MAKECMDGOALS)" "clean" +-include $(DEPFILES) +endif + +# default rule +.DEFAULT_GOAL := all + +#_______________________________________________________________________________ +# RULES + +.PHONY: all target upload clean boards monitor size + +all: target + +target: $(TARGET).hex + +upload: + @echo "\nUploading to board..." + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + stty $(STTYFARG) $(SERIALDEV) hupcl + $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i + +clean: + rm -f $(OBJECTS) + rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ + rm -rf .lib .dep + +boards: + @echo Available values for BOARD: + @sed -ne '/^#/d; /^[^.]\+\.name=/p' $(BOARDS_FILE) | \ + sed -e 's/\([^.]\+\)\.name=\(.*\)/\1 \2/' \ + -e 's/\(.\{12\}\) *\(.*\)/\1 \2/' + +monitor: + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test -n `which screen` || { \ + echo "error: can't find GNU screen, you might need to install it." >&2 \ + ecit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + screen $(SERIALDEV) + +size: $(TARGET).elf + echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf + +# building the target + +$(TARGET).hex: $(TARGET).elf + $(OBJCOPY) -O ihex -R .eeprom $< $@ + +.INTERMEDIATE: $(TARGET).elf + +$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) + $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@ + +%.o: %.c + mkdir -p .dep/$(dir $<) + $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.cpp + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.cc + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.C + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.ino + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< + +%.o: %.pde + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ -x c++ -include $(ARDUINOCOREDIR)/Arduino.h $< + +# building the arduino library + +$(ARDUINOLIB): $(ARDUINOLIBOBJS) + $(AR) rcs $@ $? + +.lib/%.c.o: %.c + mkdir -p $(dir $@) + $(COMPILE.c) -o $@ $< + +.lib/%.cpp.o: %.cpp + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +.lib/%.cc.o: %.cc + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +.lib/%.C.o: %.C + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< diff --git a/README.md b/README.md index e5880d4..acea3fe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,28 @@ Nanpy ===== -Program your Arduino prototypes using Python \ No newline at end of file +Program your Arduino prototypes using Python. + +Description +----------- + +Use Python for developing prototypes for your Arduino board! + + lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + lcd.printString("Loc. London") + +really straightforward now, isn't it? :) + +How to use +---------- + +Nanpy is composed by a Python part, that provide a set of client classes and functions to use Arduino via Python and a server firmware that you can build just typing + + ./buildfirware + +for your Arduino UNO (we are developing Nanpy on it, open the script and change the board if you need). + +License +------- + +This software is released under MIT License. Copyright (c) 2012 Octan (https://github.com/Octan) diff --git a/buildfirmware.sh b/buildfirmware.sh new file mode 100755 index 0000000..0143520 --- /dev/null +++ b/buildfirmware.sh @@ -0,0 +1,5 @@ +cd firmware +export BOARD=uno +make -f ../Makefile clean +make -f ../Makefile +make -f ../Makefile upload diff --git a/examples/clock.py b/examples/clock.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/helloworld.py b/examples/helloworld.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/lcdanimation.py b/examples/lcdanimation.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/temperature.py b/examples/temperature.py new file mode 100644 index 0000000..e69de29 diff --git a/firmware/.dep/MethodDescriptor.cpp.dep b/firmware/.dep/MethodDescriptor.cpp.dep new file mode 100644 index 0000000..f9e0516 --- /dev/null +++ b/firmware/.dep/MethodDescriptor.cpp.dep @@ -0,0 +1,5 @@ +MethodDescriptor.o: MethodDescriptor.cpp MethodDescriptor.h Utilities.h + +MethodDescriptor.h: + +Utilities.h: diff --git a/firmware/.dep/Nanpy.ino.dep b/firmware/.dep/Nanpy.ino.dep new file mode 100644 index 0000000..29ba397 --- /dev/null +++ b/firmware/.dep/Nanpy.ino.dep @@ -0,0 +1,48 @@ +Nanpy.o: Nanpy.ino \ + /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/new.h \ + /usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \ + PyOneWire.h Vector.h PyLiquidCrystal.h MethodDescriptor.h Utilities.h \ + /usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Print.h + +/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/binary.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/new.h: + +/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h: + +PyOneWire.h: + +Vector.h: + +PyLiquidCrystal.h: + +MethodDescriptor.h: + +Utilities.h: + +/usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: diff --git a/firmware/.dep/PyLiquidCrystal.cpp.dep b/firmware/.dep/PyLiquidCrystal.cpp.dep new file mode 100644 index 0000000..181cb17 --- /dev/null +++ b/firmware/.dep/PyLiquidCrystal.cpp.dep @@ -0,0 +1,42 @@ +PyLiquidCrystal.o: PyLiquidCrystal.cpp \ + /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/new.h \ + /usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \ + /usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ + PyLiquidCrystal.h MethodDescriptor.h + +/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/binary.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/new.h: + +/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h: + +/usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: + +PyLiquidCrystal.h: + +MethodDescriptor.h: diff --git a/firmware/.dep/PyOneWire.cpp.dep b/firmware/.dep/PyOneWire.cpp.dep new file mode 100644 index 0000000..27cc5df --- /dev/null +++ b/firmware/.dep/PyOneWire.cpp.dep @@ -0,0 +1,40 @@ +PyOneWire.o: PyOneWire.cpp /usr/share/arduino/libraries/OneWire/OneWire.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/new.h \ + /usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \ + PyOneWire.h Vector.h MethodDescriptor.h + +/usr/share/arduino/libraries/OneWire/OneWire.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/binary.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/new.h: + +/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h: + +PyOneWire.h: + +Vector.h: + +MethodDescriptor.h: diff --git a/firmware/.dep/Utilities.cpp.dep b/firmware/.dep/Utilities.cpp.dep new file mode 100644 index 0000000..93aa99c --- /dev/null +++ b/firmware/.dep/Utilities.cpp.dep @@ -0,0 +1,21 @@ +Utilities.o: Utilities.cpp Utilities.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ + /usr/share/arduino/hardware/arduino/cores/arduino/new.h + +Utilities.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: + +/usr/share/arduino/hardware/arduino/cores/arduino/new.h: diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp new file mode 100644 index 0000000..4aed710 --- /dev/null +++ b/firmware/MethodDescriptor.cpp @@ -0,0 +1,62 @@ +#include "MethodDescriptor.h" +#include "Utilities.h" +#include + +MethodDescriptor::MethodDescriptor() { + + this->classname = readStringFromSerial(); + char* buff = readStringFromSerial(); + this->objid = atoi(buff); + free(buff); + + buff = readStringFromSerial(); + this->n_args = atoi(buff); + free(buff); + this->name = readStringFromSerial(); + + this->stack = (char**)malloc(sizeof(char*) * this->n_args); + + for(int n = 0; n < this->n_args; n++) + { + this->stack[n] = readStringFromSerial(); + } + +}; + +int MethodDescriptor::getNArgs() { + return this->n_args; +}; + + +int MethodDescriptor::getInt(int n) { + return atoi(this->stack[n]); +}; + + +char* MethodDescriptor::getString(int n) { + return this->stack[n]; +}; + +char* MethodDescriptor::getClass() { + return this->classname; +}; + +int MethodDescriptor::getObjectId() { + return this->objid; +}; + +char* MethodDescriptor::getName() { + return this->name; +}; + +MethodDescriptor::~MethodDescriptor() { + delete(name); + delete(classname); + + for(int n = 0; n < this->n_args; n++) + { + delete(this->stack[n]); + } + + delete(this->stack); +} diff --git a/firmware/MethodDescriptor.h b/firmware/MethodDescriptor.h new file mode 100644 index 0000000..6775be3 --- /dev/null +++ b/firmware/MethodDescriptor.h @@ -0,0 +1,28 @@ +#ifndef METHOD_DESCRIPTOR +#define METHOD_DESCRIPTOR + +class MethodDescriptor { + + private: + char *name; + int objid; + char* classname; + int n_args; + char **stack; + + public: + MethodDescriptor(); + int getNArgs(); + char* getClass(); + int getObjectId(); + int getInt(int n); + char* getString(int n); + char* getName(); + ~MethodDescriptor(); + +}; + + + + +#endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino new file mode 100644 index 0000000..8d30a82 --- /dev/null +++ b/firmware/Nanpy.ino @@ -0,0 +1,92 @@ +#include + +#include "PyOneWire.h" +#include "PyLiquidCrystal.h" +#include "MethodDescriptor.h" +#include "Utilities.h" +#include + +PyLiquidCrystal* lcd_class; +PyOneWire* onewire_class; + +int pin, value; + +MethodDescriptor *m = NULL; + +void elaborate() +{ + + + + + // send data only when you receive data + if(m != NULL) + { + + delete(m); + + m = NULL; + } + + if (Serial.available() > 0) + { + + m = new MethodDescriptor(); + + if (strcmp(m->getName(), "digitalWrite") == 0) + { + digitalWrite(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "digitalRead") == 0) + { + digitalRead(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "delay") == 0) + { + delay(m->getInt(0)); + Serial.println("0"); + } + + + + lcd_class->elaborate(m); + onewire_class->elaborate(m); + + /*if (strcmp(buffz, "digitalRead") == 0) + { + pin = atoi(readStringFromSerial()); + Serial.println(digitalRead(pin)); + } + + if (strcmp(buffz,"delay") == 0) + { + value = atoi(readStringFromSerial()); + delay(value); + Serial.println("0"); + } + + lcd_class->elaborate(buffz);*/ + + } + +} + +void setup() { + onewire_class = new PyOneWire(); + pinMode(13, OUTPUT); + pinMode(12, INPUT); + Serial.begin(9600); + while (Serial.available() <= 0) { + delay(300); + } +} + +void loop(){ + elaborate(); +} + + diff --git a/firmware/PyLiquidCrystal.cpp b/firmware/PyLiquidCrystal.cpp new file mode 100644 index 0000000..701d538 --- /dev/null +++ b/firmware/PyLiquidCrystal.cpp @@ -0,0 +1,34 @@ +#include +#include +#include "PyLiquidCrystal.h" +#include "MethodDescriptor.h" +#include + +lcds lcd1; + +PyLiquidCrystal::PyLiquidCrystal() { + +}; + +void PyLiquidCrystal::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "Lcd") == 0) { + + if (strcmp(m->getName(),"new") == 0) { + int prm = 0; + lcd1.obj = new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), + m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++)); + lcd1.obj->begin(m->getInt(prm++), m->getInt(prm++)); + } + + if (strcmp(m->getName(), "print") == 0) { + lcd1.obj->print(m->getString(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "setCursor") == 0) { + lcd1.obj->setCursor(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + } +}; diff --git a/firmware/PyLiquidCrystal.h b/firmware/PyLiquidCrystal.h new file mode 100644 index 0000000..75e215b --- /dev/null +++ b/firmware/PyLiquidCrystal.h @@ -0,0 +1,29 @@ +#ifndef PY_LIQUID_CRYSTAL +#define PY_LIQUID_CRYSTAL +#include + +class LiquidCrystal; +class MethodDescriptor; + +char* readStringFromSerial(); + +struct lcds +{ + char* name; + LiquidCrystal* obj; +}; + +class PyLiquidCrystal { + + public: + + PyLiquidCrystal(); + + void elaborate( MethodDescriptor* m ); + + //void getObjectByName() + //... + +}; + +#endif diff --git a/firmware/PyOneWire.cpp b/firmware/PyOneWire.cpp new file mode 100644 index 0000000..7982d00 --- /dev/null +++ b/firmware/PyOneWire.cpp @@ -0,0 +1,80 @@ +#include +#include "PyOneWire.h" +#include "MethodDescriptor.h" +#include + +onewire ds; +SlimVector v(2); + +PyOneWire::PyOneWire() { + //OneWire *o = new OneWire[5]; +}; + +void PyOneWire::elaborate( MethodDescriptor* m ) { + + if (strcmp(m->getClass(), "OneWire") == 0) { + + if (strcmp(m->getName(), "new") == 0) { + v.insert(new OneWire(m->getInt(0))); + Serial.println(v.getLastIndex()); + } + + if (strcmp(m->getName(), "search") == 0) { + byte addr[8]; + int res = v[m->getObjectId()]->search(addr); + + if(!res) { + v[m->getObjectId()]->reset_search(); + delay(250); + Serial.println("1"); + } + + else { + String addr_hex = String(); + for( int cc = 0; cc < 7; cc++ ) + addr_hex += String(addr[cc]) + " "; + addr_hex += String(addr[7]); + Serial.println(addr_hex); + } + } + + if (strcmp(m->getName(), "reset_search") == 0) { + v[m->getObjectId()]->reset_search(); + Serial.println("0"); + } + + if (strcmp(m->getName(), "reset") == 0) { + Serial.println(v[m->getObjectId()]->reset()); + } + + if (strcmp(m->getName(), "select") == 0) { + byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); + + for(int i = 0 ; i < m->getNArgs() ; i++) + { + addr[i] = (byte)m->getInt(i); + } + + v[m->getObjectId()]->select(addr); + + delete(addr); + Serial.println("0"); + } + + if (strcmp(m->getName(), "write") == 0) { + if(m->getNArgs() == 1) + v[m->getObjectId()]->write(m->getInt(0)); + else + v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "read") == 0) { + Serial.println(v[m->getObjectId()]->read()); + } + + } +}; + +//void getObjectByName() +//... diff --git a/firmware/PyOneWire.h b/firmware/PyOneWire.h new file mode 100644 index 0000000..a1f7f0f --- /dev/null +++ b/firmware/PyOneWire.h @@ -0,0 +1,32 @@ + +#ifndef PY_ONE_WIRE +#define PY_ONE_WIRE +#include "Vector.h" + +class OneWire; +class MethodDescriptor; + +char* readStringFromSerial(); + +struct onewire +{ + char* name; + OneWire* obj; +}; + + + +class PyOneWire { + + public: + + PyOneWire(); + + void elaborate( MethodDescriptor* m ); + + //void getObjectByName() + //... + +}; + +#endif diff --git a/firmware/Utilities.cpp b/firmware/Utilities.cpp new file mode 100644 index 0000000..ebfa7ed --- /dev/null +++ b/firmware/Utilities.cpp @@ -0,0 +1,21 @@ +#include "Utilities.h" +#include +#include + +char* readStringFromSerial() +{ + char* buffer = (char*)malloc(30); + int i=0; + char ch = '0'; + do { + ch = Serial.read(); + if(ch != '\0' && ch < 255 && ch >= 0) { + buffer[i++] = ch; + } + } while(ch != '\0'); + char* buffer2 = (char*)malloc(i + 1); + buffer[i] = '\0'; + strcpy(buffer2, buffer); + free(buffer); + return buffer2; +}; diff --git a/firmware/Utilities.h b/firmware/Utilities.h new file mode 100644 index 0000000..5711c68 --- /dev/null +++ b/firmware/Utilities.h @@ -0,0 +1,7 @@ +#ifndef UTILITIES +#define UTILITIES + + char* readStringFromSerial(); + +#endif + diff --git a/firmware/Vector.h b/firmware/Vector.h new file mode 100644 index 0000000..db60455 --- /dev/null +++ b/firmware/Vector.h @@ -0,0 +1,83 @@ +template class SlimVector { + + private: + int size; + int cur_size; + T *v; + + public: + SlimVector(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { + for(int i = 0; i < size; i++) + v[i] = 0; + cur_size = 0; + } + + SlimVector(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { + size = s; + for(int i = 0; i < size; i++) + v[i] = x[i]; + } + + void insert(T el) { + this->insert(cur_size, el); + } + + void insert(int pos, T el) { + if(pos > size - 1) { + T* newv = (T*)malloc(sizeof(T) * (pos + 1)); + newv[pos] = el; + for(int i = 0; i < size; i++) + newv[i] = v[i]; + free(v); + size = pos + 1; + v = newv; + } else { + v[pos] = el; + } + cur_size++; + } + + T get(int pos) { + return v[pos]; + } + + T& operator[] ( int pos ) { + return v[pos]; + } + + int getSize() { + return this->size; + } + + int getLastIndex() { + return (this->cur_size - 1); + } + + ~SlimVector() { + free(v); + } + +}; + +/* template + void vecTor::printvec() const + { + cout<<"Vector is:\n"; + for(int i=0; i v1(3); + + v1=vecTor(a,3); // this call produces seg. fault + + //v1.vecTorset(a,3); //this call works fine + + v1.printvec(); + + return 0; */ diff --git a/nanpy/Arduino.py b/nanpy/Arduino.py new file mode 100644 index 0000000..0c0746f --- /dev/null +++ b/nanpy/Arduino.py @@ -0,0 +1,28 @@ +from ArduinoObject import ArduinoSingleObject +import Singleton + +class Arduino(ArduinoSingleObject): + + def __init__(self): + ArduinoSingleObject.__init__(self, "Arduino") + + def digitalWrite(self, pin, value): + self.call('digitalWrite', pin, value) + return self._return_value() + + def digitalRead(self, pin): + self.call('digitalRead', pin) + return self._return_value() + + def analogWrite(self, pin, value): + self.call('analogWrite', pin, value) + return self._return_value() + + def analogRead(self, pin): + self.call('analogRead', pin) + return self._return_value() + + def delay(self, value): + self.call('delay', value) + return self._return_value() + diff --git a/nanpy/ArduinoObject.py b/nanpy/ArduinoObject.py new file mode 100644 index 0000000..897a790 --- /dev/null +++ b/nanpy/ArduinoObject.py @@ -0,0 +1,50 @@ +import IdGenerator +import Singleton +from SerialManager import * + +class ArduinoObject(): + + def __init__(self, namespace, single=False): + self.namespace = namespace + self.single = single + self.id = 0 + + def _write(self, data): + data = str(data) + for ch in data: + sm.write('%c' % ch) + sm.write('\0') + + def _read(self): + return sm.readline() + + def _return_value(self): + red = sm.readline().replace("\r\n","") + return red + + def call(self, *args): + self._write(self.namespace) + self._write(self.id) + toprint = [] + nel = 0 + for arg in args: + if type(arg) == type(list()): + for el in arg: + if el != None: + toprint.append(el) + nel += 1 + else: + if arg != None: + toprint.append(arg) + nel += 1 + + self._write(nel - 1) + + for elprint in toprint: + self._write(elprint) + +class ArduinoSingleObject(ArduinoObject, Singleton.Singleton): + def __init__(self, namespace): + Singleton.Singleton.__init__( self ) + ArduinoObject.__init__(self, namespace, True) + diff --git a/nanpy/DallasTemperature.py b/nanpy/DallasTemperature.py new file mode 100644 index 0000000..8db9f39 --- /dev/null +++ b/nanpy/DallasTemperature.py @@ -0,0 +1,71 @@ +from OneWire import OneWire +import time + +class DallasTemperature(): + + def __init__(self, pin): + self.__ds = OneWire(pin) + self.__data = 0 + + def __fetchAddress(self): + ds_address = self.__ds.search() + #print "The address of the sensor is R=%s" % ds_address.get() + + if ds_address == "1": + return False + + self.__ds.reset() + self.__ds.select(ds_address) + self.__ds.write(0x44, 1) #start conversion, with parasite power on at the end + + time.sleep(1) #maybe 750ms is enough, maybe not + + present = self.__ds.reset() + self.__ds.select(ds_address) + self.__ds.write(0xBE) + return True + + def __fetchData(self): + + data = [] + + #print "DATA", + + for i in range(9): + val = self.__ds.read() + #print "%s" % val, + data.append(val) + + raw = (data[1] << 8) | data[0] + + type = 1 + + if type == 0: + + raw = raw << 3; # 9 bit resolution default + if data[7] == 0x10: + raw = (raw & 0xFFF0) + 12 - data[6] # count remain gives full 12 bit resolution + + else: + cfg = (data[4] & 0x60) + + if cfg == 0x00: + raw = raw << 3; # 9 bit resolution, 93.75 ms + elif cfg == 0x20: + raw = raw << 2; # 10 bit res, 187.5 ms + elif cfg == 0x40: + raw = raw << 1; # 11 bit res, 375 ms + else: + pass #default is 12 bit resolution, 750 ms conversion time + + self.__data = raw + + def getCelsius(self): + if self.__fetchAddress(): + self.__fetchData() + return self.__data / 16.0 + + def getFahrenheit(self): + if self.__fetchAddress(): + self.__fetchData() + return self.getCelsius() * 1.8 + 32.0 diff --git a/nanpy/IdGenerator.py b/nanpy/IdGenerator.py new file mode 100644 index 0000000..5cc33c1 --- /dev/null +++ b/nanpy/IdGenerator.py @@ -0,0 +1,9 @@ +namespaceid = {} + +def generate(namespace): + try: + namespaceid[namespace] = namespaceid[namespace] + 1 + return namespaceid[namespace] + except KeyError: + namespaceid[namespace] = 0; + return namespaceid[namespace]; diff --git a/nanpy/Lcd.py b/nanpy/Lcd.py new file mode 100644 index 0000000..586e276 --- /dev/null +++ b/nanpy/Lcd.py @@ -0,0 +1,15 @@ +from ArduinoObject import ArduinoObject + +class Lcd(ArduinoObject): + + def __init__(self, pins, begin): + ArduinoObject.__init__(self, "Lcd") + self.call('new', pins, begin) + + def printString(self, value): + self.call('print', value) + return self._return_value() + + def setCursor(self, col, row): + self.call('setCursor', col, row) + return self._return_value() diff --git a/nanpy/OneWire.py b/nanpy/OneWire.py new file mode 100644 index 0000000..f2036b3 --- /dev/null +++ b/nanpy/OneWire.py @@ -0,0 +1,48 @@ +from ArduinoObject import ArduinoObject + +class OneWireAddress(): + + def __init__(self, bytes): + self.__bytes = bytes + + def get(self): + return self.__bytes + +class OneWire(ArduinoObject): + + def __init__(self, pin): + ArduinoObject.__init__(self, "OneWire") + self.call('new', pin) + self.id = self._return_value() + + def search(self): + self.call('search') + val = self._return_value() + if val == "1": + return val + else: + return OneWireAddress(val.split(" ")) + + def reset_search(self): + self.call('reset_search') + return self._return_value() + + def reset(self): + self.call('reset') + self._return_value() + + def select(self, address): + self.call('select', address.get()) + return self._return_value() + + def write(self, address, value=None): + self.call('write', address, value) + return self._return_value() + + def read(self): + self.call('read') + return int(self._return_value()) + + + + diff --git a/nanpy/SerialManager.py b/nanpy/SerialManager.py new file mode 100644 index 0000000..49f4da8 --- /dev/null +++ b/nanpy/SerialManager.py @@ -0,0 +1,16 @@ +import serial +import time + +class SerialManager(object): + + def __init__(self, device, baud): + self.__serial = serial.Serial(device, baud) + time.sleep(2) + + def write(self, value): + self.__serial.write(value) + + def readline(self): + return self.__serial.readline() + +sm = SerialManager('/dev/ttyACM0', 9600) diff --git a/nanpy/Singleton.py b/nanpy/Singleton.py new file mode 100644 index 0000000..6096a48 --- /dev/null +++ b/nanpy/Singleton.py @@ -0,0 +1,13 @@ +class Singleton: + __single = None + def __init__( self ): + if Singleton.__single: + raise Singleton.__single + Singleton.__single = self + +def getIstance( x = Singleton ): + try: + single = x() + except Singleton, s: + single = s + return single diff --git a/nanpy/__init__.py b/nanpy/__init__.py new file mode 100644 index 0000000..d92db64 --- /dev/null +++ b/nanpy/__init__.py @@ -0,0 +1,3 @@ +from Arduino import * +from OneWire import * +from Lcd import * diff --git a/test.py b/test.py new file mode 100644 index 0000000..d514080 --- /dev/null +++ b/test.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +from nanpy.Arduino import Arduino +from nanpy.Lcd import Lcd +from nanpy.DallasTemperature import DallasTemperature + +arduino = Arduino() + +for i in range(4): + arduino.digitalWrite(13, (i + 1) % 2) + arduino.delay(10) + +print "From the pin 13 I read %s" % arduino.digitalRead(13) + +lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) +lcd.printString("Loc. London") + +temp = DallasTemperature(5) + +while(1): + lcd.setCursor(0, 1) + lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp.getCelsius(), temp.getCelsius())) + print temp.getCelsius() + From eb9ad689280e8c016891746263f5f0f0b274ea99 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 14 Sep 2012 14:25:46 +0200 Subject: [PATCH 003/344] Get rid of dep folder --- firmware/.dep/MethodDescriptor.cpp.dep | 5 --- firmware/.dep/Nanpy.ino.dep | 48 -------------------------- firmware/.dep/PyLiquidCrystal.cpp.dep | 42 ---------------------- firmware/.dep/PyOneWire.cpp.dep | 40 --------------------- firmware/.dep/Utilities.cpp.dep | 21 ----------- 5 files changed, 156 deletions(-) delete mode 100644 firmware/.dep/MethodDescriptor.cpp.dep delete mode 100644 firmware/.dep/Nanpy.ino.dep delete mode 100644 firmware/.dep/PyLiquidCrystal.cpp.dep delete mode 100644 firmware/.dep/PyOneWire.cpp.dep delete mode 100644 firmware/.dep/Utilities.cpp.dep diff --git a/firmware/.dep/MethodDescriptor.cpp.dep b/firmware/.dep/MethodDescriptor.cpp.dep deleted file mode 100644 index f9e0516..0000000 --- a/firmware/.dep/MethodDescriptor.cpp.dep +++ /dev/null @@ -1,5 +0,0 @@ -MethodDescriptor.o: MethodDescriptor.cpp MethodDescriptor.h Utilities.h - -MethodDescriptor.h: - -Utilities.h: diff --git a/firmware/.dep/Nanpy.ino.dep b/firmware/.dep/Nanpy.ino.dep deleted file mode 100644 index 29ba397..0000000 --- a/firmware/.dep/Nanpy.ino.dep +++ /dev/null @@ -1,48 +0,0 @@ -Nanpy.o: Nanpy.ino \ - /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/new.h \ - /usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \ - PyOneWire.h Vector.h PyLiquidCrystal.h MethodDescriptor.h Utilities.h \ - /usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Print.h - -/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/binary.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/new.h: - -/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h: - -PyOneWire.h: - -Vector.h: - -PyLiquidCrystal.h: - -MethodDescriptor.h: - -Utilities.h: - -/usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: diff --git a/firmware/.dep/PyLiquidCrystal.cpp.dep b/firmware/.dep/PyLiquidCrystal.cpp.dep deleted file mode 100644 index 181cb17..0000000 --- a/firmware/.dep/PyLiquidCrystal.cpp.dep +++ /dev/null @@ -1,42 +0,0 @@ -PyLiquidCrystal.o: PyLiquidCrystal.cpp \ - /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/new.h \ - /usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \ - /usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ - PyLiquidCrystal.h MethodDescriptor.h - -/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/binary.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/new.h: - -/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h: - -/usr/share/arduino/libraries/LiquidCrystal/LiquidCrystal.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: - -PyLiquidCrystal.h: - -MethodDescriptor.h: diff --git a/firmware/.dep/PyOneWire.cpp.dep b/firmware/.dep/PyOneWire.cpp.dep deleted file mode 100644 index 27cc5df..0000000 --- a/firmware/.dep/PyOneWire.cpp.dep +++ /dev/null @@ -1,40 +0,0 @@ -PyOneWire.o: PyOneWire.cpp /usr/share/arduino/libraries/OneWire/OneWire.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/binary.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/new.h \ - /usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h \ - PyOneWire.h Vector.h MethodDescriptor.h - -/usr/share/arduino/libraries/OneWire/OneWire.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/binary.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/new.h: - -/usr/share/arduino/hardware/arduino/variants/standard/pins_arduino.h: - -PyOneWire.h: - -Vector.h: - -MethodDescriptor.h: diff --git a/firmware/.dep/Utilities.cpp.dep b/firmware/.dep/Utilities.cpp.dep deleted file mode 100644 index 93aa99c..0000000 --- a/firmware/.dep/Utilities.cpp.dep +++ /dev/null @@ -1,21 +0,0 @@ -Utilities.o: Utilities.cpp Utilities.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Stream.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Print.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/WString.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/Printable.h \ - /usr/share/arduino/hardware/arduino/cores/arduino/new.h - -Utilities.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Print.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/WString.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h: - -/usr/share/arduino/hardware/arduino/cores/arduino/new.h: From a89ad2c1b0a68825133c16a0b598ebe85a43ce04 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 14 Sep 2012 14:26:22 +0200 Subject: [PATCH 004/344] Ignore dep folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2f242b2..1764b78 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,9 @@ #Arduino *.o *.hex -*/.deb +*/.dep */.lib + #Python *.pyc From 192564ddf8023d0becd9394ba750988e367b486e Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 15 Sep 2012 15:34:19 +0200 Subject: [PATCH 005/344] A super class for our classes and some changes on names --- firmware/ArduinoClass.h | 13 ++++++++ firmware/Nanpy.ino | 50 +++++++----------------------- firmware/PyLiquidCrystal.h | 6 ++-- firmware/PyOneWire.cpp | 10 ++---- firmware/PyOneWire.h | 11 +++---- firmware/{Vector.h => SlimArray.h} | 34 +++++--------------- 6 files changed, 42 insertions(+), 82 deletions(-) create mode 100644 firmware/ArduinoClass.h rename firmware/{Vector.h => SlimArray.h} (65%) diff --git a/firmware/ArduinoClass.h b/firmware/ArduinoClass.h new file mode 100644 index 0000000..18b2c59 --- /dev/null +++ b/firmware/ArduinoClass.h @@ -0,0 +1,13 @@ +#ifndef PY_ARDUINO_CLASS +#define PY_ARDUINO_CLASS + +class MethodDescriptor; + +class ArduinoClass { + + public: + virtual void elaborate( MethodDescriptor* m ) = 0; + +}; + +#endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 8d30a82..ec25f60 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,13 +1,13 @@ #include +#include "ArduinoClass.h" #include "PyOneWire.h" #include "PyLiquidCrystal.h" #include "MethodDescriptor.h" #include "Utilities.h" -#include +#include "SlimArray.h" -PyLiquidCrystal* lcd_class; -PyOneWire* onewire_class; +SlimArray classes(2); int pin, value; @@ -16,67 +16,41 @@ MethodDescriptor *m = NULL; void elaborate() { - - - // send data only when you receive data - if(m != NULL) - { - + if(m != NULL) { delete(m); - m = NULL; } - if (Serial.available() > 0) - { + if (Serial.available() > 0) { m = new MethodDescriptor(); - if (strcmp(m->getName(), "digitalWrite") == 0) - { + if (strcmp(m->getName(), "digitalWrite") == 0) { digitalWrite(m->getInt(0), m->getInt(1)); Serial.println("0"); } - if (strcmp(m->getName(), "digitalRead") == 0) - { + if (strcmp(m->getName(), "digitalRead") == 0) { digitalRead(m->getInt(0)); Serial.println("0"); } - if (strcmp(m->getName(), "delay") == 0) - { + if (strcmp(m->getName(), "delay") == 0) { delay(m->getInt(0)); Serial.println("0"); } - - - lcd_class->elaborate(m); - onewire_class->elaborate(m); - - /*if (strcmp(buffz, "digitalRead") == 0) - { - pin = atoi(readStringFromSerial()); - Serial.println(digitalRead(pin)); - } - - if (strcmp(buffz,"delay") == 0) - { - value = atoi(readStringFromSerial()); - delay(value); - Serial.println("0"); - } - - lcd_class->elaborate(buffz);*/ + for(int i = 0 ; i < classes.getSize() ; i++) + classes[i]->elaborate(m); } } void setup() { - onewire_class = new PyOneWire(); + classes.insert(new PyOneWire()); + classes.insert(new PyLiquidCrystal()); pinMode(13, OUTPUT); pinMode(12, INPUT); Serial.begin(9600); diff --git a/firmware/PyLiquidCrystal.h b/firmware/PyLiquidCrystal.h index 75e215b..59628d4 100644 --- a/firmware/PyLiquidCrystal.h +++ b/firmware/PyLiquidCrystal.h @@ -1,6 +1,7 @@ #ifndef PY_LIQUID_CRYSTAL #define PY_LIQUID_CRYSTAL #include +#include "ArduinoClass.h" class LiquidCrystal; class MethodDescriptor; @@ -13,7 +14,7 @@ struct lcds LiquidCrystal* obj; }; -class PyLiquidCrystal { +class PyLiquidCrystal: public ArduinoClass { public: @@ -21,9 +22,6 @@ class PyLiquidCrystal { void elaborate( MethodDescriptor* m ); - //void getObjectByName() - //... - }; #endif diff --git a/firmware/PyOneWire.cpp b/firmware/PyOneWire.cpp index 7982d00..8ca94ee 100644 --- a/firmware/PyOneWire.cpp +++ b/firmware/PyOneWire.cpp @@ -4,10 +4,10 @@ #include onewire ds; -SlimVector v(2); +SlimArray v(2); PyOneWire::PyOneWire() { - //OneWire *o = new OneWire[5]; + }; void PyOneWire::elaborate( MethodDescriptor* m ) { @@ -50,8 +50,7 @@ void PyOneWire::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "select") == 0) { byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); - for(int i = 0 ; i < m->getNArgs() ; i++) - { + for(int i = 0 ; i < m->getNArgs() ; i++) { addr[i] = (byte)m->getInt(i); } @@ -75,6 +74,3 @@ void PyOneWire::elaborate( MethodDescriptor* m ) { } }; - -//void getObjectByName() -//... diff --git a/firmware/PyOneWire.h b/firmware/PyOneWire.h index a1f7f0f..314e3a4 100644 --- a/firmware/PyOneWire.h +++ b/firmware/PyOneWire.h @@ -1,7 +1,8 @@ - #ifndef PY_ONE_WIRE #define PY_ONE_WIRE -#include "Vector.h" + +#include "SlimArray.h" +#include "ArduinoClass.h" class OneWire; class MethodDescriptor; @@ -16,17 +17,13 @@ struct onewire -class PyOneWire { +class PyOneWire: public ArduinoClass { public: PyOneWire(); - void elaborate( MethodDescriptor* m ); - //void getObjectByName() - //... - }; #endif diff --git a/firmware/Vector.h b/firmware/SlimArray.h similarity index 65% rename from firmware/Vector.h rename to firmware/SlimArray.h index db60455..3e93491 100644 --- a/firmware/Vector.h +++ b/firmware/SlimArray.h @@ -1,4 +1,7 @@ -template class SlimVector { +#ifndef SLIM_ARRAY +#define SLIM_ARRAY + +template class SlimArray { private: int size; @@ -6,13 +9,13 @@ template class SlimVector { T *v; public: - SlimVector(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { + SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { for(int i = 0; i < size; i++) v[i] = 0; cur_size = 0; } - SlimVector(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { + SlimArray(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { size = s; for(int i = 0; i < size; i++) v[i] = x[i]; @@ -53,31 +56,10 @@ template class SlimVector { return (this->cur_size - 1); } - ~SlimVector() { + ~SlimArray() { free(v); } }; -/* template - void vecTor::printvec() const - { - cout<<"Vector is:\n"; - for(int i=0; i v1(3); - - v1=vecTor(a,3); // this call produces seg. fault - - //v1.vecTorset(a,3); //this call works fine - - v1.printvec(); - - return 0; */ +#endif From 8d386157446d0054686c01bfa7223e6827a9c48d Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 15 Sep 2012 15:37:09 +0200 Subject: [PATCH 006/344] A super class for our classes and some changes on names --- firmware/Nanpy.ino | 4 +- firmware/PyLiquidCrystal.cpp | 34 ---------------- firmware/PyLiquidCrystal.h | 27 ------------- firmware/PyOneWire.cpp | 76 ------------------------------------ firmware/PyOneWire.h | 29 -------------- 5 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 firmware/PyLiquidCrystal.cpp delete mode 100644 firmware/PyLiquidCrystal.h delete mode 100644 firmware/PyOneWire.cpp delete mode 100644 firmware/PyOneWire.h diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index ec25f60..41fd7cd 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,8 +1,8 @@ #include #include "ArduinoClass.h" -#include "PyOneWire.h" -#include "PyLiquidCrystal.h" +#include "OneWireClass.h" +#include "LiquidCrystalClass.h" #include "MethodDescriptor.h" #include "Utilities.h" #include "SlimArray.h" diff --git a/firmware/PyLiquidCrystal.cpp b/firmware/PyLiquidCrystal.cpp deleted file mode 100644 index 701d538..0000000 --- a/firmware/PyLiquidCrystal.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include "PyLiquidCrystal.h" -#include "MethodDescriptor.h" -#include - -lcds lcd1; - -PyLiquidCrystal::PyLiquidCrystal() { - -}; - -void PyLiquidCrystal::elaborate( MethodDescriptor* m ) { - if (strcmp(m->getClass(), "Lcd") == 0) { - - if (strcmp(m->getName(),"new") == 0) { - int prm = 0; - lcd1.obj = new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), - m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++)); - lcd1.obj->begin(m->getInt(prm++), m->getInt(prm++)); - } - - if (strcmp(m->getName(), "print") == 0) { - lcd1.obj->print(m->getString(0)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "setCursor") == 0) { - lcd1.obj->setCursor(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - } -}; diff --git a/firmware/PyLiquidCrystal.h b/firmware/PyLiquidCrystal.h deleted file mode 100644 index 59628d4..0000000 --- a/firmware/PyLiquidCrystal.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PY_LIQUID_CRYSTAL -#define PY_LIQUID_CRYSTAL -#include -#include "ArduinoClass.h" - -class LiquidCrystal; -class MethodDescriptor; - -char* readStringFromSerial(); - -struct lcds -{ - char* name; - LiquidCrystal* obj; -}; - -class PyLiquidCrystal: public ArduinoClass { - - public: - - PyLiquidCrystal(); - - void elaborate( MethodDescriptor* m ); - -}; - -#endif diff --git a/firmware/PyOneWire.cpp b/firmware/PyOneWire.cpp deleted file mode 100644 index 8ca94ee..0000000 --- a/firmware/PyOneWire.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include "PyOneWire.h" -#include "MethodDescriptor.h" -#include - -onewire ds; -SlimArray v(2); - -PyOneWire::PyOneWire() { - -}; - -void PyOneWire::elaborate( MethodDescriptor* m ) { - - if (strcmp(m->getClass(), "OneWire") == 0) { - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new OneWire(m->getInt(0))); - Serial.println(v.getLastIndex()); - } - - if (strcmp(m->getName(), "search") == 0) { - byte addr[8]; - int res = v[m->getObjectId()]->search(addr); - - if(!res) { - v[m->getObjectId()]->reset_search(); - delay(250); - Serial.println("1"); - } - - else { - String addr_hex = String(); - for( int cc = 0; cc < 7; cc++ ) - addr_hex += String(addr[cc]) + " "; - addr_hex += String(addr[7]); - Serial.println(addr_hex); - } - } - - if (strcmp(m->getName(), "reset_search") == 0) { - v[m->getObjectId()]->reset_search(); - Serial.println("0"); - } - - if (strcmp(m->getName(), "reset") == 0) { - Serial.println(v[m->getObjectId()]->reset()); - } - - if (strcmp(m->getName(), "select") == 0) { - byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); - - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = (byte)m->getInt(i); - } - - v[m->getObjectId()]->select(addr); - - delete(addr); - Serial.println("0"); - } - - if (strcmp(m->getName(), "write") == 0) { - if(m->getNArgs() == 1) - v[m->getObjectId()]->write(m->getInt(0)); - else - v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "read") == 0) { - Serial.println(v[m->getObjectId()]->read()); - } - - } -}; diff --git a/firmware/PyOneWire.h b/firmware/PyOneWire.h deleted file mode 100644 index 314e3a4..0000000 --- a/firmware/PyOneWire.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PY_ONE_WIRE -#define PY_ONE_WIRE - -#include "SlimArray.h" -#include "ArduinoClass.h" - -class OneWire; -class MethodDescriptor; - -char* readStringFromSerial(); - -struct onewire -{ - char* name; - OneWire* obj; -}; - - - -class PyOneWire: public ArduinoClass { - - public: - - PyOneWire(); - void elaborate( MethodDescriptor* m ); - -}; - -#endif From ef29e11cafc0d414d6eabb6c44e69d1c2b638241 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 15 Sep 2012 15:38:24 +0200 Subject: [PATCH 007/344] Reneame our classes --- firmware/LiquidCrystalClass.cpp | 34 +++++++++++++++ firmware/LiquidCrystalClass.h | 27 ++++++++++++ firmware/OneWireClass.cpp | 76 +++++++++++++++++++++++++++++++++ firmware/OneWireClass.h | 29 +++++++++++++ 4 files changed, 166 insertions(+) create mode 100644 firmware/LiquidCrystalClass.cpp create mode 100644 firmware/LiquidCrystalClass.h create mode 100644 firmware/OneWireClass.cpp create mode 100644 firmware/OneWireClass.h diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp new file mode 100644 index 0000000..0e857d7 --- /dev/null +++ b/firmware/LiquidCrystalClass.cpp @@ -0,0 +1,34 @@ +#include +#include +#include "LiquidCrystalClass.h" +#include "MethodDescriptor.h" +#include + +lcds lcd1; + +PyLiquidCrystal::PyLiquidCrystal() { + +}; + +void PyLiquidCrystal::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "Lcd") == 0) { + + if (strcmp(m->getName(),"new") == 0) { + int prm = 0; + lcd1.obj = new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), + m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++)); + lcd1.obj->begin(m->getInt(prm++), m->getInt(prm++)); + } + + if (strcmp(m->getName(), "print") == 0) { + lcd1.obj->print(m->getString(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "setCursor") == 0) { + lcd1.obj->setCursor(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + } +}; diff --git a/firmware/LiquidCrystalClass.h b/firmware/LiquidCrystalClass.h new file mode 100644 index 0000000..f26125f --- /dev/null +++ b/firmware/LiquidCrystalClass.h @@ -0,0 +1,27 @@ +#ifndef LIQUID_CRYSTAL_CLASS +#define LIQUID_CRYSTAL_CLASS +#include +#include "ArduinoClass.h" + +class LiquidCrystal; +class MethodDescriptor; + +char* readStringFromSerial(); + +struct lcds +{ + char* name; + LiquidCrystal* obj; +}; + +class PyLiquidCrystal: public ArduinoClass { + + public: + + PyLiquidCrystal(); + + void elaborate( MethodDescriptor* m ); + +}; + +#endif diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp new file mode 100644 index 0000000..d82f3b2 --- /dev/null +++ b/firmware/OneWireClass.cpp @@ -0,0 +1,76 @@ +#include +#include "OneWireClass.h" +#include "MethodDescriptor.h" +#include + +onewire ds; +SlimArray v(2); + +PyOneWire::PyOneWire() { + +}; + +void PyOneWire::elaborate( MethodDescriptor* m ) { + + if (strcmp(m->getClass(), "OneWire") == 0) { + + if (strcmp(m->getName(), "new") == 0) { + v.insert(new OneWire(m->getInt(0))); + Serial.println(v.getLastIndex()); + } + + if (strcmp(m->getName(), "search") == 0) { + byte addr[8]; + int res = v[m->getObjectId()]->search(addr); + + if(!res) { + v[m->getObjectId()]->reset_search(); + delay(250); + Serial.println("1"); + } + + else { + String addr_hex = String(); + for( int cc = 0; cc < 7; cc++ ) + addr_hex += String(addr[cc]) + " "; + addr_hex += String(addr[7]); + Serial.println(addr_hex); + } + } + + if (strcmp(m->getName(), "reset_search") == 0) { + v[m->getObjectId()]->reset_search(); + Serial.println("0"); + } + + if (strcmp(m->getName(), "reset") == 0) { + Serial.println(v[m->getObjectId()]->reset()); + } + + if (strcmp(m->getName(), "select") == 0) { + byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); + + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = (byte)m->getInt(i); + } + + v[m->getObjectId()]->select(addr); + + delete(addr); + Serial.println("0"); + } + + if (strcmp(m->getName(), "write") == 0) { + if(m->getNArgs() == 1) + v[m->getObjectId()]->write(m->getInt(0)); + else + v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "read") == 0) { + Serial.println(v[m->getObjectId()]->read()); + } + + } +}; diff --git a/firmware/OneWireClass.h b/firmware/OneWireClass.h new file mode 100644 index 0000000..ce0fcd6 --- /dev/null +++ b/firmware/OneWireClass.h @@ -0,0 +1,29 @@ +#ifndef ONE_WIRE_CLASS +#define ONE_WIRE_CLASS + +#include "SlimArray.h" +#include "ArduinoClass.h" + +class OneWire; +class MethodDescriptor; + +char* readStringFromSerial(); + +struct onewire +{ + char* name; + OneWire* obj; +}; + + + +class PyOneWire: public ArduinoClass { + + public: + + PyOneWire(); + void elaborate( MethodDescriptor* m ); + +}; + +#endif From 6c1635e34042a4a8c774e967d14ec600860b778d Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sat, 15 Sep 2012 20:03:21 +0200 Subject: [PATCH 008/344] Forgot to change class names --- firmware/LiquidCrystalClass.cpp | 4 ++-- firmware/LiquidCrystalClass.h | 4 ++-- firmware/Nanpy.ino | 5 ++--- firmware/OneWireClass.cpp | 4 ++-- firmware/OneWireClass.h | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 0e857d7..e5102b2 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -6,11 +6,11 @@ lcds lcd1; -PyLiquidCrystal::PyLiquidCrystal() { +LiquidCrystalClass::LiquidCrystalClass() { }; -void PyLiquidCrystal::elaborate( MethodDescriptor* m ) { +void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Lcd") == 0) { if (strcmp(m->getName(),"new") == 0) { diff --git a/firmware/LiquidCrystalClass.h b/firmware/LiquidCrystalClass.h index f26125f..36ebed5 100644 --- a/firmware/LiquidCrystalClass.h +++ b/firmware/LiquidCrystalClass.h @@ -14,11 +14,11 @@ struct lcds LiquidCrystal* obj; }; -class PyLiquidCrystal: public ArduinoClass { +class LiquidCrystalClass: public ArduinoClass { public: - PyLiquidCrystal(); + LiquidCrystalClass(); void elaborate( MethodDescriptor* m ); diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 41fd7cd..89f5477 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -16,7 +16,6 @@ MethodDescriptor *m = NULL; void elaborate() { - // send data only when you receive data if(m != NULL) { delete(m); m = NULL; @@ -49,8 +48,8 @@ void elaborate() } void setup() { - classes.insert(new PyOneWire()); - classes.insert(new PyLiquidCrystal()); + classes.insert(new OneWireClass()); + classes.insert(new LiquidCrystalClass()); pinMode(13, OUTPUT); pinMode(12, INPUT); Serial.begin(9600); diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index d82f3b2..709e91d 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -6,11 +6,11 @@ onewire ds; SlimArray v(2); -PyOneWire::PyOneWire() { +OneWireClass::OneWireClass() { }; -void PyOneWire::elaborate( MethodDescriptor* m ) { +void OneWireClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "OneWire") == 0) { diff --git a/firmware/OneWireClass.h b/firmware/OneWireClass.h index ce0fcd6..cb18744 100644 --- a/firmware/OneWireClass.h +++ b/firmware/OneWireClass.h @@ -17,11 +17,11 @@ struct onewire -class PyOneWire: public ArduinoClass { +class OneWireClass: public ArduinoClass { public: - PyOneWire(); + OneWireClass(); void elaborate( MethodDescriptor* m ); }; From bf29132e3a93ea4bec4a99a8df1ab10e4eeb88ed Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Tue, 25 Sep 2012 17:59:13 +0200 Subject: [PATCH 009/344] Lcd now supports arrays, minfixes --- ...DallasTemperature.py => DallasTemperature.py | 6 +++--- README.md | 15 +++++++++++++-- examples/clock.py | 0 examples/helloworld.py | 0 examples/lcdanimation.py | 0 examples/temperature.py | 0 firmware/LiquidCrystalClass.cpp | 15 +++++++-------- firmware/LiquidCrystalClass.h | 13 ++++++------- firmware/Nanpy.ino | 17 +++++++++++++++-- firmware/OneWireClass.cpp | 5 +---- firmware/OneWireClass.h | 10 +++------- firmware/SlimArray.h | 2 ++ nanpy/Arduino.py | 4 ++++ nanpy/ArduinoObject.py | 1 - nanpy/IdGenerator.py | 9 --------- nanpy/Lcd.py | 1 + nanpy/OneWire.py | 3 --- test.py | 12 ++++++------ 18 files changed, 61 insertions(+), 52 deletions(-) rename nanpy/DallasTemperature.py => DallasTemperature.py (91%) delete mode 100644 examples/clock.py delete mode 100644 examples/helloworld.py delete mode 100644 examples/lcdanimation.py delete mode 100644 examples/temperature.py delete mode 100644 nanpy/IdGenerator.py diff --git a/nanpy/DallasTemperature.py b/DallasTemperature.py similarity index 91% rename from nanpy/DallasTemperature.py rename to DallasTemperature.py index 8db9f39..bf84614 100644 --- a/nanpy/DallasTemperature.py +++ b/DallasTemperature.py @@ -1,4 +1,4 @@ -from OneWire import OneWire +from nanpy.OneWire import OneWire import time class DallasTemperature(): @@ -18,7 +18,7 @@ def __fetchAddress(self): self.__ds.select(ds_address) self.__ds.write(0x44, 1) #start conversion, with parasite power on at the end - time.sleep(1) #maybe 750ms is enough, maybe not + time.sleep(1) #maybe 750ms is enough, maybe not present = self.__ds.reset() self.__ds.select(ds_address) @@ -42,7 +42,7 @@ def __fetchData(self): if type == 0: - raw = raw << 3; # 9 bit resolution default + raw = raw << 3; # 9 bit resolution default if data[7] == 0x10: raw = (raw & 0xFFF0) + 12 - data[6] # count remain gives full 12 bit resolution diff --git a/README.md b/README.md index acea3fe..a57ccbd 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,27 @@ Description ----------- Use Python for developing prototypes for your Arduino board! +Let's start with a classic example, turn on a led place in 13th pin.. + + arduino = Arduino() + arduino.pinMode(13, 1) + arduino.digitalWrite(13, 1) + +There are a lot of projects able to do that. Nanpy can do more! +Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. +We started supporting OneWire, Lcd and Servo library and they're still incomplete. +Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print something! lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) - lcd.printString("Loc. London") + lcd.printString("Hello World!") really straightforward now, isn't it? :) How to use ---------- -Nanpy is composed by a Python part, that provide a set of client classes and functions to use Arduino via Python and a server firmware that you can build just typing +Nanpy is composed by a Python part, that provide a set of client classes and functions to use Arduino via Python +and a server firmware that you can build just typing ./buildfirware diff --git a/examples/clock.py b/examples/clock.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/helloworld.py b/examples/helloworld.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/lcdanimation.py b/examples/lcdanimation.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/temperature.py b/examples/temperature.py deleted file mode 100644 index e69de29..0000000 diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index e5102b2..19af479 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -4,9 +4,7 @@ #include "MethodDescriptor.h" #include -lcds lcd1; - -LiquidCrystalClass::LiquidCrystalClass() { +LiquidCrystalClass::LiquidCrystalClass():v(2) { }; @@ -15,18 +13,19 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(),"new") == 0) { int prm = 0; - lcd1.obj = new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), - m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++)); - lcd1.obj->begin(m->getInt(prm++), m->getInt(prm++)); + v.insert(new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), + m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); + v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); + Serial.println(v.getLastIndex()); } if (strcmp(m->getName(), "print") == 0) { - lcd1.obj->print(m->getString(0)); + v[m->getObjectId()]->print(m->getString(0)); Serial.println("0"); } if (strcmp(m->getName(), "setCursor") == 0) { - lcd1.obj->setCursor(m->getInt(0), m->getInt(1)); + v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); Serial.println("0"); } diff --git a/firmware/LiquidCrystalClass.h b/firmware/LiquidCrystalClass.h index 36ebed5..8db8e19 100644 --- a/firmware/LiquidCrystalClass.h +++ b/firmware/LiquidCrystalClass.h @@ -1,6 +1,8 @@ #ifndef LIQUID_CRYSTAL_CLASS #define LIQUID_CRYSTAL_CLASS + #include +#include "SlimArray.h" #include "ArduinoClass.h" class LiquidCrystal; @@ -8,18 +10,15 @@ class MethodDescriptor; char* readStringFromSerial(); -struct lcds -{ - char* name; - LiquidCrystal* obj; -}; - class LiquidCrystalClass: public ArduinoClass { + private: + + SlimArray v; + public: LiquidCrystalClass(); - void elaborate( MethodDescriptor* m ); }; diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 89f5477..ca4d53f 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -35,6 +35,21 @@ void elaborate() Serial.println("0"); } + if (strcmp(m->getName(), "analogWrite") == 0) { + analogWrite(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "analogRead") == 0) { + analogRead(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "pinMode") == 0) { + pinMode(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + if (strcmp(m->getName(), "delay") == 0) { delay(m->getInt(0)); Serial.println("0"); @@ -50,8 +65,6 @@ void elaborate() void setup() { classes.insert(new OneWireClass()); classes.insert(new LiquidCrystalClass()); - pinMode(13, OUTPUT); - pinMode(12, INPUT); Serial.begin(9600); while (Serial.available() <= 0) { delay(300); diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index 709e91d..fa78b36 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -3,10 +3,7 @@ #include "MethodDescriptor.h" #include -onewire ds; -SlimArray v(2); - -OneWireClass::OneWireClass() { +OneWireClass::OneWireClass():v(2) { }; diff --git a/firmware/OneWireClass.h b/firmware/OneWireClass.h index cb18744..bdc5c29 100644 --- a/firmware/OneWireClass.h +++ b/firmware/OneWireClass.h @@ -9,15 +9,11 @@ class MethodDescriptor; char* readStringFromSerial(); -struct onewire -{ - char* name; - OneWire* obj; -}; - +class OneWireClass: public ArduinoClass { + private: -class OneWireClass: public ArduinoClass { + SlimArray v; public: diff --git a/firmware/SlimArray.h b/firmware/SlimArray.h index 3e93491..914814a 100644 --- a/firmware/SlimArray.h +++ b/firmware/SlimArray.h @@ -4,11 +4,13 @@ template class SlimArray { private: + int size; int cur_size; T *v; public: + SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { for(int i = 0; i < size; i++) v[i] = 0; diff --git a/nanpy/Arduino.py b/nanpy/Arduino.py index 0c0746f..1a70d76 100644 --- a/nanpy/Arduino.py +++ b/nanpy/Arduino.py @@ -22,6 +22,10 @@ def analogRead(self, pin): self.call('analogRead', pin) return self._return_value() + def pinMode(self, pin, mode): + self.call('pinMode', pin, mode) + return self._return_value() + def delay(self, value): self.call('delay', value) return self._return_value() diff --git a/nanpy/ArduinoObject.py b/nanpy/ArduinoObject.py index 897a790..3fb7012 100644 --- a/nanpy/ArduinoObject.py +++ b/nanpy/ArduinoObject.py @@ -1,4 +1,3 @@ -import IdGenerator import Singleton from SerialManager import * diff --git a/nanpy/IdGenerator.py b/nanpy/IdGenerator.py deleted file mode 100644 index 5cc33c1..0000000 --- a/nanpy/IdGenerator.py +++ /dev/null @@ -1,9 +0,0 @@ -namespaceid = {} - -def generate(namespace): - try: - namespaceid[namespace] = namespaceid[namespace] + 1 - return namespaceid[namespace] - except KeyError: - namespaceid[namespace] = 0; - return namespaceid[namespace]; diff --git a/nanpy/Lcd.py b/nanpy/Lcd.py index 586e276..29e7510 100644 --- a/nanpy/Lcd.py +++ b/nanpy/Lcd.py @@ -5,6 +5,7 @@ class Lcd(ArduinoObject): def __init__(self, pins, begin): ArduinoObject.__init__(self, "Lcd") self.call('new', pins, begin) + self.id = self._return_value() def printString(self, value): self.call('print', value) diff --git a/nanpy/OneWire.py b/nanpy/OneWire.py index f2036b3..4a26a85 100644 --- a/nanpy/OneWire.py +++ b/nanpy/OneWire.py @@ -43,6 +43,3 @@ def read(self): self.call('read') return int(self._return_value()) - - - diff --git a/test.py b/test.py index d514080..0ca0048 100644 --- a/test.py +++ b/test.py @@ -2,23 +2,23 @@ from nanpy.Arduino import Arduino from nanpy.Lcd import Lcd -from nanpy.DallasTemperature import DallasTemperature +from DallasTemperature import DallasTemperature arduino = Arduino() +arduino.pinMode(13, 1) + for i in range(4): arduino.digitalWrite(13, (i + 1) % 2) arduino.delay(10) -print "From the pin 13 I read %s" % arduino.digitalRead(13) - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString("Loc. London") -temp = DallasTemperature(5) +temp_int = DallasTemperature(5) +temp_ext = DallasTemperature(6) while(1): lcd.setCursor(0, 1) - lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp.getCelsius(), temp.getCelsius())) - print temp.getCelsius() + lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) From 8ba1d0678ff955deea5598290950dd2525e605e8 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 01:27:10 +0200 Subject: [PATCH 010/344] Some refactoring --- README.md | 5 ++- firmware/Nanpy.ino | 58 ++++++++++++++++--------------- nanpy/Arduino.py | 64 +++++++++++++++++----------------- nanpy/ArduinoObject.py | 78 +++++++++++++++++++++++------------------- nanpy/Singleton.py | 13 ------- test.py | 10 +++--- 6 files changed, 111 insertions(+), 117 deletions(-) delete mode 100644 nanpy/Singleton.py mode change 100644 => 100755 test.py diff --git a/README.md b/README.md index a57ccbd..a228fa5 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,8 @@ Description Use Python for developing prototypes for your Arduino board! Let's start with a classic example, turn on a led place in 13th pin.. - arduino = Arduino() - arduino.pinMode(13, 1) - arduino.digitalWrite(13, 1) + Arduino.pinMode(13, 1) + Arduino.digitalWrite(13, 1) There are a lot of projects able to do that. Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index ca4d53f..7d7bb8e 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -25,34 +25,36 @@ void elaborate() m = new MethodDescriptor(); - if (strcmp(m->getName(), "digitalWrite") == 0) { - digitalWrite(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "digitalRead") == 0) { - digitalRead(m->getInt(0)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "analogWrite") == 0) { - analogWrite(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "analogRead") == 0) { - analogRead(m->getInt(0)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "pinMode") == 0) { - pinMode(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "delay") == 0) { - delay(m->getInt(0)); - Serial.println("0"); + if (strcmp(m->getClass(), "Arduino") == 0) { + if (strcmp(m->getName(), "digitalWrite") == 0) { + digitalWrite(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "digitalRead") == 0) { + digitalRead(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "analogWrite") == 0) { + analogWrite(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "analogRead") == 0) { + analogRead(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "pinMode") == 0) { + pinMode(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "delay") == 0) { + delay(m->getInt(0)); + Serial.println("0"); + } } for(int i = 0 ; i < classes.getSize() ; i++) diff --git a/nanpy/Arduino.py b/nanpy/Arduino.py index 1a70d76..ce0f47c 100644 --- a/nanpy/Arduino.py +++ b/nanpy/Arduino.py @@ -1,32 +1,34 @@ -from ArduinoObject import ArduinoSingleObject -import Singleton - -class Arduino(ArduinoSingleObject): - - def __init__(self): - ArduinoSingleObject.__init__(self, "Arduino") - - def digitalWrite(self, pin, value): - self.call('digitalWrite', pin, value) - return self._return_value() - - def digitalRead(self, pin): - self.call('digitalRead', pin) - return self._return_value() - - def analogWrite(self, pin, value): - self.call('analogWrite', pin, value) - return self._return_value() - - def analogRead(self, pin): - self.call('analogRead', pin) - return self._return_value() - - def pinMode(self, pin, mode): - self.call('pinMode', pin, mode) - return self._return_value() - - def delay(self, value): - self.call('delay', value) - return self._return_value() +import ArduinoObject + +class Arduino(): + + @staticmethod + def digitalWrite(pin, value): + ArduinoObject.call_in_arduino('Arduino', 'digitalWrite', pin, value) + return ArduinoObject.return_value() + + @staticmethod + def digitalRead(pin): + ArduinoObject.call_in_arduino('Arduino', 'digitalRead', pin) + return ArduinoObject.return_value() + + @staticmethod + def analogWrite(pin, value): + ArduinoObject.call_in_arduino('Arduino', 'analogWrite', pin, value) + return ArduinoObject.return_value() + + @staticmethod + def analogRead(pin): + ArduinoObject.call_in_arduino('Arduino', 'analogRead', pin) + return ArduinoObject.return_value() + + @staticmethod + def pinMode(pin, mode): + ArduinoObject.call_in_arduino('Arduino', 'pinMode', pin, mode) + return ArduinoObject.return_value() + + @staticmethod + def delay(value): + ArduinoObject.call_in_arduino('Arduino', 'delay', value) + return ArduinoObject.return_value() diff --git a/nanpy/ArduinoObject.py b/nanpy/ArduinoObject.py index 3fb7012..4c58107 100644 --- a/nanpy/ArduinoObject.py +++ b/nanpy/ArduinoObject.py @@ -1,6 +1,43 @@ -import Singleton from SerialManager import * +def _write( data): + data = str(data) + for ch in data: + sm.write('%c' % ch) + print ch + sm.write('\0') + +def _read(): + return sm.readline() + +def call_in_arduino(*args): + _write(args[0]) + _write(0) + _send_parameters(args[1:]) + +def _send_parameters(args): + print args + toprint = [] + nel = 0 + for arg in args: + if type(arg) == type(list()): + for el in arg: + if el != None: + toprint.append(el) + nel += 1 + else: + if arg != None: + toprint.append(arg) + nel += 1 + + _write(nel - 1) + + for elprint in toprint: + _write(elprint) + +def return_value(): + return sm.readline().replace("\r\n","") + class ArduinoObject(): def __init__(self, namespace, single=False): @@ -8,42 +45,11 @@ def __init__(self, namespace, single=False): self.single = single self.id = 0 - def _write(self, data): - data = str(data) - for ch in data: - sm.write('%c' % ch) - sm.write('\0') - - def _read(self): - return sm.readline() - def _return_value(self): - red = sm.readline().replace("\r\n","") - return red + return return_value() def call(self, *args): - self._write(self.namespace) - self._write(self.id) - toprint = [] - nel = 0 - for arg in args: - if type(arg) == type(list()): - for el in arg: - if el != None: - toprint.append(el) - nel += 1 - else: - if arg != None: - toprint.append(arg) - nel += 1 - - self._write(nel - 1) - - for elprint in toprint: - self._write(elprint) - -class ArduinoSingleObject(ArduinoObject, Singleton.Singleton): - def __init__(self, namespace): - Singleton.Singleton.__init__( self ) - ArduinoObject.__init__(self, namespace, True) + _write(self.namespace) + _write(self.id) + _send_parameters(args) diff --git a/nanpy/Singleton.py b/nanpy/Singleton.py deleted file mode 100644 index 6096a48..0000000 --- a/nanpy/Singleton.py +++ /dev/null @@ -1,13 +0,0 @@ -class Singleton: - __single = None - def __init__( self ): - if Singleton.__single: - raise Singleton.__single - Singleton.__single = self - -def getIstance( x = Singleton ): - try: - single = x() - except Singleton, s: - single = s - return single diff --git a/test.py b/test.py old mode 100644 new mode 100755 index 0ca0048..5e10e76 --- a/test.py +++ b/test.py @@ -4,13 +4,9 @@ from nanpy.Lcd import Lcd from DallasTemperature import DallasTemperature -arduino = Arduino() - -arduino.pinMode(13, 1) - for i in range(4): - arduino.digitalWrite(13, (i + 1) % 2) - arduino.delay(10) + Arduino.digitalWrite(13, (i + 1) % 2) + Arduino.delay(10) lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString("Loc. London") @@ -18,6 +14,8 @@ temp_int = DallasTemperature(5) temp_ext = DallasTemperature(6) +Arduino.pinMode(13, 1) + while(1): lcd.setCursor(0, 1) lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) From 765b1561ad346729b899e3f944c9297467cced47 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 02:00:58 +0200 Subject: [PATCH 011/344] Setup added --- .gitignore | 4 +++ .../dallastemperature/dallastemperature.py | 2 +- test.py => examples/dallastemperature/run.py | 11 ++---- examples/helloworld/run.py | 10 ++++++ nanpy/Arduino.py | 34 ------------------- nanpy/__init__.py | 20 +++++++++-- nanpy/arduino.py | 34 +++++++++++++++++++ nanpy/{ArduinoObject.py => arduinoobject.py} | 4 +-- nanpy/{Lcd.py => lcd.py} | 2 +- nanpy/{OneWire.py => onewire.py} | 2 +- nanpy/{SerialManager.py => serialmanager.py} | 0 setup.py | 14 ++++++++ 12 files changed, 85 insertions(+), 52 deletions(-) rename DallasTemperature.py => examples/dallastemperature/dallastemperature.py (98%) rename test.py => examples/dallastemperature/run.py (58%) create mode 100755 examples/helloworld/run.py delete mode 100644 nanpy/Arduino.py create mode 100644 nanpy/arduino.py rename nanpy/{ArduinoObject.py => arduinoobject.py} (94%) rename nanpy/{Lcd.py => lcd.py} (89%) rename nanpy/{OneWire.py => onewire.py} (95%) rename nanpy/{SerialManager.py => serialmanager.py} (100%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 1764b78..5be5473 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ #General *~ +*.swp +build/ +dist/ +nanpy.egg-info/ #Arduino *.o diff --git a/DallasTemperature.py b/examples/dallastemperature/dallastemperature.py similarity index 98% rename from DallasTemperature.py rename to examples/dallastemperature/dallastemperature.py index bf84614..3635120 100644 --- a/DallasTemperature.py +++ b/examples/dallastemperature/dallastemperature.py @@ -1,4 +1,4 @@ -from nanpy.OneWire import OneWire +from nanpy import OneWire import time class DallasTemperature(): diff --git a/test.py b/examples/dallastemperature/run.py similarity index 58% rename from test.py rename to examples/dallastemperature/run.py index 5e10e76..91e68de 100755 --- a/test.py +++ b/examples/dallastemperature/run.py @@ -1,12 +1,7 @@ #!/usr/bin/env python -from nanpy.Arduino import Arduino -from nanpy.Lcd import Lcd -from DallasTemperature import DallasTemperature - -for i in range(4): - Arduino.digitalWrite(13, (i + 1) % 2) - Arduino.delay(10) +from nanpy import Lcd +from dallastemperature import DallasTemperature lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString("Loc. London") @@ -14,8 +9,6 @@ temp_int = DallasTemperature(5) temp_ext = DallasTemperature(6) -Arduino.pinMode(13, 1) - while(1): lcd.setCursor(0, 1) lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) diff --git a/examples/helloworld/run.py b/examples/helloworld/run.py new file mode 100755 index 0000000..7c2a3e1 --- /dev/null +++ b/examples/helloworld/run.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from nanpy import Arduino + +Arduino.pinMode(13, 1) + +for i in range(4): + Arduino.digitalWrite(13, (i + 1) % 2) + Arduino.delay(1000) + diff --git a/nanpy/Arduino.py b/nanpy/Arduino.py deleted file mode 100644 index ce0f47c..0000000 --- a/nanpy/Arduino.py +++ /dev/null @@ -1,34 +0,0 @@ -import ArduinoObject - -class Arduino(): - - @staticmethod - def digitalWrite(pin, value): - ArduinoObject.call_in_arduino('Arduino', 'digitalWrite', pin, value) - return ArduinoObject.return_value() - - @staticmethod - def digitalRead(pin): - ArduinoObject.call_in_arduino('Arduino', 'digitalRead', pin) - return ArduinoObject.return_value() - - @staticmethod - def analogWrite(pin, value): - ArduinoObject.call_in_arduino('Arduino', 'analogWrite', pin, value) - return ArduinoObject.return_value() - - @staticmethod - def analogRead(pin): - ArduinoObject.call_in_arduino('Arduino', 'analogRead', pin) - return ArduinoObject.return_value() - - @staticmethod - def pinMode(pin, mode): - ArduinoObject.call_in_arduino('Arduino', 'pinMode', pin, mode) - return ArduinoObject.return_value() - - @staticmethod - def delay(value): - ArduinoObject.call_in_arduino('Arduino', 'delay', value) - return ArduinoObject.return_value() - diff --git a/nanpy/__init__.py b/nanpy/__init__.py index d92db64..b060f2f 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -1,3 +1,17 @@ -from Arduino import * -from OneWire import * -from Lcd import * +# Nanpy +# Copyright 2012 Andrea Stagi +# See LICENSE for details. + +""" +Nanpy library +""" +__version__ = '1.0' +__author__ = 'Andrea Stagi' +__license__ = 'MIT' + +from nanpy.arduinoobject import ArduinoObject +from nanpy.serialmanager import SerialManager + +from nanpy.arduino import Arduino +from nanpy.lcd import Lcd +from nanpy.onewire import OneWire diff --git a/nanpy/arduino.py b/nanpy/arduino.py new file mode 100644 index 0000000..751cd77 --- /dev/null +++ b/nanpy/arduino.py @@ -0,0 +1,34 @@ +from nanpy.arduinoobject import (call_in_arduino, return_value) + +class Arduino(): + + @staticmethod + def digitalWrite(pin, value): + call_in_arduino('Arduino', 'digitalWrite', pin, value) + return return_value() + + @staticmethod + def digitalRead(pin): + call_in_arduino('Arduino', 'digitalRead', pin) + return return_value() + + @staticmethod + def analogWrite(pin, value): + call_in_arduino('Arduino', 'analogWrite', pin, value) + return return_value() + + @staticmethod + def analogRead(pin): + call_in_arduino('Arduino', 'analogRead', pin) + return return_value() + + @staticmethod + def pinMode(pin, mode): + call_in_arduino('Arduino', 'pinMode', pin, mode) + return return_value() + + @staticmethod + def delay(value): + call_in_arduino('Arduino', 'delay', value) + return return_value() + diff --git a/nanpy/ArduinoObject.py b/nanpy/arduinoobject.py similarity index 94% rename from nanpy/ArduinoObject.py rename to nanpy/arduinoobject.py index 4c58107..1cc3e51 100644 --- a/nanpy/ArduinoObject.py +++ b/nanpy/arduinoobject.py @@ -1,10 +1,9 @@ -from SerialManager import * +from nanpy.serialmanager import * def _write( data): data = str(data) for ch in data: sm.write('%c' % ch) - print ch sm.write('\0') def _read(): @@ -16,7 +15,6 @@ def call_in_arduino(*args): _send_parameters(args[1:]) def _send_parameters(args): - print args toprint = [] nel = 0 for arg in args: diff --git a/nanpy/Lcd.py b/nanpy/lcd.py similarity index 89% rename from nanpy/Lcd.py rename to nanpy/lcd.py index 29e7510..7c1273d 100644 --- a/nanpy/Lcd.py +++ b/nanpy/lcd.py @@ -1,4 +1,4 @@ -from ArduinoObject import ArduinoObject +from nanpy.arduinoobject import ArduinoObject class Lcd(ArduinoObject): diff --git a/nanpy/OneWire.py b/nanpy/onewire.py similarity index 95% rename from nanpy/OneWire.py rename to nanpy/onewire.py index 4a26a85..e41d0e6 100644 --- a/nanpy/OneWire.py +++ b/nanpy/onewire.py @@ -1,4 +1,4 @@ -from ArduinoObject import ArduinoObject +from nanpy.arduinoobject import ArduinoObject class OneWireAddress(): diff --git a/nanpy/SerialManager.py b/nanpy/serialmanager.py similarity index 100% rename from nanpy/SerialManager.py rename to nanpy/serialmanager.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c195968 --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from setuptools import setup, find_packages + +setup(name="nanpy", + version="1.0", + description="Twitter library for python", + license="MIT", + author="Andrea Stagi", + author_email="stagi.andrea@gmail.com", + url="http://github.com/Octan/nanpy", + packages = find_packages(), + keywords= "arduino library prototype", + zip_safe = True) From 243e92af411377a5b3094fa0e97f9f24756ac3bf Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 02:11:55 +0200 Subject: [PATCH 012/344] Some copyright changes --- LICENSE | 2 +- README.md | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 4182601..45abc36 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012 Octan (https://github.com/Octan) +Copyright (c) 2012 Andrea Stagi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a228fa5..6faa5c7 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,4 @@ for your Arduino UNO (we are developing Nanpy on it, open the script and change License ------- -This software is released under MIT License. Copyright (c) 2012 Octan (https://github.com/Octan) +This software is released under MIT License. Copyright (c) 2012 Andrea Stagi diff --git a/setup.py b/setup.py index c195968..cfd1e9d 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup(name="nanpy", version="1.0", - description="Twitter library for python", + description="Build your Arduino prototypes with Python", license="MIT", author="Andrea Stagi", author_email="stagi.andrea@gmail.com", From 127b560e4ece8b5d8dd3c7f27dc3c0ad20598a2c Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 14:50:21 +0200 Subject: [PATCH 013/344] Examples in a single file, name refactoring, update build part, minfixes --- README.md | 22 ++++++++--- buildfirmware.sh | 5 --- .../dallastemperature.py | 38 +++++++++++++------ examples/dallastemperature/run.py | 15 -------- examples/{helloworld/run.py => helloworld.py} | 0 Makefile => firmware/Makefile | 0 nanpy/__init__.py | 3 +- nanpy/arduino.py | 14 +++---- nanpy/{arduinoobject.py => arduinoboard.py} | 22 +++++------ nanpy/lcd.py | 8 ++-- nanpy/onewire.py | 16 ++++---- nanpy/serialmanager.py | 6 ++- 12 files changed, 79 insertions(+), 70 deletions(-) delete mode 100755 buildfirmware.sh rename examples/{dallastemperature => }/dallastemperature.py (61%) mode change 100644 => 100755 delete mode 100755 examples/dallastemperature/run.py rename examples/{helloworld/run.py => helloworld.py} (100%) rename Makefile => firmware/Makefile (100%) rename nanpy/{arduinoobject.py => arduinoboard.py} (76%) diff --git a/README.md b/README.md index 6faa5c7..c6e821d 100644 --- a/README.md +++ b/README.md @@ -22,15 +22,25 @@ Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print s really straightforward now, isn't it? :) -How to use ----------- +How to build and install +------------------------ -Nanpy is composed by a Python part, that provide a set of client classes and functions to use Arduino via Python -and a server firmware that you can build just typing +Nanpy is composed by a Python part, that provides a library to use Arduino via Python +and a server firmware. - ./buildfirware +To install Nanpy just type -for your Arduino UNO (we are developing Nanpy on it, open the script and change the board if you need). + setup.py install + +To build the firmware type + + cd firmware + export BOARD=uno (in case you use UNO board, type 'make boards' for a complete list) + make + +and then upload it on your board + + make upload License ------- diff --git a/buildfirmware.sh b/buildfirmware.sh deleted file mode 100755 index 0143520..0000000 --- a/buildfirmware.sh +++ /dev/null @@ -1,5 +0,0 @@ -cd firmware -export BOARD=uno -make -f ../Makefile clean -make -f ../Makefile -make -f ../Makefile upload diff --git a/examples/dallastemperature/dallastemperature.py b/examples/dallastemperature.py old mode 100644 new mode 100755 similarity index 61% rename from examples/dallastemperature/dallastemperature.py rename to examples/dallastemperature.py index 3635120..1117c29 --- a/examples/dallastemperature/dallastemperature.py +++ b/examples/dallastemperature.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + from nanpy import OneWire import time @@ -9,16 +11,15 @@ def __init__(self, pin): def __fetchAddress(self): ds_address = self.__ds.search() - #print "The address of the sensor is R=%s" % ds_address.get() if ds_address == "1": return False self.__ds.reset() self.__ds.select(ds_address) - self.__ds.write(0x44, 1) #start conversion, with parasite power on at the end + self.__ds.write(0x44, 1) - time.sleep(1) #maybe 750ms is enough, maybe not + time.sleep(1) present = self.__ds.reset() self.__ds.select(ds_address) @@ -29,11 +30,8 @@ def __fetchData(self): data = [] - #print "DATA", - for i in range(9): val = self.__ds.read() - #print "%s" % val, data.append(val) raw = (data[1] << 8) | data[0] @@ -42,21 +40,21 @@ def __fetchData(self): if type == 0: - raw = raw << 3; # 9 bit resolution default + raw = raw << 3; if data[7] == 0x10: - raw = (raw & 0xFFF0) + 12 - data[6] # count remain gives full 12 bit resolution + raw = (raw & 0xFFF0) + 12 - data[6] else: cfg = (data[4] & 0x60) if cfg == 0x00: - raw = raw << 3; # 9 bit resolution, 93.75 ms + raw = raw << 3 elif cfg == 0x20: - raw = raw << 2; # 10 bit res, 187.5 ms + raw = raw << 2 elif cfg == 0x40: - raw = raw << 1; # 11 bit res, 375 ms + raw = raw << 1 else: - pass #default is 12 bit resolution, 750 ms conversion time + pass self.__data = raw @@ -69,3 +67,19 @@ def getFahrenheit(self): if self.__fetchAddress(): self.__fetchData() return self.getCelsius() * 1.8 + 32.0 + + +from nanpy import Lcd + +if __name__ == "__main__": + + lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + lcd.printString("Loc. London") + + temp_int = DallasTemperature(5) + temp_ext = DallasTemperature(6) + + while(1): + lcd.setCursor(0, 1) + lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) + diff --git a/examples/dallastemperature/run.py b/examples/dallastemperature/run.py deleted file mode 100755 index 91e68de..0000000 --- a/examples/dallastemperature/run.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -from nanpy import Lcd -from dallastemperature import DallasTemperature - -lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) -lcd.printString("Loc. London") - -temp_int = DallasTemperature(5) -temp_ext = DallasTemperature(6) - -while(1): - lcd.setCursor(0, 1) - lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) - diff --git a/examples/helloworld/run.py b/examples/helloworld.py similarity index 100% rename from examples/helloworld/run.py rename to examples/helloworld.py diff --git a/Makefile b/firmware/Makefile similarity index 100% rename from Makefile rename to firmware/Makefile diff --git a/nanpy/__init__.py b/nanpy/__init__.py index b060f2f..1115511 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -9,8 +9,9 @@ __author__ = 'Andrea Stagi' __license__ = 'MIT' -from nanpy.arduinoobject import ArduinoObject +from nanpy.arduinoboard import ArduinoObject from nanpy.serialmanager import SerialManager +from nanpy.serialmanager import serial_manager from nanpy.arduino import Arduino from nanpy.lcd import Lcd diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 751cd77..40fc740 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,34 +1,34 @@ -from nanpy.arduinoobject import (call_in_arduino, return_value) +from nanpy.arduinoboard import (call_static_method, return_value) class Arduino(): @staticmethod def digitalWrite(pin, value): - call_in_arduino('Arduino', 'digitalWrite', pin, value) + call_static_method('Arduino', 'digitalWrite', pin, value) return return_value() @staticmethod def digitalRead(pin): - call_in_arduino('Arduino', 'digitalRead', pin) + call_static_method('Arduino', 'digitalRead', pin) return return_value() @staticmethod def analogWrite(pin, value): - call_in_arduino('Arduino', 'analogWrite', pin, value) + call_static_method('Arduino', 'analogWrite', pin, value) return return_value() @staticmethod def analogRead(pin): - call_in_arduino('Arduino', 'analogRead', pin) + call_static_method('Arduino', 'analogRead', pin) return return_value() @staticmethod def pinMode(pin, mode): - call_in_arduino('Arduino', 'pinMode', pin, mode) + call_static_method('Arduino', 'pinMode', pin, mode) return return_value() @staticmethod def delay(value): - call_in_arduino('Arduino', 'delay', value) + call_static_method('Arduino', 'delay', value) return return_value() diff --git a/nanpy/arduinoobject.py b/nanpy/arduinoboard.py similarity index 76% rename from nanpy/arduinoobject.py rename to nanpy/arduinoboard.py index 1cc3e51..3e35245 100644 --- a/nanpy/arduinoobject.py +++ b/nanpy/arduinoboard.py @@ -1,18 +1,13 @@ -from nanpy.serialmanager import * +from nanpy.serialmanager import serial_manager def _write( data): data = str(data) for ch in data: - sm.write('%c' % ch) - sm.write('\0') + serial_manager.write('%c' % ch) + serial_manager.write('\0') def _read(): - return sm.readline() - -def call_in_arduino(*args): - _write(args[0]) - _write(0) - _send_parameters(args[1:]) + return serial_manager.readline() def _send_parameters(args): toprint = [] @@ -34,7 +29,12 @@ def _send_parameters(args): _write(elprint) def return_value(): - return sm.readline().replace("\r\n","") + return serial_manager.readline().replace("\r\n","") + +def call_static_method(*args): + _write(args[0]) + _write(0) + _send_parameters(args[1:]) class ArduinoObject(): @@ -43,7 +43,7 @@ def __init__(self, namespace, single=False): self.single = single self.id = 0 - def _return_value(self): + def return_value(self): return return_value() def call(self, *args): diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 7c1273d..23f6da2 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -1,16 +1,16 @@ -from nanpy.arduinoobject import ArduinoObject +from nanpy.arduinoboard import ArduinoObject class Lcd(ArduinoObject): def __init__(self, pins, begin): ArduinoObject.__init__(self, "Lcd") self.call('new', pins, begin) - self.id = self._return_value() + self.id = self.return_value() def printString(self, value): self.call('print', value) - return self._return_value() + return self.return_value() def setCursor(self, col, row): self.call('setCursor', col, row) - return self._return_value() + return self.return_value() diff --git a/nanpy/onewire.py b/nanpy/onewire.py index e41d0e6..e260f70 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -1,4 +1,4 @@ -from nanpy.arduinoobject import ArduinoObject +from nanpy.arduinoboard import ArduinoObject class OneWireAddress(): @@ -13,11 +13,11 @@ class OneWire(ArduinoObject): def __init__(self, pin): ArduinoObject.__init__(self, "OneWire") self.call('new', pin) - self.id = self._return_value() + self.id = self.return_value() def search(self): self.call('search') - val = self._return_value() + val = self.return_value() if val == "1": return val else: @@ -25,21 +25,21 @@ def search(self): def reset_search(self): self.call('reset_search') - return self._return_value() + return self.return_value() def reset(self): self.call('reset') - self._return_value() + self.return_value() def select(self, address): self.call('select', address.get()) - return self._return_value() + return self.return_value() def write(self, address, value=None): self.call('write', address, value) - return self._return_value() + return self.return_value() def read(self): self.call('read') - return int(self._return_value()) + return int(self.return_value()) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 49f4da8..b166f14 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -7,10 +7,14 @@ def __init__(self, device, baud): self.__serial = serial.Serial(device, baud) time.sleep(2) + def connect(self, device, baud): + self.__serial = serial.Serial(device, baud) + time.sleep(2) + def write(self, value): self.__serial.write(value) def readline(self): return self.__serial.readline() -sm = SerialManager('/dev/ttyACM0', 9600) +serial_manager = SerialManager('/dev/ttyACM0', 9600) From 828ffdddd6e8823c13f972d0f709222959da82d3 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 15:15:01 +0200 Subject: [PATCH 014/344] Autodetect serial port --- .gitignore | 1 + nanpy/serialmanager.py | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5be5473..afa176d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build/ dist/ nanpy.egg-info/ +*.sh #Arduino *.o diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index b166f14..3f9c88d 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -1,10 +1,29 @@ import serial import time +import fnmatch +import serial + +def _auto_detect_serial_unix(preferred_list=['*']): + import glob + glist = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + ret = [] + + for d in glist: + for preferred in preferred_list: + if fnmatch.fnmatch(d, preferred): + ret.append(d) + if len(ret) > 0: + return ret + + for d in glist: + ret.append(d) + return ret class SerialManager(object): - def __init__(self, device, baud): - self.__serial = serial.Serial(device, baud) + def __init__(self): + available_ports = _auto_detect_serial_unix() + self.__serial = serial.Serial(available_ports[0], 9600, timeout=1) time.sleep(2) def connect(self, device, baud): @@ -17,4 +36,4 @@ def write(self, value): def readline(self): return self.__serial.readline() -serial_manager = SerialManager('/dev/ttyACM0', 9600) +serial_manager = SerialManager() From 91bdb433781d694ae6f7f87e24f5e3b1f0fb20b2 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 15:27:05 +0200 Subject: [PATCH 015/344] README updated --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index c6e821d..ca54870 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,24 @@ and then upload it on your board make upload +How to use +---------- + +## Serial communication + +Nanpy autodetects the serial port for you. You can specify another serial port and baudrate manually: + + from nanpy import serial_manager + serial_manager.connect('/dev/ttyACM1', 9600) + +## Import modules + +Import all the modules you need :) + + from nanpy import Arduino + from nanpy import OneWire + from nanpy import Lcd + License ------- From ec65dc119ece2eebf30c83bd8d5727d490d45397 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 15:28:15 +0200 Subject: [PATCH 016/344] README updated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca54870..ae0db34 100644 --- a/README.md +++ b/README.md @@ -45,14 +45,14 @@ and then upload it on your board How to use ---------- -## Serial communication +### Serial communication Nanpy autodetects the serial port for you. You can specify another serial port and baudrate manually: from nanpy import serial_manager serial_manager.connect('/dev/ttyACM1', 9600) -## Import modules +### Import modules Import all the modules you need :) From 2565483014c0276db3848bd6d7b3d570ceda0e7f Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 16:04:23 +0200 Subject: [PATCH 017/344] Arduino singleton class created --- firmware/ArduinoSingle.cpp | 50 ++++++++++++++++++++++++++++++++++++++ firmware/ArduinoSingle.h | 25 +++++++++++++++++++ firmware/Nanpy.ino | 34 ++------------------------ 3 files changed, 77 insertions(+), 32 deletions(-) create mode 100644 firmware/ArduinoSingle.cpp create mode 100644 firmware/ArduinoSingle.h diff --git a/firmware/ArduinoSingle.cpp b/firmware/ArduinoSingle.cpp new file mode 100644 index 0000000..47438ab --- /dev/null +++ b/firmware/ArduinoSingle.cpp @@ -0,0 +1,50 @@ +#include +#include "ArduinoSingle.h" +#include "MethodDescriptor.h" +#include + +ArduinoSingle* ArduinoSingle::instance = NULL; + +ArduinoSingle::ArduinoSingle() { + +}; + +ArduinoSingle* ArduinoSingle::getInstance() { + if (instance == NULL) + instance = new ArduinoSingle(); + return instance; +} + +void ArduinoSingle::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "Arduino") == 0) { + if (strcmp(m->getName(), "digitalWrite") == 0) { + digitalWrite(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "digitalRead") == 0) { + digitalRead(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "analogWrite") == 0) { + analogWrite(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "analogRead") == 0) { + analogRead(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "pinMode") == 0) { + pinMode(m->getInt(0), m->getInt(1)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "delay") == 0) { + delay(m->getInt(0)); + Serial.println("0"); + } + } +}; diff --git a/firmware/ArduinoSingle.h b/firmware/ArduinoSingle.h new file mode 100644 index 0000000..dac2ccd --- /dev/null +++ b/firmware/ArduinoSingle.h @@ -0,0 +1,25 @@ +#ifndef ARDUINO_SINGLE +#define ARDUINO_SINGLE + +#include +#include "ArduinoClass.h" + +class MethodDescriptor; + +char* readStringFromSerial(); + +class ArduinoSingle : public ArduinoClass { + + private: + + static ArduinoSingle* instance; + ArduinoSingle(); + + public: + + void elaborate( MethodDescriptor* m ); + static ArduinoSingle* getInstance(); + +}; + +#endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 7d7bb8e..ec69b67 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,6 +1,7 @@ #include #include "ArduinoClass.h" +#include "ArduinoSingle.h" #include "OneWireClass.h" #include "LiquidCrystalClass.h" #include "MethodDescriptor.h" @@ -25,38 +26,6 @@ void elaborate() m = new MethodDescriptor(); - if (strcmp(m->getClass(), "Arduino") == 0) { - if (strcmp(m->getName(), "digitalWrite") == 0) { - digitalWrite(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "digitalRead") == 0) { - digitalRead(m->getInt(0)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "analogWrite") == 0) { - analogWrite(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "analogRead") == 0) { - analogRead(m->getInt(0)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "pinMode") == 0) { - pinMode(m->getInt(0), m->getInt(1)); - Serial.println("0"); - } - - if (strcmp(m->getName(), "delay") == 0) { - delay(m->getInt(0)); - Serial.println("0"); - } - } - for(int i = 0 ; i < classes.getSize() ; i++) classes[i]->elaborate(m); @@ -65,6 +34,7 @@ void elaborate() } void setup() { + classes.insert(ArduinoSingle::getInstance()); classes.insert(new OneWireClass()); classes.insert(new LiquidCrystalClass()); Serial.begin(9600); From 9fdaad1a3ac9fd2b5f7d98cff690510e271b02c8 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 16:58:43 +0200 Subject: [PATCH 018/344] Added clock example, example header, minfixes --- README.md | 4 ++-- examples/blink.py | 14 ++++++++++++++ examples/clock.py | 26 ++++++++++++++++++++++++++ examples/dallastemperature.py | 4 ++++ examples/helloworld.py | 10 ---------- 5 files changed, 46 insertions(+), 12 deletions(-) create mode 100755 examples/blink.py create mode 100755 examples/clock.py delete mode 100755 examples/helloworld.py diff --git a/README.md b/README.md index ae0db34..26f0e58 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ How to build and install Nanpy is composed by a Python part, that provides a library to use Arduino via Python and a server firmware. -To install Nanpy just type +To install Nanpy just type (as root) - setup.py install + python setup.py install To build the firmware type diff --git a/examples/blink.py b/examples/blink.py new file mode 100755 index 0000000..7347902 --- /dev/null +++ b/examples/blink.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: keeps your led blinking +# Dependencies: None + +from nanpy import Arduino + +Arduino.pinMode(13, 1) + +for i in range(10000): + Arduino.digitalWrite(13, (i + 1) % 2) + Arduino.delay(10) + diff --git a/examples/clock.py b/examples/clock.py new file mode 100755 index 0000000..27613f0 --- /dev/null +++ b/examples/clock.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: get the current time from a ntp server and show it on a lcd +# Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/) + +import ntplib +from nanpy import Arduino +from nanpy import Lcd +from time import ctime +from datetime import datetime + +ntp_client = ntplib.NTPClient() +response = ntp_client.request('europe.pool.ntp.org', version=3) + +time = response.tx_time + +lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + +while (1): + lcd.setCursor(0, 0) + lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) + lcd.setCursor(0, 1) + lcd.printString((datetime.fromtimestamp(time)).strftime('%H:%M')) + Arduino.delay(1000) + time += 1 diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 1117c29..924081a 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -1,5 +1,9 @@ #!/usr/bin/env python +# Author: Andrea Stagi +# Description: a fake DallasTemperature library written in Python +# Dependencies: None + from nanpy import OneWire import time diff --git a/examples/helloworld.py b/examples/helloworld.py deleted file mode 100755 index 7c2a3e1..0000000 --- a/examples/helloworld.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python - -from nanpy import Arduino - -Arduino.pinMode(13, 1) - -for i in range(4): - Arduino.digitalWrite(13, (i + 1) % 2) - Arduino.delay(1000) - From 5257e77386fa1958455e4a487bd16f818dce2bc1 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 26 Sep 2012 22:54:53 +0200 Subject: [PATCH 019/344] Deallocate objects in Arduino as soon as python objects call __del__ --- firmware/LiquidCrystalClass.cpp | 5 +++++ firmware/OneWireClass.cpp | 5 +++++ firmware/SlimArray.h | 21 +++++++++++++++++++++ nanpy/arduinoboard.py | 6 ++++++ 4 files changed, 37 insertions(+) diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 19af479..834f69b 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -29,5 +29,10 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { Serial.println("0"); } + if (strcmp(m->getName(), "remove") == 0) { + v.remove(m->getObjectId()); + Serial.println("0"); + } + } }; diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index fa78b36..49f086c 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -69,5 +69,10 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { Serial.println(v[m->getObjectId()]->read()); } + if (strcmp(m->getName(), "remove") == 0) { + v.remove(m->getObjectId()); + Serial.println("0"); + } + } }; diff --git a/firmware/SlimArray.h b/firmware/SlimArray.h index 914814a..96d5649 100644 --- a/firmware/SlimArray.h +++ b/firmware/SlimArray.h @@ -27,6 +27,27 @@ template class SlimArray { this->insert(cur_size, el); } + void remove(int pos) { + if(pos > size - 1) + return; + + T* newv = (T*)malloc(sizeof(T) * (size - 1)); + + int j = 0; + + for(int i = 0; i < size; i++) { + if(i != pos) { + newv[j] = v[i]; + j++; + } + } + + free(v); + v = newv; + cur_size--; + size--; + } + void insert(int pos, T el) { if(pos > size - 1) { T* newv = (T*)malloc(sizeof(T) * (pos + 1)); diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 3e35245..a200cad 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -51,3 +51,9 @@ def call(self, *args): _write(self.id) _send_parameters(args) + def __del__(self): + _write(self.namespace) + _write(self.id) + _send_parameters(["remove"]) + return_value() + From b2a3af891c039a675e220ad3c6df24e3440156e6 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 09:35:48 +0200 Subject: [PATCH 020/344] Some refactoring in the communication part, call method returns the value now --- nanpy/arduino.py | 18 ++++++------------ nanpy/arduinoboard.py | 28 +++++++++++----------------- nanpy/lcd.py | 9 +++------ nanpy/onewire.py | 24 ++++++++---------------- 4 files changed, 28 insertions(+), 51 deletions(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 40fc740..fbd4051 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -4,31 +4,25 @@ class Arduino(): @staticmethod def digitalWrite(pin, value): - call_static_method('Arduino', 'digitalWrite', pin, value) - return return_value() + return call_static_method('Arduino', 'digitalWrite', pin, value) @staticmethod def digitalRead(pin): - call_static_method('Arduino', 'digitalRead', pin) - return return_value() + return call_static_method('Arduino', 'digitalRead', pin) @staticmethod def analogWrite(pin, value): - call_static_method('Arduino', 'analogWrite', pin, value) - return return_value() + return call_static_method('Arduino', 'analogWrite', pin, value) @staticmethod def analogRead(pin): - call_static_method('Arduino', 'analogRead', pin) - return return_value() + return call_static_method('Arduino', 'analogRead', pin) @staticmethod def pinMode(pin, mode): - call_static_method('Arduino', 'pinMode', pin, mode) - return return_value() + return call_static_method('Arduino', 'pinMode', pin, mode) @staticmethod def delay(value): - call_static_method('Arduino', 'delay', value) - return return_value() + return call_static_method('Arduino', 'delay', value) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index a200cad..c674985 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -1,13 +1,7 @@ from nanpy.serialmanager import serial_manager def _write( data): - data = str(data) - for ch in data: - serial_manager.write('%c' % ch) - serial_manager.write('\0') - -def _read(): - return serial_manager.readline() + serial_manager.write('%s\0' % data) def _send_parameters(args): toprint = [] @@ -31,10 +25,15 @@ def _send_parameters(args): def return_value(): return serial_manager.readline().replace("\r\n","") +def _call(namespace, id, args): + _write(namespace) + _write(id) + _send_parameters(args) + return return_value() + def call_static_method(*args): - _write(args[0]) - _write(0) - _send_parameters(args[1:]) + return _call(args[0], 0, args[1:]) + class ArduinoObject(): @@ -47,13 +46,8 @@ def return_value(self): return return_value() def call(self, *args): - _write(self.namespace) - _write(self.id) - _send_parameters(args) + return _call(self.namespace, self.id, args) def __del__(self): - _write(self.namespace) - _write(self.id) - _send_parameters(["remove"]) - return_value() + return _call(self.namespace, self.id, ["remove"]) diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 23f6da2..aee8ddc 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -4,13 +4,10 @@ class Lcd(ArduinoObject): def __init__(self, pins, begin): ArduinoObject.__init__(self, "Lcd") - self.call('new', pins, begin) - self.id = self.return_value() + self.id = self.call('new', pins, begin) def printString(self, value): - self.call('print', value) - return self.return_value() + return self.call('print', value) def setCursor(self, col, row): - self.call('setCursor', col, row) - return self.return_value() + return self.call('setCursor', col, row) diff --git a/nanpy/onewire.py b/nanpy/onewire.py index e260f70..3945331 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -12,34 +12,26 @@ class OneWire(ArduinoObject): def __init__(self, pin): ArduinoObject.__init__(self, "OneWire") - self.call('new', pin) - self.id = self.return_value() + self.id = self.call('new', pin) def search(self): - self.call('search') - val = self.return_value() + val = self.call('search') if val == "1": return val - else: - return OneWireAddress(val.split(" ")) + return OneWireAddress(val.split(" ")) def reset_search(self): - self.call('reset_search') - return self.return_value() + return self.call('reset_search') def reset(self): - self.call('reset') - self.return_value() + return self.call('reset') def select(self, address): - self.call('select', address.get()) - return self.return_value() + return self.call('select', address.get()) def write(self, address, value=None): - self.call('write', address, value) - return self.return_value() + return self.call('write', address, value) def read(self): - self.call('read') - return int(self.return_value()) + return int(self.call('read')) From 0c60b2b06bd5da6c6ab0fb849aa6854db81de958 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 09:41:53 +0200 Subject: [PATCH 021/344] Thread safe calls --- nanpy/arduinoboard.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index c674985..a170a00 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -1,4 +1,7 @@ from nanpy.serialmanager import serial_manager +from threading import Lock + +mutex = Lock() def _write( data): serial_manager.write('%s\0' % data) @@ -26,10 +29,13 @@ def return_value(): return serial_manager.readline().replace("\r\n","") def _call(namespace, id, args): + mutex.acquire() _write(namespace) _write(id) _send_parameters(args) - return return_value() + ret = return_value() + mutex.release() + return ret def call_static_method(*args): return _call(args[0], 0, args[1:]) From 10e22ee8c8c8c75677aacf1252e107dbfebc794a Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 09:57:34 +0200 Subject: [PATCH 022/344] Back to the old write method --- nanpy/arduinoboard.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index a170a00..adb439b 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -4,7 +4,10 @@ mutex = Lock() def _write( data): - serial_manager.write('%s\0' % data) + data = str(data) + for ch in data: + serial_manager.write('%c' % ch) + serial_manager.write('\0') def _send_parameters(args): toprint = [] From 8c68210d4db4976a29df67f6767be7a406dd2f43 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 10:03:00 +0200 Subject: [PATCH 023/344] Removed useless code --- README.md | 4 ++-- nanpy/arduinoboard.py | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 26f0e58..23c869e 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ Nanpy autodetects the serial port for you. You can specify another serial port a Import all the modules you need :) from nanpy import Arduino - from nanpy import OneWire - from nanpy import Lcd + from nanpy import (OneWire, Lcd) + ... License ------- diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index adb439b..dd112a8 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -46,14 +46,10 @@ def call_static_method(*args): class ArduinoObject(): - def __init__(self, namespace, single=False): + def __init__(self, namespace): self.namespace = namespace - self.single = single self.id = 0 - def return_value(self): - return return_value() - def call(self, *args): return _call(self.namespace, self.id, args) From 764633328d26643e376584efddf7ad31957b9050 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 10:09:16 +0200 Subject: [PATCH 024/344] Clock looks nice now --- examples/clock.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/clock.py b/examples/clock.py index 27613f0..e960a58 100755 --- a/examples/clock.py +++ b/examples/clock.py @@ -13,7 +13,7 @@ ntp_client = ntplib.NTPClient() response = ntp_client.request('europe.pool.ntp.org', version=3) -time = response.tx_time +time = int(response.tx_time) lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) @@ -21,6 +21,9 @@ lcd.setCursor(0, 0) lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) lcd.setCursor(0, 1) - lcd.printString((datetime.fromtimestamp(time)).strftime('%H:%M')) + if time % 2: + lcd.printString((datetime.fromtimestamp(time)).strftime('%H:%M')) + else: + lcd.printString((datetime.fromtimestamp(time)).strftime('%H %M')) Arduino.delay(1000) time += 1 From 62c193195aaeb1a210a00dccbd43bef3e106ff4f Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 10:15:40 +0200 Subject: [PATCH 025/344] Clock minfixes --- examples/clock.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/clock.py b/examples/clock.py index e960a58..3bafce9 100755 --- a/examples/clock.py +++ b/examples/clock.py @@ -22,8 +22,9 @@ lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) lcd.setCursor(0, 1) if time % 2: - lcd.printString((datetime.fromtimestamp(time)).strftime('%H:%M')) + time_format = '%H:%M' else: - lcd.printString((datetime.fromtimestamp(time)).strftime('%H %M')) + time_format = '%H %M' + lcd.printString((datetime.fromtimestamp(time)).strftime(time_format)) Arduino.delay(1000) time += 1 From a4c97ae83754af7385fc85e1b6716350442611f4 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 10:39:35 +0200 Subject: [PATCH 026/344] Examples minfixes --- examples/clock.py | 4 +--- examples/dallastemperature.py | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/clock.py b/examples/clock.py index 3bafce9..50c54e9 100755 --- a/examples/clock.py +++ b/examples/clock.py @@ -5,9 +5,7 @@ # Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/) import ntplib -from nanpy import Arduino -from nanpy import Lcd -from time import ctime +from nanpy import (Arduino, Lcd) from datetime import datetime ntp_client = ntplib.NTPClient() diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 924081a..7175080 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -4,7 +4,7 @@ # Description: a fake DallasTemperature library written in Python # Dependencies: None -from nanpy import OneWire +from nanpy import (Arduino, OneWire) import time class DallasTemperature(): @@ -22,9 +22,7 @@ def __fetchAddress(self): self.__ds.reset() self.__ds.select(ds_address) self.__ds.write(0x44, 1) - - time.sleep(1) - + Arduino.delay(700) present = self.__ds.reset() self.__ds.select(ds_address) self.__ds.write(0xBE) From 3f06fd54958f260b028cdcfb6cd9034fc77365c4 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 15:04:34 +0200 Subject: [PATCH 027/344] Get the namespace from the class name --- README.md | 13 ++++++------- nanpy/arduinoboard.py | 4 ++-- nanpy/lcd.py | 2 +- nanpy/onewire.py | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 23c869e..b56b79a 100644 --- a/README.md +++ b/README.md @@ -25,20 +25,19 @@ really straightforward now, isn't it? :) How to build and install ------------------------ -Nanpy is composed by a Python part, that provides a library to use Arduino via Python -and a server firmware. +Nanpy is composed by a Python part, that provides a library to use Arduino via Python and a server firmware. -To install Nanpy just type (as root) +To install Nanpy just type (as root): python setup.py install -To build the firmware type +To build the firmware type: cd firmware - export BOARD=uno (in case you use UNO board, type 'make boards' for a complete list) + export BOARD=uno (in case you use UNO board. Type 'make boards' for a complete list) make -and then upload it on your board +and then upload it on your board: make upload @@ -47,7 +46,7 @@ How to use ### Serial communication -Nanpy autodetects the serial port for you. You can specify another serial port and baudrate manually: +Nanpy autodetects the serial port for you, anyway you can specify another serial port and baudrate manually: from nanpy import serial_manager serial_manager.connect('/dev/ttyACM1', 9600) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index dd112a8..a09696c 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -46,8 +46,8 @@ def call_static_method(*args): class ArduinoObject(): - def __init__(self, namespace): - self.namespace = namespace + def __init__(self): + self.namespace = self.__class__.__name__ self.id = 0 def call(self, *args): diff --git a/nanpy/lcd.py b/nanpy/lcd.py index aee8ddc..99a691f 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -3,7 +3,7 @@ class Lcd(ArduinoObject): def __init__(self, pins, begin): - ArduinoObject.__init__(self, "Lcd") + ArduinoObject.__init__(self) self.id = self.call('new', pins, begin) def printString(self, value): diff --git a/nanpy/onewire.py b/nanpy/onewire.py index 3945331..15540d7 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -11,7 +11,7 @@ def get(self): class OneWire(ArduinoObject): def __init__(self, pin): - ArduinoObject.__init__(self, "OneWire") + ArduinoObject.__init__(self) self.id = self.call('new', pin) def search(self): From 1c368bd27e0556fc8de696bb142d1b1f3005fbce Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 16:35:51 +0200 Subject: [PATCH 028/344] Decorator for methods that dont need any python work --- firmware/LiquidCrystalClass.cpp | 2 +- nanpy/arduinoboard.py | 7 +++++++ nanpy/lcd.py | 7 +++++-- nanpy/onewire.py | 22 +++++++++++++--------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 834f69b..ec97329 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -19,7 +19,7 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { Serial.println(v.getLastIndex()); } - if (strcmp(m->getName(), "print") == 0) { + if (strcmp(m->getName(), "printString") == 0) { v[m->getObjectId()]->print(m->getString(0)); Serial.println("0"); } diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index a09696c..b7f10e1 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -31,6 +31,13 @@ def _send_parameters(args): def return_value(): return serial_manager.readline().replace("\r\n","") +def arduinoclassmethod(funct, *args, **kwargs): + def wrapper(self, *args, **kwargs): + call_pars = [funct.__name__] + call_pars.extend(args) + return _call(self.namespace, self.id, call_pars) + return wrapper + def _call(namespace, id, args): mutex.acquire() _write(namespace) diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 99a691f..76487fe 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -1,4 +1,5 @@ from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoclassmethod class Lcd(ArduinoObject): @@ -6,8 +7,10 @@ def __init__(self, pins, begin): ArduinoObject.__init__(self) self.id = self.call('new', pins, begin) + @arduinoclassmethod def printString(self, value): - return self.call('print', value) + pass + @arduinoclassmethod def setCursor(self, col, row): - return self.call('setCursor', col, row) + pass diff --git a/nanpy/onewire.py b/nanpy/onewire.py index 15540d7..86e4369 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -1,4 +1,5 @@ from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoclassmethod class OneWireAddress(): @@ -20,18 +21,21 @@ def search(self): return val return OneWireAddress(val.split(" ")) - def reset_search(self): - return self.call('reset_search') - - def reset(self): - return self.call('reset') - def select(self, address): return self.call('select', address.get()) - def write(self, address, value=None): - return self.call('write', address, value) - def read(self): return int(self.call('read')) + @arduinoclassmethod + def reset_search(self): + pass + + @arduinoclassmethod + def reset(self): + pass + + @arduinoclassmethod + def write(self, address, value=None): + pass + From b23acd9af1f18ac15ab7786dbc4720be0b820ad2 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 27 Sep 2012 17:15:07 +0200 Subject: [PATCH 029/344] A new decorator for class methods, refactoring needed --- nanpy/arduino.py | 53 ++++++++++++++++++++++++------------------- nanpy/arduinoboard.py | 26 ++++++++++++++------- nanpy/lcd.py | 6 ++--- nanpy/onewire.py | 8 +++---- 4 files changed, 55 insertions(+), 38 deletions(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index fbd4051..f9c405c 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,28 +1,35 @@ from nanpy.arduinoboard import (call_static_method, return_value) +from nanpy.arduinoboard import arduinoclassmethod class Arduino(): - @staticmethod - def digitalWrite(pin, value): - return call_static_method('Arduino', 'digitalWrite', pin, value) - - @staticmethod - def digitalRead(pin): - return call_static_method('Arduino', 'digitalRead', pin) - - @staticmethod - def analogWrite(pin, value): - return call_static_method('Arduino', 'analogWrite', pin, value) - - @staticmethod - def analogRead(pin): - return call_static_method('Arduino', 'analogRead', pin) - - @staticmethod - def pinMode(pin, mode): - return call_static_method('Arduino', 'pinMode', pin, mode) - - @staticmethod - def delay(value): - return call_static_method('Arduino', 'delay', value) + @classmethod + @arduinoclassmethod + def digitalWrite(cls, pin, value): + pass + + @classmethod + @arduinoclassmethod + def digitalRead(cls, pin): + pass + + @classmethod + @arduinoclassmethod + def analogWrite(cls, pin, value): + pass + + @classmethod + @arduinoclassmethod + def analogRead(cls, pin): + pass + + @classmethod + @arduinoclassmethod + def pinMode(cls, pin, mode): + pass + + @classmethod + @arduinoclassmethod + def delay(cls, value): + pass diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index b7f10e1..0c9eb6d 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -31,13 +31,6 @@ def _send_parameters(args): def return_value(): return serial_manager.readline().replace("\r\n","") -def arduinoclassmethod(funct, *args, **kwargs): - def wrapper(self, *args, **kwargs): - call_pars = [funct.__name__] - call_pars.extend(args) - return _call(self.namespace, self.id, call_pars) - return wrapper - def _call(namespace, id, args): mutex.acquire() _write(namespace) @@ -47,9 +40,26 @@ def _call(namespace, id, args): mutex.release() return ret -def call_static_method(*args): +def _call_static(args): return _call(args[0], 0, args[1:]) +def arduinoobjectmethod(funct, *args, **kwargs): + def wrapper(self, *args, **kwargs): + call_pars = [funct.__name__] + call_pars.extend(args) + return _call(self.namespace, self.id, call_pars) + return wrapper + +def arduinoclassmethod(funct, *args, **kwargs): + def wrapper(cls, *args, **kwargs): + call_pars = [cls.__name__, funct.__name__] + call_pars.extend(args) + return _call_static(call_pars) + return wrapper + +def call_static_method(*args): + return _call_static(args) + class ArduinoObject(): diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 76487fe..179a091 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoclassmethod +from nanpy.arduinoboard import arduinoobjectmethod class Lcd(ArduinoObject): @@ -7,10 +7,10 @@ def __init__(self, pins, begin): ArduinoObject.__init__(self) self.id = self.call('new', pins, begin) - @arduinoclassmethod + @arduinoobjectmethod def printString(self, value): pass - @arduinoclassmethod + @arduinoobjectmethod def setCursor(self, col, row): pass diff --git a/nanpy/onewire.py b/nanpy/onewire.py index 86e4369..36f191a 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoclassmethod +from nanpy.arduinoboard import arduinoobjectmethod class OneWireAddress(): @@ -27,15 +27,15 @@ def select(self, address): def read(self): return int(self.call('read')) - @arduinoclassmethod + @arduinoobjectmethod def reset_search(self): pass - @arduinoclassmethod + @arduinoobjectmethod def reset(self): pass - @arduinoclassmethod + @arduinoobjectmethod def write(self, address, value=None): pass From 964fed13d215c890ca95d3a6e439844be046ae0b Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 28 Sep 2012 00:28:40 +0200 Subject: [PATCH 030/344] Woooh minfixes to improve speed --- nanpy/arduinoboard.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 0c9eb6d..f4229bc 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -40,9 +40,6 @@ def _call(namespace, id, args): mutex.release() return ret -def _call_static(args): - return _call(args[0], 0, args[1:]) - def arduinoobjectmethod(funct, *args, **kwargs): def wrapper(self, *args, **kwargs): call_pars = [funct.__name__] @@ -52,13 +49,13 @@ def wrapper(self, *args, **kwargs): def arduinoclassmethod(funct, *args, **kwargs): def wrapper(cls, *args, **kwargs): - call_pars = [cls.__name__, funct.__name__] + call_pars = [funct.__name__] call_pars.extend(args) - return _call_static(call_pars) + return _call(cls.__name__, 0, call_pars) return wrapper def call_static_method(*args): - return _call_static(args) + return _call(args[0], 0, args[1:]) class ArduinoObject(): From c6ba5d871a951ab19e26bfacc31d985cd1ec5ad6 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 28 Sep 2012 00:58:13 +0200 Subject: [PATCH 031/344] Constants added --- README.md | 4 ++-- examples/blink.py | 2 +- nanpy/arduino.py | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b56b79a..a3b3a30 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Description Use Python for developing prototypes for your Arduino board! Let's start with a classic example, turn on a led place in 13th pin.. - Arduino.pinMode(13, 1) - Arduino.digitalWrite(13, 1) + Arduino.pinMode(13, Arduino.OUTPUT) + Arduino.digitalWrite(13, Arduino.HIGH) There are a lot of projects able to do that. Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. diff --git a/examples/blink.py b/examples/blink.py index 7347902..438cdc7 100755 --- a/examples/blink.py +++ b/examples/blink.py @@ -6,7 +6,7 @@ from nanpy import Arduino -Arduino.pinMode(13, 1) +Arduino.pinMode(13, Arduino.OUTPUT) for i in range(10000): Arduino.digitalWrite(13, (i + 1) % 2) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index f9c405c..4fdbd9b 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -3,6 +3,11 @@ class Arduino(): + HIGH = 1 + LOW = 0 + INPUT = 0 + OUTPUT = 1 + @classmethod @arduinoclassmethod def digitalWrite(cls, pin, value): From c842f06e415aabe29fb18f50b0bfbd0b3abff566 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 28 Sep 2012 01:01:48 +0200 Subject: [PATCH 032/344] Grammatical minfix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3b3a30..5e2f1cd 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Description ----------- Use Python for developing prototypes for your Arduino board! -Let's start with a classic example, turn on a led place in 13th pin.. +Let's start with a classic example, turn on a led placed in 13th pin.. Arduino.pinMode(13, Arduino.OUTPUT) Arduino.digitalWrite(13, Arduino.HIGH) From 2124dbf159ff6e4ed35a2cb78e9e2a32d4d7c28a Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 28 Sep 2012 01:02:25 +0200 Subject: [PATCH 033/344] Grammatical minfix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e2f1cd..7a3364f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Description ----------- Use Python for developing prototypes for your Arduino board! -Let's start with a classic example, turn on a led placed in 13th pin.. +Let's start with a classic example, turn on a led placed in the 13th pin.. Arduino.pinMode(13, Arduino.OUTPUT) Arduino.digitalWrite(13, Arduino.HIGH) From e00e8b448a3aa19e844fccc5345cadd6fa9a61e2 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 28 Sep 2012 15:27:54 +0200 Subject: [PATCH 034/344] Stepper support added --- examples/stepper.py | 17 +++++++++++++++++ firmware/Nanpy.ino | 2 ++ firmware/StepperClass.cpp | 36 ++++++++++++++++++++++++++++++++++++ firmware/StepperClass.h | 26 ++++++++++++++++++++++++++ nanpy/__init__.py | 1 + nanpy/stepper.py | 16 ++++++++++++++++ 6 files changed, 98 insertions(+) create mode 100755 examples/stepper.py create mode 100644 firmware/StepperClass.cpp create mode 100644 firmware/StepperClass.h create mode 100644 nanpy/stepper.py diff --git a/examples/stepper.py b/examples/stepper.py new file mode 100755 index 0000000..a6372e1 --- /dev/null +++ b/examples/stepper.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: just a test for Stepper module +# Dependencies: None + +from nanpy import Stepper +from nanpy import Arduino + +motor = Stepper(100, 9 , 10) + +motor.setSpeed(10000) + +while True: + motor.step(-10) + Arduino.delay(1000) + diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index ec69b67..44db3fd 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -4,6 +4,7 @@ #include "ArduinoSingle.h" #include "OneWireClass.h" #include "LiquidCrystalClass.h" +#include "StepperClass.h" #include "MethodDescriptor.h" #include "Utilities.h" #include "SlimArray.h" @@ -37,6 +38,7 @@ void setup() { classes.insert(ArduinoSingle::getInstance()); classes.insert(new OneWireClass()); classes.insert(new LiquidCrystalClass()); + classes.insert(new StepperClass()); Serial.begin(9600); while (Serial.available() <= 0) { delay(300); diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp new file mode 100644 index 0000000..2df3eb7 --- /dev/null +++ b/firmware/StepperClass.cpp @@ -0,0 +1,36 @@ +#include +#include +#include "StepperClass.h" +#include "MethodDescriptor.h" +#include + +StepperClass::StepperClass():v(2) { + +}; + +void StepperClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "Stepper") == 0) { + + if (strcmp(m->getName(),"new") == 0) { + int prm = 0; + v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); + Serial.println(v.getLastIndex()); + } + + if (strcmp(m->getName(), "setSpeed") == 0) { + v[m->getObjectId()]->setSpeed(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "step") == 0) { + v[m->getObjectId()]->step(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "remove") == 0) { + v.remove(m->getObjectId()); + Serial.println("0"); + } + + } +}; diff --git a/firmware/StepperClass.h b/firmware/StepperClass.h new file mode 100644 index 0000000..6e0da50 --- /dev/null +++ b/firmware/StepperClass.h @@ -0,0 +1,26 @@ +#ifndef STEPPER_CLASS +#define STEPPER_CLASS + +#include +#include "SlimArray.h" +#include "ArduinoClass.h" + +class Stepper; +class MethodDescriptor; + +char* readStringFromSerial(); + +class StepperClass: public ArduinoClass { + + private: + + SlimArray v; + + public: + + StepperClass(); + void elaborate( MethodDescriptor* m ); + +}; + +#endif diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 1115511..9d2838c 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -16,3 +16,4 @@ from nanpy.arduino import Arduino from nanpy.lcd import Lcd from nanpy.onewire import OneWire +from nanpy.stepper import Stepper diff --git a/nanpy/stepper.py b/nanpy/stepper.py new file mode 100644 index 0000000..f821e44 --- /dev/null +++ b/nanpy/stepper.py @@ -0,0 +1,16 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoobjectmethod + +class Stepper(ArduinoObject): + + def __init__(self, revsteps, pin1, pin2): + ArduinoObject.__init__(self) + self.id = self.call('new', revsteps, pin1, pin2) + + @arduinoobjectmethod + def setSpeed(self, value): + pass + + @arduinoobjectmethod + def step(self, value): + pass From 6f3086b32a9b848435896ea1fef1202b1a83e0fd Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 28 Sep 2012 17:18:57 +0200 Subject: [PATCH 035/344] README updated --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a3364f..ad06509 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Nanpy ===== -Program your Arduino prototypes using Python. +Program your Arduino prototypes using Python, also using a Raspberry!! Description ----------- From 04dcb6b246472685a2b3dc424785c2efae956c98 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 28 Sep 2012 17:20:17 +0200 Subject: [PATCH 036/344] README updated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad06509..6d06390 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ really straightforward now, isn't it? :) How to build and install ------------------------ -Nanpy is composed by a Python part, that provides a library to use Arduino via Python and a server firmware. +Nanpy is composed by a Python part, that provides a library to use Arduino via Python and a server firmware. You can install Nanpy on a Raspberry too :) -To install Nanpy just type (as root): +To install Nanpy just type (as root, requires python-setuptools): python setup.py install From 7d6f532bf2b9488a2a1e97021f3a2eb3c3117e97 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sat, 29 Sep 2012 00:41:56 +0200 Subject: [PATCH 037/344] Set a different baud rate for the Arduino part --- README.md | 4 ++++ firmware/Makefile | 6 ++++++ firmware/Nanpy.ino | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d06390..0ba1f2c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,10 @@ and then upload it on your board: make upload +Optionally you can also set the baud rate: + + export BAUDRATE=115200 (default value is 9600) + How to use ---------- diff --git a/firmware/Makefile b/firmware/Makefile index 050a9d7..42bef39 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -249,6 +249,12 @@ CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) +ifdef DEBUG +CPPFLAGS += -DDEBUG=$(DEBUG) +endif +ifdef BAUDRATE +CPPFLAGS += -DBAUDRATE=$(BAUDRATE) +endif CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES)) diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 44db3fd..f9ed180 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -9,6 +9,10 @@ #include "Utilities.h" #include "SlimArray.h" +#ifndef BAUDRATE + #define BAUDRATE 9600 +#endif + SlimArray classes(2); int pin, value; @@ -39,7 +43,7 @@ void setup() { classes.insert(new OneWireClass()); classes.insert(new LiquidCrystalClass()); classes.insert(new StepperClass()); - Serial.begin(9600); + Serial.begin(BAUDRATE); while (Serial.available() <= 0) { delay(300); } From 0a57679796da2c7ac4f0e9f783edb24a6322e169 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 01:35:28 +0200 Subject: [PATCH 038/344] Servo support added --- firmware/Nanpy.ino | 2 ++ firmware/ServoClass.cpp | 48 +++++++++++++++++++++++++++++++++++++++++ firmware/ServoClass.h | 26 ++++++++++++++++++++++ nanpy/__init__.py | 1 + nanpy/servo.py | 27 +++++++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 firmware/ServoClass.cpp create mode 100644 firmware/ServoClass.h create mode 100644 nanpy/servo.py diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index f9ed180..63ef6f5 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -5,6 +5,7 @@ #include "OneWireClass.h" #include "LiquidCrystalClass.h" #include "StepperClass.h" +#include "ServoClass.h" #include "MethodDescriptor.h" #include "Utilities.h" #include "SlimArray.h" @@ -43,6 +44,7 @@ void setup() { classes.insert(new OneWireClass()); classes.insert(new LiquidCrystalClass()); classes.insert(new StepperClass()); + classes.insert(new ServoClass()); Serial.begin(BAUDRATE); while (Serial.available() <= 0) { delay(300); diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp new file mode 100644 index 0000000..4803d55 --- /dev/null +++ b/firmware/ServoClass.cpp @@ -0,0 +1,48 @@ +#include +#include +#include "ServoClass.h" +#include "MethodDescriptor.h" +#include + +ServoClass::ServoClass():v(2) { + +}; + +void ServoClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "Servo") == 0) { + + if (strcmp(m->getName(),"new") == 0) { + v.insert(new Servo()); + v[v.getLastIndex()]->attach(m->getInt(0)); + Serial.println(v.getLastIndex()); + } + + if (strcmp(m->getName(), "write") == 0) { + v[m->getObjectId()]->write(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "read") == 0) { + Serial.println(v[m->getObjectId()]->read()); + } + + if (strcmp(m->getName(), "writeMicroseconds") == 0) { + v[m->getObjectId()]->writeMicroseconds(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "readMicroseconds") == 0) { + Serial.println(v[m->getObjectId()]->readMicroseconds()); + } + + if (strcmp(m->getName(), "detach") == 0) { + v[m->getObjectId()]->detach(); + Serial.println("0"); + } + + if (strcmp(m->getName(), "attached") == 0) { + Serial.println(v[m->getObjectId()]->attached()); + } + + } +}; diff --git a/firmware/ServoClass.h b/firmware/ServoClass.h new file mode 100644 index 0000000..b2fdcac --- /dev/null +++ b/firmware/ServoClass.h @@ -0,0 +1,26 @@ +#ifndef SERVO_CLASS +#define SERVO_CLASS + +#include +#include "SlimArray.h" +#include "ArduinoClass.h" + +class Servo; +class MethodDescriptor; + +char* readStringFromSerial(); + +class ServoClass: public ArduinoClass { + + private: + + SlimArray v; + + public: + + ServoClass(); + void elaborate( MethodDescriptor* m ); + +}; + +#endif diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 9d2838c..c08fd56 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -17,3 +17,4 @@ from nanpy.lcd import Lcd from nanpy.onewire import OneWire from nanpy.stepper import Stepper +from nanpy.stepper import Servo diff --git a/nanpy/servo.py b/nanpy/servo.py new file mode 100644 index 0000000..50ab353 --- /dev/null +++ b/nanpy/servo.py @@ -0,0 +1,27 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoobjectmethod + +class Servo(ArduinoObject): + + def __init__(self, pin) + self.id = self.call('new', pin) + + @arduinoobjectmethod + def write(self, value): + pass + + @arduinoobjectmethod + def read(self): + pass + + @arduinoobjectmethod + def writeMicroseconds(self, value): + pass + + @arduinoobjectmethod + def readMicroseconds(self, value): + pass + + @arduinoobjectmethod + def attached(self): + pass From e032c4ac1185ac70e86a84c35424d001ced1af0f Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 02:14:19 +0200 Subject: [PATCH 039/344] README updated --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ba1f2c..836c497 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Let's start with a classic example, turn on a led placed in the 13th pin.. There are a lot of projects able to do that. Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. -We started supporting OneWire, Lcd and Servo library and they're still incomplete. +We started supporting OneWire, Lcd, Stepper and Servo library and they're still incomplete. Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print something! lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) @@ -22,6 +22,20 @@ Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print s really straightforward now, isn't it? :) +Dependencies +------------ + +- Python + + python-setuptools + python-serial + +- Arduino + + OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html + +NOTE: Nanpy uses both built-in and third-party libraries, such as OneWire and DallasTemperature. We assume that they're installed in the Arduino's "libraries" folder, for example in Ubuntu you can find it in /usr/share/arduino by default. + How to build and install ------------------------ From be0dfa02f5942197aac6424816d86f3a73467563 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 02:16:27 +0200 Subject: [PATCH 040/344] README updated --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 836c497..5890551 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ Nanpy ===== -Program your Arduino prototypes using Python, also using a Raspberry!! +Program your Arduino prototypes using Python. Description ----------- -Use Python for developing prototypes for your Arduino board! +The main purpose of Nanpy is making programmers' life easier, giving them something to create prototypes faster and use Arduino in a simpler way, thanks to a powerful language like Python. Also Nanpy can run on RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use it for communicating with Arduino :) + Let's start with a classic example, turn on a led placed in the 13th pin.. Arduino.pinMode(13, Arduino.OUTPUT) @@ -25,16 +26,16 @@ really straightforward now, isn't it? :) Dependencies ------------ -- Python +#### Python python-setuptools python-serial -- Arduino +#### Arduino OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html -NOTE: Nanpy uses both built-in and third-party libraries, such as OneWire and DallasTemperature. We assume that they're installed in the Arduino's "libraries" folder, for example in Ubuntu you can find it in /usr/share/arduino by default. +NOTE: Nanpy uses both built-in and third-party libraries, such as OneWire and DallasTemperature. We assume that you install them in the Arduino's "libraries" folder, for example in Ubuntu you can find it in /usr/share/arduino by default. How to build and install ------------------------ @@ -77,6 +78,11 @@ Import all the modules you need :) from nanpy import (OneWire, Lcd) ... +How to contribute +----------------- + +Nanpy needs a lot of work to be a great instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at + License ------- From b8f5ff503b4a251ae6d8ec71db7bb0fefe952d06 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 02:18:56 +0200 Subject: [PATCH 041/344] Minfix importing Servo --- nanpy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index c08fd56..8bbcb45 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -17,4 +17,4 @@ from nanpy.lcd import Lcd from nanpy.onewire import OneWire from nanpy.stepper import Stepper -from nanpy.stepper import Servo +from nanpy.servo import Servo From b5c7e6515885287224ac0de18bda8b490ccacf24 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 02:44:13 +0200 Subject: [PATCH 042/344] A simple method to make Nanpy failing smoothly in case Arduino is not found --- nanpy/serialmanager.py | 20 ++++++++++++++++++-- nanpy/servo.py | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 3f9c88d..62a7ec6 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -19,12 +19,28 @@ def _auto_detect_serial_unix(preferred_list=['*']): ret.append(d) return ret +class NoneSerialManager(object): + + def write(self, val): + pass + + def read(self): + return "" + + def readline(self): + return "" + + class SerialManager(object): def __init__(self): available_ports = _auto_detect_serial_unix() - self.__serial = serial.Serial(available_ports[0], 9600, timeout=1) - time.sleep(2) + try: + self.__serial = serial.Serial(available_ports[0], 9600, timeout=1) + time.sleep(2) + except: + print "Error trying to connect to Arduino" + self.__serial = NoneSerialManager() def connect(self, device, baud): self.__serial = serial.Serial(device, baud) diff --git a/nanpy/servo.py b/nanpy/servo.py index 50ab353..f2fa09f 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -3,7 +3,7 @@ class Servo(ArduinoObject): - def __init__(self, pin) + def __init__(self, pin): self.id = self.call('new', pin) @arduinoobjectmethod From e50be869a6c13753c712823103e771b75f3e993f Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 14:01:31 +0200 Subject: [PATCH 043/344] Dallas Temperature initial support added --- firmware/DallasTemperatureClass.cpp | 48 +++++++++++++++++++++++++++++ firmware/DallasTemperatureClass.h | 26 ++++++++++++++++ firmware/Nanpy.ino | 2 ++ nanpy/__init__.py | 1 + nanpy/dallastemperature.py | 24 +++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 firmware/DallasTemperatureClass.cpp create mode 100644 firmware/DallasTemperatureClass.h create mode 100644 nanpy/dallastemperature.py diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp new file mode 100644 index 0000000..addcd76 --- /dev/null +++ b/firmware/DallasTemperatureClass.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include "DallasTemperatureClass.h" +#include "MethodDescriptor.h" +#include + +DallasTemperatureClass::DallasTemperatureClass():v(2) { + +}; + +void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "DallasTemperature") == 0) { + + if (strcmp(m->getName(),"new") == 0) { + int prm = 0; + OneWire* wr = new OneWire(m->getInt(0)); + v.insert(new DallasTemperature(&(*wr))); + Serial.println(v.getLastIndex()); + } + + if (strcmp(m->getName(), "begin") == 0) { + v[m->getObjectId()]->begin(); + Serial.println("0"); + } + + if (strcmp(m->getName(), "requestTemperatures") == 0) { + v[m->getObjectId()]->requestTemperatures(); + Serial.println("0"); + } + + if (strcmp(m->getName(), "getTempCByIndex") == 0) { + v[m->getObjectId()]->getTempCByIndex(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "getTempFByIndex") == 0) { + v[m->getObjectId()]->getTempFByIndex(m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "remove") == 0) { + v.remove(m->getObjectId()); + Serial.println("0"); + } + + } +}; diff --git a/firmware/DallasTemperatureClass.h b/firmware/DallasTemperatureClass.h new file mode 100644 index 0000000..4b6c269 --- /dev/null +++ b/firmware/DallasTemperatureClass.h @@ -0,0 +1,26 @@ +#ifndef DALLAS_TEMP_CLASS +#define DALLAS_TEMP_CLASS + +#include +#include "SlimArray.h" +#include "ArduinoClass.h" + +class DallasTemperature; +class MethodDescriptor; + +char* readStringFromSerial(); + +class DallasTemperatureClass: public ArduinoClass { + + private: + + SlimArray v; + + public: + + DallasTemperatureClass(); + void elaborate( MethodDescriptor* m ); + +}; + +#endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 63ef6f5..f38d8c8 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -6,6 +6,7 @@ #include "LiquidCrystalClass.h" #include "StepperClass.h" #include "ServoClass.h" +#include "DallasTemperatureClass.h" #include "MethodDescriptor.h" #include "Utilities.h" #include "SlimArray.h" @@ -45,6 +46,7 @@ void setup() { classes.insert(new LiquidCrystalClass()); classes.insert(new StepperClass()); classes.insert(new ServoClass()); + classes.insert(new DallasTemperatureClass()); Serial.begin(BAUDRATE); while (Serial.available() <= 0) { delay(300); diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 8bbcb45..d87e54b 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -18,3 +18,4 @@ from nanpy.onewire import OneWire from nanpy.stepper import Stepper from nanpy.servo import Servo +from nanpy.dallastemperature import DallasTemperature diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py new file mode 100644 index 0000000..d1e751d --- /dev/null +++ b/nanpy/dallastemperature.py @@ -0,0 +1,24 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoobjectmethod + +class DallasTemperature(ArduinoObject): + + def __init__(self, pin): + ArduinoObject.__init__(self) + self.id = self.call('new', pin) + + @arduinoobjectmethod + def begin(self): + pass + + @arduinoobjectmethod + def requestTemperatures(self): + pass + + @arduinoobjectmethod + def getTempCByIndex(self, index): + pass + + @arduinoobjectmethod + def getTempFByIndex(self, index): + pass From c4c95f599dc694c1b182ae2cd56e0391e9dbca75 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 14:04:02 +0200 Subject: [PATCH 044/344] Delete object omitted --- firmware/DallasTemperatureClass.cpp | 1 + firmware/LiquidCrystalClass.cpp | 1 + firmware/OneWireClass.cpp | 1 + firmware/ServoClass.cpp | 6 ++++++ firmware/StepperClass.cpp | 1 + 5 files changed, 10 insertions(+) diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index addcd76..a895d7b 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -40,6 +40,7 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); v.remove(m->getObjectId()); Serial.println("0"); } diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index ec97329..e13b68f 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -30,6 +30,7 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); v.remove(m->getObjectId()); Serial.println("0"); } diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index 49f086c..3f08eb5 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -70,6 +70,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); v.remove(m->getObjectId()); Serial.println("0"); } diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index 4803d55..119c3bf 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -44,5 +44,11 @@ void ServoClass::elaborate( MethodDescriptor* m ) { Serial.println(v[m->getObjectId()]->attached()); } + if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); + v.remove(m->getObjectId()); + Serial.println("0"); + } + } }; diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 2df3eb7..a3ea2f7 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -28,6 +28,7 @@ void StepperClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); v.remove(m->getObjectId()); Serial.println("0"); } From a26815fcb50cf854260689881d18f59c827d6ca8 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 14:19:18 +0200 Subject: [PATCH 045/344] Added an example for Dallas Temperature --- examples/dallastemperature.py | 85 +++------------------------------- examples/mytemperaturelib.py | 87 +++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 78 deletions(-) create mode 100755 examples/mytemperaturelib.py diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 7175080..3a04706 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -1,87 +1,16 @@ #!/usr/bin/env python # Author: Andrea Stagi -# Description: a fake DallasTemperature library written in Python +# Description: just a test for DallasTemperature # Dependencies: None -from nanpy import (Arduino, OneWire) -import time +from nanpy import DallasTemperature -class DallasTemperature(): +sensors = DallasTemperature(5) - def __init__(self, pin): - self.__ds = OneWire(pin) - self.__data = 0 +sensors.begin() - def __fetchAddress(self): - ds_address = self.__ds.search() - - if ds_address == "1": - return False - - self.__ds.reset() - self.__ds.select(ds_address) - self.__ds.write(0x44, 1) - Arduino.delay(700) - present = self.__ds.reset() - self.__ds.select(ds_address) - self.__ds.write(0xBE) - return True - - def __fetchData(self): - - data = [] - - for i in range(9): - val = self.__ds.read() - data.append(val) - - raw = (data[1] << 8) | data[0] - - type = 1 - - if type == 0: - - raw = raw << 3; - if data[7] == 0x10: - raw = (raw & 0xFFF0) + 12 - data[6] - - else: - cfg = (data[4] & 0x60) - - if cfg == 0x00: - raw = raw << 3 - elif cfg == 0x20: - raw = raw << 2 - elif cfg == 0x40: - raw = raw << 1 - else: - pass - - self.__data = raw - - def getCelsius(self): - if self.__fetchAddress(): - self.__fetchData() - return self.__data / 16.0 - - def getFahrenheit(self): - if self.__fetchAddress(): - self.__fetchData() - return self.getCelsius() * 1.8 + 32.0 - - -from nanpy import Lcd - -if __name__ == "__main__": - - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) - lcd.printString("Loc. London") - - temp_int = DallasTemperature(5) - temp_ext = DallasTemperature(6) - - while(1): - lcd.setCursor(0, 1) - lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) +while True: + sensors.requestTemperatures() + print sensors.getTempCByIndex(0) diff --git a/examples/mytemperaturelib.py b/examples/mytemperaturelib.py new file mode 100755 index 0000000..7175080 --- /dev/null +++ b/examples/mytemperaturelib.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: a fake DallasTemperature library written in Python +# Dependencies: None + +from nanpy import (Arduino, OneWire) +import time + +class DallasTemperature(): + + def __init__(self, pin): + self.__ds = OneWire(pin) + self.__data = 0 + + def __fetchAddress(self): + ds_address = self.__ds.search() + + if ds_address == "1": + return False + + self.__ds.reset() + self.__ds.select(ds_address) + self.__ds.write(0x44, 1) + Arduino.delay(700) + present = self.__ds.reset() + self.__ds.select(ds_address) + self.__ds.write(0xBE) + return True + + def __fetchData(self): + + data = [] + + for i in range(9): + val = self.__ds.read() + data.append(val) + + raw = (data[1] << 8) | data[0] + + type = 1 + + if type == 0: + + raw = raw << 3; + if data[7] == 0x10: + raw = (raw & 0xFFF0) + 12 - data[6] + + else: + cfg = (data[4] & 0x60) + + if cfg == 0x00: + raw = raw << 3 + elif cfg == 0x20: + raw = raw << 2 + elif cfg == 0x40: + raw = raw << 1 + else: + pass + + self.__data = raw + + def getCelsius(self): + if self.__fetchAddress(): + self.__fetchData() + return self.__data / 16.0 + + def getFahrenheit(self): + if self.__fetchAddress(): + self.__fetchData() + return self.getCelsius() * 1.8 + 32.0 + + +from nanpy import Lcd + +if __name__ == "__main__": + + lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + lcd.printString("Loc. London") + + temp_int = DallasTemperature(5) + temp_ext = DallasTemperature(6) + + while(1): + lcd.setCursor(0, 1) + lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) + From 2f897eecbf25341d132183ceb426729a2f06c685 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 14:32:40 +0200 Subject: [PATCH 046/344] Minfixes on Dallas Temperature --- firmware/DallasTemperatureClass.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index a895d7b..19c0cda 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -30,13 +30,11 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "getTempCByIndex") == 0) { - v[m->getObjectId()]->getTempCByIndex(m->getInt(0)); - Serial.println("0"); + Serial.println(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); } if (strcmp(m->getName(), "getTempFByIndex") == 0) { - v[m->getObjectId()]->getTempFByIndex(m->getInt(0)); - Serial.println("0"); + Serial.println(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); } if (strcmp(m->getName(), "remove") == 0) { From f465fe7011c269898a0f3a9858ea220e10b8a5b5 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 14:36:47 +0200 Subject: [PATCH 047/344] README update --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5890551..f3a7d11 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ Nanpy ===== -Program your Arduino prototypes using Python. +Use your Arduino board with Python. Description ----------- -The main purpose of Nanpy is making programmers' life easier, giving them something to create prototypes faster and use Arduino in a simpler way, thanks to a powerful language like Python. Also Nanpy can run on RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use it for communicating with Arduino :) +The main purpose of Nanpy is making programmers' life easier, giving them something to create prototypes faster and use Arduino in a simpler way, thanks to a simple and powerful language like Python. Also Nanpy can run on RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use it for communicating with Arduino :) Let's start with a classic example, turn on a led placed in the 13th pin.. @@ -34,6 +34,7 @@ Dependencies #### Arduino OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html + DallasTemperature http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library NOTE: Nanpy uses both built-in and third-party libraries, such as OneWire and DallasTemperature. We assume that you install them in the Arduino's "libraries" folder, for example in Ubuntu you can find it in /usr/share/arduino by default. From d766a05b978f299d69a578b8c7d5c79a94d5c0d1 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 14:40:21 +0200 Subject: [PATCH 048/344] README update --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3a7d11..7c76380 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,13 @@ Dependencies #### Python - python-setuptools - python-serial +- python-setuptools +- python-serial #### Arduino - OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html - DallasTemperature http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library +- OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html +- DallasTemperature http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library NOTE: Nanpy uses both built-in and third-party libraries, such as OneWire and DallasTemperature. We assume that you install them in the Arduino's "libraries" folder, for example in Ubuntu you can find it in /usr/share/arduino by default. From cfdfa64d1a37e77c87e825724409360501d62137 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 16:14:49 +0200 Subject: [PATCH 049/344] Minfixes --- README.md | 4 +--- firmware/DallasTemperatureClass.cpp | 2 +- firmware/LiquidCrystalClass.cpp | 2 +- firmware/Nanpy.ino | 32 +++++++++++++---------------- firmware/OneWireClass.cpp | 2 +- firmware/ServoClass.cpp | 2 +- firmware/StepperClass.cpp | 2 +- 7 files changed, 20 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 7c76380..ffb4a4f 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,11 @@ really straightforward now, isn't it? :) Dependencies ------------ -#### Python - +#### Python (2.2 or later) - python-setuptools - python-serial #### Arduino - - OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html - DallasTemperature http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 19c0cda..3108df6 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -5,7 +5,7 @@ #include "MethodDescriptor.h" #include -DallasTemperatureClass::DallasTemperatureClass():v(2) { +DallasTemperatureClass::DallasTemperatureClass():v(0) { }; diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index e13b68f..f207f19 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -4,7 +4,7 @@ #include "MethodDescriptor.h" #include -LiquidCrystalClass::LiquidCrystalClass():v(2) { +LiquidCrystalClass::LiquidCrystalClass():v(0) { }; diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index f38d8c8..0ac9b09 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -21,7 +21,20 @@ int pin, value; MethodDescriptor *m = NULL; -void elaborate() +void setup() { + classes.insert(ArduinoSingle::getInstance()); + classes.insert(new OneWireClass()); + classes.insert(new LiquidCrystalClass()); + classes.insert(new StepperClass()); + classes.insert(new ServoClass()); + classes.insert(new DallasTemperatureClass()); + Serial.begin(BAUDRATE); + while (Serial.available() <= 0) { + delay(300); + } +} + +void loop() { if(m != NULL) { @@ -40,21 +53,4 @@ void elaborate() } -void setup() { - classes.insert(ArduinoSingle::getInstance()); - classes.insert(new OneWireClass()); - classes.insert(new LiquidCrystalClass()); - classes.insert(new StepperClass()); - classes.insert(new ServoClass()); - classes.insert(new DallasTemperatureClass()); - Serial.begin(BAUDRATE); - while (Serial.available() <= 0) { - delay(300); - } -} - -void loop(){ - elaborate(); -} - diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index 3f08eb5..3000fe3 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -3,7 +3,7 @@ #include "MethodDescriptor.h" #include -OneWireClass::OneWireClass():v(2) { +OneWireClass::OneWireClass():v(0) { }; diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index 119c3bf..01aa179 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -4,7 +4,7 @@ #include "MethodDescriptor.h" #include -ServoClass::ServoClass():v(2) { +ServoClass::ServoClass():v(0) { }; diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index a3ea2f7..73acfd8 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -4,7 +4,7 @@ #include "MethodDescriptor.h" #include -StepperClass::StepperClass():v(2) { +StepperClass::StepperClass():v(0) { }; From 0d5274ef310d60a242ce2dfe3e8b8538213ade84 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 17:19:32 +0200 Subject: [PATCH 050/344] Tone support added --- examples/melody.py | 17 ++++++ firmware/Nanpy.ino | 2 + firmware/ToneClass.cpp | 36 +++++++++++ firmware/ToneClass.h | 133 +++++++++++++++++++++++++++++++++++++++++ nanpy/__init__.py | 1 + nanpy/tone.py | 106 ++++++++++++++++++++++++++++++++ 6 files changed, 295 insertions(+) create mode 100755 examples/melody.py create mode 100644 firmware/ToneClass.cpp create mode 100644 firmware/ToneClass.h create mode 100644 nanpy/tone.py diff --git a/examples/melody.py b/examples/melody.py new file mode 100755 index 0000000..6d1509a --- /dev/null +++ b/examples/melody.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: play a melody +# Dependencies: None + +from nanpy import Tone + +melody = [[Tone.NOTE_C4, 4], [Tone.NOTE_G3, 8], [Tone.NOTE_G3, 8], + [Tone.NOTE_A3, 4], [Tone.NOTE_G3, 4], [0, 4], + [Tone.NOTE_B3, 4], [Tone.NOTE_C4, 4]] + +tone = Tone(8) + +for note in melody: + tone.play(note[0] , 1000/note[1]); + diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 0ac9b09..f802306 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -7,6 +7,7 @@ #include "StepperClass.h" #include "ServoClass.h" #include "DallasTemperatureClass.h" +#include "ToneClass.h" #include "MethodDescriptor.h" #include "Utilities.h" #include "SlimArray.h" @@ -28,6 +29,7 @@ void setup() { classes.insert(new StepperClass()); classes.insert(new ServoClass()); classes.insert(new DallasTemperatureClass()); + classes.insert(new ToneClass()); Serial.begin(BAUDRATE); while (Serial.available() <= 0) { delay(300); diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp new file mode 100644 index 0000000..141ac55 --- /dev/null +++ b/firmware/ToneClass.cpp @@ -0,0 +1,36 @@ +#include +#include +#include "ToneClass.h" +#include "MethodDescriptor.h" +#include + +ToneClass::ToneClass():v(0) { + +}; + +void ToneClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "Tone") == 0) { + + if (strcmp(m->getName(),"new") == 0) { + v.insert(new Tone (m->getInt(0))); + Serial.println(v.getLastIndex()); + } + + if (strcmp(m->getName(), "play") == 0) { + v[m->getObjectId()]->play(m->getInt(0), m->getInt(0)); + Serial.println("0"); + } + + if (strcmp(m->getName(), "stop") == 0) { + v[m->getObjectId()]->stop(); + Serial.println("0"); + } + + if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); + v.remove(m->getObjectId()); + Serial.println("0"); + } + + } +}; diff --git a/firmware/ToneClass.h b/firmware/ToneClass.h new file mode 100644 index 0000000..f9b64cd --- /dev/null +++ b/firmware/ToneClass.h @@ -0,0 +1,133 @@ +#ifndef TONE_CLASS +#define TONE_CLASS + +#include +#include "SlimArray.h" +#include "ArduinoClass.h" + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 + +class MethodDescriptor; + +class Tone { + + private: + + int pin; + + public: + + Tone(int pin) : pin(pin) {} + void play(int note, int duration) { + tone(pin, note, duration); + delay(duration * 1.30); + noTone(pin); + } + void stop(void) {noTone(pin);} + +}; + +char* readStringFromSerial(); + +class ToneClass: public ArduinoClass { + + private: + + SlimArray v; + + public: + + ToneClass(); + void elaborate( MethodDescriptor* m ); + +}; + +#endif diff --git a/nanpy/__init__.py b/nanpy/__init__.py index d87e54b..1af1e89 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -19,3 +19,4 @@ from nanpy.stepper import Stepper from nanpy.servo import Servo from nanpy.dallastemperature import DallasTemperature +from nanpy.tone import Tone diff --git a/nanpy/tone.py b/nanpy/tone.py new file mode 100644 index 0000000..c887641 --- /dev/null +++ b/nanpy/tone.py @@ -0,0 +1,106 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoobjectmethod + +class Tone(ArduinoObject): + + NOTE_B0 = 31 + NOTE_C1 = 33 + NOTE_CS1 = 35 + NOTE_D1 = 37 + NOTE_DS1 = 39 + NOTE_E1 = 41 + NOTE_F1 = 44 + NOTE_FS1 = 46 + NOTE_G1 = 49 + NOTE_GS1 = 52 + NOTE_A1 = 55 + NOTE_AS1 = 58 + NOTE_B1 = 62 + NOTE_C2 = 65 + NOTE_CS2 = 69 + NOTE_D2 = 73 + NOTE_DS2 = 78 + NOTE_E2 = 82 + NOTE_F2 = 87 + NOTE_FS2 = 93 + NOTE_G2 = 98 + NOTE_GS2 = 104 + NOTE_A2 = 110 + NOTE_AS2 = 117 + NOTE_B2 = 123 + NOTE_C3 = 131 + NOTE_CS3 = 139 + NOTE_D3 = 147 + NOTE_DS3 = 156 + NOTE_E3 = 165 + NOTE_F3 = 175 + NOTE_FS3 = 185 + NOTE_G3 = 196 + NOTE_GS3 = 208 + NOTE_A3 = 220 + NOTE_AS3 = 233 + NOTE_B3 = 247 + NOTE_C4 = 262 + NOTE_CS4 = 277 + NOTE_D4 = 294 + NOTE_DS4 = 311 + NOTE_E4 = 330 + NOTE_F4 = 349 + NOTE_FS4 = 370 + NOTE_G4 = 392 + NOTE_GS4 = 415 + NOTE_A4 = 440 + NOTE_AS4 = 466 + NOTE_B4 = 494 + NOTE_C5 = 523 + NOTE_CS5 = 554 + NOTE_D5 = 587 + NOTE_DS5 = 622 + NOTE_E5 = 659 + NOTE_F5 = 698 + NOTE_FS5 = 740 + NOTE_G5 = 784 + NOTE_GS5 = 831 + NOTE_A5 = 880 + NOTE_AS5 = 932 + NOTE_B5 = 988 + NOTE_C6 = 1047 + NOTE_CS6 = 1109 + NOTE_D6 = 1175 + NOTE_DS6 = 1245 + NOTE_E6 = 1319 + NOTE_F6 = 1397 + NOTE_FS6 = 1480 + NOTE_G6 = 1568 + NOTE_GS6 = 1661 + NOTE_A6 = 1760 + NOTE_AS6 = 1865 + NOTE_B6 = 1976 + NOTE_C7 = 2093 + NOTE_CS7 = 2217 + NOTE_D7 = 2349 + NOTE_DS7 = 2489 + NOTE_E7 = 2637 + NOTE_F7 = 2794 + NOTE_FS7 = 2960 + NOTE_G7 = 3136 + NOTE_GS7 = 3322 + NOTE_A7 = 3520 + NOTE_AS7 = 3729 + NOTE_B7 = 3951 + NOTE_C8 = 4186 + NOTE_CS8 = 4435 + NOTE_D8 = 4699 + NOTE_DS8 = 4978 + + def __init__(self, pin): + ArduinoObject.__init__(self) + self.id = self.call('new', pin) + + @arduinoobjectmethod + def play(self, note, duration): + pass + + @arduinoobjectmethod + def stop(self): + pass From b7dbc118578c760b90adfa26266cb390da070a76 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Sep 2012 17:33:58 +0200 Subject: [PATCH 051/344] Minfixes to melody example --- examples/melody.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/melody.py b/examples/melody.py index 6d1509a..3e1e382 100755 --- a/examples/melody.py +++ b/examples/melody.py @@ -10,8 +10,8 @@ [Tone.NOTE_A3, 4], [Tone.NOTE_G3, 4], [0, 4], [Tone.NOTE_B3, 4], [Tone.NOTE_C4, 4]] -tone = Tone(8) +tone = Tone(13) for note in melody: - tone.play(note[0] , 1000/note[1]); + tone.play(note[0] , 1000/note[1]) From 1e6740801e901bf06d8b9d2b55d21cfa76fc9ee3 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 1 Oct 2012 08:34:01 +0200 Subject: [PATCH 052/344] An initial semplification of python interface --- examples/clock.py | 6 ++---- examples/dallastemperature.py | 2 -- examples/stepper.py | 4 +--- firmware/DallasTemperatureClass.cpp | 9 +++------ nanpy/dallastemperature.py | 4 ---- nanpy/lcd.py | 5 +++++ nanpy/stepper.py | 4 +++- 7 files changed, 14 insertions(+), 20 deletions(-) diff --git a/examples/clock.py b/examples/clock.py index 50c54e9..5db1e50 100755 --- a/examples/clock.py +++ b/examples/clock.py @@ -16,13 +16,11 @@ lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) while (1): - lcd.setCursor(0, 0) - lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) - lcd.setCursor(0, 1) + lcd.printString(0, 0, (datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) if time % 2: time_format = '%H:%M' else: time_format = '%H %M' - lcd.printString((datetime.fromtimestamp(time)).strftime(time_format)) + lcd.printString(0, 1, (datetime.fromtimestamp(time)).strftime(time_format)) Arduino.delay(1000) time += 1 diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 3a04706..6e816f5 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -8,8 +8,6 @@ sensors = DallasTemperature(5) -sensors.begin() - while True: sensors.requestTemperatures() print sensors.getTempCByIndex(0) diff --git a/examples/stepper.py b/examples/stepper.py index a6372e1..ad92db5 100755 --- a/examples/stepper.py +++ b/examples/stepper.py @@ -7,9 +7,7 @@ from nanpy import Stepper from nanpy import Arduino -motor = Stepper(100, 9 , 10) - -motor.setSpeed(10000) +motor = Stepper(100, 9 , 10, 1000) while True: motor.step(-10) diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 3108df6..beaa69d 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -15,15 +15,12 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(),"new") == 0) { int prm = 0; OneWire* wr = new OneWire(m->getInt(0)); - v.insert(new DallasTemperature(&(*wr))); + DallasTemperature* dt = new DallasTemperature(&(*wr)); + v.insert(dt); + dt->begin(); Serial.println(v.getLastIndex()); } - if (strcmp(m->getName(), "begin") == 0) { - v[m->getObjectId()]->begin(); - Serial.println("0"); - } - if (strcmp(m->getName(), "requestTemperatures") == 0) { v[m->getObjectId()]->requestTemperatures(); Serial.println("0"); diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index d1e751d..3505356 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -7,10 +7,6 @@ def __init__(self, pin): ArduinoObject.__init__(self) self.id = self.call('new', pin) - @arduinoobjectmethod - def begin(self): - pass - @arduinoobjectmethod def requestTemperatures(self): pass diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 179a091..7b26f4e 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -11,6 +11,11 @@ def __init__(self, pins, begin): def printString(self, value): pass + def printString(self, col, row, value): + self.setCursor(col, row) + self.printString(value) + pass + @arduinoobjectmethod def setCursor(self, col, row): pass diff --git a/nanpy/stepper.py b/nanpy/stepper.py index f821e44..b674526 100644 --- a/nanpy/stepper.py +++ b/nanpy/stepper.py @@ -3,9 +3,11 @@ class Stepper(ArduinoObject): - def __init__(self, revsteps, pin1, pin2): + def __init__(self, revsteps, pin1, pin2, speed=None): ArduinoObject.__init__(self) self.id = self.call('new', revsteps, pin1, pin2) + if speed: + self.setSpeed(speed) @arduinoobjectmethod def setSpeed(self, value): From c5a50f963e5bc62b544d7f224c453024a9ea8825 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 1 Oct 2012 17:18:56 +0200 Subject: [PATCH 053/344] First heavy refactoring --- examples/clock.py | 8 ++- .../{ArduinoSingle.cpp => ArduinoClass.cpp} | 16 +----- firmware/ArduinoClass.h | 10 ++-- firmware/ArduinoSingle.h | 25 -------- firmware/BaseClass.h | 57 +++++++++++++++++++ firmware/DallasTemperatureClass.cpp | 7 +-- firmware/DallasTemperatureClass.h | 14 +---- firmware/LiquidCrystalClass.cpp | 14 +---- firmware/LiquidCrystalClass.h | 16 ++---- firmware/Nanpy.ino | 45 +++++---------- firmware/OneWireClass.cpp | 6 +- firmware/OneWireClass.h | 13 +---- firmware/ServoClass.cpp | 6 +- firmware/ServoClass.h | 14 +---- firmware/StepperClass.cpp | 6 +- firmware/StepperClass.h | 14 +---- firmware/ToneClass.cpp | 7 +-- firmware/ToneClass.h | 14 +---- nanpy/lcd.py | 5 -- 19 files changed, 112 insertions(+), 185 deletions(-) rename firmware/{ArduinoSingle.cpp => ArduinoClass.cpp} (76%) delete mode 100644 firmware/ArduinoSingle.h create mode 100644 firmware/BaseClass.h diff --git a/examples/clock.py b/examples/clock.py index 5db1e50..c89ab36 100755 --- a/examples/clock.py +++ b/examples/clock.py @@ -16,11 +16,13 @@ lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) while (1): - lcd.printString(0, 0, (datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) + lcd.setCursor(0, 0) + lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) if time % 2: time_format = '%H:%M' else: - time_format = '%H %M' - lcd.printString(0, 1, (datetime.fromtimestamp(time)).strftime(time_format)) + time_format = '%H %M' + lcd.setCursor(0, 1) + lcd.printString((datetime.fromtimestamp(time)).strftime(time_format)) Arduino.delay(1000) time += 1 diff --git a/firmware/ArduinoSingle.cpp b/firmware/ArduinoClass.cpp similarity index 76% rename from firmware/ArduinoSingle.cpp rename to firmware/ArduinoClass.cpp index 47438ab..6576ee6 100644 --- a/firmware/ArduinoSingle.cpp +++ b/firmware/ArduinoClass.cpp @@ -1,21 +1,9 @@ #include -#include "ArduinoSingle.h" +#include "ArduinoClass.h" #include "MethodDescriptor.h" #include -ArduinoSingle* ArduinoSingle::instance = NULL; - -ArduinoSingle::ArduinoSingle() { - -}; - -ArduinoSingle* ArduinoSingle::getInstance() { - if (instance == NULL) - instance = new ArduinoSingle(); - return instance; -} - -void ArduinoSingle::elaborate( MethodDescriptor* m ) { +void ArduinoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Arduino") == 0) { if (strcmp(m->getName(), "digitalWrite") == 0) { digitalWrite(m->getInt(0), m->getInt(1)); diff --git a/firmware/ArduinoClass.h b/firmware/ArduinoClass.h index 18b2c59..4b054e9 100644 --- a/firmware/ArduinoClass.h +++ b/firmware/ArduinoClass.h @@ -1,12 +1,14 @@ -#ifndef PY_ARDUINO_CLASS -#define PY_ARDUINO_CLASS +#ifndef ARDUINO_CLASS +#define ARDUINO_CLASS + +#include "BaseClass.h" class MethodDescriptor; -class ArduinoClass { +class ArduinoClass : public BaseClass { public: - virtual void elaborate( MethodDescriptor* m ) = 0; + void elaborate( MethodDescriptor* m ); }; diff --git a/firmware/ArduinoSingle.h b/firmware/ArduinoSingle.h deleted file mode 100644 index dac2ccd..0000000 --- a/firmware/ArduinoSingle.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ARDUINO_SINGLE -#define ARDUINO_SINGLE - -#include -#include "ArduinoClass.h" - -class MethodDescriptor; - -char* readStringFromSerial(); - -class ArduinoSingle : public ArduinoClass { - - private: - - static ArduinoSingle* instance; - ArduinoSingle(); - - public: - - void elaborate( MethodDescriptor* m ); - static ArduinoSingle* getInstance(); - -}; - -#endif diff --git a/firmware/BaseClass.h b/firmware/BaseClass.h new file mode 100644 index 0000000..4c36e2c --- /dev/null +++ b/firmware/BaseClass.h @@ -0,0 +1,57 @@ +#ifndef BASE_CLASS +#define BASE_CLASS + +#include "SlimArray.h" +#include "MethodDescriptor.h" + +class MethodDescriptor; + +class BaseClass { + + public: + virtual void elaborate( MethodDescriptor* m ) = 0; + +}; + +template class ObjectsManager : public BaseClass { + + protected: + SlimArray v; + + public: + ObjectsManager() {} + void elaborate( MethodDescriptor* m ) { + if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); + v.remove(m->getObjectId()); + Serial.println("0"); + } + } + +}; + +static SlimArray classes; + +class Register { + + public: + + template static void registerClass() { + classes.insert((BaseClass*)new T()); + } + + static void elaborate(MethodDescriptor* m) { + for(int i = 0 ; i < classes.getSize() ; i++) + classes[i]->elaborate(m); + + if(m != NULL) { + delete(m); + m = NULL; + } + } + +}; + +#define REGISTER_CLASS(cls) Register::registerClass(); + +#endif diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index beaa69d..0c6797f 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -5,13 +5,12 @@ #include "MethodDescriptor.h" #include -DallasTemperatureClass::DallasTemperatureClass():v(0) { - -}; - void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "DallasTemperature") == 0) { + ObjectsManager::elaborate(m); + if (strcmp(m->getName(),"new") == 0) { int prm = 0; OneWire* wr = new OneWire(m->getInt(0)); diff --git a/firmware/DallasTemperatureClass.h b/firmware/DallasTemperatureClass.h index 4b6c269..dee2337 100644 --- a/firmware/DallasTemperatureClass.h +++ b/firmware/DallasTemperatureClass.h @@ -1,24 +1,14 @@ #ifndef DALLAS_TEMP_CLASS #define DALLAS_TEMP_CLASS -#include -#include "SlimArray.h" -#include "ArduinoClass.h" +#include "BaseClass.h" class DallasTemperature; class MethodDescriptor; -char* readStringFromSerial(); - -class DallasTemperatureClass: public ArduinoClass { - - private: - - SlimArray v; +class DallasTemperatureClass: public ObjectsManager { public: - - DallasTemperatureClass(); void elaborate( MethodDescriptor* m ); }; diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index f207f19..b6e0f5b 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -4,14 +4,12 @@ #include "MethodDescriptor.h" #include -LiquidCrystalClass::LiquidCrystalClass():v(0) { - -}; - void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Lcd") == 0) { - if (strcmp(m->getName(),"new") == 0) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { int prm = 0; v.insert(new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); @@ -29,11 +27,5 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { Serial.println("0"); } - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); - } - } }; diff --git a/firmware/LiquidCrystalClass.h b/firmware/LiquidCrystalClass.h index 8db8e19..dee9efc 100644 --- a/firmware/LiquidCrystalClass.h +++ b/firmware/LiquidCrystalClass.h @@ -1,26 +1,18 @@ #ifndef LIQUID_CRYSTAL_CLASS #define LIQUID_CRYSTAL_CLASS -#include -#include "SlimArray.h" -#include "ArduinoClass.h" +#include "BaseClass.h" class LiquidCrystal; class MethodDescriptor; -char* readStringFromSerial(); - -class LiquidCrystalClass: public ArduinoClass { - - private: - - SlimArray v; +class LiquidCrystalClass : public ObjectsManager { public: - - LiquidCrystalClass(); void elaborate( MethodDescriptor* m ); }; + + #endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index f802306..528400b 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,58 +1,41 @@ -#include +#include "BaseClass.h" #include "ArduinoClass.h" -#include "ArduinoSingle.h" #include "OneWireClass.h" -#include "LiquidCrystalClass.h" #include "StepperClass.h" #include "ServoClass.h" #include "DallasTemperatureClass.h" +#include "LiquidCrystalClass.h" #include "ToneClass.h" #include "MethodDescriptor.h" -#include "Utilities.h" -#include "SlimArray.h" #ifndef BAUDRATE #define BAUDRATE 9600 #endif -SlimArray classes(2); - -int pin, value; - MethodDescriptor *m = NULL; void setup() { - classes.insert(ArduinoSingle::getInstance()); - classes.insert(new OneWireClass()); - classes.insert(new LiquidCrystalClass()); - classes.insert(new StepperClass()); - classes.insert(new ServoClass()); - classes.insert(new DallasTemperatureClass()); - classes.insert(new ToneClass()); + + REGISTER_CLASS(ArduinoClass); + REGISTER_CLASS(LiquidCrystalClass); + REGISTER_CLASS(OneWireClass); + REGISTER_CLASS(DallasTemperatureClass); + REGISTER_CLASS(StepperClass); + REGISTER_CLASS(ServoClass); + REGISTER_CLASS(ToneClass); + Serial.begin(BAUDRATE); + while (Serial.available() <= 0) { delay(300); } } -void loop() -{ - - if(m != NULL) { - delete(m); - m = NULL; - } - +void loop() { if (Serial.available() > 0) { - m = new MethodDescriptor(); - - for(int i = 0 ; i < classes.getSize() ; i++) - classes[i]->elaborate(m); - + Register::elaborate(m); } - } - diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index 3000fe3..fc093dd 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -3,14 +3,12 @@ #include "MethodDescriptor.h" #include -OneWireClass::OneWireClass():v(0) { - -}; - void OneWireClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "OneWire") == 0) { + ObjectsManager::elaborate(m); + if (strcmp(m->getName(), "new") == 0) { v.insert(new OneWire(m->getInt(0))); Serial.println(v.getLastIndex()); diff --git a/firmware/OneWireClass.h b/firmware/OneWireClass.h index bdc5c29..0e59f97 100644 --- a/firmware/OneWireClass.h +++ b/firmware/OneWireClass.h @@ -1,23 +1,14 @@ #ifndef ONE_WIRE_CLASS #define ONE_WIRE_CLASS -#include "SlimArray.h" -#include "ArduinoClass.h" +#include "BaseClass.h" class OneWire; class MethodDescriptor; -char* readStringFromSerial(); - -class OneWireClass: public ArduinoClass { - - private: - - SlimArray v; +class OneWireClass: public ObjectsManager { public: - - OneWireClass(); void elaborate( MethodDescriptor* m ); }; diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index 01aa179..44bf89e 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -4,13 +4,11 @@ #include "MethodDescriptor.h" #include -ServoClass::ServoClass():v(0) { - -}; - void ServoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Servo") == 0) { + ObjectsManager::elaborate(m); + if (strcmp(m->getName(),"new") == 0) { v.insert(new Servo()); v[v.getLastIndex()]->attach(m->getInt(0)); diff --git a/firmware/ServoClass.h b/firmware/ServoClass.h index b2fdcac..6f33a7e 100644 --- a/firmware/ServoClass.h +++ b/firmware/ServoClass.h @@ -1,24 +1,14 @@ #ifndef SERVO_CLASS #define SERVO_CLASS -#include -#include "SlimArray.h" -#include "ArduinoClass.h" +#include "BaseClass.h" class Servo; class MethodDescriptor; -char* readStringFromSerial(); - -class ServoClass: public ArduinoClass { - - private: - - SlimArray v; +class ServoClass: public ObjectsManager { public: - - ServoClass(); void elaborate( MethodDescriptor* m ); }; diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 73acfd8..7b91d37 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -4,13 +4,11 @@ #include "MethodDescriptor.h" #include -StepperClass::StepperClass():v(0) { - -}; - void StepperClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Stepper") == 0) { + ObjectsManager::elaborate(m); + if (strcmp(m->getName(),"new") == 0) { int prm = 0; v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); diff --git a/firmware/StepperClass.h b/firmware/StepperClass.h index 6e0da50..cb75329 100644 --- a/firmware/StepperClass.h +++ b/firmware/StepperClass.h @@ -1,24 +1,14 @@ #ifndef STEPPER_CLASS #define STEPPER_CLASS -#include -#include "SlimArray.h" -#include "ArduinoClass.h" +#include "BaseClass.h" class Stepper; class MethodDescriptor; -char* readStringFromSerial(); - -class StepperClass: public ArduinoClass { - - private: - - SlimArray v; +class StepperClass: public ObjectsManager { public: - - StepperClass(); void elaborate( MethodDescriptor* m ); }; diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 141ac55..771b054 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -1,16 +1,13 @@ #include -#include #include "ToneClass.h" #include "MethodDescriptor.h" #include -ToneClass::ToneClass():v(0) { - -}; - void ToneClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Tone") == 0) { + ObjectsManager::elaborate(m); + if (strcmp(m->getName(),"new") == 0) { v.insert(new Tone (m->getInt(0))); Serial.println(v.getLastIndex()); diff --git a/firmware/ToneClass.h b/firmware/ToneClass.h index f9b64cd..cc295a6 100644 --- a/firmware/ToneClass.h +++ b/firmware/ToneClass.h @@ -1,9 +1,7 @@ #ifndef TONE_CLASS #define TONE_CLASS -#include -#include "SlimArray.h" -#include "ArduinoClass.h" +#include "BaseClass.h" #define NOTE_B0 31 #define NOTE_C1 33 @@ -115,17 +113,9 @@ class Tone { }; -char* readStringFromSerial(); - -class ToneClass: public ArduinoClass { - - private: - - SlimArray v; +class ToneClass: public ObjectsManager { public: - - ToneClass(); void elaborate( MethodDescriptor* m ); }; diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 7b26f4e..179a091 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -11,11 +11,6 @@ def __init__(self, pins, begin): def printString(self, value): pass - def printString(self, col, row, value): - self.setCursor(col, row) - self.printString(value) - pass - @arduinoobjectmethod def setCursor(self, col, row): pass From 8c53a3a113dac414d5bc65e57d609475a7b185e3 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 1 Oct 2012 20:44:23 +0200 Subject: [PATCH 054/344] Decorators for return values --- nanpy/arduino.py | 4 +++- nanpy/arduinoboard.py | 16 ++++++++++++++++ nanpy/dallastemperature.py | 4 +++- nanpy/onewire.py | 6 ++++-- nanpy/servo.py | 4 +++- setup.py | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 4fdbd9b..e0e4232 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import (call_static_method, return_value) -from nanpy.arduinoboard import arduinoclassmethod +from nanpy.arduinoboard import (arduinoclassmethod, returnint) class Arduino(): @@ -13,6 +13,7 @@ class Arduino(): def digitalWrite(cls, pin, value): pass + @returnint @classmethod @arduinoclassmethod def digitalRead(cls, pin): @@ -23,6 +24,7 @@ def digitalRead(cls, pin): def analogWrite(cls, pin, value): pass + @returnint @classmethod @arduinoclassmethod def analogRead(cls, pin): diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index f4229bc..a5d222d 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -40,6 +40,22 @@ def _call(namespace, id, args): mutex.release() return ret +def returnfloat(conv, *args, **kwargs): + def wrapper(self, *args, **kwargs): + try: + return float(conv(self, args, kwargs)) + except ValueError: + return -1 + return wrapper + +def returnint(conv, *args, **kwargs): + def wrapper(self, *args, **kwargs): + try: + return int(conv(self, args, kwargs)) + except ValueError: + return -1 + return wrapper + def arduinoobjectmethod(funct, *args, **kwargs): def wrapper(self, *args, **kwargs): call_pars = [funct.__name__] diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 3505356..73a7073 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod +from nanpy.arduinoboard import (arduinoobjectmethod, returnfloat) class DallasTemperature(ArduinoObject): @@ -11,10 +11,12 @@ def __init__(self, pin): def requestTemperatures(self): pass + @returnfloat @arduinoobjectmethod def getTempCByIndex(self, index): pass + @returnfloat @arduinoobjectmethod def getTempFByIndex(self, index): pass diff --git a/nanpy/onewire.py b/nanpy/onewire.py index 36f191a..613afe4 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod +from nanpy.arduinoboard import (arduinoobjectmethod, returnint) class OneWireAddress(): @@ -24,8 +24,10 @@ def search(self): def select(self, address): return self.call('select', address.get()) + @returnint + @arduinoobjectmethod def read(self): - return int(self.call('read')) + pass @arduinoobjectmethod def reset_search(self): diff --git a/nanpy/servo.py b/nanpy/servo.py index f2fa09f..c87ea23 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod +from nanpy.arduinoboard import (arduinoobjectmethod, returnint) class Servo(ArduinoObject): @@ -10,6 +10,7 @@ def __init__(self, pin): def write(self, value): pass + @returnint @arduinoobjectmethod def read(self): pass @@ -18,6 +19,7 @@ def read(self): def writeMicroseconds(self, value): pass + @returnint @arduinoobjectmethod def readMicroseconds(self, value): pass diff --git a/setup.py b/setup.py index cfd1e9d..b6a2661 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="1.0", + version="0.1", description="Build your Arduino prototypes with Python", license="MIT", author="Andrea Stagi", From 2a3706afc4ca953ca24c67c9dd8cc585767ca28e Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 1 Oct 2012 21:04:09 +0200 Subject: [PATCH 055/344] Bumped to version 0.2 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b6a2661..e25633a 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,8 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.1", - description="Build your Arduino prototypes with Python", + version="0.2", + description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", author_email="stagi.andrea@gmail.com", From 4229ddd171f5204c6765a725039929911d79cfd2 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 2 Oct 2012 01:23:10 +0200 Subject: [PATCH 056/344] Minfixes and some cleanup --- firmware/DallasTemperatureClass.cpp | 10 ++++++---- firmware/LiquidCrystalClass.cpp | 1 + firmware/MethodDescriptor.cpp | 2 -- firmware/OneWireClass.cpp | 6 ------ firmware/ServoClass.cpp | 6 ------ firmware/StepperClass.cpp | 6 ------ firmware/ToneClass.cpp | 6 ------ nanpy/arduino.py | 4 ++-- nanpy/dallastemperature.py | 14 ++++++++++++++ 9 files changed, 23 insertions(+), 32 deletions(-) diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 0c6797f..d500d77 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -33,11 +33,13 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { Serial.println(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); } - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); + /*if (strcmp(m->getName(), "toFahrenheit") == 0) { + Serial.println(DallasTemperature::toFahrenheit(m->getFloat(0))); } + if (strcmp(m->getName(), "toCelsius") == 0) { + Serial.println(DallasTemperature::toCelsius(m->getFloat(0))); + }*/ + } }; diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index b6e0f5b..7a11f00 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -3,6 +3,7 @@ #include "LiquidCrystalClass.h" #include "MethodDescriptor.h" #include +#include void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Lcd") == 0) { diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index 4aed710..cec8a34 100644 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -27,12 +27,10 @@ int MethodDescriptor::getNArgs() { return this->n_args; }; - int MethodDescriptor::getInt(int n) { return atoi(this->stack[n]); }; - char* MethodDescriptor::getString(int n) { return this->stack[n]; }; diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index fc093dd..c7aee2f 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -67,11 +67,5 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { Serial.println(v[m->getObjectId()]->read()); } - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); - } - } }; diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index 44bf89e..e054d3c 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -42,11 +42,5 @@ void ServoClass::elaborate( MethodDescriptor* m ) { Serial.println(v[m->getObjectId()]->attached()); } - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); - } - } }; diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 7b91d37..73b8440 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -25,11 +25,5 @@ void StepperClass::elaborate( MethodDescriptor* m ) { Serial.println("0"); } - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); - } - } }; diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 771b054..0311bed 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -23,11 +23,5 @@ void ToneClass::elaborate( MethodDescriptor* m ) { Serial.println("0"); } - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); - } - } }; diff --git a/nanpy/arduino.py b/nanpy/arduino.py index e0e4232..22246ef 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -13,8 +13,8 @@ class Arduino(): def digitalWrite(cls, pin, value): pass - @returnint @classmethod + @returnint @arduinoclassmethod def digitalRead(cls, pin): pass @@ -24,8 +24,8 @@ def digitalRead(cls, pin): def analogWrite(cls, pin, value): pass - @returnint @classmethod + @returnint @arduinoclassmethod def analogRead(cls, pin): pass diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 73a7073..fa66c68 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -20,3 +20,17 @@ def getTempCByIndex(self, index): @arduinoobjectmethod def getTempFByIndex(self, index): pass + + """ + @classmethod + @returnfloat + @arduinoclassmethod + def toFahrenheit(cls, value): + pass + + @classmethod + @returnfloat + @arduinoclassmethod + def toFahrenheit(cls, value): + pass + """ From df81314a41e9be6b33adf3748448ee902e0dacc5 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 2 Oct 2012 12:56:27 +0200 Subject: [PATCH 057/344] Fixed decorator bug, added conversions for DallasTemperature --- examples/dallastemperature.py | 4 +++- firmware/DallasTemperatureClass.cpp | 4 ++-- firmware/Makefile | 2 +- firmware/MethodDescriptor.cpp | 9 +++++++++ firmware/MethodDescriptor.h | 2 ++ nanpy/arduinoboard.py | 9 +++++---- nanpy/dallastemperature.py | 7 +++---- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 6e816f5..93bedb6 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -10,5 +10,7 @@ while True: sensors.requestTemperatures() - print sensors.getTempCByIndex(0) + temp = sensors.getTempCByIndex(0) + print temp + print DallasTemperature.toFahrenheit(temp) diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index d500d77..e0a23fc 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -33,13 +33,13 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { Serial.println(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); } - /*if (strcmp(m->getName(), "toFahrenheit") == 0) { + if (strcmp(m->getName(), "toFahrenheit") == 0) { Serial.println(DallasTemperature::toFahrenheit(m->getFloat(0))); } if (strcmp(m->getName(), "toCelsius") == 0) { Serial.println(DallasTemperature::toCelsius(m->getFloat(0))); - }*/ + } } }; diff --git a/firmware/Makefile b/firmware/Makefile index 42bef39..69d6013 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -331,7 +331,7 @@ $(TARGET).hex: $(TARGET).elf .INTERMEDIATE: $(TARGET).elf $(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) - $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@ + $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@ -lm %.o: %.c mkdir -p .dep/$(dir $<) diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index cec8a34..7221d83 100644 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -1,6 +1,7 @@ #include "MethodDescriptor.h" #include "Utilities.h" #include +#include MethodDescriptor::MethodDescriptor() { @@ -31,6 +32,14 @@ int MethodDescriptor::getInt(int n) { return atoi(this->stack[n]); }; +float MethodDescriptor::getFloat(int n) { + return atof(this->stack[n]); +}; + +double MethodDescriptor::getDouble(int n) { + return atof(this->stack[n]); +}; + char* MethodDescriptor::getString(int n) { return this->stack[n]; }; diff --git a/firmware/MethodDescriptor.h b/firmware/MethodDescriptor.h index 6775be3..729e773 100644 --- a/firmware/MethodDescriptor.h +++ b/firmware/MethodDescriptor.h @@ -16,6 +16,8 @@ class MethodDescriptor { char* getClass(); int getObjectId(); int getInt(int n); + float getFloat(int n); + double getDouble(int n); char* getString(int n); char* getName(); ~MethodDescriptor(); diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index a5d222d..6859dd1 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -40,18 +40,19 @@ def _call(namespace, id, args): mutex.release() return ret -def returnfloat(conv, *args, **kwargs): +def returnfloat(conv): def wrapper(self, *args, **kwargs): try: - return float(conv(self, args, kwargs)) + return float(conv(self, *args, **kwargs)) except ValueError: return -1 + return wrapper def returnint(conv, *args, **kwargs): def wrapper(self, *args, **kwargs): try: - return int(conv(self, args, kwargs)) + return int(conv(self, *args, **kwargs)) except ValueError: return -1 return wrapper @@ -63,7 +64,7 @@ def wrapper(self, *args, **kwargs): return _call(self.namespace, self.id, call_pars) return wrapper -def arduinoclassmethod(funct, *args, **kwargs): +def arduinoclassmethod(funct): def wrapper(cls, *args, **kwargs): call_pars = [funct.__name__] call_pars.extend(args) diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index fa66c68..1f8961e 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returnfloat) +from nanpy.arduinoboard import (arduinoobjectmethod, arduinoclassmethod, returnfloat, returnint) class DallasTemperature(ArduinoObject): @@ -21,11 +21,10 @@ def getTempCByIndex(self, index): def getTempFByIndex(self, index): pass - """ @classmethod @returnfloat @arduinoclassmethod - def toFahrenheit(cls, value): + def toCelsius(cls, value): pass @classmethod @@ -33,4 +32,4 @@ def toFahrenheit(cls, value): @arduinoclassmethod def toFahrenheit(cls, value): pass - """ + From 48f9dacf7d7e0c1ab1454d915002a150c6c742d8 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 2 Oct 2012 15:34:34 +0200 Subject: [PATCH 058/344] Bumped to version 0.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e25633a..34819b6 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.2", + version="0.3", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From acfc5ed7e51611c6c7a994af2ad48b73c6f88032 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 3 Oct 2012 15:55:24 +0200 Subject: [PATCH 059/344] Make programmers life simpler, include third part libs in the code --- README.md | 6 - firmware/Makefile | 7 + .../DallasTemperature/DallasTemperature.cpp | 738 ++++++++++++++++++ .../DallasTemperature/DallasTemperature.h | 242 ++++++ .../libraries/DallasTemperature/README.TXT | 53 ++ .../libraries/DallasTemperature/change.txt | 85 ++ .../examples/Alarm/Alarm.pde | 162 ++++ .../examples/AlarmHandler/AlarmHandler.pde | 144 ++++ .../examples/Multiple/Multiple.pde | 140 ++++ .../examples/Simple/Simple.pde | 33 + .../examples/Single/Single.pde | 109 +++ .../examples/Tester/Tester.pde | 124 +++ .../WaitForConversion/WaitForConversion.pde | 66 ++ .../WaitForConversion2/WaitForConversion2.pde | 80 ++ .../libraries/DallasTemperature/keywords.txt | 54 ++ firmware/libraries/OneWire/OneWire.cpp | 527 +++++++++++++ firmware/libraries/OneWire/OneWire.h | 192 +++++ .../DS18x20_Temperature.pde | 109 +++ .../examples/DS2408_Switch/DS2408_Switch.pde | 77 ++ .../examples/DS250x_PROM/DS250x_PROM.pde | 90 +++ firmware/libraries/OneWire/keywords.txt | 38 + 21 files changed, 3070 insertions(+), 6 deletions(-) create mode 100644 firmware/libraries/DallasTemperature/DallasTemperature.cpp create mode 100644 firmware/libraries/DallasTemperature/DallasTemperature.h create mode 100644 firmware/libraries/DallasTemperature/README.TXT create mode 100644 firmware/libraries/DallasTemperature/change.txt create mode 100644 firmware/libraries/DallasTemperature/examples/Alarm/Alarm.pde create mode 100644 firmware/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde create mode 100644 firmware/libraries/DallasTemperature/examples/Multiple/Multiple.pde create mode 100644 firmware/libraries/DallasTemperature/examples/Simple/Simple.pde create mode 100644 firmware/libraries/DallasTemperature/examples/Single/Single.pde create mode 100644 firmware/libraries/DallasTemperature/examples/Tester/Tester.pde create mode 100644 firmware/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde create mode 100644 firmware/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde create mode 100644 firmware/libraries/DallasTemperature/keywords.txt create mode 100644 firmware/libraries/OneWire/OneWire.cpp create mode 100644 firmware/libraries/OneWire/OneWire.h create mode 100644 firmware/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde create mode 100644 firmware/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde create mode 100644 firmware/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde create mode 100644 firmware/libraries/OneWire/keywords.txt diff --git a/README.md b/README.md index ffb4a4f..a864b3a 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,6 @@ Dependencies - python-setuptools - python-serial -#### Arduino -- OneWire http://www.pjrc.com/teensy/td_libs_OneWire.html -- DallasTemperature http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library - -NOTE: Nanpy uses both built-in and third-party libraries, such as OneWire and DallasTemperature. We assume that you install them in the Arduino's "libraries" folder, for example in Ubuntu you can find it in /usr/share/arduino by default. - How to build and install ------------------------ diff --git a/firmware/Makefile b/firmware/Makefile index 69d6013..f8c8f4c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -174,6 +174,9 @@ SOURCES := $(INOFILE) \ LIBRARIES := $(filter $(notdir $(wildcard $(ARDUINODIR)/libraries/*)), \ $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) +LIBRARIES += $(filter $(notdir $(wildcard libraries/*)), \ + $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) + endif # no serial device? make a poor attempt to detect an arduino @@ -203,6 +206,8 @@ ARDUINOLIB := .lib/arduino.a ARDUINOLIBLIBSDIR := $(ARDUINODIR)/libraries ARDUINOLIBLIBSPATH := $(foreach lib, $(LIBRARIES), \ $(ARDUINODIR)/libraries/$(lib)/ $(ARDUINODIR)/libraries/$(lib)/utility/ ) +ARDUINOLIBLIBSPATH += $(foreach lib, $(LIBRARIES), \ + ./libraries/$(lib)/ ./libraries/$(lib)/utility/ ) ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(ARDUINOLIBLIBSPATH), \ $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) ifeq "$(AVRDUDECONF)" "" @@ -258,6 +263,7 @@ endif CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES)) +CPPFLAGS += $(addprefix -I./libraries/, $(LIBRARIES)) CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h @@ -287,6 +293,7 @@ all: target target: $(TARGET).hex upload: + @echo $(LIBRARIES) @echo "\nUploading to board..." @test -n "$(SERIALDEV)" || { \ echo "error: SERIALDEV could not be determined automatically." >&2; \ diff --git a/firmware/libraries/DallasTemperature/DallasTemperature.cpp b/firmware/libraries/DallasTemperature/DallasTemperature.cpp new file mode 100644 index 0000000..1409701 --- /dev/null +++ b/firmware/libraries/DallasTemperature/DallasTemperature.cpp @@ -0,0 +1,738 @@ +// This library 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. + +// Version 3.7.2 modified on Dec 6, 2011 to support Arduino 1.0 +// See Includes... +// Modified by Jordan Hochenbaum + +#include "DallasTemperature.h" + +#if ARDUINO >= 100 + #include "Arduino.h" +#else +extern "C" { + #include "WConstants.h" +} +#endif + +DallasTemperature::DallasTemperature(OneWire* _oneWire) + #if REQUIRESALARMS + : _AlarmHandler(&defaultAlarmHandler) + #endif +{ + _wire = _oneWire; + devices = 0; + parasite = false; + bitResolution = 9; + waitForConversion = true; + checkForConversion = true; +} + +// initialise the bus +void DallasTemperature::begin(void) +{ + DeviceAddress deviceAddress; + + _wire->reset_search(); + devices = 0; // Reset the number of devices when we enumerate wire devices + + while (_wire->search(deviceAddress)) + { + if (validAddress(deviceAddress)) + { + if (!parasite && readPowerSupply(deviceAddress)) parasite = true; + + ScratchPad scratchPad; + + readScratchPad(deviceAddress, scratchPad); + + bitResolution = max(bitResolution, getResolution(deviceAddress)); + + devices++; + } + } +} + +// returns the number of devices found on the bus +uint8_t DallasTemperature::getDeviceCount(void) +{ + return devices; +} + +// returns true if address is valid +bool DallasTemperature::validAddress(uint8_t* deviceAddress) +{ + return (_wire->crc8(deviceAddress, 7) == deviceAddress[7]); +} + +// finds an address at a given index on the bus +// returns true if the device was found +bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index) +{ + uint8_t depth = 0; + + _wire->reset_search(); + + while (depth <= index && _wire->search(deviceAddress)) + { + if (depth == index && validAddress(deviceAddress)) return true; + depth++; + } + + return false; +} + +// attempt to determine if the device at the given address is connected to the bus +bool DallasTemperature::isConnected(uint8_t* deviceAddress) +{ + ScratchPad scratchPad; + return isConnected(deviceAddress, scratchPad); +} + +// attempt to determine if the device at the given address is connected to the bus +// also allows for updating the read scratchpad +bool DallasTemperature::isConnected(uint8_t* deviceAddress, uint8_t* scratchPad) +{ + readScratchPad(deviceAddress, scratchPad); + return (_wire->crc8(scratchPad, 8) == scratchPad[SCRATCHPAD_CRC]); +} + +// read device's scratch pad +void DallasTemperature::readScratchPad(uint8_t* deviceAddress, uint8_t* scratchPad) +{ + // send the command + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(READSCRATCH); + + // TODO => collect all comments & use simple loop + // byte 0: temperature LSB + // byte 1: temperature MSB + // byte 2: high alarm temp + // byte 3: low alarm temp + // byte 4: DS18S20: store for crc + // DS18B20 & DS1822: configuration register + // byte 5: internal use & crc + // byte 6: DS18S20: COUNT_REMAIN + // DS18B20 & DS1822: store for crc + // byte 7: DS18S20: COUNT_PER_C + // DS18B20 & DS1822: store for crc + // byte 8: SCRATCHPAD_CRC + // + // for(int i=0; i<9; i++) + // { + // scratchPad[i] = _wire->read(); + // } + + + // read the response + + // byte 0: temperature LSB + scratchPad[TEMP_LSB] = _wire->read(); + + // byte 1: temperature MSB + scratchPad[TEMP_MSB] = _wire->read(); + + // byte 2: high alarm temp + scratchPad[HIGH_ALARM_TEMP] = _wire->read(); + + // byte 3: low alarm temp + scratchPad[LOW_ALARM_TEMP] = _wire->read(); + + // byte 4: + // DS18S20: store for crc + // DS18B20 & DS1822: configuration register + scratchPad[CONFIGURATION] = _wire->read(); + + // byte 5: + // internal use & crc + scratchPad[INTERNAL_BYTE] = _wire->read(); + + // byte 6: + // DS18S20: COUNT_REMAIN + // DS18B20 & DS1822: store for crc + scratchPad[COUNT_REMAIN] = _wire->read(); + + // byte 7: + // DS18S20: COUNT_PER_C + // DS18B20 & DS1822: store for crc + scratchPad[COUNT_PER_C] = _wire->read(); + + // byte 8: + // SCTRACHPAD_CRC + scratchPad[SCRATCHPAD_CRC] = _wire->read(); + + _wire->reset(); +} + +// writes device's scratch pad +void DallasTemperature::writeScratchPad(uint8_t* deviceAddress, const uint8_t* scratchPad) +{ + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(WRITESCRATCH); + _wire->write(scratchPad[HIGH_ALARM_TEMP]); // high alarm temp + _wire->write(scratchPad[LOW_ALARM_TEMP]); // low alarm temp + // DS18S20 does not use the configuration register + if (deviceAddress[0] != DS18S20MODEL) _wire->write(scratchPad[CONFIGURATION]); // configuration + _wire->reset(); + // save the newly written values to eeprom + _wire->write(COPYSCRATCH, parasite); + if (parasite) delay(10); // 10ms delay + _wire->reset(); +} + +// reads the device's power requirements +bool DallasTemperature::readPowerSupply(uint8_t* deviceAddress) +{ + bool ret = false; + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(READPOWERSUPPLY); + if (_wire->read_bit() == 0) ret = true; + _wire->reset(); + return ret; +} + + +// set resolution of all devices to 9, 10, 11, or 12 bits +// if new resolution is out of range, it is constrained. +void DallasTemperature::setResolution(uint8_t newResolution) +{ + bitResolution = constrain(newResolution, 9, 12); + DeviceAddress deviceAddress; + for (int i=0; ireset(); + _wire->skip(); + _wire->write(STARTCONVO, parasite); + + // ASYNC mode? + if (!waitForConversion) return; + blockTillConversionComplete(&bitResolution, 0); + + return; +} + +// sends command for one device to perform a temperature by address +// returns FALSE if device is disconnected +// returns TRUE otherwise +bool DallasTemperature::requestTemperaturesByAddress(uint8_t* deviceAddress) +{ + + _wire->reset(); + _wire->select(deviceAddress); + _wire->write(STARTCONVO, parasite); + + // check device + ScratchPad scratchPad; + if (!isConnected(deviceAddress, scratchPad)) return false; + + + // ASYNC mode? + if (!waitForConversion) return true; + uint8_t bitResolution = getResolution(deviceAddress); + blockTillConversionComplete(&bitResolution, deviceAddress); + + return true; +} + + +void DallasTemperature::blockTillConversionComplete(uint8_t* bitResolution, uint8_t* deviceAddress) +{ + if(deviceAddress != 0 && checkForConversion && !parasite) + { + // Continue to check if the IC has responded with a temperature + // NB: Could cause issues with multiple devices (one device may respond faster) + unsigned long start = millis(); + while(!isConversionAvailable(0) && ((millis() - start) < 750)); + } + + // Wait a fix number of cycles till conversion is complete (based on IC datasheet) + switch (*bitResolution) + { + case 9: + delay(94); + break; + case 10: + delay(188); + break; + case 11: + delay(375); + break; + case 12: + default: + delay(750); + break; + } + +} + +// sends command for one device to perform a temp conversion by index +bool DallasTemperature::requestTemperaturesByIndex(uint8_t deviceIndex) +{ + DeviceAddress deviceAddress; + getAddress(deviceAddress, deviceIndex); + return requestTemperaturesByAddress(deviceAddress); +} + +// Fetch temperature for device index +float DallasTemperature::getTempCByIndex(uint8_t deviceIndex) +{ + DeviceAddress deviceAddress; + getAddress(deviceAddress, deviceIndex); + return getTempC((uint8_t*)deviceAddress); +} + +// Fetch temperature for device index +float DallasTemperature::getTempFByIndex(uint8_t deviceIndex) +{ + return toFahrenheit(getTempCByIndex(deviceIndex)); +} + +// reads scratchpad and returns the temperature in degrees C +float DallasTemperature::calculateTemperature(uint8_t* deviceAddress, uint8_t* scratchPad) +{ + int16_t rawTemperature = (((int16_t)scratchPad[TEMP_MSB]) << 8) | scratchPad[TEMP_LSB]; + + switch (deviceAddress[0]) + { + case DS18B20MODEL: + case DS1822MODEL: + switch (scratchPad[CONFIGURATION]) + { + case TEMP_12_BIT: + return (float)rawTemperature * 0.0625; + break; + case TEMP_11_BIT: + return (float)(rawTemperature >> 1) * 0.125; + break; + case TEMP_10_BIT: + return (float)(rawTemperature >> 2) * 0.25; + break; + case TEMP_9_BIT: + return (float)(rawTemperature >> 3) * 0.5; + break; + } + break; + case DS18S20MODEL: + /* + + Resolutions greater than 9 bits can be calculated using the data from + the temperature, COUNT REMAIN and COUNT PER �C registers in the + scratchpad. Note that the COUNT PER �C register is hard-wired to 16 + (10h). After reading the scratchpad, the TEMP_READ value is obtained + by truncating the 0.5�C bit (bit 0) from the temperature data. The + extended resolution temperature can then be calculated using the + following equation: + + COUNT_PER_C - COUNT_REMAIN + TEMPERATURE = TEMP_READ - 0.25 + -------------------------- + COUNT_PER_C + */ + + // Good spot. Thanks Nic Johns for your contribution + return (float)(rawTemperature >> 1) - 0.25 +((float)(scratchPad[COUNT_PER_C] - scratchPad[COUNT_REMAIN]) / (float)scratchPad[COUNT_PER_C] ); + break; + } +} + +// returns temperature in degrees C or DEVICE_DISCONNECTED if the +// device's scratch pad cannot be read successfully. +// the numeric value of DEVICE_DISCONNECTED is defined in +// DallasTemperature.h. It is a large negative number outside the +// operating range of the device +float DallasTemperature::getTempC(uint8_t* deviceAddress) +{ + // TODO: Multiple devices (up to 64) on the same bus may take + // some time to negotiate a response + // What happens in case of collision? + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad); + return DEVICE_DISCONNECTED; +} + +// returns temperature in degrees F +// TODO: - when getTempC returns DEVICE_DISCONNECTED +// -127 gets converted to -196.6 F +float DallasTemperature::getTempF(uint8_t* deviceAddress) +{ + return toFahrenheit(getTempC(deviceAddress)); +} + +// returns true if the bus requires parasite power +bool DallasTemperature::isParasitePowerMode(void) +{ + return parasite; +} + +#if REQUIRESALARMS + +/* + +ALARMS: + +TH and TL Register Format + +BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 + S 2^6 2^5 2^4 2^3 2^2 2^1 2^0 + +Only bits 11 through 4 of the temperature register are used +in the TH and TL comparison since TH and TL are 8-bit +registers. If the measured temperature is lower than or equal +to TL or higher than or equal to TH, an alarm condition exists +and an alarm flag is set inside the DS18B20. This flag is +updated after every temperature measurement; therefore, if the +alarm condition goes away, the flag will be turned off after +the next temperature conversion. + +*/ + +// sets the high alarm temperature for a device in degrees celsius +// accepts a float, but the alarm resolution will ignore anything +// after a decimal point. valid range is -55C - 125C +void DallasTemperature::setHighAlarmTemp(uint8_t* deviceAddress, char celsius) +{ + // make sure the alarm temperature is within the device's range + if (celsius > 125) celsius = 125; + else if (celsius < -55) celsius = -55; + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) + { + scratchPad[HIGH_ALARM_TEMP] = (uint8_t)celsius; + writeScratchPad(deviceAddress, scratchPad); + } +} + +// sets the low alarm temperature for a device in degreed celsius +// accepts a float, but the alarm resolution will ignore anything +// after a decimal point. valid range is -55C - 125C +void DallasTemperature::setLowAlarmTemp(uint8_t* deviceAddress, char celsius) +{ + // make sure the alarm temperature is within the device's range + if (celsius > 125) celsius = 125; + else if (celsius < -55) celsius = -55; + + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) + { + scratchPad[LOW_ALARM_TEMP] = (uint8_t)celsius; + writeScratchPad(deviceAddress, scratchPad); + } +} + +// returns a char with the current high alarm temperature or +// DEVICE_DISCONNECTED for an address +char DallasTemperature::getHighAlarmTemp(uint8_t* deviceAddress) +{ + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[HIGH_ALARM_TEMP]; + return DEVICE_DISCONNECTED; +} + +// returns a char with the current low alarm temperature or +// DEVICE_DISCONNECTED for an address +char DallasTemperature::getLowAlarmTemp(uint8_t* deviceAddress) +{ + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[LOW_ALARM_TEMP]; + return DEVICE_DISCONNECTED; +} + +// resets internal variables used for the alarm search +void DallasTemperature::resetAlarmSearch() +{ + alarmSearchJunction = -1; + alarmSearchExhausted = 0; + for(uint8_t i = 0; i < 7; i++) + alarmSearchAddress[i] = 0; +} + +// This is a modified version of the OneWire::search method. +// +// Also added the OneWire search fix documented here: +// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295 +// +// Perform an alarm search. If this function returns a '1' then it has +// enumerated the next device and you may retrieve the ROM from the +// OneWire::address variable. If there are no devices, no further +// devices, or something horrible happens in the middle of the +// enumeration then a 0 is returned. If a new device is found then +// its address is copied to newAddr. Use +// DallasTemperature::resetAlarmSearch() to start over. +bool DallasTemperature::alarmSearch(uint8_t* newAddr) +{ + uint8_t i; + char lastJunction = -1; + uint8_t done = 1; + + if (alarmSearchExhausted) return false; + if (!_wire->reset()) return false; + + // send the alarm search command + _wire->write(0xEC, 0); + + for(i = 0; i < 64; i++) + { + uint8_t a = _wire->read_bit( ); + uint8_t nota = _wire->read_bit( ); + uint8_t ibyte = i / 8; + uint8_t ibit = 1 << (i & 7); + + // I don't think this should happen, this means nothing responded, but maybe if + // something vanishes during the search it will come up. + if (a && nota) return false; + + if (!a && !nota) + { + if (i == alarmSearchJunction) + { + // this is our time to decide differently, we went zero last time, go one. + a = 1; + alarmSearchJunction = lastJunction; + } + else if (i < alarmSearchJunction) + { + // take whatever we took last time, look in address + if (alarmSearchAddress[ibyte] & ibit) a = 1; + else + { + // Only 0s count as pending junctions, we've already exhasuted the 0 side of 1s + a = 0; + done = 0; + lastJunction = i; + } + } + else + { + // we are blazing new tree, take the 0 + a = 0; + alarmSearchJunction = i; + done = 0; + } + // OneWire search fix + // See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295 + } + + if (a) alarmSearchAddress[ibyte] |= ibit; + else alarmSearchAddress[ibyte] &= ~ibit; + + _wire->write_bit(a); + } + + if (done) alarmSearchExhausted = 1; + for (i = 0; i < 8; i++) newAddr[i] = alarmSearchAddress[i]; + return true; +} + +// returns true if device address has an alarm condition +// TODO: can this be done with only TEMP_MSB REGISTER (faster) +// if ((char) scratchPad[TEMP_MSB] <= (char) scratchPad[LOW_ALARM_TEMP]) return true; +// if ((char) scratchPad[TEMP_MSB] >= (char) scratchPad[HIGH_ALARM_TEMP]) return true; +bool DallasTemperature::hasAlarm(uint8_t* deviceAddress) +{ + ScratchPad scratchPad; + if (isConnected(deviceAddress, scratchPad)) + { + float temp = calculateTemperature(deviceAddress, scratchPad); + + // check low alarm + if ((char)temp <= (char)scratchPad[LOW_ALARM_TEMP]) return true; + + // check high alarm + if ((char)temp >= (char)scratchPad[HIGH_ALARM_TEMP]) return true; + } + + // no alarm + return false; +} + +// returns true if any device is reporting an alarm condition on the bus +bool DallasTemperature::hasAlarm(void) +{ + DeviceAddress deviceAddress; + resetAlarmSearch(); + return alarmSearch(deviceAddress); +} + +// runs the alarm handler for all devices returned by alarmSearch() +void DallasTemperature::processAlarms(void) +{ + resetAlarmSearch(); + DeviceAddress alarmAddr; + + while (alarmSearch(alarmAddr)) + { + if (validAddress(alarmAddr)) + _AlarmHandler(alarmAddr); + } +} + +// sets the alarm handler +void DallasTemperature::setAlarmHandler(AlarmHandler *handler) +{ + _AlarmHandler = handler; +} + +// The default alarm handler +void DallasTemperature::defaultAlarmHandler(uint8_t* deviceAddress) +{ +} + +#endif + +// Convert float celsius to fahrenheit +float DallasTemperature::toFahrenheit(float celsius) +{ + return (celsius * 1.8) + 32; +} + +// Convert float fahrenheit to celsius +float DallasTemperature::toCelsius(float fahrenheit) +{ + return (fahrenheit - 32) / 1.8; +} + +#if REQUIRESNEW + +// MnetCS - Allocates memory for DallasTemperature. Allows us to instance a new object +void* DallasTemperature::operator new(unsigned int size) // Implicit NSS obj size +{ + void * p; // void pointer + p = malloc(size); // Allocate memory + memset((DallasTemperature*)p,0,size); // Initalise memory + + //!!! CANT EXPLICITLY CALL CONSTRUCTOR - workaround by using an init() methodR - workaround by using an init() method + return (DallasTemperature*) p; // Cast blank region to NSS pointer +} + +// MnetCS 2009 - Unallocates the memory used by this instance +void DallasTemperature::operator delete(void* p) +{ + DallasTemperature* pNss = (DallasTemperature*) p; // Cast to NSS pointer + pNss->~DallasTemperature(); // Destruct the object + + free(p); // Free the memory +} + +#endif diff --git a/firmware/libraries/DallasTemperature/DallasTemperature.h b/firmware/libraries/DallasTemperature/DallasTemperature.h new file mode 100644 index 0000000..ff8262f --- /dev/null +++ b/firmware/libraries/DallasTemperature/DallasTemperature.h @@ -0,0 +1,242 @@ +#ifndef DallasTemperature_h +#define DallasTemperature_h + +#define DALLASTEMPLIBVERSION "3.7.2" + +// This library 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. + +// set to true to include code for new and delete operators +#ifndef REQUIRESNEW +#define REQUIRESNEW false +#endif + +// set to true to include code implementing alarm search functions +#ifndef REQUIRESALARMS +#define REQUIRESALARMS true +#endif + +#include +#include + +// Model IDs +#define DS18S20MODEL 0x10 +#define DS18B20MODEL 0x28 +#define DS1822MODEL 0x22 + +// OneWire commands +#define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad +#define COPYSCRATCH 0x48 // Copy EEPROM +#define READSCRATCH 0xBE // Read EEPROM +#define WRITESCRATCH 0x4E // Write to EEPROM +#define RECALLSCRATCH 0xB8 // Reload from last known +#define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power +#define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition + +// Scratchpad locations +#define TEMP_LSB 0 +#define TEMP_MSB 1 +#define HIGH_ALARM_TEMP 2 +#define LOW_ALARM_TEMP 3 +#define CONFIGURATION 4 +#define INTERNAL_BYTE 5 +#define COUNT_REMAIN 6 +#define COUNT_PER_C 7 +#define SCRATCHPAD_CRC 8 + +// Device resolution +#define TEMP_9_BIT 0x1F // 9 bit +#define TEMP_10_BIT 0x3F // 10 bit +#define TEMP_11_BIT 0x5F // 11 bit +#define TEMP_12_BIT 0x7F // 12 bit + +// Error Codes +#define DEVICE_DISCONNECTED -127 + +typedef uint8_t DeviceAddress[8]; + +class DallasTemperature +{ + public: + + DallasTemperature(OneWire*); + + // initalise bus + void begin(void); + + // returns the number of devices found on the bus + uint8_t getDeviceCount(void); + + // Is a conversion complete on the wire? + bool isConversionComplete(void); + + // returns true if address is valid + bool validAddress(uint8_t*); + + // finds an address at a given index on the bus + bool getAddress(uint8_t*, const uint8_t); + + // attempt to determine if the device at the given address is connected to the bus + bool isConnected(uint8_t*); + + // attempt to determine if the device at the given address is connected to the bus + // also allows for updating the read scratchpad + bool isConnected(uint8_t*, uint8_t*); + + // read device's scratchpad + void readScratchPad(uint8_t*, uint8_t*); + + // write device's scratchpad + void writeScratchPad(uint8_t*, const uint8_t*); + + // read device's power requirements + bool readPowerSupply(uint8_t*); + + // get global resolution + uint8_t getResolution(); + + // set global resolution to 9, 10, 11, or 12 bits + void setResolution(uint8_t); + + // returns the device resolution, 9-12 + uint8_t getResolution(uint8_t*); + + // set resolution of a device to 9, 10, 11, or 12 bits + bool setResolution(uint8_t*, uint8_t); + + // sets/gets the waitForConversion flag + void setWaitForConversion(bool); + bool getWaitForConversion(void); + + // sets/gets the checkForConversion flag + void setCheckForConversion(bool); + bool getCheckForConversion(void); + + // sends command for all devices on the bus to perform a temperature conversion + void requestTemperatures(void); + + // sends command for one device to perform a temperature conversion by address + bool requestTemperaturesByAddress(uint8_t*); + + // sends command for one device to perform a temperature conversion by index + bool requestTemperaturesByIndex(uint8_t); + + // returns temperature in degrees C + float getTempC(uint8_t*); + + // returns temperature in degrees F + float getTempF(uint8_t*); + + // Get temperature for device index (slow) + float getTempCByIndex(uint8_t); + + // Get temperature for device index (slow) + float getTempFByIndex(uint8_t); + + // returns true if the bus requires parasite power + bool isParasitePowerMode(void); + + bool isConversionAvailable(uint8_t*); + + #if REQUIRESALARMS + + typedef void AlarmHandler(uint8_t*); + + // sets the high alarm temperature for a device + // accepts a char. valid range is -55C - 125C + void setHighAlarmTemp(uint8_t*, const char); + + // sets the low alarm temperature for a device + // accepts a char. valid range is -55C - 125C + void setLowAlarmTemp(uint8_t*, const char); + + // returns a signed char with the current high alarm temperature for a device + // in the range -55C - 125C + char getHighAlarmTemp(uint8_t*); + + // returns a signed char with the current low alarm temperature for a device + // in the range -55C - 125C + char getLowAlarmTemp(uint8_t*); + + // resets internal variables used for the alarm search + void resetAlarmSearch(void); + + // search the wire for devices with active alarms + bool alarmSearch(uint8_t*); + + // returns true if ia specific device has an alarm + bool hasAlarm(uint8_t*); + + // returns true if any device is reporting an alarm on the bus + bool hasAlarm(void); + + // runs the alarm handler for all devices returned by alarmSearch() + void processAlarms(void); + + // sets the alarm handler + void setAlarmHandler(AlarmHandler *); + + // The default alarm handler + static void defaultAlarmHandler(uint8_t*); + + #endif + + // convert from celcius to farenheit + static float toFahrenheit(const float); + + // convert from farenheit to celsius + static float toCelsius(const float); + + #if REQUIRESNEW + + // initalize memory area + void* operator new (unsigned int); + + // delete memory reference + void operator delete(void*); + + #endif + + private: + typedef uint8_t ScratchPad[9]; + + // parasite power on or off + bool parasite; + + // used to determine the delay amount needed to allow for the + // temperature conversion to take place + uint8_t bitResolution; + + // used to requestTemperature with or without delay + bool waitForConversion; + + // used to requestTemperature to dynamically check if a conversion is complete + bool checkForConversion; + + // count of devices on the bus + uint8_t devices; + + // Take a pointer to one wire instance + OneWire* _wire; + + // reads scratchpad and returns the temperature in degrees C + float calculateTemperature(uint8_t*, uint8_t*); + + void blockTillConversionComplete(uint8_t*,uint8_t*); + + #if REQUIRESALARMS + + // required for alarmSearch + uint8_t alarmSearchAddress[8]; + char alarmSearchJunction; + uint8_t alarmSearchExhausted; + + // the alarm handler function pointer + AlarmHandler *_AlarmHandler; + + #endif + +}; +#endif diff --git a/firmware/libraries/DallasTemperature/README.TXT b/firmware/libraries/DallasTemperature/README.TXT new file mode 100644 index 0000000..764bdd7 --- /dev/null +++ b/firmware/libraries/DallasTemperature/README.TXT @@ -0,0 +1,53 @@ +Arduino Library for Dallas Temperature ICs +========================================== + +Usage +----- + +This library supports the following devices: + DS18B20 + DS18S20 - Please note there appears to be an issue with this series. + DS1822 + +You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line +and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The +centre pin is the data line '1-wire'. + +We have included a "REQUIRESNEW" and "REQUIRESALARMS" definition. If you +want to slim down the code feel free to use either of these by including +#define REQUIRESNEW or #define REQUIRESALARMS a the top of DallasTemperature.h + +Credits +------- + +The OneWire code has been derived from +http://www.arduino.cc/playground/Learning/OneWire. +Miles Burton originally developed this library. +Tim Newsome added support for multiple sensors on +the same bus. +Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5) +Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0) + + +Website +------- + +You can find the latest version of the library at +http://milesburton.com/index.php?title=Dallas_Temperature_Control_Library + +License +------- + +This library 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 library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/firmware/libraries/DallasTemperature/change.txt b/firmware/libraries/DallasTemperature/change.txt new file mode 100644 index 0000000..42564ca --- /dev/null +++ b/firmware/libraries/DallasTemperature/change.txt @@ -0,0 +1,85 @@ + +This file contains the change history of the Dallas Temperature Control Library. + +VERSION 3.7.2 BETA +=================== +DATE: 6 DEC 2011 + +- Jordan Hochenbaum [jhochenbaum@gmail.com] updated library for compatibility with Arduino 1.0. + +VERSION 3.7.0 BETA +=================== +DATE: 11 JAN 2011 + +- Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0) + The library is backwards compatible with version 3.6.0 + + MAJOR: async modus + ------------------ +- Added - private bool waitForConversion. +This boolean is default set to true in the Constructor to keep the library backwards compatible. If this flag is true calls to requestTemperatures(), requestTemperaturesByAddress() et al, will be blocking with the appropiate time specified (in datasheet) for the resolution used. If the flag is set to false, requestTemperatures() et al, will return immediately after the conversion command is send over the 1-wire interface. The programmer is responsible to wait long enough before reading the temperature values. This enables the application to do other things while waiting for a new reading, like calculations, update LCD, read/write other IO lines etc. See examples. + +- Added - void setWaitForConversion(bool); +To set the flag to true or false, depending on the modus needed. + +- Added - bool getWaitForConversion(void); +To get the current value of the flag. + +- Changed - void requestTemperatures(void); +Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready. + +- Changed - bool requestTemperaturesByAddress(uint8_t*); +Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready. + + + MINOR version number + -------------------- +- Added - #define DALLASTEMPLIBVERSION "3.7.0" +To indicate the version number in .h file + + + MINOR internal var bitResolution + ---------------------------- +- Changed - private int conversionDelay - is renamed to - private int bitResolution +As this variable holds the resolution. The delay for the conversion is derived from it. + +- Changed - uint8_t getResolution(uint8_t* deviceAddress); +If the device is not connected, it returns 0, otherwise it returns the resolution of the device. + +- Changed - bool setResolution(uint8_t* deviceAddress, uint8_t newResolution); +If the device is not connected, it returns FALSE (fail), otherwise it returns TRUE (succes). + +- Added - uint8_t getResolution(); +Returns bitResolution. + +- Added - void setResolution(uint8_t newResolution) +Sets the internal variable bitResolution, and all devices to this value + + + MINOR check connected state + ---------------------------- +- Changed - bool requestTemperaturesByIndex(deviceIndex) +Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise. + +- Changed - bool requestTemperaturesByAddress(deviceAddress) +Changed return type from void to bool. The function returns false if the device identified with [deviceAddress] is not found on the bus and true otherwise. +Added code to handle the DS18S20 which has a 9 bit resolution separately. +Changed code so the blocking delay matches the bitResolution set in the device with deviceAddress. + +- Changed - bool requestTemperaturesByIndex(uint8_t deviceIndex) +Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise. + + + +VERSION 3.6.0 +============== +DATE: 2010-10-10 + +- no detailed change history known except: + +- The OneWire code has been derived from +http://www.arduino.cc/playground/Learning/OneWire. +- Miles Burton originally developed this library. +- Tim Newsome added support for multiple sensors on +the same bus. +- Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5) diff --git a/firmware/libraries/DallasTemperature/examples/Alarm/Alarm.pde b/firmware/libraries/DallasTemperature/examples/Alarm/Alarm.pde new file mode 100644 index 0000000..d9c6e6c --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/Alarm/Alarm.pde @@ -0,0 +1,162 @@ +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +// arrays to hold device addresses +DeviceAddress insideThermometer, outsideThermometer; + +void setup(void) +{ + // start serial port + Serial.begin(9600); + Serial.println("Dallas Temperature IC Control Library Demo"); + + // Start up the library + sensors.begin(); + + // locate devices on the bus + Serial.print("Found "); + Serial.print(sensors.getDeviceCount(), DEC); + Serial.println(" devices."); + + // search for devices on the bus and assign based on an index. + if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); + if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); + + // show the addresses we found on the bus + Serial.print("Device 0 Address: "); + printAddress(insideThermometer); + Serial.println(); + + Serial.print("Device 0 Alarms: "); + printAlarms(insideThermometer); + Serial.println(); + + Serial.print("Device 1 Address: "); + printAddress(outsideThermometer); + Serial.println(); + + Serial.print("Device 1 Alarms: "); + printAlarms(outsideThermometer); + Serial.println(); + + Serial.println("Setting alarm temps..."); + + // alarm when temp is higher than 30C + sensors.setHighAlarmTemp(insideThermometer, 30); + + // alarm when temp is lower than -10C + sensors.setLowAlarmTemp(insideThermometer, -10); + + // alarm when temp is higher than 31C + sensors.setHighAlarmTemp(outsideThermometer, 31); + + // alarn when temp is lower than 27C + sensors.setLowAlarmTemp(outsideThermometer, 27); + + Serial.print("New Device 0 Alarms: "); + printAlarms(insideThermometer); + Serial.println(); + + Serial.print("New Device 1 Alarms: "); + printAlarms(outsideThermometer); + Serial.println(); +} + +// function to print a device address +void printAddress(DeviceAddress deviceAddress) +{ + for (uint8_t i = 0; i < 8; i++) + { + if (deviceAddress[i] < 16) Serial.print("0"); + Serial.print(deviceAddress[i], HEX); + } +} + +// function to print the temperature for a device +void printTemperature(DeviceAddress deviceAddress) +{ + float tempC = sensors.getTempC(deviceAddress); + Serial.print("Temp C: "); + Serial.print(tempC); + Serial.print(" Temp F: "); + Serial.print(DallasTemperature::toFahrenheit(tempC)); +} + +void printAlarms(uint8_t deviceAddress[]) +{ + char temp; + temp = sensors.getHighAlarmTemp(deviceAddress); + Serial.print("High Alarm: "); + Serial.print(temp, DEC); + Serial.print("C/"); + Serial.print(DallasTemperature::toFahrenheit(temp)); + Serial.print("F | Low Alarm: "); + temp = sensors.getLowAlarmTemp(deviceAddress); + Serial.print(temp, DEC); + Serial.print("C/"); + Serial.print(DallasTemperature::toFahrenheit(temp)); + Serial.print("F"); +} + +// main function to print information about a device +void printData(DeviceAddress deviceAddress) +{ + Serial.print("Device Address: "); + printAddress(deviceAddress); + Serial.print(" "); + printTemperature(deviceAddress); + Serial.println(); +} + +void checkAlarm(DeviceAddress deviceAddress) +{ + if (sensors.hasAlarm(deviceAddress)) + { + Serial.print("ALARM: "); + printData(deviceAddress); + } +} + +void loop(void) +{ + // call sensors.requestTemperatures() to issue a global temperature + // request to all devices on the bus + Serial.print("Requesting temperatures..."); + sensors.requestTemperatures(); + Serial.println("DONE"); + + // Method 1: + // check each address individually for an alarm condition + checkAlarm(insideThermometer); + checkAlarm(outsideThermometer); +/* + // Alternate method: + // Search the bus and iterate through addresses of devices with alarms + + // space for the alarm device's address + DeviceAddress alarmAddr; + + Serial.println("Searching for alarms..."); + + // resetAlarmSearch() must be called before calling alarmSearch() + sensors.resetAlarmSearch(); + + // alarmSearch() returns 0 when there are no devices with alarms + while (sensors.alarmSearch(alarmAddr)) + { + Serial.print("ALARM: "); + printData(alarmAddr); + } +*/ + +} + diff --git a/firmware/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde b/firmware/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde new file mode 100644 index 0000000..4b72962 --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde @@ -0,0 +1,144 @@ +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +// arrays to hold device addresses +DeviceAddress insideThermometer, outsideThermometer; + +// function that will be called when an alarm condition exists during DallasTemperatures::processAlarms(); +void newAlarmHandler(uint8_t* deviceAddress) +{ + Serial.println("Alarm Handler Start"); + printAlarmInfo(deviceAddress); + printTemp(deviceAddress); + Serial.println(); + Serial.println("Alarm Handler Finish"); +} + +void printCurrentTemp(DeviceAddress deviceAddress) +{ + printAddress(deviceAddress); + printTemp(deviceAddress); + Serial.println(); +} + +void printAddress(DeviceAddress deviceAddress) +{ + Serial.print("Address: "); + for (uint8_t i = 0; i < 8; i++) + { + if (deviceAddress[i] < 16) Serial.print("0"); + Serial.print(deviceAddress[i], HEX); + } + Serial.print(" "); +} + +void printTemp(DeviceAddress deviceAddress) +{ + float tempC = sensors.getTempC(deviceAddress); + if (tempC != DEVICE_DISCONNECTED) + { + Serial.print("Current Temp C: "); + Serial.print(tempC); + } + else Serial.print("DEVICE DISCONNECTED"); + Serial.print(" "); +} + +void printAlarmInfo(DeviceAddress deviceAddress) +{ + char temp; + printAddress(deviceAddress); + temp = sensors.getHighAlarmTemp(deviceAddress); + Serial.print("High Alarm: "); + Serial.print(temp, DEC); + Serial.print("C"); + Serial.print(" Low Alarm: "); + temp = sensors.getLowAlarmTemp(deviceAddress); + Serial.print(temp, DEC); + Serial.print("C"); + Serial.print(" "); +} + +void setup(void) +{ + // start serial port + Serial.begin(9600); + Serial.println("Dallas Temperature IC Control Library Demo"); + + // Start up the library + sensors.begin(); + + // locate devices on the bus + Serial.print("Found "); + Serial.print(sensors.getDeviceCount(), DEC); + Serial.println(" devices."); + + // search for devices on the bus and assign based on an index + if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); + if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); + + Serial.print("Device insideThermometer "); + printAlarmInfo(insideThermometer); + Serial.println(); + + Serial.print("Device outsideThermometer "); + printAlarmInfo(outsideThermometer); + Serial.println(); + + // set alarm ranges + Serial.println("Setting alarm temps..."); + sensors.setHighAlarmTemp(insideThermometer, 26); + sensors.setLowAlarmTemp(insideThermometer, 22); + sensors.setHighAlarmTemp(outsideThermometer, 25); + sensors.setLowAlarmTemp(outsideThermometer, 21); + + Serial.print("New insideThermometer "); + printAlarmInfo(insideThermometer); + Serial.println(); + + Serial.print("New outsideThermometer "); + printAlarmInfo(outsideThermometer); + Serial.println(); + + // attach alarm handler + sensors.setAlarmHandler(&newAlarmHandler); + +} + +void loop(void) +{ + // ask the devices to measure the temperature + sensors.requestTemperatures(); + + // if an alarm condition exists as a result of the most recent + // requestTemperatures() request, it exists until the next time + // requestTemperatures() is called AND there isn't an alarm condition + // on the device + if (sensors.hasAlarm()) + { + Serial.println("Oh noes! There is at least one alarm on the bus."); + } + + // call alarm handler function defined by sensors.setAlarmHandler + // for each device reporting an alarm + sensors.processAlarms(); + + if (!sensors.hasAlarm()) + { + // just print out the current temperature + printCurrentTemp(insideThermometer); + printCurrentTemp(outsideThermometer); + } + + delay(1000); +} + diff --git a/firmware/libraries/DallasTemperature/examples/Multiple/Multiple.pde b/firmware/libraries/DallasTemperature/examples/Multiple/Multiple.pde new file mode 100644 index 0000000..37e7ba6 --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/Multiple/Multiple.pde @@ -0,0 +1,140 @@ +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 +#define TEMPERATURE_PRECISION 9 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +// arrays to hold device addresses +DeviceAddress insideThermometer, outsideThermometer; + +void setup(void) +{ + // start serial port + Serial.begin(9600); + Serial.println("Dallas Temperature IC Control Library Demo"); + + // Start up the library + sensors.begin(); + + // locate devices on the bus + Serial.print("Locating devices..."); + Serial.print("Found "); + Serial.print(sensors.getDeviceCount(), DEC); + Serial.println(" devices."); + + // report parasite power requirements + Serial.print("Parasite power is: "); + if (sensors.isParasitePowerMode()) Serial.println("ON"); + else Serial.println("OFF"); + + // assign address manually. the addresses below will beed to be changed + // to valid device addresses on your bus. device address can be retrieved + // by using either oneWire.search(deviceAddress) or individually via + // sensors.getAddress(deviceAddress, index) + //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; + //outsideThermometer = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 }; + + // search for devices on the bus and assign based on an index. ideally, + // you would do this to initially discover addresses on the bus and then + // use those addresses and manually assign them (see above) once you know + // the devices on your bus (and assuming they don't change). + // + // method 1: by index + if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); + if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); + + // method 2: search() + // search() looks for the next device. Returns 1 if a new address has been + // returned. A zero might mean that the bus is shorted, there are no devices, + // or you have already retrieved all of them. It might be a good idea to + // check the CRC to make sure you didn't get garbage. The order is + // deterministic. You will always get the same devices in the same order + // + // Must be called before search() + //oneWire.reset_search(); + // assigns the first address found to insideThermometer + //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer"); + // assigns the seconds address found to outsideThermometer + //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer"); + + // show the addresses we found on the bus + Serial.print("Device 0 Address: "); + printAddress(insideThermometer); + Serial.println(); + + Serial.print("Device 1 Address: "); + printAddress(outsideThermometer); + Serial.println(); + + // set the resolution to 9 bit + sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION); + sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION); + + Serial.print("Device 0 Resolution: "); + Serial.print(sensors.getResolution(insideThermometer), DEC); + Serial.println(); + + Serial.print("Device 1 Resolution: "); + Serial.print(sensors.getResolution(outsideThermometer), DEC); + Serial.println(); +} + +// function to print a device address +void printAddress(DeviceAddress deviceAddress) +{ + for (uint8_t i = 0; i < 8; i++) + { + // zero pad the address if necessary + if (deviceAddress[i] < 16) Serial.print("0"); + Serial.print(deviceAddress[i], HEX); + } +} + +// function to print the temperature for a device +void printTemperature(DeviceAddress deviceAddress) +{ + float tempC = sensors.getTempC(deviceAddress); + Serial.print("Temp C: "); + Serial.print(tempC); + Serial.print(" Temp F: "); + Serial.print(DallasTemperature::toFahrenheit(tempC)); +} + +// function to print a device's resolution +void printResolution(DeviceAddress deviceAddress) +{ + Serial.print("Resolution: "); + Serial.print(sensors.getResolution(deviceAddress)); + Serial.println(); +} + +// main function to print information about a device +void printData(DeviceAddress deviceAddress) +{ + Serial.print("Device Address: "); + printAddress(deviceAddress); + Serial.print(" "); + printTemperature(deviceAddress); + Serial.println(); +} + +void loop(void) +{ + // call sensors.requestTemperatures() to issue a global temperature + // request to all devices on the bus + Serial.print("Requesting temperatures..."); + sensors.requestTemperatures(); + Serial.println("DONE"); + + // print the device information + printData(insideThermometer); + printData(outsideThermometer); +} + diff --git a/firmware/libraries/DallasTemperature/examples/Simple/Simple.pde b/firmware/libraries/DallasTemperature/examples/Simple/Simple.pde new file mode 100644 index 0000000..5b2954d --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/Simple/Simple.pde @@ -0,0 +1,33 @@ +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +void setup(void) +{ + // start serial port + Serial.begin(9600); + Serial.println("Dallas Temperature IC Control Library Demo"); + + // Start up the library + sensors.begin(); +} + +void loop(void) +{ + // call sensors.requestTemperatures() to issue a global temperature + // request to all devices on the bus + Serial.print("Requesting temperatures..."); + sensors.requestTemperatures(); // Send the command to get temperatures + Serial.println("DONE"); + + Serial.print("Temperature for the device 1 (index 0) is: "); + Serial.println(sensors.getTempCByIndex(0)); +} diff --git a/firmware/libraries/DallasTemperature/examples/Single/Single.pde b/firmware/libraries/DallasTemperature/examples/Single/Single.pde new file mode 100644 index 0000000..7336859 --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/Single/Single.pde @@ -0,0 +1,109 @@ +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +// arrays to hold device address +DeviceAddress insideThermometer; + +void setup(void) +{ + // start serial port + Serial.begin(9600); + Serial.println("Dallas Temperature IC Control Library Demo"); + + // locate devices on the bus + Serial.print("Locating devices..."); + sensors.begin(); + Serial.print("Found "); + Serial.print(sensors.getDeviceCount(), DEC); + Serial.println(" devices."); + + // report parasite power requirements + Serial.print("Parasite power is: "); + if (sensors.isParasitePowerMode()) Serial.println("ON"); + else Serial.println("OFF"); + + // assign address manually. the addresses below will beed to be changed + // to valid device addresses on your bus. device address can be retrieved + // by using either oneWire.search(deviceAddress) or individually via + // sensors.getAddress(deviceAddress, index) + //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; + + // Method 1: + // search for devices on the bus and assign based on an index. ideally, + // you would do this to initially discover addresses on the bus and then + // use those addresses and manually assign them (see above) once you know + // the devices on your bus (and assuming they don't change). + if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); + + // method 2: search() + // search() looks for the next device. Returns 1 if a new address has been + // returned. A zero might mean that the bus is shorted, there are no devices, + // or you have already retrieved all of them. It might be a good idea to + // check the CRC to make sure you didn't get garbage. The order is + // deterministic. You will always get the same devices in the same order + // + // Must be called before search() + //oneWire.reset_search(); + // assigns the first address found to insideThermometer + //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer"); + + // show the addresses we found on the bus + Serial.print("Device 0 Address: "); + printAddress(insideThermometer); + Serial.println(); + + // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions) + sensors.setResolution(insideThermometer, 9); + + Serial.print("Device 0 Resolution: "); + Serial.print(sensors.getResolution(insideThermometer), DEC); + Serial.println(); +} + +// function to print the temperature for a device +void printTemperature(DeviceAddress deviceAddress) +{ + // method 1 - slower + //Serial.print("Temp C: "); + //Serial.print(sensors.getTempC(deviceAddress)); + //Serial.print(" Temp F: "); + //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit + + // method 2 - faster + float tempC = sensors.getTempC(deviceAddress); + Serial.print("Temp C: "); + Serial.print(tempC); + Serial.print(" Temp F: "); + Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit +} + +void loop(void) +{ + // call sensors.requestTemperatures() to issue a global temperature + // request to all devices on the bus + Serial.print("Requesting temperatures..."); + sensors.requestTemperatures(); // Send the command to get temperatures + Serial.println("DONE"); + + // It responds almost immediately. Let's print out the data + printTemperature(insideThermometer); // Use a simple function to print out the data +} + +// function to print a device address +void printAddress(DeviceAddress deviceAddress) +{ + for (uint8_t i = 0; i < 8; i++) + { + if (deviceAddress[i] < 16) Serial.print("0"); + Serial.print(deviceAddress[i], HEX); + } +} diff --git a/firmware/libraries/DallasTemperature/examples/Tester/Tester.pde b/firmware/libraries/DallasTemperature/examples/Tester/Tester.pde new file mode 100644 index 0000000..33ca9ba --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/Tester/Tester.pde @@ -0,0 +1,124 @@ +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 +#define TEMPERATURE_PRECISION 9 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +int numberOfDevices; // Number of temperature devices found + +DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address + +void setup(void) +{ + // start serial port + Serial.begin(9600); + Serial.println("Dallas Temperature IC Control Library Demo"); + + // Start up the library + sensors.begin(); + + // Grab a count of devices on the wire + numberOfDevices = sensors.getDeviceCount(); + + // locate devices on the bus + Serial.print("Locating devices..."); + + Serial.print("Found "); + Serial.print(numberOfDevices, DEC); + Serial.println(" devices."); + + // report parasite power requirements + Serial.print("Parasite power is: "); + if (sensors.isParasitePowerMode()) Serial.println("ON"); + else Serial.println("OFF"); + + // Loop through each device, print out address + for(int i=0;i +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +void setup(void) +{ + // start serial port + Serial.begin(115200); + Serial.println("Dallas Temperature Control Library - Async Demo"); + Serial.println("\nDemo shows the difference in length of the call\n\n"); + + // Start up the library + sensors.begin(); +} + +void loop(void) +{ + // Request temperature conversion (traditional) + Serial.println("Before blocking requestForConversion"); + unsigned long start = millis(); + + sensors.requestTemperatures(); + + unsigned long stop = millis(); + Serial.println("After blocking requestForConversion"); + Serial.print("Time used: "); + Serial.println(stop - start); + + // get temperature + Serial.print("Temperature: "); + Serial.println(sensors.getTempCByIndex(0)); + Serial.println("\n"); + + // Request temperature conversion - non-blocking / async + Serial.println("Before NON-blocking/async requestForConversion"); + start = millis(); + sensors.setWaitForConversion(false); // makes it async + sensors.requestTemperatures(); + sensors.setWaitForConversion(true); + stop = millis(); + Serial.println("After NON-blocking/async requestForConversion"); + Serial.print("Time used: "); + Serial.println(stop - start); + + + // 9 bit resolution by default + // Note the programmer is responsible for the right delay + // we could do something usefull here instead of the delay + int resolution = 9; + delay(750/ (1 << (12-resolution))); + + // get temperature + Serial.print("Temperature: "); + Serial.println(sensors.getTempCByIndex(0)); + Serial.println("\n\n\n\n"); + + delay(5000); +} diff --git a/firmware/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde b/firmware/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde new file mode 100644 index 0000000..4322330 --- /dev/null +++ b/firmware/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde @@ -0,0 +1,80 @@ +// +// Sample of using Async reading of Dallas Temperature Sensors +// +#include +#include + +// Data wire is plugged into port 2 on the Arduino +#define ONE_WIRE_BUS 2 + +// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) +OneWire oneWire(ONE_WIRE_BUS); + +// Pass our oneWire reference to Dallas Temperature. +DallasTemperature sensors(&oneWire); + +DeviceAddress tempDeviceAddress; + +int resolution = 12; +unsigned long lastTempRequest = 0; +int delayInMillis = 0; +float temperature = 0.0; +int idle = 0; +// +// SETUP +// +void setup(void) +{ + Serial.begin(115200); + Serial.println("Dallas Temperature Control Library - Async Demo"); + Serial.print("Library Version: "); + Serial.println(DALLASTEMPLIBVERSION); + Serial.println("\n"); + + sensors.begin(); + sensors.getAddress(tempDeviceAddress, 0); + sensors.setResolution(tempDeviceAddress, resolution); + + sensors.setWaitForConversion(false); + sensors.requestTemperatures(); + delayInMillis = 750 / (1 << (12 - resolution)); + lastTempRequest = millis(); + + pinMode(13, OUTPUT); +} + +void loop(void) +{ + + if (millis() - lastTempRequest >= delayInMillis) // waited long enough?? + { + digitalWrite(13, LOW); + Serial.print(" Temperature: "); + temperature = sensors.getTempCByIndex(0); + Serial.println(temperature, resolution - 8); + Serial.print(" Resolution: "); + Serial.println(resolution); + Serial.print("Idle counter: "); + Serial.println(idle); + Serial.println(); + + idle = 0; + + // immediately after fetching the temperature we request a new sample + // in the async modus + // for the demo we let the resolution change to show differences + resolution++; + if (resolution > 12) resolution = 9; + + sensors.setResolution(tempDeviceAddress, resolution); + sensors.requestTemperatures(); + delayInMillis = 750 / (1 << (12 - resolution)); + lastTempRequest = millis(); + } + + digitalWrite(13, HIGH); + // we can do usefull things here + // for the demo we just count the idle time in millis + delay(1); + idle++; +} diff --git a/firmware/libraries/DallasTemperature/keywords.txt b/firmware/libraries/DallasTemperature/keywords.txt new file mode 100644 index 0000000..0212d44 --- /dev/null +++ b/firmware/libraries/DallasTemperature/keywords.txt @@ -0,0 +1,54 @@ +####################################### +# Syntax Coloring Map For Ultrasound +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### +DallasTemperature KEYWORD1 +OneWire KEYWORD1 +AlarmHandler KEYWORD1 +DeviceAddress KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +setResolution KEYWORD2 +getResolution KEYWORD2 +getTempC KEYWORD2 +toFahrenheit KEYWORD2 +getTempF KEYWORD2 +getTempCByIndex KEYWORD2 +getTempFByIndex KEYWORD2 +setWaitForConversion KEYWORD2 +getWaitForConversion KEYWORD2 +requestTemperatures KEYWORD2 +requestTemperaturesByAddress KEYWORD2 +requestTemperaturesByIndex KEYWORD2 +isParasitePowerMode KEYWORD2 +begin KEYWORD2 +getDeviceCount KEYWORD2 +getAddress KEYWORD2 +validAddress KEYWORD2 +isConnected KEYWORD2 +readScratchPad KEYWORD2 +writeScratchPad KEYWORD2 +readPowerSupply KEYWORD2 +setHighAlarmTemp KEYWORD2 +setLowAlarmTemp KEYWORD2 +getHighAlarmTemp KEYWORD2 +getLowAlarmTemp KEYWORD2 +resetAlarmSearch KEYWORD2 +alarmSearch KEYWORD2 +hasAlarm KEYWORD2 +toCelsius KEYWORD2 +processAlarmss KEYWORD2 +setAlarmHandlers KEYWORD2 +defaultAlarmHandler KEYWORD2 +calculateTemperature KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/firmware/libraries/OneWire/OneWire.cpp b/firmware/libraries/OneWire/OneWire.cpp new file mode 100644 index 0000000..5c3561a --- /dev/null +++ b/firmware/libraries/OneWire/OneWire.cpp @@ -0,0 +1,527 @@ +/* +Copyright (c) 2007, Jim Studt (original old version - many contributors since) + +The latest version of this library may be found at: + http://www.pjrc.com/teensy/td_libs_OneWire.html + +Version 2.1: + Arduino 1.0 compatibility, Paul Stoffregen + Improve temperature example, Paul Stoffregen + DS250x_PROM example, Guillermo Lovato + PIC32 (chipKit) compatibility, Jason Dangel, dangel.jason AT gmail.com + Improvements from Glenn Trewitt: + - crc16() now works + - check_crc16() does all of calculation/checking work. + - Added read_bytes() and write_bytes(), to reduce tedious loops. + - Added ds2408 example. + Delete very old, out-of-date readme file (info is here) + +Version 2.0: Modifications by Paul Stoffregen, January 2010: +http://www.pjrc.com/teensy/td_libs_OneWire.html + Search fix from Robin James + http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 + Use direct optimized I/O in all cases + Disable interrupts during timing critical sections + (this solves many random communication errors) + Disable interrupts during read-modify-write I/O + Reduce RAM consumption by eliminating unnecessary + variables and trimming many to 8 bits + Optimize both crc8 - table version moved to flash + +Modified to work with larger numbers of devices - avoids loop. +Tested in Arduino 11 alpha with 12 sensors. +26 Sept 2008 -- Robin James +http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 + +Updated to work with arduino-0008 and to include skip() as of +2007/07/06. --RJL20 + +Modified to calculate the 8-bit CRC directly, avoiding the need for +the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010 +-- Tom Pollard, Jan 23, 2008 + +Jim Studt's original library was modified by Josh Larios. + +Tom Pollard, pollard@alum.mit.edu, contributed around May 20, 2008 + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Much of the code was inspired by Derek Yerger's code, though I don't +think much of that remains. In any event that was.. + (copyleft) 2006 by Derek Yerger - Free to distribute freely. + +The CRC code was excerpted and inspired by the Dallas Semiconductor +sample code bearing this copyright. +//--------------------------------------------------------------------------- +// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES +// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// Except as contained in this notice, the name of Dallas Semiconductor +// shall not be used except as stated in the Dallas Semiconductor +// Branding Policy. +//-------------------------------------------------------------------------- +*/ + +#include "OneWire.h" + + +OneWire::OneWire(uint8_t pin) +{ + pinMode(pin, INPUT); + bitmask = PIN_TO_BITMASK(pin); + baseReg = PIN_TO_BASEREG(pin); +#if ONEWIRE_SEARCH + reset_search(); +#endif +} + + +// Perform the onewire reset function. We will wait up to 250uS for +// the bus to come high, if it doesn't then it is broken or shorted +// and we return a 0; +// +// Returns 1 if a device asserted a presence pulse, 0 otherwise. +// +uint8_t OneWire::reset(void) +{ + IO_REG_TYPE mask = bitmask; + volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; + uint8_t r; + uint8_t retries = 125; + + noInterrupts(); + DIRECT_MODE_INPUT(reg, mask); + interrupts(); + // wait until the wire is high... just in case + do { + if (--retries == 0) return 0; + delayMicroseconds(2); + } while ( !DIRECT_READ(reg, mask)); + + noInterrupts(); + DIRECT_WRITE_LOW(reg, mask); + DIRECT_MODE_OUTPUT(reg, mask); // drive output low + interrupts(); + delayMicroseconds(500); + noInterrupts(); + DIRECT_MODE_INPUT(reg, mask); // allow it to float + delayMicroseconds(80); + r = !DIRECT_READ(reg, mask); + interrupts(); + delayMicroseconds(420); + return r; +} + +// +// Write a bit. Port and bit is used to cut lookup time and provide +// more certain timing. +// +void OneWire::write_bit(uint8_t v) +{ + IO_REG_TYPE mask=bitmask; + volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; + + if (v & 1) { + noInterrupts(); + DIRECT_WRITE_LOW(reg, mask); + DIRECT_MODE_OUTPUT(reg, mask); // drive output low + delayMicroseconds(10); + DIRECT_WRITE_HIGH(reg, mask); // drive output high + interrupts(); + delayMicroseconds(55); + } else { + noInterrupts(); + DIRECT_WRITE_LOW(reg, mask); + DIRECT_MODE_OUTPUT(reg, mask); // drive output low + delayMicroseconds(65); + DIRECT_WRITE_HIGH(reg, mask); // drive output high + interrupts(); + delayMicroseconds(5); + } +} + +// +// Read a bit. Port and bit is used to cut lookup time and provide +// more certain timing. +// +uint8_t OneWire::read_bit(void) +{ + IO_REG_TYPE mask=bitmask; + volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; + uint8_t r; + + noInterrupts(); + DIRECT_MODE_OUTPUT(reg, mask); + DIRECT_WRITE_LOW(reg, mask); + delayMicroseconds(3); + DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise + delayMicroseconds(10); + r = DIRECT_READ(reg, mask); + interrupts(); + delayMicroseconds(53); + return r; +} + +// +// Write a byte. The writing code uses the active drivers to raise the +// pin high, if you need power after the write (e.g. DS18S20 in +// parasite power mode) then set 'power' to 1, otherwise the pin will +// go tri-state at the end of the write to avoid heating in a short or +// other mishap. +// +void OneWire::write(uint8_t v, uint8_t power /* = 0 */) { + uint8_t bitMask; + + for (bitMask = 0x01; bitMask; bitMask <<= 1) { + OneWire::write_bit( (bitMask & v)?1:0); + } + if ( !power) { + noInterrupts(); + DIRECT_MODE_INPUT(baseReg, bitmask); + DIRECT_WRITE_LOW(baseReg, bitmask); + interrupts(); + } +} + +void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) { + for (uint16_t i = 0 ; i < count ; i++) + write(buf[i]); + if (!power) { + noInterrupts(); + DIRECT_MODE_INPUT(baseReg, bitmask); + DIRECT_WRITE_LOW(baseReg, bitmask); + interrupts(); + } +} + +// +// Read a byte +// +uint8_t OneWire::read() { + uint8_t bitMask; + uint8_t r = 0; + + for (bitMask = 0x01; bitMask; bitMask <<= 1) { + if ( OneWire::read_bit()) r |= bitMask; + } + return r; +} + +void OneWire::read_bytes(uint8_t *buf, uint16_t count) { + for (uint16_t i = 0 ; i < count ; i++) + buf[i] = read(); +} + +// +// Do a ROM select +// +void OneWire::select( uint8_t rom[8]) +{ + int i; + + write(0x55); // Choose ROM + + for( i = 0; i < 8; i++) write(rom[i]); +} + +// +// Do a ROM skip +// +void OneWire::skip() +{ + write(0xCC); // Skip ROM +} + +void OneWire::depower() +{ + noInterrupts(); + DIRECT_MODE_INPUT(baseReg, bitmask); + interrupts(); +} + +#if ONEWIRE_SEARCH + +// +// You need to use this function to start a search again from the beginning. +// You do not need to do it for the first search, though you could. +// +void OneWire::reset_search() + { + // reset the search state + LastDiscrepancy = 0; + LastDeviceFlag = FALSE; + LastFamilyDiscrepancy = 0; + for(int i = 7; ; i--) + { + ROM_NO[i] = 0; + if ( i == 0) break; + } + } + +// +// Perform a search. If this function returns a '1' then it has +// enumerated the next device and you may retrieve the ROM from the +// OneWire::address variable. If there are no devices, no further +// devices, or something horrible happens in the middle of the +// enumeration then a 0 is returned. If a new device is found then +// its address is copied to newAddr. Use OneWire::reset_search() to +// start over. +// +// --- Replaced by the one from the Dallas Semiconductor web site --- +//-------------------------------------------------------------------------- +// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing +// search state. +// Return TRUE : device found, ROM number in ROM_NO buffer +// FALSE : device not found, end of search +// +uint8_t OneWire::search(uint8_t *newAddr) +{ + uint8_t id_bit_number; + uint8_t last_zero, rom_byte_number, search_result; + uint8_t id_bit, cmp_id_bit; + + unsigned char rom_byte_mask, search_direction; + + // initialize for search + id_bit_number = 1; + last_zero = 0; + rom_byte_number = 0; + rom_byte_mask = 1; + search_result = 0; + + // if the last call was not the last one + if (!LastDeviceFlag) + { + // 1-Wire reset + if (!reset()) + { + // reset the search + LastDiscrepancy = 0; + LastDeviceFlag = FALSE; + LastFamilyDiscrepancy = 0; + return FALSE; + } + + // issue the search command + write(0xF0); + + // loop to do the search + do + { + // read a bit and its complement + id_bit = read_bit(); + cmp_id_bit = read_bit(); + + // check for no devices on 1-wire + if ((id_bit == 1) && (cmp_id_bit == 1)) + break; + else + { + // all devices coupled have 0 or 1 + if (id_bit != cmp_id_bit) + search_direction = id_bit; // bit write value for search + else + { + // if this discrepancy if before the Last Discrepancy + // on a previous next then pick the same as last time + if (id_bit_number < LastDiscrepancy) + search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0); + else + // if equal to last pick 1, if not then pick 0 + search_direction = (id_bit_number == LastDiscrepancy); + + // if 0 was picked then record its position in LastZero + if (search_direction == 0) + { + last_zero = id_bit_number; + + // check for Last discrepancy in family + if (last_zero < 9) + LastFamilyDiscrepancy = last_zero; + } + } + + // set or clear the bit in the ROM byte rom_byte_number + // with mask rom_byte_mask + if (search_direction == 1) + ROM_NO[rom_byte_number] |= rom_byte_mask; + else + ROM_NO[rom_byte_number] &= ~rom_byte_mask; + + // serial number search direction write bit + write_bit(search_direction); + + // increment the byte counter id_bit_number + // and shift the mask rom_byte_mask + id_bit_number++; + rom_byte_mask <<= 1; + + // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask + if (rom_byte_mask == 0) + { + rom_byte_number++; + rom_byte_mask = 1; + } + } + } + while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 + + // if the search was successful then + if (!(id_bit_number < 65)) + { + // search successful so set LastDiscrepancy,LastDeviceFlag,search_result + LastDiscrepancy = last_zero; + + // check for last device + if (LastDiscrepancy == 0) + LastDeviceFlag = TRUE; + + search_result = TRUE; + } + } + + // if no device found then reset counters so next 'search' will be like a first + if (!search_result || !ROM_NO[0]) + { + LastDiscrepancy = 0; + LastDeviceFlag = FALSE; + LastFamilyDiscrepancy = 0; + search_result = FALSE; + } + for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i]; + return search_result; + } + +#endif + +#if ONEWIRE_CRC +// The 1-Wire CRC scheme is described in Maxim Application Note 27: +// "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products" +// + +#if ONEWIRE_CRC8_TABLE +// This table comes from Dallas sample code where it is freely reusable, +// though Copyright (C) 2000 Dallas Semiconductor Corporation +static const uint8_t PROGMEM dscrc_table[] = { + 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, + 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, + 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, + 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, + 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, + 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, + 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, + 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, + 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, + 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, + 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, + 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, + 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, + 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, + 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, + 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; + +// +// Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM +// and the registers. (note: this might better be done without to +// table, it would probably be smaller and certainly fast enough +// compared to all those delayMicrosecond() calls. But I got +// confused, so I use this table from the examples.) +// +uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) +{ + uint8_t crc = 0; + + while (len--) { + crc = pgm_read_byte(dscrc_table + (crc ^ *addr++)); + } + return crc; +} +#else +// +// Compute a Dallas Semiconductor 8 bit CRC directly. +// this is much slower, but much smaller, than the lookup table. +// +uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) +{ + uint8_t crc = 0; + + while (len--) { + uint8_t inbyte = *addr++; + for (uint8_t i = 8; i; i--) { + uint8_t mix = (crc ^ inbyte) & 0x01; + crc >>= 1; + if (mix) crc ^= 0x8C; + inbyte >>= 1; + } + } + return crc; +} +#endif + +#if ONEWIRE_CRC16 +bool OneWire::check_crc16(uint8_t* input, uint16_t len, uint8_t* inverted_crc) +{ + uint16_t crc = ~crc16(input, len); + return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1]; +} + +uint16_t OneWire::crc16(uint8_t* input, uint16_t len) +{ + static const uint8_t oddparity[16] = + { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; + uint16_t crc = 0; // Starting seed is zero. + + for (uint16_t i = 0 ; i < len ; i++) { + // Even though we're just copying a byte from the input, + // we'll be doing 16-bit computation with it. + uint16_t cdata = input[i]; + cdata = (cdata ^ (crc & 0xff)) & 0xff; + crc >>= 8; + + if (oddparity[cdata & 0x0F] ^ oddparity[cdata >> 4]) + crc ^= 0xC001; + + cdata <<= 6; + crc ^= cdata; + cdata <<= 1; + crc ^= cdata; + } + return crc; +} +#endif + +#endif diff --git a/firmware/libraries/OneWire/OneWire.h b/firmware/libraries/OneWire/OneWire.h new file mode 100644 index 0000000..2737b27 --- /dev/null +++ b/firmware/libraries/OneWire/OneWire.h @@ -0,0 +1,192 @@ +#ifndef OneWire_h +#define OneWire_h + +#include + +#if ARDUINO >= 100 +#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc +#else +#include "WProgram.h" // for delayMicroseconds +#include "pins_arduino.h" // for digitalPinToBitMask, etc +#endif + +// You can exclude certain features from OneWire. In theory, this +// might save some space. In practice, the compiler automatically +// removes unused code (technically, the linker, using -fdata-sections +// and -ffunction-sections when compiling, and Wl,--gc-sections +// when linking), so most of these will not result in any code size +// reduction. Well, unless you try to use the missing features +// and redesign your program to not need them! ONEWIRE_CRC8_TABLE +// is the exception, because it selects a fast but large algorithm +// or a small but slow algorithm. + +// you can exclude onewire_search by defining that to 0 +#ifndef ONEWIRE_SEARCH +#define ONEWIRE_SEARCH 1 +#endif + +// You can exclude CRC checks altogether by defining this to 0 +#ifndef ONEWIRE_CRC +#define ONEWIRE_CRC 1 +#endif + +// Select the table-lookup method of computing the 8-bit CRC +// by setting this to 1. The lookup table enlarges code size by +// about 250 bytes. It does NOT consume RAM (but did in very +// old versions of OneWire). If you disable this, a slower +// but very compact algorithm is used. +#ifndef ONEWIRE_CRC8_TABLE +#define ONEWIRE_CRC8_TABLE 1 +#endif + +// You can allow 16-bit CRC checks by defining this to 1 +// (Note that ONEWIRE_CRC must also be 1.) +#ifndef ONEWIRE_CRC16 +#define ONEWIRE_CRC16 1 +#endif + +#define FALSE 0 +#define TRUE 1 + +// Platform specific I/O definitions + +#if defined(__AVR__) +#define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint8_t +#define IO_REG_ASM asm("r30") +#define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) +#define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask)) +#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask)) +#define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask)) +#define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask)) + +#elif defined(__PIC32MX__) +#include // is this necessary? +#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) +#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) +#define IO_REG_TYPE uint32_t +#define IO_REG_ASM +#define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 +#define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 +#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 +#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 +#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28 + +#else +#error "Please define I/O register types here" +#endif + + +class OneWire +{ + private: + IO_REG_TYPE bitmask; + volatile IO_REG_TYPE *baseReg; + +#if ONEWIRE_SEARCH + // global search state + unsigned char ROM_NO[8]; + uint8_t LastDiscrepancy; + uint8_t LastFamilyDiscrepancy; + uint8_t LastDeviceFlag; +#endif + + public: + OneWire( uint8_t pin); + + // Perform a 1-Wire reset cycle. Returns 1 if a device responds + // with a presence pulse. Returns 0 if there is no device or the + // bus is shorted or otherwise held low for more than 250uS + uint8_t reset(void); + + // Issue a 1-Wire rom select command, you do the reset first. + void select( uint8_t rom[8]); + + // Issue a 1-Wire rom skip command, to address all on bus. + void skip(void); + + // Write a byte. If 'power' is one then the wire is held high at + // the end for parasitically powered devices. You are responsible + // for eventually depowering it by calling depower() or doing + // another read or write. + void write(uint8_t v, uint8_t power = 0); + + void write_bytes(const uint8_t *buf, uint16_t count, bool power = 0); + + // Read a byte. + uint8_t read(void); + + void read_bytes(uint8_t *buf, uint16_t count); + + // Write a bit. The bus is always left powered at the end, see + // note in write() about that. + void write_bit(uint8_t v); + + // Read a bit. + uint8_t read_bit(void); + + // Stop forcing power onto the bus. You only need to do this if + // you used the 'power' flag to write() or used a write_bit() call + // and aren't about to do another read or write. You would rather + // not leave this powered if you don't have to, just in case + // someone shorts your bus. + void depower(void); + +#if ONEWIRE_SEARCH + // Clear the search state so that if will start from the beginning again. + void reset_search(); + + // Look for the next device. Returns 1 if a new address has been + // returned. A zero might mean that the bus is shorted, there are + // no devices, or you have already retrieved all of them. It + // might be a good idea to check the CRC to make sure you didn't + // get garbage. The order is deterministic. You will always get + // the same devices in the same order. + uint8_t search(uint8_t *newAddr); +#endif + +#if ONEWIRE_CRC + // Compute a Dallas Semiconductor 8 bit CRC, these are used in the + // ROM and scratchpad registers. + static uint8_t crc8( uint8_t *addr, uint8_t len); + +#if ONEWIRE_CRC16 + // Compute the 1-Wire CRC16 and compare it against the received CRC. + // Example usage (reading a DS2408): + // // Put everything in a buffer so we can compute the CRC easily. + // uint8_t buf[13]; + // buf[0] = 0xF0; // Read PIO Registers + // buf[1] = 0x88; // LSB address + // buf[2] = 0x00; // MSB address + // WriteBytes(net, buf, 3); // Write 3 cmd bytes + // ReadBytes(net, buf+3, 10); // Read 6 data bytes, 2 0xFF, 2 CRC16 + // if (!CheckCRC16(buf, 11, &buf[11])) { + // // Handle error. + // } + // + // @param input - Array of bytes to checksum. + // @param len - How many bytes to use. + // @param inverted_crc - The two CRC16 bytes in the received data. + // This should just point into the received data, + // *not* at a 16-bit integer. + // @return True, iff the CRC matches. + static bool check_crc16(uint8_t* input, uint16_t len, uint8_t* inverted_crc); + + // Compute a Dallas Semiconductor 16 bit CRC. This is required to check + // the integrity of data received from many 1-Wire devices. Note that the + // CRC computed here is *not* what you'll get from the 1-Wire network, + // for two reasons: + // 1) The CRC is transmitted bitwise inverted. + // 2) Depending on the endian-ness of your processor, the binary + // representation of the two-byte return value may have a different + // byte order than the two bytes you get from 1-Wire. + // @param input - Array of bytes to checksum. + // @param len - How many bytes to use. + // @return The CRC16, as defined by Dallas Semiconductor. + static uint16_t crc16(uint8_t* input, uint16_t len); +#endif +#endif +}; + +#endif diff --git a/firmware/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde b/firmware/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde new file mode 100644 index 0000000..1d632ca --- /dev/null +++ b/firmware/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde @@ -0,0 +1,109 @@ +#include + +// OneWire DS18S20, DS18B20, DS1822 Temperature Example +// +// http://www.pjrc.com/teensy/td_libs_OneWire.html +// +// The DallasTemperature library can do all this work for you! +// http://milesburton.com/Dallas_Temperature_Control_Library + +OneWire ds(10); // on pin 10 + +void setup(void) { + Serial.begin(9600); +} + +void loop(void) { + byte i; + byte present = 0; + byte type_s; + byte data[12]; + byte addr[8]; + float celsius, fahrenheit; + + if ( !ds.search(addr)) { + Serial.println("No more addresses."); + Serial.println(); + ds.reset_search(); + delay(250); + return; + } + + Serial.print("ROM ="); + for( i = 0; i < 8; i++) { + Serial.write(' '); + Serial.print(addr[i], HEX); + } + + if (OneWire::crc8(addr, 7) != addr[7]) { + Serial.println("CRC is not valid!"); + return; + } + Serial.println(); + + // the first ROM byte indicates which chip + switch (addr[0]) { + case 0x10: + Serial.println(" Chip = DS18S20"); // or old DS1820 + type_s = 1; + break; + case 0x28: + Serial.println(" Chip = DS18B20"); + type_s = 0; + break; + case 0x22: + Serial.println(" Chip = DS1822"); + type_s = 0; + break; + default: + Serial.println("Device is not a DS18x20 family device."); + return; + } + + ds.reset(); + ds.select(addr); + ds.write(0x44,1); // start conversion, with parasite power on at the end + + delay(1000); // maybe 750ms is enough, maybe not + // we might do a ds.depower() here, but the reset will take care of it. + + present = ds.reset(); + ds.select(addr); + ds.write(0xBE); // Read Scratchpad + + Serial.print(" Data = "); + Serial.print(present,HEX); + Serial.print(" "); + for ( i = 0; i < 9; i++) { // we need 9 bytes + data[i] = ds.read(); + Serial.print(data[i], HEX); + Serial.print(" "); + } + Serial.print(" CRC="); + Serial.print(OneWire::crc8(data, 8), HEX); + Serial.println(); + + // convert the data to actual temperature + + unsigned int raw = (data[1] << 8) | data[0]; + if (type_s) { + raw = raw << 3; // 9 bit resolution default + if (data[7] == 0x10) { + // count remain gives full 12 bit resolution + raw = (raw & 0xFFF0) + 12 - data[6]; + } + } else { + byte cfg = (data[4] & 0x60); + if (cfg == 0x00) raw = raw << 3; // 9 bit resolution, 93.75 ms + else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms + else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms + // default is 12 bit resolution, 750 ms conversion time + } + celsius = (float)raw / 16.0; + fahrenheit = celsius * 1.8 + 32.0; + Serial.print(" Temperature = "); + Serial.print(celsius); + Serial.print(" Celsius, "); + Serial.print(fahrenheit); + Serial.println(" Fahrenheit"); +} diff --git a/firmware/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde b/firmware/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde new file mode 100644 index 0000000..d171f9b --- /dev/null +++ b/firmware/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde @@ -0,0 +1,77 @@ +#include + +/* + * DS2408 8-Channel Addressable Switch + * + * Writte by Glenn Trewitt, glenn at trewitt dot org + * + * Some notes about the DS2408: + * - Unlike most input/output ports, the DS2408 doesn't have mode bits to + * set whether the pins are input or output. If you issue a read command, + * they're inputs. If you write to them, they're outputs. + * - For reading from a switch, you should use 10K pull-up resisters. + */ + +void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0) { + for (uint8_t i = 0; i < count; i++) { + Serial.print(addr[i]>>4, HEX); + Serial.print(addr[i]&0x0f, HEX); + } + if (newline) + Serial.println(); +} + +void ReadAndReport(OneWire* net, uint8_t* addr) { + Serial.print(" Reading DS2408 "); + PrintBytes(addr, 8); + Serial.println(); + + uint8_t buf[13]; // Put everything in the buffer so we can compute CRC easily. + buf[0] = 0xF0; // Read PIO Registers + buf[1] = 0x88; // LSB address + buf[2] = 0x00; // MSB address + net->write_bytes(buf, 3); + net->read_bytes(buf+3, 10); // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16 + net->reset(); + + if (!OneWire::check_crc16(buf, 11, &buf[11])) { + Serial.print("CRC failure in DS2408 at "); + PrintBytes(addr, 8, true); + return; + } + Serial.print(" DS2408 data = "); + // First 3 bytes contain command, register address. + Serial.println(buf[3], BIN); +} + +OneWire net(10); // on pin 10 + +void setup(void) { + Serial.begin(9600); +} + +void loop(void) { + byte i; + byte present = 0; + byte addr[8]; + + if (!net.search(addr)) { + Serial.print("No more addresses.\n"); + net.reset_search(); + delay(1000); + return; + } + + if (OneWire::crc8(addr, 7) != addr[7]) { + Serial.print("CRC is not valid!\n"); + return; + } + + if (addr[0] != 0x29) { + PrintBytes(addr, 8); + Serial.print(" is not a DS2408.\n"); + return; + } + + ReadAndReport(&net, addr); +} diff --git a/firmware/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde b/firmware/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde new file mode 100644 index 0000000..baa51c8 --- /dev/null +++ b/firmware/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde @@ -0,0 +1,90 @@ +/* +DS250x add-only programmable memory reader w/SKIP ROM. + + The DS250x is a 512/1024bit add-only PROM(you can add data but cannot change the old one) that's used mainly for device identification purposes + like serial number, mfgr data, unique identifiers, etc. It uses the Maxim 1-wire bus. + + This sketch will use the SKIP ROM function that skips the 1-Wire search phase since we only have one device connected in the bus on digital pin 6. + If more than one device is connected to the bus, it will fail. + Sketch will not verify if device connected is from the DS250x family since the skip rom function effectively skips the family-id byte readout. + thus it is possible to run this sketch with any Maxim OneWire device in which case the command CRC will most likely fail. + Sketch will only read the first page of memory(32bits) starting from the lower address(0000h), if more than 1 device is present, then use the sketch with search functions. + Remember to put a 4.7K pullup resistor between pin 6 and +Vcc + + To change the range or ammount of data to read, simply change the data array size, LSB/MSB addresses and for loop iterations + + This example code is in the public domain and is provided AS-IS. + + Built with Arduino 0022 and PJRC OneWire 2.0 library http://www.pjrc.com/teensy/td_libs_OneWire.html + + created by Guillermo Lovato + march/2011 + + */ + +#include +OneWire ds(6); // OneWire bus on digital pin 6 +void setup() { + Serial.begin (9600); +} + +void loop() { + byte i; // This is for the for loops + boolean present; // device present var + byte data[32]; // container for the data from device + byte leemem[3] = { // array with the commands to initiate a read, DS250x devices expect 3 bytes to start a read: command,LSB&MSB adresses + 0xF0 , 0x00 , 0x00 }; // 0xF0 is the Read Data command, followed by 00h 00h as starting address(the beginning, 0000h) + byte ccrc; // Variable to store the command CRC + byte ccrc_calc; + + present = ds.reset(); // OneWire bus reset, always needed to start operation on the bus, returns a 1/TRUE if there's a device present. + ds.skip(); // Skip ROM search + + if (present == TRUE){ // We only try to read the data if there's a device present + Serial.println("DS250x device present"); + ds.write(leemem[0],1); // Read data command, leave ghost power on + ds.write(leemem[1],1); // LSB starting address, leave ghost power on + ds.write(leemem[2],1); // MSB starting address, leave ghost power on + + ccrc = ds.read(); // DS250x generates a CRC for the command we sent, we assign a read slot and store it's value + ccrc_calc = OneWire::crc8(leemem, 3); // We calculate the CRC of the commands we sent using the library function and store it + + if ( ccrc_calc != ccrc) { // Then we compare it to the value the ds250x calculated, if it fails, we print debug messages and abort + Serial.println("Invalid command CRC!"); + Serial.print("Calculated CRC:"); + Serial.println(ccrc_calc,HEX); // HEX makes it easier to observe and compare + Serial.print("DS250x readback CRC:"); + Serial.println(ccrc,HEX); + return; // Since CRC failed, we abort the rest of the loop and start over + } + Serial.println("Data is: "); // For the printout of the data + for ( i = 0; i < 32; i++) { // Now it's time to read the PROM data itself, each page is 32 bytes so we need 32 read commands + data[i] = ds.read(); // we store each read byte to a different position in the data array + Serial.print(data[i]); // printout in ASCII + Serial.print(" "); // blank space + } + Serial.println(); + delay(5000); // Delay so we don't saturate the serial output + } + else { // Nothing is connected in the bus + Serial.println("Nothing connected"); + delay(3000); + } +} + + + + + + + + + + + + + + + + + diff --git a/firmware/libraries/OneWire/keywords.txt b/firmware/libraries/OneWire/keywords.txt new file mode 100644 index 0000000..bee5d90 --- /dev/null +++ b/firmware/libraries/OneWire/keywords.txt @@ -0,0 +1,38 @@ +####################################### +# Syntax Coloring Map For OneWire +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +OneWire KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +reset KEYWORD2 +write_bit KEYWORD2 +read_bit KEYWORD2 +write KEYWORD2 +write_bytes KEYWORD2 +read KEYWORD2 +read_bytes KEYWORD2 +select KEYWORD2 +skip KEYWORD2 +depower KEYWORD2 +reset_search KEYWORD2 +search KEYWORD2 +crc8 KEYWORD2 +crc16 KEYWORD2 +check_crc16 KEYWORD2 + +####################################### +# Instances (KEYWORD2) +####################################### + + +####################################### +# Constants (LITERAL1) +####################################### From 5836ac23ffed8a94ac8b5b57f0a0b708c2e15fff Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 3 Oct 2012 16:33:55 +0200 Subject: [PATCH 060/344] Minfixes --- examples/dallastemperature.py | 4 ++-- examples/mytemperaturelib.py | 6 +++--- firmware/Makefile | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 93bedb6..8272534 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -11,6 +11,6 @@ while True: sensors.requestTemperatures() temp = sensors.getTempCByIndex(0) - print temp - print DallasTemperature.toFahrenheit(temp) + print "The temperature, in Celsius degrees is %0.2f" % temp + print "Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp) diff --git a/examples/mytemperaturelib.py b/examples/mytemperaturelib.py index 7175080..5d55dea 100755 --- a/examples/mytemperaturelib.py +++ b/examples/mytemperaturelib.py @@ -7,7 +7,7 @@ from nanpy import (Arduino, OneWire) import time -class DallasTemperature(): +class FakeDallasTemperature(): def __init__(self, pin): self.__ds = OneWire(pin) @@ -78,8 +78,8 @@ def getFahrenheit(self): lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString("Loc. London") - temp_int = DallasTemperature(5) - temp_ext = DallasTemperature(6) + temp_int = FakeDallasTemperature(6) + temp_ext = FakeDallasTemperature(5) while(1): lcd.setCursor(0, 1) diff --git a/firmware/Makefile b/firmware/Makefile index f8c8f4c..7312264 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -293,7 +293,6 @@ all: target target: $(TARGET).hex upload: - @echo $(LIBRARIES) @echo "\nUploading to board..." @test -n "$(SERIALDEV)" || { \ echo "error: SERIALDEV could not be determined automatically." >&2; \ From 8aba3c68ec953e897aae47e7349fa14d8c2fc243 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 3 Oct 2012 16:35:33 +0200 Subject: [PATCH 061/344] Bumped to version 0.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 34819b6..80632ed 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.3", + version="0.4", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From d0ac0bd674f54db646fab095e521490ebe2c1097 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Tue, 9 Oct 2012 12:22:16 +0200 Subject: [PATCH 062/344] A new decorator for changing the return type --- examples/melody.py | 2 +- nanpy/arduino.py | 6 +++--- nanpy/arduinoboard.py | 25 +++++++++---------------- nanpy/dallastemperature.py | 10 +++++----- nanpy/onewire.py | 4 ++-- nanpy/servo.py | 6 +++--- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/examples/melody.py b/examples/melody.py index 3e1e382..cc2a6df 100755 --- a/examples/melody.py +++ b/examples/melody.py @@ -10,7 +10,7 @@ [Tone.NOTE_A3, 4], [Tone.NOTE_G3, 4], [0, 4], [Tone.NOTE_B3, 4], [Tone.NOTE_C4, 4]] -tone = Tone(13) +tone = Tone(4) for note in melody: tone.play(note[0] , 1000/note[1]) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 22246ef..d77745d 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import (call_static_method, return_value) -from nanpy.arduinoboard import (arduinoclassmethod, returnint) +from nanpy.arduinoboard import (arduinoclassmethod, returns) class Arduino(): @@ -14,7 +14,7 @@ def digitalWrite(cls, pin, value): pass @classmethod - @returnint + @returns(int) @arduinoclassmethod def digitalRead(cls, pin): pass @@ -25,7 +25,7 @@ def analogWrite(cls, pin, value): pass @classmethod - @returnint + @returns(int) @arduinoclassmethod def analogRead(cls, pin): pass diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 6859dd1..4f7caa3 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -40,22 +40,15 @@ def _call(namespace, id, args): mutex.release() return ret -def returnfloat(conv): - def wrapper(self, *args, **kwargs): - try: - return float(conv(self, *args, **kwargs)) - except ValueError: - return -1 - - return wrapper - -def returnint(conv, *args, **kwargs): - def wrapper(self, *args, **kwargs): - try: - return int(conv(self, *args, **kwargs)) - except ValueError: - return -1 - return wrapper +def returns(fconv): + def wrapf(func): + def wrapper(self, *args, **kwargs): + try: + return fconv(func(self, *args, **kwargs)) + except ValueError: + return -1 + return wrapper + return wrapf def arduinoobjectmethod(funct, *args, **kwargs): def wrapper(self, *args, **kwargs): diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 1f8961e..2bdfea8 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, arduinoclassmethod, returnfloat, returnint) +from nanpy.arduinoboard import (arduinoobjectmethod, arduinoclassmethod, returns) class DallasTemperature(ArduinoObject): @@ -11,24 +11,24 @@ def __init__(self, pin): def requestTemperatures(self): pass - @returnfloat + @returns(float) @arduinoobjectmethod def getTempCByIndex(self, index): pass - @returnfloat + @returns(float) @arduinoobjectmethod def getTempFByIndex(self, index): pass @classmethod - @returnfloat + @returns(float) @arduinoclassmethod def toCelsius(cls, value): pass @classmethod - @returnfloat + @returns(float) @arduinoclassmethod def toFahrenheit(cls, value): pass diff --git a/nanpy/onewire.py b/nanpy/onewire.py index 613afe4..ed834c3 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returnint) +from nanpy.arduinoboard import (arduinoobjectmethod, returns) class OneWireAddress(): @@ -24,7 +24,7 @@ def search(self): def select(self, address): return self.call('select', address.get()) - @returnint + @returns(int) @arduinoobjectmethod def read(self): pass diff --git a/nanpy/servo.py b/nanpy/servo.py index c87ea23..062130b 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returnint) +from nanpy.arduinoboard import (arduinoobjectmethod, returns) class Servo(ArduinoObject): @@ -10,7 +10,7 @@ def __init__(self, pin): def write(self, value): pass - @returnint + @returns(int) @arduinoobjectmethod def read(self): pass @@ -19,7 +19,7 @@ def read(self): def writeMicroseconds(self, value): pass - @returnint + @returns(int) @arduinoobjectmethod def readMicroseconds(self, value): pass From a12df5be3d569329ab457385441877612f04939b Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Tue, 9 Oct 2012 13:32:29 +0200 Subject: [PATCH 063/344] Deleted Utilities, Serial operations moved on MethodDescriptor, see returns method --- firmware/DallasTemperatureClass.cpp | 12 +++---- firmware/LiquidCrystalClass.cpp | 6 ++-- firmware/MethodDescriptor.cpp | 52 +++++++++++++++++++++++++---- firmware/MethodDescriptor.h | 10 ++++-- firmware/OneWireClass.cpp | 16 ++++----- firmware/ServoClass.cpp | 14 ++++---- firmware/StepperClass.cpp | 6 ++-- firmware/ToneClass.cpp | 6 ++-- firmware/Utilities.cpp | 21 ------------ firmware/Utilities.h | 7 ---- 10 files changed, 83 insertions(+), 67 deletions(-) delete mode 100644 firmware/Utilities.cpp delete mode 100644 firmware/Utilities.h diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index e0a23fc..15631ff 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -17,28 +17,28 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { DallasTemperature* dt = new DallasTemperature(&(*wr)); v.insert(dt); dt->begin(); - Serial.println(v.getLastIndex()); + m->returns(v.getLastIndex()); } if (strcmp(m->getName(), "requestTemperatures") == 0) { v[m->getObjectId()]->requestTemperatures(); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "getTempCByIndex") == 0) { - Serial.println(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); + m->returns(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); } if (strcmp(m->getName(), "getTempFByIndex") == 0) { - Serial.println(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); + m->returns(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); } if (strcmp(m->getName(), "toFahrenheit") == 0) { - Serial.println(DallasTemperature::toFahrenheit(m->getFloat(0))); + m->returns(DallasTemperature::toFahrenheit(m->getFloat(0))); } if (strcmp(m->getName(), "toCelsius") == 0) { - Serial.println(DallasTemperature::toCelsius(m->getFloat(0))); + m->returns(DallasTemperature::toCelsius(m->getFloat(0))); } } diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 7a11f00..7862c09 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -15,17 +15,17 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { v.insert(new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); - Serial.println(v.getLastIndex()); + m->returns(v.getLastIndex()); } if (strcmp(m->getName(), "printString") == 0) { v[m->getObjectId()]->print(m->getString(0)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "setCursor") == 0) { v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); - Serial.println("0"); + m->returns("0"); } } diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index 7221d83..68d2f77 100644 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -1,24 +1,45 @@ #include "MethodDescriptor.h" -#include "Utilities.h" #include #include +#include + +char* readStringFromSerial() +{ + char* buffer = (char*)malloc(30); + int i=0; + char ch = '0'; + do { + ch = Serial.read(); + if(ch != '\0' && ch < 255 && ch >= 0) { + buffer[i++] = ch; + } + } while(ch != '\0'); + char* buffer2 = (char*)malloc(i + 1); + buffer[i] = '\0'; + strcpy(buffer2, buffer); + free(buffer); + return buffer2; +}; MethodDescriptor::MethodDescriptor() { this->classname = readStringFromSerial(); - char* buff = readStringFromSerial(); + + char* buff; + + buff = readStringFromSerial(); this->objid = atoi(buff); free(buff); buff = readStringFromSerial(); this->n_args = atoi(buff); free(buff); + this->name = readStringFromSerial(); this->stack = (char**)malloc(sizeof(char*) * this->n_args); - for(int n = 0; n < this->n_args; n++) - { + for(int n = 0; n < this->n_args; n++) { this->stack[n] = readStringFromSerial(); } @@ -56,12 +77,31 @@ char* MethodDescriptor::getName() { return this->name; }; +void MethodDescriptor::returns(String& val) { + Serial.println(val); +} + +void MethodDescriptor::returns(const char* val) { + Serial.println(val); +} + +void MethodDescriptor::returns(int val) { + Serial.println(val); +} + +void MethodDescriptor::returns(float val) { + Serial.println(val); +} + +void MethodDescriptor::returns(double val) { + Serial.println(val); +} + MethodDescriptor::~MethodDescriptor() { delete(name); delete(classname); - for(int n = 0; n < this->n_args; n++) - { + for(int n = 0; n < this->n_args; n++) { delete(this->stack[n]); } diff --git a/firmware/MethodDescriptor.h b/firmware/MethodDescriptor.h index 729e773..e933c85 100644 --- a/firmware/MethodDescriptor.h +++ b/firmware/MethodDescriptor.h @@ -1,6 +1,8 @@ #ifndef METHOD_DESCRIPTOR #define METHOD_DESCRIPTOR +#include + class MethodDescriptor { private: @@ -20,11 +22,13 @@ class MethodDescriptor { double getDouble(int n); char* getString(int n); char* getName(); + void returns(String& val); + void returns(const char* val); + void returns(int val); + void returns(float val); + void returns(double val); ~MethodDescriptor(); }; - - - #endif diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index c7aee2f..e21361d 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -11,7 +11,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "new") == 0) { v.insert(new OneWire(m->getInt(0))); - Serial.println(v.getLastIndex()); + m->returns(v.getLastIndex()); } if (strcmp(m->getName(), "search") == 0) { @@ -21,7 +21,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { if(!res) { v[m->getObjectId()]->reset_search(); delay(250); - Serial.println("1"); + m->returns("1"); } else { @@ -29,17 +29,17 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { for( int cc = 0; cc < 7; cc++ ) addr_hex += String(addr[cc]) + " "; addr_hex += String(addr[7]); - Serial.println(addr_hex); + m->returns(addr_hex); } } if (strcmp(m->getName(), "reset_search") == 0) { v[m->getObjectId()]->reset_search(); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "reset") == 0) { - Serial.println(v[m->getObjectId()]->reset()); + m->returns(v[m->getObjectId()]->reset()); } if (strcmp(m->getName(), "select") == 0) { @@ -52,7 +52,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { v[m->getObjectId()]->select(addr); delete(addr); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "write") == 0) { @@ -60,11 +60,11 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { v[m->getObjectId()]->write(m->getInt(0)); else v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "read") == 0) { - Serial.println(v[m->getObjectId()]->read()); + m->returns(v[m->getObjectId()]->read()); } } diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index e054d3c..dd363f3 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -12,34 +12,34 @@ void ServoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(),"new") == 0) { v.insert(new Servo()); v[v.getLastIndex()]->attach(m->getInt(0)); - Serial.println(v.getLastIndex()); + m->returns(v.getLastIndex()); } if (strcmp(m->getName(), "write") == 0) { v[m->getObjectId()]->write(m->getInt(0)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "read") == 0) { - Serial.println(v[m->getObjectId()]->read()); + m->returns(v[m->getObjectId()]->read()); } if (strcmp(m->getName(), "writeMicroseconds") == 0) { v[m->getObjectId()]->writeMicroseconds(m->getInt(0)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "readMicroseconds") == 0) { - Serial.println(v[m->getObjectId()]->readMicroseconds()); + m->returns(v[m->getObjectId()]->readMicroseconds()); } if (strcmp(m->getName(), "detach") == 0) { v[m->getObjectId()]->detach(); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "attached") == 0) { - Serial.println(v[m->getObjectId()]->attached()); + m->returns(v[m->getObjectId()]->attached()); } } diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 73b8440..ec5fc09 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -12,17 +12,17 @@ void StepperClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(),"new") == 0) { int prm = 0; v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); - Serial.println(v.getLastIndex()); + m->returns(v.getLastIndex()); } if (strcmp(m->getName(), "setSpeed") == 0) { v[m->getObjectId()]->setSpeed(m->getInt(0)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "step") == 0) { v[m->getObjectId()]->step(m->getInt(0)); - Serial.println("0"); + m->returns("0"); } } diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 0311bed..0d4e6a5 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -10,17 +10,17 @@ void ToneClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(),"new") == 0) { v.insert(new Tone (m->getInt(0))); - Serial.println(v.getLastIndex()); + m->returns(v.getLastIndex()); } if (strcmp(m->getName(), "play") == 0) { v[m->getObjectId()]->play(m->getInt(0), m->getInt(0)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "stop") == 0) { v[m->getObjectId()]->stop(); - Serial.println("0"); + m->returns("0"); } } diff --git a/firmware/Utilities.cpp b/firmware/Utilities.cpp deleted file mode 100644 index ebfa7ed..0000000 --- a/firmware/Utilities.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "Utilities.h" -#include -#include - -char* readStringFromSerial() -{ - char* buffer = (char*)malloc(30); - int i=0; - char ch = '0'; - do { - ch = Serial.read(); - if(ch != '\0' && ch < 255 && ch >= 0) { - buffer[i++] = ch; - } - } while(ch != '\0'); - char* buffer2 = (char*)malloc(i + 1); - buffer[i] = '\0'; - strcpy(buffer2, buffer); - free(buffer); - return buffer2; -}; diff --git a/firmware/Utilities.h b/firmware/Utilities.h deleted file mode 100644 index 5711c68..0000000 --- a/firmware/Utilities.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef UTILITIES -#define UTILITIES - - char* readStringFromSerial(); - -#endif - From d7dd391704bae6f21961c00ed6be880efb7ce10f Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 17 Oct 2012 01:46:03 +0200 Subject: [PATCH 064/344] New methods for DallasTemperature --- examples/dallastemperature.py | 6 ++-- firmware/DallasTemperatureClass.cpp | 55 +++++++++++++++++++++++++---- nanpy/dallastemperature.py | 18 ++++++++-- 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 8272534..02eaceb 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -9,8 +9,10 @@ sensors = DallasTemperature(5) while True: - sensors.requestTemperatures() - temp = sensors.getTempCByIndex(0) + print "There are %d devices connected on pin %d" % (sensors.getDeviceCount(), sensors.pin) + sensors.requestTemperatures(0) + addr = sensors.getAddress(0) + temp = sensors.getTempC(addr) print "The temperature, in Celsius degrees is %0.2f" % temp print "Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp) diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 15631ff..fabbf89 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -21,16 +21,55 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "requestTemperatures") == 0) { - v[m->getObjectId()]->requestTemperatures(); - m->returns("0"); + if (m->getNArgs() == 1) { + m->returns(v[m->getObjectId()]->requestTemperaturesByIndex(m->getInt(0))); + } else if (m->getNArgs() > 1) { + byte addr[8]; + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = (byte)m->getInt(i); + } + m->returns(v[m->getObjectId()]->requestTemperaturesByAddress(addr)); + } else { + v[m->getObjectId()]->requestTemperatures(); + m->returns("0"); + } } - if (strcmp(m->getName(), "getTempCByIndex") == 0) { - m->returns(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); + if (strcmp(m->getName(), "getTempC") == 0) { + if(m->getNArgs() == 1) { + m->returns(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); + } else { + byte addr[8]; + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = (byte)m->getInt(i); + } + m->returns(v[m->getObjectId()]->getTempC(addr)); + } } - if (strcmp(m->getName(), "getTempFByIndex") == 0) { - m->returns(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); + if (strcmp(m->getName(), "getTempF") == 0) { + if(m->getNArgs() == 1) { + m->returns(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); + } else { + byte addr[8]; + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = (byte)m->getInt(i); + } + m->returns(v[m->getObjectId()]->getTempF(addr)); + } + } + + if (strcmp(m->getName(), "getAddress") == 0) { + byte addr[8]; + String addr_hex = String(); + if(!v[m->getObjectId()]->getAddress(addr, m->getInt(0))) { + m->returns("1"); + return; + } + for( int cc = 0; cc < 7; cc++ ) + addr_hex += String(addr[cc]) + " "; + addr_hex += String(addr[7]); + m->returns(addr_hex); } if (strcmp(m->getName(), "toFahrenheit") == 0) { @@ -41,5 +80,9 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { m->returns(DallasTemperature::toCelsius(m->getFloat(0))); } + if (strcmp(m->getName(), "getDeviceCount") == 0) { + m->returns(v[m->getObjectId()]->getDeviceCount()); + } + } }; diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 2bdfea8..03cd8fc 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -5,20 +5,32 @@ class DallasTemperature(ArduinoObject): def __init__(self, pin): ArduinoObject.__init__(self) + self.pin = pin self.id = self.call('new', pin) + @returns(int) @arduinoobjectmethod - def requestTemperatures(self): + def getDeviceCount(self): + pass + + def getAddress(self, index): + val = self.call('getAddress') + if val == "1": + return val + return val.split(" ") + + @arduinoobjectmethod + def requestTemperatures(self, address = None): pass @returns(float) @arduinoobjectmethod - def getTempCByIndex(self, index): + def getTempC(self, address): pass @returns(float) @arduinoobjectmethod - def getTempFByIndex(self, index): + def getTempF(self, address): pass @classmethod From b03d65cff742058d7996fbe49098d673862567e4 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 17 Oct 2012 02:07:33 +0200 Subject: [PATCH 065/344] Removed OneWireAddress type, useless --- nanpy/onewire.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/nanpy/onewire.py b/nanpy/onewire.py index ed834c3..46c8c89 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -1,14 +1,6 @@ from nanpy.arduinoboard import ArduinoObject from nanpy.arduinoboard import (arduinoobjectmethod, returns) -class OneWireAddress(): - - def __init__(self, bytes): - self.__bytes = bytes - - def get(self): - return self.__bytes - class OneWire(ArduinoObject): def __init__(self, pin): @@ -19,10 +11,11 @@ def search(self): val = self.call('search') if val == "1": return val - return OneWireAddress(val.split(" ")) + return val.split(" ") + @arduinoobjectmethod def select(self, address): - return self.call('select', address.get()) + pass @returns(int) @arduinoobjectmethod From cc39c103c7295af2dcc1c190611bdb9a4e00924f Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 31 Oct 2012 15:53:22 +0100 Subject: [PATCH 066/344] Minfixes --- firmware/ArduinoClass.cpp | 2 +- nanpy/arduino.py | 4 +++- nanpy/arduinoboard.py | 1 + nanpy/servo.py | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/firmware/ArduinoClass.cpp b/firmware/ArduinoClass.cpp index 6576ee6..8f7b427 100644 --- a/firmware/ArduinoClass.cpp +++ b/firmware/ArduinoClass.cpp @@ -31,7 +31,7 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "delay") == 0) { - delay(m->getInt(0)); + //delay(m->getInt(0)); Serial.println("0"); } } diff --git a/nanpy/arduino.py b/nanpy/arduino.py index d77745d..e408981 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,6 +1,8 @@ from nanpy.arduinoboard import (call_static_method, return_value) from nanpy.arduinoboard import (arduinoclassmethod, returns) +import time + class Arduino(): HIGH = 1 @@ -38,5 +40,5 @@ def pinMode(cls, pin, mode): @classmethod @arduinoclassmethod def delay(cls, value): - pass + time.sleep(value/1000) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 4f7caa3..6996050 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -61,6 +61,7 @@ def arduinoclassmethod(funct): def wrapper(cls, *args, **kwargs): call_pars = [funct.__name__] call_pars.extend(args) + funct(cls, *args, **kwargs) return _call(cls.__name__, 0, call_pars) return wrapper diff --git a/nanpy/servo.py b/nanpy/servo.py index 062130b..1443e41 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -4,6 +4,7 @@ class Servo(ArduinoObject): def __init__(self, pin): + ArduinoObject.__init__(self) self.id = self.call('new', pin) @arduinoobjectmethod From 6dc9e01cb654649e0ce2abe0548bae308492dc34 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Wed, 31 Oct 2012 18:36:44 +0100 Subject: [PATCH 067/344] Added the possibility to specify col and row in a print function on Lcd --- firmware/ArduinoClass.cpp | 6 ++---- firmware/LiquidCrystalClass.cpp | 7 ++++++- nanpy/lcd.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/firmware/ArduinoClass.cpp b/firmware/ArduinoClass.cpp index 8f7b427..b2612aa 100644 --- a/firmware/ArduinoClass.cpp +++ b/firmware/ArduinoClass.cpp @@ -11,8 +11,7 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "digitalRead") == 0) { - digitalRead(m->getInt(0)); - Serial.println("0"); + Serial.println(digitalRead(m->getInt(0))); } if (strcmp(m->getName(), "analogWrite") == 0) { @@ -21,8 +20,7 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "analogRead") == 0) { - analogRead(m->getInt(0)); - Serial.println("0"); + Serial.println(analogRead(m->getInt(0))); } if (strcmp(m->getName(), "pinMode") == 0) { diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 7862c09..12ab425 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -19,7 +19,12 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { } if (strcmp(m->getName(), "printString") == 0) { - v[m->getObjectId()]->print(m->getString(0)); + if(m->getNArgs() == 3) { + v[m->getObjectId()]->setCursor(m->getInt(1), m->getInt(2)); + v[m->getObjectId()]->print(m->getString(0)); + } + else + v[m->getObjectId()]->print(m->getString(0)); m->returns("0"); } diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 179a091..5c9a9c5 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -8,7 +8,7 @@ def __init__(self, pins, begin): self.id = self.call('new', pins, begin) @arduinoobjectmethod - def printString(self, value): + def printString(self, value, col = None, row = None): pass @arduinoobjectmethod From a16de8297a26d5b9d7b2fdaac6266547c3acba20 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 1 Nov 2012 02:24:41 +0100 Subject: [PATCH 068/344] Call function in arduinoobjectmethod --- nanpy/arduinoboard.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 6996050..ad93ef9 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -54,6 +54,7 @@ def arduinoobjectmethod(funct, *args, **kwargs): def wrapper(self, *args, **kwargs): call_pars = [funct.__name__] call_pars.extend(args) + funct(self, *args, **kwargs) return _call(self.namespace, self.id, call_pars) return wrapper From 2753daad5db75ed6f18dfe0672c021aa63abd5a1 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 1 Nov 2012 03:41:32 +0100 Subject: [PATCH 069/344] README updated --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a864b3a..ad82542 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,21 @@ Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print s really straightforward now, isn't it? :) +Multithreading +-------------- + +What happens if you call methods in an async context? Nothing bad, all works! every call is mutually exclusive.. For example, suppose that two threads need to write on the same Lcd and in different positions at the same time... well, just call printString on the Lcd object specifying the position (row and column) + + #Thread_1 + ... + lcd.printString("Hello First Row!", 0, 0) + ... + + #Thread_2 + .... + lcd.printString("Hello Second Row!", 0, 1) + ... + Dependencies ------------ @@ -74,7 +89,7 @@ Import all the modules you need :) How to contribute ----------------- -Nanpy needs a lot of work to be a great instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at +Nanpy needs a lot of work to be a great instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at License ------- From d81dcb24d9c66182147ad851bd8a89b80991634b Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 1 Nov 2012 16:24:27 +0100 Subject: [PATCH 070/344] Added class ComChannel to support other communication methods --- firmware/ComChannel.h | 52 +++++++++++++++++++++++++++++++++++ firmware/MethodDescriptor.cpp | 12 ++++---- firmware/Nanpy.ino | 14 ++-------- 3 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 firmware/ComChannel.h diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h new file mode 100644 index 0000000..6114aea --- /dev/null +++ b/firmware/ComChannel.h @@ -0,0 +1,52 @@ +#ifndef COM_CH +#define COM_CH + +#ifndef BAUDRATE + #define BAUDRATE 9600 +#endif + +#include +#include + +class ComChannel { + + public: + + static bool available() { + if (Serial.available() > 0) + return true; + else + return false; + } + + static void connect() { + Serial.begin(BAUDRATE); + while (Serial.available() <= 0) { + delay(300); + } + } + + static void println(String& val) { + Serial.println(val); + } + + static void println(const char* val) { + Serial.println(val); + } + + static void println(int val) { + Serial.println(val); + } + + static void println(float val) { + Serial.println(val); + } + + static void println(double val) { + Serial.println(val); + } + +}; + +#endif + diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index 68d2f77..f8777a2 100644 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -1,7 +1,7 @@ #include "MethodDescriptor.h" #include #include -#include +#include "ComChannel.h" char* readStringFromSerial() { @@ -78,23 +78,23 @@ char* MethodDescriptor::getName() { }; void MethodDescriptor::returns(String& val) { - Serial.println(val); + ComChannel::println(val); } void MethodDescriptor::returns(const char* val) { - Serial.println(val); + ComChannel::println(val); } void MethodDescriptor::returns(int val) { - Serial.println(val); + ComChannel::println(val); } void MethodDescriptor::returns(float val) { - Serial.println(val); + ComChannel::println(val); } void MethodDescriptor::returns(double val) { - Serial.println(val); + ComChannel::println(val); } MethodDescriptor::~MethodDescriptor() { diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 528400b..d340ee5 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,5 +1,4 @@ #include "BaseClass.h" - #include "ArduinoClass.h" #include "OneWireClass.h" #include "StepperClass.h" @@ -8,10 +7,7 @@ #include "LiquidCrystalClass.h" #include "ToneClass.h" #include "MethodDescriptor.h" - -#ifndef BAUDRATE - #define BAUDRATE 9600 -#endif +#include "ComChannel.h" MethodDescriptor *m = NULL; @@ -25,15 +21,11 @@ void setup() { REGISTER_CLASS(ServoClass); REGISTER_CLASS(ToneClass); - Serial.begin(BAUDRATE); - - while (Serial.available() <= 0) { - delay(300); - } + ComChannel::connect(); } void loop() { - if (Serial.available() > 0) { + if (ComChannel::available() > 0) { m = new MethodDescriptor(); Register::elaborate(m); } From 539e3dd386b8773268a11492e42784bda8089eac Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 1 Nov 2012 16:40:18 +0100 Subject: [PATCH 071/344] Bumped to version 0.5 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 80632ed..b0a11c6 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.4", + version="0.5", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From 18791d6b0f6cd875d4c47406a9d418b55b532c14 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 8 Nov 2012 01:43:32 +0100 Subject: [PATCH 072/344] Support Leonardo boards --- firmware/Makefile | 387 +------------------------------------------- firmware/arduino.mk | 386 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 388 insertions(+), 385 deletions(-) create mode 100644 firmware/arduino.mk diff --git a/firmware/Makefile b/firmware/Makefile index 7312264..ffb62a8 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,385 +1,2 @@ -#_______________________________________________________________________________ -# -# edam's Arduino makefile -#_______________________________________________________________________________ -# version 0.3 -# -# Copyright (C) 2011, 1012 Tim Marston . -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -#_______________________________________________________________________________ -# -# -# This is a general purpose makefile for use with Arduino hardware and -# software. It works with the arduino-1.0 software release. To download the -# latest version of this makefile, visit the following website, where you can -# also find more information and documentation on it's use. The following text -# can only really be considered a reference to it's use. -# -# http://ed.am/dev/make/arduino-mk -# -# This makefile can be used as a drop-in replacement for the Arduino IDE's -# build system. To use it, save arduino.mk somewhere (I keep mine at -# ~/src/arduino.mk) and create a symlink to it in your project directory named -# "Makefile". For example: -# -# $ ln -s ~/src/arduino.mk Makefile -# -# The Arduino software (version 1.0 or later) is required. If you are using -# Debian (or a derivative), type `apt-get install arduino`. Otherwise, you -# will have to download the Arduino software manually from http://arduino.cc/. -# It is suggested that you install it at ~/opt/arduino if you are unsure. -# -# If you downloaded the Arduino software manually and unpacked it somewhere -# other than ~/opt/arduino, you will need to set up ARDUINODIR to be the path -# where you unpacked it. (If unset, ARDUINODIR defaults to ~/opt/arduino and -# then /usr/share/arduino, in that order.) You might be best to set this in -# your ~/.profile by adding something like this: -# -# export ARDUINODIR=~/somewhere/arduino-1.0 -# -# You will also need to set BOARD to the type of Arduino you're building for. -# Type `make boards` for a list of acceptable values. You could set a default -# in your ~/.profile if you want, but it is suggested that you specify this at -# build time, especially if you work with different types of Arduino. For -# example: -# -# $ export BOARD=uno -# $ make -# -# You may also need to set SERIALDEV if it is not detected correctly. -# -# The presence of a .ino (or .pde) file causes the arduino.mk to automatically -# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp -# files in the project directory (or any "util" or "utility" subdirectories) -# are automatically included in the build and are scanned for Arduino libraries -# that have been #included. Note, there can only be one .ino (or .pde) file. -# -# Alternatively, if you want to manually specify build variables, create a -# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. -# (There is no need to define TARGET). Here is an example Makefile: -# -# SOURCES := main.cc other.cc -# LIBRARIES := EEPROM -# include ~/src/arduino.mk -# -# Here is a complete list of configuration parameters: -# -# ARDUINODIR The path where the Arduino software is installed on your system. -# -# ARDUINOCONST The Arduino software version, as an integer, used to define the -# ARDUINO version constant. This defaults to 100 if undefined. -# -# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess -# based on where the avrdude in use is. If empty, no avrdude.conf -# is passed to avrdude (to the system default is used). -# -# AVRTOOLSPATH A space-separated list of directories to search in order when -# looking for the avr build tools. This defaults to the system PATH -# followed by subdirectories in ARDUINODIR if undefined. -# -# BOARD Specify a target board type. Run `make boards` to see available -# board types. -# -# LIBRARIES A list of Arduino libraries to build and include. This is set -# automatically if a .ino (or .pde) is found. -# -# SERIALDEV The unix device name of the serial device that is the Arduino. -# If unspecified, an attempt is made to determine the name of a -# connected Arduino's serial device. -# -# SOURCES A list of all source files of whatever language. The language -# type is determined by the file extension. This is set -# automatically if a .ino (or .pde) is found. -# -# TARGET The name of the target file. This is set automatically if a -# .ino (or .pde) is found, but it is not necessary to set it -# otherwise. -# -# This makefile also defines the following goals for use on the command line -# when you run make: -# -# all This is the default if no goal is specified. It builds the -# target. -# -# target Builds the target. -# -# upload Uploads the last built target to an attached Arduino. -# -# clean Deletes files created during the build. -# -# boards Display a list of available board names, so that you can set the -# BOARD environment variable appropriately. -# -# monitor Start `screen` on the serial device. This is meant to be an -# equivalent to the Arduino serial monitor. -# -# size Displays size information about the bulit target. -# -# Builds the specified file, either an object file or the target, -# from those that that would be built for the project. -#_______________________________________________________________________________ -# - -# default arduino software directory, check software exists -ifndef ARDUINODIR -ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino)) -endif -ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" -$(error ARDUINODIR is not set correctly; arduino software not found) -endif - -# default arduino version -ARDUINOCONST ?= 100 - -# default path for avr tools -ifndef AVRTOOLSPATH -AVRTOOLSPATH := $(subst :, , $(PATH)) -AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools -AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools/avr/bin -endif - -# auto mode? -INOFILE := $(wildcard *.ino *.pde) -ifdef INOFILE -ifneq "$(words $(INOFILE))" "1" -$(error There is more than one .pde or .ino file in this directory!) -endif - -# automatically determine sources and targeet -TARGET := $(basename $(INOFILE)) -SOURCES := $(INOFILE) \ - $(wildcard *.c *.cc *.cpp) \ - $(wildcard $(addprefix util/, *.c *.cc *.cpp)) \ - $(wildcard $(addprefix utility/, *.c *.cc *.cpp)) - -# automatically determine included libraries -LIBRARIES := $(filter $(notdir $(wildcard $(ARDUINODIR)/libraries/*)), \ - $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) - -LIBRARIES += $(filter $(notdir $(wildcard libraries/*)), \ - $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) - -endif - -# no serial device? make a poor attempt to detect an arduino -SERIALDEVGUESS := 0 -ifeq "$(SERIALDEV)" "" -SERIALDEV := $(firstword $(wildcard \ - /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) -SERIALDEVGUESS := 1 -endif - -# software -findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) -CC := $(call findsoftware,avr-gcc) -CXX := $(call findsoftware,avr-g++) -LD := $(call findsoftware,avr-ld) -AR := $(call findsoftware,avr-ar) -OBJCOPY := $(call findsoftware,avr-objcopy) -AVRDUDE := $(call findsoftware,avrdude) -AVRSIZE := $(call findsoftware,avr-size) - -# files -TARGET := $(if $(TARGET),$(TARGET),a.out) -OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) -DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) -ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino -ARDUINOLIB := .lib/arduino.a -ARDUINOLIBLIBSDIR := $(ARDUINODIR)/libraries -ARDUINOLIBLIBSPATH := $(foreach lib, $(LIBRARIES), \ - $(ARDUINODIR)/libraries/$(lib)/ $(ARDUINODIR)/libraries/$(lib)/utility/ ) -ARDUINOLIBLIBSPATH += $(foreach lib, $(LIBRARIES), \ - ./libraries/$(lib)/ ./libraries/$(lib)/utility/ ) -ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(ARDUINOLIBLIBSPATH), \ - $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) -ifeq "$(AVRDUDECONF)" "" -ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" -AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf -else -AVRDUDECONF := $(wildcard $(AVRDUDE).conf) -endif -endif - -# no board? -ifndef BOARD -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is unset. Type 'make boards' to see possible values) -endif -endif -endif - -# obtain board parameters from the arduino boards.txt file -BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt -BOARD_BUILD_MCU := \ - $(shell sed -ne "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_BUILD_FCPU := \ - $(shell sed -ne "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_BUILD_VARIANT := \ - $(shell sed -ne "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_UPLOAD_SPEED := \ - $(shell sed -ne "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_UPLOAD_PROTOCOL := \ - $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE)) - -# invalid board? -ifeq "$(BOARD_BUILD_MCU)" "" -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is invalid. Type 'make boards' to see possible values) -endif -endif -endif - -# flags -CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) -ifdef DEBUG -CPPFLAGS += -DDEBUG=$(DEBUG) -endif -ifdef BAUDRATE -CPPFLAGS += -DBAUDRATE=$(BAUDRATE) -endif -CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) -CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ -CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES)) -CPPFLAGS += $(addprefix -I./libraries/, $(LIBRARIES)) -CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) -CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep -CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h -AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV -AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) -AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) -LINKFLAGS := -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) - -# figure out which arg to use with stty -STTYFARG := $(shell stty --help > /dev/null 2>&1 && echo -F || echo -f) - -# include dependencies -ifneq "$(MAKECMDGOALS)" "clean" --include $(DEPFILES) -endif - -# default rule -.DEFAULT_GOAL := all - -#_______________________________________________________________________________ -# RULES - -.PHONY: all target upload clean boards monitor size - -all: target - -target: $(TARGET).hex - -upload: - @echo "\nUploading to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - stty $(STTYFARG) $(SERIALDEV) hupcl - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i - -clean: - rm -f $(OBJECTS) - rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ - rm -rf .lib .dep - -boards: - @echo Available values for BOARD: - @sed -ne '/^#/d; /^[^.]\+\.name=/p' $(BOARDS_FILE) | \ - sed -e 's/\([^.]\+\)\.name=\(.*\)/\1 \2/' \ - -e 's/\(.\{12\}\) *\(.*\)/\1 \2/' - -monitor: - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test -n `which screen` || { \ - echo "error: can't find GNU screen, you might need to install it." >&2 \ - ecit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - screen $(SERIALDEV) - -size: $(TARGET).elf - echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf - -# building the target - -$(TARGET).hex: $(TARGET).elf - $(OBJCOPY) -O ihex -R .eeprom $< $@ - -.INTERMEDIATE: $(TARGET).elf - -$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) - $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -o $@ -lm - -%.o: %.c - mkdir -p .dep/$(dir $<) - $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cpp - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cc - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.C - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.ino - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -%.o: %.pde - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ -x c++ -include $(ARDUINOCOREDIR)/Arduino.h $< - -# building the arduino library - -$(ARDUINOLIB): $(ARDUINOLIBOBJS) - $(AR) rcs $@ $? - -.lib/%.c.o: %.c - mkdir -p $(dir $@) - $(COMPILE.c) -o $@ $< - -.lib/%.cpp.o: %.cpp - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.cc.o: %.cc - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.C.o: %.C - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< +LINKFLAGSEXTRA := -lm +include arduino.mk diff --git a/firmware/arduino.mk b/firmware/arduino.mk new file mode 100644 index 0000000..5481d84 --- /dev/null +++ b/firmware/arduino.mk @@ -0,0 +1,386 @@ +#_______________________________________________________________________________ +# +# edam's Arduino makefile +#_______________________________________________________________________________ +# version 0.3 +# +# Copyright (C) 2011, 2012 Tim Marston . +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +#_______________________________________________________________________________ +# +# +# This is a general purpose makefile for use with Arduino hardware and +# software. It works with the arduino-1.0 software release. To download the +# latest version of this makefile, visit the following website, where you can +# also find more information and documentation on it's use. The following text +# can only really be considered a reference to it's use. +# +# http://ed.am/dev/make/arduino-mk +# +# This makefile can be used as a drop-in replacement for the Arduino IDE's +# build system. To use it, save arduino.mk somewhere (I keep mine at +# ~/src/arduino.mk) and create a symlink to it in your project directory named +# "Makefile". For example: +# +# $ ln -s ~/src/arduino.mk Makefile +# +# The Arduino software (version 1.0 or later) is required. If you are using +# Debian (or a derivative), type `apt-get install arduino`. Otherwise, you +# will have to download the Arduino software manually from http://arduino.cc/. +# It is suggested that you install it at ~/opt/arduino if you are unsure. +# +# If you downloaded the Arduino software manually and unpacked it somewhere +# other than ~/opt/arduino, you will need to set up ARDUINODIR to be the path +# where you unpacked it. (If unset, ARDUINODIR defaults to ~/opt/arduino and +# then /usr/share/arduino, in that order.) You might be best to set this in +# your ~/.profile by adding something like this: +# +# export ARDUINODIR=~/somewhere/arduino-1.0 +# +# You will also need to set BOARD to the type of Arduino you're building for. +# Type `make boards` for a list of acceptable values. You could set a default +# in your ~/.profile if you want, but it is suggested that you specify this at +# build time, especially if you work with different types of Arduino. For +# example: +# +# $ export BOARD=uno +# $ make +# +# You may also need to set SERIALDEV if it is not detected correctly. +# +# The presence of a .ino (or .pde) file causes the arduino.mk to automatically +# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp +# files in the project directory (or any "util" or "utility" subdirectories) +# are automatically included in the build and are scanned for Arduino libraries +# that have been #included. Note, there can only be one .ino (or .pde) file. +# +# Alternatively, if you want to manually specify build variables, create a +# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. +# (There is no need to define TARGET). Here is an example Makefile: +# +# SOURCES := main.cc other.cc +# LIBRARIES := EEPROM +# include ~/src/arduino.mk +# +# Here is a complete list of configuration parameters: +# +# ARDUINODIR The path where the Arduino software is installed on your system. +# +# ARDUINOCONST The Arduino software version, as an integer, used to define the +# ARDUINO version constant. This defaults to 100 if undefined. +# +# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess +# based on where the avrdude in use is. If empty, no avrdude.conf +# is passed to avrdude (to the system default is used). +# +# AVRTOOLSPATH A space-separated list of directories to search in order when +# looking for the avr build tools. This defaults to the system PATH +# followed by subdirectories in ARDUINODIR if undefined. +# +# BOARD Specify a target board type. Run `make boards` to see available +# board types. +# +# LIBRARIES A list of Arduino libraries to build and include. This is set +# automatically if a .ino (or .pde) is found. +# +# SERIALDEV The unix device name of the serial device that is the Arduino. +# If unspecified, an attempt is made to determine the name of a +# connected Arduino's serial device. +# +# SOURCES A list of all source files of whatever language. The language +# type is determined by the file extension. This is set +# automatically if a .ino (or .pde) is found. +# +# TARGET The name of the target file. This is set automatically if a +# .ino (or .pde) is found, but it is not necessary to set it +# otherwise. +# +# This makefile also defines the following goals for use on the command line +# when you run make: +# +# all This is the default if no goal is specified. It builds the +# target. +# +# target Builds the target. +# +# upload Uploads the last built target to an attached Arduino. +# +# clean Deletes files created during the build. +# +# boards Display a list of available board names, so that you can set the +# BOARD environment variable appropriately. +# +# monitor Start `screen` on the serial device. This is meant to be an +# equivalent to the Arduino serial monitor. +# +# size Displays size information about the bulit target. +# +# Builds the specified file, either an object file or the target, +# from those that that would be built for the project. +#_______________________________________________________________________________ +# + +# default arduino software directory, check software exists +ifndef ARDUINODIR +ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino)) +endif +ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" +$(error ARDUINODIR is not set correctly; arduino software not found) +endif + +# default arduino version +ARDUINOCONST ?= 100 + +# default path for avr tools +ifndef AVRTOOLSPATH +AVRTOOLSPATH := $(subst :, , $(PATH)) +AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools +AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools/avr/bin +endif + +# auto mode? +INOFILE := $(wildcard *.ino *.pde) +ifdef INOFILE +ifneq "$(words $(INOFILE))" "1" +$(error There is more than one .pde or .ino file in this directory!) +endif + +# automatically determine sources and targeet +TARGET := $(basename $(INOFILE)) +SOURCES := $(INOFILE) \ + $(wildcard *.c *.cc *.cpp) \ + $(wildcard $(addprefix util/, *.c *.cc *.cpp)) \ + $(wildcard $(addprefix utility/, *.c *.cc *.cpp)) + +# automatically determine included libraries +LIBRARIES := $(filter $(notdir $(wildcard $(ARDUINODIR)/libraries/*)), \ + $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) + +LIBRARIES += $(filter $(notdir $(wildcard libraries/*)), \ + $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) + +endif + +# no serial device? make a poor attempt to detect an arduino +SERIALDEVGUESS := 0 +ifeq "$(SERIALDEV)" "" +SERIALDEV := $(firstword $(wildcard \ + /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) +SERIALDEVGUESS := 1 +endif + +# software +findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) +CC := $(call findsoftware,avr-gcc) +CXX := $(call findsoftware,avr-g++) +LD := $(call findsoftware,avr-ld) +AR := $(call findsoftware,avr-ar) +OBJCOPY := $(call findsoftware,avr-objcopy) +AVRDUDE := $(call findsoftware,avrdude) +AVRSIZE := $(call findsoftware,avr-size) + +# files +TARGET := $(if $(TARGET),$(TARGET),a.out) +OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) +DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) +ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino +ARDUINOLIB := .lib/arduino.a +ARDUINOLIBLIBSDIR := $(ARDUINODIR)/libraries +ARDUINOLIBLIBSPATH := $(foreach lib, $(LIBRARIES), \ + $(ARDUINODIR)/libraries/$(lib)/ $(ARDUINODIR)/libraries/$(lib)/utility/ ) +ARDUINOLIBLIBSPATH += $(foreach lib, $(LIBRARIES), \ + ./libraries/$(lib)/ ./libraries/$(lib)/utility/ ) +ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(ARDUINOLIBLIBSPATH), \ + $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) +ifeq "$(AVRDUDECONF)" "" +ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" +AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf +else +AVRDUDECONF := $(wildcard $(AVRDUDE).conf) +endif +endif + +# no board? +ifndef BOARD +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is unset. Type 'make boards' to see possible values) +endif +endif +endif + +# obtain board parameters from the arduino boards.txt file +BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt +BOARD_BUILD_MCU := \ + $(shell sed -ne "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_BUILD_FCPU := \ + $(shell sed -ne "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_BUILD_VARIANT := \ + $(shell sed -ne "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_UPLOAD_SPEED := \ + $(shell sed -ne "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_UPLOAD_PROTOCOL := \ + $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_USB_VID := \ + $(shell sed -ne "s/$(BOARD).build.vid=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_USB_PID := \ + $(shell sed -ne "s/$(BOARD).build.pid=\(.*\)/\1/p" $(BOARDS_FILE)) + +# invalid board? +ifeq "$(BOARD_BUILD_MCU)" "" +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is invalid. Type 'make boards' to see possible values) +endif +endif +endif + +# flags +CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections +CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) +CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) +ifneq "$(BOARD_USB_VID)" "" +CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) +endif +CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) +CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ +CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES)) +CPPFLAGS += $(addprefix -I./libraries/, $(LIBRARIES)) +CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) +CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep +CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h +AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV +AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) +AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) +LINKFLAGS := -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) + +# figure out which arg to use with stty +STTYFARG := $(shell stty --help > /dev/null 2>&1 && echo -F || echo -f) + +# include dependencies +ifneq "$(MAKECMDGOALS)" "clean" +-include $(DEPFILES) +endif + +# default rule +.DEFAULT_GOAL := all + +#_______________________________________________________________________________ +# RULES + +.PHONY: all target upload clean boards monitor size + +all: target + +target: $(TARGET).hex + +upload: + @echo "\nUploading to board..." + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + stty $(STTYFARG) $(SERIALDEV) hupcl + $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i + +clean: + rm -f $(OBJECTS) + rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ + rm -rf .lib .dep + +boards: + @echo Available values for BOARD: + @sed -ne '/^#/d; /^[^.]\+\.name=/p' $(BOARDS_FILE) | \ + sed -e 's/\([^.]\+\)\.name=\(.*\)/\1 \2/' \ + -e 's/\(.\{12\}\) *\(.*\)/\1 \2/' + +monitor: + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test -n `which screen` || { \ + echo "error: can't find GNU screen, you might need to install it." >&2 \ + ecit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + screen $(SERIALDEV) + +size: $(TARGET).elf + echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf + +# building the target + +$(TARGET).hex: $(TARGET).elf + $(OBJCOPY) -O ihex -R .eeprom $< $@ + +.INTERMEDIATE: $(TARGET).elf + +$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) + $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) $(LINKFLAGSEXTRA) -o $@ + +%.o: %.c + mkdir -p .dep/$(dir $<) + $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.cpp + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.cc + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.C + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.ino + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< + +%.o: %.pde + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ -x c++ -include $(ARDUINOCOREDIR)/Arduino.h $< + +# building the arduino library + +$(ARDUINOLIB): $(ARDUINOLIBOBJS) + $(AR) rcs $@ $? + +.lib/%.c.o: %.c + mkdir -p $(dir $@) + $(COMPILE.c) -o $@ $< + +.lib/%.cpp.o: %.cpp + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +.lib/%.cc.o: %.cc + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +.lib/%.C.o: %.C + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< From bb4ab6e11a231dd3fe54792fd0aa2e530e988074 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Thu, 8 Nov 2012 22:37:11 +0100 Subject: [PATCH 073/344] Changed url --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b0a11c6..5964c2b 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ license="MIT", author="Andrea Stagi", author_email="stagi.andrea@gmail.com", - url="http://github.com/Octan/nanpy", + url="http://github.com/nanpy/nanpy", packages = find_packages(), keywords= "arduino library prototype", zip_safe = True) From e376eccdd48bf0cbd9047f77eb880ab684c9c1de Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 9 Nov 2012 00:07:42 +0100 Subject: [PATCH 074/344] Initial support for python3 --- examples/dallastemperature.py | 6 +++--- nanpy/arduinoboard.py | 2 +- nanpy/dallastemperature.py | 3 ++- nanpy/onewire.py | 2 +- nanpy/serialmanager.py | 11 +++++++---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/dallastemperature.py b/examples/dallastemperature.py index 02eaceb..8977aaf 100755 --- a/examples/dallastemperature.py +++ b/examples/dallastemperature.py @@ -9,10 +9,10 @@ sensors = DallasTemperature(5) while True: - print "There are %d devices connected on pin %d" % (sensors.getDeviceCount(), sensors.pin) + print("There are %d devices connected on pin %d" % (sensors.getDeviceCount(), sensors.pin)) sensors.requestTemperatures(0) addr = sensors.getAddress(0) temp = sensors.getTempC(addr) - print "The temperature, in Celsius degrees is %0.2f" % temp - print "Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp) + print("The temperature, in Celsius degrees is %0.2f" % temp) + print("Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp)) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index ad93ef9..4030436 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -29,7 +29,7 @@ def _send_parameters(args): _write(elprint) def return_value(): - return serial_manager.readline().replace("\r\n","") + return serial_manager.readline().replace('\r\n', '') def _call(namespace, id, args): mutex.acquire() diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 03cd8fc..9db8bed 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -17,7 +17,8 @@ def getAddress(self, index): val = self.call('getAddress') if val == "1": return val - return val.split(" ") + return val.split(' ') + @arduinoobjectmethod def requestTemperatures(self, address = None): diff --git a/nanpy/onewire.py b/nanpy/onewire.py index 46c8c89..d3f1013 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -11,7 +11,7 @@ def search(self): val = self.call('search') if val == "1": return val - return val.split(" ") + return val.split(' ') @arduinoobjectmethod def select(self, address): diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 62a7ec6..dd10349 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -1,7 +1,7 @@ import serial import time import fnmatch -import serial +import sys def _auto_detect_serial_unix(preferred_list=['*']): import glob @@ -39,7 +39,7 @@ def __init__(self): self.__serial = serial.Serial(available_ports[0], 9600, timeout=1) time.sleep(2) except: - print "Error trying to connect to Arduino" + print("Error trying to connect to Arduino") self.__serial = NoneSerialManager() def connect(self, device, baud): @@ -47,9 +47,12 @@ def connect(self, device, baud): time.sleep(2) def write(self, value): - self.__serial.write(value) + if sys.version_info.major == 2: + self.__serial.write(value) + else: + self.__serial.write(bytes(value, 'latin-1')) def readline(self): - return self.__serial.readline() + return self.__serial.readline().decode() serial_manager = SerialManager() From 1300e1223bb1abc7832d40fcfedfc71416a25d00 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Fri, 9 Nov 2012 00:17:37 +0100 Subject: [PATCH 075/344] A new class to manage serial comm for python2 --- nanpy/serialmanager.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index dd10349..3867bb8 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -36,23 +36,32 @@ class SerialManager(object): def __init__(self): available_ports = _auto_detect_serial_unix() try: - self.__serial = serial.Serial(available_ports[0], 9600, timeout=1) + self._serial = serial.Serial(available_ports[0], 9600, timeout=1) time.sleep(2) except: print("Error trying to connect to Arduino") - self.__serial = NoneSerialManager() + self._serial = NoneSerialManager() def connect(self, device, baud): - self.__serial = serial.Serial(device, baud) + self._serial = serial.Serial(device, baud) time.sleep(2) def write(self, value): - if sys.version_info.major == 2: - self.__serial.write(value) - else: - self.__serial.write(bytes(value, 'latin-1')) + self._serial.write(bytes(value, 'latin-1')) def readline(self): - return self.__serial.readline().decode() + return self._serial.readline().decode() + +class SerialManagerPy2(SerialManager): + + def __init__(self): + SerialManager.__init__(self) + + def write(self, value): + self._serial.write(value) + +if sys.version_info.major == 2: + serial_manager = SerialManagerPy2() +elif sys.version_info.major == 3: + serial_manager = SerialManager() -serial_manager = SerialManager() From e6896ca37eff1e316f15a125f71098fde1641fcd Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sat, 10 Nov 2012 12:46:11 +0100 Subject: [PATCH 076/344] Minfixes and support for Leonardo serial --- firmware/ArduinoClass.cpp | 12 ++++++------ firmware/ComChannel.h | 31 +++++++++++++++++++++++++++++++ firmware/arduino.mk | 7 +++++++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/firmware/ArduinoClass.cpp b/firmware/ArduinoClass.cpp index b2612aa..99f3833 100644 --- a/firmware/ArduinoClass.cpp +++ b/firmware/ArduinoClass.cpp @@ -7,30 +7,30 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Arduino") == 0) { if (strcmp(m->getName(), "digitalWrite") == 0) { digitalWrite(m->getInt(0), m->getInt(1)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "digitalRead") == 0) { - Serial.println(digitalRead(m->getInt(0))); + m->returns(digitalRead(m->getInt(0))); } if (strcmp(m->getName(), "analogWrite") == 0) { analogWrite(m->getInt(0), m->getInt(1)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "analogRead") == 0) { - Serial.println(analogRead(m->getInt(0))); + m->returns(analogRead(m->getInt(0))); } if (strcmp(m->getName(), "pinMode") == 0) { pinMode(m->getInt(0), m->getInt(1)); - Serial.println("0"); + m->returns("0"); } if (strcmp(m->getName(), "delay") == 0) { //delay(m->getInt(0)); - Serial.println("0"); + m->returns("0"); } } }; diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h index 6114aea..dbad1de 100644 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -13,37 +13,68 @@ class ComChannel { public: static bool available() { + #if BOARD == 2 + if (Serial1.available() > 0) + #else if (Serial.available() > 0) + #endif return true; else return false; } static void connect() { + #if BOARD == 2 + Serial1.begin(BAUDRATE); + while (Serial1.available() <= 0) { + delay(300); + } + #else Serial.begin(BAUDRATE); while (Serial.available() <= 0) { delay(300); } + #endif } static void println(String& val) { + #if BOARD == 2 + Serial1.println(val); + #else Serial.println(val); + #endif } static void println(const char* val) { + #if BOARD == 2 + Serial1.println(val); + #else Serial.println(val); + #endif } static void println(int val) { + #if BOARD == 2 + Serial1.println(val); + #else Serial.println(val); + #endif } static void println(float val) { + #if BOARD == 2 + Serial1.println(val); + #else Serial.println(val); + #endif } static void println(double val) { + #if BOARD == 2 + Serial1.println(val); + #else Serial.println(val); + #endif } }; diff --git a/firmware/arduino.mk b/firmware/arduino.mk index 5481d84..e2d1c3a 100644 --- a/firmware/arduino.mk +++ b/firmware/arduino.mk @@ -260,6 +260,13 @@ CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) ifneq "$(BOARD_USB_VID)" "" CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) +CPPFLAGS += -DBOARD=2 +endif +ifdef DEBUG +CPPFLAGS += -DDEBUG=$(DEBUG) +endif +ifdef BAUDRATE +CPPFLAGS += -DBAUDRATE=$(BAUDRATE) endif CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ From 30ab7b74895800c030dc341ace19c6ad3c13a011 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sat, 10 Nov 2012 14:11:10 +0100 Subject: [PATCH 077/344] Some changes on serial communication --- firmware/ComChannel.h | 6 ------ firmware/Nanpy.ino | 6 ++---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h index dbad1de..da3a78c 100644 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -26,14 +26,8 @@ class ComChannel { static void connect() { #if BOARD == 2 Serial1.begin(BAUDRATE); - while (Serial1.available() <= 0) { - delay(300); - } #else Serial.begin(BAUDRATE); - while (Serial.available() <= 0) { - delay(300); - } #endif } diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index d340ee5..4d9f7c6 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -25,9 +25,7 @@ void setup() { } void loop() { - if (ComChannel::available() > 0) { - m = new MethodDescriptor(); - Register::elaborate(m); - } + m = new MethodDescriptor(); + Register::elaborate(m); } From e04b23d52e1001cb2cb745c0d6cd0abfedf2f6f0 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sat, 10 Nov 2012 21:49:43 +0100 Subject: [PATCH 078/344] Back to use Serial --- firmware/ComChannel.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h index da3a78c..8ed60dc 100644 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -13,62 +13,34 @@ class ComChannel { public: static bool available() { - #if BOARD == 2 - if (Serial1.available() > 0) - #else if (Serial.available() > 0) - #endif return true; else return false; } static void connect() { - #if BOARD == 2 - Serial1.begin(BAUDRATE); - #else Serial.begin(BAUDRATE); - #endif } static void println(String& val) { - #if BOARD == 2 - Serial1.println(val); - #else Serial.println(val); - #endif } static void println(const char* val) { - #if BOARD == 2 - Serial1.println(val); - #else Serial.println(val); - #endif } static void println(int val) { - #if BOARD == 2 - Serial1.println(val); - #else Serial.println(val); - #endif } static void println(float val) { - #if BOARD == 2 - Serial1.println(val); - #else Serial.println(val); - #endif } static void println(double val) { - #if BOARD == 2 - Serial1.println(val); - #else Serial.println(val); - #endif } }; From d33fa6d215298f6acc8fba6aacbe4aeeb4bafbde Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sun, 11 Nov 2012 00:16:06 +0100 Subject: [PATCH 079/344] Makefile updated to the last version --- firmware/Makefile | 1 - firmware/arduino.mk | 36 ++++++++++++++---------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/firmware/Makefile b/firmware/Makefile index ffb62a8..29ebe54 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,2 +1 @@ -LINKFLAGSEXTRA := -lm include arduino.mk diff --git a/firmware/arduino.mk b/firmware/arduino.mk index e2d1c3a..10f5200 100644 --- a/firmware/arduino.mk +++ b/firmware/arduino.mk @@ -2,9 +2,9 @@ # # edam's Arduino makefile #_______________________________________________________________________________ -# version 0.3 +# version 0.4dev # -# Copyright (C) 2011, 2012 Tim Marston . +# Copyright (C) 2011, 1012 Tim Marston . # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -258,21 +258,12 @@ CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) -ifneq "$(BOARD_USB_VID)" "" CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) -CPPFLAGS += -DBOARD=2 -endif -ifdef DEBUG -CPPFLAGS += -DDEBUG=$(DEBUG) -endif -ifdef BAUDRATE -CPPFLAGS += -DBAUDRATE=$(BAUDRATE) -endif -CPPFLAGS += -I. -Iutil -Iutility -I$(ARDUINOCOREDIR) -CPPFLAGS += -I$(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ -CPPFLAGS += $(addprefix -I$(ARDUINODIR)/libraries/, $(LIBRARIES)) +CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR) +CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ +CPPFLAGS += $(addprefix -I $(ARDUINODIR)/libraries/, $(LIBRARIES)) CPPFLAGS += $(addprefix -I./libraries/, $(LIBRARIES)) -CPPFLAGS += $(patsubst %, -I$(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) +CPPFLAGS += $(patsubst %, -I $(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV @@ -280,8 +271,9 @@ AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) LINKFLAGS := -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) -# figure out which arg to use with stty -STTYFARG := $(shell stty --help > /dev/null 2>&1 && echo -F || echo -f) +# figure out which arg to use with stty (for OS X, GNU and busybox stty) +STTYFARG := $(shell stty --help 2>&1 | \ + grep -q 'illegal option' && echo -f || echo -F) # include dependencies ifneq "$(MAKECMDGOALS)" "clean" @@ -300,7 +292,7 @@ all: target target: $(TARGET).hex -upload: +upload: target @echo "\nUploading to board..." @test -n "$(SERIALDEV)" || { \ echo "error: SERIALDEV could not be determined automatically." >&2; \ @@ -318,9 +310,9 @@ clean: boards: @echo Available values for BOARD: - @sed -ne '/^#/d; /^[^.]\+\.name=/p' $(BOARDS_FILE) | \ - sed -e 's/\([^.]\+\)\.name=\(.*\)/\1 \2/' \ - -e 's/\(.\{12\}\) *\(.*\)/\1 \2/' + @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDS_FILE) | \ + sed -Ee 's/([^.]+)\.name=(.*)/\1 \2/' \ + -e 's/(.{12}) *(.*)/\1 \2/' monitor: @test -n "$(SERIALDEV)" || { \ @@ -345,7 +337,7 @@ $(TARGET).hex: $(TARGET).elf .INTERMEDIATE: $(TARGET).elf $(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) - $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) $(LINKFLAGSEXTRA) -o $@ + $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@ %.o: %.c mkdir -p .dep/$(dir $<) From f659e50c436b3e3b5d9e1d6a6267496372b51594 Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sun, 11 Nov 2012 01:28:25 +0100 Subject: [PATCH 080/344] Added doc for installing with Python3. Closes #1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad82542..537c6d7 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Dependencies ------------ #### Python (2.2 or later) -- python-setuptools +- python-distribute (http://pypi.python.org/pypi/distribute) - python-serial How to build and install From eec3acad589572bc49ccda3bcdeb82eb5e3ae4bf Mon Sep 17 00:00:00 2001 From: 4ndreaSt4gi Date: Sun, 11 Nov 2012 03:21:10 +0100 Subject: [PATCH 081/344] Please donate added --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 537c6d7..cf16b36 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,11 @@ How to contribute Nanpy needs a lot of work to be a great instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at +Donate +------ + +Do you want to buy us a coffee? We need it to code all night long! if you like this project and you want to support it with some cents, please donate :) https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J + License ------- From b7b55a528b8bab8466ffa5d11fb8bd8d9987e5a6 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 13 Nov 2012 00:16:53 +0100 Subject: [PATCH 082/344] Minfixes and Leonardo fix --- firmware/ComChannel.h | 4 +++- firmware/MethodDescriptor.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 firmware/ComChannel.h mode change 100644 => 100755 firmware/MethodDescriptor.cpp diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h old mode 100644 new mode 100755 index 8ed60dc..ef58385 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -5,7 +5,6 @@ #define BAUDRATE 9600 #endif -#include #include class ComChannel { @@ -21,6 +20,9 @@ class ComChannel { static void connect() { Serial.begin(BAUDRATE); + while (!Serial) { + ; + } } static void println(String& val) { diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp old mode 100644 new mode 100755 index f8777a2..6784c70 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -2,6 +2,7 @@ #include #include #include "ComChannel.h" +#include char* readStringFromSerial() { From aec0cc6ae127ea58488a2163afafe9abba1cc800 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 13 Nov 2012 01:13:00 +0100 Subject: [PATCH 083/344] Minfixes on the interface fixes #3 --- README.md | 8 ++--- firmware/ComChannel.cpp | 59 +++++++++++++++++++++++++++++++++++ firmware/ComChannel.h | 51 +++++++----------------------- firmware/MethodDescriptor.cpp | 28 +++-------------- nanpy/serialmanager.py | 4 +-- 5 files changed, 79 insertions(+), 71 deletions(-) create mode 100755 firmware/ComChannel.cpp diff --git a/README.md b/README.md index cf16b36..e3ff24e 100644 --- a/README.md +++ b/README.md @@ -64,19 +64,15 @@ and then upload it on your board: make upload -Optionally you can also set the baud rate: - - export BAUDRATE=115200 (default value is 9600) - How to use ---------- ### Serial communication -Nanpy autodetects the serial port for you, anyway you can specify another serial port and baudrate manually: +Nanpy autodetects the serial port for you, anyway you can specify another serial port manually: from nanpy import serial_manager - serial_manager.connect('/dev/ttyACM1', 9600) + serial_manager.connect('/dev/ttyACM1') ### Import modules diff --git a/firmware/ComChannel.cpp b/firmware/ComChannel.cpp new file mode 100755 index 0000000..2ae177d --- /dev/null +++ b/firmware/ComChannel.cpp @@ -0,0 +1,59 @@ +#include "ComChannel.h" +#include + +char* readLineFromSerial() +{ + char* buffer = (char*)malloc(30); + int i=0; + char ch = '0'; + do { + ch = Serial.read(); + if(ch != '\0' && ch < 255 && ch >= 0) { + buffer[i++] = ch; + } + } while(ch != '\0'); + char* buffer2 = (char*)malloc(i + 1); + buffer[i] = '\0'; + strcpy(buffer2, buffer); + free(buffer); + return buffer2; +}; + +bool ComChannel::available() { + if (Serial.available() > 0) + return true; + else + return false; +} + +void ComChannel::connect() { + Serial.begin(BAUDRATE); + while (!Serial) { + ; + } +} + +void ComChannel::println(String& val) { + Serial.println(val); +} + +void ComChannel::println(const char* val) { + Serial.println(val); +} + +void ComChannel::println(int val) { + Serial.println(val); +} + +void ComChannel::println(float val) { + Serial.println(val); +} + +void ComChannel::println(double val) { + Serial.println(val); +} + +char* ComChannel::readLine() { + return readLineFromSerial(); +} + diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h index ef58385..ff23ee4 100755 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -1,50 +1,21 @@ -#ifndef COM_CH -#define COM_CH +#ifndef COM_CHANNEL +#define COM_CHANNEL -#ifndef BAUDRATE - #define BAUDRATE 9600 -#endif +#define BAUDRATE 9600 #include class ComChannel { public: - - static bool available() { - if (Serial.available() > 0) - return true; - else - return false; - } - - static void connect() { - Serial.begin(BAUDRATE); - while (!Serial) { - ; - } - } - - static void println(String& val) { - Serial.println(val); - } - - static void println(const char* val) { - Serial.println(val); - } - - static void println(int val) { - Serial.println(val); - } - - static void println(float val) { - Serial.println(val); - } - - static void println(double val) { - Serial.println(val); - } - + static bool available(); + static void connect(); + static void println(String& val); + static void println(const char* val); + static void println(int val); + static void println(float val); + static void println(double val); + static char* readLine(); }; #endif diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index 6784c70..622f401 100755 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -4,44 +4,26 @@ #include "ComChannel.h" #include -char* readStringFromSerial() -{ - char* buffer = (char*)malloc(30); - int i=0; - char ch = '0'; - do { - ch = Serial.read(); - if(ch != '\0' && ch < 255 && ch >= 0) { - buffer[i++] = ch; - } - } while(ch != '\0'); - char* buffer2 = (char*)malloc(i + 1); - buffer[i] = '\0'; - strcpy(buffer2, buffer); - free(buffer); - return buffer2; -}; - MethodDescriptor::MethodDescriptor() { - this->classname = readStringFromSerial(); + this->classname = ComChannel::readLine(); char* buff; - buff = readStringFromSerial(); + buff = ComChannel::readLine(); this->objid = atoi(buff); free(buff); - buff = readStringFromSerial(); + buff = ComChannel::readLine(); this->n_args = atoi(buff); free(buff); - this->name = readStringFromSerial(); + this->name = ComChannel::readLine(); this->stack = (char**)malloc(sizeof(char*) * this->n_args); for(int n = 0; n < this->n_args; n++) { - this->stack[n] = readStringFromSerial(); + this->stack[n] = ComChannel::readLine(); } }; diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 3867bb8..3715946 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -42,8 +42,8 @@ def __init__(self): print("Error trying to connect to Arduino") self._serial = NoneSerialManager() - def connect(self, device, baud): - self._serial = serial.Serial(device, baud) + def connect(self, device): + self._serial = serial.Serial(device, 9600) time.sleep(2) def write(self, value): From 333e3bbd7fe60c1a1e7adea1b5ea23f33106cc52 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 13 Nov 2012 03:18:12 +0100 Subject: [PATCH 084/344] Cleaning some code --- nanpy/arduino.py | 1 - nanpy/arduinoboard.py | 30 ++++++++++++------------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index e408981..2ccccdd 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,4 +1,3 @@ -from nanpy.arduinoboard import (call_static_method, return_value) from nanpy.arduinoboard import (arduinoclassmethod, returns) import time diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 4030436..25111d2 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -3,15 +3,21 @@ mutex = Lock() -def _write( data): - data = str(data) - for ch in data: - serial_manager.write('%c' % ch) - serial_manager.write('\0') +def _write(data): + serial_manager.write('%s\0' % str(data)) + +def return_value(): + return serial_manager.readline().replace('\r\n', '') + +def _call(namespace, id, args): -def _send_parameters(args): toprint = [] nel = 0 + + mutex.acquire() + _write(namespace) + _write(id) + for arg in args: if type(arg) == type(list()): for el in arg: @@ -28,14 +34,6 @@ def _send_parameters(args): for elprint in toprint: _write(elprint) -def return_value(): - return serial_manager.readline().replace('\r\n', '') - -def _call(namespace, id, args): - mutex.acquire() - _write(namespace) - _write(id) - _send_parameters(args) ret = return_value() mutex.release() return ret @@ -66,10 +64,6 @@ def wrapper(cls, *args, **kwargs): return _call(cls.__name__, 0, call_pars) return wrapper -def call_static_method(*args): - return _call(args[0], 0, args[1:]) - - class ArduinoObject(): def __init__(self): From d58f41eba8b5383381ee6f88c3449e6816ae7659 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 14 Nov 2012 15:04:44 +0100 Subject: [PATCH 085/344] Available check reenabled --- firmware/Nanpy.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 4d9f7c6..bf289cb 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -25,7 +25,9 @@ void setup() { } void loop() { - m = new MethodDescriptor(); - Register::elaborate(m); + if(ComChannel::available()) { + m = new MethodDescriptor(); + Register::elaborate(m); + } } From 584157fffbb0940976d76a3859047aa34ddf1287 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 14 Nov 2012 15:05:58 +0100 Subject: [PATCH 086/344] Bumped to version 0.6 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5964c2b..9fbb84b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.5", + version="0.6", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From ee2a39f7435485b4146236513911d8a2f0e57557 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 14 Nov 2012 16:35:39 +0100 Subject: [PATCH 087/344] Thank you friends --- THANKS | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 THANKS diff --git a/THANKS b/THANKS new file mode 100644 index 0000000..85ab147 --- /dev/null +++ b/THANKS @@ -0,0 +1,7 @@ +PACKAGERS +--------- +- Andrea Grandi (@andreagrandi) - Ubuntu packager + +TESTERS +------- +- Fernando Molina (@F_M_A) - Leonardo boards From 157fad25683b3789629009be74d083980aa93fb5 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 21 Dec 2012 13:12:12 +0100 Subject: [PATCH 088/344] Use the official version of edams makefile --- README.md | 1 + firmware/arduino.mk | 75 ++++++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index e3ff24e..29aae46 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Dependencies #### Python (2.2 or later) - python-distribute (http://pypi.python.org/pypi/distribute) - python-serial +- edam's Arduino makefile (http://bzr.ed.am/make/arduino-mk/, included) How to build and install ------------------------ diff --git a/firmware/arduino.mk b/firmware/arduino.mk index 10f5200..0039b64 100644 --- a/firmware/arduino.mk +++ b/firmware/arduino.mk @@ -2,9 +2,9 @@ # # edam's Arduino makefile #_______________________________________________________________________________ -# version 0.4dev +# version 0.5dev # -# Copyright (C) 2011, 1012 Tim Marston . +# Copyright (C) 2011, 2012 Tim Marston . # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -70,7 +70,7 @@ # determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp # files in the project directory (or any "util" or "utility" subdirectories) # are automatically included in the build and are scanned for Arduino libraries -# that have been #included. Note, there can only be one .ino (or .pde) file. +# that have been #included. Note, there can only be one .ino (or .pde) file. # # Alternatively, if you want to manually specify build variables, create a # Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. @@ -85,22 +85,35 @@ # ARDUINODIR The path where the Arduino software is installed on your system. # # ARDUINOCONST The Arduino software version, as an integer, used to define the -# ARDUINO version constant. This defaults to 100 if undefined. +# ARDUINO version constant. This defaults to 100 if undefined. # -# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess -# based on where the avrdude in use is. If empty, no avrdude.conf +# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess +# based on where the avrdude in use is. If empty, no avrdude.conf # is passed to avrdude (to the system default is used). # -# AVRTOOLSPATH A space-separated list of directories to search in order when -# looking for the avr build tools. This defaults to the system PATH -# followed by subdirectories in ARDUINODIR if undefined. +# AVRDUDEFLAGS Specify any additional flags for avrdude. The usual flags, +# required to build the project, will be appended to this. +# +# AVRTOOLSPATH A space-separated list of directories that is searched in order +# when looking for the avr build tools. This defaults to PATH, +# followed by subdirectories in ARDUINODIR. # # BOARD Specify a target board type. Run `make boards` to see available # board types. # +# CPPFLAGS Specify any additional flags for the compiler. The usual flags, +# required to build the project, will be appended to this. +# +# LINKFLAGS Specify any additional flags for the linker. The usual flags, +# required to build the project, will be appended to this. +# # LIBRARIES A list of Arduino libraries to build and include. This is set # automatically if a .ino (or .pde) is found. # +# LIBRARYPATH A space-separated list of directories that is searched in order +# when looking for Arduino libraries. This defaults to "libs", +# "libraries" and then the Arduino software's libraries directory. +# # SERIALDEV The unix device name of the serial device that is the Arduino. # If unspecified, an attempt is made to determine the name of a # connected Arduino's serial device. @@ -156,6 +169,9 @@ AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools/avr/bin endif +# default path to find libraries +LIBRARYPATH ?= libraries libs $(ARDUINODIR)/libraries + # auto mode? INOFILE := $(wildcard *.ino *.pde) ifdef INOFILE @@ -166,15 +182,12 @@ endif # automatically determine sources and targeet TARGET := $(basename $(INOFILE)) SOURCES := $(INOFILE) \ - $(wildcard *.c *.cc *.cpp) \ - $(wildcard $(addprefix util/, *.c *.cc *.cpp)) \ - $(wildcard $(addprefix utility/, *.c *.cc *.cpp)) + $(wildcard *.c *.cc *.cpp *.C) \ + $(wildcard $(addprefix util/, *.c *.cc *.cpp *.C)) \ + $(wildcard $(addprefix utility/, *.c *.cc *.cpp *.C)) # automatically determine included libraries -LIBRARIES := $(filter $(notdir $(wildcard $(ARDUINODIR)/libraries/*)), \ - $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) - -LIBRARIES += $(filter $(notdir $(wildcard libraries/*)), \ +LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \ $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) endif @@ -197,19 +210,21 @@ OBJCOPY := $(call findsoftware,avr-objcopy) AVRDUDE := $(call findsoftware,avrdude) AVRSIZE := $(call findsoftware,avr-size) +# directories +ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino +LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \ + $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH))))) +LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS)) + # files TARGET := $(if $(TARGET),$(TARGET),a.out) OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) -ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino ARDUINOLIB := .lib/arduino.a -ARDUINOLIBLIBSDIR := $(ARDUINODIR)/libraries -ARDUINOLIBLIBSPATH := $(foreach lib, $(LIBRARIES), \ - $(ARDUINODIR)/libraries/$(lib)/ $(ARDUINODIR)/libraries/$(lib)/utility/ ) -ARDUINOLIBLIBSPATH += $(foreach lib, $(LIBRARIES), \ - ./libraries/$(lib)/ ./libraries/$(lib)/utility/ ) -ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(ARDUINOLIBLIBSPATH), \ +ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \ $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) + +# avrdude confifuration ifeq "$(AVRDUDECONF)" "" ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf @@ -254,22 +269,20 @@ endif endif # flags -CPPFLAGS := -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections +CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR) CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ -CPPFLAGS += $(addprefix -I $(ARDUINODIR)/libraries/, $(LIBRARIES)) -CPPFLAGS += $(addprefix -I./libraries/, $(LIBRARIES)) -CPPFLAGS += $(patsubst %, -I $(ARDUINODIR)/libraries/%/utility, $(LIBRARIES)) +CPPFLAGS += $(addprefix -I , $(LIBRARYDIRS)) CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h -AVRDUDEFLAGS := $(addprefix -C , $(AVRDUDECONF)) -DV +AVRDUDEFLAGS += $(addprefix -C , $(AVRDUDECONF)) -DV AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) -LINKFLAGS := -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) +LINKFLAGS += -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) # figure out which arg to use with stty (for OS X, GNU and busybox stty) STTYFARG := $(shell stty --help 2>&1 | \ @@ -320,7 +333,7 @@ monitor: exit 1; } @test -n `which screen` || { \ echo "error: can't find GNU screen, you might need to install it." >&2 \ - ecit 1; } + exit 1; } @test 0 -eq $(SERIALDEVGUESS) || { \ echo "*GUESSING* at serial device:" $(SERIALDEV); \ echo; } @@ -361,7 +374,7 @@ $(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) %.o: %.pde mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ -x c++ -include $(ARDUINOCOREDIR)/Arduino.h $< + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< # building the arduino library From 8c6f38a8c0818966d66bb97efe0039d3dae80bff Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 21 Dec 2012 13:39:43 +0100 Subject: [PATCH 089/344] Uploaded the last version of edams makefile --- firmware/arduino.mk | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/firmware/arduino.mk b/firmware/arduino.mk index 0039b64..ad502a7 100644 --- a/firmware/arduino.mk +++ b/firmware/arduino.mk @@ -159,18 +159,22 @@ ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" $(error ARDUINODIR is not set correctly; arduino software not found) endif +# obtain preferences from the IDE's preferences.txt +PREFERENCES_FILE := $(wildcard $(HOME)/.arduino/preferences.txt) +ifneq "$(PREFERENCES_FILE)" "" +SKETCHBOOKDIR := \ + $(shell sed -ne "s/sketchbook.path=\(.*\)/\1/p" $(PREFERENCES_FILE)) +endif + # default arduino version ARDUINOCONST ?= 100 # default path for avr tools -ifndef AVRTOOLSPATH -AVRTOOLSPATH := $(subst :, , $(PATH)) -AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools -AVRTOOLSPATH += $(ARDUINODIR)/hardware/tools/avr/bin -endif +AVRTOOLSPATH ?= $(subst :, , $(PATH)) $(ARDUINODIR)/hardware/tools \ + $(ARDUINODIR)/hardware/tools/avr/bin # default path to find libraries -LIBRARYPATH ?= libraries libs $(ARDUINODIR)/libraries +LIBRARYPATH ?= libraries libs $(SKETCHBOOKDIR)/libraries $(ARDUINODIR)/libraries # auto mode? INOFILE := $(wildcard *.ino *.pde) @@ -258,6 +262,8 @@ BOARD_USB_VID := \ $(shell sed -ne "s/$(BOARD).build.vid=\(.*\)/\1/p" $(BOARDS_FILE)) BOARD_USB_PID := \ $(shell sed -ne "s/$(BOARD).build.pid=\(.*\)/\1/p" $(BOARDS_FILE)) +BOARD_BOOTLOADER_PATH := \ + $(shell sed -ne "s/$(BOARD).bootloader.path=\(.*\)/\1/p" $(BOARDS_FILE)) # invalid board? ifeq "$(BOARD_BUILD_MCU)" "" @@ -313,6 +319,10 @@ upload: target @test 0 -eq $(SERIALDEVGUESS) || { \ echo "*GUESSING* at serial device:" $(SERIALDEV); \ echo; } +ifeq "$(BOARD_BOOTLOADER_PATH)" "caterina" + stty $(STTYFARG) $(SERIALDEV) speed 1200 + sleep 1 +endif stty $(STTYFARG) $(SERIALDEV) hupcl $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i From f41ea50954f8516cb078f35f99efda0a58086820 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 22 Dec 2012 16:43:42 +0100 Subject: [PATCH 090/344] Added map function --- nanpy/arduino.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 2ccccdd..7a3c91c 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -37,7 +37,10 @@ def pinMode(cls, pin, mode): pass @classmethod - @arduinoclassmethod def delay(cls, value): time.sleep(value/1000) + @classmethod + def map(cls, x, in_min, in_max, out_min, out_max): + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min + From 0e1b43927ea66b45a85ae9258319f9a26a2cb4ec Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 25 Dec 2012 03:08:53 +0100 Subject: [PATCH 091/344] Return an integer instead of a string where possible --- firmware/ArduinoClass.cpp | 9 ++++----- firmware/DallasTemperatureClass.cpp | 4 ++-- firmware/LiquidCrystalClass.cpp | 4 ++-- firmware/OneWireClass.cpp | 8 ++++---- firmware/ServoClass.cpp | 6 +++--- firmware/StepperClass.cpp | 4 ++-- firmware/ToneClass.cpp | 4 ++-- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/firmware/ArduinoClass.cpp b/firmware/ArduinoClass.cpp index 99f3833..b0aff76 100644 --- a/firmware/ArduinoClass.cpp +++ b/firmware/ArduinoClass.cpp @@ -7,7 +7,7 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Arduino") == 0) { if (strcmp(m->getName(), "digitalWrite") == 0) { digitalWrite(m->getInt(0), m->getInt(1)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "digitalRead") == 0) { @@ -16,7 +16,7 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "analogWrite") == 0) { analogWrite(m->getInt(0), m->getInt(1)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "analogRead") == 0) { @@ -25,12 +25,11 @@ void ArduinoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "pinMode") == 0) { pinMode(m->getInt(0), m->getInt(1)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "delay") == 0) { - //delay(m->getInt(0)); - m->returns("0"); + m->returns(0); } } }; diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index fabbf89..08bf983 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -31,7 +31,7 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { m->returns(v[m->getObjectId()]->requestTemperaturesByAddress(addr)); } else { v[m->getObjectId()]->requestTemperatures(); - m->returns("0"); + m->returns(0); } } @@ -63,7 +63,7 @@ void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { byte addr[8]; String addr_hex = String(); if(!v[m->getObjectId()]->getAddress(addr, m->getInt(0))) { - m->returns("1"); + m->returns(1); return; } for( int cc = 0; cc < 7; cc++ ) diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 12ab425..e73b97c 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -25,12 +25,12 @@ void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { } else v[m->getObjectId()]->print(m->getString(0)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "setCursor") == 0) { v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); - m->returns("0"); + m->returns(0); } } diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index e21361d..b14241f 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -21,7 +21,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { if(!res) { v[m->getObjectId()]->reset_search(); delay(250); - m->returns("1"); + m->returns(1); } else { @@ -35,7 +35,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "reset_search") == 0) { v[m->getObjectId()]->reset_search(); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "reset") == 0) { @@ -52,7 +52,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { v[m->getObjectId()]->select(addr); delete(addr); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "write") == 0) { @@ -60,7 +60,7 @@ void OneWireClass::elaborate( MethodDescriptor* m ) { v[m->getObjectId()]->write(m->getInt(0)); else v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "read") == 0) { diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index dd363f3..f222d00 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -17,7 +17,7 @@ void ServoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "write") == 0) { v[m->getObjectId()]->write(m->getInt(0)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "read") == 0) { @@ -26,7 +26,7 @@ void ServoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "writeMicroseconds") == 0) { v[m->getObjectId()]->writeMicroseconds(m->getInt(0)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "readMicroseconds") == 0) { @@ -35,7 +35,7 @@ void ServoClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "detach") == 0) { v[m->getObjectId()]->detach(); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "attached") == 0) { diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index ec5fc09..33e7654 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -17,12 +17,12 @@ void StepperClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "setSpeed") == 0) { v[m->getObjectId()]->setSpeed(m->getInt(0)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "step") == 0) { v[m->getObjectId()]->step(m->getInt(0)); - m->returns("0"); + m->returns(0); } } diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 0d4e6a5..966a2fd 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -15,12 +15,12 @@ void ToneClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "play") == 0) { v[m->getObjectId()]->play(m->getInt(0), m->getInt(0)); - m->returns("0"); + m->returns(0); } if (strcmp(m->getName(), "stop") == 0) { v[m->getObjectId()]->stop(); - m->returns("0"); + m->returns(0); } } From 7ab0922bbe34043a862d3a38f3e2c30a4970719a Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Dec 2012 04:07:21 +0100 Subject: [PATCH 092/344] CapacitiveSensor added --- firmware/CapacitiveSensorClass.cpp | 16 ++ firmware/CapacitiveSensorClass.h | 16 ++ firmware/Nanpy.ino | 2 + .../libraries/CapacitiveSensor/.gitignore | 12 ++ .../CapacitiveSensor/CapacitiveSensor.cpp | 181 ++++++++++++++++++ .../CapacitiveSensor/CapacitiveSensor.h | 51 +++++ firmware/libraries/CapacitiveSensor/README.md | 4 + .../CapacitiveSensorSketch.pde | 39 ++++ .../libraries/CapacitiveSensor/keywords.txt | 6 + 9 files changed, 327 insertions(+) create mode 100644 firmware/CapacitiveSensorClass.cpp create mode 100644 firmware/CapacitiveSensorClass.h create mode 100644 firmware/libraries/CapacitiveSensor/.gitignore create mode 100644 firmware/libraries/CapacitiveSensor/CapacitiveSensor.cpp create mode 100644 firmware/libraries/CapacitiveSensor/CapacitiveSensor.h create mode 100644 firmware/libraries/CapacitiveSensor/README.md create mode 100644 firmware/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde create mode 100644 firmware/libraries/CapacitiveSensor/keywords.txt diff --git a/firmware/CapacitiveSensorClass.cpp b/firmware/CapacitiveSensorClass.cpp new file mode 100644 index 0000000..a9a12c2 --- /dev/null +++ b/firmware/CapacitiveSensorClass.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "CapacitiveSensorClass.h" +#include "MethodDescriptor.h" + +void CapacitiveSensorClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "CapacitiveSensor") == 0) { + + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + //TODO + } + + } +}; diff --git a/firmware/CapacitiveSensorClass.h b/firmware/CapacitiveSensorClass.h new file mode 100644 index 0000000..90233de --- /dev/null +++ b/firmware/CapacitiveSensorClass.h @@ -0,0 +1,16 @@ +#ifndef CAPACITIVE_SENSOR_CLASS +#define CAPACITIVE_SENSOR_CLASS + +#include "BaseClass.h" + +class CapacitiveSensor; +class MethodDescriptor; + +class CapacitiveSensorClass : public ObjectsManager { + + public: + void elaborate( MethodDescriptor* m ); + +}; + +#endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index bf289cb..44a406a 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -5,6 +5,7 @@ #include "ServoClass.h" #include "DallasTemperatureClass.h" #include "LiquidCrystalClass.h" +#include "CapacitiveSensorClass.h" #include "ToneClass.h" #include "MethodDescriptor.h" #include "ComChannel.h" @@ -20,6 +21,7 @@ void setup() { REGISTER_CLASS(StepperClass); REGISTER_CLASS(ServoClass); REGISTER_CLASS(ToneClass); + REGISTER_CLASS(CapacitiveSensorClass); ComChannel::connect(); } diff --git a/firmware/libraries/CapacitiveSensor/.gitignore b/firmware/libraries/CapacitiveSensor/.gitignore new file mode 100644 index 0000000..8df9393 --- /dev/null +++ b/firmware/libraries/CapacitiveSensor/.gitignore @@ -0,0 +1,12 @@ +# Compiled Object files +*.slo +*.lo +*.o + +# Compiled Dynamic libraries +*.so + +# Compiled Static libraries +*.lai +*.la +*.a diff --git a/firmware/libraries/CapacitiveSensor/CapacitiveSensor.cpp b/firmware/libraries/CapacitiveSensor/CapacitiveSensor.cpp new file mode 100644 index 0000000..54e0d81 --- /dev/null +++ b/firmware/libraries/CapacitiveSensor/CapacitiveSensor.cpp @@ -0,0 +1,181 @@ +/* + CapacitiveSense.h v.04 - Capacitive Sensing Library for 'duino / Wiring + Copyright (c) 2009 Paul Bagder All right reserved. + Version 04 by Paul Stoffregen - Arduino 1.0 compatibility, issue 146 fix + vim: set ts=4: + */ + +#if ARDUINO >= 100 +#include "Arduino.h" +#else +#include "WProgram.h" +#include "pins_arduino.h" +#include "WConstants.h" +#endif + +#include "CapacitiveSensor.h" + +// Constructor ///////////////////////////////////////////////////////////////// +// Function that handles the creation and setup of instances + +CapacitiveSensor::CapacitiveSensor(uint8_t sendPin, uint8_t receivePin) +{ + uint8_t sPort, rPort; + + // initialize this instance's variables + // Serial.begin(9600); // for debugging + error = 1; + loopTimingFactor = 310; // determined empirically - a hack + + CS_Timeout_Millis = (2000 * (float)loopTimingFactor * (float)F_CPU) / 16000000; + CS_AutocaL_Millis = 20000; + + // Serial.print("timwOut = "); + // Serial.println(CS_Timeout_Millis); + + // get pin mapping and port for send Pin - from PinMode function in core + +#ifdef NUM_DIGITAL_PINS + if (sendPin >= NUM_DIGITAL_PINS) error = -1; + if (receivePin >= NUM_DIGITAL_PINS) error = -1; +#endif + + sBit = digitalPinToBitMask(sendPin); // get send pin's ports and bitmask + sPort = digitalPinToPort(sendPin); + sReg = portModeRegister(sPort); + sOut = portOutputRegister(sPort); // get pointer to output register + + rBit = digitalPinToBitMask(receivePin); // get receive pin's ports and bitmask + rPort = digitalPinToPort(receivePin); + rReg = portModeRegister(rPort); + rIn = portInputRegister(rPort); + rOut = portOutputRegister(rPort); + + // get pin mapping and port for receive Pin - from digital pin functions in Wiring.c + noInterrupts(); + *sReg |= sBit; // set sendpin to OUTPUT + interrupts(); + leastTotal = 0x0FFFFFFFL; // input large value for autocalibrate begin + lastCal = millis(); // set millis for start +} + +// Public Methods ////////////////////////////////////////////////////////////// +// Functions available in Wiring sketches, this library, and other libraries + +long CapacitiveSensor::capacitiveSensor(uint8_t samples) +{ + total = 0; + if (samples == 0) return 0; + if (error < 0) return -1; // bad pin + + + for (uint8_t i = 0; i < samples; i++) { // loop for samples parameter - simple lowpass filter + if (SenseOneCycle() < 0) return -2; // variable over timeout +} + + // only calibrate if time is greater than CS_AutocaL_Millis and total is less than 10% of baseline + // this is an attempt to keep from calibrating when the sensor is seeing a "touched" signal + + if ( (millis() - lastCal > CS_AutocaL_Millis) && abs(total - leastTotal) < (int)(.10 * (float)leastTotal) ) { + + // Serial.println(); // debugging + // Serial.println("auto-calibrate"); + // Serial.println(); + // delay(2000); */ + + leastTotal = 0x0FFFFFFFL; // reset for "autocalibrate" + lastCal = millis(); + } + /*else{ // debugging + Serial.print(" total = "); + Serial.print(total); + + Serial.print(" leastTotal = "); + Serial.println(leastTotal); + + Serial.print("total - leastTotal = "); + x = total - leastTotal ; + Serial.print(x); + Serial.print(" .1 * leastTotal = "); + x = (int)(.1 * (float)leastTotal); + Serial.println(x); + } */ + + // routine to subtract baseline (non-sensed capacitance) from sensor return + if (total < leastTotal) leastTotal = total; // set floor value to subtract from sensed value + return(total - leastTotal); + +} + +long CapacitiveSensor::capacitiveSensorRaw(uint8_t samples) +{ + total = 0; + if (samples == 0) return 0; + if (error < 0) return -1; // bad pin - this appears not to work + + for (uint8_t i = 0; i < samples; i++) { // loop for samples parameter - simple lowpass filter + if (SenseOneCycle() < 0) return -2; // variable over timeout + } + + return total; +} + + +void CapacitiveSensor::reset_CS_AutoCal(void){ + leastTotal = 0x0FFFFFFFL; +} + +void CapacitiveSensor::set_CS_AutocaL_Millis(unsigned long autoCal_millis){ + CS_AutocaL_Millis = autoCal_millis; +} + +void CapacitiveSensor::set_CS_Timeout_Millis(unsigned long timeout_millis){ + CS_Timeout_Millis = (timeout_millis * (float)loopTimingFactor * (float)F_CPU) / 16000000; // floats to deal with large numbers +} + +// Private Methods ///////////////////////////////////////////////////////////// +// Functions only available to other functions in this library + +int CapacitiveSensor::SenseOneCycle(void) +{ + noInterrupts(); + *sOut &= ~sBit; // set Send Pin Register low + + *rReg &= ~rBit; // set receivePin to input + *rOut &= ~rBit; // set receivePin Register low to make sure pullups are off + + *rReg |= rBit; // set pin to OUTPUT - pin is now LOW AND OUTPUT + *rReg &= ~rBit; // set pin to INPUT + + *sOut |= sBit; // set send Pin High + interrupts(); + + while ( !(*rIn & rBit) && (total < CS_Timeout_Millis) ) { // while receive pin is LOW AND total is positive value + total++; + } + + if (total > CS_Timeout_Millis) { + return -2; // total variable over timeout + } + + // set receive pin HIGH briefly to charge up fully - because the while loop above will exit when pin is ~ 2.5V + noInterrupts(); + *rOut |= rBit; // set receive pin HIGH - turns on pullup + *rReg |= rBit; // set pin to OUTPUT - pin is now HIGH AND OUTPUT + *rReg &= ~rBit; // set pin to INPUT + *rOut &= ~rBit; // turn off pullup + + *sOut &= ~sBit; // set send Pin LOW + interrupts(); + + while ( (*rIn & rBit) && (total < CS_Timeout_Millis) ) { // while receive pin is HIGH AND total is less than timeout + total++; + } + // Serial.println(total); + + if (total >= CS_Timeout_Millis) { + return -2; // total variable over timeout + } else { + return 1; + } +} diff --git a/firmware/libraries/CapacitiveSensor/CapacitiveSensor.h b/firmware/libraries/CapacitiveSensor/CapacitiveSensor.h new file mode 100644 index 0000000..45424b1 --- /dev/null +++ b/firmware/libraries/CapacitiveSensor/CapacitiveSensor.h @@ -0,0 +1,51 @@ +/* + CapacitiveSense.h v.04 - Capacitive Sensing Library for 'duino / Wiring + Copyright (c) 2008 Paul Bagder All rights reserved. + Version 04 by Paul Stoffregen - Arduino 1.0 compatibility, issue 146 fix + vim: set ts=4: +*/ + +// ensure this library description is only included once +#ifndef CapacitiveSensor_h +#define CapacitiveSensor_h + +#if ARDUINO >= 100 +#include "Arduino.h" +#else +#include "WProgram.h" +#endif + +// library interface description +class CapacitiveSensor +{ + // user-accessible "public" interface + public: + // methods + CapacitiveSensor(uint8_t sendPin, uint8_t receivePin); + long capacitiveSensorRaw(uint8_t samples); + long capacitiveSensor(uint8_t samples); + void set_CS_Timeout_Millis(unsigned long timeout_millis); + void reset_CS_AutoCal(); + void set_CS_AutocaL_Millis(unsigned long autoCal_millis); + // library-accessible "private" interface + private: + // variables + int error; + unsigned long leastTotal; + unsigned int loopTimingFactor; + unsigned long CS_Timeout_Millis; + unsigned long CS_AutocaL_Millis; + unsigned long lastCal; + unsigned long total; + uint8_t sBit; // send pin's ports and bitmask + volatile uint8_t *sReg; + volatile uint8_t *sOut; + uint8_t rBit; // receive pin's ports and bitmask + volatile uint8_t *rReg; + volatile uint8_t *rIn; + volatile uint8_t *rOut; + // methods + int SenseOneCycle(void); +}; + +#endif diff --git a/firmware/libraries/CapacitiveSensor/README.md b/firmware/libraries/CapacitiveSensor/README.md new file mode 100644 index 0000000..0799c96 --- /dev/null +++ b/firmware/libraries/CapacitiveSensor/README.md @@ -0,0 +1,4 @@ +CapacitiveSensor +================ + +CapacitiveSensor \ No newline at end of file diff --git a/firmware/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde b/firmware/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde new file mode 100644 index 0000000..a036612 --- /dev/null +++ b/firmware/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde @@ -0,0 +1,39 @@ +#include + +/* + * CapitiveSense Library Demo Sketch + * Paul Badger 2008 + * Uses a high value resistor e.g. 10M between send pin and receive pin + * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values. + * Receive pin is the sensor pin - try different amounts of foil/metal on this pin + */ + + +CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired +CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil +CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil + +void setup() +{ + cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example + Serial.begin(9600); +} + +void loop() +{ + long start = millis(); + long total1 = cs_4_2.capacitiveSensor(30); + long total2 = cs_4_6.capacitiveSensor(30); + long total3 = cs_4_8.capacitiveSensor(30); + + Serial.print(millis() - start); // check on performance in milliseconds + Serial.print("\t"); // tab character for debug windown spacing + + Serial.print(total1); // print sensor output 1 + Serial.print("\t"); + Serial.print(total2); // print sensor output 2 + Serial.print("\t"); + Serial.println(total3); // print sensor output 3 + + delay(10); // arbitrary delay to limit data to serial port +} diff --git a/firmware/libraries/CapacitiveSensor/keywords.txt b/firmware/libraries/CapacitiveSensor/keywords.txt new file mode 100644 index 0000000..1933303 --- /dev/null +++ b/firmware/libraries/CapacitiveSensor/keywords.txt @@ -0,0 +1,6 @@ +CapacitiveSensor KEYWORD1 +capacitiveSensorRaw KEYWORD2 +capacitiveSensor KEYWORD2 +set_CS_Timeout_Millis KEYWORD2 +reset_CS_AutoCal KEYWORD2 +set_CS_AutocaL_Millis KEYWORD2 From 046921941391721c435dc8ca09a7992f3780f238 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Dec 2012 04:09:10 +0100 Subject: [PATCH 093/344] CapacitiveSensor gitignore removed --- firmware/libraries/CapacitiveSensor/.gitignore | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 firmware/libraries/CapacitiveSensor/.gitignore diff --git a/firmware/libraries/CapacitiveSensor/.gitignore b/firmware/libraries/CapacitiveSensor/.gitignore deleted file mode 100644 index 8df9393..0000000 --- a/firmware/libraries/CapacitiveSensor/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# Compiled Object files -*.slo -*.lo -*.o - -# Compiled Dynamic libraries -*.so - -# Compiled Static libraries -*.lai -*.la -*.a From e8a6714fa51615941678b141b9b1fbe35fbea714 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 29 Dec 2012 14:46:35 +0100 Subject: [PATCH 094/344] CapacitiveSensor library is now supported --- firmware/CapacitiveSensorClass.cpp | 11 ++++++++++- firmware/ComChannel.cpp | 7 ++++--- firmware/ComChannel.h | 1 + firmware/MethodDescriptor.cpp | 4 ++++ firmware/MethodDescriptor.h | 1 + nanpy/__init__.py | 1 + nanpy/capacitivesensor.py | 19 +++++++++++++++++++ 7 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 nanpy/capacitivesensor.py diff --git a/firmware/CapacitiveSensorClass.cpp b/firmware/CapacitiveSensorClass.cpp index a9a12c2..f1e24a2 100644 --- a/firmware/CapacitiveSensorClass.cpp +++ b/firmware/CapacitiveSensorClass.cpp @@ -9,7 +9,16 @@ void CapacitiveSensorClass::elaborate( MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { - //TODO + v.insert(new CapacitiveSensor(m->getInt(0), m->getInt(1))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "capacitiveSensor") == 0) { + m->returns(v[m->getObjectId()]->capacitiveSensor(m->getInt(0))); + } + + if (strcmp(m->getName(), "capacitiveSensorRaw") == 0) { + m->returns(v[m->getObjectId()]->capacitiveSensorRaw(m->getInt(0))); } } diff --git a/firmware/ComChannel.cpp b/firmware/ComChannel.cpp index 2ae177d..900b515 100755 --- a/firmware/ComChannel.cpp +++ b/firmware/ComChannel.cpp @@ -28,9 +28,6 @@ bool ComChannel::available() { void ComChannel::connect() { Serial.begin(BAUDRATE); - while (!Serial) { - ; - } } void ComChannel::println(String& val) { @@ -53,6 +50,10 @@ void ComChannel::println(double val) { Serial.println(val); } +void ComChannel::println(long val) { + Serial.println(val); +} + char* ComChannel::readLine() { return readLineFromSerial(); } diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h index ff23ee4..667136a 100755 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -15,6 +15,7 @@ class ComChannel { static void println(int val); static void println(float val); static void println(double val); + static void println(long val); static char* readLine(); }; diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index 622f401..13b1795 100755 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -80,6 +80,10 @@ void MethodDescriptor::returns(double val) { ComChannel::println(val); } +void MethodDescriptor::returns(long val) { + ComChannel::println(val); +} + MethodDescriptor::~MethodDescriptor() { delete(name); delete(classname); diff --git a/firmware/MethodDescriptor.h b/firmware/MethodDescriptor.h index e933c85..768a1c7 100644 --- a/firmware/MethodDescriptor.h +++ b/firmware/MethodDescriptor.h @@ -27,6 +27,7 @@ class MethodDescriptor { void returns(int val); void returns(float val); void returns(double val); + void returns(long val); ~MethodDescriptor(); }; diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 1af1e89..b8647e0 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -20,3 +20,4 @@ from nanpy.servo import Servo from nanpy.dallastemperature import DallasTemperature from nanpy.tone import Tone +from nanpy.capacitivesensor import CapacitiveSensor diff --git a/nanpy/capacitivesensor.py b/nanpy/capacitivesensor.py new file mode 100644 index 0000000..95fabe5 --- /dev/null +++ b/nanpy/capacitivesensor.py @@ -0,0 +1,19 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import (arduinoobjectmethod, returns) + +class CapacitiveSensor(ArduinoObject): + + def __init__(self, pin1, pin2): + ArduinoObject.__init__(self) + self.id = self.call('new', pin1, pin2) + + @returns(int) + @arduinoobjectmethod + def capacitiveSensor(self, samples): + pass + + @returns(int) + @arduinoobjectmethod + def capacitiveSensorRaw(self, samples): + pass + From 26b16d5140e46e4524240e08d1a5bdd47ed8da21 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 2 Jan 2013 15:05:50 +0100 Subject: [PATCH 095/344] Bumped to version 0.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9fbb84b..04db14f 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.6", + version="0.7", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From d3ba59e97a6cdad73125e14a833443bc43792ada Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 7 Jan 2013 03:11:44 +0100 Subject: [PATCH 096/344] Changed edams makefile url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29aae46..b7efca9 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Dependencies #### Python (2.2 or later) - python-distribute (http://pypi.python.org/pypi/distribute) - python-serial -- edam's Arduino makefile (http://bzr.ed.am/make/arduino-mk/, included) +- edam's Arduino makefile (http://ed.am/dev/make/arduino-mk, included) How to build and install ------------------------ From ec7801340e249727734d14f3233dc605b84c2615 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 16 Jan 2013 13:13:18 +0100 Subject: [PATCH 097/344] EEPROM support added --- firmware/EEPROMClass.cpp | 17 +++++++++++++++++ firmware/EEPROMClass.h | 17 +++++++++++++++++ firmware/Nanpy.ino | 4 ++++ firmware/SlimArray.h | 2 ++ nanpy/__init__.py | 1 + nanpy/eeprom.py | 14 ++++++++++++++ 6 files changed, 55 insertions(+) create mode 100644 firmware/EEPROMClass.cpp create mode 100644 firmware/EEPROMClass.h create mode 100644 nanpy/eeprom.py diff --git a/firmware/EEPROMClass.cpp b/firmware/EEPROMClass.cpp new file mode 100644 index 0000000..248e55a --- /dev/null +++ b/firmware/EEPROMClass.cpp @@ -0,0 +1,17 @@ +#include +#include "EEPROMClass.h" +#include "MethodDescriptor.h" +#include + +void nanpy::EEPROMClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "EEPROM") == 0) { + if (strcmp(m->getName(), "write") == 0) { + EEPROM.write(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "read") == 0) { + m->returns(EEPROM.read(m->getInt(0))); + } + } +}; diff --git a/firmware/EEPROMClass.h b/firmware/EEPROMClass.h new file mode 100644 index 0000000..27f6564 --- /dev/null +++ b/firmware/EEPROMClass.h @@ -0,0 +1,17 @@ +#ifndef EEPROM_CLASS +#define EEPROM_CLASS + +#include "BaseClass.h" + +class MethodDescriptor; + +namespace nanpy { + class EEPROMClass : public BaseClass { + + public: + void elaborate( MethodDescriptor* m ); + + }; +} + +#endif diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 44a406a..7893486 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -9,11 +9,15 @@ #include "ToneClass.h" #include "MethodDescriptor.h" #include "ComChannel.h" +#include "EEPROMClass.h" + +using namespace nanpy; MethodDescriptor *m = NULL; void setup() { + REGISTER_CLASS(EEPROMClass); REGISTER_CLASS(ArduinoClass); REGISTER_CLASS(LiquidCrystalClass); REGISTER_CLASS(OneWireClass); diff --git a/firmware/SlimArray.h b/firmware/SlimArray.h index 96d5649..7db58fc 100644 --- a/firmware/SlimArray.h +++ b/firmware/SlimArray.h @@ -1,6 +1,8 @@ #ifndef SLIM_ARRAY #define SLIM_ARRAY +#include + template class SlimArray { private: diff --git a/nanpy/__init__.py b/nanpy/__init__.py index b8647e0..abc7651 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -14,6 +14,7 @@ from nanpy.serialmanager import serial_manager from nanpy.arduino import Arduino +from nanpy.eeprom import EEPROM from nanpy.lcd import Lcd from nanpy.onewire import OneWire from nanpy.stepper import Stepper diff --git a/nanpy/eeprom.py b/nanpy/eeprom.py new file mode 100644 index 0000000..ab32035 --- /dev/null +++ b/nanpy/eeprom.py @@ -0,0 +1,14 @@ +from nanpy.arduinoboard import (arduinoclassmethod, returns) + +class EEPROM(): + + @classmethod + @arduinoclassmethod + def write(cls, address, value): + pass + + @classmethod + @returns(int) + @arduinoclassmethod + def read(cls, address): + pass From fbae269845ef6b6f4027d20536e9753ecb9ed862 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 13 Feb 2013 12:56:44 +0100 Subject: [PATCH 098/344] Nanpy namespace everywhere --- firmware/ArduinoClass.cpp | 3 +- firmware/ArduinoClass.h | 11 +-- firmware/BaseClass.h | 65 +++++++------- firmware/CapacitiveSensorClass.cpp | 3 +- firmware/CapacitiveSensorClass.h | 12 +-- firmware/ComChannel.cpp | 18 ++-- firmware/ComChannel.h | 26 +++--- firmware/DallasTemperatureClass.cpp | 3 +- firmware/DallasTemperatureClass.h | 12 +-- firmware/EEPROMClass.cpp | 3 +- firmware/EEPROMClass.h | 5 +- firmware/LiquidCrystalClass.cpp | 3 +- firmware/LiquidCrystalClass.h | 13 +-- firmware/MethodDescriptor.cpp | 32 +++---- firmware/MethodDescriptor.h | 53 ++++++------ firmware/OneWireClass.cpp | 3 +- firmware/OneWireClass.h | 12 +-- firmware/ServoClass.cpp | 3 +- firmware/ServoClass.h | 12 +-- firmware/SlimArray.h | 126 ++++++++++++++-------------- firmware/StepperClass.cpp | 3 +- firmware/StepperClass.h | 12 +-- firmware/ToneClass.cpp | 3 +- firmware/ToneClass.h | 36 ++++---- 24 files changed, 241 insertions(+), 231 deletions(-) diff --git a/firmware/ArduinoClass.cpp b/firmware/ArduinoClass.cpp index b0aff76..ad45e43 100644 --- a/firmware/ArduinoClass.cpp +++ b/firmware/ArduinoClass.cpp @@ -1,9 +1,8 @@ #include #include "ArduinoClass.h" -#include "MethodDescriptor.h" #include -void ArduinoClass::elaborate( MethodDescriptor* m ) { +void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Arduino") == 0) { if (strcmp(m->getName(), "digitalWrite") == 0) { digitalWrite(m->getInt(0), m->getInt(1)); diff --git a/firmware/ArduinoClass.h b/firmware/ArduinoClass.h index 4b054e9..34a0a9d 100644 --- a/firmware/ArduinoClass.h +++ b/firmware/ArduinoClass.h @@ -2,14 +2,15 @@ #define ARDUINO_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" -class MethodDescriptor; +namespace nanpy { + class ArduinoClass : public BaseClass { -class ArduinoClass : public BaseClass { - - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); + }; }; #endif diff --git a/firmware/BaseClass.h b/firmware/BaseClass.h index 4c36e2c..59764df 100644 --- a/firmware/BaseClass.h +++ b/firmware/BaseClass.h @@ -4,53 +4,54 @@ #include "SlimArray.h" #include "MethodDescriptor.h" -class MethodDescriptor; +namespace nanpy { -class BaseClass { + class BaseClass { - public: - virtual void elaborate( MethodDescriptor* m ) = 0; + public: + virtual void elaborate( nanpy::MethodDescriptor* m ) = 0; -}; + }; -template class ObjectsManager : public BaseClass { + template class ObjectsManager : public BaseClass { - protected: - SlimArray v; + protected: + nanpy::SlimArray v; - public: - ObjectsManager() {} - void elaborate( MethodDescriptor* m ) { - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); + public: + ObjectsManager() {} + void elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); + v.remove(m->getObjectId()); + Serial.println("0"); + } } - } -}; + }; -static SlimArray classes; + static nanpy::SlimArray classes; -class Register { + class Register { - public: - - template static void registerClass() { - classes.insert((BaseClass*)new T()); - } + public: + + template static void registerClass() { + classes.insert((nanpy::BaseClass*)new T()); + } - static void elaborate(MethodDescriptor* m) { - for(int i = 0 ; i < classes.getSize() ; i++) - classes[i]->elaborate(m); + static void elaborate(nanpy::MethodDescriptor* m) { + for(int i = 0 ; i < classes.getSize() ; i++) + classes[i]->elaborate(m); - if(m != NULL) { - delete(m); - m = NULL; + if(m != NULL) { + delete(m); + m = NULL; + } } - } -}; + }; +} #define REGISTER_CLASS(cls) Register::registerClass(); diff --git a/firmware/CapacitiveSensorClass.cpp b/firmware/CapacitiveSensorClass.cpp index f1e24a2..bcd66b6 100644 --- a/firmware/CapacitiveSensorClass.cpp +++ b/firmware/CapacitiveSensorClass.cpp @@ -1,9 +1,8 @@ #include #include #include "CapacitiveSensorClass.h" -#include "MethodDescriptor.h" -void CapacitiveSensorClass::elaborate( MethodDescriptor* m ) { +void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "CapacitiveSensor") == 0) { ObjectsManager::elaborate(m); diff --git a/firmware/CapacitiveSensorClass.h b/firmware/CapacitiveSensorClass.h index 90233de..63d3566 100644 --- a/firmware/CapacitiveSensorClass.h +++ b/firmware/CapacitiveSensorClass.h @@ -2,15 +2,17 @@ #define CAPACITIVE_SENSOR_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" class CapacitiveSensor; -class MethodDescriptor; -class CapacitiveSensorClass : public ObjectsManager { +namespace nanpy { + class CapacitiveSensorClass : public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); -}; + }; +} #endif diff --git a/firmware/ComChannel.cpp b/firmware/ComChannel.cpp index 900b515..be08118 100755 --- a/firmware/ComChannel.cpp +++ b/firmware/ComChannel.cpp @@ -19,42 +19,42 @@ char* readLineFromSerial() return buffer2; }; -bool ComChannel::available() { +bool nanpy::ComChannel::available() { if (Serial.available() > 0) return true; else return false; } -void ComChannel::connect() { +void nanpy::ComChannel::connect() { Serial.begin(BAUDRATE); } -void ComChannel::println(String& val) { +void nanpy::ComChannel::println(String& val) { Serial.println(val); } -void ComChannel::println(const char* val) { +void nanpy::ComChannel::println(const char* val) { Serial.println(val); } -void ComChannel::println(int val) { +void nanpy::ComChannel::println(int val) { Serial.println(val); } -void ComChannel::println(float val) { +void nanpy::ComChannel::println(float val) { Serial.println(val); } -void ComChannel::println(double val) { +void nanpy::ComChannel::println(double val) { Serial.println(val); } -void ComChannel::println(long val) { +void nanpy::ComChannel::println(long val) { Serial.println(val); } -char* ComChannel::readLine() { +char* nanpy::ComChannel::readLine() { return readLineFromSerial(); } diff --git a/firmware/ComChannel.h b/firmware/ComChannel.h index 667136a..5437120 100755 --- a/firmware/ComChannel.h +++ b/firmware/ComChannel.h @@ -5,19 +5,21 @@ #include -class ComChannel { +namespace nanpy { + class ComChannel { - public: - static bool available(); - static void connect(); - static void println(String& val); - static void println(const char* val); - static void println(int val); - static void println(float val); - static void println(double val); - static void println(long val); - static char* readLine(); -}; + public: + static bool available(); + static void connect(); + static void println(String& val); + static void println(const char* val); + static void println(int val); + static void println(float val); + static void println(double val); + static void println(long val); + static char* readLine(); + }; +} #endif diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 08bf983..8b15e56 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -2,10 +2,9 @@ #include #include #include "DallasTemperatureClass.h" -#include "MethodDescriptor.h" #include -void DallasTemperatureClass::elaborate( MethodDescriptor* m ) { +void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "DallasTemperature") == 0) { diff --git a/firmware/DallasTemperatureClass.h b/firmware/DallasTemperatureClass.h index dee2337..d03b237 100644 --- a/firmware/DallasTemperatureClass.h +++ b/firmware/DallasTemperatureClass.h @@ -2,15 +2,17 @@ #define DALLAS_TEMP_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" class DallasTemperature; -class MethodDescriptor; -class DallasTemperatureClass: public ObjectsManager { +namespace nanpy { + class DallasTemperatureClass: public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); -}; + }; +} #endif diff --git a/firmware/EEPROMClass.cpp b/firmware/EEPROMClass.cpp index 248e55a..a9263b9 100644 --- a/firmware/EEPROMClass.cpp +++ b/firmware/EEPROMClass.cpp @@ -1,9 +1,8 @@ #include #include "EEPROMClass.h" -#include "MethodDescriptor.h" #include -void nanpy::EEPROMClass::elaborate( MethodDescriptor* m ) { +void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "EEPROM") == 0) { if (strcmp(m->getName(), "write") == 0) { EEPROM.write(m->getInt(0), m->getInt(1)); diff --git a/firmware/EEPROMClass.h b/firmware/EEPROMClass.h index 27f6564..1fe20d1 100644 --- a/firmware/EEPROMClass.h +++ b/firmware/EEPROMClass.h @@ -2,14 +2,13 @@ #define EEPROM_CLASS #include "BaseClass.h" - -class MethodDescriptor; +#include "MethodDescriptor.h" namespace nanpy { class EEPROMClass : public BaseClass { public: - void elaborate( MethodDescriptor* m ); + void elaborate( nanpy::MethodDescriptor* m ); }; } diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index e73b97c..30c8406 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -1,11 +1,10 @@ #include #include #include "LiquidCrystalClass.h" -#include "MethodDescriptor.h" #include #include -void LiquidCrystalClass::elaborate( MethodDescriptor* m ) { +void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Lcd") == 0) { ObjectsManager::elaborate(m); diff --git a/firmware/LiquidCrystalClass.h b/firmware/LiquidCrystalClass.h index dee9efc..8e1e572 100644 --- a/firmware/LiquidCrystalClass.h +++ b/firmware/LiquidCrystalClass.h @@ -2,17 +2,18 @@ #define LIQUID_CRYSTAL_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" class LiquidCrystal; -class MethodDescriptor; -class LiquidCrystalClass : public ObjectsManager { +namespace nanpy { + class LiquidCrystalClass : public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); - -}; + public: + void elaborate( nanpy::MethodDescriptor* m ); + }; +} #endif diff --git a/firmware/MethodDescriptor.cpp b/firmware/MethodDescriptor.cpp index 13b1795..45f2a15 100755 --- a/firmware/MethodDescriptor.cpp +++ b/firmware/MethodDescriptor.cpp @@ -4,7 +4,7 @@ #include "ComChannel.h" #include -MethodDescriptor::MethodDescriptor() { +nanpy::MethodDescriptor::MethodDescriptor() { this->classname = ComChannel::readLine(); @@ -28,63 +28,63 @@ MethodDescriptor::MethodDescriptor() { }; -int MethodDescriptor::getNArgs() { +int nanpy::MethodDescriptor::getNArgs() { return this->n_args; }; -int MethodDescriptor::getInt(int n) { +int nanpy::MethodDescriptor::getInt(int n) { return atoi(this->stack[n]); }; -float MethodDescriptor::getFloat(int n) { +float nanpy::MethodDescriptor::getFloat(int n) { return atof(this->stack[n]); }; -double MethodDescriptor::getDouble(int n) { +double nanpy::MethodDescriptor::getDouble(int n) { return atof(this->stack[n]); }; -char* MethodDescriptor::getString(int n) { +char* nanpy::MethodDescriptor::getString(int n) { return this->stack[n]; }; -char* MethodDescriptor::getClass() { +char* nanpy::MethodDescriptor::getClass() { return this->classname; }; -int MethodDescriptor::getObjectId() { +int nanpy::MethodDescriptor::getObjectId() { return this->objid; }; -char* MethodDescriptor::getName() { +char* nanpy::MethodDescriptor::getName() { return this->name; }; -void MethodDescriptor::returns(String& val) { +void nanpy::MethodDescriptor::returns(String& val) { ComChannel::println(val); } -void MethodDescriptor::returns(const char* val) { +void nanpy::MethodDescriptor::returns(const char* val) { ComChannel::println(val); } -void MethodDescriptor::returns(int val) { +void nanpy::MethodDescriptor::returns(int val) { ComChannel::println(val); } -void MethodDescriptor::returns(float val) { +void nanpy::MethodDescriptor::returns(float val) { ComChannel::println(val); } -void MethodDescriptor::returns(double val) { +void nanpy::MethodDescriptor::returns(double val) { ComChannel::println(val); } -void MethodDescriptor::returns(long val) { +void nanpy::MethodDescriptor::returns(long val) { ComChannel::println(val); } -MethodDescriptor::~MethodDescriptor() { +nanpy::MethodDescriptor::~MethodDescriptor() { delete(name); delete(classname); diff --git a/firmware/MethodDescriptor.h b/firmware/MethodDescriptor.h index 768a1c7..6ceeca9 100644 --- a/firmware/MethodDescriptor.h +++ b/firmware/MethodDescriptor.h @@ -3,33 +3,34 @@ #include -class MethodDescriptor { +namespace nanpy { + class MethodDescriptor { - private: - char *name; - int objid; - char* classname; - int n_args; - char **stack; + private: + char *name; + int objid; + char* classname; + int n_args; + char **stack; - public: - MethodDescriptor(); - int getNArgs(); - char* getClass(); - int getObjectId(); - int getInt(int n); - float getFloat(int n); - double getDouble(int n); - char* getString(int n); - char* getName(); - void returns(String& val); - void returns(const char* val); - void returns(int val); - void returns(float val); - void returns(double val); - void returns(long val); - ~MethodDescriptor(); - -}; + public: + MethodDescriptor(); + int getNArgs(); + char* getClass(); + int getObjectId(); + int getInt(int n); + float getFloat(int n); + double getDouble(int n); + char* getString(int n); + char* getName(); + void returns(String& val); + void returns(const char* val); + void returns(int val); + void returns(float val); + void returns(double val); + void returns(long val); + ~MethodDescriptor(); + }; +} #endif diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index b14241f..3f7bf8c 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -1,9 +1,8 @@ #include #include "OneWireClass.h" -#include "MethodDescriptor.h" #include -void OneWireClass::elaborate( MethodDescriptor* m ) { +void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "OneWire") == 0) { diff --git a/firmware/OneWireClass.h b/firmware/OneWireClass.h index 0e59f97..aff3bf9 100644 --- a/firmware/OneWireClass.h +++ b/firmware/OneWireClass.h @@ -2,15 +2,17 @@ #define ONE_WIRE_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" class OneWire; -class MethodDescriptor; -class OneWireClass: public ObjectsManager { +namespace nanpy { + class OneWireClass: public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); -}; + }; +} #endif diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index f222d00..28d2a95 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -1,10 +1,9 @@ #include #include #include "ServoClass.h" -#include "MethodDescriptor.h" #include -void ServoClass::elaborate( MethodDescriptor* m ) { +void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Servo") == 0) { ObjectsManager::elaborate(m); diff --git a/firmware/ServoClass.h b/firmware/ServoClass.h index 6f33a7e..535d7ef 100644 --- a/firmware/ServoClass.h +++ b/firmware/ServoClass.h @@ -2,15 +2,17 @@ #define SERVO_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" class Servo; -class MethodDescriptor; -class ServoClass: public ObjectsManager { +namespace nanpy { + class ServoClass: public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); -}; + }; +} #endif diff --git a/firmware/SlimArray.h b/firmware/SlimArray.h index 7db58fc..30cb23f 100644 --- a/firmware/SlimArray.h +++ b/firmware/SlimArray.h @@ -3,88 +3,90 @@ #include -template class SlimArray { +namespace nanpy { + template class SlimArray { - private: + private: - int size; - int cur_size; - T *v; + int size; + int cur_size; + T *v; - public: + public: - SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { - for(int i = 0; i < size; i++) - v[i] = 0; - cur_size = 0; - } + SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { + for(int i = 0; i < size; i++) + v[i] = 0; + cur_size = 0; + } - SlimArray(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { - size = s; - for(int i = 0; i < size; i++) - v[i] = x[i]; - } + SlimArray(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { + size = s; + for(int i = 0; i < size; i++) + v[i] = x[i]; + } - void insert(T el) { - this->insert(cur_size, el); - } + void insert(T el) { + this->insert(cur_size, el); + } - void remove(int pos) { - if(pos > size - 1) - return; + void remove(int pos) { + if(pos > size - 1) + return; - T* newv = (T*)malloc(sizeof(T) * (size - 1)); + T* newv = (T*)malloc(sizeof(T) * (size - 1)); - int j = 0; + int j = 0; - for(int i = 0; i < size; i++) { - if(i != pos) { - newv[j] = v[i]; - j++; + for(int i = 0; i < size; i++) { + if(i != pos) { + newv[j] = v[i]; + j++; + } } - } - - free(v); - v = newv; - cur_size--; - size--; - } - void insert(int pos, T el) { - if(pos > size - 1) { - T* newv = (T*)malloc(sizeof(T) * (pos + 1)); - newv[pos] = el; - for(int i = 0; i < size; i++) - newv[i] = v[i]; free(v); - size = pos + 1; v = newv; - } else { - v[pos] = el; + cur_size--; + size--; } - cur_size++; - } - T get(int pos) { - return v[pos]; - } + void insert(int pos, T el) { + if(pos > size - 1) { + T* newv = (T*)malloc(sizeof(T) * (pos + 1)); + newv[pos] = el; + for(int i = 0; i < size; i++) + newv[i] = v[i]; + free(v); + size = pos + 1; + v = newv; + } else { + v[pos] = el; + } + cur_size++; + } + + T get(int pos) { + return v[pos]; + } - T& operator[] ( int pos ) { - return v[pos]; - } + T& operator[] ( int pos ) { + return v[pos]; + } - int getSize() { - return this->size; - } + int getSize() { + return this->size; + } - int getLastIndex() { - return (this->cur_size - 1); - } + int getLastIndex() { + return (this->cur_size - 1); + } - ~SlimArray() { - free(v); - } + ~SlimArray() { + free(v); + } -}; + }; +} #endif diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 33e7654..7157e85 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -1,10 +1,9 @@ #include #include #include "StepperClass.h" -#include "MethodDescriptor.h" #include -void StepperClass::elaborate( MethodDescriptor* m ) { +void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Stepper") == 0) { ObjectsManager::elaborate(m); diff --git a/firmware/StepperClass.h b/firmware/StepperClass.h index cb75329..bf0382f 100644 --- a/firmware/StepperClass.h +++ b/firmware/StepperClass.h @@ -2,15 +2,17 @@ #define STEPPER_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" class Stepper; -class MethodDescriptor; -class StepperClass: public ObjectsManager { +namespace nanpy { + class StepperClass: public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); -}; + }; +} #endif diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 966a2fd..578186b 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -1,9 +1,8 @@ #include #include "ToneClass.h" -#include "MethodDescriptor.h" #include -void ToneClass::elaborate( MethodDescriptor* m ) { +void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Tone") == 0) { ObjectsManager::elaborate(m); diff --git a/firmware/ToneClass.h b/firmware/ToneClass.h index cc295a6..4e06cb7 100644 --- a/firmware/ToneClass.h +++ b/firmware/ToneClass.h @@ -2,6 +2,7 @@ #define TONE_CLASS #include "BaseClass.h" +#include "MethodDescriptor.h" #define NOTE_B0 31 #define NOTE_C1 33 @@ -93,31 +94,32 @@ #define NOTE_D8 4699 #define NOTE_DS8 4978 -class MethodDescriptor; +namespace nanpy { -class Tone { + class Tone { - private: + private: - int pin; + int pin; - public: + public: - Tone(int pin) : pin(pin) {} - void play(int note, int duration) { - tone(pin, note, duration); - delay(duration * 1.30); - noTone(pin); - } - void stop(void) {noTone(pin);} + Tone(int pin) : pin(pin) {} + void play(int note, int duration) { + tone(pin, note, duration); + delay(duration * 1.30); + noTone(pin); + } + void stop(void) {noTone(pin);} -}; + }; -class ToneClass: public ObjectsManager { + class ToneClass: public ObjectsManager { - public: - void elaborate( MethodDescriptor* m ); + public: + void elaborate( nanpy::MethodDescriptor* m ); -}; + }; +} #endif From 92c8d9ab6d29b2a823c89450f23e6cb228b6b8f9 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 13 Feb 2013 13:02:51 +0100 Subject: [PATCH 099/344] Example using EEPROM added --- examples/eepromtest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 examples/eepromtest.py diff --git a/examples/eepromtest.py b/examples/eepromtest.py new file mode 100755 index 0000000..4a0602d --- /dev/null +++ b/examples/eepromtest.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: write and read from EEPROM +# Dependencies: None + +from nanpy import EEPROM + +print("Write 33 on the EEPROM at address 100") +EEPROM.write(100, 33) +print("The value at address 100 is %d" % EEPROM.read(100)) + From db99ed8a54cd987ccad93af2453394c25b01bd65 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Thu, 14 Feb 2013 04:12:14 +0100 Subject: [PATCH 100/344] README and LICENSE updated --- LICENSE | 2 +- README.md | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/LICENSE b/LICENSE index 45abc36..40bed8b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012 Andrea Stagi +Copyright (c) 2012-2013 Andrea Stagi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b7efca9..77bd10c 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,7 @@ Dependencies How to build and install ------------------------ -Nanpy is composed by a Python part, that provides a library to use Arduino via Python and a server firmware. You can install Nanpy on a Raspberry too :) - -To install Nanpy just type (as root, requires python-setuptools): - - python setup.py install - -To build the firmware type: +You need to build the firmware for your Arduino first, you can find it in the firmware directory: cd firmware export BOARD=uno (in case you use UNO board. Type 'make boards' for a complete list) @@ -65,6 +59,10 @@ and then upload it on your board: make upload +To install Nanpy just type (as root): + + python setup.py install + How to use ---------- @@ -91,9 +89,9 @@ Nanpy needs a lot of work to be a great instrument. You can contribute with patc Donate ------ -Do you want to buy us a coffee? We need it to code all night long! if you like this project and you want to support it with some cents, please donate :) https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J +Do you want to support us with a coffee? We need it to code all night long! if you like this project and you want to support it with some cents, please donate :) https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J License ------- -This software is released under MIT License. Copyright (c) 2012 Andrea Stagi +This software is released under MIT License. Copyright (c) 2012-2013 Andrea Stagi From 101522b56ef889450b0a284387b4e280569ae261 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 19 Feb 2013 12:15:55 +0100 Subject: [PATCH 101/344] Minfix on delay --- nanpy/arduino.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 7a3c91c..4b9ca51 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -38,7 +38,7 @@ def pinMode(cls, pin, mode): @classmethod def delay(cls, value): - time.sleep(value/1000) + time.sleep(float(value)/1000) @classmethod def map(cls, x, in_min, in_max, out_min, out_max): From 091a131467990c8b82912a1654f9b64fa4f0bc83 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 19 Feb 2013 12:22:31 +0100 Subject: [PATCH 102/344] New eeprom example by Kevin Ng --- examples/eepromread.py | 28 ++++++++++++++++++++++++++++ examples/eepromtest.py | 12 ------------ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100755 examples/eepromread.py delete mode 100755 examples/eepromtest.py diff --git a/examples/eepromread.py b/examples/eepromread.py new file mode 100755 index 0000000..df89f8d --- /dev/null +++ b/examples/eepromread.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Author: Kevin Ng +# Description: read from EEPROM +# Dependencies: None + +from nanpy import EEPROM +import sys + +EEPROM_SIZE = 1024//4 #only read first 256 bytes + + +def display(a_list): + for i in range(0, EEPROM_SIZE//16-1): + for j in range(0, 15): + sys.stdout.write( "%x : " % a_list[j+i*16]) + print + +def read_eeprom(): + data_list = [] + for i in range(0, EEPROM_SIZE): + s = EEPROM.read(i) + data_list.append(s) + return data_list + +if __name__ == "__main__": + print("Reading first 256 bytes of eeprom...") + display(read_eeprom()) diff --git a/examples/eepromtest.py b/examples/eepromtest.py deleted file mode 100755 index 4a0602d..0000000 --- a/examples/eepromtest.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: write and read from EEPROM -# Dependencies: None - -from nanpy import EEPROM - -print("Write 33 on the EEPROM at address 100") -EEPROM.write(100, 33) -print("The value at address 100 is %d" % EEPROM.read(100)) - From 5a40f5f4ac704e98e5519b928aeaa85d7767052b Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 19 Feb 2013 12:28:22 +0100 Subject: [PATCH 103/344] Added Kevin Ng to contributors --- THANKS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/THANKS b/THANKS index 85ab147..0d1526f 100644 --- a/THANKS +++ b/THANKS @@ -1,3 +1,7 @@ +BUGFIXING +--------- +- Kevin Ng (kevin.ngkf@gmail.com) + PACKAGERS --------- - Andrea Grandi (@andreagrandi) - Ubuntu packager From 8af550b693a1a021306d7d68f2ea004ffe1788a2 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 19 Feb 2013 12:31:15 +0100 Subject: [PATCH 104/344] Bumped to version 0.8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 04db14f..ef69c88 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.7", + version="0.8", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From c5c26e41b1db678dcacf2b5b10d7084b71f11b87 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 1 Dec 2013 10:03:13 +0100 Subject: [PATCH 105/344] git ignore hidden files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index afa176d..ff6f2d4 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ nanpy.egg-info/ #Python *.pyc +#hidden files +.* +!.gitignore From 0349ab1465e49c595e4b4b5c7e633b86a13fa0c2 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 8 Dec 2013 16:11:38 +0100 Subject: [PATCH 106/344] make it gcc 4.3.2 compatible --- firmware/CapacitiveSensorClass.cpp | 2 +- firmware/DallasTemperatureClass.cpp | 2 +- firmware/LiquidCrystalClass.cpp | 2 +- firmware/OneWireClass.cpp | 2 +- firmware/ServoClass.cpp | 2 +- firmware/StepperClass.cpp | 2 +- firmware/ToneClass.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/CapacitiveSensorClass.cpp b/firmware/CapacitiveSensorClass.cpp index bcd66b6..ee758d1 100644 --- a/firmware/CapacitiveSensorClass.cpp +++ b/firmware/CapacitiveSensorClass.cpp @@ -5,7 +5,7 @@ void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "CapacitiveSensor") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { v.insert(new CapacitiveSensor(m->getInt(0), m->getInt(1))); diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 8b15e56..0e11977 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -8,7 +8,7 @@ void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "DallasTemperature") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { int prm = 0; diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 30c8406..f30c871 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -7,7 +7,7 @@ void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Lcd") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { int prm = 0; diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index 3f7bf8c..37bf799 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -6,7 +6,7 @@ void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "OneWire") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { v.insert(new OneWire(m->getInt(0))); diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index 28d2a95..2bcb788 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -6,7 +6,7 @@ void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Servo") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { v.insert(new Servo()); diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 7157e85..1266bed 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -6,7 +6,7 @@ void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Stepper") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { int prm = 0; diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 578186b..1ff7dd9 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -5,7 +5,7 @@ void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Tone") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { v.insert(new Tone (m->getInt(0))); From 52af93b1158134afcdb1401c954ebe266076f779 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 8 Dec 2013 16:15:30 +0100 Subject: [PATCH 107/344] put all includes in .ino file, so the gui can compile it --- firmware/Nanpy.ino | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 7893486..88e4c66 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,3 +1,11 @@ +#include +#include +#include +#include +#include +#include +#include + #include "BaseClass.h" #include "ArduinoClass.h" #include "OneWireClass.h" @@ -17,7 +25,7 @@ MethodDescriptor *m = NULL; void setup() { - REGISTER_CLASS(EEPROMClass); + REGISTER_CLASS(nanpy::EEPROMClass); REGISTER_CLASS(ArduinoClass); REGISTER_CLASS(LiquidCrystalClass); REGISTER_CLASS(OneWireClass); From 7cc05734b0d13ae87069bbe4f7810391e0203029 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 8 Dec 2013 16:11:38 +0100 Subject: [PATCH 108/344] make it gcc 4.3.2 compatible --- firmware/CapacitiveSensorClass.cpp | 2 +- firmware/DallasTemperatureClass.cpp | 2 +- firmware/LiquidCrystalClass.cpp | 2 +- firmware/OneWireClass.cpp | 2 +- firmware/ServoClass.cpp | 2 +- firmware/StepperClass.cpp | 2 +- firmware/ToneClass.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware/CapacitiveSensorClass.cpp b/firmware/CapacitiveSensorClass.cpp index bcd66b6..ee758d1 100644 --- a/firmware/CapacitiveSensorClass.cpp +++ b/firmware/CapacitiveSensorClass.cpp @@ -5,7 +5,7 @@ void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "CapacitiveSensor") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { v.insert(new CapacitiveSensor(m->getInt(0), m->getInt(1))); diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/DallasTemperatureClass.cpp index 8b15e56..0e11977 100644 --- a/firmware/DallasTemperatureClass.cpp +++ b/firmware/DallasTemperatureClass.cpp @@ -8,7 +8,7 @@ void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "DallasTemperature") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { int prm = 0; diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/LiquidCrystalClass.cpp index 30c8406..f30c871 100644 --- a/firmware/LiquidCrystalClass.cpp +++ b/firmware/LiquidCrystalClass.cpp @@ -7,7 +7,7 @@ void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Lcd") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { int prm = 0; diff --git a/firmware/OneWireClass.cpp b/firmware/OneWireClass.cpp index 3f7bf8c..37bf799 100644 --- a/firmware/OneWireClass.cpp +++ b/firmware/OneWireClass.cpp @@ -6,7 +6,7 @@ void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "OneWire") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { v.insert(new OneWire(m->getInt(0))); diff --git a/firmware/ServoClass.cpp b/firmware/ServoClass.cpp index 28d2a95..2bcb788 100644 --- a/firmware/ServoClass.cpp +++ b/firmware/ServoClass.cpp @@ -6,7 +6,7 @@ void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Servo") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { v.insert(new Servo()); diff --git a/firmware/StepperClass.cpp b/firmware/StepperClass.cpp index 7157e85..1266bed 100644 --- a/firmware/StepperClass.cpp +++ b/firmware/StepperClass.cpp @@ -6,7 +6,7 @@ void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getClass(), "Stepper") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { int prm = 0; diff --git a/firmware/ToneClass.cpp b/firmware/ToneClass.cpp index 578186b..1ff7dd9 100644 --- a/firmware/ToneClass.cpp +++ b/firmware/ToneClass.cpp @@ -5,7 +5,7 @@ void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Tone") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { v.insert(new Tone (m->getInt(0))); From ec518c666c0e9317f6cc8e848c5400da19842acd Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 8 Dec 2013 16:15:30 +0100 Subject: [PATCH 109/344] put all includes in .ino file, so the gui can compile it --- firmware/Nanpy.ino | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/Nanpy.ino b/firmware/Nanpy.ino index 7893486..88e4c66 100644 --- a/firmware/Nanpy.ino +++ b/firmware/Nanpy.ino @@ -1,3 +1,11 @@ +#include +#include +#include +#include +#include +#include +#include + #include "BaseClass.h" #include "ArduinoClass.h" #include "OneWireClass.h" @@ -17,7 +25,7 @@ MethodDescriptor *m = NULL; void setup() { - REGISTER_CLASS(EEPROMClass); + REGISTER_CLASS(nanpy::EEPROMClass); REGISTER_CLASS(ArduinoClass); REGISTER_CLASS(LiquidCrystalClass); REGISTER_CLASS(OneWireClass); From 7f77cb6c3b60c33ba8394e590ce78059c8ed3262 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 8 Dec 2013 16:51:58 +0100 Subject: [PATCH 110/344] new method: pinModeRead() --- firmware/ArduinoClass.cpp | 14 ++++++++++++++ nanpy/arduino.py | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/firmware/ArduinoClass.cpp b/firmware/ArduinoClass.cpp index ad45e43..10ef0a7 100644 --- a/firmware/ArduinoClass.cpp +++ b/firmware/ArduinoClass.cpp @@ -2,6 +2,16 @@ #include "ArduinoClass.h" #include + +byte pinModeRead(int pin) +{ + byte bitmask = digitalPinToBitMask(pin); + word port = digitalPinToPort(pin); + byte reg = *portModeRegister(port); + byte mode = (reg & bitmask) ? 1 : 0; + return mode; +} + void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Arduino") == 0) { if (strcmp(m->getName(), "digitalWrite") == 0) { @@ -27,6 +37,10 @@ void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { m->returns(0); } + if (strcmp(m->getName(), "pinModeRead") == 0) { + m->returns(pinModeRead(m->getInt(0))); + } + if (strcmp(m->getName(), "delay") == 0) { m->returns(0); } diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 4b9ca51..dd073b7 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -36,6 +36,11 @@ def analogRead(cls, pin): def pinMode(cls, pin, mode): pass + @classmethod + @arduinoclassmethod + def pinModeRead(cls, pin): + pass + @classmethod def delay(cls, value): time.sleep(float(value)/1000) From 29594c8c4ba7c6b7c2f4b095692825d1309ca881 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Thu, 12 Dec 2013 19:18:16 +0100 Subject: [PATCH 111/344] Ignore mac files, updated makefile --- .gitignore | 1 + firmware/arduino.mk | 215 ++++++++++++++++++++++++++------------------ 2 files changed, 128 insertions(+), 88 deletions(-) diff --git a/.gitignore b/.gitignore index afa176d..7c6939e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ #General +.DS_Store *~ *.swp build/ diff --git a/firmware/arduino.mk b/firmware/arduino.mk index ad502a7..3028d5d 100644 --- a/firmware/arduino.mk +++ b/firmware/arduino.mk @@ -2,9 +2,9 @@ # # edam's Arduino makefile #_______________________________________________________________________________ -# version 0.5dev +# version 0.5 # -# Copyright (C) 2011, 2012 Tim Marston . +# Copyright (C) 2011, 2012, 2013 Tim Marston . # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -28,38 +28,38 @@ # # # This is a general purpose makefile for use with Arduino hardware and -# software. It works with the arduino-1.0 software release. To download the -# latest version of this makefile, visit the following website, where you can -# also find more information and documentation on it's use. The following text -# can only really be considered a reference to it's use. +# software. It works with the arduino-1.0 and later software releases. It +# should work GNU/Linux and OS X. To download the latest version of this +# makefile visit the following website where you can also find documentation on +# it's use. (The following text can only really be considered a reference.) # # http://ed.am/dev/make/arduino-mk # # This makefile can be used as a drop-in replacement for the Arduino IDE's -# build system. To use it, save arduino.mk somewhere (I keep mine at -# ~/src/arduino.mk) and create a symlink to it in your project directory named -# "Makefile". For example: +# build system. To use it, just copy arduino.mk in to your project directory. +# Or, you could save it somewhere (I keep mine at ~/src/arduino.mk) and create +# a symlink to it in your project directory, named "Makefile". For example: # # $ ln -s ~/src/arduino.mk Makefile # -# The Arduino software (version 1.0 or later) is required. If you are using -# Debian (or a derivative), type `apt-get install arduino`. Otherwise, you -# will have to download the Arduino software manually from http://arduino.cc/. -# It is suggested that you install it at ~/opt/arduino if you are unsure. +# The Arduino software (version 1.0 or later) is required. On GNU/Linux you +# can probably install the software from your package manager. If you are +# using Debian (or a derivative), try `apt-get install arduino`. Otherwise, +# you can download the Arduino software manually from http://arduino.cc/. It +# is suggested that you install it at ~/opt/arduino (or /Applications on OS X) +# if you are unsure. # # If you downloaded the Arduino software manually and unpacked it somewhere -# other than ~/opt/arduino, you will need to set up ARDUINODIR to be the path -# where you unpacked it. (If unset, ARDUINODIR defaults to ~/opt/arduino and -# then /usr/share/arduino, in that order.) You might be best to set this in +# other than ~/opt/arduino (or /Applications), you will need to set up the +# ARDUINODIR environment variable to be the path where you unpacked it. (If +# unset, ARDUINODIR defaults to some sensible places). You could set this in # your ~/.profile by adding something like this: # # export ARDUINODIR=~/somewhere/arduino-1.0 # -# You will also need to set BOARD to the type of Arduino you're building for. -# Type `make boards` for a list of acceptable values. You could set a default -# in your ~/.profile if you want, but it is suggested that you specify this at -# build time, especially if you work with different types of Arduino. For -# example: +# For each project, you will also need to set BOARD to the type of Arduino +# you're building for. Type `make boards` for a list of acceptable values. +# For example: # # $ export BOARD=uno # $ make @@ -70,14 +70,18 @@ # determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp # files in the project directory (or any "util" or "utility" subdirectories) # are automatically included in the build and are scanned for Arduino libraries -# that have been #included. Note, there can only be one .ino (or .pde) file. +# that have been #included. Note, there can only be one .ino (or .pde) file in +# a project directory and if you want to be compatible with the Arduino IDE, it +# should be called the same as the directory name. # # Alternatively, if you want to manually specify build variables, create a # Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. -# (There is no need to define TARGET). Here is an example Makefile: +# (There is no need to define TARGET). You can also specify the BOARD here, if +# the project has a specific one. Here is an example Makefile: # # SOURCES := main.cc other.cc # LIBRARIES := EEPROM +# BOARD := pro5v # include ~/src/arduino.mk # # Here is a complete list of configuration parameters: @@ -88,8 +92,8 @@ # ARDUINO version constant. This defaults to 100 if undefined. # # AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess -# based on where the avrdude in use is. If empty, no avrdude.conf -# is passed to avrdude (to the system default is used). +# based on where avrdude is. If set empty, no avrdude.conf is +# passed to avrdude (so the system default is used). # # AVRDUDEFLAGS Specify any additional flags for avrdude. The usual flags, # required to build the project, will be appended to this. @@ -112,11 +116,12 @@ # # LIBRARYPATH A space-separated list of directories that is searched in order # when looking for Arduino libraries. This defaults to "libs", -# "libraries" and then the Arduino software's libraries directory. +# "libraries" (in the project directory), then your sketchbook +# "libraries" directory, then the Arduino libraries directory. # -# SERIALDEV The unix device name of the serial device that is the Arduino. -# If unspecified, an attempt is made to determine the name of a -# connected Arduino's serial device. +# SERIALDEV The POSIX device name of the serial device that is the Arduino. +# If unspecified, an attempt is made to guess the name of a +# connected Arduino's serial device, which may work in some cases. # # SOURCES A list of all source files of whatever language. The language # type is determined by the file extension. This is set @@ -134,7 +139,8 @@ # # target Builds the target. # -# upload Uploads the last built target to an attached Arduino. +# upload Uploads the target (building it, as necessary) to an attached +# Arduino. # # clean Deletes files created during the build. # @@ -144,7 +150,9 @@ # monitor Start `screen` on the serial device. This is meant to be an # equivalent to the Arduino serial monitor. # -# size Displays size information about the bulit target. +# size Displays size information about the built target. +# +# bootloader Burns the bootloader for your board to it. # # Builds the specified file, either an object file or the target, # from those that that would be built for the project. @@ -153,19 +161,14 @@ # default arduino software directory, check software exists ifndef ARDUINODIR -ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino)) +ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino \ + /Applications/Arduino.app/Contents/Resources/Java \ + $(HOME)/Applications/Arduino.app/Contents/Resources/Java)) endif ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" $(error ARDUINODIR is not set correctly; arduino software not found) endif -# obtain preferences from the IDE's preferences.txt -PREFERENCES_FILE := $(wildcard $(HOME)/.arduino/preferences.txt) -ifneq "$(PREFERENCES_FILE)" "" -SKETCHBOOKDIR := \ - $(shell sed -ne "s/sketchbook.path=\(.*\)/\1/p" $(PREFERENCES_FILE)) -endif - # default arduino version ARDUINOCONST ?= 100 @@ -176,6 +179,58 @@ AVRTOOLSPATH ?= $(subst :, , $(PATH)) $(ARDUINODIR)/hardware/tools \ # default path to find libraries LIBRARYPATH ?= libraries libs $(SKETCHBOOKDIR)/libraries $(ARDUINODIR)/libraries +# default serial device to a poor guess (something that might be an arduino) +SERIALDEVGUESS := 0 +ifndef SERIALDEV +SERIALDEV := $(firstword $(wildcard \ + /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) +SERIALDEVGUESS := 1 +endif + +# no board? +ifndef BOARD +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is unset. Type 'make boards' to see possible values) +endif +endif +endif + +# obtain board parameters from the arduino boards.txt file +BOARDSFILE := $(ARDUINODIR)/hardware/arduino/boards.txt +readboardsparam = $(shell sed -ne "s/$(BOARD).$(1)=\(.*\)/\1/p" $(BOARDSFILE)) +BOARD_BUILD_MCU := $(call readboardsparam,build.mcu) +BOARD_BUILD_FCPU := $(call readboardsparam,build.f_cpu) +BOARD_BUILD_VARIANT := $(call readboardsparam,build.variant) +BOARD_UPLOAD_SPEED := $(call readboardsparam,upload.speed) +BOARD_UPLOAD_PROTOCOL := $(call readboardsparam,upload.protocol) +BOARD_USB_VID := $(call readboardsparam,build.vid) +BOARD_USB_PID := $(call readboardsparam,build.pid) +BOARD_BOOTLOADER_UNLOCK := $(call readboardsparam,bootloader.unlock_bits) +BOARD_BOOTLOADER_LOCK := $(call readboardsparam,bootloader.lock_bits) +BOARD_BOOTLOADER_LFUSES := $(call readboardsparam,bootloader.low_fuses) +BOARD_BOOTLOADER_HFUSES := $(call readboardsparam,bootloader.high_fuses) +BOARD_BOOTLOADER_EFUSES := $(call readboardsparam,bootloader.extended_fuses) +BOARD_BOOTLOADER_PATH := $(call readboardsparam,bootloader.path) +BOARD_BOOTLOADER_FILE := $(call readboardsparam,bootloader.file) + +# obtain preferences from the IDE's preferences.txt +PREFERENCESFILE := $(firstword $(wildcard \ + $(HOME)/.arduino/preferences.txt $(HOME)/Library/Arduino/preferences.txt)) +ifneq "$(PREFERENCESFILE)" "" +readpreferencesparam = $(shell sed -ne "s/$(1)=\(.*\)/\1/p" $(PREFERENCESFILE)) +SKETCHBOOKDIR := $(call readpreferencesparam,sketchbook.path) +endif + +# invalid board? +ifeq "$(BOARD_BUILD_MCU)" "" +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is invalid. Type 'make boards' to see possible values) +endif +endif +endif + # auto mode? INOFILE := $(wildcard *.ino *.pde) ifdef INOFILE @@ -196,14 +251,6 @@ LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \ endif -# no serial device? make a poor attempt to detect an arduino -SERIALDEVGUESS := 0 -ifeq "$(SERIALDEV)" "" -SERIALDEV := $(firstword $(wildcard \ - /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) -SERIALDEVGUESS := 1 -endif - # software findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) CC := $(call findsoftware,avr-gcc) @@ -227,6 +274,9 @@ DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) ARDUINOLIB := .lib/arduino.a ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \ $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) +BOOTLOADERHEX := $(addprefix \ + $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \ + $(BOARD_BOOTLOADER_FILE)) # avrdude confifuration ifeq "$(AVRDUDECONF)" "" @@ -237,43 +287,6 @@ AVRDUDECONF := $(wildcard $(AVRDUDE).conf) endif endif -# no board? -ifndef BOARD -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is unset. Type 'make boards' to see possible values) -endif -endif -endif - -# obtain board parameters from the arduino boards.txt file -BOARDS_FILE := $(ARDUINODIR)/hardware/arduino/boards.txt -BOARD_BUILD_MCU := \ - $(shell sed -ne "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_BUILD_FCPU := \ - $(shell sed -ne "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_BUILD_VARIANT := \ - $(shell sed -ne "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_UPLOAD_SPEED := \ - $(shell sed -ne "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_UPLOAD_PROTOCOL := \ - $(shell sed -ne "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_USB_VID := \ - $(shell sed -ne "s/$(BOARD).build.vid=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_USB_PID := \ - $(shell sed -ne "s/$(BOARD).build.pid=\(.*\)/\1/p" $(BOARDS_FILE)) -BOARD_BOOTLOADER_PATH := \ - $(shell sed -ne "s/$(BOARD).bootloader.path=\(.*\)/\1/p" $(BOARDS_FILE)) - -# invalid board? -ifeq "$(BOARD_BUILD_MCU)" "" -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is invalid. Type 'make boards' to see possible values) -endif -endif -endif - # flags CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums @@ -305,7 +318,7 @@ endif #_______________________________________________________________________________ # RULES -.PHONY: all target upload clean boards monitor size +.PHONY: all target upload clean boards monitor size bootloader all: target @@ -322,8 +335,9 @@ upload: target ifeq "$(BOARD_BOOTLOADER_PATH)" "caterina" stty $(STTYFARG) $(SERIALDEV) speed 1200 sleep 1 -endif +else stty $(STTYFARG) $(SERIALDEV) hupcl +endif $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i clean: @@ -332,8 +346,8 @@ clean: rm -rf .lib .dep boards: - @echo Available values for BOARD: - @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDS_FILE) | \ + @echo "Available values for BOARD:" + @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDSFILE) | \ sed -Ee 's/([^.]+)\.name=(.*)/\1 \2/' \ -e 's/(.{12}) *(.*)/\1 \2/' @@ -352,6 +366,26 @@ monitor: size: $(TARGET).elf echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf +bootloader: + @echo "Burning bootloader to board..." + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + stty $(STTYFARG) $(SERIALDEV) hupcl + $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m + $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m + $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m +ifneq "$(BOARD_BOOTLOADER_EFUSES)" "" + $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m +endif +ifneq "$(BOOTLOADERHEX)" "" + $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i +endif + $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m + # building the target $(TARGET).hex: $(TARGET).elf @@ -406,3 +440,8 @@ $(ARDUINOLIB): $(ARDUINOLIBOBJS) .lib/%.C.o: %.C mkdir -p $(dir $@) $(COMPILE.cpp) -o $@ $< + +# Local Variables: +# mode: makefile +# tab-width: 4 +# End: \ No newline at end of file From 4aa2f89d8b1fe9664e1c3ec93655b69bdb6748d0 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Thu, 12 Dec 2013 19:33:24 +0100 Subject: [PATCH 112/344] Added contributors --- THANKS | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/THANKS b/THANKS index 0d1526f..5ccfb5c 100644 --- a/THANKS +++ b/THANKS @@ -1,11 +1,10 @@ -BUGFIXING ---------- +Contributors +------------ - Kevin Ng (kevin.ngkf@gmail.com) +- Ponty (khttps://github.com/ponty) +- Andrea Grandi (https://github.com/andreagrandi) +- Tim Marston (tim@ed.am) -PACKAGERS ---------- -- Andrea Grandi (@andreagrandi) - Ubuntu packager - -TESTERS +Testers ------- -- Fernando Molina (@F_M_A) - Leonardo boards +- Fernando Molina (twitter @F_M_A) - Leonardo boards From 0229c0187360b0292ed819cee4964e3bf606e09d Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 15 Dec 2013 08:31:50 +0100 Subject: [PATCH 113/344] put firmware code under "Nanpy" directory for GUI compatibility --- firmware/{ => Nanpy}/ArduinoClass.cpp | 0 firmware/{ => Nanpy}/ArduinoClass.h | 0 firmware/{ => Nanpy}/BaseClass.h | 0 firmware/{ => Nanpy}/CapacitiveSensorClass.cpp | 0 firmware/{ => Nanpy}/CapacitiveSensorClass.h | 0 firmware/{ => Nanpy}/ComChannel.cpp | 0 firmware/{ => Nanpy}/ComChannel.h | 0 firmware/{ => Nanpy}/DallasTemperatureClass.cpp | 0 firmware/{ => Nanpy}/DallasTemperatureClass.h | 0 firmware/{ => Nanpy}/EEPROMClass.cpp | 0 firmware/{ => Nanpy}/EEPROMClass.h | 0 firmware/{ => Nanpy}/LiquidCrystalClass.cpp | 0 firmware/{ => Nanpy}/LiquidCrystalClass.h | 0 firmware/{ => Nanpy}/Makefile | 0 firmware/{ => Nanpy}/MethodDescriptor.cpp | 0 firmware/{ => Nanpy}/MethodDescriptor.h | 0 firmware/{ => Nanpy}/Nanpy.ino | 0 firmware/{ => Nanpy}/OneWireClass.cpp | 0 firmware/{ => Nanpy}/OneWireClass.h | 0 firmware/{ => Nanpy}/ServoClass.cpp | 0 firmware/{ => Nanpy}/ServoClass.h | 0 firmware/{ => Nanpy}/SlimArray.h | 0 firmware/{ => Nanpy}/StepperClass.cpp | 0 firmware/{ => Nanpy}/StepperClass.h | 0 firmware/{ => Nanpy}/ToneClass.cpp | 0 firmware/{ => Nanpy}/ToneClass.h | 0 firmware/{ => Nanpy}/arduino.mk | 0 .../{ => Nanpy}/libraries/CapacitiveSensor/CapacitiveSensor.cpp | 0 .../{ => Nanpy}/libraries/CapacitiveSensor/CapacitiveSensor.h | 0 firmware/{ => Nanpy}/libraries/CapacitiveSensor/README.md | 0 .../examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde | 0 firmware/{ => Nanpy}/libraries/CapacitiveSensor/keywords.txt | 0 .../{ => Nanpy}/libraries/DallasTemperature/DallasTemperature.cpp | 0 .../{ => Nanpy}/libraries/DallasTemperature/DallasTemperature.h | 0 firmware/{ => Nanpy}/libraries/DallasTemperature/README.TXT | 0 firmware/{ => Nanpy}/libraries/DallasTemperature/change.txt | 0 .../libraries/DallasTemperature/examples/Alarm/Alarm.pde | 0 .../DallasTemperature/examples/AlarmHandler/AlarmHandler.pde | 0 .../libraries/DallasTemperature/examples/Multiple/Multiple.pde | 0 .../libraries/DallasTemperature/examples/Simple/Simple.pde | 0 .../libraries/DallasTemperature/examples/Single/Single.pde | 0 .../libraries/DallasTemperature/examples/Tester/Tester.pde | 0 .../examples/WaitForConversion/WaitForConversion.pde | 0 .../examples/WaitForConversion2/WaitForConversion2.pde | 0 firmware/{ => Nanpy}/libraries/DallasTemperature/keywords.txt | 0 firmware/{ => Nanpy}/libraries/OneWire/OneWire.cpp | 0 firmware/{ => Nanpy}/libraries/OneWire/OneWire.h | 0 .../OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde | 0 .../libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde | 0 .../libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde | 0 firmware/{ => Nanpy}/libraries/OneWire/keywords.txt | 0 51 files changed, 0 insertions(+), 0 deletions(-) rename firmware/{ => Nanpy}/ArduinoClass.cpp (100%) rename firmware/{ => Nanpy}/ArduinoClass.h (100%) rename firmware/{ => Nanpy}/BaseClass.h (100%) rename firmware/{ => Nanpy}/CapacitiveSensorClass.cpp (100%) rename firmware/{ => Nanpy}/CapacitiveSensorClass.h (100%) rename firmware/{ => Nanpy}/ComChannel.cpp (100%) rename firmware/{ => Nanpy}/ComChannel.h (100%) rename firmware/{ => Nanpy}/DallasTemperatureClass.cpp (100%) rename firmware/{ => Nanpy}/DallasTemperatureClass.h (100%) rename firmware/{ => Nanpy}/EEPROMClass.cpp (100%) rename firmware/{ => Nanpy}/EEPROMClass.h (100%) rename firmware/{ => Nanpy}/LiquidCrystalClass.cpp (100%) rename firmware/{ => Nanpy}/LiquidCrystalClass.h (100%) rename firmware/{ => Nanpy}/Makefile (100%) rename firmware/{ => Nanpy}/MethodDescriptor.cpp (100%) rename firmware/{ => Nanpy}/MethodDescriptor.h (100%) rename firmware/{ => Nanpy}/Nanpy.ino (100%) rename firmware/{ => Nanpy}/OneWireClass.cpp (100%) rename firmware/{ => Nanpy}/OneWireClass.h (100%) rename firmware/{ => Nanpy}/ServoClass.cpp (100%) rename firmware/{ => Nanpy}/ServoClass.h (100%) rename firmware/{ => Nanpy}/SlimArray.h (100%) rename firmware/{ => Nanpy}/StepperClass.cpp (100%) rename firmware/{ => Nanpy}/StepperClass.h (100%) rename firmware/{ => Nanpy}/ToneClass.cpp (100%) rename firmware/{ => Nanpy}/ToneClass.h (100%) rename firmware/{ => Nanpy}/arduino.mk (100%) rename firmware/{ => Nanpy}/libraries/CapacitiveSensor/CapacitiveSensor.cpp (100%) rename firmware/{ => Nanpy}/libraries/CapacitiveSensor/CapacitiveSensor.h (100%) rename firmware/{ => Nanpy}/libraries/CapacitiveSensor/README.md (100%) rename firmware/{ => Nanpy}/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde (100%) rename firmware/{ => Nanpy}/libraries/CapacitiveSensor/keywords.txt (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/DallasTemperature.cpp (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/DallasTemperature.h (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/README.TXT (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/change.txt (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/Alarm/Alarm.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/Multiple/Multiple.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/Simple/Simple.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/Single/Single.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/Tester/Tester.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde (100%) rename firmware/{ => Nanpy}/libraries/DallasTemperature/keywords.txt (100%) rename firmware/{ => Nanpy}/libraries/OneWire/OneWire.cpp (100%) rename firmware/{ => Nanpy}/libraries/OneWire/OneWire.h (100%) rename firmware/{ => Nanpy}/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde (100%) rename firmware/{ => Nanpy}/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde (100%) rename firmware/{ => Nanpy}/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde (100%) rename firmware/{ => Nanpy}/libraries/OneWire/keywords.txt (100%) diff --git a/firmware/ArduinoClass.cpp b/firmware/Nanpy/ArduinoClass.cpp similarity index 100% rename from firmware/ArduinoClass.cpp rename to firmware/Nanpy/ArduinoClass.cpp diff --git a/firmware/ArduinoClass.h b/firmware/Nanpy/ArduinoClass.h similarity index 100% rename from firmware/ArduinoClass.h rename to firmware/Nanpy/ArduinoClass.h diff --git a/firmware/BaseClass.h b/firmware/Nanpy/BaseClass.h similarity index 100% rename from firmware/BaseClass.h rename to firmware/Nanpy/BaseClass.h diff --git a/firmware/CapacitiveSensorClass.cpp b/firmware/Nanpy/CapacitiveSensorClass.cpp similarity index 100% rename from firmware/CapacitiveSensorClass.cpp rename to firmware/Nanpy/CapacitiveSensorClass.cpp diff --git a/firmware/CapacitiveSensorClass.h b/firmware/Nanpy/CapacitiveSensorClass.h similarity index 100% rename from firmware/CapacitiveSensorClass.h rename to firmware/Nanpy/CapacitiveSensorClass.h diff --git a/firmware/ComChannel.cpp b/firmware/Nanpy/ComChannel.cpp similarity index 100% rename from firmware/ComChannel.cpp rename to firmware/Nanpy/ComChannel.cpp diff --git a/firmware/ComChannel.h b/firmware/Nanpy/ComChannel.h similarity index 100% rename from firmware/ComChannel.h rename to firmware/Nanpy/ComChannel.h diff --git a/firmware/DallasTemperatureClass.cpp b/firmware/Nanpy/DallasTemperatureClass.cpp similarity index 100% rename from firmware/DallasTemperatureClass.cpp rename to firmware/Nanpy/DallasTemperatureClass.cpp diff --git a/firmware/DallasTemperatureClass.h b/firmware/Nanpy/DallasTemperatureClass.h similarity index 100% rename from firmware/DallasTemperatureClass.h rename to firmware/Nanpy/DallasTemperatureClass.h diff --git a/firmware/EEPROMClass.cpp b/firmware/Nanpy/EEPROMClass.cpp similarity index 100% rename from firmware/EEPROMClass.cpp rename to firmware/Nanpy/EEPROMClass.cpp diff --git a/firmware/EEPROMClass.h b/firmware/Nanpy/EEPROMClass.h similarity index 100% rename from firmware/EEPROMClass.h rename to firmware/Nanpy/EEPROMClass.h diff --git a/firmware/LiquidCrystalClass.cpp b/firmware/Nanpy/LiquidCrystalClass.cpp similarity index 100% rename from firmware/LiquidCrystalClass.cpp rename to firmware/Nanpy/LiquidCrystalClass.cpp diff --git a/firmware/LiquidCrystalClass.h b/firmware/Nanpy/LiquidCrystalClass.h similarity index 100% rename from firmware/LiquidCrystalClass.h rename to firmware/Nanpy/LiquidCrystalClass.h diff --git a/firmware/Makefile b/firmware/Nanpy/Makefile similarity index 100% rename from firmware/Makefile rename to firmware/Nanpy/Makefile diff --git a/firmware/MethodDescriptor.cpp b/firmware/Nanpy/MethodDescriptor.cpp similarity index 100% rename from firmware/MethodDescriptor.cpp rename to firmware/Nanpy/MethodDescriptor.cpp diff --git a/firmware/MethodDescriptor.h b/firmware/Nanpy/MethodDescriptor.h similarity index 100% rename from firmware/MethodDescriptor.h rename to firmware/Nanpy/MethodDescriptor.h diff --git a/firmware/Nanpy.ino b/firmware/Nanpy/Nanpy.ino similarity index 100% rename from firmware/Nanpy.ino rename to firmware/Nanpy/Nanpy.ino diff --git a/firmware/OneWireClass.cpp b/firmware/Nanpy/OneWireClass.cpp similarity index 100% rename from firmware/OneWireClass.cpp rename to firmware/Nanpy/OneWireClass.cpp diff --git a/firmware/OneWireClass.h b/firmware/Nanpy/OneWireClass.h similarity index 100% rename from firmware/OneWireClass.h rename to firmware/Nanpy/OneWireClass.h diff --git a/firmware/ServoClass.cpp b/firmware/Nanpy/ServoClass.cpp similarity index 100% rename from firmware/ServoClass.cpp rename to firmware/Nanpy/ServoClass.cpp diff --git a/firmware/ServoClass.h b/firmware/Nanpy/ServoClass.h similarity index 100% rename from firmware/ServoClass.h rename to firmware/Nanpy/ServoClass.h diff --git a/firmware/SlimArray.h b/firmware/Nanpy/SlimArray.h similarity index 100% rename from firmware/SlimArray.h rename to firmware/Nanpy/SlimArray.h diff --git a/firmware/StepperClass.cpp b/firmware/Nanpy/StepperClass.cpp similarity index 100% rename from firmware/StepperClass.cpp rename to firmware/Nanpy/StepperClass.cpp diff --git a/firmware/StepperClass.h b/firmware/Nanpy/StepperClass.h similarity index 100% rename from firmware/StepperClass.h rename to firmware/Nanpy/StepperClass.h diff --git a/firmware/ToneClass.cpp b/firmware/Nanpy/ToneClass.cpp similarity index 100% rename from firmware/ToneClass.cpp rename to firmware/Nanpy/ToneClass.cpp diff --git a/firmware/ToneClass.h b/firmware/Nanpy/ToneClass.h similarity index 100% rename from firmware/ToneClass.h rename to firmware/Nanpy/ToneClass.h diff --git a/firmware/arduino.mk b/firmware/Nanpy/arduino.mk similarity index 100% rename from firmware/arduino.mk rename to firmware/Nanpy/arduino.mk diff --git a/firmware/libraries/CapacitiveSensor/CapacitiveSensor.cpp b/firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.cpp similarity index 100% rename from firmware/libraries/CapacitiveSensor/CapacitiveSensor.cpp rename to firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.cpp diff --git a/firmware/libraries/CapacitiveSensor/CapacitiveSensor.h b/firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.h similarity index 100% rename from firmware/libraries/CapacitiveSensor/CapacitiveSensor.h rename to firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.h diff --git a/firmware/libraries/CapacitiveSensor/README.md b/firmware/Nanpy/libraries/CapacitiveSensor/README.md similarity index 100% rename from firmware/libraries/CapacitiveSensor/README.md rename to firmware/Nanpy/libraries/CapacitiveSensor/README.md diff --git a/firmware/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde b/firmware/Nanpy/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde similarity index 100% rename from firmware/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde rename to firmware/Nanpy/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde diff --git a/firmware/libraries/CapacitiveSensor/keywords.txt b/firmware/Nanpy/libraries/CapacitiveSensor/keywords.txt similarity index 100% rename from firmware/libraries/CapacitiveSensor/keywords.txt rename to firmware/Nanpy/libraries/CapacitiveSensor/keywords.txt diff --git a/firmware/libraries/DallasTemperature/DallasTemperature.cpp b/firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.cpp similarity index 100% rename from firmware/libraries/DallasTemperature/DallasTemperature.cpp rename to firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.cpp diff --git a/firmware/libraries/DallasTemperature/DallasTemperature.h b/firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.h similarity index 100% rename from firmware/libraries/DallasTemperature/DallasTemperature.h rename to firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.h diff --git a/firmware/libraries/DallasTemperature/README.TXT b/firmware/Nanpy/libraries/DallasTemperature/README.TXT similarity index 100% rename from firmware/libraries/DallasTemperature/README.TXT rename to firmware/Nanpy/libraries/DallasTemperature/README.TXT diff --git a/firmware/libraries/DallasTemperature/change.txt b/firmware/Nanpy/libraries/DallasTemperature/change.txt similarity index 100% rename from firmware/libraries/DallasTemperature/change.txt rename to firmware/Nanpy/libraries/DallasTemperature/change.txt diff --git a/firmware/libraries/DallasTemperature/examples/Alarm/Alarm.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/Alarm/Alarm.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/Alarm/Alarm.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/Alarm/Alarm.pde diff --git a/firmware/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde diff --git a/firmware/libraries/DallasTemperature/examples/Multiple/Multiple.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/Multiple/Multiple.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/Multiple/Multiple.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/Multiple/Multiple.pde diff --git a/firmware/libraries/DallasTemperature/examples/Simple/Simple.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/Simple/Simple.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/Simple/Simple.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/Simple/Simple.pde diff --git a/firmware/libraries/DallasTemperature/examples/Single/Single.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/Single/Single.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/Single/Single.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/Single/Single.pde diff --git a/firmware/libraries/DallasTemperature/examples/Tester/Tester.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/Tester/Tester.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/Tester/Tester.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/Tester/Tester.pde diff --git a/firmware/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde diff --git a/firmware/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde b/firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde similarity index 100% rename from firmware/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde rename to firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde diff --git a/firmware/libraries/DallasTemperature/keywords.txt b/firmware/Nanpy/libraries/DallasTemperature/keywords.txt similarity index 100% rename from firmware/libraries/DallasTemperature/keywords.txt rename to firmware/Nanpy/libraries/DallasTemperature/keywords.txt diff --git a/firmware/libraries/OneWire/OneWire.cpp b/firmware/Nanpy/libraries/OneWire/OneWire.cpp similarity index 100% rename from firmware/libraries/OneWire/OneWire.cpp rename to firmware/Nanpy/libraries/OneWire/OneWire.cpp diff --git a/firmware/libraries/OneWire/OneWire.h b/firmware/Nanpy/libraries/OneWire/OneWire.h similarity index 100% rename from firmware/libraries/OneWire/OneWire.h rename to firmware/Nanpy/libraries/OneWire/OneWire.h diff --git a/firmware/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde b/firmware/Nanpy/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde similarity index 100% rename from firmware/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde rename to firmware/Nanpy/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde diff --git a/firmware/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde b/firmware/Nanpy/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde similarity index 100% rename from firmware/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde rename to firmware/Nanpy/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde diff --git a/firmware/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde b/firmware/Nanpy/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde similarity index 100% rename from firmware/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde rename to firmware/Nanpy/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde diff --git a/firmware/libraries/OneWire/keywords.txt b/firmware/Nanpy/libraries/OneWire/keywords.txt similarity index 100% rename from firmware/libraries/OneWire/keywords.txt rename to firmware/Nanpy/libraries/OneWire/keywords.txt From 247b14fdab35d6fdfb37448682d17bc603bb3c17 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 15 Dec 2013 08:39:04 +0100 Subject: [PATCH 114/344] documentation of GUI upload process --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77bd10c..f3f6d0e 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,9 @@ and then upload it on your board: make upload -To install Nanpy just type (as root): +or copy firmware/Nanpy directory under your "sketchbook" directory, start Arduino program, open Sketchbook/Nanpy, select "Upload". + +To install Nanpy Python library just type (as root): python setup.py install From 39aea744642b4fa9aa70df9f2742a98e49169fe3 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:45:41 +0100 Subject: [PATCH 115/344] support for unsigned integers --- firmware/Nanpy/ComChannel.cpp | 8 ++++++++ firmware/Nanpy/ComChannel.h | 2 ++ firmware/Nanpy/MethodDescriptor.cpp | 8 ++++++++ firmware/Nanpy/MethodDescriptor.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/firmware/Nanpy/ComChannel.cpp b/firmware/Nanpy/ComChannel.cpp index be08118..fe5a2a4 100755 --- a/firmware/Nanpy/ComChannel.cpp +++ b/firmware/Nanpy/ComChannel.cpp @@ -42,6 +42,10 @@ void nanpy::ComChannel::println(int val) { Serial.println(val); } +void nanpy::ComChannel::println(unsigned int val) { + Serial.println(val); +} + void nanpy::ComChannel::println(float val) { Serial.println(val); } @@ -54,6 +58,10 @@ void nanpy::ComChannel::println(long val) { Serial.println(val); } +void nanpy::ComChannel::println(unsigned long val) { + Serial.println(val); +} + char* nanpy::ComChannel::readLine() { return readLineFromSerial(); } diff --git a/firmware/Nanpy/ComChannel.h b/firmware/Nanpy/ComChannel.h index 5437120..258b285 100755 --- a/firmware/Nanpy/ComChannel.h +++ b/firmware/Nanpy/ComChannel.h @@ -14,9 +14,11 @@ namespace nanpy { static void println(String& val); static void println(const char* val); static void println(int val); + static void println(unsigned int val); static void println(float val); static void println(double val); static void println(long val); + static void println(unsigned long val); static char* readLine(); }; } diff --git a/firmware/Nanpy/MethodDescriptor.cpp b/firmware/Nanpy/MethodDescriptor.cpp index 45f2a15..1fa3cf8 100755 --- a/firmware/Nanpy/MethodDescriptor.cpp +++ b/firmware/Nanpy/MethodDescriptor.cpp @@ -72,6 +72,10 @@ void nanpy::MethodDescriptor::returns(int val) { ComChannel::println(val); } +void nanpy::MethodDescriptor::returns(unsigned int val) { + ComChannel::println(val); +} + void nanpy::MethodDescriptor::returns(float val) { ComChannel::println(val); } @@ -84,6 +88,10 @@ void nanpy::MethodDescriptor::returns(long val) { ComChannel::println(val); } +void nanpy::MethodDescriptor::returns(unsigned long val) { + ComChannel::println(val); +} + nanpy::MethodDescriptor::~MethodDescriptor() { delete(name); delete(classname); diff --git a/firmware/Nanpy/MethodDescriptor.h b/firmware/Nanpy/MethodDescriptor.h index 6ceeca9..ad3e89c 100644 --- a/firmware/Nanpy/MethodDescriptor.h +++ b/firmware/Nanpy/MethodDescriptor.h @@ -26,9 +26,11 @@ namespace nanpy { void returns(String& val); void returns(const char* val); void returns(int val); + void returns(unsigned int val); void returns(float val); void returns(double val); void returns(long val); + void returns(unsigned long val); ~MethodDescriptor(); }; From 51238637accb977a82b3d7664746b808333689b0 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:42:56 +0100 Subject: [PATCH 116/344] git ignore all hidden files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7c6939e..76b38e3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ nanpy.egg-info/ #Python *.pyc +#hidden files +.* +!.gitignore From 439ac7ae09cf879acb5f9f5c84807bee16cdc362 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:45:31 +0100 Subject: [PATCH 117/344] change blink time from 10 ms to 200 ms (it was too fast) --- examples/blink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/blink.py b/examples/blink.py index 438cdc7..0363cd2 100755 --- a/examples/blink.py +++ b/examples/blink.py @@ -10,5 +10,5 @@ for i in range(10000): Arduino.digitalWrite(13, (i + 1) % 2) - Arduino.delay(10) + Arduino.delay(200) From bf842b5ad012a66cc792ecfee25e2e02995cd29d Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:47:40 +0100 Subject: [PATCH 118/344] subclass every class from object --- nanpy/arduino.py | 2 +- nanpy/arduinoboard.py | 2 +- nanpy/eeprom.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index 4b9ca51..bd28eef 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -2,7 +2,7 @@ import time -class Arduino(): +class Arduino(object): HIGH = 1 LOW = 0 diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 25111d2..ba86d62 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -64,7 +64,7 @@ def wrapper(cls, *args, **kwargs): return _call(cls.__name__, 0, call_pars) return wrapper -class ArduinoObject(): +class ArduinoObject(object): def __init__(self): self.namespace = self.__class__.__name__ diff --git a/nanpy/eeprom.py b/nanpy/eeprom.py index ab32035..752c698 100644 --- a/nanpy/eeprom.py +++ b/nanpy/eeprom.py @@ -1,6 +1,6 @@ from nanpy.arduinoboard import (arduinoclassmethod, returns) -class EEPROM(): +class EEPROM(object): @classmethod @arduinoclassmethod From b4c76c9dc9278afeca269b1610287f16741190ce Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:48:24 +0100 Subject: [PATCH 119/344] py3 compatibility --- nanpy/serialmanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 3715946..9f82981 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -60,8 +60,8 @@ def __init__(self): def write(self, value): self._serial.write(value) -if sys.version_info.major == 2: +if sys.version_info[0] == 2: serial_manager = SerialManagerPy2() -elif sys.version_info.major == 3: +elif sys.version_info[0] == 3: serial_manager = SerialManager() From 06eebc8cdd9ee2a7159f67f3c28b5a570c946ef9 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:49:32 +0100 Subject: [PATCH 120/344] new decorator: memoized --- nanpy/memo.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 nanpy/memo.py diff --git a/nanpy/memo.py b/nanpy/memo.py new file mode 100644 index 0000000..d9c9c65 --- /dev/null +++ b/nanpy/memo.py @@ -0,0 +1,35 @@ +import functools + +''' +http://wiki.python.org/moin/PythonDecoratorLibrary +''' + + +class memoized(object): + """Decorator that caches a function's return value each time it is called. + If called later with the same arguments, the cached value is returned, and + not re-evaluated. + """ + def __init__(self, func): + self.func = func + self.cache = {} + + def __call__(self, *args): + try: + return self.cache[args] + except KeyError: + value = self.func(*args) + self.cache[args] = value + return value + except TypeError: + # uncachable -- for instance, passing a list as an argument. + # Better to not cache than to blow up entirely. + return self.func(*args) + + def __repr__(self): + """Return the function's docstring.""" + return self.func.__doc__ + + def __get__(self, obj, objtype): + """Support instance methods.""" + return functools.partial(self.__call__, obj) From 673c99fd76652bfce01d8f5f9c09e66d1fcff574 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:51:34 +0100 Subject: [PATCH 121/344] new: EEPROM.size() --- firmware/Nanpy/EEPROMClass.cpp | 5 ++++- nanpy/eeprom.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/firmware/Nanpy/EEPROMClass.cpp b/firmware/Nanpy/EEPROMClass.cpp index a9263b9..da095da 100644 --- a/firmware/Nanpy/EEPROMClass.cpp +++ b/firmware/Nanpy/EEPROMClass.cpp @@ -8,9 +8,12 @@ void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { EEPROM.write(m->getInt(0), m->getInt(1)); m->returns(0); } - if (strcmp(m->getName(), "read") == 0) { m->returns(EEPROM.read(m->getInt(0))); } + + if (strcmp(m->getName(), "size") == 0) { + m->returns(E2END+1); + } } }; diff --git a/nanpy/eeprom.py b/nanpy/eeprom.py index 752c698..1db53bd 100644 --- a/nanpy/eeprom.py +++ b/nanpy/eeprom.py @@ -1,4 +1,5 @@ from nanpy.arduinoboard import (arduinoclassmethod, returns) +from nanpy.memo import memoized class EEPROM(object): @@ -12,3 +13,10 @@ def write(cls, address, value): @arduinoclassmethod def read(cls, address): pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def size(cls): + pass From fa58daeba26a192b9e5862da18147a28f05196f9 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:29:16 +0100 Subject: [PATCH 122/344] example: read full EEPROM --- examples/eepromread.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/eepromread.py b/examples/eepromread.py index df89f8d..08ab865 100755 --- a/examples/eepromread.py +++ b/examples/eepromread.py @@ -7,7 +7,7 @@ from nanpy import EEPROM import sys -EEPROM_SIZE = 1024//4 #only read first 256 bytes +EEPROM_SIZE = EEPROM.size() def display(a_list): @@ -16,6 +16,7 @@ def display(a_list): sys.stdout.write( "%x : " % a_list[j+i*16]) print + def read_eeprom(): data_list = [] for i in range(0, EEPROM_SIZE): @@ -23,6 +24,7 @@ def read_eeprom(): data_list.append(s) return data_list + if __name__ == "__main__": - print("Reading first 256 bytes of eeprom...") + print("Reading eeprom (%s bytes)..." % EEPROM_SIZE) display(read_eeprom()) From 884bdee808aadac936179995b0b5a2e43be7a227 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 19:53:36 +0100 Subject: [PATCH 123/344] new: Arduino.pinModeRead() , Arduino.millis() --- firmware/Nanpy/ArduinoClass.cpp | 18 ++++++++++++++++++ nanpy/arduino.py | 14 +++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/firmware/Nanpy/ArduinoClass.cpp b/firmware/Nanpy/ArduinoClass.cpp index ad45e43..f6ad0f8 100644 --- a/firmware/Nanpy/ArduinoClass.cpp +++ b/firmware/Nanpy/ArduinoClass.cpp @@ -2,6 +2,16 @@ #include "ArduinoClass.h" #include + +byte pinModeRead(int pin) +{ + byte bitmask = digitalPinToBitMask(pin); + word port = digitalPinToPort(pin); + byte reg = *portModeRegister(port); + byte mode = (reg & bitmask) ? 1 : 0; + return mode; +} + void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getClass(), "Arduino") == 0) { if (strcmp(m->getName(), "digitalWrite") == 0) { @@ -27,8 +37,16 @@ void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { m->returns(0); } + if (strcmp(m->getName(), "pinModeRead") == 0) { + m->returns(pinModeRead(m->getInt(0))); + } + if (strcmp(m->getName(), "delay") == 0) { m->returns(0); } + + if (strcmp(m->getName(), "millis") == 0) { + m->returns(millis()); + } } }; diff --git a/nanpy/arduino.py b/nanpy/arduino.py index bd28eef..d16acec 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,7 +1,7 @@ from nanpy.arduinoboard import (arduinoclassmethod, returns) - import time + class Arduino(object): HIGH = 1 @@ -36,9 +36,21 @@ def analogRead(cls, pin): def pinMode(cls, pin, mode): pass + @classmethod + @returns(int) + @arduinoclassmethod + def pinModeRead(cls, pin): + pass + @classmethod def delay(cls, value): time.sleep(float(value)/1000) + + @classmethod + @returns(int) + @arduinoclassmethod + def millis(cls): + pass @classmethod def map(cls, x, in_min, in_max, out_min, out_max): From 2c7daf09d3e5c397807a8f479747e011735935c4 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:17:42 +0100 Subject: [PATCH 124/344] code generator and its output --- codegen/__init__.py | 130 + firmware/Nanpy/generated_avr_registers.h | 13764 +++++++++++++++++++++ firmware/Nanpy/generated_mcu.h | 1287 ++ 3 files changed, 15181 insertions(+) create mode 100644 codegen/__init__.py create mode 100644 firmware/Nanpy/generated_avr_registers.h create mode 100644 firmware/Nanpy/generated_mcu.h diff --git a/codegen/__init__.py b/codegen/__init__.py new file mode 100644 index 0000000..aebc6db --- /dev/null +++ b/codegen/__init__.py @@ -0,0 +1,130 @@ +from path import path + + +def read_define(fname, name): + for line in path(fname).lines(): + ls = line.split(name) + if len(ls) > 1: + if ls[0].strip().strip('#') == 'define': + return ls[1].strip() + + +class Codegen(object): + + def __init__(self, root): + self.root = root + + def header(self, avrlibc=True): + s = ''' +// this file was generated by codegen.py +''' + if avrlibc: + s += ''' +// __AVR_LIBC_VERSION_STRING__ = {version} +// __AVR_LIBC_DATE_STRING__ = {date} + \n'''.format( + version=self.version(), + date=self.date(), + ) + + return (s) + + def version(self): + return ( + read_define(self.root / 'version.h', '__AVR_LIBC_VERSION_STRING__') + ) + + def date(self): + return read_define(self.root / 'version.h', '__AVR_LIBC_DATE_STRING__') + + def write_header(self, hfile, text, avrlibc=True): + print 'writing to %s' % hfile + hfile.write_text(self.header(avrlibc) + text) + + def regs(self, target): + print '== generating code for registers ==' + valid = set() + defs = set() + print 'reading %s directory' % self.root + for h in path(self.root).walkfiles('*.h'): + for x in h.lines(): + x = x.replace('#', '').strip() + ls = x.split() + [''] * 4 + if 'define' == ls[0]: + if '_struct' not in ls[1]: + if '_SFR_IO8' in ls[2] or '_SFR_MEM8' in ls[2]: + valid.add(ls[1]) + if '_SFR_IO16' in ls[2] or '_SFR_MEM16' in ls[2]: + valid.add(ls[1]) + + ok = True + if '(' in ls[2]: + ok = False + if ls[1] != ls[1].upper(): + ok = False + if ls[1].startswith('_'): + ok = False + for s in ['(', '_vect', '_H', 'eeprom']: + if s in ls[1]: + ok = False + if ok: + defs.add(ls[1]) + exlude_regs = ['SPDR0'] + valid = filter(lambda x: x not in exlude_regs, valid) + valid = sorted(valid) + TEMPLATE = ''' +#ifdef {0} + DEFINE({0}) +#else + MISSING({0}) +#endif''' + cpp = '\n'.join([TEMPLATE.format(x) for x in valid]) + + self.write_header(target, cpp) + + def mcu(self, target): + print '== generating code for MCUs ==' + valid = set() + print 'reading %s directory' % self.root + for h in self.root.walkfiles('*.h'): + for x in h.lines(): + x = x.replace('#', '').strip() + x = x.replace('!', '').strip() + ls = x.split() + [''] * 4 + if ls[0] in ['elif', 'if']: + for t in ls: + if 'defined' in t or 'defined' in x: + if '__AVR_AT' in t: + t = t.replace('defined', '') + t = t.replace('(', '') + t = t.replace(')', '') + t = t.strip() + valid.add(t) + + valid = sorted(valid) + TEMPLATE = ''' +#ifdef {0} +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "{0}" +#endif''' + cpp = '\n'.join([TEMPLATE.format(x) for x in valid]) + self.write_header(target, cpp) + + +def main(): + firmware_path = path(__file__).abspath().parent.parent / 'firmware' + nanpy_path = path(__file__).abspath().parent.parent / 'nanpy' + avr_include_path = path('/usr/lib/avr/include/avr/') + + x = Codegen(avr_include_path) + + x.regs(firmware_path / 'Nanpy' / 'generated_avr_registers.h') + + x.mcu(firmware_path / 'Nanpy' / 'generated_mcu.h') + + print 'done' + +if __name__ == '__main__': + main() diff --git a/firmware/Nanpy/generated_avr_registers.h b/firmware/Nanpy/generated_avr_registers.h new file mode 100644 index 0000000..caf238d --- /dev/null +++ b/firmware/Nanpy/generated_avr_registers.h @@ -0,0 +1,13764 @@ + +// this file was generated by codegen.py + +// __AVR_LIBC_VERSION_STRING__ = "1.8.0" +// __AVR_LIBC_DATE_STRING__ = "20111228" + + +#ifdef AC0CON + DEFINE(AC0CON) +#else + MISSING(AC0CON) +#endif + +#ifdef AC1CON + DEFINE(AC1CON) +#else + MISSING(AC1CON) +#endif + +#ifdef AC1ECON + DEFINE(AC1ECON) +#else + MISSING(AC1ECON) +#endif + +#ifdef AC2CON + DEFINE(AC2CON) +#else + MISSING(AC2CON) +#endif + +#ifdef AC2ECON + DEFINE(AC2ECON) +#else + MISSING(AC2ECON) +#endif + +#ifdef AC3CON + DEFINE(AC3CON) +#else + MISSING(AC3CON) +#endif + +#ifdef AC3ECON + DEFINE(AC3ECON) +#else + MISSING(AC3ECON) +#endif + +#ifdef ACA_AC0CTRL + DEFINE(ACA_AC0CTRL) +#else + MISSING(ACA_AC0CTRL) +#endif + +#ifdef ACA_AC0MUXCTRL + DEFINE(ACA_AC0MUXCTRL) +#else + MISSING(ACA_AC0MUXCTRL) +#endif + +#ifdef ACA_AC1CTRL + DEFINE(ACA_AC1CTRL) +#else + MISSING(ACA_AC1CTRL) +#endif + +#ifdef ACA_AC1MUXCTRL + DEFINE(ACA_AC1MUXCTRL) +#else + MISSING(ACA_AC1MUXCTRL) +#endif + +#ifdef ACA_CTRLA + DEFINE(ACA_CTRLA) +#else + MISSING(ACA_CTRLA) +#endif + +#ifdef ACA_CTRLB + DEFINE(ACA_CTRLB) +#else + MISSING(ACA_CTRLB) +#endif + +#ifdef ACA_STATUS + DEFINE(ACA_STATUS) +#else + MISSING(ACA_STATUS) +#endif + +#ifdef ACA_WINCTRL + DEFINE(ACA_WINCTRL) +#else + MISSING(ACA_WINCTRL) +#endif + +#ifdef ACB_AC0CTRL + DEFINE(ACB_AC0CTRL) +#else + MISSING(ACB_AC0CTRL) +#endif + +#ifdef ACB_AC0MUXCTRL + DEFINE(ACB_AC0MUXCTRL) +#else + MISSING(ACB_AC0MUXCTRL) +#endif + +#ifdef ACB_AC1CTRL + DEFINE(ACB_AC1CTRL) +#else + MISSING(ACB_AC1CTRL) +#endif + +#ifdef ACB_AC1MUXCTRL + DEFINE(ACB_AC1MUXCTRL) +#else + MISSING(ACB_AC1MUXCTRL) +#endif + +#ifdef ACB_CTRLA + DEFINE(ACB_CTRLA) +#else + MISSING(ACB_CTRLA) +#endif + +#ifdef ACB_CTRLB + DEFINE(ACB_CTRLB) +#else + MISSING(ACB_CTRLB) +#endif + +#ifdef ACB_STATUS + DEFINE(ACB_STATUS) +#else + MISSING(ACB_STATUS) +#endif + +#ifdef ACB_WINCTRL + DEFINE(ACB_WINCTRL) +#else + MISSING(ACB_WINCTRL) +#endif + +#ifdef ACSR + DEFINE(ACSR) +#else + MISSING(ACSR) +#endif + +#ifdef ACSRA + DEFINE(ACSRA) +#else + MISSING(ACSRA) +#endif + +#ifdef ACSRB + DEFINE(ACSRB) +#else + MISSING(ACSRB) +#endif + +#ifdef ADC + DEFINE(ADC) +#else + MISSING(ADC) +#endif + +#ifdef ADCA_CAL + DEFINE(ADCA_CAL) +#else + MISSING(ADCA_CAL) +#endif + +#ifdef ADCA_CH0RES + DEFINE(ADCA_CH0RES) +#else + MISSING(ADCA_CH0RES) +#endif + +#ifdef ADCA_CH0_CTRL + DEFINE(ADCA_CH0_CTRL) +#else + MISSING(ADCA_CH0_CTRL) +#endif + +#ifdef ADCA_CH0_INTCTRL + DEFINE(ADCA_CH0_INTCTRL) +#else + MISSING(ADCA_CH0_INTCTRL) +#endif + +#ifdef ADCA_CH0_INTFLAGS + DEFINE(ADCA_CH0_INTFLAGS) +#else + MISSING(ADCA_CH0_INTFLAGS) +#endif + +#ifdef ADCA_CH0_MUXCTRL + DEFINE(ADCA_CH0_MUXCTRL) +#else + MISSING(ADCA_CH0_MUXCTRL) +#endif + +#ifdef ADCA_CH0_RES + DEFINE(ADCA_CH0_RES) +#else + MISSING(ADCA_CH0_RES) +#endif + +#ifdef ADCA_CH1RES + DEFINE(ADCA_CH1RES) +#else + MISSING(ADCA_CH1RES) +#endif + +#ifdef ADCA_CH1_CTRL + DEFINE(ADCA_CH1_CTRL) +#else + MISSING(ADCA_CH1_CTRL) +#endif + +#ifdef ADCA_CH1_INTCTRL + DEFINE(ADCA_CH1_INTCTRL) +#else + MISSING(ADCA_CH1_INTCTRL) +#endif + +#ifdef ADCA_CH1_INTFLAGS + DEFINE(ADCA_CH1_INTFLAGS) +#else + MISSING(ADCA_CH1_INTFLAGS) +#endif + +#ifdef ADCA_CH1_MUXCTRL + DEFINE(ADCA_CH1_MUXCTRL) +#else + MISSING(ADCA_CH1_MUXCTRL) +#endif + +#ifdef ADCA_CH1_RES + DEFINE(ADCA_CH1_RES) +#else + MISSING(ADCA_CH1_RES) +#endif + +#ifdef ADCA_CH2RES + DEFINE(ADCA_CH2RES) +#else + MISSING(ADCA_CH2RES) +#endif + +#ifdef ADCA_CH2_CTRL + DEFINE(ADCA_CH2_CTRL) +#else + MISSING(ADCA_CH2_CTRL) +#endif + +#ifdef ADCA_CH2_INTCTRL + DEFINE(ADCA_CH2_INTCTRL) +#else + MISSING(ADCA_CH2_INTCTRL) +#endif + +#ifdef ADCA_CH2_INTFLAGS + DEFINE(ADCA_CH2_INTFLAGS) +#else + MISSING(ADCA_CH2_INTFLAGS) +#endif + +#ifdef ADCA_CH2_MUXCTRL + DEFINE(ADCA_CH2_MUXCTRL) +#else + MISSING(ADCA_CH2_MUXCTRL) +#endif + +#ifdef ADCA_CH2_RES + DEFINE(ADCA_CH2_RES) +#else + MISSING(ADCA_CH2_RES) +#endif + +#ifdef ADCA_CH3RES + DEFINE(ADCA_CH3RES) +#else + MISSING(ADCA_CH3RES) +#endif + +#ifdef ADCA_CH3_CTRL + DEFINE(ADCA_CH3_CTRL) +#else + MISSING(ADCA_CH3_CTRL) +#endif + +#ifdef ADCA_CH3_INTCTRL + DEFINE(ADCA_CH3_INTCTRL) +#else + MISSING(ADCA_CH3_INTCTRL) +#endif + +#ifdef ADCA_CH3_INTFLAGS + DEFINE(ADCA_CH3_INTFLAGS) +#else + MISSING(ADCA_CH3_INTFLAGS) +#endif + +#ifdef ADCA_CH3_MUXCTRL + DEFINE(ADCA_CH3_MUXCTRL) +#else + MISSING(ADCA_CH3_MUXCTRL) +#endif + +#ifdef ADCA_CH3_RES + DEFINE(ADCA_CH3_RES) +#else + MISSING(ADCA_CH3_RES) +#endif + +#ifdef ADCA_CMP + DEFINE(ADCA_CMP) +#else + MISSING(ADCA_CMP) +#endif + +#ifdef ADCA_CTRLA + DEFINE(ADCA_CTRLA) +#else + MISSING(ADCA_CTRLA) +#endif + +#ifdef ADCA_CTRLB + DEFINE(ADCA_CTRLB) +#else + MISSING(ADCA_CTRLB) +#endif + +#ifdef ADCA_EVCTRL + DEFINE(ADCA_EVCTRL) +#else + MISSING(ADCA_EVCTRL) +#endif + +#ifdef ADCA_INTFLAGS + DEFINE(ADCA_INTFLAGS) +#else + MISSING(ADCA_INTFLAGS) +#endif + +#ifdef ADCA_PRESCALER + DEFINE(ADCA_PRESCALER) +#else + MISSING(ADCA_PRESCALER) +#endif + +#ifdef ADCA_REFCTRL + DEFINE(ADCA_REFCTRL) +#else + MISSING(ADCA_REFCTRL) +#endif + +#ifdef ADCA_TEMP + DEFINE(ADCA_TEMP) +#else + MISSING(ADCA_TEMP) +#endif + +#ifdef ADCB_CAL + DEFINE(ADCB_CAL) +#else + MISSING(ADCB_CAL) +#endif + +#ifdef ADCB_CH0RES + DEFINE(ADCB_CH0RES) +#else + MISSING(ADCB_CH0RES) +#endif + +#ifdef ADCB_CH0_CTRL + DEFINE(ADCB_CH0_CTRL) +#else + MISSING(ADCB_CH0_CTRL) +#endif + +#ifdef ADCB_CH0_INTCTRL + DEFINE(ADCB_CH0_INTCTRL) +#else + MISSING(ADCB_CH0_INTCTRL) +#endif + +#ifdef ADCB_CH0_INTFLAGS + DEFINE(ADCB_CH0_INTFLAGS) +#else + MISSING(ADCB_CH0_INTFLAGS) +#endif + +#ifdef ADCB_CH0_MUXCTRL + DEFINE(ADCB_CH0_MUXCTRL) +#else + MISSING(ADCB_CH0_MUXCTRL) +#endif + +#ifdef ADCB_CH0_RES + DEFINE(ADCB_CH0_RES) +#else + MISSING(ADCB_CH0_RES) +#endif + +#ifdef ADCB_CH1RES + DEFINE(ADCB_CH1RES) +#else + MISSING(ADCB_CH1RES) +#endif + +#ifdef ADCB_CH1_CTRL + DEFINE(ADCB_CH1_CTRL) +#else + MISSING(ADCB_CH1_CTRL) +#endif + +#ifdef ADCB_CH1_INTCTRL + DEFINE(ADCB_CH1_INTCTRL) +#else + MISSING(ADCB_CH1_INTCTRL) +#endif + +#ifdef ADCB_CH1_INTFLAGS + DEFINE(ADCB_CH1_INTFLAGS) +#else + MISSING(ADCB_CH1_INTFLAGS) +#endif + +#ifdef ADCB_CH1_MUXCTRL + DEFINE(ADCB_CH1_MUXCTRL) +#else + MISSING(ADCB_CH1_MUXCTRL) +#endif + +#ifdef ADCB_CH1_RES + DEFINE(ADCB_CH1_RES) +#else + MISSING(ADCB_CH1_RES) +#endif + +#ifdef ADCB_CH2RES + DEFINE(ADCB_CH2RES) +#else + MISSING(ADCB_CH2RES) +#endif + +#ifdef ADCB_CH2_CTRL + DEFINE(ADCB_CH2_CTRL) +#else + MISSING(ADCB_CH2_CTRL) +#endif + +#ifdef ADCB_CH2_INTCTRL + DEFINE(ADCB_CH2_INTCTRL) +#else + MISSING(ADCB_CH2_INTCTRL) +#endif + +#ifdef ADCB_CH2_INTFLAGS + DEFINE(ADCB_CH2_INTFLAGS) +#else + MISSING(ADCB_CH2_INTFLAGS) +#endif + +#ifdef ADCB_CH2_MUXCTRL + DEFINE(ADCB_CH2_MUXCTRL) +#else + MISSING(ADCB_CH2_MUXCTRL) +#endif + +#ifdef ADCB_CH2_RES + DEFINE(ADCB_CH2_RES) +#else + MISSING(ADCB_CH2_RES) +#endif + +#ifdef ADCB_CH3RES + DEFINE(ADCB_CH3RES) +#else + MISSING(ADCB_CH3RES) +#endif + +#ifdef ADCB_CH3_CTRL + DEFINE(ADCB_CH3_CTRL) +#else + MISSING(ADCB_CH3_CTRL) +#endif + +#ifdef ADCB_CH3_INTCTRL + DEFINE(ADCB_CH3_INTCTRL) +#else + MISSING(ADCB_CH3_INTCTRL) +#endif + +#ifdef ADCB_CH3_INTFLAGS + DEFINE(ADCB_CH3_INTFLAGS) +#else + MISSING(ADCB_CH3_INTFLAGS) +#endif + +#ifdef ADCB_CH3_MUXCTRL + DEFINE(ADCB_CH3_MUXCTRL) +#else + MISSING(ADCB_CH3_MUXCTRL) +#endif + +#ifdef ADCB_CH3_RES + DEFINE(ADCB_CH3_RES) +#else + MISSING(ADCB_CH3_RES) +#endif + +#ifdef ADCB_CMP + DEFINE(ADCB_CMP) +#else + MISSING(ADCB_CMP) +#endif + +#ifdef ADCB_CTRLA + DEFINE(ADCB_CTRLA) +#else + MISSING(ADCB_CTRLA) +#endif + +#ifdef ADCB_CTRLB + DEFINE(ADCB_CTRLB) +#else + MISSING(ADCB_CTRLB) +#endif + +#ifdef ADCB_EVCTRL + DEFINE(ADCB_EVCTRL) +#else + MISSING(ADCB_EVCTRL) +#endif + +#ifdef ADCB_INTFLAGS + DEFINE(ADCB_INTFLAGS) +#else + MISSING(ADCB_INTFLAGS) +#endif + +#ifdef ADCB_PRESCALER + DEFINE(ADCB_PRESCALER) +#else + MISSING(ADCB_PRESCALER) +#endif + +#ifdef ADCB_REFCTRL + DEFINE(ADCB_REFCTRL) +#else + MISSING(ADCB_REFCTRL) +#endif + +#ifdef ADCB_TEMP + DEFINE(ADCB_TEMP) +#else + MISSING(ADCB_TEMP) +#endif + +#ifdef ADCH + DEFINE(ADCH) +#else + MISSING(ADCH) +#endif + +#ifdef ADCL + DEFINE(ADCL) +#else + MISSING(ADCL) +#endif + +#ifdef ADCRA + DEFINE(ADCRA) +#else + MISSING(ADCRA) +#endif + +#ifdef ADCRB + DEFINE(ADCRB) +#else + MISSING(ADCRB) +#endif + +#ifdef ADCRC + DEFINE(ADCRC) +#else + MISSING(ADCRC) +#endif + +#ifdef ADCRD + DEFINE(ADCRD) +#else + MISSING(ADCRD) +#endif + +#ifdef ADCRE + DEFINE(ADCRE) +#else + MISSING(ADCRE) +#endif + +#ifdef ADCSR + DEFINE(ADCSR) +#else + MISSING(ADCSR) +#endif + +#ifdef ADCSRA + DEFINE(ADCSRA) +#else + MISSING(ADCSRA) +#endif + +#ifdef ADCSRB + DEFINE(ADCSRB) +#else + MISSING(ADCSRB) +#endif + +#ifdef ADCSRC + DEFINE(ADCSRC) +#else + MISSING(ADCSRC) +#endif + +#ifdef ADCW + DEFINE(ADCW) +#else + MISSING(ADCW) +#endif + +#ifdef ADCWH + DEFINE(ADCWH) +#else + MISSING(ADCWH) +#endif + +#ifdef ADCWL + DEFINE(ADCWL) +#else + MISSING(ADCWL) +#endif + +#ifdef ADIFR + DEFINE(ADIFR) +#else + MISSING(ADIFR) +#endif + +#ifdef ADIMR + DEFINE(ADIMR) +#else + MISSING(ADIMR) +#endif + +#ifdef ADMUX + DEFINE(ADMUX) +#else + MISSING(ADMUX) +#endif + +#ifdef ADRSLT + DEFINE(ADRSLT) +#else + MISSING(ADRSLT) +#endif + +#ifdef ADRSLTH + DEFINE(ADRSLTH) +#else + MISSING(ADRSLTH) +#endif + +#ifdef ADRSLTHI + DEFINE(ADRSLTHI) +#else + MISSING(ADRSLTHI) +#endif + +#ifdef ADRSLTL + DEFINE(ADRSLTL) +#else + MISSING(ADRSLTL) +#endif + +#ifdef ADRSLTLO + DEFINE(ADRSLTLO) +#else + MISSING(ADRSLTLO) +#endif + +#ifdef ADSCSRA + DEFINE(ADSCSRA) +#else + MISSING(ADSCSRA) +#endif + +#ifdef ADSCSRB + DEFINE(ADSCSRB) +#else + MISSING(ADSCSRB) +#endif + +#ifdef AESACR + DEFINE(AESACR) +#else + MISSING(AESACR) +#endif + +#ifdef AESADDR + DEFINE(AESADDR) +#else + MISSING(AESADDR) +#endif + +#ifdef AESCR + DEFINE(AESCR) +#else + MISSING(AESCR) +#endif + +#ifdef AESDR + DEFINE(AESDR) +#else + MISSING(AESDR) +#endif + +#ifdef AES_CTRL + DEFINE(AES_CTRL) +#else + MISSING(AES_CTRL) +#endif + +#ifdef AES_INTCTRL + DEFINE(AES_INTCTRL) +#else + MISSING(AES_INTCTRL) +#endif + +#ifdef AES_KEY + DEFINE(AES_KEY) +#else + MISSING(AES_KEY) +#endif + +#ifdef AES_STATE + DEFINE(AES_STATE) +#else + MISSING(AES_STATE) +#endif + +#ifdef AES_STATUS + DEFINE(AES_STATUS) +#else + MISSING(AES_STATUS) +#endif + +#ifdef AGPDDR + DEFINE(AGPDDR) +#else + MISSING(AGPDDR) +#endif + +#ifdef AGPPIN + DEFINE(AGPPIN) +#else + MISSING(AGPPIN) +#endif + +#ifdef AGPPORT + DEFINE(AGPPORT) +#else + MISSING(AGPPORT) +#endif + +#ifdef AMISCR + DEFINE(AMISCR) +#else + MISSING(AMISCR) +#endif + +#ifdef AMP0CSR + DEFINE(AMP0CSR) +#else + MISSING(AMP0CSR) +#endif + +#ifdef AMP1CSR + DEFINE(AMP1CSR) +#else + MISSING(AMP1CSR) +#endif + +#ifdef AMP2CSR + DEFINE(AMP2CSR) +#else + MISSING(AMP2CSR) +#endif + +#ifdef AMUXCTL + DEFINE(AMUXCTL) +#else + MISSING(AMUXCTL) +#endif + +#ifdef ANT_DIV + DEFINE(ANT_DIV) +#else + MISSING(ANT_DIV) +#endif + +#ifdef ASSR + DEFINE(ASSR) +#else + MISSING(ASSR) +#endif + +#ifdef AVR_CONFIG + DEFINE(AVR_CONFIG) +#else + MISSING(AVR_CONFIG) +#endif + +#ifdef AWEXC_CTRL + DEFINE(AWEXC_CTRL) +#else + MISSING(AWEXC_CTRL) +#endif + +#ifdef AWEXC_DTBOTH + DEFINE(AWEXC_DTBOTH) +#else + MISSING(AWEXC_DTBOTH) +#endif + +#ifdef AWEXC_DTBOTHBUF + DEFINE(AWEXC_DTBOTHBUF) +#else + MISSING(AWEXC_DTBOTHBUF) +#endif + +#ifdef AWEXC_DTHS + DEFINE(AWEXC_DTHS) +#else + MISSING(AWEXC_DTHS) +#endif + +#ifdef AWEXC_DTHSBUF + DEFINE(AWEXC_DTHSBUF) +#else + MISSING(AWEXC_DTHSBUF) +#endif + +#ifdef AWEXC_DTLS + DEFINE(AWEXC_DTLS) +#else + MISSING(AWEXC_DTLS) +#endif + +#ifdef AWEXC_DTLSBUF + DEFINE(AWEXC_DTLSBUF) +#else + MISSING(AWEXC_DTLSBUF) +#endif + +#ifdef AWEXC_FDCTRL + DEFINE(AWEXC_FDCTRL) +#else + MISSING(AWEXC_FDCTRL) +#endif + +#ifdef AWEXC_FDEMASK + DEFINE(AWEXC_FDEMASK) +#else + MISSING(AWEXC_FDEMASK) +#endif + +#ifdef AWEXC_OUTOVEN + DEFINE(AWEXC_OUTOVEN) +#else + MISSING(AWEXC_OUTOVEN) +#endif + +#ifdef AWEXC_STATUS + DEFINE(AWEXC_STATUS) +#else + MISSING(AWEXC_STATUS) +#endif + +#ifdef AWEXE_CTRL + DEFINE(AWEXE_CTRL) +#else + MISSING(AWEXE_CTRL) +#endif + +#ifdef AWEXE_DTBOTH + DEFINE(AWEXE_DTBOTH) +#else + MISSING(AWEXE_DTBOTH) +#endif + +#ifdef AWEXE_DTBOTHBUF + DEFINE(AWEXE_DTBOTHBUF) +#else + MISSING(AWEXE_DTBOTHBUF) +#endif + +#ifdef AWEXE_DTHS + DEFINE(AWEXE_DTHS) +#else + MISSING(AWEXE_DTHS) +#endif + +#ifdef AWEXE_DTHSBUF + DEFINE(AWEXE_DTHSBUF) +#else + MISSING(AWEXE_DTHSBUF) +#endif + +#ifdef AWEXE_DTLS + DEFINE(AWEXE_DTLS) +#else + MISSING(AWEXE_DTLS) +#endif + +#ifdef AWEXE_DTLSBUF + DEFINE(AWEXE_DTLSBUF) +#else + MISSING(AWEXE_DTLSBUF) +#endif + +#ifdef AWEXE_FDCTRL + DEFINE(AWEXE_FDCTRL) +#else + MISSING(AWEXE_FDCTRL) +#endif + +#ifdef AWEXE_FDEMASK + DEFINE(AWEXE_FDEMASK) +#else + MISSING(AWEXE_FDEMASK) +#endif + +#ifdef AWEXE_OUTOVEN + DEFINE(AWEXE_OUTOVEN) +#else + MISSING(AWEXE_OUTOVEN) +#endif + +#ifdef AWEXE_STATUS + DEFINE(AWEXE_STATUS) +#else + MISSING(AWEXE_STATUS) +#endif + +#ifdef BATMON + DEFINE(BATMON) +#else + MISSING(BATMON) +#endif + +#ifdef BGCAL + DEFINE(BGCAL) +#else + MISSING(BGCAL) +#endif + +#ifdef BGCCR + DEFINE(BGCCR) +#else + MISSING(BGCCR) +#endif + +#ifdef BGCR + DEFINE(BGCR) +#else + MISSING(BGCR) +#endif + +#ifdef BGCRA + DEFINE(BGCRA) +#else + MISSING(BGCRA) +#endif + +#ifdef BGCRB + DEFINE(BGCRB) +#else + MISSING(BGCRB) +#endif + +#ifdef BGCRR + DEFINE(BGCRR) +#else + MISSING(BGCRR) +#endif + +#ifdef BGCSR + DEFINE(BGCSR) +#else + MISSING(BGCSR) +#endif + +#ifdef BGCSRA + DEFINE(BGCSRA) +#else + MISSING(BGCSRA) +#endif + +#ifdef BGLR + DEFINE(BGLR) +#else + MISSING(BGLR) +#endif + +#ifdef BGPDDR + DEFINE(BGPDDR) +#else + MISSING(BGPDDR) +#endif + +#ifdef BGPPIN + DEFINE(BGPPIN) +#else + MISSING(BGPPIN) +#endif + +#ifdef BGPPORT + DEFINE(BGPPORT) +#else + MISSING(BGPPORT) +#endif + +#ifdef BL_CONFIG + DEFINE(BL_CONFIG) +#else + MISSING(BL_CONFIG) +#endif + +#ifdef BODCR + DEFINE(BODCR) +#else + MISSING(BODCR) +#endif + +#ifdef BPCHCD + DEFINE(BPCHCD) +#else + MISSING(BPCHCD) +#endif + +#ifdef BPCOCD + DEFINE(BPCOCD) +#else + MISSING(BPCOCD) +#endif + +#ifdef BPCR + DEFINE(BPCR) +#else + MISSING(BPCR) +#endif + +#ifdef BPDHCD + DEFINE(BPDHCD) +#else + MISSING(BPDHCD) +#endif + +#ifdef BPDOCD + DEFINE(BPDOCD) +#else + MISSING(BPDOCD) +#endif + +#ifdef BPDUV + DEFINE(BPDUV) +#else + MISSING(BPDUV) +#endif + +#ifdef BPHCTR + DEFINE(BPHCTR) +#else + MISSING(BPHCTR) +#endif + +#ifdef BPIFR + DEFINE(BPIFR) +#else + MISSING(BPIFR) +#endif + +#ifdef BPIMSK + DEFINE(BPIMSK) +#else + MISSING(BPIMSK) +#endif + +#ifdef BPIR + DEFINE(BPIR) +#else + MISSING(BPIR) +#endif + +#ifdef BPOCD + DEFINE(BPOCD) +#else + MISSING(BPOCD) +#endif + +#ifdef BPOCTR + DEFINE(BPOCTR) +#else + MISSING(BPOCTR) +#endif + +#ifdef BPPLR + DEFINE(BPPLR) +#else + MISSING(BPPLR) +#endif + +#ifdef BPSCD + DEFINE(BPSCD) +#else + MISSING(BPSCD) +#endif + +#ifdef BPSCTR + DEFINE(BPSCTR) +#else + MISSING(BPSCTR) +#endif + +#ifdef BTCNT + DEFINE(BTCNT) +#else + MISSING(BTCNT) +#endif + +#ifdef BTCR + DEFINE(BTCR) +#else + MISSING(BTCR) +#endif + +#ifdef B_DET + DEFINE(B_DET) +#else + MISSING(B_DET) +#endif + +#ifdef CADAC0 + DEFINE(CADAC0) +#else + MISSING(CADAC0) +#endif + +#ifdef CADAC1 + DEFINE(CADAC1) +#else + MISSING(CADAC1) +#endif + +#ifdef CADAC2 + DEFINE(CADAC2) +#else + MISSING(CADAC2) +#endif + +#ifdef CADAC3 + DEFINE(CADAC3) +#else + MISSING(CADAC3) +#endif + +#ifdef CADCSRA + DEFINE(CADCSRA) +#else + MISSING(CADCSRA) +#endif + +#ifdef CADCSRB + DEFINE(CADCSRB) +#else + MISSING(CADCSRB) +#endif + +#ifdef CADCSRC + DEFINE(CADCSRC) +#else + MISSING(CADCSRC) +#endif + +#ifdef CADIC + DEFINE(CADIC) +#else + MISSING(CADIC) +#endif + +#ifdef CADICH + DEFINE(CADICH) +#else + MISSING(CADICH) +#endif + +#ifdef CADICL + DEFINE(CADICL) +#else + MISSING(CADICL) +#endif + +#ifdef CADRC + DEFINE(CADRC) +#else + MISSING(CADRC) +#endif + +#ifdef CADRCC + DEFINE(CADRCC) +#else + MISSING(CADRCC) +#endif + +#ifdef CADRCL + DEFINE(CADRCL) +#else + MISSING(CADRCL) +#endif + +#ifdef CADRCLH + DEFINE(CADRCLH) +#else + MISSING(CADRCLH) +#endif + +#ifdef CADRCLL + DEFINE(CADRCLL) +#else + MISSING(CADRCLL) +#endif + +#ifdef CADRDC + DEFINE(CADRDC) +#else + MISSING(CADRDC) +#endif + +#ifdef CANBT1 + DEFINE(CANBT1) +#else + MISSING(CANBT1) +#endif + +#ifdef CANBT2 + DEFINE(CANBT2) +#else + MISSING(CANBT2) +#endif + +#ifdef CANBT3 + DEFINE(CANBT3) +#else + MISSING(CANBT3) +#endif + +#ifdef CANCDMOB + DEFINE(CANCDMOB) +#else + MISSING(CANCDMOB) +#endif + +#ifdef CANEN + DEFINE(CANEN) +#else + MISSING(CANEN) +#endif + +#ifdef CANEN1 + DEFINE(CANEN1) +#else + MISSING(CANEN1) +#endif + +#ifdef CANEN2 + DEFINE(CANEN2) +#else + MISSING(CANEN2) +#endif + +#ifdef CANGCON + DEFINE(CANGCON) +#else + MISSING(CANGCON) +#endif + +#ifdef CANGIE + DEFINE(CANGIE) +#else + MISSING(CANGIE) +#endif + +#ifdef CANGIT + DEFINE(CANGIT) +#else + MISSING(CANGIT) +#endif + +#ifdef CANGSTA + DEFINE(CANGSTA) +#else + MISSING(CANGSTA) +#endif + +#ifdef CANHPMOB + DEFINE(CANHPMOB) +#else + MISSING(CANHPMOB) +#endif + +#ifdef CANIDM1 + DEFINE(CANIDM1) +#else + MISSING(CANIDM1) +#endif + +#ifdef CANIDM2 + DEFINE(CANIDM2) +#else + MISSING(CANIDM2) +#endif + +#ifdef CANIDM3 + DEFINE(CANIDM3) +#else + MISSING(CANIDM3) +#endif + +#ifdef CANIDM4 + DEFINE(CANIDM4) +#else + MISSING(CANIDM4) +#endif + +#ifdef CANIDT1 + DEFINE(CANIDT1) +#else + MISSING(CANIDT1) +#endif + +#ifdef CANIDT2 + DEFINE(CANIDT2) +#else + MISSING(CANIDT2) +#endif + +#ifdef CANIDT3 + DEFINE(CANIDT3) +#else + MISSING(CANIDT3) +#endif + +#ifdef CANIDT4 + DEFINE(CANIDT4) +#else + MISSING(CANIDT4) +#endif + +#ifdef CANIE + DEFINE(CANIE) +#else + MISSING(CANIE) +#endif + +#ifdef CANIE1 + DEFINE(CANIE1) +#else + MISSING(CANIE1) +#endif + +#ifdef CANIE2 + DEFINE(CANIE2) +#else + MISSING(CANIE2) +#endif + +#ifdef CANMSG + DEFINE(CANMSG) +#else + MISSING(CANMSG) +#endif + +#ifdef CANPAGE + DEFINE(CANPAGE) +#else + MISSING(CANPAGE) +#endif + +#ifdef CANREC + DEFINE(CANREC) +#else + MISSING(CANREC) +#endif + +#ifdef CANSIT + DEFINE(CANSIT) +#else + MISSING(CANSIT) +#endif + +#ifdef CANSIT1 + DEFINE(CANSIT1) +#else + MISSING(CANSIT1) +#endif + +#ifdef CANSIT2 + DEFINE(CANSIT2) +#else + MISSING(CANSIT2) +#endif + +#ifdef CANSTM + DEFINE(CANSTM) +#else + MISSING(CANSTM) +#endif + +#ifdef CANSTMH + DEFINE(CANSTMH) +#else + MISSING(CANSTMH) +#endif + +#ifdef CANSTML + DEFINE(CANSTML) +#else + MISSING(CANSTML) +#endif + +#ifdef CANSTMOB + DEFINE(CANSTMOB) +#else + MISSING(CANSTMOB) +#endif + +#ifdef CANTCON + DEFINE(CANTCON) +#else + MISSING(CANTCON) +#endif + +#ifdef CANTEC + DEFINE(CANTEC) +#else + MISSING(CANTEC) +#endif + +#ifdef CANTIM + DEFINE(CANTIM) +#else + MISSING(CANTIM) +#endif + +#ifdef CANTIMH + DEFINE(CANTIMH) +#else + MISSING(CANTIMH) +#endif + +#ifdef CANTIML + DEFINE(CANTIML) +#else + MISSING(CANTIML) +#endif + +#ifdef CANTTC + DEFINE(CANTTC) +#else + MISSING(CANTTC) +#endif + +#ifdef CANTTCH + DEFINE(CANTTCH) +#else + MISSING(CANTTCH) +#endif + +#ifdef CANTTCL + DEFINE(CANTTCL) +#else + MISSING(CANTTCL) +#endif + +#ifdef CBCR + DEFINE(CBCR) +#else + MISSING(CBCR) +#endif + +#ifdef CBPTR + DEFINE(CBPTR) +#else + MISSING(CBPTR) +#endif + +#ifdef CBTR1 + DEFINE(CBTR1) +#else + MISSING(CBTR1) +#endif + +#ifdef CBTR2 + DEFINE(CBTR2) +#else + MISSING(CBTR2) +#endif + +#ifdef CBTR3 + DEFINE(CBTR3) +#else + MISSING(CBTR3) +#endif + +#ifdef CCA_THRES + DEFINE(CCA_THRES) +#else + MISSING(CCA_THRES) +#endif + +#ifdef CCFLG + DEFINE(CCFLG) +#else + MISSING(CCFLG) +#endif + +#ifdef CCISR + DEFINE(CCISR) +#else + MISSING(CCISR) +#endif + +#ifdef CCP + DEFINE(CCP) +#else + MISSING(CCP) +#endif + +#ifdef CCSR + DEFINE(CCSR) +#else + MISSING(CCSR) +#endif + +#ifdef CDIVCAN + DEFINE(CDIVCAN) +#else + MISSING(CDIVCAN) +#endif + +#ifdef CEFR + DEFINE(CEFR) +#else + MISSING(CEFR) +#endif + +#ifdef CGPDDR + DEFINE(CGPDDR) +#else + MISSING(CGPDDR) +#endif + +#ifdef CGPPIN + DEFINE(CGPPIN) +#else + MISSING(CGPPIN) +#endif + +#ifdef CGPPORT + DEFINE(CGPPORT) +#else + MISSING(CGPPORT) +#endif + +#ifdef CHGDCSR + DEFINE(CHGDCSR) +#else + MISSING(CHGDCSR) +#endif + +#ifdef CIDAH0 + DEFINE(CIDAH0) +#else + MISSING(CIDAH0) +#endif + +#ifdef CIDAH1 + DEFINE(CIDAH1) +#else + MISSING(CIDAH1) +#endif + +#ifdef CIER + DEFINE(CIER) +#else + MISSING(CIER) +#endif + +#ifdef CKSEL0 + DEFINE(CKSEL0) +#else + MISSING(CKSEL0) +#endif + +#ifdef CKSEL1 + DEFINE(CKSEL1) +#else + MISSING(CKSEL1) +#endif + +#ifdef CKSTA + DEFINE(CKSTA) +#else + MISSING(CKSTA) +#endif + +#ifdef CLKCSR + DEFINE(CLKCSR) +#else + MISSING(CLKCSR) +#endif + +#ifdef CLKMSR + DEFINE(CLKMSR) +#else + MISSING(CLKMSR) +#endif + +#ifdef CLKPR + DEFINE(CLKPR) +#else + MISSING(CLKPR) +#endif + +#ifdef CLKPSR + DEFINE(CLKPSR) +#else + MISSING(CLKPSR) +#endif + +#ifdef CLKSEL0 + DEFINE(CLKSEL0) +#else + MISSING(CLKSEL0) +#endif + +#ifdef CLKSEL1 + DEFINE(CLKSEL1) +#else + MISSING(CLKSEL1) +#endif + +#ifdef CLKSELR + DEFINE(CLKSELR) +#else + MISSING(CLKSELR) +#endif + +#ifdef CLKSTA + DEFINE(CLKSTA) +#else + MISSING(CLKSTA) +#endif + +#ifdef CLK_CNTR + DEFINE(CLK_CNTR) +#else + MISSING(CLK_CNTR) +#endif + +#ifdef CLK_CTRL + DEFINE(CLK_CTRL) +#else + MISSING(CLK_CTRL) +#endif + +#ifdef CLK_LOCK + DEFINE(CLK_LOCK) +#else + MISSING(CLK_LOCK) +#endif + +#ifdef CLK_PSCTRL + DEFINE(CLK_PSCTRL) +#else + MISSING(CLK_PSCTRL) +#endif + +#ifdef CLK_RTCCTRL + DEFINE(CLK_RTCCTRL) +#else + MISSING(CLK_RTCCTRL) +#endif + +#ifdef CLK_USBCTRL + DEFINE(CLK_USBCTRL) +#else + MISSING(CLK_USBCTRL) +#endif + +#ifdef CMCR + DEFINE(CMCR) +#else + MISSING(CMCR) +#endif + +#ifdef CMIMR + DEFINE(CMIMR) +#else + MISSING(CMIMR) +#endif + +#ifdef CMSR + DEFINE(CMSR) +#else + MISSING(CMSR) +#endif + +#ifdef COSDAC + DEFINE(COSDAC) +#else + MISSING(COSDAC) +#endif + +#ifdef COSDACH + DEFINE(COSDACH) +#else + MISSING(COSDACH) +#endif + +#ifdef COSDACL + DEFINE(COSDACL) +#else + MISSING(COSDACL) +#endif + +#ifdef CPU_CCP + DEFINE(CPU_CCP) +#else + MISSING(CPU_CCP) +#endif + +#ifdef CPU_EIND + DEFINE(CPU_EIND) +#else + MISSING(CPU_EIND) +#endif + +#ifdef CPU_RAMPD + DEFINE(CPU_RAMPD) +#else + MISSING(CPU_RAMPD) +#endif + +#ifdef CPU_RAMPX + DEFINE(CPU_RAMPX) +#else + MISSING(CPU_RAMPX) +#endif + +#ifdef CPU_RAMPY + DEFINE(CPU_RAMPY) +#else + MISSING(CPU_RAMPY) +#endif + +#ifdef CPU_RAMPZ + DEFINE(CPU_RAMPZ) +#else + MISSING(CPU_RAMPZ) +#endif + +#ifdef CPU_SPH + DEFINE(CPU_SPH) +#else + MISSING(CPU_SPH) +#endif + +#ifdef CPU_SPL + DEFINE(CPU_SPL) +#else + MISSING(CPU_SPL) +#endif + +#ifdef CPU_SREG + DEFINE(CPU_SREG) +#else + MISSING(CPU_SREG) +#endif + +#ifdef CRAFEN + DEFINE(CRAFEN) +#else + MISSING(CRAFEN) +#endif + +#ifdef CRC_CHECKSUM0 + DEFINE(CRC_CHECKSUM0) +#else + MISSING(CRC_CHECKSUM0) +#endif + +#ifdef CRC_CHECKSUM1 + DEFINE(CRC_CHECKSUM1) +#else + MISSING(CRC_CHECKSUM1) +#endif + +#ifdef CRC_CHECKSUM2 + DEFINE(CRC_CHECKSUM2) +#else + MISSING(CRC_CHECKSUM2) +#endif + +#ifdef CRC_CHECKSUM3 + DEFINE(CRC_CHECKSUM3) +#else + MISSING(CRC_CHECKSUM3) +#endif + +#ifdef CRC_CTRL + DEFINE(CRC_CTRL) +#else + MISSING(CRC_CTRL) +#endif + +#ifdef CRC_DATAIN + DEFINE(CRC_DATAIN) +#else + MISSING(CRC_DATAIN) +#endif + +#ifdef CRC_STATUS + DEFINE(CRC_STATUS) +#else + MISSING(CRC_STATUS) +#endif + +#ifdef CRXERR + DEFINE(CRXERR) +#else + MISSING(CRXERR) +#endif + +#ifdef CSMA_BE + DEFINE(CSMA_BE) +#else + MISSING(CSMA_BE) +#endif + +#ifdef CSMA_SEED_0 + DEFINE(CSMA_SEED_0) +#else + MISSING(CSMA_SEED_0) +#endif + +#ifdef CSMA_SEED_1 + DEFINE(CSMA_SEED_1) +#else + MISSING(CSMA_SEED_1) +#endif + +#ifdef CTARR + DEFINE(CTARR) +#else + MISSING(CTARR) +#endif + +#ifdef CTXERR + DEFINE(CTXERR) +#else + MISSING(CTXERR) +#endif + +#ifdef CURIRED + DEFINE(CURIRED) +#else + MISSING(CURIRED) +#endif + +#ifdef CURIRUN + DEFINE(CURIRUN) +#else + MISSING(CURIRUN) +#endif + +#ifdef CURRDLY + DEFINE(CURRDLY) +#else + MISSING(CURRDLY) +#endif + +#ifdef CVER + DEFINE(CVER) +#else + MISSING(CVER) +#endif + +#ifdef DAC + DEFINE(DAC) +#else + MISSING(DAC) +#endif + +#ifdef DACA_CH0DATA + DEFINE(DACA_CH0DATA) +#else + MISSING(DACA_CH0DATA) +#endif + +#ifdef DACA_CH0GAINCAL + DEFINE(DACA_CH0GAINCAL) +#else + MISSING(DACA_CH0GAINCAL) +#endif + +#ifdef DACA_CH0OFFSETCAL + DEFINE(DACA_CH0OFFSETCAL) +#else + MISSING(DACA_CH0OFFSETCAL) +#endif + +#ifdef DACA_CH1DATA + DEFINE(DACA_CH1DATA) +#else + MISSING(DACA_CH1DATA) +#endif + +#ifdef DACA_CH1GAINCAL + DEFINE(DACA_CH1GAINCAL) +#else + MISSING(DACA_CH1GAINCAL) +#endif + +#ifdef DACA_CH1OFFSETCAL + DEFINE(DACA_CH1OFFSETCAL) +#else + MISSING(DACA_CH1OFFSETCAL) +#endif + +#ifdef DACA_CTRLA + DEFINE(DACA_CTRLA) +#else + MISSING(DACA_CTRLA) +#endif + +#ifdef DACA_CTRLB + DEFINE(DACA_CTRLB) +#else + MISSING(DACA_CTRLB) +#endif + +#ifdef DACA_CTRLC + DEFINE(DACA_CTRLC) +#else + MISSING(DACA_CTRLC) +#endif + +#ifdef DACA_EVCTRL + DEFINE(DACA_EVCTRL) +#else + MISSING(DACA_EVCTRL) +#endif + +#ifdef DACA_GAINCAL + DEFINE(DACA_GAINCAL) +#else + MISSING(DACA_GAINCAL) +#endif + +#ifdef DACA_OFFSETCAL + DEFINE(DACA_OFFSETCAL) +#else + MISSING(DACA_OFFSETCAL) +#endif + +#ifdef DACA_STATUS + DEFINE(DACA_STATUS) +#else + MISSING(DACA_STATUS) +#endif + +#ifdef DACA_TIMCTRL + DEFINE(DACA_TIMCTRL) +#else + MISSING(DACA_TIMCTRL) +#endif + +#ifdef DACB_CH0DATA + DEFINE(DACB_CH0DATA) +#else + MISSING(DACB_CH0DATA) +#endif + +#ifdef DACB_CH0GAINCAL + DEFINE(DACB_CH0GAINCAL) +#else + MISSING(DACB_CH0GAINCAL) +#endif + +#ifdef DACB_CH0OFFSETCAL + DEFINE(DACB_CH0OFFSETCAL) +#else + MISSING(DACB_CH0OFFSETCAL) +#endif + +#ifdef DACB_CH1DATA + DEFINE(DACB_CH1DATA) +#else + MISSING(DACB_CH1DATA) +#endif + +#ifdef DACB_CH1GAINCAL + DEFINE(DACB_CH1GAINCAL) +#else + MISSING(DACB_CH1GAINCAL) +#endif + +#ifdef DACB_CH1OFFSETCAL + DEFINE(DACB_CH1OFFSETCAL) +#else + MISSING(DACB_CH1OFFSETCAL) +#endif + +#ifdef DACB_CTRLA + DEFINE(DACB_CTRLA) +#else + MISSING(DACB_CTRLA) +#endif + +#ifdef DACB_CTRLB + DEFINE(DACB_CTRLB) +#else + MISSING(DACB_CTRLB) +#endif + +#ifdef DACB_CTRLC + DEFINE(DACB_CTRLC) +#else + MISSING(DACB_CTRLC) +#endif + +#ifdef DACB_EVCTRL + DEFINE(DACB_EVCTRL) +#else + MISSING(DACB_EVCTRL) +#endif + +#ifdef DACB_GAINCAL + DEFINE(DACB_GAINCAL) +#else + MISSING(DACB_GAINCAL) +#endif + +#ifdef DACB_OFFSETCAL + DEFINE(DACB_OFFSETCAL) +#else + MISSING(DACB_OFFSETCAL) +#endif + +#ifdef DACB_STATUS + DEFINE(DACB_STATUS) +#else + MISSING(DACB_STATUS) +#endif + +#ifdef DACB_TIMCTRL + DEFINE(DACB_TIMCTRL) +#else + MISSING(DACB_TIMCTRL) +#endif + +#ifdef DACCTRL + DEFINE(DACCTRL) +#else + MISSING(DACCTRL) +#endif + +#ifdef DACH + DEFINE(DACH) +#else + MISSING(DACH) +#endif + +#ifdef DACL + DEFINE(DACL) +#else + MISSING(DACL) +#endif + +#ifdef DACON + DEFINE(DACON) +#else + MISSING(DACON) +#endif + +#ifdef DACVAL + DEFINE(DACVAL) +#else + MISSING(DACVAL) +#endif + +#ifdef DACVALH + DEFINE(DACVALH) +#else + MISSING(DACVALH) +#endif + +#ifdef DACVALHI + DEFINE(DACVALHI) +#else + MISSING(DACVALHI) +#endif + +#ifdef DACVALL + DEFINE(DACVALL) +#else + MISSING(DACVALL) +#endif + +#ifdef DACVALLO + DEFINE(DACVALLO) +#else + MISSING(DACVALLO) +#endif + +#ifdef DCCR + DEFINE(DCCR) +#else + MISSING(DCCR) +#endif + +#ifdef DDRA + DEFINE(DDRA) +#else + MISSING(DDRA) +#endif + +#ifdef DDRB + DEFINE(DDRB) +#else + MISSING(DDRB) +#endif + +#ifdef DDRC + DEFINE(DDRC) +#else + MISSING(DDRC) +#endif + +#ifdef DDRD + DEFINE(DDRD) +#else + MISSING(DDRD) +#endif + +#ifdef DDRE + DEFINE(DDRE) +#else + MISSING(DDRE) +#endif + +#ifdef DDRF + DEFINE(DDRF) +#else + MISSING(DDRF) +#endif + +#ifdef DDRG + DEFINE(DDRG) +#else + MISSING(DDRG) +#endif + +#ifdef DDRH + DEFINE(DDRH) +#else + MISSING(DDRH) +#endif + +#ifdef DDRJ + DEFINE(DDRJ) +#else + MISSING(DDRJ) +#endif + +#ifdef DDRK + DEFINE(DDRK) +#else + MISSING(DDRK) +#endif + +#ifdef DDRL + DEFINE(DDRL) +#else + MISSING(DDRL) +#endif + +#ifdef DEEAR + DEFINE(DEEAR) +#else + MISSING(DEEAR) +#endif + +#ifdef DEEARL + DEFINE(DEEARL) +#else + MISSING(DEEARL) +#endif + +#ifdef DEECR + DEFINE(DEECR) +#else + MISSING(DEECR) +#endif + +#ifdef DEEDR + DEFINE(DEEDR) +#else + MISSING(DEEDR) +#endif + +#ifdef DFLLRC2M_CALA + DEFINE(DFLLRC2M_CALA) +#else + MISSING(DFLLRC2M_CALA) +#endif + +#ifdef DFLLRC2M_CALB + DEFINE(DFLLRC2M_CALB) +#else + MISSING(DFLLRC2M_CALB) +#endif + +#ifdef DFLLRC2M_COMP0 + DEFINE(DFLLRC2M_COMP0) +#else + MISSING(DFLLRC2M_COMP0) +#endif + +#ifdef DFLLRC2M_COMP1 + DEFINE(DFLLRC2M_COMP1) +#else + MISSING(DFLLRC2M_COMP1) +#endif + +#ifdef DFLLRC2M_COMP2 + DEFINE(DFLLRC2M_COMP2) +#else + MISSING(DFLLRC2M_COMP2) +#endif + +#ifdef DFLLRC2M_CTRL + DEFINE(DFLLRC2M_CTRL) +#else + MISSING(DFLLRC2M_CTRL) +#endif + +#ifdef DFLLRC32M_CALA + DEFINE(DFLLRC32M_CALA) +#else + MISSING(DFLLRC32M_CALA) +#endif + +#ifdef DFLLRC32M_CALB + DEFINE(DFLLRC32M_CALB) +#else + MISSING(DFLLRC32M_CALB) +#endif + +#ifdef DFLLRC32M_COMP0 + DEFINE(DFLLRC32M_COMP0) +#else + MISSING(DFLLRC32M_COMP0) +#endif + +#ifdef DFLLRC32M_COMP1 + DEFINE(DFLLRC32M_COMP1) +#else + MISSING(DFLLRC32M_COMP1) +#endif + +#ifdef DFLLRC32M_COMP2 + DEFINE(DFLLRC32M_COMP2) +#else + MISSING(DFLLRC32M_COMP2) +#endif + +#ifdef DFLLRC32M_CTRL + DEFINE(DFLLRC32M_CTRL) +#else + MISSING(DFLLRC32M_CTRL) +#endif + +#ifdef DIDR + DEFINE(DIDR) +#else + MISSING(DIDR) +#endif + +#ifdef DIDR0 + DEFINE(DIDR0) +#else + MISSING(DIDR0) +#endif + +#ifdef DIDR1 + DEFINE(DIDR1) +#else + MISSING(DIDR1) +#endif + +#ifdef DIDR2 + DEFINE(DIDR2) +#else + MISSING(DIDR2) +#endif + +#ifdef DMA_CH0_ADDRCTRL + DEFINE(DMA_CH0_ADDRCTRL) +#else + MISSING(DMA_CH0_ADDRCTRL) +#endif + +#ifdef DMA_CH0_CTRLA + DEFINE(DMA_CH0_CTRLA) +#else + MISSING(DMA_CH0_CTRLA) +#endif + +#ifdef DMA_CH0_CTRLB + DEFINE(DMA_CH0_CTRLB) +#else + MISSING(DMA_CH0_CTRLB) +#endif + +#ifdef DMA_CH0_DESTADDR0 + DEFINE(DMA_CH0_DESTADDR0) +#else + MISSING(DMA_CH0_DESTADDR0) +#endif + +#ifdef DMA_CH0_DESTADDR1 + DEFINE(DMA_CH0_DESTADDR1) +#else + MISSING(DMA_CH0_DESTADDR1) +#endif + +#ifdef DMA_CH0_DESTADDR2 + DEFINE(DMA_CH0_DESTADDR2) +#else + MISSING(DMA_CH0_DESTADDR2) +#endif + +#ifdef DMA_CH0_REPCNT + DEFINE(DMA_CH0_REPCNT) +#else + MISSING(DMA_CH0_REPCNT) +#endif + +#ifdef DMA_CH0_SRCADDR0 + DEFINE(DMA_CH0_SRCADDR0) +#else + MISSING(DMA_CH0_SRCADDR0) +#endif + +#ifdef DMA_CH0_SRCADDR1 + DEFINE(DMA_CH0_SRCADDR1) +#else + MISSING(DMA_CH0_SRCADDR1) +#endif + +#ifdef DMA_CH0_SRCADDR2 + DEFINE(DMA_CH0_SRCADDR2) +#else + MISSING(DMA_CH0_SRCADDR2) +#endif + +#ifdef DMA_CH0_TRFCNT + DEFINE(DMA_CH0_TRFCNT) +#else + MISSING(DMA_CH0_TRFCNT) +#endif + +#ifdef DMA_CH0_TRIGSRC + DEFINE(DMA_CH0_TRIGSRC) +#else + MISSING(DMA_CH0_TRIGSRC) +#endif + +#ifdef DMA_CH1_ADDRCTRL + DEFINE(DMA_CH1_ADDRCTRL) +#else + MISSING(DMA_CH1_ADDRCTRL) +#endif + +#ifdef DMA_CH1_CTRLA + DEFINE(DMA_CH1_CTRLA) +#else + MISSING(DMA_CH1_CTRLA) +#endif + +#ifdef DMA_CH1_CTRLB + DEFINE(DMA_CH1_CTRLB) +#else + MISSING(DMA_CH1_CTRLB) +#endif + +#ifdef DMA_CH1_DESTADDR0 + DEFINE(DMA_CH1_DESTADDR0) +#else + MISSING(DMA_CH1_DESTADDR0) +#endif + +#ifdef DMA_CH1_DESTADDR1 + DEFINE(DMA_CH1_DESTADDR1) +#else + MISSING(DMA_CH1_DESTADDR1) +#endif + +#ifdef DMA_CH1_DESTADDR2 + DEFINE(DMA_CH1_DESTADDR2) +#else + MISSING(DMA_CH1_DESTADDR2) +#endif + +#ifdef DMA_CH1_REPCNT + DEFINE(DMA_CH1_REPCNT) +#else + MISSING(DMA_CH1_REPCNT) +#endif + +#ifdef DMA_CH1_SRCADDR0 + DEFINE(DMA_CH1_SRCADDR0) +#else + MISSING(DMA_CH1_SRCADDR0) +#endif + +#ifdef DMA_CH1_SRCADDR1 + DEFINE(DMA_CH1_SRCADDR1) +#else + MISSING(DMA_CH1_SRCADDR1) +#endif + +#ifdef DMA_CH1_SRCADDR2 + DEFINE(DMA_CH1_SRCADDR2) +#else + MISSING(DMA_CH1_SRCADDR2) +#endif + +#ifdef DMA_CH1_TRFCNT + DEFINE(DMA_CH1_TRFCNT) +#else + MISSING(DMA_CH1_TRFCNT) +#endif + +#ifdef DMA_CH1_TRIGSRC + DEFINE(DMA_CH1_TRIGSRC) +#else + MISSING(DMA_CH1_TRIGSRC) +#endif + +#ifdef DMA_CH2_ADDRCTRL + DEFINE(DMA_CH2_ADDRCTRL) +#else + MISSING(DMA_CH2_ADDRCTRL) +#endif + +#ifdef DMA_CH2_CTRLA + DEFINE(DMA_CH2_CTRLA) +#else + MISSING(DMA_CH2_CTRLA) +#endif + +#ifdef DMA_CH2_CTRLB + DEFINE(DMA_CH2_CTRLB) +#else + MISSING(DMA_CH2_CTRLB) +#endif + +#ifdef DMA_CH2_DESTADDR0 + DEFINE(DMA_CH2_DESTADDR0) +#else + MISSING(DMA_CH2_DESTADDR0) +#endif + +#ifdef DMA_CH2_DESTADDR1 + DEFINE(DMA_CH2_DESTADDR1) +#else + MISSING(DMA_CH2_DESTADDR1) +#endif + +#ifdef DMA_CH2_DESTADDR2 + DEFINE(DMA_CH2_DESTADDR2) +#else + MISSING(DMA_CH2_DESTADDR2) +#endif + +#ifdef DMA_CH2_REPCNT + DEFINE(DMA_CH2_REPCNT) +#else + MISSING(DMA_CH2_REPCNT) +#endif + +#ifdef DMA_CH2_SRCADDR0 + DEFINE(DMA_CH2_SRCADDR0) +#else + MISSING(DMA_CH2_SRCADDR0) +#endif + +#ifdef DMA_CH2_SRCADDR1 + DEFINE(DMA_CH2_SRCADDR1) +#else + MISSING(DMA_CH2_SRCADDR1) +#endif + +#ifdef DMA_CH2_SRCADDR2 + DEFINE(DMA_CH2_SRCADDR2) +#else + MISSING(DMA_CH2_SRCADDR2) +#endif + +#ifdef DMA_CH2_TRFCNT + DEFINE(DMA_CH2_TRFCNT) +#else + MISSING(DMA_CH2_TRFCNT) +#endif + +#ifdef DMA_CH2_TRIGSRC + DEFINE(DMA_CH2_TRIGSRC) +#else + MISSING(DMA_CH2_TRIGSRC) +#endif + +#ifdef DMA_CH3_ADDRCTRL + DEFINE(DMA_CH3_ADDRCTRL) +#else + MISSING(DMA_CH3_ADDRCTRL) +#endif + +#ifdef DMA_CH3_CTRLA + DEFINE(DMA_CH3_CTRLA) +#else + MISSING(DMA_CH3_CTRLA) +#endif + +#ifdef DMA_CH3_CTRLB + DEFINE(DMA_CH3_CTRLB) +#else + MISSING(DMA_CH3_CTRLB) +#endif + +#ifdef DMA_CH3_DESTADDR0 + DEFINE(DMA_CH3_DESTADDR0) +#else + MISSING(DMA_CH3_DESTADDR0) +#endif + +#ifdef DMA_CH3_DESTADDR1 + DEFINE(DMA_CH3_DESTADDR1) +#else + MISSING(DMA_CH3_DESTADDR1) +#endif + +#ifdef DMA_CH3_DESTADDR2 + DEFINE(DMA_CH3_DESTADDR2) +#else + MISSING(DMA_CH3_DESTADDR2) +#endif + +#ifdef DMA_CH3_REPCNT + DEFINE(DMA_CH3_REPCNT) +#else + MISSING(DMA_CH3_REPCNT) +#endif + +#ifdef DMA_CH3_SRCADDR0 + DEFINE(DMA_CH3_SRCADDR0) +#else + MISSING(DMA_CH3_SRCADDR0) +#endif + +#ifdef DMA_CH3_SRCADDR1 + DEFINE(DMA_CH3_SRCADDR1) +#else + MISSING(DMA_CH3_SRCADDR1) +#endif + +#ifdef DMA_CH3_SRCADDR2 + DEFINE(DMA_CH3_SRCADDR2) +#else + MISSING(DMA_CH3_SRCADDR2) +#endif + +#ifdef DMA_CH3_TRFCNT + DEFINE(DMA_CH3_TRFCNT) +#else + MISSING(DMA_CH3_TRFCNT) +#endif + +#ifdef DMA_CH3_TRIGSRC + DEFINE(DMA_CH3_TRIGSRC) +#else + MISSING(DMA_CH3_TRIGSRC) +#endif + +#ifdef DMA_CTRL + DEFINE(DMA_CTRL) +#else + MISSING(DMA_CTRL) +#endif + +#ifdef DMA_INTFLAGS + DEFINE(DMA_INTFLAGS) +#else + MISSING(DMA_INTFLAGS) +#endif + +#ifdef DMA_STATUS + DEFINE(DMA_STATUS) +#else + MISSING(DMA_STATUS) +#endif + +#ifdef DMA_TEMP + DEFINE(DMA_TEMP) +#else + MISSING(DMA_TEMP) +#endif + +#ifdef DPDS0 + DEFINE(DPDS0) +#else + MISSING(DPDS0) +#endif + +#ifdef DPDS1 + DEFINE(DPDS1) +#else + MISSING(DPDS1) +#endif + +#ifdef DRTRAM0 + DEFINE(DRTRAM0) +#else + MISSING(DRTRAM0) +#endif + +#ifdef DRTRAM1 + DEFINE(DRTRAM1) +#else + MISSING(DRTRAM1) +#endif + +#ifdef DRTRAM2 + DEFINE(DRTRAM2) +#else + MISSING(DRTRAM2) +#endif + +#ifdef DRTRAM3 + DEFINE(DRTRAM3) +#else + MISSING(DRTRAM3) +#endif + +#ifdef DT1 + DEFINE(DT1) +#else + MISSING(DT1) +#endif + +#ifdef DT1A + DEFINE(DT1A) +#else + MISSING(DT1A) +#endif + +#ifdef DT1B + DEFINE(DT1B) +#else + MISSING(DT1B) +#endif + +#ifdef DT4 + DEFINE(DT4) +#else + MISSING(DT4) +#endif + +#ifdef DTPS1 + DEFINE(DTPS1) +#else + MISSING(DTPS1) +#endif + +#ifdef DWDR + DEFINE(DWDR) +#else + MISSING(DWDR) +#endif + +#ifdef EBI_CS0_BASEADDR + DEFINE(EBI_CS0_BASEADDR) +#else + MISSING(EBI_CS0_BASEADDR) +#endif + +#ifdef EBI_CS0_CTRLA + DEFINE(EBI_CS0_CTRLA) +#else + MISSING(EBI_CS0_CTRLA) +#endif + +#ifdef EBI_CS0_CTRLB + DEFINE(EBI_CS0_CTRLB) +#else + MISSING(EBI_CS0_CTRLB) +#endif + +#ifdef EBI_CS1_BASEADDR + DEFINE(EBI_CS1_BASEADDR) +#else + MISSING(EBI_CS1_BASEADDR) +#endif + +#ifdef EBI_CS1_CTRLA + DEFINE(EBI_CS1_CTRLA) +#else + MISSING(EBI_CS1_CTRLA) +#endif + +#ifdef EBI_CS1_CTRLB + DEFINE(EBI_CS1_CTRLB) +#else + MISSING(EBI_CS1_CTRLB) +#endif + +#ifdef EBI_CS2_BASEADDR + DEFINE(EBI_CS2_BASEADDR) +#else + MISSING(EBI_CS2_BASEADDR) +#endif + +#ifdef EBI_CS2_CTRLA + DEFINE(EBI_CS2_CTRLA) +#else + MISSING(EBI_CS2_CTRLA) +#endif + +#ifdef EBI_CS2_CTRLB + DEFINE(EBI_CS2_CTRLB) +#else + MISSING(EBI_CS2_CTRLB) +#endif + +#ifdef EBI_CS3_BASEADDR + DEFINE(EBI_CS3_BASEADDR) +#else + MISSING(EBI_CS3_BASEADDR) +#endif + +#ifdef EBI_CS3_CTRLA + DEFINE(EBI_CS3_CTRLA) +#else + MISSING(EBI_CS3_CTRLA) +#endif + +#ifdef EBI_CS3_CTRLB + DEFINE(EBI_CS3_CTRLB) +#else + MISSING(EBI_CS3_CTRLB) +#endif + +#ifdef EBI_CTRL + DEFINE(EBI_CTRL) +#else + MISSING(EBI_CTRL) +#endif + +#ifdef EBI_INITDLY + DEFINE(EBI_INITDLY) +#else + MISSING(EBI_INITDLY) +#endif + +#ifdef EBI_REFRESH + DEFINE(EBI_REFRESH) +#else + MISSING(EBI_REFRESH) +#endif + +#ifdef EBI_SDRAMCTRLA + DEFINE(EBI_SDRAMCTRLA) +#else + MISSING(EBI_SDRAMCTRLA) +#endif + +#ifdef EBI_SDRAMCTRLB + DEFINE(EBI_SDRAMCTRLB) +#else + MISSING(EBI_SDRAMCTRLB) +#endif + +#ifdef EBI_SDRAMCTRLC + DEFINE(EBI_SDRAMCTRLC) +#else + MISSING(EBI_SDRAMCTRLC) +#endif + +#ifdef EEAR + DEFINE(EEAR) +#else + MISSING(EEAR) +#endif + +#ifdef EEARH + DEFINE(EEARH) +#else + MISSING(EEARH) +#endif + +#ifdef EEARL + DEFINE(EEARL) +#else + MISSING(EEARL) +#endif + +#ifdef EECR + DEFINE(EECR) +#else + MISSING(EECR) +#endif + +#ifdef EEDR + DEFINE(EEDR) +#else + MISSING(EEDR) +#endif + +#ifdef EICR + DEFINE(EICR) +#else + MISSING(EICR) +#endif + +#ifdef EICRA + DEFINE(EICRA) +#else + MISSING(EICRA) +#endif + +#ifdef EICRB + DEFINE(EICRB) +#else + MISSING(EICRB) +#endif + +#ifdef EIFR + DEFINE(EIFR) +#else + MISSING(EIFR) +#endif + +#ifdef EIMF + DEFINE(EIMF) +#else + MISSING(EIMF) +#endif + +#ifdef EIMSK + DEFINE(EIMSK) +#else + MISSING(EIMSK) +#endif + +#ifdef EIND + DEFINE(EIND) +#else + MISSING(EIND) +#endif + +#ifdef EIRR + DEFINE(EIRR) +#else + MISSING(EIRR) +#endif + +#ifdef EMCUCR + DEFINE(EMCUCR) +#else + MISSING(EMCUCR) +#endif + +#ifdef ETIFR + DEFINE(ETIFR) +#else + MISSING(ETIFR) +#endif + +#ifdef ETIMSK + DEFINE(ETIMSK) +#else + MISSING(ETIMSK) +#endif + +#ifdef EUCSRA + DEFINE(EUCSRA) +#else + MISSING(EUCSRA) +#endif + +#ifdef EUCSRB + DEFINE(EUCSRB) +#else + MISSING(EUCSRB) +#endif + +#ifdef EUCSRC + DEFINE(EUCSRC) +#else + MISSING(EUCSRC) +#endif + +#ifdef EUDR + DEFINE(EUDR) +#else + MISSING(EUDR) +#endif + +#ifdef EVSYS_CH0CTRL + DEFINE(EVSYS_CH0CTRL) +#else + MISSING(EVSYS_CH0CTRL) +#endif + +#ifdef EVSYS_CH0MUX + DEFINE(EVSYS_CH0MUX) +#else + MISSING(EVSYS_CH0MUX) +#endif + +#ifdef EVSYS_CH1CTRL + DEFINE(EVSYS_CH1CTRL) +#else + MISSING(EVSYS_CH1CTRL) +#endif + +#ifdef EVSYS_CH1MUX + DEFINE(EVSYS_CH1MUX) +#else + MISSING(EVSYS_CH1MUX) +#endif + +#ifdef EVSYS_CH2CTRL + DEFINE(EVSYS_CH2CTRL) +#else + MISSING(EVSYS_CH2CTRL) +#endif + +#ifdef EVSYS_CH2MUX + DEFINE(EVSYS_CH2MUX) +#else + MISSING(EVSYS_CH2MUX) +#endif + +#ifdef EVSYS_CH3CTRL + DEFINE(EVSYS_CH3CTRL) +#else + MISSING(EVSYS_CH3CTRL) +#endif + +#ifdef EVSYS_CH3MUX + DEFINE(EVSYS_CH3MUX) +#else + MISSING(EVSYS_CH3MUX) +#endif + +#ifdef EVSYS_CH4CTRL + DEFINE(EVSYS_CH4CTRL) +#else + MISSING(EVSYS_CH4CTRL) +#endif + +#ifdef EVSYS_CH4MUX + DEFINE(EVSYS_CH4MUX) +#else + MISSING(EVSYS_CH4MUX) +#endif + +#ifdef EVSYS_CH5CTRL + DEFINE(EVSYS_CH5CTRL) +#else + MISSING(EVSYS_CH5CTRL) +#endif + +#ifdef EVSYS_CH5MUX + DEFINE(EVSYS_CH5MUX) +#else + MISSING(EVSYS_CH5MUX) +#endif + +#ifdef EVSYS_CH6CTRL + DEFINE(EVSYS_CH6CTRL) +#else + MISSING(EVSYS_CH6CTRL) +#endif + +#ifdef EVSYS_CH6MUX + DEFINE(EVSYS_CH6MUX) +#else + MISSING(EVSYS_CH6MUX) +#endif + +#ifdef EVSYS_CH7CTRL + DEFINE(EVSYS_CH7CTRL) +#else + MISSING(EVSYS_CH7CTRL) +#endif + +#ifdef EVSYS_CH7MUX + DEFINE(EVSYS_CH7MUX) +#else + MISSING(EVSYS_CH7MUX) +#endif + +#ifdef EVSYS_DATA + DEFINE(EVSYS_DATA) +#else + MISSING(EVSYS_DATA) +#endif + +#ifdef EVSYS_STROBE + DEFINE(EVSYS_STROBE) +#else + MISSING(EVSYS_STROBE) +#endif + +#ifdef EXOCR1A + DEFINE(EXOCR1A) +#else + MISSING(EXOCR1A) +#endif + +#ifdef EXOCR1AH + DEFINE(EXOCR1AH) +#else + MISSING(EXOCR1AH) +#endif + +#ifdef EXOCR1AL + DEFINE(EXOCR1AL) +#else + MISSING(EXOCR1AL) +#endif + +#ifdef EXOCR1B + DEFINE(EXOCR1B) +#else + MISSING(EXOCR1B) +#endif + +#ifdef EXOCR1BH + DEFINE(EXOCR1BH) +#else + MISSING(EXOCR1BH) +#endif + +#ifdef EXOCR1BL + DEFINE(EXOCR1BL) +#else + MISSING(EXOCR1BL) +#endif + +#ifdef EXTCCR0 + DEFINE(EXTCCR0) +#else + MISSING(EXTCCR0) +#endif + +#ifdef EXTCCR1A + DEFINE(EXTCCR1A) +#else + MISSING(EXTCCR1A) +#endif + +#ifdef EXTCCR1B + DEFINE(EXTCCR1B) +#else + MISSING(EXTCCR1B) +#endif + +#ifdef EXTCNT + DEFINE(EXTCNT) +#else + MISSING(EXTCNT) +#endif + +#ifdef EXTCNT1 + DEFINE(EXTCNT1) +#else + MISSING(EXTCNT1) +#endif + +#ifdef EXTCNT1H + DEFINE(EXTCNT1H) +#else + MISSING(EXTCNT1H) +#endif + +#ifdef EXTCNT1L + DEFINE(EXTCNT1L) +#else + MISSING(EXTCNT1L) +#endif + +#ifdef EXTIFR + DEFINE(EXTIFR) +#else + MISSING(EXTIFR) +#endif + +#ifdef EXTIMSK + DEFINE(EXTIMSK) +#else + MISSING(EXTIMSK) +#endif + +#ifdef FCSR + DEFINE(FCSR) +#else + MISSING(FCSR) +#endif + +#ifdef FISCR + DEFINE(FISCR) +#else + MISSING(FISCR) +#endif + +#ifdef FISUA + DEFINE(FISUA) +#else + MISSING(FISUA) +#endif + +#ifdef FISUB + DEFINE(FISUB) +#else + MISSING(FISUB) +#endif + +#ifdef FISUC + DEFINE(FISUC) +#else + MISSING(FISUC) +#endif + +#ifdef FISUD + DEFINE(FISUD) +#else + MISSING(FISUD) +#endif + +#ifdef FOSCCAL + DEFINE(FOSCCAL) +#else + MISSING(FOSCCAL) +#endif + +#ifdef FPGAD + DEFINE(FPGAD) +#else + MISSING(FPGAD) +#endif + +#ifdef FPGAX + DEFINE(FPGAX) +#else + MISSING(FPGAX) +#endif + +#ifdef FPGAY + DEFINE(FPGAY) +#else + MISSING(FPGAY) +#endif + +#ifdef FPGAZ + DEFINE(FPGAZ) +#else + MISSING(FPGAZ) +#endif + +#ifdef FRCCAL + DEFINE(FRCCAL) +#else + MISSING(FRCCAL) +#endif + +#ifdef FTN_CTRL + DEFINE(FTN_CTRL) +#else + MISSING(FTN_CTRL) +#endif + +#ifdef GAINDAC + DEFINE(GAINDAC) +#else + MISSING(GAINDAC) +#endif + +#ifdef GICR + DEFINE(GICR) +#else + MISSING(GICR) +#endif + +#ifdef GIFR + DEFINE(GIFR) +#else + MISSING(GIFR) +#endif + +#ifdef GIMSK + DEFINE(GIMSK) +#else + MISSING(GIMSK) +#endif + +#ifdef GIPR + DEFINE(GIPR) +#else + MISSING(GIPR) +#endif + +#ifdef GPIO0 + DEFINE(GPIO0) +#else + MISSING(GPIO0) +#endif + +#ifdef GPIO1 + DEFINE(GPIO1) +#else + MISSING(GPIO1) +#endif + +#ifdef GPIO2 + DEFINE(GPIO2) +#else + MISSING(GPIO2) +#endif + +#ifdef GPIO3 + DEFINE(GPIO3) +#else + MISSING(GPIO3) +#endif + +#ifdef GPIO4 + DEFINE(GPIO4) +#else + MISSING(GPIO4) +#endif + +#ifdef GPIO5 + DEFINE(GPIO5) +#else + MISSING(GPIO5) +#endif + +#ifdef GPIO6 + DEFINE(GPIO6) +#else + MISSING(GPIO6) +#endif + +#ifdef GPIO7 + DEFINE(GPIO7) +#else + MISSING(GPIO7) +#endif + +#ifdef GPIO8 + DEFINE(GPIO8) +#else + MISSING(GPIO8) +#endif + +#ifdef GPIO9 + DEFINE(GPIO9) +#else + MISSING(GPIO9) +#endif + +#ifdef GPIOA + DEFINE(GPIOA) +#else + MISSING(GPIOA) +#endif + +#ifdef GPIOB + DEFINE(GPIOB) +#else + MISSING(GPIOB) +#endif + +#ifdef GPIOC + DEFINE(GPIOC) +#else + MISSING(GPIOC) +#endif + +#ifdef GPIOD + DEFINE(GPIOD) +#else + MISSING(GPIOD) +#endif + +#ifdef GPIOE + DEFINE(GPIOE) +#else + MISSING(GPIOE) +#endif + +#ifdef GPIOF + DEFINE(GPIOF) +#else + MISSING(GPIOF) +#endif + +#ifdef GPIOR0 + DEFINE(GPIOR0) +#else + MISSING(GPIOR0) +#endif + +#ifdef GPIOR1 + DEFINE(GPIOR1) +#else + MISSING(GPIOR1) +#endif + +#ifdef GPIOR2 + DEFINE(GPIOR2) +#else + MISSING(GPIOR2) +#endif + +#ifdef GPIOR3 + DEFINE(GPIOR3) +#else + MISSING(GPIOR3) +#endif + +#ifdef GPIOR4 + DEFINE(GPIOR4) +#else + MISSING(GPIOR4) +#endif + +#ifdef GPIOR5 + DEFINE(GPIOR5) +#else + MISSING(GPIOR5) +#endif + +#ifdef GPIOR6 + DEFINE(GPIOR6) +#else + MISSING(GPIOR6) +#endif + +#ifdef GPIOR7 + DEFINE(GPIOR7) +#else + MISSING(GPIOR7) +#endif + +#ifdef GPIOR8 + DEFINE(GPIOR8) +#else + MISSING(GPIOR8) +#endif + +#ifdef GPIOR9 + DEFINE(GPIOR9) +#else + MISSING(GPIOR9) +#endif + +#ifdef GPIORA + DEFINE(GPIORA) +#else + MISSING(GPIORA) +#endif + +#ifdef GPIORB + DEFINE(GPIORB) +#else + MISSING(GPIORB) +#endif + +#ifdef GPIORC + DEFINE(GPIORC) +#else + MISSING(GPIORC) +#endif + +#ifdef GPIORD + DEFINE(GPIORD) +#else + MISSING(GPIORD) +#endif + +#ifdef GPIORE + DEFINE(GPIORE) +#else + MISSING(GPIORE) +#endif + +#ifdef GPIORF + DEFINE(GPIORF) +#else + MISSING(GPIORF) +#endif + +#ifdef GPIO_GPIO0 + DEFINE(GPIO_GPIO0) +#else + MISSING(GPIO_GPIO0) +#endif + +#ifdef GPIO_GPIO1 + DEFINE(GPIO_GPIO1) +#else + MISSING(GPIO_GPIO1) +#endif + +#ifdef GPIO_GPIO2 + DEFINE(GPIO_GPIO2) +#else + MISSING(GPIO_GPIO2) +#endif + +#ifdef GPIO_GPIO3 + DEFINE(GPIO_GPIO3) +#else + MISSING(GPIO_GPIO3) +#endif + +#ifdef GPIO_GPIO4 + DEFINE(GPIO_GPIO4) +#else + MISSING(GPIO_GPIO4) +#endif + +#ifdef GPIO_GPIO5 + DEFINE(GPIO_GPIO5) +#else + MISSING(GPIO_GPIO5) +#endif + +#ifdef GPIO_GPIO6 + DEFINE(GPIO_GPIO6) +#else + MISSING(GPIO_GPIO6) +#endif + +#ifdef GPIO_GPIO7 + DEFINE(GPIO_GPIO7) +#else + MISSING(GPIO_GPIO7) +#endif + +#ifdef GPIO_GPIO8 + DEFINE(GPIO_GPIO8) +#else + MISSING(GPIO_GPIO8) +#endif + +#ifdef GPIO_GPIO9 + DEFINE(GPIO_GPIO9) +#else + MISSING(GPIO_GPIO9) +#endif + +#ifdef GPIO_GPIOA + DEFINE(GPIO_GPIOA) +#else + MISSING(GPIO_GPIOA) +#endif + +#ifdef GPIO_GPIOB + DEFINE(GPIO_GPIOB) +#else + MISSING(GPIO_GPIOB) +#endif + +#ifdef GPIO_GPIOC + DEFINE(GPIO_GPIOC) +#else + MISSING(GPIO_GPIOC) +#endif + +#ifdef GPIO_GPIOD + DEFINE(GPIO_GPIOD) +#else + MISSING(GPIO_GPIOD) +#endif + +#ifdef GPIO_GPIOE + DEFINE(GPIO_GPIOE) +#else + MISSING(GPIO_GPIOE) +#endif + +#ifdef GPIO_GPIOF + DEFINE(GPIO_GPIOF) +#else + MISSING(GPIO_GPIOF) +#endif + +#ifdef GPIO_GPIOR0 + DEFINE(GPIO_GPIOR0) +#else + MISSING(GPIO_GPIOR0) +#endif + +#ifdef GPIO_GPIOR1 + DEFINE(GPIO_GPIOR1) +#else + MISSING(GPIO_GPIOR1) +#endif + +#ifdef GPIO_GPIOR2 + DEFINE(GPIO_GPIOR2) +#else + MISSING(GPIO_GPIOR2) +#endif + +#ifdef GPIO_GPIOR3 + DEFINE(GPIO_GPIOR3) +#else + MISSING(GPIO_GPIOR3) +#endif + +#ifdef GPIO_GPIOR4 + DEFINE(GPIO_GPIOR4) +#else + MISSING(GPIO_GPIOR4) +#endif + +#ifdef GPIO_GPIOR5 + DEFINE(GPIO_GPIOR5) +#else + MISSING(GPIO_GPIOR5) +#endif + +#ifdef GPIO_GPIOR6 + DEFINE(GPIO_GPIOR6) +#else + MISSING(GPIO_GPIOR6) +#endif + +#ifdef GPIO_GPIOR7 + DEFINE(GPIO_GPIOR7) +#else + MISSING(GPIO_GPIOR7) +#endif + +#ifdef GPIO_GPIOR8 + DEFINE(GPIO_GPIOR8) +#else + MISSING(GPIO_GPIOR8) +#endif + +#ifdef GPIO_GPIOR9 + DEFINE(GPIO_GPIOR9) +#else + MISSING(GPIO_GPIOR9) +#endif + +#ifdef GPIO_GPIORA + DEFINE(GPIO_GPIORA) +#else + MISSING(GPIO_GPIORA) +#endif + +#ifdef GPIO_GPIORB + DEFINE(GPIO_GPIORB) +#else + MISSING(GPIO_GPIORB) +#endif + +#ifdef GPIO_GPIORC + DEFINE(GPIO_GPIORC) +#else + MISSING(GPIO_GPIORC) +#endif + +#ifdef GPIO_GPIORD + DEFINE(GPIO_GPIORD) +#else + MISSING(GPIO_GPIORD) +#endif + +#ifdef GPIO_GPIORE + DEFINE(GPIO_GPIORE) +#else + MISSING(GPIO_GPIORE) +#endif + +#ifdef GPIO_GPIORF + DEFINE(GPIO_GPIORF) +#else + MISSING(GPIO_GPIORF) +#endif + +#ifdef GTCCR + DEFINE(GTCCR) +#else + MISSING(GTCCR) +#endif + +#ifdef HIRESC_CTRLA + DEFINE(HIRESC_CTRLA) +#else + MISSING(HIRESC_CTRLA) +#endif + +#ifdef HIRESD_CTRLA + DEFINE(HIRESD_CTRLA) +#else + MISSING(HIRESD_CTRLA) +#endif + +#ifdef HIRESE_CTRLA + DEFINE(HIRESE_CTRLA) +#else + MISSING(HIRESE_CTRLA) +#endif + +#ifdef HIRESF_CTRLA + DEFINE(HIRESF_CTRLA) +#else + MISSING(HIRESF_CTRLA) +#endif + +#ifdef HSSPICFG + DEFINE(HSSPICFG) +#else + MISSING(HSSPICFG) +#endif + +#ifdef HSSPICNT + DEFINE(HSSPICNT) +#else + MISSING(HSSPICNT) +#endif + +#ifdef HSSPICR + DEFINE(HSSPICR) +#else + MISSING(HSSPICR) +#endif + +#ifdef HSSPIDMAB + DEFINE(HSSPIDMAB) +#else + MISSING(HSSPIDMAB) +#endif + +#ifdef HSSPIDMACS + DEFINE(HSSPIDMACS) +#else + MISSING(HSSPIDMACS) +#endif + +#ifdef HSSPIDMAD + DEFINE(HSSPIDMAD) +#else + MISSING(HSSPIDMAD) +#endif + +#ifdef HSSPIDMADH + DEFINE(HSSPIDMADH) +#else + MISSING(HSSPIDMADH) +#endif + +#ifdef HSSPIDMADL + DEFINE(HSSPIDMADL) +#else + MISSING(HSSPIDMADL) +#endif + +#ifdef HSSPIGTR + DEFINE(HSSPIGTR) +#else + MISSING(HSSPIGTR) +#endif + +#ifdef HSSPIIER + DEFINE(HSSPIIER) +#else + MISSING(HSSPIIER) +#endif + +#ifdef HSSPIIR + DEFINE(HSSPIIR) +#else + MISSING(HSSPIIR) +#endif + +#ifdef HSSPIRDR + DEFINE(HSSPIRDR) +#else + MISSING(HSSPIRDR) +#endif + +#ifdef HSSPISR + DEFINE(HSSPISR) +#else + MISSING(HSSPISR) +#endif + +#ifdef HSSPITDR + DEFINE(HSSPITDR) +#else + MISSING(HSSPITDR) +#endif + +#ifdef HSSPITO + DEFINE(HSSPITO) +#else + MISSING(HSSPITO) +#endif + +#ifdef HSSPITOH + DEFINE(HSSPITOH) +#else + MISSING(HSSPITOH) +#endif + +#ifdef HSSPITOL + DEFINE(HSSPITOL) +#else + MISSING(HSSPITOL) +#endif + +#ifdef ICR + DEFINE(ICR) +#else + MISSING(ICR) +#endif + +#ifdef ICR0 + DEFINE(ICR0) +#else + MISSING(ICR0) +#endif + +#ifdef ICR0H + DEFINE(ICR0H) +#else + MISSING(ICR0H) +#endif + +#ifdef ICR0L + DEFINE(ICR0L) +#else + MISSING(ICR0L) +#endif + +#ifdef ICR1 + DEFINE(ICR1) +#else + MISSING(ICR1) +#endif + +#ifdef ICR1H + DEFINE(ICR1H) +#else + MISSING(ICR1H) +#endif + +#ifdef ICR1L + DEFINE(ICR1L) +#else + MISSING(ICR1L) +#endif + +#ifdef ICR3 + DEFINE(ICR3) +#else + MISSING(ICR3) +#endif + +#ifdef ICR3H + DEFINE(ICR3H) +#else + MISSING(ICR3H) +#endif + +#ifdef ICR3L + DEFINE(ICR3L) +#else + MISSING(ICR3L) +#endif + +#ifdef ICR4 + DEFINE(ICR4) +#else + MISSING(ICR4) +#endif + +#ifdef ICR4H + DEFINE(ICR4H) +#else + MISSING(ICR4H) +#endif + +#ifdef ICR4L + DEFINE(ICR4L) +#else + MISSING(ICR4L) +#endif + +#ifdef ICR5 + DEFINE(ICR5) +#else + MISSING(ICR5) +#endif + +#ifdef ICR5H + DEFINE(ICR5H) +#else + MISSING(ICR5H) +#endif + +#ifdef ICR5L + DEFINE(ICR5L) +#else + MISSING(ICR5L) +#endif + +#ifdef IDXCTRL + DEFINE(IDXCTRL) +#else + MISSING(IDXCTRL) +#endif + +#ifdef IDXIFLG + DEFINE(IDXIFLG) +#else + MISSING(IDXIFLG) +#endif + +#ifdef IDXIMSK + DEFINE(IDXIMSK) +#else + MISSING(IDXIMSK) +#endif + +#ifdef IDXMSDT + DEFINE(IDXMSDT) +#else + MISSING(IDXMSDT) +#endif + +#ifdef IDXSTRB + DEFINE(IDXSTRB) +#else + MISSING(IDXSTRB) +#endif + +#ifdef IEEE_ADDR_0 + DEFINE(IEEE_ADDR_0) +#else + MISSING(IEEE_ADDR_0) +#endif + +#ifdef IEEE_ADDR_1 + DEFINE(IEEE_ADDR_1) +#else + MISSING(IEEE_ADDR_1) +#endif + +#ifdef IEEE_ADDR_2 + DEFINE(IEEE_ADDR_2) +#else + MISSING(IEEE_ADDR_2) +#endif + +#ifdef IEEE_ADDR_3 + DEFINE(IEEE_ADDR_3) +#else + MISSING(IEEE_ADDR_3) +#endif + +#ifdef IEEE_ADDR_4 + DEFINE(IEEE_ADDR_4) +#else + MISSING(IEEE_ADDR_4) +#endif + +#ifdef IEEE_ADDR_5 + DEFINE(IEEE_ADDR_5) +#else + MISSING(IEEE_ADDR_5) +#endif + +#ifdef IEEE_ADDR_6 + DEFINE(IEEE_ADDR_6) +#else + MISSING(IEEE_ADDR_6) +#endif + +#ifdef IEEE_ADDR_7 + DEFINE(IEEE_ADDR_7) +#else + MISSING(IEEE_ADDR_7) +#endif + +#ifdef IFR + DEFINE(IFR) +#else + MISSING(IFR) +#endif + +#ifdef INOCR1A + DEFINE(INOCR1A) +#else + MISSING(INOCR1A) +#endif + +#ifdef INOCR1AH + DEFINE(INOCR1AH) +#else + MISSING(INOCR1AH) +#endif + +#ifdef INOCR1AL + DEFINE(INOCR1AL) +#else + MISSING(INOCR1AL) +#endif + +#ifdef INOCR1B + DEFINE(INOCR1B) +#else + MISSING(INOCR1B) +#endif + +#ifdef INOCR1BH + DEFINE(INOCR1BH) +#else + MISSING(INOCR1BH) +#endif + +#ifdef INOCR1BL + DEFINE(INOCR1BL) +#else + MISSING(INOCR1BL) +#endif + +#ifdef INTCCR0 + DEFINE(INTCCR0) +#else + MISSING(INTCCR0) +#endif + +#ifdef INTCCR1A + DEFINE(INTCCR1A) +#else + MISSING(INTCCR1A) +#endif + +#ifdef INTCCR1B + DEFINE(INTCCR1B) +#else + MISSING(INTCCR1B) +#endif + +#ifdef INTCNT + DEFINE(INTCNT) +#else + MISSING(INTCNT) +#endif + +#ifdef INTCNT1 + DEFINE(INTCNT1) +#else + MISSING(INTCNT1) +#endif + +#ifdef INTCNT1H + DEFINE(INTCNT1H) +#else + MISSING(INTCNT1H) +#endif + +#ifdef INTCNT1L + DEFINE(INTCNT1L) +#else + MISSING(INTCNT1L) +#endif + +#ifdef INTIFR + DEFINE(INTIFR) +#else + MISSING(INTIFR) +#endif + +#ifdef INTIMSK + DEFINE(INTIMSK) +#else + MISSING(INTIMSK) +#endif + +#ifdef IOF + DEFINE(IOF) +#else + MISSING(IOF) +#endif + +#ifdef IO_DATIN + DEFINE(IO_DATIN) +#else + MISSING(IO_DATIN) +#endif + +#ifdef IO_DATOUT + DEFINE(IO_DATOUT) +#else + MISSING(IO_DATOUT) +#endif + +#ifdef IO_ENAB + DEFINE(IO_ENAB) +#else + MISSING(IO_ENAB) +#endif + +#ifdef IPA + DEFINE(IPA) +#else + MISSING(IPA) +#endif + +#ifdef IPAH + DEFINE(IPAH) +#else + MISSING(IPAH) +#endif + +#ifdef IPAL + DEFINE(IPAL) +#else + MISSING(IPAL) +#endif + +#ifdef IPCR + DEFINE(IPCR) +#else + MISSING(IPCR) +#endif + +#ifdef IPD + DEFINE(IPD) +#else + MISSING(IPD) +#endif + +#ifdef IPDH + DEFINE(IPDH) +#else + MISSING(IPDH) +#endif + +#ifdef IPDL + DEFINE(IPDL) +#else + MISSING(IPDL) +#endif + +#ifdef IRCOM_CTRL + DEFINE(IRCOM_CTRL) +#else + MISSING(IRCOM_CTRL) +#endif + +#ifdef IRCOM_RXPLCTRL + DEFINE(IRCOM_RXPLCTRL) +#else + MISSING(IRCOM_RXPLCTRL) +#endif + +#ifdef IRCOM_TXPLCTRL + DEFINE(IRCOM_TXPLCTRL) +#else + MISSING(IRCOM_TXPLCTRL) +#endif + +#ifdef IRDAMOD + DEFINE(IRDAMOD) +#else + MISSING(IRDAMOD) +#endif + +#ifdef IRQ_MASK + DEFINE(IRQ_MASK) +#else + MISSING(IRQ_MASK) +#endif + +#ifdef IRQ_STATUS + DEFINE(IRQ_STATUS) +#else + MISSING(IRQ_STATUS) +#endif + +#ifdef KBER + DEFINE(KBER) +#else + MISSING(KBER) +#endif + +#ifdef KBFR + DEFINE(KBFR) +#else + MISSING(KBFR) +#endif + +#ifdef KBLSR + DEFINE(KBLSR) +#else + MISSING(KBLSR) +#endif + +#ifdef LCDCCR + DEFINE(LCDCCR) +#else + MISSING(LCDCCR) +#endif + +#ifdef LCDCRA + DEFINE(LCDCRA) +#else + MISSING(LCDCRA) +#endif + +#ifdef LCDCRB + DEFINE(LCDCRB) +#else + MISSING(LCDCRB) +#endif + +#ifdef LCDDR0 + DEFINE(LCDDR0) +#else + MISSING(LCDDR0) +#endif + +#ifdef LCDDR00 + DEFINE(LCDDR00) +#else + MISSING(LCDDR00) +#endif + +#ifdef LCDDR01 + DEFINE(LCDDR01) +#else + MISSING(LCDDR01) +#endif + +#ifdef LCDDR02 + DEFINE(LCDDR02) +#else + MISSING(LCDDR02) +#endif + +#ifdef LCDDR03 + DEFINE(LCDDR03) +#else + MISSING(LCDDR03) +#endif + +#ifdef LCDDR04 + DEFINE(LCDDR04) +#else + MISSING(LCDDR04) +#endif + +#ifdef LCDDR05 + DEFINE(LCDDR05) +#else + MISSING(LCDDR05) +#endif + +#ifdef LCDDR06 + DEFINE(LCDDR06) +#else + MISSING(LCDDR06) +#endif + +#ifdef LCDDR07 + DEFINE(LCDDR07) +#else + MISSING(LCDDR07) +#endif + +#ifdef LCDDR08 + DEFINE(LCDDR08) +#else + MISSING(LCDDR08) +#endif + +#ifdef LCDDR09 + DEFINE(LCDDR09) +#else + MISSING(LCDDR09) +#endif + +#ifdef LCDDR1 + DEFINE(LCDDR1) +#else + MISSING(LCDDR1) +#endif + +#ifdef LCDDR10 + DEFINE(LCDDR10) +#else + MISSING(LCDDR10) +#endif + +#ifdef LCDDR11 + DEFINE(LCDDR11) +#else + MISSING(LCDDR11) +#endif + +#ifdef LCDDR12 + DEFINE(LCDDR12) +#else + MISSING(LCDDR12) +#endif + +#ifdef LCDDR13 + DEFINE(LCDDR13) +#else + MISSING(LCDDR13) +#endif + +#ifdef LCDDR14 + DEFINE(LCDDR14) +#else + MISSING(LCDDR14) +#endif + +#ifdef LCDDR15 + DEFINE(LCDDR15) +#else + MISSING(LCDDR15) +#endif + +#ifdef LCDDR16 + DEFINE(LCDDR16) +#else + MISSING(LCDDR16) +#endif + +#ifdef LCDDR17 + DEFINE(LCDDR17) +#else + MISSING(LCDDR17) +#endif + +#ifdef LCDDR18 + DEFINE(LCDDR18) +#else + MISSING(LCDDR18) +#endif + +#ifdef LCDDR19 + DEFINE(LCDDR19) +#else + MISSING(LCDDR19) +#endif + +#ifdef LCDDR2 + DEFINE(LCDDR2) +#else + MISSING(LCDDR2) +#endif + +#ifdef LCDDR3 + DEFINE(LCDDR3) +#else + MISSING(LCDDR3) +#endif + +#ifdef LCDDR4 + DEFINE(LCDDR4) +#else + MISSING(LCDDR4) +#endif + +#ifdef LCDDR5 + DEFINE(LCDDR5) +#else + MISSING(LCDDR5) +#endif + +#ifdef LCDDR6 + DEFINE(LCDDR6) +#else + MISSING(LCDDR6) +#endif + +#ifdef LCDDR7 + DEFINE(LCDDR7) +#else + MISSING(LCDDR7) +#endif + +#ifdef LCDDR8 + DEFINE(LCDDR8) +#else + MISSING(LCDDR8) +#endif + +#ifdef LCDDR9 + DEFINE(LCDDR9) +#else + MISSING(LCDDR9) +#endif + +#ifdef LCDFRR + DEFINE(LCDFRR) +#else + MISSING(LCDFRR) +#endif + +#ifdef LEDCR + DEFINE(LEDCR) +#else + MISSING(LEDCR) +#endif + +#ifdef LFCAL + DEFINE(LFCAL) +#else + MISSING(LFCAL) +#endif + +#ifdef LFCALH + DEFINE(LFCALH) +#else + MISSING(LFCALH) +#endif + +#ifdef LFCALL + DEFINE(LFCALL) +#else + MISSING(LFCALL) +#endif + +#ifdef LFCDR + DEFINE(LFCDR) +#else + MISSING(LFCDR) +#endif + +#ifdef LFFR + DEFINE(LFFR) +#else + MISSING(LFFR) +#endif + +#ifdef LFHCR + DEFINE(LFHCR) +#else + MISSING(LFHCR) +#endif + +#ifdef LFIDC + DEFINE(LFIDC) +#else + MISSING(LFIDC) +#endif + +#ifdef LFIDCH + DEFINE(LFIDCH) +#else + MISSING(LFIDCH) +#endif + +#ifdef LFIDCL + DEFINE(LFIDCL) +#else + MISSING(LFIDCL) +#endif + +#ifdef LFIMR + DEFINE(LFIMR) +#else + MISSING(LFIMR) +#endif + +#ifdef LFRB + DEFINE(LFRB) +#else + MISSING(LFRB) +#endif + +#ifdef LFRCR + DEFINE(LFRCR) +#else + MISSING(LFRCR) +#endif + +#ifdef LFRR + DEFINE(LFRR) +#else + MISSING(LFRR) +#endif + +#ifdef LFSR0 + DEFINE(LFSR0) +#else + MISSING(LFSR0) +#endif + +#ifdef LFSR1 + DEFINE(LFSR1) +#else + MISSING(LFSR1) +#endif + +#ifdef LFSR2 + DEFINE(LFSR2) +#else + MISSING(LFSR2) +#endif + +#ifdef LFSR3 + DEFINE(LFSR3) +#else + MISSING(LFSR3) +#endif + +#ifdef LINBRR + DEFINE(LINBRR) +#else + MISSING(LINBRR) +#endif + +#ifdef LINBRRH + DEFINE(LINBRRH) +#else + MISSING(LINBRRH) +#endif + +#ifdef LINBRRL + DEFINE(LINBRRL) +#else + MISSING(LINBRRL) +#endif + +#ifdef LINBTR + DEFINE(LINBTR) +#else + MISSING(LINBTR) +#endif + +#ifdef LINCR + DEFINE(LINCR) +#else + MISSING(LINCR) +#endif + +#ifdef LINDAT + DEFINE(LINDAT) +#else + MISSING(LINDAT) +#endif + +#ifdef LINDLR + DEFINE(LINDLR) +#else + MISSING(LINDLR) +#endif + +#ifdef LINENIR + DEFINE(LINENIR) +#else + MISSING(LINENIR) +#endif + +#ifdef LINERR + DEFINE(LINERR) +#else + MISSING(LINERR) +#endif + +#ifdef LINIDR + DEFINE(LINIDR) +#else + MISSING(LINIDR) +#endif + +#ifdef LINSEL + DEFINE(LINSEL) +#else + MISSING(LINSEL) +#endif + +#ifdef LINSIR + DEFINE(LINSIR) +#else + MISSING(LINSIR) +#endif + +#ifdef LLCR + DEFINE(LLCR) +#else + MISSING(LLCR) +#endif + +#ifdef LLDRH + DEFINE(LLDRH) +#else + MISSING(LLDRH) +#endif + +#ifdef LLDRL + DEFINE(LLDRL) +#else + MISSING(LLDRL) +#endif + +#ifdef LOCKDET1 + DEFINE(LOCKDET1) +#else + MISSING(LOCKDET1) +#endif + +#ifdef LOCKDET2 + DEFINE(LOCKDET2) +#else + MISSING(LOCKDET2) +#endif + +#ifdef MAN_ID_0 + DEFINE(MAN_ID_0) +#else + MISSING(MAN_ID_0) +#endif + +#ifdef MAN_ID_1 + DEFINE(MAN_ID_1) +#else + MISSING(MAN_ID_1) +#endif + +#ifdef MCSR + DEFINE(MCSR) +#else + MISSING(MCSR) +#endif + +#ifdef MCUCR + DEFINE(MCUCR) +#else + MISSING(MCUCR) +#endif + +#ifdef MCUCS + DEFINE(MCUCS) +#else + MISSING(MCUCS) +#endif + +#ifdef MCUCSR + DEFINE(MCUCSR) +#else + MISSING(MCUCSR) +#endif + +#ifdef MCUR + DEFINE(MCUR) +#else + MISSING(MCUR) +#endif + +#ifdef MCUSR + DEFINE(MCUSR) +#else + MISSING(MCUSR) +#endif + +#ifdef MCU_ANAINIT + DEFINE(MCU_ANAINIT) +#else + MISSING(MCU_ANAINIT) +#endif + +#ifdef MCU_AWEXLOCK + DEFINE(MCU_AWEXLOCK) +#else + MISSING(MCU_AWEXLOCK) +#endif + +#ifdef MCU_DEVID0 + DEFINE(MCU_DEVID0) +#else + MISSING(MCU_DEVID0) +#endif + +#ifdef MCU_DEVID1 + DEFINE(MCU_DEVID1) +#else + MISSING(MCU_DEVID1) +#endif + +#ifdef MCU_DEVID2 + DEFINE(MCU_DEVID2) +#else + MISSING(MCU_DEVID2) +#endif + +#ifdef MCU_EVSYSLOCK + DEFINE(MCU_EVSYSLOCK) +#else + MISSING(MCU_EVSYSLOCK) +#endif + +#ifdef MCU_JTAGUID + DEFINE(MCU_JTAGUID) +#else + MISSING(MCU_JTAGUID) +#endif + +#ifdef MCU_MCUCR + DEFINE(MCU_MCUCR) +#else + MISSING(MCU_MCUCR) +#endif + +#ifdef MCU_REVID + DEFINE(MCU_REVID) +#else + MISSING(MCU_REVID) +#endif + +#ifdef MODCR + DEFINE(MODCR) +#else + MISSING(MODCR) +#endif + +#ifdef MONDR + DEFINE(MONDR) +#else + MISSING(MONDR) +#endif + +#ifdef MSELR + DEFINE(MSELR) +#else + MISSING(MSELR) +#endif + +#ifdef MSMCR + DEFINE(MSMCR) +#else + MISSING(MSMCR) +#endif + +#ifdef MSPCR + DEFINE(MSPCR) +#else + MISSING(MSPCR) +#endif + +#ifdef MSPDR + DEFINE(MSPDR) +#else + MISSING(MSPDR) +#endif + +#ifdef MSPSR + DEFINE(MSPSR) +#else + MISSING(MSPSR) +#endif + +#ifdef MSVCAL + DEFINE(MSVCAL) +#else + MISSING(MSVCAL) +#endif + +#ifdef MUBRR + DEFINE(MUBRR) +#else + MISSING(MUBRR) +#endif + +#ifdef MUBRRH + DEFINE(MUBRRH) +#else + MISSING(MUBRRH) +#endif + +#ifdef MUBRRL + DEFINE(MUBRRL) +#else + MISSING(MUBRRL) +#endif + +#ifdef NEMCR + DEFINE(NEMCR) +#else + MISSING(NEMCR) +#endif + +#ifdef NVMCMD + DEFINE(NVMCMD) +#else + MISSING(NVMCMD) +#endif + +#ifdef NVMCSR + DEFINE(NVMCSR) +#else + MISSING(NVMCSR) +#endif + +#ifdef NVM_ADDR0 + DEFINE(NVM_ADDR0) +#else + MISSING(NVM_ADDR0) +#endif + +#ifdef NVM_ADDR1 + DEFINE(NVM_ADDR1) +#else + MISSING(NVM_ADDR1) +#endif + +#ifdef NVM_ADDR2 + DEFINE(NVM_ADDR2) +#else + MISSING(NVM_ADDR2) +#endif + +#ifdef NVM_CMD + DEFINE(NVM_CMD) +#else + MISSING(NVM_CMD) +#endif + +#ifdef NVM_CTRLA + DEFINE(NVM_CTRLA) +#else + MISSING(NVM_CTRLA) +#endif + +#ifdef NVM_CTRLB + DEFINE(NVM_CTRLB) +#else + MISSING(NVM_CTRLB) +#endif + +#ifdef NVM_DATA0 + DEFINE(NVM_DATA0) +#else + MISSING(NVM_DATA0) +#endif + +#ifdef NVM_DATA1 + DEFINE(NVM_DATA1) +#else + MISSING(NVM_DATA1) +#endif + +#ifdef NVM_DATA2 + DEFINE(NVM_DATA2) +#else + MISSING(NVM_DATA2) +#endif + +#ifdef NVM_INTCTRL + DEFINE(NVM_INTCTRL) +#else + MISSING(NVM_INTCTRL) +#endif + +#ifdef NVM_LOCKBITS + DEFINE(NVM_LOCKBITS) +#else + MISSING(NVM_LOCKBITS) +#endif + +#ifdef NVM_STATUS + DEFINE(NVM_STATUS) +#else + MISSING(NVM_STATUS) +#endif + +#ifdef OCDR + DEFINE(OCDR) +#else + MISSING(OCDR) +#endif + +#ifdef OCD_OCDR0 + DEFINE(OCD_OCDR0) +#else + MISSING(OCD_OCDR0) +#endif + +#ifdef OCD_OCDR1 + DEFINE(OCD_OCDR1) +#else + MISSING(OCD_OCDR1) +#endif + +#ifdef OCR0 + DEFINE(OCR0) +#else + MISSING(OCR0) +#endif + +#ifdef OCR0A + DEFINE(OCR0A) +#else + MISSING(OCR0A) +#endif + +#ifdef OCR0AH + DEFINE(OCR0AH) +#else + MISSING(OCR0AH) +#endif + +#ifdef OCR0AL + DEFINE(OCR0AL) +#else + MISSING(OCR0AL) +#endif + +#ifdef OCR0B + DEFINE(OCR0B) +#else + MISSING(OCR0B) +#endif + +#ifdef OCR0BH + DEFINE(OCR0BH) +#else + MISSING(OCR0BH) +#endif + +#ifdef OCR0BL + DEFINE(OCR0BL) +#else + MISSING(OCR0BL) +#endif + +#ifdef OCR0RA + DEFINE(OCR0RA) +#else + MISSING(OCR0RA) +#endif + +#ifdef OCR0RAH + DEFINE(OCR0RAH) +#else + MISSING(OCR0RAH) +#endif + +#ifdef OCR0RAL + DEFINE(OCR0RAL) +#else + MISSING(OCR0RAL) +#endif + +#ifdef OCR0RB + DEFINE(OCR0RB) +#else + MISSING(OCR0RB) +#endif + +#ifdef OCR0RBH + DEFINE(OCR0RBH) +#else + MISSING(OCR0RBH) +#endif + +#ifdef OCR0RBL + DEFINE(OCR0RBL) +#else + MISSING(OCR0RBL) +#endif + +#ifdef OCR0SA + DEFINE(OCR0SA) +#else + MISSING(OCR0SA) +#endif + +#ifdef OCR0SAH + DEFINE(OCR0SAH) +#else + MISSING(OCR0SAH) +#endif + +#ifdef OCR0SAL + DEFINE(OCR0SAL) +#else + MISSING(OCR0SAL) +#endif + +#ifdef OCR0SB + DEFINE(OCR0SB) +#else + MISSING(OCR0SB) +#endif + +#ifdef OCR0SBH + DEFINE(OCR0SBH) +#else + MISSING(OCR0SBH) +#endif + +#ifdef OCR0SBL + DEFINE(OCR0SBL) +#else + MISSING(OCR0SBL) +#endif + +#ifdef OCR1 + DEFINE(OCR1) +#else + MISSING(OCR1) +#endif + +#ifdef OCR1A + DEFINE(OCR1A) +#else + MISSING(OCR1A) +#endif + +#ifdef OCR1AH + DEFINE(OCR1AH) +#else + MISSING(OCR1AH) +#endif + +#ifdef OCR1AL + DEFINE(OCR1AL) +#else + MISSING(OCR1AL) +#endif + +#ifdef OCR1B + DEFINE(OCR1B) +#else + MISSING(OCR1B) +#endif + +#ifdef OCR1BH + DEFINE(OCR1BH) +#else + MISSING(OCR1BH) +#endif + +#ifdef OCR1BL + DEFINE(OCR1BL) +#else + MISSING(OCR1BL) +#endif + +#ifdef OCR1C + DEFINE(OCR1C) +#else + MISSING(OCR1C) +#endif + +#ifdef OCR1CH + DEFINE(OCR1CH) +#else + MISSING(OCR1CH) +#endif + +#ifdef OCR1CL + DEFINE(OCR1CL) +#else + MISSING(OCR1CL) +#endif + +#ifdef OCR1D + DEFINE(OCR1D) +#else + MISSING(OCR1D) +#endif + +#ifdef OCR1H + DEFINE(OCR1H) +#else + MISSING(OCR1H) +#endif + +#ifdef OCR1L + DEFINE(OCR1L) +#else + MISSING(OCR1L) +#endif + +#ifdef OCR1RA + DEFINE(OCR1RA) +#else + MISSING(OCR1RA) +#endif + +#ifdef OCR1RAH + DEFINE(OCR1RAH) +#else + MISSING(OCR1RAH) +#endif + +#ifdef OCR1RAL + DEFINE(OCR1RAL) +#else + MISSING(OCR1RAL) +#endif + +#ifdef OCR1RB + DEFINE(OCR1RB) +#else + MISSING(OCR1RB) +#endif + +#ifdef OCR1RBH + DEFINE(OCR1RBH) +#else + MISSING(OCR1RBH) +#endif + +#ifdef OCR1RBL + DEFINE(OCR1RBL) +#else + MISSING(OCR1RBL) +#endif + +#ifdef OCR1SA + DEFINE(OCR1SA) +#else + MISSING(OCR1SA) +#endif + +#ifdef OCR1SAH + DEFINE(OCR1SAH) +#else + MISSING(OCR1SAH) +#endif + +#ifdef OCR1SAL + DEFINE(OCR1SAL) +#else + MISSING(OCR1SAL) +#endif + +#ifdef OCR1SB + DEFINE(OCR1SB) +#else + MISSING(OCR1SB) +#endif + +#ifdef OCR1SBH + DEFINE(OCR1SBH) +#else + MISSING(OCR1SBH) +#endif + +#ifdef OCR1SBL + DEFINE(OCR1SBL) +#else + MISSING(OCR1SBL) +#endif + +#ifdef OCR2 + DEFINE(OCR2) +#else + MISSING(OCR2) +#endif + +#ifdef OCR2A + DEFINE(OCR2A) +#else + MISSING(OCR2A) +#endif + +#ifdef OCR2B + DEFINE(OCR2B) +#else + MISSING(OCR2B) +#endif + +#ifdef OCR2RA + DEFINE(OCR2RA) +#else + MISSING(OCR2RA) +#endif + +#ifdef OCR2RAH + DEFINE(OCR2RAH) +#else + MISSING(OCR2RAH) +#endif + +#ifdef OCR2RAL + DEFINE(OCR2RAL) +#else + MISSING(OCR2RAL) +#endif + +#ifdef OCR2RB + DEFINE(OCR2RB) +#else + MISSING(OCR2RB) +#endif + +#ifdef OCR2RBH + DEFINE(OCR2RBH) +#else + MISSING(OCR2RBH) +#endif + +#ifdef OCR2RBL + DEFINE(OCR2RBL) +#else + MISSING(OCR2RBL) +#endif + +#ifdef OCR2SA + DEFINE(OCR2SA) +#else + MISSING(OCR2SA) +#endif + +#ifdef OCR2SAH + DEFINE(OCR2SAH) +#else + MISSING(OCR2SAH) +#endif + +#ifdef OCR2SAL + DEFINE(OCR2SAL) +#else + MISSING(OCR2SAL) +#endif + +#ifdef OCR2SB + DEFINE(OCR2SB) +#else + MISSING(OCR2SB) +#endif + +#ifdef OCR2SBH + DEFINE(OCR2SBH) +#else + MISSING(OCR2SBH) +#endif + +#ifdef OCR2SBL + DEFINE(OCR2SBL) +#else + MISSING(OCR2SBL) +#endif + +#ifdef OCR3A + DEFINE(OCR3A) +#else + MISSING(OCR3A) +#endif + +#ifdef OCR3AH + DEFINE(OCR3AH) +#else + MISSING(OCR3AH) +#endif + +#ifdef OCR3AL + DEFINE(OCR3AL) +#else + MISSING(OCR3AL) +#endif + +#ifdef OCR3B + DEFINE(OCR3B) +#else + MISSING(OCR3B) +#endif + +#ifdef OCR3BH + DEFINE(OCR3BH) +#else + MISSING(OCR3BH) +#endif + +#ifdef OCR3BL + DEFINE(OCR3BL) +#else + MISSING(OCR3BL) +#endif + +#ifdef OCR3C + DEFINE(OCR3C) +#else + MISSING(OCR3C) +#endif + +#ifdef OCR3CH + DEFINE(OCR3CH) +#else + MISSING(OCR3CH) +#endif + +#ifdef OCR3CL + DEFINE(OCR3CL) +#else + MISSING(OCR3CL) +#endif + +#ifdef OCR4A + DEFINE(OCR4A) +#else + MISSING(OCR4A) +#endif + +#ifdef OCR4AH + DEFINE(OCR4AH) +#else + MISSING(OCR4AH) +#endif + +#ifdef OCR4AL + DEFINE(OCR4AL) +#else + MISSING(OCR4AL) +#endif + +#ifdef OCR4B + DEFINE(OCR4B) +#else + MISSING(OCR4B) +#endif + +#ifdef OCR4BH + DEFINE(OCR4BH) +#else + MISSING(OCR4BH) +#endif + +#ifdef OCR4BL + DEFINE(OCR4BL) +#else + MISSING(OCR4BL) +#endif + +#ifdef OCR4C + DEFINE(OCR4C) +#else + MISSING(OCR4C) +#endif + +#ifdef OCR4CH + DEFINE(OCR4CH) +#else + MISSING(OCR4CH) +#endif + +#ifdef OCR4CL + DEFINE(OCR4CL) +#else + MISSING(OCR4CL) +#endif + +#ifdef OCR4D + DEFINE(OCR4D) +#else + MISSING(OCR4D) +#endif + +#ifdef OCR5A + DEFINE(OCR5A) +#else + MISSING(OCR5A) +#endif + +#ifdef OCR5AH + DEFINE(OCR5AH) +#else + MISSING(OCR5AH) +#endif + +#ifdef OCR5AL + DEFINE(OCR5AL) +#else + MISSING(OCR5AL) +#endif + +#ifdef OCR5B + DEFINE(OCR5B) +#else + MISSING(OCR5B) +#endif + +#ifdef OCR5BH + DEFINE(OCR5BH) +#else + MISSING(OCR5BH) +#endif + +#ifdef OCR5BL + DEFINE(OCR5BL) +#else + MISSING(OCR5BL) +#endif + +#ifdef OCR5C + DEFINE(OCR5C) +#else + MISSING(OCR5C) +#endif + +#ifdef OCR5CH + DEFINE(OCR5CH) +#else + MISSING(OCR5CH) +#endif + +#ifdef OCR5CL + DEFINE(OCR5CL) +#else + MISSING(OCR5CL) +#endif + +#ifdef OCRA1 + DEFINE(OCRA1) +#else + MISSING(OCRA1) +#endif + +#ifdef OCRA1H + DEFINE(OCRA1H) +#else + MISSING(OCRA1H) +#endif + +#ifdef OCRA1L + DEFINE(OCRA1L) +#else + MISSING(OCRA1L) +#endif + +#ifdef OCRB1 + DEFINE(OCRB1) +#else + MISSING(OCRB1) +#endif + +#ifdef OCRB1H + DEFINE(OCRB1H) +#else + MISSING(OCRB1H) +#endif + +#ifdef OCRB1L + DEFINE(OCRB1L) +#else + MISSING(OCRB1L) +#endif + +#ifdef OSCCAL + DEFINE(OSCCAL) +#else + MISSING(OSCCAL) +#endif + +#ifdef OSC_CTRL + DEFINE(OSC_CTRL) +#else + MISSING(OSC_CTRL) +#endif + +#ifdef OSC_DFLLCTRL + DEFINE(OSC_DFLLCTRL) +#else + MISSING(OSC_DFLLCTRL) +#endif + +#ifdef OSC_PLLCTRL + DEFINE(OSC_PLLCTRL) +#else + MISSING(OSC_PLLCTRL) +#endif + +#ifdef OSC_RC32KCAL + DEFINE(OSC_RC32KCAL) +#else + MISSING(OSC_RC32KCAL) +#endif + +#ifdef OSC_STATUS + DEFINE(OSC_STATUS) +#else + MISSING(OSC_STATUS) +#endif + +#ifdef OSC_XOSCCTRL + DEFINE(OSC_XOSCCTRL) +#else + MISSING(OSC_XOSCCTRL) +#endif + +#ifdef OSC_XOSCFAIL + DEFINE(OSC_XOSCFAIL) +#else + MISSING(OSC_XOSCFAIL) +#endif + +#ifdef OSICSR + DEFINE(OSICSR) +#else + MISSING(OSICSR) +#endif + +#ifdef OTGCON + DEFINE(OTGCON) +#else + MISSING(OTGCON) +#endif + +#ifdef OTGIEN + DEFINE(OTGIEN) +#else + MISSING(OTGIEN) +#endif + +#ifdef OTGINT + DEFINE(OTGINT) +#else + MISSING(OTGINT) +#endif + +#ifdef OTGTCON + DEFINE(OTGTCON) +#else + MISSING(OTGTCON) +#endif + +#ifdef PACR + DEFINE(PACR) +#else + MISSING(PACR) +#endif + +#ifdef PAN_ID_0 + DEFINE(PAN_ID_0) +#else + MISSING(PAN_ID_0) +#endif + +#ifdef PAN_ID_1 + DEFINE(PAN_ID_1) +#else + MISSING(PAN_ID_1) +#endif + +#ifdef PART_NUM + DEFINE(PART_NUM) +#else + MISSING(PART_NUM) +#endif + +#ifdef PASDLY2 + DEFINE(PASDLY2) +#else + MISSING(PASDLY2) +#endif + +#ifdef PBOV + DEFINE(PBOV) +#else + MISSING(PBOV) +#endif + +#ifdef PCICR + DEFINE(PCICR) +#else + MISSING(PCICR) +#endif + +#ifdef PCIFR + DEFINE(PCIFR) +#else + MISSING(PCIFR) +#endif + +#ifdef PCMSK + DEFINE(PCMSK) +#else + MISSING(PCMSK) +#endif + +#ifdef PCMSK0 + DEFINE(PCMSK0) +#else + MISSING(PCMSK0) +#endif + +#ifdef PCMSK1 + DEFINE(PCMSK1) +#else + MISSING(PCMSK1) +#endif + +#ifdef PCMSK2 + DEFINE(PCMSK2) +#else + MISSING(PCMSK2) +#endif + +#ifdef PCMSK3 + DEFINE(PCMSK3) +#else + MISSING(PCMSK3) +#endif + +#ifdef PCNF + DEFINE(PCNF) +#else + MISSING(PCNF) +#endif + +#ifdef PCNF0 + DEFINE(PCNF0) +#else + MISSING(PCNF0) +#endif + +#ifdef PCNF1 + DEFINE(PCNF1) +#else + MISSING(PCNF1) +#endif + +#ifdef PCNF2 + DEFINE(PCNF2) +#else + MISSING(PCNF2) +#endif + +#ifdef PCNFE2 + DEFINE(PCNFE2) +#else + MISSING(PCNFE2) +#endif + +#ifdef PCTL + DEFINE(PCTL) +#else + MISSING(PCTL) +#endif + +#ifdef PCTL0 + DEFINE(PCTL0) +#else + MISSING(PCTL0) +#endif + +#ifdef PCTL1 + DEFINE(PCTL1) +#else + MISSING(PCTL1) +#endif + +#ifdef PCTL2 + DEFINE(PCTL2) +#else + MISSING(PCTL2) +#endif + +#ifdef PERIPHEN + DEFINE(PERIPHEN) +#else + MISSING(PERIPHEN) +#endif + +#ifdef PFRC0A + DEFINE(PFRC0A) +#else + MISSING(PFRC0A) +#endif + +#ifdef PFRC0B + DEFINE(PFRC0B) +#else + MISSING(PFRC0B) +#endif + +#ifdef PFRC1A + DEFINE(PFRC1A) +#else + MISSING(PFRC1A) +#endif + +#ifdef PFRC1B + DEFINE(PFRC1B) +#else + MISSING(PFRC1B) +#endif + +#ifdef PFRC2A + DEFINE(PFRC2A) +#else + MISSING(PFRC2A) +#endif + +#ifdef PFRC2B + DEFINE(PFRC2B) +#else + MISSING(PFRC2B) +#endif + +#ifdef PHY_CC_CCA + DEFINE(PHY_CC_CCA) +#else + MISSING(PHY_CC_CCA) +#endif + +#ifdef PHY_ED_LEVEL + DEFINE(PHY_ED_LEVEL) +#else + MISSING(PHY_ED_LEVEL) +#endif + +#ifdef PHY_RSSI + DEFINE(PHY_RSSI) +#else + MISSING(PHY_RSSI) +#endif + +#ifdef PHY_TX_PWR + DEFINE(PHY_TX_PWR) +#else + MISSING(PHY_TX_PWR) +#endif + +#ifdef PICR0 + DEFINE(PICR0) +#else + MISSING(PICR0) +#endif + +#ifdef PICR0H + DEFINE(PICR0H) +#else + MISSING(PICR0H) +#endif + +#ifdef PICR0L + DEFINE(PICR0L) +#else + MISSING(PICR0L) +#endif + +#ifdef PICR1 + DEFINE(PICR1) +#else + MISSING(PICR1) +#endif + +#ifdef PICR1H + DEFINE(PICR1H) +#else + MISSING(PICR1H) +#endif + +#ifdef PICR1L + DEFINE(PICR1L) +#else + MISSING(PICR1L) +#endif + +#ifdef PICR2 + DEFINE(PICR2) +#else + MISSING(PICR2) +#endif + +#ifdef PICR2H + DEFINE(PICR2H) +#else + MISSING(PICR2H) +#endif + +#ifdef PICR2L + DEFINE(PICR2L) +#else + MISSING(PICR2L) +#endif + +#ifdef PIFR + DEFINE(PIFR) +#else + MISSING(PIFR) +#endif + +#ifdef PIFR0 + DEFINE(PIFR0) +#else + MISSING(PIFR0) +#endif + +#ifdef PIFR1 + DEFINE(PIFR1) +#else + MISSING(PIFR1) +#endif + +#ifdef PIFR2 + DEFINE(PIFR2) +#else + MISSING(PIFR2) +#endif + +#ifdef PIM + DEFINE(PIM) +#else + MISSING(PIM) +#endif + +#ifdef PIM0 + DEFINE(PIM0) +#else + MISSING(PIM0) +#endif + +#ifdef PIM1 + DEFINE(PIM1) +#else + MISSING(PIM1) +#endif + +#ifdef PIM2 + DEFINE(PIM2) +#else + MISSING(PIM2) +#endif + +#ifdef PINA + DEFINE(PINA) +#else + MISSING(PINA) +#endif + +#ifdef PINB + DEFINE(PINB) +#else + MISSING(PINB) +#endif + +#ifdef PINC + DEFINE(PINC) +#else + MISSING(PINC) +#endif + +#ifdef PIND + DEFINE(PIND) +#else + MISSING(PIND) +#endif + +#ifdef PINE + DEFINE(PINE) +#else + MISSING(PINE) +#endif + +#ifdef PINF + DEFINE(PINF) +#else + MISSING(PINF) +#endif + +#ifdef PING + DEFINE(PING) +#else + MISSING(PING) +#endif + +#ifdef PINH + DEFINE(PINH) +#else + MISSING(PINH) +#endif + +#ifdef PINJ + DEFINE(PINJ) +#else + MISSING(PINJ) +#endif + +#ifdef PINK + DEFINE(PINK) +#else + MISSING(PINK) +#endif + +#ifdef PINL + DEFINE(PINL) +#else + MISSING(PINL) +#endif + +#ifdef PLLCR + DEFINE(PLLCR) +#else + MISSING(PLLCR) +#endif + +#ifdef PLLCSR + DEFINE(PLLCSR) +#else + MISSING(PLLCSR) +#endif + +#ifdef PLLFRQ + DEFINE(PLLFRQ) +#else + MISSING(PLLFRQ) +#endif + +#ifdef PLL_CF + DEFINE(PLL_CF) +#else + MISSING(PLL_CF) +#endif + +#ifdef PLL_DCU + DEFINE(PLL_DCU) +#else + MISSING(PLL_DCU) +#endif + +#ifdef PMIC0 + DEFINE(PMIC0) +#else + MISSING(PMIC0) +#endif + +#ifdef PMIC1 + DEFINE(PMIC1) +#else + MISSING(PMIC1) +#endif + +#ifdef PMIC2 + DEFINE(PMIC2) +#else + MISSING(PMIC2) +#endif + +#ifdef PMIC_CTRL + DEFINE(PMIC_CTRL) +#else + MISSING(PMIC_CTRL) +#endif + +#ifdef PMIC_INTPRI + DEFINE(PMIC_INTPRI) +#else + MISSING(PMIC_INTPRI) +#endif + +#ifdef PMIC_STATUS + DEFINE(PMIC_STATUS) +#else + MISSING(PMIC_STATUS) +#endif + +#ifdef POC + DEFINE(POC) +#else + MISSING(POC) +#endif + +#ifdef POCR0RA + DEFINE(POCR0RA) +#else + MISSING(POCR0RA) +#endif + +#ifdef POCR0RAH + DEFINE(POCR0RAH) +#else + MISSING(POCR0RAH) +#endif + +#ifdef POCR0RAL + DEFINE(POCR0RAL) +#else + MISSING(POCR0RAL) +#endif + +#ifdef POCR0SA + DEFINE(POCR0SA) +#else + MISSING(POCR0SA) +#endif + +#ifdef POCR0SAH + DEFINE(POCR0SAH) +#else + MISSING(POCR0SAH) +#endif + +#ifdef POCR0SAL + DEFINE(POCR0SAL) +#else + MISSING(POCR0SAL) +#endif + +#ifdef POCR0SB + DEFINE(POCR0SB) +#else + MISSING(POCR0SB) +#endif + +#ifdef POCR0SBH + DEFINE(POCR0SBH) +#else + MISSING(POCR0SBH) +#endif + +#ifdef POCR0SBL + DEFINE(POCR0SBL) +#else + MISSING(POCR0SBL) +#endif + +#ifdef POCR1RA + DEFINE(POCR1RA) +#else + MISSING(POCR1RA) +#endif + +#ifdef POCR1RAH + DEFINE(POCR1RAH) +#else + MISSING(POCR1RAH) +#endif + +#ifdef POCR1RAL + DEFINE(POCR1RAL) +#else + MISSING(POCR1RAL) +#endif + +#ifdef POCR1SA + DEFINE(POCR1SA) +#else + MISSING(POCR1SA) +#endif + +#ifdef POCR1SAH + DEFINE(POCR1SAH) +#else + MISSING(POCR1SAH) +#endif + +#ifdef POCR1SAL + DEFINE(POCR1SAL) +#else + MISSING(POCR1SAL) +#endif + +#ifdef POCR1SB + DEFINE(POCR1SB) +#else + MISSING(POCR1SB) +#endif + +#ifdef POCR1SBH + DEFINE(POCR1SBH) +#else + MISSING(POCR1SBH) +#endif + +#ifdef POCR1SBL + DEFINE(POCR1SBL) +#else + MISSING(POCR1SBL) +#endif + +#ifdef POCR2RA + DEFINE(POCR2RA) +#else + MISSING(POCR2RA) +#endif + +#ifdef POCR2RAH + DEFINE(POCR2RAH) +#else + MISSING(POCR2RAH) +#endif + +#ifdef POCR2RAL + DEFINE(POCR2RAL) +#else + MISSING(POCR2RAL) +#endif + +#ifdef POCR2SA + DEFINE(POCR2SA) +#else + MISSING(POCR2SA) +#endif + +#ifdef POCR2SAH + DEFINE(POCR2SAH) +#else + MISSING(POCR2SAH) +#endif + +#ifdef POCR2SAL + DEFINE(POCR2SAL) +#else + MISSING(POCR2SAL) +#endif + +#ifdef POCR2SB + DEFINE(POCR2SB) +#else + MISSING(POCR2SB) +#endif + +#ifdef POCR2SBH + DEFINE(POCR2SBH) +#else + MISSING(POCR2SBH) +#endif + +#ifdef POCR2SBL + DEFINE(POCR2SBL) +#else + MISSING(POCR2SBL) +#endif + +#ifdef POCR_RB + DEFINE(POCR_RB) +#else + MISSING(POCR_RB) +#endif + +#ifdef POCR_RBH + DEFINE(POCR_RBH) +#else + MISSING(POCR_RBH) +#endif + +#ifdef POCR_RBL + DEFINE(POCR_RBL) +#else + MISSING(POCR_RBL) +#endif + +#ifdef POCRxRB + DEFINE(POCRxRB) +#else + MISSING(POCRxRB) +#endif + +#ifdef POCRxRBH + DEFINE(POCRxRBH) +#else + MISSING(POCRxRBH) +#endif + +#ifdef POCRxRBL + DEFINE(POCRxRBL) +#else + MISSING(POCRxRBL) +#endif + +#ifdef POM2 + DEFINE(POM2) +#else + MISSING(POM2) +#endif + +#ifdef PORTA + DEFINE(PORTA) +#else + MISSING(PORTA) +#endif + +#ifdef PORTA_DIR + DEFINE(PORTA_DIR) +#else + MISSING(PORTA_DIR) +#endif + +#ifdef PORTA_DIRCLR + DEFINE(PORTA_DIRCLR) +#else + MISSING(PORTA_DIRCLR) +#endif + +#ifdef PORTA_DIRSET + DEFINE(PORTA_DIRSET) +#else + MISSING(PORTA_DIRSET) +#endif + +#ifdef PORTA_DIRTGL + DEFINE(PORTA_DIRTGL) +#else + MISSING(PORTA_DIRTGL) +#endif + +#ifdef PORTA_IN + DEFINE(PORTA_IN) +#else + MISSING(PORTA_IN) +#endif + +#ifdef PORTA_INT0MASK + DEFINE(PORTA_INT0MASK) +#else + MISSING(PORTA_INT0MASK) +#endif + +#ifdef PORTA_INT1MASK + DEFINE(PORTA_INT1MASK) +#else + MISSING(PORTA_INT1MASK) +#endif + +#ifdef PORTA_INTCTRL + DEFINE(PORTA_INTCTRL) +#else + MISSING(PORTA_INTCTRL) +#endif + +#ifdef PORTA_INTFLAGS + DEFINE(PORTA_INTFLAGS) +#else + MISSING(PORTA_INTFLAGS) +#endif + +#ifdef PORTA_OUT + DEFINE(PORTA_OUT) +#else + MISSING(PORTA_OUT) +#endif + +#ifdef PORTA_OUTCLR + DEFINE(PORTA_OUTCLR) +#else + MISSING(PORTA_OUTCLR) +#endif + +#ifdef PORTA_OUTSET + DEFINE(PORTA_OUTSET) +#else + MISSING(PORTA_OUTSET) +#endif + +#ifdef PORTA_OUTTGL + DEFINE(PORTA_OUTTGL) +#else + MISSING(PORTA_OUTTGL) +#endif + +#ifdef PORTA_PIN0CTRL + DEFINE(PORTA_PIN0CTRL) +#else + MISSING(PORTA_PIN0CTRL) +#endif + +#ifdef PORTA_PIN1CTRL + DEFINE(PORTA_PIN1CTRL) +#else + MISSING(PORTA_PIN1CTRL) +#endif + +#ifdef PORTA_PIN2CTRL + DEFINE(PORTA_PIN2CTRL) +#else + MISSING(PORTA_PIN2CTRL) +#endif + +#ifdef PORTA_PIN3CTRL + DEFINE(PORTA_PIN3CTRL) +#else + MISSING(PORTA_PIN3CTRL) +#endif + +#ifdef PORTA_PIN4CTRL + DEFINE(PORTA_PIN4CTRL) +#else + MISSING(PORTA_PIN4CTRL) +#endif + +#ifdef PORTA_PIN5CTRL + DEFINE(PORTA_PIN5CTRL) +#else + MISSING(PORTA_PIN5CTRL) +#endif + +#ifdef PORTA_PIN6CTRL + DEFINE(PORTA_PIN6CTRL) +#else + MISSING(PORTA_PIN6CTRL) +#endif + +#ifdef PORTA_PIN7CTRL + DEFINE(PORTA_PIN7CTRL) +#else + MISSING(PORTA_PIN7CTRL) +#endif + +#ifdef PORTB + DEFINE(PORTB) +#else + MISSING(PORTB) +#endif + +#ifdef PORTB_DIR + DEFINE(PORTB_DIR) +#else + MISSING(PORTB_DIR) +#endif + +#ifdef PORTB_DIRCLR + DEFINE(PORTB_DIRCLR) +#else + MISSING(PORTB_DIRCLR) +#endif + +#ifdef PORTB_DIRSET + DEFINE(PORTB_DIRSET) +#else + MISSING(PORTB_DIRSET) +#endif + +#ifdef PORTB_DIRTGL + DEFINE(PORTB_DIRTGL) +#else + MISSING(PORTB_DIRTGL) +#endif + +#ifdef PORTB_IN + DEFINE(PORTB_IN) +#else + MISSING(PORTB_IN) +#endif + +#ifdef PORTB_INT0MASK + DEFINE(PORTB_INT0MASK) +#else + MISSING(PORTB_INT0MASK) +#endif + +#ifdef PORTB_INT1MASK + DEFINE(PORTB_INT1MASK) +#else + MISSING(PORTB_INT1MASK) +#endif + +#ifdef PORTB_INTCTRL + DEFINE(PORTB_INTCTRL) +#else + MISSING(PORTB_INTCTRL) +#endif + +#ifdef PORTB_INTFLAGS + DEFINE(PORTB_INTFLAGS) +#else + MISSING(PORTB_INTFLAGS) +#endif + +#ifdef PORTB_OUT + DEFINE(PORTB_OUT) +#else + MISSING(PORTB_OUT) +#endif + +#ifdef PORTB_OUTCLR + DEFINE(PORTB_OUTCLR) +#else + MISSING(PORTB_OUTCLR) +#endif + +#ifdef PORTB_OUTSET + DEFINE(PORTB_OUTSET) +#else + MISSING(PORTB_OUTSET) +#endif + +#ifdef PORTB_OUTTGL + DEFINE(PORTB_OUTTGL) +#else + MISSING(PORTB_OUTTGL) +#endif + +#ifdef PORTB_PIN0CTRL + DEFINE(PORTB_PIN0CTRL) +#else + MISSING(PORTB_PIN0CTRL) +#endif + +#ifdef PORTB_PIN1CTRL + DEFINE(PORTB_PIN1CTRL) +#else + MISSING(PORTB_PIN1CTRL) +#endif + +#ifdef PORTB_PIN2CTRL + DEFINE(PORTB_PIN2CTRL) +#else + MISSING(PORTB_PIN2CTRL) +#endif + +#ifdef PORTB_PIN3CTRL + DEFINE(PORTB_PIN3CTRL) +#else + MISSING(PORTB_PIN3CTRL) +#endif + +#ifdef PORTB_PIN4CTRL + DEFINE(PORTB_PIN4CTRL) +#else + MISSING(PORTB_PIN4CTRL) +#endif + +#ifdef PORTB_PIN5CTRL + DEFINE(PORTB_PIN5CTRL) +#else + MISSING(PORTB_PIN5CTRL) +#endif + +#ifdef PORTB_PIN6CTRL + DEFINE(PORTB_PIN6CTRL) +#else + MISSING(PORTB_PIN6CTRL) +#endif + +#ifdef PORTB_PIN7CTRL + DEFINE(PORTB_PIN7CTRL) +#else + MISSING(PORTB_PIN7CTRL) +#endif + +#ifdef PORTC + DEFINE(PORTC) +#else + MISSING(PORTC) +#endif + +#ifdef PORTCFG_CLKEVOUT + DEFINE(PORTCFG_CLKEVOUT) +#else + MISSING(PORTCFG_CLKEVOUT) +#endif + +#ifdef PORTCFG_MPCMASK + DEFINE(PORTCFG_MPCMASK) +#else + MISSING(PORTCFG_MPCMASK) +#endif + +#ifdef PORTCFG_VPCTRLA + DEFINE(PORTCFG_VPCTRLA) +#else + MISSING(PORTCFG_VPCTRLA) +#endif + +#ifdef PORTCFG_VPCTRLB + DEFINE(PORTCFG_VPCTRLB) +#else + MISSING(PORTCFG_VPCTRLB) +#endif + +#ifdef PORTCR + DEFINE(PORTCR) +#else + MISSING(PORTCR) +#endif + +#ifdef PORTC_DIR + DEFINE(PORTC_DIR) +#else + MISSING(PORTC_DIR) +#endif + +#ifdef PORTC_DIRCLR + DEFINE(PORTC_DIRCLR) +#else + MISSING(PORTC_DIRCLR) +#endif + +#ifdef PORTC_DIRSET + DEFINE(PORTC_DIRSET) +#else + MISSING(PORTC_DIRSET) +#endif + +#ifdef PORTC_DIRTGL + DEFINE(PORTC_DIRTGL) +#else + MISSING(PORTC_DIRTGL) +#endif + +#ifdef PORTC_IN + DEFINE(PORTC_IN) +#else + MISSING(PORTC_IN) +#endif + +#ifdef PORTC_INT0MASK + DEFINE(PORTC_INT0MASK) +#else + MISSING(PORTC_INT0MASK) +#endif + +#ifdef PORTC_INT1MASK + DEFINE(PORTC_INT1MASK) +#else + MISSING(PORTC_INT1MASK) +#endif + +#ifdef PORTC_INTCTRL + DEFINE(PORTC_INTCTRL) +#else + MISSING(PORTC_INTCTRL) +#endif + +#ifdef PORTC_INTFLAGS + DEFINE(PORTC_INTFLAGS) +#else + MISSING(PORTC_INTFLAGS) +#endif + +#ifdef PORTC_OUT + DEFINE(PORTC_OUT) +#else + MISSING(PORTC_OUT) +#endif + +#ifdef PORTC_OUTCLR + DEFINE(PORTC_OUTCLR) +#else + MISSING(PORTC_OUTCLR) +#endif + +#ifdef PORTC_OUTSET + DEFINE(PORTC_OUTSET) +#else + MISSING(PORTC_OUTSET) +#endif + +#ifdef PORTC_OUTTGL + DEFINE(PORTC_OUTTGL) +#else + MISSING(PORTC_OUTTGL) +#endif + +#ifdef PORTC_PIN0CTRL + DEFINE(PORTC_PIN0CTRL) +#else + MISSING(PORTC_PIN0CTRL) +#endif + +#ifdef PORTC_PIN1CTRL + DEFINE(PORTC_PIN1CTRL) +#else + MISSING(PORTC_PIN1CTRL) +#endif + +#ifdef PORTC_PIN2CTRL + DEFINE(PORTC_PIN2CTRL) +#else + MISSING(PORTC_PIN2CTRL) +#endif + +#ifdef PORTC_PIN3CTRL + DEFINE(PORTC_PIN3CTRL) +#else + MISSING(PORTC_PIN3CTRL) +#endif + +#ifdef PORTC_PIN4CTRL + DEFINE(PORTC_PIN4CTRL) +#else + MISSING(PORTC_PIN4CTRL) +#endif + +#ifdef PORTC_PIN5CTRL + DEFINE(PORTC_PIN5CTRL) +#else + MISSING(PORTC_PIN5CTRL) +#endif + +#ifdef PORTC_PIN6CTRL + DEFINE(PORTC_PIN6CTRL) +#else + MISSING(PORTC_PIN6CTRL) +#endif + +#ifdef PORTC_PIN7CTRL + DEFINE(PORTC_PIN7CTRL) +#else + MISSING(PORTC_PIN7CTRL) +#endif + +#ifdef PORTD + DEFINE(PORTD) +#else + MISSING(PORTD) +#endif + +#ifdef PORTD_DIR + DEFINE(PORTD_DIR) +#else + MISSING(PORTD_DIR) +#endif + +#ifdef PORTD_DIRCLR + DEFINE(PORTD_DIRCLR) +#else + MISSING(PORTD_DIRCLR) +#endif + +#ifdef PORTD_DIRSET + DEFINE(PORTD_DIRSET) +#else + MISSING(PORTD_DIRSET) +#endif + +#ifdef PORTD_DIRTGL + DEFINE(PORTD_DIRTGL) +#else + MISSING(PORTD_DIRTGL) +#endif + +#ifdef PORTD_IN + DEFINE(PORTD_IN) +#else + MISSING(PORTD_IN) +#endif + +#ifdef PORTD_INT0MASK + DEFINE(PORTD_INT0MASK) +#else + MISSING(PORTD_INT0MASK) +#endif + +#ifdef PORTD_INT1MASK + DEFINE(PORTD_INT1MASK) +#else + MISSING(PORTD_INT1MASK) +#endif + +#ifdef PORTD_INTCTRL + DEFINE(PORTD_INTCTRL) +#else + MISSING(PORTD_INTCTRL) +#endif + +#ifdef PORTD_INTFLAGS + DEFINE(PORTD_INTFLAGS) +#else + MISSING(PORTD_INTFLAGS) +#endif + +#ifdef PORTD_OUT + DEFINE(PORTD_OUT) +#else + MISSING(PORTD_OUT) +#endif + +#ifdef PORTD_OUTCLR + DEFINE(PORTD_OUTCLR) +#else + MISSING(PORTD_OUTCLR) +#endif + +#ifdef PORTD_OUTSET + DEFINE(PORTD_OUTSET) +#else + MISSING(PORTD_OUTSET) +#endif + +#ifdef PORTD_OUTTGL + DEFINE(PORTD_OUTTGL) +#else + MISSING(PORTD_OUTTGL) +#endif + +#ifdef PORTD_PIN0CTRL + DEFINE(PORTD_PIN0CTRL) +#else + MISSING(PORTD_PIN0CTRL) +#endif + +#ifdef PORTD_PIN1CTRL + DEFINE(PORTD_PIN1CTRL) +#else + MISSING(PORTD_PIN1CTRL) +#endif + +#ifdef PORTD_PIN2CTRL + DEFINE(PORTD_PIN2CTRL) +#else + MISSING(PORTD_PIN2CTRL) +#endif + +#ifdef PORTD_PIN3CTRL + DEFINE(PORTD_PIN3CTRL) +#else + MISSING(PORTD_PIN3CTRL) +#endif + +#ifdef PORTD_PIN4CTRL + DEFINE(PORTD_PIN4CTRL) +#else + MISSING(PORTD_PIN4CTRL) +#endif + +#ifdef PORTD_PIN5CTRL + DEFINE(PORTD_PIN5CTRL) +#else + MISSING(PORTD_PIN5CTRL) +#endif + +#ifdef PORTD_PIN6CTRL + DEFINE(PORTD_PIN6CTRL) +#else + MISSING(PORTD_PIN6CTRL) +#endif + +#ifdef PORTD_PIN7CTRL + DEFINE(PORTD_PIN7CTRL) +#else + MISSING(PORTD_PIN7CTRL) +#endif + +#ifdef PORTE + DEFINE(PORTE) +#else + MISSING(PORTE) +#endif + +#ifdef PORTE_DIR + DEFINE(PORTE_DIR) +#else + MISSING(PORTE_DIR) +#endif + +#ifdef PORTE_DIRCLR + DEFINE(PORTE_DIRCLR) +#else + MISSING(PORTE_DIRCLR) +#endif + +#ifdef PORTE_DIRSET + DEFINE(PORTE_DIRSET) +#else + MISSING(PORTE_DIRSET) +#endif + +#ifdef PORTE_DIRTGL + DEFINE(PORTE_DIRTGL) +#else + MISSING(PORTE_DIRTGL) +#endif + +#ifdef PORTE_IN + DEFINE(PORTE_IN) +#else + MISSING(PORTE_IN) +#endif + +#ifdef PORTE_INT0MASK + DEFINE(PORTE_INT0MASK) +#else + MISSING(PORTE_INT0MASK) +#endif + +#ifdef PORTE_INT1MASK + DEFINE(PORTE_INT1MASK) +#else + MISSING(PORTE_INT1MASK) +#endif + +#ifdef PORTE_INTCTRL + DEFINE(PORTE_INTCTRL) +#else + MISSING(PORTE_INTCTRL) +#endif + +#ifdef PORTE_INTFLAGS + DEFINE(PORTE_INTFLAGS) +#else + MISSING(PORTE_INTFLAGS) +#endif + +#ifdef PORTE_OUT + DEFINE(PORTE_OUT) +#else + MISSING(PORTE_OUT) +#endif + +#ifdef PORTE_OUTCLR + DEFINE(PORTE_OUTCLR) +#else + MISSING(PORTE_OUTCLR) +#endif + +#ifdef PORTE_OUTSET + DEFINE(PORTE_OUTSET) +#else + MISSING(PORTE_OUTSET) +#endif + +#ifdef PORTE_OUTTGL + DEFINE(PORTE_OUTTGL) +#else + MISSING(PORTE_OUTTGL) +#endif + +#ifdef PORTE_PIN0CTRL + DEFINE(PORTE_PIN0CTRL) +#else + MISSING(PORTE_PIN0CTRL) +#endif + +#ifdef PORTE_PIN1CTRL + DEFINE(PORTE_PIN1CTRL) +#else + MISSING(PORTE_PIN1CTRL) +#endif + +#ifdef PORTE_PIN2CTRL + DEFINE(PORTE_PIN2CTRL) +#else + MISSING(PORTE_PIN2CTRL) +#endif + +#ifdef PORTE_PIN3CTRL + DEFINE(PORTE_PIN3CTRL) +#else + MISSING(PORTE_PIN3CTRL) +#endif + +#ifdef PORTE_PIN4CTRL + DEFINE(PORTE_PIN4CTRL) +#else + MISSING(PORTE_PIN4CTRL) +#endif + +#ifdef PORTE_PIN5CTRL + DEFINE(PORTE_PIN5CTRL) +#else + MISSING(PORTE_PIN5CTRL) +#endif + +#ifdef PORTE_PIN6CTRL + DEFINE(PORTE_PIN6CTRL) +#else + MISSING(PORTE_PIN6CTRL) +#endif + +#ifdef PORTE_PIN7CTRL + DEFINE(PORTE_PIN7CTRL) +#else + MISSING(PORTE_PIN7CTRL) +#endif + +#ifdef PORTF + DEFINE(PORTF) +#else + MISSING(PORTF) +#endif + +#ifdef PORTF_DIR + DEFINE(PORTF_DIR) +#else + MISSING(PORTF_DIR) +#endif + +#ifdef PORTF_DIRCLR + DEFINE(PORTF_DIRCLR) +#else + MISSING(PORTF_DIRCLR) +#endif + +#ifdef PORTF_DIRSET + DEFINE(PORTF_DIRSET) +#else + MISSING(PORTF_DIRSET) +#endif + +#ifdef PORTF_DIRTGL + DEFINE(PORTF_DIRTGL) +#else + MISSING(PORTF_DIRTGL) +#endif + +#ifdef PORTF_IN + DEFINE(PORTF_IN) +#else + MISSING(PORTF_IN) +#endif + +#ifdef PORTF_INT0MASK + DEFINE(PORTF_INT0MASK) +#else + MISSING(PORTF_INT0MASK) +#endif + +#ifdef PORTF_INT1MASK + DEFINE(PORTF_INT1MASK) +#else + MISSING(PORTF_INT1MASK) +#endif + +#ifdef PORTF_INTCTRL + DEFINE(PORTF_INTCTRL) +#else + MISSING(PORTF_INTCTRL) +#endif + +#ifdef PORTF_INTFLAGS + DEFINE(PORTF_INTFLAGS) +#else + MISSING(PORTF_INTFLAGS) +#endif + +#ifdef PORTF_OUT + DEFINE(PORTF_OUT) +#else + MISSING(PORTF_OUT) +#endif + +#ifdef PORTF_OUTCLR + DEFINE(PORTF_OUTCLR) +#else + MISSING(PORTF_OUTCLR) +#endif + +#ifdef PORTF_OUTSET + DEFINE(PORTF_OUTSET) +#else + MISSING(PORTF_OUTSET) +#endif + +#ifdef PORTF_OUTTGL + DEFINE(PORTF_OUTTGL) +#else + MISSING(PORTF_OUTTGL) +#endif + +#ifdef PORTF_PIN0CTRL + DEFINE(PORTF_PIN0CTRL) +#else + MISSING(PORTF_PIN0CTRL) +#endif + +#ifdef PORTF_PIN1CTRL + DEFINE(PORTF_PIN1CTRL) +#else + MISSING(PORTF_PIN1CTRL) +#endif + +#ifdef PORTF_PIN2CTRL + DEFINE(PORTF_PIN2CTRL) +#else + MISSING(PORTF_PIN2CTRL) +#endif + +#ifdef PORTF_PIN3CTRL + DEFINE(PORTF_PIN3CTRL) +#else + MISSING(PORTF_PIN3CTRL) +#endif + +#ifdef PORTF_PIN4CTRL + DEFINE(PORTF_PIN4CTRL) +#else + MISSING(PORTF_PIN4CTRL) +#endif + +#ifdef PORTF_PIN5CTRL + DEFINE(PORTF_PIN5CTRL) +#else + MISSING(PORTF_PIN5CTRL) +#endif + +#ifdef PORTF_PIN6CTRL + DEFINE(PORTF_PIN6CTRL) +#else + MISSING(PORTF_PIN6CTRL) +#endif + +#ifdef PORTF_PIN7CTRL + DEFINE(PORTF_PIN7CTRL) +#else + MISSING(PORTF_PIN7CTRL) +#endif + +#ifdef PORTG + DEFINE(PORTG) +#else + MISSING(PORTG) +#endif + +#ifdef PORTH + DEFINE(PORTH) +#else + MISSING(PORTH) +#endif + +#ifdef PORTH_DIR + DEFINE(PORTH_DIR) +#else + MISSING(PORTH_DIR) +#endif + +#ifdef PORTH_DIRCLR + DEFINE(PORTH_DIRCLR) +#else + MISSING(PORTH_DIRCLR) +#endif + +#ifdef PORTH_DIRSET + DEFINE(PORTH_DIRSET) +#else + MISSING(PORTH_DIRSET) +#endif + +#ifdef PORTH_DIRTGL + DEFINE(PORTH_DIRTGL) +#else + MISSING(PORTH_DIRTGL) +#endif + +#ifdef PORTH_IN + DEFINE(PORTH_IN) +#else + MISSING(PORTH_IN) +#endif + +#ifdef PORTH_INT0MASK + DEFINE(PORTH_INT0MASK) +#else + MISSING(PORTH_INT0MASK) +#endif + +#ifdef PORTH_INT1MASK + DEFINE(PORTH_INT1MASK) +#else + MISSING(PORTH_INT1MASK) +#endif + +#ifdef PORTH_INTCTRL + DEFINE(PORTH_INTCTRL) +#else + MISSING(PORTH_INTCTRL) +#endif + +#ifdef PORTH_INTFLAGS + DEFINE(PORTH_INTFLAGS) +#else + MISSING(PORTH_INTFLAGS) +#endif + +#ifdef PORTH_OUT + DEFINE(PORTH_OUT) +#else + MISSING(PORTH_OUT) +#endif + +#ifdef PORTH_OUTCLR + DEFINE(PORTH_OUTCLR) +#else + MISSING(PORTH_OUTCLR) +#endif + +#ifdef PORTH_OUTSET + DEFINE(PORTH_OUTSET) +#else + MISSING(PORTH_OUTSET) +#endif + +#ifdef PORTH_OUTTGL + DEFINE(PORTH_OUTTGL) +#else + MISSING(PORTH_OUTTGL) +#endif + +#ifdef PORTH_PIN0CTRL + DEFINE(PORTH_PIN0CTRL) +#else + MISSING(PORTH_PIN0CTRL) +#endif + +#ifdef PORTH_PIN1CTRL + DEFINE(PORTH_PIN1CTRL) +#else + MISSING(PORTH_PIN1CTRL) +#endif + +#ifdef PORTH_PIN2CTRL + DEFINE(PORTH_PIN2CTRL) +#else + MISSING(PORTH_PIN2CTRL) +#endif + +#ifdef PORTH_PIN3CTRL + DEFINE(PORTH_PIN3CTRL) +#else + MISSING(PORTH_PIN3CTRL) +#endif + +#ifdef PORTH_PIN4CTRL + DEFINE(PORTH_PIN4CTRL) +#else + MISSING(PORTH_PIN4CTRL) +#endif + +#ifdef PORTH_PIN5CTRL + DEFINE(PORTH_PIN5CTRL) +#else + MISSING(PORTH_PIN5CTRL) +#endif + +#ifdef PORTH_PIN6CTRL + DEFINE(PORTH_PIN6CTRL) +#else + MISSING(PORTH_PIN6CTRL) +#endif + +#ifdef PORTH_PIN7CTRL + DEFINE(PORTH_PIN7CTRL) +#else + MISSING(PORTH_PIN7CTRL) +#endif + +#ifdef PORTJ + DEFINE(PORTJ) +#else + MISSING(PORTJ) +#endif + +#ifdef PORTJ_DIR + DEFINE(PORTJ_DIR) +#else + MISSING(PORTJ_DIR) +#endif + +#ifdef PORTJ_DIRCLR + DEFINE(PORTJ_DIRCLR) +#else + MISSING(PORTJ_DIRCLR) +#endif + +#ifdef PORTJ_DIRSET + DEFINE(PORTJ_DIRSET) +#else + MISSING(PORTJ_DIRSET) +#endif + +#ifdef PORTJ_DIRTGL + DEFINE(PORTJ_DIRTGL) +#else + MISSING(PORTJ_DIRTGL) +#endif + +#ifdef PORTJ_IN + DEFINE(PORTJ_IN) +#else + MISSING(PORTJ_IN) +#endif + +#ifdef PORTJ_INT0MASK + DEFINE(PORTJ_INT0MASK) +#else + MISSING(PORTJ_INT0MASK) +#endif + +#ifdef PORTJ_INT1MASK + DEFINE(PORTJ_INT1MASK) +#else + MISSING(PORTJ_INT1MASK) +#endif + +#ifdef PORTJ_INTCTRL + DEFINE(PORTJ_INTCTRL) +#else + MISSING(PORTJ_INTCTRL) +#endif + +#ifdef PORTJ_INTFLAGS + DEFINE(PORTJ_INTFLAGS) +#else + MISSING(PORTJ_INTFLAGS) +#endif + +#ifdef PORTJ_OUT + DEFINE(PORTJ_OUT) +#else + MISSING(PORTJ_OUT) +#endif + +#ifdef PORTJ_OUTCLR + DEFINE(PORTJ_OUTCLR) +#else + MISSING(PORTJ_OUTCLR) +#endif + +#ifdef PORTJ_OUTSET + DEFINE(PORTJ_OUTSET) +#else + MISSING(PORTJ_OUTSET) +#endif + +#ifdef PORTJ_OUTTGL + DEFINE(PORTJ_OUTTGL) +#else + MISSING(PORTJ_OUTTGL) +#endif + +#ifdef PORTJ_PIN0CTRL + DEFINE(PORTJ_PIN0CTRL) +#else + MISSING(PORTJ_PIN0CTRL) +#endif + +#ifdef PORTJ_PIN1CTRL + DEFINE(PORTJ_PIN1CTRL) +#else + MISSING(PORTJ_PIN1CTRL) +#endif + +#ifdef PORTJ_PIN2CTRL + DEFINE(PORTJ_PIN2CTRL) +#else + MISSING(PORTJ_PIN2CTRL) +#endif + +#ifdef PORTJ_PIN3CTRL + DEFINE(PORTJ_PIN3CTRL) +#else + MISSING(PORTJ_PIN3CTRL) +#endif + +#ifdef PORTJ_PIN4CTRL + DEFINE(PORTJ_PIN4CTRL) +#else + MISSING(PORTJ_PIN4CTRL) +#endif + +#ifdef PORTJ_PIN5CTRL + DEFINE(PORTJ_PIN5CTRL) +#else + MISSING(PORTJ_PIN5CTRL) +#endif + +#ifdef PORTJ_PIN6CTRL + DEFINE(PORTJ_PIN6CTRL) +#else + MISSING(PORTJ_PIN6CTRL) +#endif + +#ifdef PORTJ_PIN7CTRL + DEFINE(PORTJ_PIN7CTRL) +#else + MISSING(PORTJ_PIN7CTRL) +#endif + +#ifdef PORTK + DEFINE(PORTK) +#else + MISSING(PORTK) +#endif + +#ifdef PORTK_DIR + DEFINE(PORTK_DIR) +#else + MISSING(PORTK_DIR) +#endif + +#ifdef PORTK_DIRCLR + DEFINE(PORTK_DIRCLR) +#else + MISSING(PORTK_DIRCLR) +#endif + +#ifdef PORTK_DIRSET + DEFINE(PORTK_DIRSET) +#else + MISSING(PORTK_DIRSET) +#endif + +#ifdef PORTK_DIRTGL + DEFINE(PORTK_DIRTGL) +#else + MISSING(PORTK_DIRTGL) +#endif + +#ifdef PORTK_IN + DEFINE(PORTK_IN) +#else + MISSING(PORTK_IN) +#endif + +#ifdef PORTK_INT0MASK + DEFINE(PORTK_INT0MASK) +#else + MISSING(PORTK_INT0MASK) +#endif + +#ifdef PORTK_INT1MASK + DEFINE(PORTK_INT1MASK) +#else + MISSING(PORTK_INT1MASK) +#endif + +#ifdef PORTK_INTCTRL + DEFINE(PORTK_INTCTRL) +#else + MISSING(PORTK_INTCTRL) +#endif + +#ifdef PORTK_INTFLAGS + DEFINE(PORTK_INTFLAGS) +#else + MISSING(PORTK_INTFLAGS) +#endif + +#ifdef PORTK_OUT + DEFINE(PORTK_OUT) +#else + MISSING(PORTK_OUT) +#endif + +#ifdef PORTK_OUTCLR + DEFINE(PORTK_OUTCLR) +#else + MISSING(PORTK_OUTCLR) +#endif + +#ifdef PORTK_OUTSET + DEFINE(PORTK_OUTSET) +#else + MISSING(PORTK_OUTSET) +#endif + +#ifdef PORTK_OUTTGL + DEFINE(PORTK_OUTTGL) +#else + MISSING(PORTK_OUTTGL) +#endif + +#ifdef PORTK_PIN0CTRL + DEFINE(PORTK_PIN0CTRL) +#else + MISSING(PORTK_PIN0CTRL) +#endif + +#ifdef PORTK_PIN1CTRL + DEFINE(PORTK_PIN1CTRL) +#else + MISSING(PORTK_PIN1CTRL) +#endif + +#ifdef PORTK_PIN2CTRL + DEFINE(PORTK_PIN2CTRL) +#else + MISSING(PORTK_PIN2CTRL) +#endif + +#ifdef PORTK_PIN3CTRL + DEFINE(PORTK_PIN3CTRL) +#else + MISSING(PORTK_PIN3CTRL) +#endif + +#ifdef PORTK_PIN4CTRL + DEFINE(PORTK_PIN4CTRL) +#else + MISSING(PORTK_PIN4CTRL) +#endif + +#ifdef PORTK_PIN5CTRL + DEFINE(PORTK_PIN5CTRL) +#else + MISSING(PORTK_PIN5CTRL) +#endif + +#ifdef PORTK_PIN6CTRL + DEFINE(PORTK_PIN6CTRL) +#else + MISSING(PORTK_PIN6CTRL) +#endif + +#ifdef PORTK_PIN7CTRL + DEFINE(PORTK_PIN7CTRL) +#else + MISSING(PORTK_PIN7CTRL) +#endif + +#ifdef PORTL + DEFINE(PORTL) +#else + MISSING(PORTL) +#endif + +#ifdef PORTQ_DIR + DEFINE(PORTQ_DIR) +#else + MISSING(PORTQ_DIR) +#endif + +#ifdef PORTQ_DIRCLR + DEFINE(PORTQ_DIRCLR) +#else + MISSING(PORTQ_DIRCLR) +#endif + +#ifdef PORTQ_DIRSET + DEFINE(PORTQ_DIRSET) +#else + MISSING(PORTQ_DIRSET) +#endif + +#ifdef PORTQ_DIRTGL + DEFINE(PORTQ_DIRTGL) +#else + MISSING(PORTQ_DIRTGL) +#endif + +#ifdef PORTQ_IN + DEFINE(PORTQ_IN) +#else + MISSING(PORTQ_IN) +#endif + +#ifdef PORTQ_INT0MASK + DEFINE(PORTQ_INT0MASK) +#else + MISSING(PORTQ_INT0MASK) +#endif + +#ifdef PORTQ_INT1MASK + DEFINE(PORTQ_INT1MASK) +#else + MISSING(PORTQ_INT1MASK) +#endif + +#ifdef PORTQ_INTCTRL + DEFINE(PORTQ_INTCTRL) +#else + MISSING(PORTQ_INTCTRL) +#endif + +#ifdef PORTQ_INTFLAGS + DEFINE(PORTQ_INTFLAGS) +#else + MISSING(PORTQ_INTFLAGS) +#endif + +#ifdef PORTQ_OUT + DEFINE(PORTQ_OUT) +#else + MISSING(PORTQ_OUT) +#endif + +#ifdef PORTQ_OUTCLR + DEFINE(PORTQ_OUTCLR) +#else + MISSING(PORTQ_OUTCLR) +#endif + +#ifdef PORTQ_OUTSET + DEFINE(PORTQ_OUTSET) +#else + MISSING(PORTQ_OUTSET) +#endif + +#ifdef PORTQ_OUTTGL + DEFINE(PORTQ_OUTTGL) +#else + MISSING(PORTQ_OUTTGL) +#endif + +#ifdef PORTQ_PIN0CTRL + DEFINE(PORTQ_PIN0CTRL) +#else + MISSING(PORTQ_PIN0CTRL) +#endif + +#ifdef PORTQ_PIN1CTRL + DEFINE(PORTQ_PIN1CTRL) +#else + MISSING(PORTQ_PIN1CTRL) +#endif + +#ifdef PORTQ_PIN2CTRL + DEFINE(PORTQ_PIN2CTRL) +#else + MISSING(PORTQ_PIN2CTRL) +#endif + +#ifdef PORTQ_PIN3CTRL + DEFINE(PORTQ_PIN3CTRL) +#else + MISSING(PORTQ_PIN3CTRL) +#endif + +#ifdef PORTQ_PIN4CTRL + DEFINE(PORTQ_PIN4CTRL) +#else + MISSING(PORTQ_PIN4CTRL) +#endif + +#ifdef PORTQ_PIN5CTRL + DEFINE(PORTQ_PIN5CTRL) +#else + MISSING(PORTQ_PIN5CTRL) +#endif + +#ifdef PORTQ_PIN6CTRL + DEFINE(PORTQ_PIN6CTRL) +#else + MISSING(PORTQ_PIN6CTRL) +#endif + +#ifdef PORTQ_PIN7CTRL + DEFINE(PORTQ_PIN7CTRL) +#else + MISSING(PORTQ_PIN7CTRL) +#endif + +#ifdef PORTR_DIR + DEFINE(PORTR_DIR) +#else + MISSING(PORTR_DIR) +#endif + +#ifdef PORTR_DIRCLR + DEFINE(PORTR_DIRCLR) +#else + MISSING(PORTR_DIRCLR) +#endif + +#ifdef PORTR_DIRSET + DEFINE(PORTR_DIRSET) +#else + MISSING(PORTR_DIRSET) +#endif + +#ifdef PORTR_DIRTGL + DEFINE(PORTR_DIRTGL) +#else + MISSING(PORTR_DIRTGL) +#endif + +#ifdef PORTR_IN + DEFINE(PORTR_IN) +#else + MISSING(PORTR_IN) +#endif + +#ifdef PORTR_INT0MASK + DEFINE(PORTR_INT0MASK) +#else + MISSING(PORTR_INT0MASK) +#endif + +#ifdef PORTR_INT1MASK + DEFINE(PORTR_INT1MASK) +#else + MISSING(PORTR_INT1MASK) +#endif + +#ifdef PORTR_INTCTRL + DEFINE(PORTR_INTCTRL) +#else + MISSING(PORTR_INTCTRL) +#endif + +#ifdef PORTR_INTFLAGS + DEFINE(PORTR_INTFLAGS) +#else + MISSING(PORTR_INTFLAGS) +#endif + +#ifdef PORTR_OUT + DEFINE(PORTR_OUT) +#else + MISSING(PORTR_OUT) +#endif + +#ifdef PORTR_OUTCLR + DEFINE(PORTR_OUTCLR) +#else + MISSING(PORTR_OUTCLR) +#endif + +#ifdef PORTR_OUTSET + DEFINE(PORTR_OUTSET) +#else + MISSING(PORTR_OUTSET) +#endif + +#ifdef PORTR_OUTTGL + DEFINE(PORTR_OUTTGL) +#else + MISSING(PORTR_OUTTGL) +#endif + +#ifdef PORTR_PIN0CTRL + DEFINE(PORTR_PIN0CTRL) +#else + MISSING(PORTR_PIN0CTRL) +#endif + +#ifdef PORTR_PIN1CTRL + DEFINE(PORTR_PIN1CTRL) +#else + MISSING(PORTR_PIN1CTRL) +#endif + +#ifdef PORTR_PIN2CTRL + DEFINE(PORTR_PIN2CTRL) +#else + MISSING(PORTR_PIN2CTRL) +#endif + +#ifdef PORTR_PIN3CTRL + DEFINE(PORTR_PIN3CTRL) +#else + MISSING(PORTR_PIN3CTRL) +#endif + +#ifdef PORTR_PIN4CTRL + DEFINE(PORTR_PIN4CTRL) +#else + MISSING(PORTR_PIN4CTRL) +#endif + +#ifdef PORTR_PIN5CTRL + DEFINE(PORTR_PIN5CTRL) +#else + MISSING(PORTR_PIN5CTRL) +#endif + +#ifdef PORTR_PIN6CTRL + DEFINE(PORTR_PIN6CTRL) +#else + MISSING(PORTR_PIN6CTRL) +#endif + +#ifdef PORTR_PIN7CTRL + DEFINE(PORTR_PIN7CTRL) +#else + MISSING(PORTR_PIN7CTRL) +#endif + +#ifdef PRELD + DEFINE(PRELD) +#else + MISSING(PRELD) +#endif + +#ifdef PRR + DEFINE(PRR) +#else + MISSING(PRR) +#endif + +#ifdef PRR0 + DEFINE(PRR0) +#else + MISSING(PRR0) +#endif + +#ifdef PRR1 + DEFINE(PRR1) +#else + MISSING(PRR1) +#endif + +#ifdef PRR2 + DEFINE(PRR2) +#else + MISSING(PRR2) +#endif + +#ifdef PR_PRGEN + DEFINE(PR_PRGEN) +#else + MISSING(PR_PRGEN) +#endif + +#ifdef PR_PRPA + DEFINE(PR_PRPA) +#else + MISSING(PR_PRPA) +#endif + +#ifdef PR_PRPB + DEFINE(PR_PRPB) +#else + MISSING(PR_PRPB) +#endif + +#ifdef PR_PRPC + DEFINE(PR_PRPC) +#else + MISSING(PR_PRPC) +#endif + +#ifdef PR_PRPD + DEFINE(PR_PRPD) +#else + MISSING(PR_PRPD) +#endif + +#ifdef PR_PRPE + DEFINE(PR_PRPE) +#else + MISSING(PR_PRPE) +#endif + +#ifdef PR_PRPF + DEFINE(PR_PRPF) +#else + MISSING(PR_PRPF) +#endif + +#ifdef PS2CON + DEFINE(PS2CON) +#else + MISSING(PS2CON) +#endif + +#ifdef PSOC0 + DEFINE(PSOC0) +#else + MISSING(PSOC0) +#endif + +#ifdef PSOC1 + DEFINE(PSOC1) +#else + MISSING(PSOC1) +#endif + +#ifdef PSOC2 + DEFINE(PSOC2) +#else + MISSING(PSOC2) +#endif + +#ifdef PSYNC + DEFINE(PSYNC) +#else + MISSING(PSYNC) +#endif + +#ifdef PUEA + DEFINE(PUEA) +#else + MISSING(PUEA) +#endif + +#ifdef PUEB + DEFINE(PUEB) +#else + MISSING(PUEB) +#endif + +#ifdef PUEC + DEFINE(PUEC) +#else + MISSING(PUEC) +#endif + +#ifdef PWMCTL + DEFINE(PWMCTL) +#else + MISSING(PWMCTL) +#endif + +#ifdef PWMMSK + DEFINE(PWMMSK) +#else + MISSING(PWMMSK) +#endif + +#ifdef PWMPER + DEFINE(PWMPER) +#else + MISSING(PWMPER) +#endif + +#ifdef PWMSFRQ + DEFINE(PWMSFRQ) +#else + MISSING(PWMSFRQ) +#endif + +#ifdef PWR_ATTEN + DEFINE(PWR_ATTEN) +#else + MISSING(PWR_ATTEN) +#endif + +#ifdef QTCSR + DEFINE(QTCSR) +#else + MISSING(QTCSR) +#endif + +#ifdef RAMAR + DEFINE(RAMAR) +#else + MISSING(RAMAR) +#endif + +#ifdef RAMDR + DEFINE(RAMDR) +#else + MISSING(RAMDR) +#endif + +#ifdef RAMPD + DEFINE(RAMPD) +#else + MISSING(RAMPD) +#endif + +#ifdef RAMPX + DEFINE(RAMPX) +#else + MISSING(RAMPX) +#endif + +#ifdef RAMPY + DEFINE(RAMPY) +#else + MISSING(RAMPY) +#endif + +#ifdef RAMPZ + DEFINE(RAMPZ) +#else + MISSING(RAMPZ) +#endif + +#ifdef RCCTRL + DEFINE(RCCTRL) +#else + MISSING(RCCTRL) +#endif + +#ifdef RDWDR + DEFINE(RDWDR) +#else + MISSING(RDWDR) +#endif + +#ifdef REGCR + DEFINE(REGCR) +#else + MISSING(REGCR) +#endif + +#ifdef RNGCR + DEFINE(RNGCR) +#else + MISSING(RNGCR) +#endif + +#ifdef ROCR + DEFINE(ROCR) +#else + MISSING(ROCR) +#endif + +#ifdef RSTFLR + DEFINE(RSTFLR) +#else + MISSING(RSTFLR) +#endif + +#ifdef RST_CTRL + DEFINE(RST_CTRL) +#else + MISSING(RST_CTRL) +#endif + +#ifdef RST_STATUS + DEFINE(RST_STATUS) +#else + MISSING(RST_STATUS) +#endif + +#ifdef RTC32_CTRL + DEFINE(RTC32_CTRL) +#else + MISSING(RTC32_CTRL) +#endif + +#ifdef RTC32_INTCTRL + DEFINE(RTC32_INTCTRL) +#else + MISSING(RTC32_INTCTRL) +#endif + +#ifdef RTC32_INTFLAGS + DEFINE(RTC32_INTFLAGS) +#else + MISSING(RTC32_INTFLAGS) +#endif + +#ifdef RTC32_SYNCCTRL + DEFINE(RTC32_SYNCCTRL) +#else + MISSING(RTC32_SYNCCTRL) +#endif + +#ifdef RTC_CNT + DEFINE(RTC_CNT) +#else + MISSING(RTC_CNT) +#endif + +#ifdef RTC_COMP + DEFINE(RTC_COMP) +#else + MISSING(RTC_COMP) +#endif + +#ifdef RTC_CTRL + DEFINE(RTC_CTRL) +#else + MISSING(RTC_CTRL) +#endif + +#ifdef RTC_INTCTRL + DEFINE(RTC_INTCTRL) +#else + MISSING(RTC_INTCTRL) +#endif + +#ifdef RTC_INTFLAGS + DEFINE(RTC_INTFLAGS) +#else + MISSING(RTC_INTFLAGS) +#endif + +#ifdef RTC_PER + DEFINE(RTC_PER) +#else + MISSING(RTC_PER) +#endif + +#ifdef RTC_STATUS + DEFINE(RTC_STATUS) +#else + MISSING(RTC_STATUS) +#endif + +#ifdef RTC_TEMP + DEFINE(RTC_TEMP) +#else + MISSING(RTC_TEMP) +#endif + +#ifdef RXB + DEFINE(RXB) +#else + MISSING(RXB) +#endif + +#ifdef RX_CTRL + DEFINE(RX_CTRL) +#else + MISSING(RX_CTRL) +#endif + +#ifdef RX_SYN + DEFINE(RX_SYN) +#else + MISSING(RX_SYN) +#endif + +#ifdef SCBTSRHH + DEFINE(SCBTSRHH) +#else + MISSING(SCBTSRHH) +#endif + +#ifdef SCBTSRHL + DEFINE(SCBTSRHL) +#else + MISSING(SCBTSRHL) +#endif + +#ifdef SCBTSRLH + DEFINE(SCBTSRLH) +#else + MISSING(SCBTSRLH) +#endif + +#ifdef SCBTSRLL + DEFINE(SCBTSRLL) +#else + MISSING(SCBTSRLL) +#endif + +#ifdef SCCNTHH + DEFINE(SCCNTHH) +#else + MISSING(SCCNTHH) +#endif + +#ifdef SCCNTHL + DEFINE(SCCNTHL) +#else + MISSING(SCCNTHL) +#endif + +#ifdef SCCNTLH + DEFINE(SCCNTLH) +#else + MISSING(SCCNTLH) +#endif + +#ifdef SCCNTLL + DEFINE(SCCNTLL) +#else + MISSING(SCCNTLL) +#endif + +#ifdef SCCON + DEFINE(SCCON) +#else + MISSING(SCCON) +#endif + +#ifdef SCCR + DEFINE(SCCR) +#else + MISSING(SCCR) +#endif + +#ifdef SCCR0 + DEFINE(SCCR0) +#else + MISSING(SCCR0) +#endif + +#ifdef SCCR1 + DEFINE(SCCR1) +#else + MISSING(SCCR1) +#endif + +#ifdef SCETU + DEFINE(SCETU) +#else + MISSING(SCETU) +#endif + +#ifdef SCETUH + DEFINE(SCETUH) +#else + MISSING(SCETUH) +#endif + +#ifdef SCETUL + DEFINE(SCETUL) +#else + MISSING(SCETUL) +#endif + +#ifdef SCGT + DEFINE(SCGT) +#else + MISSING(SCGT) +#endif + +#ifdef SCGTH + DEFINE(SCGTH) +#else + MISSING(SCGTH) +#endif + +#ifdef SCGTL + DEFINE(SCGTL) +#else + MISSING(SCGTL) +#endif + +#ifdef SCIBUF + DEFINE(SCIBUF) +#else + MISSING(SCIBUF) +#endif + +#ifdef SCICLK + DEFINE(SCICLK) +#else + MISSING(SCICLK) +#endif + +#ifdef SCICR + DEFINE(SCICR) +#else + MISSING(SCICR) +#endif + +#ifdef SCIER + DEFINE(SCIER) +#else + MISSING(SCIER) +#endif + +#ifdef SCIIR + DEFINE(SCIIR) +#else + MISSING(SCIIR) +#endif + +#ifdef SCIO + DEFINE(SCIO) +#else + MISSING(SCIO) +#endif + +#ifdef SCIRQM + DEFINE(SCIRQM) +#else + MISSING(SCIRQM) +#endif + +#ifdef SCIRQS + DEFINE(SCIRQS) +#else + MISSING(SCIRQS) +#endif + +#ifdef SCISR + DEFINE(SCISR) +#else + MISSING(SCISR) +#endif + +#ifdef SCOCR1HH + DEFINE(SCOCR1HH) +#else + MISSING(SCOCR1HH) +#endif + +#ifdef SCOCR1HL + DEFINE(SCOCR1HL) +#else + MISSING(SCOCR1HL) +#endif + +#ifdef SCOCR1LH + DEFINE(SCOCR1LH) +#else + MISSING(SCOCR1LH) +#endif + +#ifdef SCOCR1LL + DEFINE(SCOCR1LL) +#else + MISSING(SCOCR1LL) +#endif + +#ifdef SCOCR2HH + DEFINE(SCOCR2HH) +#else + MISSING(SCOCR2HH) +#endif + +#ifdef SCOCR2HL + DEFINE(SCOCR2HL) +#else + MISSING(SCOCR2HL) +#endif + +#ifdef SCOCR2LH + DEFINE(SCOCR2LH) +#else + MISSING(SCOCR2LH) +#endif + +#ifdef SCOCR2LL + DEFINE(SCOCR2LL) +#else + MISSING(SCOCR2LL) +#endif + +#ifdef SCOCR3HH + DEFINE(SCOCR3HH) +#else + MISSING(SCOCR3HH) +#endif + +#ifdef SCOCR3HL + DEFINE(SCOCR3HL) +#else + MISSING(SCOCR3HL) +#endif + +#ifdef SCOCR3LH + DEFINE(SCOCR3LH) +#else + MISSING(SCOCR3LH) +#endif + +#ifdef SCOCR3LL + DEFINE(SCOCR3LL) +#else + MISSING(SCOCR3LL) +#endif + +#ifdef SCR + DEFINE(SCR) +#else + MISSING(SCR) +#endif + +#ifdef SCSR + DEFINE(SCSR) +#else + MISSING(SCSR) +#endif + +#ifdef SCSW + DEFINE(SCSW) +#else + MISSING(SCSW) +#endif + +#ifdef SCTSRHH + DEFINE(SCTSRHH) +#else + MISSING(SCTSRHH) +#endif + +#ifdef SCTSRHL + DEFINE(SCTSRHL) +#else + MISSING(SCTSRHL) +#endif + +#ifdef SCTSRLH + DEFINE(SCTSRLH) +#else + MISSING(SCTSRLH) +#endif + +#ifdef SCTSRLL + DEFINE(SCTSRLL) +#else + MISSING(SCTSRLL) +#endif + +#ifdef SCWT0 + DEFINE(SCWT0) +#else + MISSING(SCWT0) +#endif + +#ifdef SCWT1 + DEFINE(SCWT1) +#else + MISSING(SCWT1) +#endif + +#ifdef SCWT2 + DEFINE(SCWT2) +#else + MISSING(SCWT2) +#endif + +#ifdef SCWT3 + DEFINE(SCWT3) +#else + MISSING(SCWT3) +#endif + +#ifdef SFD_VALUE + DEFINE(SFD_VALUE) +#else + MISSING(SFD_VALUE) +#endif + +#ifdef SFIOR + DEFINE(SFIOR) +#else + MISSING(SFIOR) +#endif + +#ifdef SFTCR + DEFINE(SFTCR) +#else + MISSING(SFTCR) +#endif + +#ifdef SHORT_ADDR_0 + DEFINE(SHORT_ADDR_0) +#else + MISSING(SHORT_ADDR_0) +#endif + +#ifdef SHORT_ADDR_1 + DEFINE(SHORT_ADDR_1) +#else + MISSING(SHORT_ADDR_1) +#endif + +#ifdef SIMSK + DEFINE(SIMSK) +#else + MISSING(SIMSK) +#endif + +#ifdef SINDAC + DEFINE(SINDAC) +#else + MISSING(SINDAC) +#endif + +#ifdef SINDACH + DEFINE(SINDACH) +#else + MISSING(SINDACH) +#endif + +#ifdef SINDACL + DEFINE(SINDACL) +#else + MISSING(SINDACL) +#endif + +#ifdef SLEEP_CTRL + DEFINE(SLEEP_CTRL) +#else + MISSING(SLEEP_CTRL) +#endif + +#ifdef SMCR + DEFINE(SMCR) +#else + MISSING(SMCR) +#endif + +#ifdef SMONCR + DEFINE(SMONCR) +#else + MISSING(SMONCR) +#endif + +#ifdef SOSCCALA + DEFINE(SOSCCALA) +#else + MISSING(SOSCCALA) +#endif + +#ifdef SOSCCALB + DEFINE(SOSCCALB) +#else + MISSING(SOSCCALB) +#endif + +#ifdef SP + DEFINE(SP) +#else + MISSING(SP) +#endif + +#ifdef SPCR + DEFINE(SPCR) +#else + MISSING(SPCR) +#endif + +#ifdef SPCR0 + DEFINE(SPCR0) +#else + MISSING(SPCR0) +#endif + +#ifdef SPDR + DEFINE(SPDR) +#else + MISSING(SPDR) +#endif + +#ifdef SPH + DEFINE(SPH) +#else + MISSING(SPH) +#endif + +#ifdef SPIC_CTRL + DEFINE(SPIC_CTRL) +#else + MISSING(SPIC_CTRL) +#endif + +#ifdef SPIC_DATA + DEFINE(SPIC_DATA) +#else + MISSING(SPIC_DATA) +#endif + +#ifdef SPIC_INTCTRL + DEFINE(SPIC_INTCTRL) +#else + MISSING(SPIC_INTCTRL) +#endif + +#ifdef SPIC_STATUS + DEFINE(SPIC_STATUS) +#else + MISSING(SPIC_STATUS) +#endif + +#ifdef SPID_CTRL + DEFINE(SPID_CTRL) +#else + MISSING(SPID_CTRL) +#endif + +#ifdef SPID_DATA + DEFINE(SPID_DATA) +#else + MISSING(SPID_DATA) +#endif + +#ifdef SPID_INTCTRL + DEFINE(SPID_INTCTRL) +#else + MISSING(SPID_INTCTRL) +#endif + +#ifdef SPID_STATUS + DEFINE(SPID_STATUS) +#else + MISSING(SPID_STATUS) +#endif + +#ifdef SPIE_CTRL + DEFINE(SPIE_CTRL) +#else + MISSING(SPIE_CTRL) +#endif + +#ifdef SPIE_DATA + DEFINE(SPIE_DATA) +#else + MISSING(SPIE_DATA) +#endif + +#ifdef SPIE_INTCTRL + DEFINE(SPIE_INTCTRL) +#else + MISSING(SPIE_INTCTRL) +#endif + +#ifdef SPIE_STATUS + DEFINE(SPIE_STATUS) +#else + MISSING(SPIE_STATUS) +#endif + +#ifdef SPIF_CTRL + DEFINE(SPIF_CTRL) +#else + MISSING(SPIF_CTRL) +#endif + +#ifdef SPIF_DATA + DEFINE(SPIF_DATA) +#else + MISSING(SPIF_DATA) +#endif + +#ifdef SPIF_INTCTRL + DEFINE(SPIF_INTCTRL) +#else + MISSING(SPIF_INTCTRL) +#endif + +#ifdef SPIF_STATUS + DEFINE(SPIF_STATUS) +#else + MISSING(SPIF_STATUS) +#endif + +#ifdef SPL + DEFINE(SPL) +#else + MISSING(SPL) +#endif + +#ifdef SPMCR + DEFINE(SPMCR) +#else + MISSING(SPMCR) +#endif + +#ifdef SPMCSR + DEFINE(SPMCSR) +#else + MISSING(SPMCSR) +#endif + +#ifdef SPSR + DEFINE(SPSR) +#else + MISSING(SPSR) +#endif + +#ifdef SPSR0 + DEFINE(SPSR0) +#else + MISSING(SPSR0) +#endif + +#ifdef SPWMCTL + DEFINE(SPWMCTL) +#else + MISSING(SPWMCTL) +#endif + +#ifdef SRCCAL + DEFINE(SRCCAL) +#else + MISSING(SRCCAL) +#endif + +#ifdef SREG + DEFINE(SREG) +#else + MISSING(SREG) +#endif + +#ifdef SSFR + DEFINE(SSFR) +#else + MISSING(SSFR) +#endif + +#ifdef STAT + DEFINE(STAT) +#else + MISSING(STAT) +#endif + +#ifdef SVCR + DEFINE(SVCR) +#else + MISSING(SVCR) +#endif + +#ifdef T0CR + DEFINE(T0CR) +#else + MISSING(T0CR) +#endif + +#ifdef T10IFR + DEFINE(T10IFR) +#else + MISSING(T10IFR) +#endif + +#ifdef T1CR + DEFINE(T1CR) +#else + MISSING(T1CR) +#endif + +#ifdef T2COR + DEFINE(T2COR) +#else + MISSING(T2COR) +#endif + +#ifdef T2CORH + DEFINE(T2CORH) +#else + MISSING(T2CORH) +#endif + +#ifdef T2CORL + DEFINE(T2CORL) +#else + MISSING(T2CORL) +#endif + +#ifdef T2CRA + DEFINE(T2CRA) +#else + MISSING(T2CRA) +#endif + +#ifdef T2CRB + DEFINE(T2CRB) +#else + MISSING(T2CRB) +#endif + +#ifdef T2ICR + DEFINE(T2ICR) +#else + MISSING(T2ICR) +#endif + +#ifdef T2ICRH + DEFINE(T2ICRH) +#else + MISSING(T2ICRH) +#endif + +#ifdef T2ICRL + DEFINE(T2ICRL) +#else + MISSING(T2ICRL) +#endif + +#ifdef T2IFR + DEFINE(T2IFR) +#else + MISSING(T2IFR) +#endif + +#ifdef T2IMR + DEFINE(T2IMR) +#else + MISSING(T2IMR) +#endif + +#ifdef T2MDR + DEFINE(T2MDR) +#else + MISSING(T2MDR) +#endif + +#ifdef T2MRA + DEFINE(T2MRA) +#else + MISSING(T2MRA) +#endif + +#ifdef T2MRB + DEFINE(T2MRB) +#else + MISSING(T2MRB) +#endif + +#ifdef T3CORA + DEFINE(T3CORA) +#else + MISSING(T3CORA) +#endif + +#ifdef T3CORAH + DEFINE(T3CORAH) +#else + MISSING(T3CORAH) +#endif + +#ifdef T3CORAL + DEFINE(T3CORAL) +#else + MISSING(T3CORAL) +#endif + +#ifdef T3CORB + DEFINE(T3CORB) +#else + MISSING(T3CORB) +#endif + +#ifdef T3CORBH + DEFINE(T3CORBH) +#else + MISSING(T3CORBH) +#endif + +#ifdef T3CORBL + DEFINE(T3CORBL) +#else + MISSING(T3CORBL) +#endif + +#ifdef T3CRA + DEFINE(T3CRA) +#else + MISSING(T3CRA) +#endif + +#ifdef T3CRB + DEFINE(T3CRB) +#else + MISSING(T3CRB) +#endif + +#ifdef T3ICR + DEFINE(T3ICR) +#else + MISSING(T3ICR) +#endif + +#ifdef T3ICRH + DEFINE(T3ICRH) +#else + MISSING(T3ICRH) +#endif + +#ifdef T3ICRL + DEFINE(T3ICRL) +#else + MISSING(T3ICRL) +#endif + +#ifdef T3IFR + DEFINE(T3IFR) +#else + MISSING(T3IFR) +#endif + +#ifdef T3IMR + DEFINE(T3IMR) +#else + MISSING(T3IMR) +#endif + +#ifdef T3MRA + DEFINE(T3MRA) +#else + MISSING(T3MRA) +#endif + +#ifdef T3MRB + DEFINE(T3MRB) +#else + MISSING(T3MRB) +#endif + +#ifdef TC1H + DEFINE(TC1H) +#else + MISSING(TC1H) +#endif + +#ifdef TC4H + DEFINE(TC4H) +#else + MISSING(TC4H) +#endif + +#ifdef TCC0_CCA + DEFINE(TCC0_CCA) +#else + MISSING(TCC0_CCA) +#endif + +#ifdef TCC0_CCABUF + DEFINE(TCC0_CCABUF) +#else + MISSING(TCC0_CCABUF) +#endif + +#ifdef TCC0_CCB + DEFINE(TCC0_CCB) +#else + MISSING(TCC0_CCB) +#endif + +#ifdef TCC0_CCBBUF + DEFINE(TCC0_CCBBUF) +#else + MISSING(TCC0_CCBBUF) +#endif + +#ifdef TCC0_CCC + DEFINE(TCC0_CCC) +#else + MISSING(TCC0_CCC) +#endif + +#ifdef TCC0_CCCBUF + DEFINE(TCC0_CCCBUF) +#else + MISSING(TCC0_CCCBUF) +#endif + +#ifdef TCC0_CCD + DEFINE(TCC0_CCD) +#else + MISSING(TCC0_CCD) +#endif + +#ifdef TCC0_CCDBUF + DEFINE(TCC0_CCDBUF) +#else + MISSING(TCC0_CCDBUF) +#endif + +#ifdef TCC0_CNT + DEFINE(TCC0_CNT) +#else + MISSING(TCC0_CNT) +#endif + +#ifdef TCC0_CTRLA + DEFINE(TCC0_CTRLA) +#else + MISSING(TCC0_CTRLA) +#endif + +#ifdef TCC0_CTRLB + DEFINE(TCC0_CTRLB) +#else + MISSING(TCC0_CTRLB) +#endif + +#ifdef TCC0_CTRLC + DEFINE(TCC0_CTRLC) +#else + MISSING(TCC0_CTRLC) +#endif + +#ifdef TCC0_CTRLD + DEFINE(TCC0_CTRLD) +#else + MISSING(TCC0_CTRLD) +#endif + +#ifdef TCC0_CTRLE + DEFINE(TCC0_CTRLE) +#else + MISSING(TCC0_CTRLE) +#endif + +#ifdef TCC0_CTRLFCLR + DEFINE(TCC0_CTRLFCLR) +#else + MISSING(TCC0_CTRLFCLR) +#endif + +#ifdef TCC0_CTRLFSET + DEFINE(TCC0_CTRLFSET) +#else + MISSING(TCC0_CTRLFSET) +#endif + +#ifdef TCC0_CTRLGCLR + DEFINE(TCC0_CTRLGCLR) +#else + MISSING(TCC0_CTRLGCLR) +#endif + +#ifdef TCC0_CTRLGSET + DEFINE(TCC0_CTRLGSET) +#else + MISSING(TCC0_CTRLGSET) +#endif + +#ifdef TCC0_INTCTRLA + DEFINE(TCC0_INTCTRLA) +#else + MISSING(TCC0_INTCTRLA) +#endif + +#ifdef TCC0_INTCTRLB + DEFINE(TCC0_INTCTRLB) +#else + MISSING(TCC0_INTCTRLB) +#endif + +#ifdef TCC0_INTFLAGS + DEFINE(TCC0_INTFLAGS) +#else + MISSING(TCC0_INTFLAGS) +#endif + +#ifdef TCC0_PER + DEFINE(TCC0_PER) +#else + MISSING(TCC0_PER) +#endif + +#ifdef TCC0_PERBUF + DEFINE(TCC0_PERBUF) +#else + MISSING(TCC0_PERBUF) +#endif + +#ifdef TCC0_TEMP + DEFINE(TCC0_TEMP) +#else + MISSING(TCC0_TEMP) +#endif + +#ifdef TCC1_CCA + DEFINE(TCC1_CCA) +#else + MISSING(TCC1_CCA) +#endif + +#ifdef TCC1_CCABUF + DEFINE(TCC1_CCABUF) +#else + MISSING(TCC1_CCABUF) +#endif + +#ifdef TCC1_CCB + DEFINE(TCC1_CCB) +#else + MISSING(TCC1_CCB) +#endif + +#ifdef TCC1_CCBBUF + DEFINE(TCC1_CCBBUF) +#else + MISSING(TCC1_CCBBUF) +#endif + +#ifdef TCC1_CNT + DEFINE(TCC1_CNT) +#else + MISSING(TCC1_CNT) +#endif + +#ifdef TCC1_CTRLA + DEFINE(TCC1_CTRLA) +#else + MISSING(TCC1_CTRLA) +#endif + +#ifdef TCC1_CTRLB + DEFINE(TCC1_CTRLB) +#else + MISSING(TCC1_CTRLB) +#endif + +#ifdef TCC1_CTRLC + DEFINE(TCC1_CTRLC) +#else + MISSING(TCC1_CTRLC) +#endif + +#ifdef TCC1_CTRLD + DEFINE(TCC1_CTRLD) +#else + MISSING(TCC1_CTRLD) +#endif + +#ifdef TCC1_CTRLE + DEFINE(TCC1_CTRLE) +#else + MISSING(TCC1_CTRLE) +#endif + +#ifdef TCC1_CTRLFCLR + DEFINE(TCC1_CTRLFCLR) +#else + MISSING(TCC1_CTRLFCLR) +#endif + +#ifdef TCC1_CTRLFSET + DEFINE(TCC1_CTRLFSET) +#else + MISSING(TCC1_CTRLFSET) +#endif + +#ifdef TCC1_CTRLGCLR + DEFINE(TCC1_CTRLGCLR) +#else + MISSING(TCC1_CTRLGCLR) +#endif + +#ifdef TCC1_CTRLGSET + DEFINE(TCC1_CTRLGSET) +#else + MISSING(TCC1_CTRLGSET) +#endif + +#ifdef TCC1_INTCTRLA + DEFINE(TCC1_INTCTRLA) +#else + MISSING(TCC1_INTCTRLA) +#endif + +#ifdef TCC1_INTCTRLB + DEFINE(TCC1_INTCTRLB) +#else + MISSING(TCC1_INTCTRLB) +#endif + +#ifdef TCC1_INTFLAGS + DEFINE(TCC1_INTFLAGS) +#else + MISSING(TCC1_INTFLAGS) +#endif + +#ifdef TCC1_PER + DEFINE(TCC1_PER) +#else + MISSING(TCC1_PER) +#endif + +#ifdef TCC1_PERBUF + DEFINE(TCC1_PERBUF) +#else + MISSING(TCC1_PERBUF) +#endif + +#ifdef TCC1_TEMP + DEFINE(TCC1_TEMP) +#else + MISSING(TCC1_TEMP) +#endif + +#ifdef TCCR0 + DEFINE(TCCR0) +#else + MISSING(TCCR0) +#endif + +#ifdef TCCR0A + DEFINE(TCCR0A) +#else + MISSING(TCCR0A) +#endif + +#ifdef TCCR0B + DEFINE(TCCR0B) +#else + MISSING(TCCR0B) +#endif + +#ifdef TCCR0C + DEFINE(TCCR0C) +#else + MISSING(TCCR0C) +#endif + +#ifdef TCCR1 + DEFINE(TCCR1) +#else + MISSING(TCCR1) +#endif + +#ifdef TCCR1A + DEFINE(TCCR1A) +#else + MISSING(TCCR1A) +#endif + +#ifdef TCCR1B + DEFINE(TCCR1B) +#else + MISSING(TCCR1B) +#endif + +#ifdef TCCR1C + DEFINE(TCCR1C) +#else + MISSING(TCCR1C) +#endif + +#ifdef TCCR1D + DEFINE(TCCR1D) +#else + MISSING(TCCR1D) +#endif + +#ifdef TCCR1E + DEFINE(TCCR1E) +#else + MISSING(TCCR1E) +#endif + +#ifdef TCCR2 + DEFINE(TCCR2) +#else + MISSING(TCCR2) +#endif + +#ifdef TCCR2A + DEFINE(TCCR2A) +#else + MISSING(TCCR2A) +#endif + +#ifdef TCCR2B + DEFINE(TCCR2B) +#else + MISSING(TCCR2B) +#endif + +#ifdef TCCR3A + DEFINE(TCCR3A) +#else + MISSING(TCCR3A) +#endif + +#ifdef TCCR3B + DEFINE(TCCR3B) +#else + MISSING(TCCR3B) +#endif + +#ifdef TCCR3C + DEFINE(TCCR3C) +#else + MISSING(TCCR3C) +#endif + +#ifdef TCCR4A + DEFINE(TCCR4A) +#else + MISSING(TCCR4A) +#endif + +#ifdef TCCR4B + DEFINE(TCCR4B) +#else + MISSING(TCCR4B) +#endif + +#ifdef TCCR4C + DEFINE(TCCR4C) +#else + MISSING(TCCR4C) +#endif + +#ifdef TCCR4D + DEFINE(TCCR4D) +#else + MISSING(TCCR4D) +#endif + +#ifdef TCCR4E + DEFINE(TCCR4E) +#else + MISSING(TCCR4E) +#endif + +#ifdef TCCR5A + DEFINE(TCCR5A) +#else + MISSING(TCCR5A) +#endif + +#ifdef TCCR5B + DEFINE(TCCR5B) +#else + MISSING(TCCR5B) +#endif + +#ifdef TCCR5C + DEFINE(TCCR5C) +#else + MISSING(TCCR5C) +#endif + +#ifdef TCD0_CCA + DEFINE(TCD0_CCA) +#else + MISSING(TCD0_CCA) +#endif + +#ifdef TCD0_CCABUF + DEFINE(TCD0_CCABUF) +#else + MISSING(TCD0_CCABUF) +#endif + +#ifdef TCD0_CCB + DEFINE(TCD0_CCB) +#else + MISSING(TCD0_CCB) +#endif + +#ifdef TCD0_CCBBUF + DEFINE(TCD0_CCBBUF) +#else + MISSING(TCD0_CCBBUF) +#endif + +#ifdef TCD0_CCC + DEFINE(TCD0_CCC) +#else + MISSING(TCD0_CCC) +#endif + +#ifdef TCD0_CCCBUF + DEFINE(TCD0_CCCBUF) +#else + MISSING(TCD0_CCCBUF) +#endif + +#ifdef TCD0_CCD + DEFINE(TCD0_CCD) +#else + MISSING(TCD0_CCD) +#endif + +#ifdef TCD0_CCDBUF + DEFINE(TCD0_CCDBUF) +#else + MISSING(TCD0_CCDBUF) +#endif + +#ifdef TCD0_CNT + DEFINE(TCD0_CNT) +#else + MISSING(TCD0_CNT) +#endif + +#ifdef TCD0_CTRLA + DEFINE(TCD0_CTRLA) +#else + MISSING(TCD0_CTRLA) +#endif + +#ifdef TCD0_CTRLB + DEFINE(TCD0_CTRLB) +#else + MISSING(TCD0_CTRLB) +#endif + +#ifdef TCD0_CTRLC + DEFINE(TCD0_CTRLC) +#else + MISSING(TCD0_CTRLC) +#endif + +#ifdef TCD0_CTRLD + DEFINE(TCD0_CTRLD) +#else + MISSING(TCD0_CTRLD) +#endif + +#ifdef TCD0_CTRLE + DEFINE(TCD0_CTRLE) +#else + MISSING(TCD0_CTRLE) +#endif + +#ifdef TCD0_CTRLFCLR + DEFINE(TCD0_CTRLFCLR) +#else + MISSING(TCD0_CTRLFCLR) +#endif + +#ifdef TCD0_CTRLFSET + DEFINE(TCD0_CTRLFSET) +#else + MISSING(TCD0_CTRLFSET) +#endif + +#ifdef TCD0_CTRLGCLR + DEFINE(TCD0_CTRLGCLR) +#else + MISSING(TCD0_CTRLGCLR) +#endif + +#ifdef TCD0_CTRLGSET + DEFINE(TCD0_CTRLGSET) +#else + MISSING(TCD0_CTRLGSET) +#endif + +#ifdef TCD0_INTCTRLA + DEFINE(TCD0_INTCTRLA) +#else + MISSING(TCD0_INTCTRLA) +#endif + +#ifdef TCD0_INTCTRLB + DEFINE(TCD0_INTCTRLB) +#else + MISSING(TCD0_INTCTRLB) +#endif + +#ifdef TCD0_INTFLAGS + DEFINE(TCD0_INTFLAGS) +#else + MISSING(TCD0_INTFLAGS) +#endif + +#ifdef TCD0_PER + DEFINE(TCD0_PER) +#else + MISSING(TCD0_PER) +#endif + +#ifdef TCD0_PERBUF + DEFINE(TCD0_PERBUF) +#else + MISSING(TCD0_PERBUF) +#endif + +#ifdef TCD0_TEMP + DEFINE(TCD0_TEMP) +#else + MISSING(TCD0_TEMP) +#endif + +#ifdef TCD1_CCA + DEFINE(TCD1_CCA) +#else + MISSING(TCD1_CCA) +#endif + +#ifdef TCD1_CCABUF + DEFINE(TCD1_CCABUF) +#else + MISSING(TCD1_CCABUF) +#endif + +#ifdef TCD1_CCB + DEFINE(TCD1_CCB) +#else + MISSING(TCD1_CCB) +#endif + +#ifdef TCD1_CCBBUF + DEFINE(TCD1_CCBBUF) +#else + MISSING(TCD1_CCBBUF) +#endif + +#ifdef TCD1_CNT + DEFINE(TCD1_CNT) +#else + MISSING(TCD1_CNT) +#endif + +#ifdef TCD1_CTRLA + DEFINE(TCD1_CTRLA) +#else + MISSING(TCD1_CTRLA) +#endif + +#ifdef TCD1_CTRLB + DEFINE(TCD1_CTRLB) +#else + MISSING(TCD1_CTRLB) +#endif + +#ifdef TCD1_CTRLC + DEFINE(TCD1_CTRLC) +#else + MISSING(TCD1_CTRLC) +#endif + +#ifdef TCD1_CTRLD + DEFINE(TCD1_CTRLD) +#else + MISSING(TCD1_CTRLD) +#endif + +#ifdef TCD1_CTRLE + DEFINE(TCD1_CTRLE) +#else + MISSING(TCD1_CTRLE) +#endif + +#ifdef TCD1_CTRLFCLR + DEFINE(TCD1_CTRLFCLR) +#else + MISSING(TCD1_CTRLFCLR) +#endif + +#ifdef TCD1_CTRLFSET + DEFINE(TCD1_CTRLFSET) +#else + MISSING(TCD1_CTRLFSET) +#endif + +#ifdef TCD1_CTRLGCLR + DEFINE(TCD1_CTRLGCLR) +#else + MISSING(TCD1_CTRLGCLR) +#endif + +#ifdef TCD1_CTRLGSET + DEFINE(TCD1_CTRLGSET) +#else + MISSING(TCD1_CTRLGSET) +#endif + +#ifdef TCD1_INTCTRLA + DEFINE(TCD1_INTCTRLA) +#else + MISSING(TCD1_INTCTRLA) +#endif + +#ifdef TCD1_INTCTRLB + DEFINE(TCD1_INTCTRLB) +#else + MISSING(TCD1_INTCTRLB) +#endif + +#ifdef TCD1_INTFLAGS + DEFINE(TCD1_INTFLAGS) +#else + MISSING(TCD1_INTFLAGS) +#endif + +#ifdef TCD1_PER + DEFINE(TCD1_PER) +#else + MISSING(TCD1_PER) +#endif + +#ifdef TCD1_PERBUF + DEFINE(TCD1_PERBUF) +#else + MISSING(TCD1_PERBUF) +#endif + +#ifdef TCD1_TEMP + DEFINE(TCD1_TEMP) +#else + MISSING(TCD1_TEMP) +#endif + +#ifdef TCE0_CCA + DEFINE(TCE0_CCA) +#else + MISSING(TCE0_CCA) +#endif + +#ifdef TCE0_CCABUF + DEFINE(TCE0_CCABUF) +#else + MISSING(TCE0_CCABUF) +#endif + +#ifdef TCE0_CCB + DEFINE(TCE0_CCB) +#else + MISSING(TCE0_CCB) +#endif + +#ifdef TCE0_CCBBUF + DEFINE(TCE0_CCBBUF) +#else + MISSING(TCE0_CCBBUF) +#endif + +#ifdef TCE0_CCC + DEFINE(TCE0_CCC) +#else + MISSING(TCE0_CCC) +#endif + +#ifdef TCE0_CCCBUF + DEFINE(TCE0_CCCBUF) +#else + MISSING(TCE0_CCCBUF) +#endif + +#ifdef TCE0_CCD + DEFINE(TCE0_CCD) +#else + MISSING(TCE0_CCD) +#endif + +#ifdef TCE0_CCDBUF + DEFINE(TCE0_CCDBUF) +#else + MISSING(TCE0_CCDBUF) +#endif + +#ifdef TCE0_CNT + DEFINE(TCE0_CNT) +#else + MISSING(TCE0_CNT) +#endif + +#ifdef TCE0_CTRLA + DEFINE(TCE0_CTRLA) +#else + MISSING(TCE0_CTRLA) +#endif + +#ifdef TCE0_CTRLB + DEFINE(TCE0_CTRLB) +#else + MISSING(TCE0_CTRLB) +#endif + +#ifdef TCE0_CTRLC + DEFINE(TCE0_CTRLC) +#else + MISSING(TCE0_CTRLC) +#endif + +#ifdef TCE0_CTRLD + DEFINE(TCE0_CTRLD) +#else + MISSING(TCE0_CTRLD) +#endif + +#ifdef TCE0_CTRLE + DEFINE(TCE0_CTRLE) +#else + MISSING(TCE0_CTRLE) +#endif + +#ifdef TCE0_CTRLFCLR + DEFINE(TCE0_CTRLFCLR) +#else + MISSING(TCE0_CTRLFCLR) +#endif + +#ifdef TCE0_CTRLFSET + DEFINE(TCE0_CTRLFSET) +#else + MISSING(TCE0_CTRLFSET) +#endif + +#ifdef TCE0_CTRLGCLR + DEFINE(TCE0_CTRLGCLR) +#else + MISSING(TCE0_CTRLGCLR) +#endif + +#ifdef TCE0_CTRLGSET + DEFINE(TCE0_CTRLGSET) +#else + MISSING(TCE0_CTRLGSET) +#endif + +#ifdef TCE0_INTCTRLA + DEFINE(TCE0_INTCTRLA) +#else + MISSING(TCE0_INTCTRLA) +#endif + +#ifdef TCE0_INTCTRLB + DEFINE(TCE0_INTCTRLB) +#else + MISSING(TCE0_INTCTRLB) +#endif + +#ifdef TCE0_INTFLAGS + DEFINE(TCE0_INTFLAGS) +#else + MISSING(TCE0_INTFLAGS) +#endif + +#ifdef TCE0_PER + DEFINE(TCE0_PER) +#else + MISSING(TCE0_PER) +#endif + +#ifdef TCE0_PERBUF + DEFINE(TCE0_PERBUF) +#else + MISSING(TCE0_PERBUF) +#endif + +#ifdef TCE0_TEMP + DEFINE(TCE0_TEMP) +#else + MISSING(TCE0_TEMP) +#endif + +#ifdef TCE1_CCA + DEFINE(TCE1_CCA) +#else + MISSING(TCE1_CCA) +#endif + +#ifdef TCE1_CCABUF + DEFINE(TCE1_CCABUF) +#else + MISSING(TCE1_CCABUF) +#endif + +#ifdef TCE1_CCB + DEFINE(TCE1_CCB) +#else + MISSING(TCE1_CCB) +#endif + +#ifdef TCE1_CCBBUF + DEFINE(TCE1_CCBBUF) +#else + MISSING(TCE1_CCBBUF) +#endif + +#ifdef TCE1_CNT + DEFINE(TCE1_CNT) +#else + MISSING(TCE1_CNT) +#endif + +#ifdef TCE1_CTRLA + DEFINE(TCE1_CTRLA) +#else + MISSING(TCE1_CTRLA) +#endif + +#ifdef TCE1_CTRLB + DEFINE(TCE1_CTRLB) +#else + MISSING(TCE1_CTRLB) +#endif + +#ifdef TCE1_CTRLC + DEFINE(TCE1_CTRLC) +#else + MISSING(TCE1_CTRLC) +#endif + +#ifdef TCE1_CTRLD + DEFINE(TCE1_CTRLD) +#else + MISSING(TCE1_CTRLD) +#endif + +#ifdef TCE1_CTRLE + DEFINE(TCE1_CTRLE) +#else + MISSING(TCE1_CTRLE) +#endif + +#ifdef TCE1_CTRLFCLR + DEFINE(TCE1_CTRLFCLR) +#else + MISSING(TCE1_CTRLFCLR) +#endif + +#ifdef TCE1_CTRLFSET + DEFINE(TCE1_CTRLFSET) +#else + MISSING(TCE1_CTRLFSET) +#endif + +#ifdef TCE1_CTRLGCLR + DEFINE(TCE1_CTRLGCLR) +#else + MISSING(TCE1_CTRLGCLR) +#endif + +#ifdef TCE1_CTRLGSET + DEFINE(TCE1_CTRLGSET) +#else + MISSING(TCE1_CTRLGSET) +#endif + +#ifdef TCE1_INTCTRLA + DEFINE(TCE1_INTCTRLA) +#else + MISSING(TCE1_INTCTRLA) +#endif + +#ifdef TCE1_INTCTRLB + DEFINE(TCE1_INTCTRLB) +#else + MISSING(TCE1_INTCTRLB) +#endif + +#ifdef TCE1_INTFLAGS + DEFINE(TCE1_INTFLAGS) +#else + MISSING(TCE1_INTFLAGS) +#endif + +#ifdef TCE1_PER + DEFINE(TCE1_PER) +#else + MISSING(TCE1_PER) +#endif + +#ifdef TCE1_PERBUF + DEFINE(TCE1_PERBUF) +#else + MISSING(TCE1_PERBUF) +#endif + +#ifdef TCE1_TEMP + DEFINE(TCE1_TEMP) +#else + MISSING(TCE1_TEMP) +#endif + +#ifdef TCF0_CCA + DEFINE(TCF0_CCA) +#else + MISSING(TCF0_CCA) +#endif + +#ifdef TCF0_CCABUF + DEFINE(TCF0_CCABUF) +#else + MISSING(TCF0_CCABUF) +#endif + +#ifdef TCF0_CCB + DEFINE(TCF0_CCB) +#else + MISSING(TCF0_CCB) +#endif + +#ifdef TCF0_CCBBUF + DEFINE(TCF0_CCBBUF) +#else + MISSING(TCF0_CCBBUF) +#endif + +#ifdef TCF0_CCC + DEFINE(TCF0_CCC) +#else + MISSING(TCF0_CCC) +#endif + +#ifdef TCF0_CCCBUF + DEFINE(TCF0_CCCBUF) +#else + MISSING(TCF0_CCCBUF) +#endif + +#ifdef TCF0_CCD + DEFINE(TCF0_CCD) +#else + MISSING(TCF0_CCD) +#endif + +#ifdef TCF0_CCDBUF + DEFINE(TCF0_CCDBUF) +#else + MISSING(TCF0_CCDBUF) +#endif + +#ifdef TCF0_CNT + DEFINE(TCF0_CNT) +#else + MISSING(TCF0_CNT) +#endif + +#ifdef TCF0_CTRLA + DEFINE(TCF0_CTRLA) +#else + MISSING(TCF0_CTRLA) +#endif + +#ifdef TCF0_CTRLB + DEFINE(TCF0_CTRLB) +#else + MISSING(TCF0_CTRLB) +#endif + +#ifdef TCF0_CTRLC + DEFINE(TCF0_CTRLC) +#else + MISSING(TCF0_CTRLC) +#endif + +#ifdef TCF0_CTRLD + DEFINE(TCF0_CTRLD) +#else + MISSING(TCF0_CTRLD) +#endif + +#ifdef TCF0_CTRLE + DEFINE(TCF0_CTRLE) +#else + MISSING(TCF0_CTRLE) +#endif + +#ifdef TCF0_CTRLFCLR + DEFINE(TCF0_CTRLFCLR) +#else + MISSING(TCF0_CTRLFCLR) +#endif + +#ifdef TCF0_CTRLFSET + DEFINE(TCF0_CTRLFSET) +#else + MISSING(TCF0_CTRLFSET) +#endif + +#ifdef TCF0_CTRLGCLR + DEFINE(TCF0_CTRLGCLR) +#else + MISSING(TCF0_CTRLGCLR) +#endif + +#ifdef TCF0_CTRLGSET + DEFINE(TCF0_CTRLGSET) +#else + MISSING(TCF0_CTRLGSET) +#endif + +#ifdef TCF0_INTCTRLA + DEFINE(TCF0_INTCTRLA) +#else + MISSING(TCF0_INTCTRLA) +#endif + +#ifdef TCF0_INTCTRLB + DEFINE(TCF0_INTCTRLB) +#else + MISSING(TCF0_INTCTRLB) +#endif + +#ifdef TCF0_INTFLAGS + DEFINE(TCF0_INTFLAGS) +#else + MISSING(TCF0_INTFLAGS) +#endif + +#ifdef TCF0_PER + DEFINE(TCF0_PER) +#else + MISSING(TCF0_PER) +#endif + +#ifdef TCF0_PERBUF + DEFINE(TCF0_PERBUF) +#else + MISSING(TCF0_PERBUF) +#endif + +#ifdef TCF0_TEMP + DEFINE(TCF0_TEMP) +#else + MISSING(TCF0_TEMP) +#endif + +#ifdef TCF1_CCA + DEFINE(TCF1_CCA) +#else + MISSING(TCF1_CCA) +#endif + +#ifdef TCF1_CCABUF + DEFINE(TCF1_CCABUF) +#else + MISSING(TCF1_CCABUF) +#endif + +#ifdef TCF1_CCB + DEFINE(TCF1_CCB) +#else + MISSING(TCF1_CCB) +#endif + +#ifdef TCF1_CCBBUF + DEFINE(TCF1_CCBBUF) +#else + MISSING(TCF1_CCBBUF) +#endif + +#ifdef TCF1_CNT + DEFINE(TCF1_CNT) +#else + MISSING(TCF1_CNT) +#endif + +#ifdef TCF1_CTRLA + DEFINE(TCF1_CTRLA) +#else + MISSING(TCF1_CTRLA) +#endif + +#ifdef TCF1_CTRLB + DEFINE(TCF1_CTRLB) +#else + MISSING(TCF1_CTRLB) +#endif + +#ifdef TCF1_CTRLC + DEFINE(TCF1_CTRLC) +#else + MISSING(TCF1_CTRLC) +#endif + +#ifdef TCF1_CTRLD + DEFINE(TCF1_CTRLD) +#else + MISSING(TCF1_CTRLD) +#endif + +#ifdef TCF1_CTRLE + DEFINE(TCF1_CTRLE) +#else + MISSING(TCF1_CTRLE) +#endif + +#ifdef TCF1_CTRLFCLR + DEFINE(TCF1_CTRLFCLR) +#else + MISSING(TCF1_CTRLFCLR) +#endif + +#ifdef TCF1_CTRLFSET + DEFINE(TCF1_CTRLFSET) +#else + MISSING(TCF1_CTRLFSET) +#endif + +#ifdef TCF1_CTRLGCLR + DEFINE(TCF1_CTRLGCLR) +#else + MISSING(TCF1_CTRLGCLR) +#endif + +#ifdef TCF1_CTRLGSET + DEFINE(TCF1_CTRLGSET) +#else + MISSING(TCF1_CTRLGSET) +#endif + +#ifdef TCF1_INTCTRLA + DEFINE(TCF1_INTCTRLA) +#else + MISSING(TCF1_INTCTRLA) +#endif + +#ifdef TCF1_INTCTRLB + DEFINE(TCF1_INTCTRLB) +#else + MISSING(TCF1_INTCTRLB) +#endif + +#ifdef TCF1_INTFLAGS + DEFINE(TCF1_INTFLAGS) +#else + MISSING(TCF1_INTFLAGS) +#endif + +#ifdef TCF1_PER + DEFINE(TCF1_PER) +#else + MISSING(TCF1_PER) +#endif + +#ifdef TCF1_PERBUF + DEFINE(TCF1_PERBUF) +#else + MISSING(TCF1_PERBUF) +#endif + +#ifdef TCF1_TEMP + DEFINE(TCF1_TEMP) +#else + MISSING(TCF1_TEMP) +#endif + +#ifdef TCNT0 + DEFINE(TCNT0) +#else + MISSING(TCNT0) +#endif + +#ifdef TCNT0H + DEFINE(TCNT0H) +#else + MISSING(TCNT0H) +#endif + +#ifdef TCNT0L + DEFINE(TCNT0L) +#else + MISSING(TCNT0L) +#endif + +#ifdef TCNT1 + DEFINE(TCNT1) +#else + MISSING(TCNT1) +#endif + +#ifdef TCNT1H + DEFINE(TCNT1H) +#else + MISSING(TCNT1H) +#endif + +#ifdef TCNT1L + DEFINE(TCNT1L) +#else + MISSING(TCNT1L) +#endif + +#ifdef TCNT2 + DEFINE(TCNT2) +#else + MISSING(TCNT2) +#endif + +#ifdef TCNT3 + DEFINE(TCNT3) +#else + MISSING(TCNT3) +#endif + +#ifdef TCNT3H + DEFINE(TCNT3H) +#else + MISSING(TCNT3H) +#endif + +#ifdef TCNT3L + DEFINE(TCNT3L) +#else + MISSING(TCNT3L) +#endif + +#ifdef TCNT4 + DEFINE(TCNT4) +#else + MISSING(TCNT4) +#endif + +#ifdef TCNT4H + DEFINE(TCNT4H) +#else + MISSING(TCNT4H) +#endif + +#ifdef TCNT4L + DEFINE(TCNT4L) +#else + MISSING(TCNT4L) +#endif + +#ifdef TCNT5 + DEFINE(TCNT5) +#else + MISSING(TCNT5) +#endif + +#ifdef TCNT5H + DEFINE(TCNT5H) +#else + MISSING(TCNT5H) +#endif + +#ifdef TCNT5L + DEFINE(TCNT5L) +#else + MISSING(TCNT5L) +#endif + +#ifdef TIFR + DEFINE(TIFR) +#else + MISSING(TIFR) +#endif + +#ifdef TIFR0 + DEFINE(TIFR0) +#else + MISSING(TIFR0) +#endif + +#ifdef TIFR1 + DEFINE(TIFR1) +#else + MISSING(TIFR1) +#endif + +#ifdef TIFR2 + DEFINE(TIFR2) +#else + MISSING(TIFR2) +#endif + +#ifdef TIFR3 + DEFINE(TIFR3) +#else + MISSING(TIFR3) +#endif + +#ifdef TIFR4 + DEFINE(TIFR4) +#else + MISSING(TIFR4) +#endif + +#ifdef TIFR5 + DEFINE(TIFR5) +#else + MISSING(TIFR5) +#endif + +#ifdef TIMSK + DEFINE(TIMSK) +#else + MISSING(TIMSK) +#endif + +#ifdef TIMSK0 + DEFINE(TIMSK0) +#else + MISSING(TIMSK0) +#endif + +#ifdef TIMSK1 + DEFINE(TIMSK1) +#else + MISSING(TIMSK1) +#endif + +#ifdef TIMSK2 + DEFINE(TIMSK2) +#else + MISSING(TIMSK2) +#endif + +#ifdef TIMSK3 + DEFINE(TIMSK3) +#else + MISSING(TIMSK3) +#endif + +#ifdef TIMSK4 + DEFINE(TIMSK4) +#else + MISSING(TIMSK4) +#endif + +#ifdef TIMSK5 + DEFINE(TIMSK5) +#else + MISSING(TIMSK5) +#endif + +#ifdef TRXFBEND + DEFINE(TRXFBEND) +#else + MISSING(TRXFBEND) +#endif + +#ifdef TRXFBST + DEFINE(TRXFBST) +#else + MISSING(TRXFBST) +#endif + +#ifdef TRXPR + DEFINE(TRXPR) +#else + MISSING(TRXPR) +#endif + +#ifdef TRX_CTRL_0 + DEFINE(TRX_CTRL_0) +#else + MISSING(TRX_CTRL_0) +#endif + +#ifdef TRX_CTRL_1 + DEFINE(TRX_CTRL_1) +#else + MISSING(TRX_CTRL_1) +#endif + +#ifdef TRX_CTRL_2 + DEFINE(TRX_CTRL_2) +#else + MISSING(TRX_CTRL_2) +#endif + +#ifdef TRX_STATE + DEFINE(TRX_STATE) +#else + MISSING(TRX_STATE) +#endif + +#ifdef TRX_STATUS + DEFINE(TRX_STATUS) +#else + MISSING(TRX_STATUS) +#endif + +#ifdef TSCR + DEFINE(TSCR) +#else + MISSING(TSCR) +#endif + +#ifdef TST_CTRL_DIGI + DEFINE(TST_CTRL_DIGI) +#else + MISSING(TST_CTRL_DIGI) +#endif + +#ifdef TST_RX_LENGTH + DEFINE(TST_RX_LENGTH) +#else + MISSING(TST_RX_LENGTH) +#endif + +#ifdef TWAMR + DEFINE(TWAMR) +#else + MISSING(TWAMR) +#endif + +#ifdef TWAR + DEFINE(TWAR) +#else + MISSING(TWAR) +#endif + +#ifdef TWBCSR + DEFINE(TWBCSR) +#else + MISSING(TWBCSR) +#endif + +#ifdef TWBR + DEFINE(TWBR) +#else + MISSING(TWBR) +#endif + +#ifdef TWCR + DEFINE(TWCR) +#else + MISSING(TWCR) +#endif + +#ifdef TWDR + DEFINE(TWDR) +#else + MISSING(TWDR) +#endif + +#ifdef TWHSR + DEFINE(TWHSR) +#else + MISSING(TWHSR) +#endif + +#ifdef TWIC_CTRL + DEFINE(TWIC_CTRL) +#else + MISSING(TWIC_CTRL) +#endif + +#ifdef TWIC_MASTER_ADDR + DEFINE(TWIC_MASTER_ADDR) +#else + MISSING(TWIC_MASTER_ADDR) +#endif + +#ifdef TWIC_MASTER_BAUD + DEFINE(TWIC_MASTER_BAUD) +#else + MISSING(TWIC_MASTER_BAUD) +#endif + +#ifdef TWIC_MASTER_CTRLA + DEFINE(TWIC_MASTER_CTRLA) +#else + MISSING(TWIC_MASTER_CTRLA) +#endif + +#ifdef TWIC_MASTER_CTRLB + DEFINE(TWIC_MASTER_CTRLB) +#else + MISSING(TWIC_MASTER_CTRLB) +#endif + +#ifdef TWIC_MASTER_CTRLC + DEFINE(TWIC_MASTER_CTRLC) +#else + MISSING(TWIC_MASTER_CTRLC) +#endif + +#ifdef TWIC_MASTER_DATA + DEFINE(TWIC_MASTER_DATA) +#else + MISSING(TWIC_MASTER_DATA) +#endif + +#ifdef TWIC_MASTER_STATUS + DEFINE(TWIC_MASTER_STATUS) +#else + MISSING(TWIC_MASTER_STATUS) +#endif + +#ifdef TWIC_SLAVE_ADDR + DEFINE(TWIC_SLAVE_ADDR) +#else + MISSING(TWIC_SLAVE_ADDR) +#endif + +#ifdef TWIC_SLAVE_ADDRMASK + DEFINE(TWIC_SLAVE_ADDRMASK) +#else + MISSING(TWIC_SLAVE_ADDRMASK) +#endif + +#ifdef TWIC_SLAVE_CTRLA + DEFINE(TWIC_SLAVE_CTRLA) +#else + MISSING(TWIC_SLAVE_CTRLA) +#endif + +#ifdef TWIC_SLAVE_CTRLB + DEFINE(TWIC_SLAVE_CTRLB) +#else + MISSING(TWIC_SLAVE_CTRLB) +#endif + +#ifdef TWIC_SLAVE_DATA + DEFINE(TWIC_SLAVE_DATA) +#else + MISSING(TWIC_SLAVE_DATA) +#endif + +#ifdef TWIC_SLAVE_STATUS + DEFINE(TWIC_SLAVE_STATUS) +#else + MISSING(TWIC_SLAVE_STATUS) +#endif + +#ifdef TWID_CTRL + DEFINE(TWID_CTRL) +#else + MISSING(TWID_CTRL) +#endif + +#ifdef TWID_MASTER_ADDR + DEFINE(TWID_MASTER_ADDR) +#else + MISSING(TWID_MASTER_ADDR) +#endif + +#ifdef TWID_MASTER_BAUD + DEFINE(TWID_MASTER_BAUD) +#else + MISSING(TWID_MASTER_BAUD) +#endif + +#ifdef TWID_MASTER_CTRLA + DEFINE(TWID_MASTER_CTRLA) +#else + MISSING(TWID_MASTER_CTRLA) +#endif + +#ifdef TWID_MASTER_CTRLB + DEFINE(TWID_MASTER_CTRLB) +#else + MISSING(TWID_MASTER_CTRLB) +#endif + +#ifdef TWID_MASTER_CTRLC + DEFINE(TWID_MASTER_CTRLC) +#else + MISSING(TWID_MASTER_CTRLC) +#endif + +#ifdef TWID_MASTER_DATA + DEFINE(TWID_MASTER_DATA) +#else + MISSING(TWID_MASTER_DATA) +#endif + +#ifdef TWID_MASTER_STATUS + DEFINE(TWID_MASTER_STATUS) +#else + MISSING(TWID_MASTER_STATUS) +#endif + +#ifdef TWID_SLAVE_ADDR + DEFINE(TWID_SLAVE_ADDR) +#else + MISSING(TWID_SLAVE_ADDR) +#endif + +#ifdef TWID_SLAVE_ADDRMASK + DEFINE(TWID_SLAVE_ADDRMASK) +#else + MISSING(TWID_SLAVE_ADDRMASK) +#endif + +#ifdef TWID_SLAVE_CTRLA + DEFINE(TWID_SLAVE_CTRLA) +#else + MISSING(TWID_SLAVE_CTRLA) +#endif + +#ifdef TWID_SLAVE_CTRLB + DEFINE(TWID_SLAVE_CTRLB) +#else + MISSING(TWID_SLAVE_CTRLB) +#endif + +#ifdef TWID_SLAVE_DATA + DEFINE(TWID_SLAVE_DATA) +#else + MISSING(TWID_SLAVE_DATA) +#endif + +#ifdef TWID_SLAVE_STATUS + DEFINE(TWID_SLAVE_STATUS) +#else + MISSING(TWID_SLAVE_STATUS) +#endif + +#ifdef TWIE_CTRL + DEFINE(TWIE_CTRL) +#else + MISSING(TWIE_CTRL) +#endif + +#ifdef TWIE_MASTER_ADDR + DEFINE(TWIE_MASTER_ADDR) +#else + MISSING(TWIE_MASTER_ADDR) +#endif + +#ifdef TWIE_MASTER_BAUD + DEFINE(TWIE_MASTER_BAUD) +#else + MISSING(TWIE_MASTER_BAUD) +#endif + +#ifdef TWIE_MASTER_CTRLA + DEFINE(TWIE_MASTER_CTRLA) +#else + MISSING(TWIE_MASTER_CTRLA) +#endif + +#ifdef TWIE_MASTER_CTRLB + DEFINE(TWIE_MASTER_CTRLB) +#else + MISSING(TWIE_MASTER_CTRLB) +#endif + +#ifdef TWIE_MASTER_CTRLC + DEFINE(TWIE_MASTER_CTRLC) +#else + MISSING(TWIE_MASTER_CTRLC) +#endif + +#ifdef TWIE_MASTER_DATA + DEFINE(TWIE_MASTER_DATA) +#else + MISSING(TWIE_MASTER_DATA) +#endif + +#ifdef TWIE_MASTER_STATUS + DEFINE(TWIE_MASTER_STATUS) +#else + MISSING(TWIE_MASTER_STATUS) +#endif + +#ifdef TWIE_SLAVE_ADDR + DEFINE(TWIE_SLAVE_ADDR) +#else + MISSING(TWIE_SLAVE_ADDR) +#endif + +#ifdef TWIE_SLAVE_ADDRMASK + DEFINE(TWIE_SLAVE_ADDRMASK) +#else + MISSING(TWIE_SLAVE_ADDRMASK) +#endif + +#ifdef TWIE_SLAVE_CTRLA + DEFINE(TWIE_SLAVE_CTRLA) +#else + MISSING(TWIE_SLAVE_CTRLA) +#endif + +#ifdef TWIE_SLAVE_CTRLB + DEFINE(TWIE_SLAVE_CTRLB) +#else + MISSING(TWIE_SLAVE_CTRLB) +#endif + +#ifdef TWIE_SLAVE_DATA + DEFINE(TWIE_SLAVE_DATA) +#else + MISSING(TWIE_SLAVE_DATA) +#endif + +#ifdef TWIE_SLAVE_STATUS + DEFINE(TWIE_SLAVE_STATUS) +#else + MISSING(TWIE_SLAVE_STATUS) +#endif + +#ifdef TWIF_CTRL + DEFINE(TWIF_CTRL) +#else + MISSING(TWIF_CTRL) +#endif + +#ifdef TWIF_MASTER_ADDR + DEFINE(TWIF_MASTER_ADDR) +#else + MISSING(TWIF_MASTER_ADDR) +#endif + +#ifdef TWIF_MASTER_BAUD + DEFINE(TWIF_MASTER_BAUD) +#else + MISSING(TWIF_MASTER_BAUD) +#endif + +#ifdef TWIF_MASTER_CTRLA + DEFINE(TWIF_MASTER_CTRLA) +#else + MISSING(TWIF_MASTER_CTRLA) +#endif + +#ifdef TWIF_MASTER_CTRLB + DEFINE(TWIF_MASTER_CTRLB) +#else + MISSING(TWIF_MASTER_CTRLB) +#endif + +#ifdef TWIF_MASTER_CTRLC + DEFINE(TWIF_MASTER_CTRLC) +#else + MISSING(TWIF_MASTER_CTRLC) +#endif + +#ifdef TWIF_MASTER_DATA + DEFINE(TWIF_MASTER_DATA) +#else + MISSING(TWIF_MASTER_DATA) +#endif + +#ifdef TWIF_MASTER_STATUS + DEFINE(TWIF_MASTER_STATUS) +#else + MISSING(TWIF_MASTER_STATUS) +#endif + +#ifdef TWIF_SLAVE_ADDR + DEFINE(TWIF_SLAVE_ADDR) +#else + MISSING(TWIF_SLAVE_ADDR) +#endif + +#ifdef TWIF_SLAVE_ADDRMASK + DEFINE(TWIF_SLAVE_ADDRMASK) +#else + MISSING(TWIF_SLAVE_ADDRMASK) +#endif + +#ifdef TWIF_SLAVE_CTRLA + DEFINE(TWIF_SLAVE_CTRLA) +#else + MISSING(TWIF_SLAVE_CTRLA) +#endif + +#ifdef TWIF_SLAVE_CTRLB + DEFINE(TWIF_SLAVE_CTRLB) +#else + MISSING(TWIF_SLAVE_CTRLB) +#endif + +#ifdef TWIF_SLAVE_DATA + DEFINE(TWIF_SLAVE_DATA) +#else + MISSING(TWIF_SLAVE_DATA) +#endif + +#ifdef TWIF_SLAVE_STATUS + DEFINE(TWIF_SLAVE_STATUS) +#else + MISSING(TWIF_SLAVE_STATUS) +#endif + +#ifdef TWIHSR + DEFINE(TWIHSR) +#else + MISSING(TWIHSR) +#endif + +#ifdef TWSA + DEFINE(TWSA) +#else + MISSING(TWSA) +#endif + +#ifdef TWSAM + DEFINE(TWSAM) +#else + MISSING(TWSAM) +#endif + +#ifdef TWSCRA + DEFINE(TWSCRA) +#else + MISSING(TWSCRA) +#endif + +#ifdef TWSCRB + DEFINE(TWSCRB) +#else + MISSING(TWSCRB) +#endif + +#ifdef TWSD + DEFINE(TWSD) +#else + MISSING(TWSD) +#endif + +#ifdef TWSR + DEFINE(TWSR) +#else + MISSING(TWSR) +#endif + +#ifdef TWSSRA + DEFINE(TWSSRA) +#else + MISSING(TWSSRA) +#endif + +#ifdef TXB + DEFINE(TXB) +#else + MISSING(TXB) +#endif + +#ifdef TX_CNTL + DEFINE(TX_CNTL) +#else + MISSING(TX_CNTL) +#endif + +#ifdef UBRR + DEFINE(UBRR) +#else + MISSING(UBRR) +#endif + +#ifdef UBRR0 + DEFINE(UBRR0) +#else + MISSING(UBRR0) +#endif + +#ifdef UBRR0H + DEFINE(UBRR0H) +#else + MISSING(UBRR0H) +#endif + +#ifdef UBRR0L + DEFINE(UBRR0L) +#else + MISSING(UBRR0L) +#endif + +#ifdef UBRR1 + DEFINE(UBRR1) +#else + MISSING(UBRR1) +#endif + +#ifdef UBRR1H + DEFINE(UBRR1H) +#else + MISSING(UBRR1H) +#endif + +#ifdef UBRR1L + DEFINE(UBRR1L) +#else + MISSING(UBRR1L) +#endif + +#ifdef UBRR2 + DEFINE(UBRR2) +#else + MISSING(UBRR2) +#endif + +#ifdef UBRR2H + DEFINE(UBRR2H) +#else + MISSING(UBRR2H) +#endif + +#ifdef UBRR2L + DEFINE(UBRR2L) +#else + MISSING(UBRR2L) +#endif + +#ifdef UBRR3 + DEFINE(UBRR3) +#else + MISSING(UBRR3) +#endif + +#ifdef UBRR3H + DEFINE(UBRR3H) +#else + MISSING(UBRR3H) +#endif + +#ifdef UBRR3L + DEFINE(UBRR3L) +#else + MISSING(UBRR3L) +#endif + +#ifdef UBRRH + DEFINE(UBRRH) +#else + MISSING(UBRRH) +#endif + +#ifdef UBRRHI + DEFINE(UBRRHI) +#else + MISSING(UBRRHI) +#endif + +#ifdef UBRRL + DEFINE(UBRRL) +#else + MISSING(UBRRL) +#endif + +#ifdef UBRRLO + DEFINE(UBRRLO) +#else + MISSING(UBRRLO) +#endif + +#ifdef UCR + DEFINE(UCR) +#else + MISSING(UCR) +#endif + +#ifdef UCRA + DEFINE(UCRA) +#else + MISSING(UCRA) +#endif + +#ifdef UCRB + DEFINE(UCRB) +#else + MISSING(UCRB) +#endif + +#ifdef UCSR0A + DEFINE(UCSR0A) +#else + MISSING(UCSR0A) +#endif + +#ifdef UCSR0B + DEFINE(UCSR0B) +#else + MISSING(UCSR0B) +#endif + +#ifdef UCSR0C + DEFINE(UCSR0C) +#else + MISSING(UCSR0C) +#endif + +#ifdef UCSR1A + DEFINE(UCSR1A) +#else + MISSING(UCSR1A) +#endif + +#ifdef UCSR1B + DEFINE(UCSR1B) +#else + MISSING(UCSR1B) +#endif + +#ifdef UCSR1C + DEFINE(UCSR1C) +#else + MISSING(UCSR1C) +#endif + +#ifdef UCSR1D + DEFINE(UCSR1D) +#else + MISSING(UCSR1D) +#endif + +#ifdef UCSR2A + DEFINE(UCSR2A) +#else + MISSING(UCSR2A) +#endif + +#ifdef UCSR2B + DEFINE(UCSR2B) +#else + MISSING(UCSR2B) +#endif + +#ifdef UCSR2C + DEFINE(UCSR2C) +#else + MISSING(UCSR2C) +#endif + +#ifdef UCSR3A + DEFINE(UCSR3A) +#else + MISSING(UCSR3A) +#endif + +#ifdef UCSR3B + DEFINE(UCSR3B) +#else + MISSING(UCSR3B) +#endif + +#ifdef UCSR3C + DEFINE(UCSR3C) +#else + MISSING(UCSR3C) +#endif + +#ifdef UCSRA + DEFINE(UCSRA) +#else + MISSING(UCSRA) +#endif + +#ifdef UCSRB + DEFINE(UCSRB) +#else + MISSING(UCSRB) +#endif + +#ifdef UCSRC + DEFINE(UCSRC) +#else + MISSING(UCSRC) +#endif + +#ifdef UDADDR + DEFINE(UDADDR) +#else + MISSING(UDADDR) +#endif + +#ifdef UDCON + DEFINE(UDCON) +#else + MISSING(UDCON) +#endif + +#ifdef UDFNUM + DEFINE(UDFNUM) +#else + MISSING(UDFNUM) +#endif + +#ifdef UDFNUMH + DEFINE(UDFNUMH) +#else + MISSING(UDFNUMH) +#endif + +#ifdef UDFNUML + DEFINE(UDFNUML) +#else + MISSING(UDFNUML) +#endif + +#ifdef UDIEN + DEFINE(UDIEN) +#else + MISSING(UDIEN) +#endif + +#ifdef UDINT + DEFINE(UDINT) +#else + MISSING(UDINT) +#endif + +#ifdef UDMFN + DEFINE(UDMFN) +#else + MISSING(UDMFN) +#endif + +#ifdef UDPADD + DEFINE(UDPADD) +#else + MISSING(UDPADD) +#endif + +#ifdef UDPADDH + DEFINE(UDPADDH) +#else + MISSING(UDPADDH) +#endif + +#ifdef UDPADDL + DEFINE(UDPADDL) +#else + MISSING(UDPADDL) +#endif + +#ifdef UDR + DEFINE(UDR) +#else + MISSING(UDR) +#endif + +#ifdef UDR0 + DEFINE(UDR0) +#else + MISSING(UDR0) +#endif + +#ifdef UDR1 + DEFINE(UDR1) +#else + MISSING(UDR1) +#endif + +#ifdef UDR2 + DEFINE(UDR2) +#else + MISSING(UDR2) +#endif + +#ifdef UDR3 + DEFINE(UDR3) +#else + MISSING(UDR3) +#endif + +#ifdef UDTST + DEFINE(UDTST) +#else + MISSING(UDTST) +#endif + +#ifdef UEBCHX + DEFINE(UEBCHX) +#else + MISSING(UEBCHX) +#endif + +#ifdef UEBCLX + DEFINE(UEBCLX) +#else + MISSING(UEBCLX) +#endif + +#ifdef UEBCX + DEFINE(UEBCX) +#else + MISSING(UEBCX) +#endif + +#ifdef UECFG0X + DEFINE(UECFG0X) +#else + MISSING(UECFG0X) +#endif + +#ifdef UECFG1X + DEFINE(UECFG1X) +#else + MISSING(UECFG1X) +#endif + +#ifdef UECONX + DEFINE(UECONX) +#else + MISSING(UECONX) +#endif + +#ifdef UEDATX + DEFINE(UEDATX) +#else + MISSING(UEDATX) +#endif + +#ifdef UEIENX + DEFINE(UEIENX) +#else + MISSING(UEIENX) +#endif + +#ifdef UEINT + DEFINE(UEINT) +#else + MISSING(UEINT) +#endif + +#ifdef UEINTX + DEFINE(UEINTX) +#else + MISSING(UEINTX) +#endif + +#ifdef UENUM + DEFINE(UENUM) +#else + MISSING(UENUM) +#endif + +#ifdef UERST + DEFINE(UERST) +#else + MISSING(UERST) +#endif + +#ifdef UESTA0X + DEFINE(UESTA0X) +#else + MISSING(UESTA0X) +#endif + +#ifdef UESTA1X + DEFINE(UESTA1X) +#else + MISSING(UESTA1X) +#endif + +#ifdef UHADDR + DEFINE(UHADDR) +#else + MISSING(UHADDR) +#endif + +#ifdef UHCON + DEFINE(UHCON) +#else + MISSING(UHCON) +#endif + +#ifdef UHCR + DEFINE(UHCR) +#else + MISSING(UHCR) +#endif + +#ifdef UHFLEN + DEFINE(UHFLEN) +#else + MISSING(UHFLEN) +#endif + +#ifdef UHFNUM + DEFINE(UHFNUM) +#else + MISSING(UHFNUM) +#endif + +#ifdef UHFNUMH + DEFINE(UHFNUMH) +#else + MISSING(UHFNUMH) +#endif + +#ifdef UHFNUML + DEFINE(UHFNUML) +#else + MISSING(UHFNUML) +#endif + +#ifdef UHIEN + DEFINE(UHIEN) +#else + MISSING(UHIEN) +#endif + +#ifdef UHINT + DEFINE(UHINT) +#else + MISSING(UHINT) +#endif + +#ifdef UHSR + DEFINE(UHSR) +#else + MISSING(UHSR) +#endif + +#ifdef UHWCON + DEFINE(UHWCON) +#else + MISSING(UHWCON) +#endif + +#ifdef UPBCHX + DEFINE(UPBCHX) +#else + MISSING(UPBCHX) +#endif + +#ifdef UPBCLX + DEFINE(UPBCLX) +#else + MISSING(UPBCLX) +#endif + +#ifdef UPBCX + DEFINE(UPBCX) +#else + MISSING(UPBCX) +#endif + +#ifdef UPBCXH + DEFINE(UPBCXH) +#else + MISSING(UPBCXH) +#endif + +#ifdef UPBCXL + DEFINE(UPBCXL) +#else + MISSING(UPBCXL) +#endif + +#ifdef UPCFG0X + DEFINE(UPCFG0X) +#else + MISSING(UPCFG0X) +#endif + +#ifdef UPCFG1X + DEFINE(UPCFG1X) +#else + MISSING(UPCFG1X) +#endif + +#ifdef UPCFG2X + DEFINE(UPCFG2X) +#else + MISSING(UPCFG2X) +#endif + +#ifdef UPCONX + DEFINE(UPCONX) +#else + MISSING(UPCONX) +#endif + +#ifdef UPCRX + DEFINE(UPCRX) +#else + MISSING(UPCRX) +#endif + +#ifdef UPDATX + DEFINE(UPDATX) +#else + MISSING(UPDATX) +#endif + +#ifdef UPERRX + DEFINE(UPERRX) +#else + MISSING(UPERRX) +#endif + +#ifdef UPIENX + DEFINE(UPIENX) +#else + MISSING(UPIENX) +#endif + +#ifdef UPINRQX + DEFINE(UPINRQX) +#else + MISSING(UPINRQX) +#endif + +#ifdef UPINT + DEFINE(UPINT) +#else + MISSING(UPINT) +#endif + +#ifdef UPINTX + DEFINE(UPINTX) +#else + MISSING(UPINTX) +#endif + +#ifdef UPNUM + DEFINE(UPNUM) +#else + MISSING(UPNUM) +#endif + +#ifdef UPOE + DEFINE(UPOE) +#else + MISSING(UPOE) +#endif + +#ifdef UPRST + DEFINE(UPRST) +#else + MISSING(UPRST) +#endif + +#ifdef UPSTAX + DEFINE(UPSTAX) +#else + MISSING(UPSTAX) +#endif + +#ifdef USARTC0_BAUDCTRLA + DEFINE(USARTC0_BAUDCTRLA) +#else + MISSING(USARTC0_BAUDCTRLA) +#endif + +#ifdef USARTC0_BAUDCTRLB + DEFINE(USARTC0_BAUDCTRLB) +#else + MISSING(USARTC0_BAUDCTRLB) +#endif + +#ifdef USARTC0_CTRLA + DEFINE(USARTC0_CTRLA) +#else + MISSING(USARTC0_CTRLA) +#endif + +#ifdef USARTC0_CTRLB + DEFINE(USARTC0_CTRLB) +#else + MISSING(USARTC0_CTRLB) +#endif + +#ifdef USARTC0_CTRLC + DEFINE(USARTC0_CTRLC) +#else + MISSING(USARTC0_CTRLC) +#endif + +#ifdef USARTC0_DATA + DEFINE(USARTC0_DATA) +#else + MISSING(USARTC0_DATA) +#endif + +#ifdef USARTC0_STATUS + DEFINE(USARTC0_STATUS) +#else + MISSING(USARTC0_STATUS) +#endif + +#ifdef USARTC1_BAUDCTRLA + DEFINE(USARTC1_BAUDCTRLA) +#else + MISSING(USARTC1_BAUDCTRLA) +#endif + +#ifdef USARTC1_BAUDCTRLB + DEFINE(USARTC1_BAUDCTRLB) +#else + MISSING(USARTC1_BAUDCTRLB) +#endif + +#ifdef USARTC1_CTRLA + DEFINE(USARTC1_CTRLA) +#else + MISSING(USARTC1_CTRLA) +#endif + +#ifdef USARTC1_CTRLB + DEFINE(USARTC1_CTRLB) +#else + MISSING(USARTC1_CTRLB) +#endif + +#ifdef USARTC1_CTRLC + DEFINE(USARTC1_CTRLC) +#else + MISSING(USARTC1_CTRLC) +#endif + +#ifdef USARTC1_DATA + DEFINE(USARTC1_DATA) +#else + MISSING(USARTC1_DATA) +#endif + +#ifdef USARTC1_STATUS + DEFINE(USARTC1_STATUS) +#else + MISSING(USARTC1_STATUS) +#endif + +#ifdef USARTD0_BAUDCTRLA + DEFINE(USARTD0_BAUDCTRLA) +#else + MISSING(USARTD0_BAUDCTRLA) +#endif + +#ifdef USARTD0_BAUDCTRLB + DEFINE(USARTD0_BAUDCTRLB) +#else + MISSING(USARTD0_BAUDCTRLB) +#endif + +#ifdef USARTD0_CTRLA + DEFINE(USARTD0_CTRLA) +#else + MISSING(USARTD0_CTRLA) +#endif + +#ifdef USARTD0_CTRLB + DEFINE(USARTD0_CTRLB) +#else + MISSING(USARTD0_CTRLB) +#endif + +#ifdef USARTD0_CTRLC + DEFINE(USARTD0_CTRLC) +#else + MISSING(USARTD0_CTRLC) +#endif + +#ifdef USARTD0_DATA + DEFINE(USARTD0_DATA) +#else + MISSING(USARTD0_DATA) +#endif + +#ifdef USARTD0_STATUS + DEFINE(USARTD0_STATUS) +#else + MISSING(USARTD0_STATUS) +#endif + +#ifdef USARTD1_BAUDCTRLA + DEFINE(USARTD1_BAUDCTRLA) +#else + MISSING(USARTD1_BAUDCTRLA) +#endif + +#ifdef USARTD1_BAUDCTRLB + DEFINE(USARTD1_BAUDCTRLB) +#else + MISSING(USARTD1_BAUDCTRLB) +#endif + +#ifdef USARTD1_CTRLA + DEFINE(USARTD1_CTRLA) +#else + MISSING(USARTD1_CTRLA) +#endif + +#ifdef USARTD1_CTRLB + DEFINE(USARTD1_CTRLB) +#else + MISSING(USARTD1_CTRLB) +#endif + +#ifdef USARTD1_CTRLC + DEFINE(USARTD1_CTRLC) +#else + MISSING(USARTD1_CTRLC) +#endif + +#ifdef USARTD1_DATA + DEFINE(USARTD1_DATA) +#else + MISSING(USARTD1_DATA) +#endif + +#ifdef USARTD1_STATUS + DEFINE(USARTD1_STATUS) +#else + MISSING(USARTD1_STATUS) +#endif + +#ifdef USARTE0_BAUDCTRLA + DEFINE(USARTE0_BAUDCTRLA) +#else + MISSING(USARTE0_BAUDCTRLA) +#endif + +#ifdef USARTE0_BAUDCTRLB + DEFINE(USARTE0_BAUDCTRLB) +#else + MISSING(USARTE0_BAUDCTRLB) +#endif + +#ifdef USARTE0_CTRLA + DEFINE(USARTE0_CTRLA) +#else + MISSING(USARTE0_CTRLA) +#endif + +#ifdef USARTE0_CTRLB + DEFINE(USARTE0_CTRLB) +#else + MISSING(USARTE0_CTRLB) +#endif + +#ifdef USARTE0_CTRLC + DEFINE(USARTE0_CTRLC) +#else + MISSING(USARTE0_CTRLC) +#endif + +#ifdef USARTE0_DATA + DEFINE(USARTE0_DATA) +#else + MISSING(USARTE0_DATA) +#endif + +#ifdef USARTE0_STATUS + DEFINE(USARTE0_STATUS) +#else + MISSING(USARTE0_STATUS) +#endif + +#ifdef USARTE1_BAUDCTRLA + DEFINE(USARTE1_BAUDCTRLA) +#else + MISSING(USARTE1_BAUDCTRLA) +#endif + +#ifdef USARTE1_BAUDCTRLB + DEFINE(USARTE1_BAUDCTRLB) +#else + MISSING(USARTE1_BAUDCTRLB) +#endif + +#ifdef USARTE1_CTRLA + DEFINE(USARTE1_CTRLA) +#else + MISSING(USARTE1_CTRLA) +#endif + +#ifdef USARTE1_CTRLB + DEFINE(USARTE1_CTRLB) +#else + MISSING(USARTE1_CTRLB) +#endif + +#ifdef USARTE1_CTRLC + DEFINE(USARTE1_CTRLC) +#else + MISSING(USARTE1_CTRLC) +#endif + +#ifdef USARTE1_DATA + DEFINE(USARTE1_DATA) +#else + MISSING(USARTE1_DATA) +#endif + +#ifdef USARTE1_STATUS + DEFINE(USARTE1_STATUS) +#else + MISSING(USARTE1_STATUS) +#endif + +#ifdef USARTF0_BAUDCTRLA + DEFINE(USARTF0_BAUDCTRLA) +#else + MISSING(USARTF0_BAUDCTRLA) +#endif + +#ifdef USARTF0_BAUDCTRLB + DEFINE(USARTF0_BAUDCTRLB) +#else + MISSING(USARTF0_BAUDCTRLB) +#endif + +#ifdef USARTF0_CTRLA + DEFINE(USARTF0_CTRLA) +#else + MISSING(USARTF0_CTRLA) +#endif + +#ifdef USARTF0_CTRLB + DEFINE(USARTF0_CTRLB) +#else + MISSING(USARTF0_CTRLB) +#endif + +#ifdef USARTF0_CTRLC + DEFINE(USARTF0_CTRLC) +#else + MISSING(USARTF0_CTRLC) +#endif + +#ifdef USARTF0_DATA + DEFINE(USARTF0_DATA) +#else + MISSING(USARTF0_DATA) +#endif + +#ifdef USARTF0_STATUS + DEFINE(USARTF0_STATUS) +#else + MISSING(USARTF0_STATUS) +#endif + +#ifdef USARTF1_BAUDCTRLA + DEFINE(USARTF1_BAUDCTRLA) +#else + MISSING(USARTF1_BAUDCTRLA) +#endif + +#ifdef USARTF1_BAUDCTRLB + DEFINE(USARTF1_BAUDCTRLB) +#else + MISSING(USARTF1_BAUDCTRLB) +#endif + +#ifdef USARTF1_CTRLA + DEFINE(USARTF1_CTRLA) +#else + MISSING(USARTF1_CTRLA) +#endif + +#ifdef USARTF1_CTRLB + DEFINE(USARTF1_CTRLB) +#else + MISSING(USARTF1_CTRLB) +#endif + +#ifdef USARTF1_CTRLC + DEFINE(USARTF1_CTRLC) +#else + MISSING(USARTF1_CTRLC) +#endif + +#ifdef USARTF1_DATA + DEFINE(USARTF1_DATA) +#else + MISSING(USARTF1_DATA) +#endif + +#ifdef USARTF1_STATUS + DEFINE(USARTF1_STATUS) +#else + MISSING(USARTF1_STATUS) +#endif + +#ifdef USBCON + DEFINE(USBCON) +#else + MISSING(USBCON) +#endif + +#ifdef USBCR + DEFINE(USBCR) +#else + MISSING(USBCR) +#endif + +#ifdef USBCSEX + DEFINE(USBCSEX) +#else + MISSING(USBCSEX) +#endif + +#ifdef USBDBCEX + DEFINE(USBDBCEX) +#else + MISSING(USBDBCEX) +#endif + +#ifdef USBDMAB + DEFINE(USBDMAB) +#else + MISSING(USBDMAB) +#endif + +#ifdef USBDMACS + DEFINE(USBDMACS) +#else + MISSING(USBDMACS) +#endif + +#ifdef USBDMAD + DEFINE(USBDMAD) +#else + MISSING(USBDMAD) +#endif + +#ifdef USBDMADH + DEFINE(USBDMADH) +#else + MISSING(USBDMADH) +#endif + +#ifdef USBDMADL + DEFINE(USBDMADL) +#else + MISSING(USBDMADL) +#endif + +#ifdef USBEI + DEFINE(USBEI) +#else + MISSING(USBEI) +#endif + +#ifdef USBEIM + DEFINE(USBEIM) +#else + MISSING(USBEIM) +#endif + +#ifdef USBENUM + DEFINE(USBENUM) +#else + MISSING(USBENUM) +#endif + +#ifdef USBFA + DEFINE(USBFA) +#else + MISSING(USBFA) +#endif + +#ifdef USBFCEX + DEFINE(USBFCEX) +#else + MISSING(USBFCEX) +#endif + +#ifdef USBFN + DEFINE(USBFN) +#else + MISSING(USBFN) +#endif + +#ifdef USBFNH + DEFINE(USBFNH) +#else + MISSING(USBFNH) +#endif + +#ifdef USBFNL + DEFINE(USBFNL) +#else + MISSING(USBFNL) +#endif + +#ifdef USBGS + DEFINE(USBGS) +#else + MISSING(USBGS) +#endif + +#ifdef USBINT + DEFINE(USBINT) +#else + MISSING(USBINT) +#endif + +#ifdef USBPI + DEFINE(USBPI) +#else + MISSING(USBPI) +#endif + +#ifdef USBPIM + DEFINE(USBPIM) +#else + MISSING(USBPIM) +#endif + +#ifdef USBRSTE + DEFINE(USBRSTE) +#else + MISSING(USBRSTE) +#endif + +#ifdef USBSTA + DEFINE(USBSTA) +#else + MISSING(USBSTA) +#endif + +#ifdef USB_ADDR + DEFINE(USB_ADDR) +#else + MISSING(USB_ADDR) +#endif + +#ifdef USB_CAL0 + DEFINE(USB_CAL0) +#else + MISSING(USB_CAL0) +#endif + +#ifdef USB_CAL1 + DEFINE(USB_CAL1) +#else + MISSING(USB_CAL1) +#endif + +#ifdef USB_CTRLA + DEFINE(USB_CTRLA) +#else + MISSING(USB_CTRLA) +#endif + +#ifdef USB_CTRLB + DEFINE(USB_CTRLB) +#else + MISSING(USB_CTRLB) +#endif + +#ifdef USB_EPPTR + DEFINE(USB_EPPTR) +#else + MISSING(USB_EPPTR) +#endif + +#ifdef USB_EP_TABLE_EP0IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP0IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP0IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP0IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP0IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP0IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_CNTH + DEFINE(USB_EP_TABLE_EP0IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP0IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP0IN_CNTL + DEFINE(USB_EP_TABLE_EP0IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP0IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_CTRL + DEFINE(USB_EP_TABLE_EP0IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP0IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP0IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP0IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP0IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP0IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP0IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_STATUS + DEFINE(USB_EP_TABLE_EP0IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP0IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP0OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP0OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_CNTH + DEFINE(USB_EP_TABLE_EP0OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP0OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_CNTL + DEFINE(USB_EP_TABLE_EP0OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP0OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_CTRL + DEFINE(USB_EP_TABLE_EP0OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP0OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP0OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP0OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_STATUS + DEFINE(USB_EP_TABLE_EP0OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP0OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP10IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP10IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP10IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP10IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP10IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP10IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_CNTH + DEFINE(USB_EP_TABLE_EP10IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP10IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP10IN_CNTL + DEFINE(USB_EP_TABLE_EP10IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP10IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_CTRL + DEFINE(USB_EP_TABLE_EP10IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP10IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP10IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP10IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP10IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP10IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP10IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_STATUS + DEFINE(USB_EP_TABLE_EP10IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP10IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP10OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP10OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_CNTH + DEFINE(USB_EP_TABLE_EP10OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP10OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_CNTL + DEFINE(USB_EP_TABLE_EP10OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP10OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_CTRL + DEFINE(USB_EP_TABLE_EP10OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP10OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP10OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP10OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_STATUS + DEFINE(USB_EP_TABLE_EP10OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP10OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP11IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP11IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP11IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP11IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP11IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP11IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_CNTH + DEFINE(USB_EP_TABLE_EP11IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP11IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP11IN_CNTL + DEFINE(USB_EP_TABLE_EP11IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP11IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_CTRL + DEFINE(USB_EP_TABLE_EP11IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP11IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP11IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP11IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP11IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP11IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP11IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_STATUS + DEFINE(USB_EP_TABLE_EP11IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP11IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP11OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP11OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_CNTH + DEFINE(USB_EP_TABLE_EP11OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP11OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_CNTL + DEFINE(USB_EP_TABLE_EP11OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP11OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_CTRL + DEFINE(USB_EP_TABLE_EP11OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP11OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP11OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP11OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_STATUS + DEFINE(USB_EP_TABLE_EP11OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP11OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP12IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP12IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP12IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP12IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP12IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP12IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_CNTH + DEFINE(USB_EP_TABLE_EP12IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP12IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP12IN_CNTL + DEFINE(USB_EP_TABLE_EP12IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP12IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_CTRL + DEFINE(USB_EP_TABLE_EP12IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP12IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP12IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP12IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP12IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP12IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP12IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_STATUS + DEFINE(USB_EP_TABLE_EP12IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP12IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP12OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP12OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_CNTH + DEFINE(USB_EP_TABLE_EP12OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP12OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_CNTL + DEFINE(USB_EP_TABLE_EP12OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP12OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_CTRL + DEFINE(USB_EP_TABLE_EP12OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP12OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP12OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP12OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_STATUS + DEFINE(USB_EP_TABLE_EP12OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP12OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP13IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP13IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP13IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP13IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP13IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP13IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_CNTH + DEFINE(USB_EP_TABLE_EP13IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP13IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP13IN_CNTL + DEFINE(USB_EP_TABLE_EP13IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP13IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_CTRL + DEFINE(USB_EP_TABLE_EP13IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP13IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP13IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP13IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP13IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP13IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP13IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_STATUS + DEFINE(USB_EP_TABLE_EP13IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP13IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP13OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP13OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_CNTH + DEFINE(USB_EP_TABLE_EP13OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP13OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_CNTL + DEFINE(USB_EP_TABLE_EP13OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP13OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_CTRL + DEFINE(USB_EP_TABLE_EP13OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP13OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP13OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP13OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_STATUS + DEFINE(USB_EP_TABLE_EP13OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP13OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP14IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP14IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP14IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP14IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP14IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP14IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_CNTH + DEFINE(USB_EP_TABLE_EP14IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP14IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP14IN_CNTL + DEFINE(USB_EP_TABLE_EP14IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP14IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_CTRL + DEFINE(USB_EP_TABLE_EP14IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP14IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP14IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP14IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP14IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP14IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP14IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_STATUS + DEFINE(USB_EP_TABLE_EP14IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP14IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP14OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP14OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_CNTH + DEFINE(USB_EP_TABLE_EP14OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP14OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_CNTL + DEFINE(USB_EP_TABLE_EP14OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP14OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_CTRL + DEFINE(USB_EP_TABLE_EP14OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP14OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP14OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP14OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_STATUS + DEFINE(USB_EP_TABLE_EP14OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP14OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP15IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP15IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP15IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP15IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP15IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP15IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_CNTH + DEFINE(USB_EP_TABLE_EP15IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP15IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP15IN_CNTL + DEFINE(USB_EP_TABLE_EP15IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP15IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_CTRL + DEFINE(USB_EP_TABLE_EP15IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP15IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP15IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP15IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP15IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP15IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP15IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_STATUS + DEFINE(USB_EP_TABLE_EP15IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP15IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP15OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP15OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_CNTH + DEFINE(USB_EP_TABLE_EP15OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP15OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_CNTL + DEFINE(USB_EP_TABLE_EP15OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP15OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_CTRL + DEFINE(USB_EP_TABLE_EP15OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP15OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP15OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP15OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_STATUS + DEFINE(USB_EP_TABLE_EP15OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP15OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP1IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP1IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP1IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP1IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP1IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP1IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_CNTH + DEFINE(USB_EP_TABLE_EP1IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP1IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP1IN_CNTL + DEFINE(USB_EP_TABLE_EP1IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP1IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_CTRL + DEFINE(USB_EP_TABLE_EP1IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP1IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP1IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP1IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP1IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP1IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP1IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_STATUS + DEFINE(USB_EP_TABLE_EP1IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP1IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP1OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP1OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_CNTH + DEFINE(USB_EP_TABLE_EP1OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP1OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_CNTL + DEFINE(USB_EP_TABLE_EP1OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP1OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_CTRL + DEFINE(USB_EP_TABLE_EP1OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP1OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP1OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP1OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_STATUS + DEFINE(USB_EP_TABLE_EP1OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP1OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP2IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP2IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP2IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP2IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP2IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP2IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_CNTH + DEFINE(USB_EP_TABLE_EP2IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP2IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP2IN_CNTL + DEFINE(USB_EP_TABLE_EP2IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP2IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_CTRL + DEFINE(USB_EP_TABLE_EP2IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP2IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP2IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP2IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP2IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP2IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP2IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_STATUS + DEFINE(USB_EP_TABLE_EP2IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP2IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP2OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP2OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_CNTH + DEFINE(USB_EP_TABLE_EP2OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP2OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_CNTL + DEFINE(USB_EP_TABLE_EP2OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP2OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_CTRL + DEFINE(USB_EP_TABLE_EP2OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP2OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP2OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP2OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_STATUS + DEFINE(USB_EP_TABLE_EP2OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP2OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP3IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP3IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP3IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP3IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP3IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP3IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_CNTH + DEFINE(USB_EP_TABLE_EP3IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP3IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP3IN_CNTL + DEFINE(USB_EP_TABLE_EP3IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP3IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_CTRL + DEFINE(USB_EP_TABLE_EP3IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP3IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP3IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP3IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP3IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP3IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP3IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_STATUS + DEFINE(USB_EP_TABLE_EP3IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP3IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP3OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP3OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_CNTH + DEFINE(USB_EP_TABLE_EP3OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP3OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_CNTL + DEFINE(USB_EP_TABLE_EP3OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP3OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_CTRL + DEFINE(USB_EP_TABLE_EP3OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP3OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP3OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP3OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_STATUS + DEFINE(USB_EP_TABLE_EP3OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP3OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP4IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP4IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP4IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP4IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP4IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP4IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_CNTH + DEFINE(USB_EP_TABLE_EP4IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP4IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP4IN_CNTL + DEFINE(USB_EP_TABLE_EP4IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP4IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_CTRL + DEFINE(USB_EP_TABLE_EP4IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP4IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP4IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP4IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP4IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP4IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP4IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_STATUS + DEFINE(USB_EP_TABLE_EP4IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP4IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP4OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP4OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_CNTH + DEFINE(USB_EP_TABLE_EP4OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP4OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_CNTL + DEFINE(USB_EP_TABLE_EP4OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP4OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_CTRL + DEFINE(USB_EP_TABLE_EP4OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP4OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP4OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP4OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_STATUS + DEFINE(USB_EP_TABLE_EP4OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP4OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP5IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP5IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP5IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP5IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP5IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP5IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_CNTH + DEFINE(USB_EP_TABLE_EP5IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP5IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP5IN_CNTL + DEFINE(USB_EP_TABLE_EP5IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP5IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_CTRL + DEFINE(USB_EP_TABLE_EP5IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP5IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP5IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP5IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP5IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP5IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP5IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_STATUS + DEFINE(USB_EP_TABLE_EP5IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP5IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP5OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP5OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_CNTH + DEFINE(USB_EP_TABLE_EP5OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP5OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_CNTL + DEFINE(USB_EP_TABLE_EP5OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP5OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_CTRL + DEFINE(USB_EP_TABLE_EP5OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP5OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP5OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP5OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_STATUS + DEFINE(USB_EP_TABLE_EP5OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP5OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP6IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP6IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP6IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP6IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP6IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP6IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_CNTH + DEFINE(USB_EP_TABLE_EP6IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP6IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP6IN_CNTL + DEFINE(USB_EP_TABLE_EP6IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP6IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_CTRL + DEFINE(USB_EP_TABLE_EP6IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP6IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP6IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP6IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP6IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP6IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP6IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_STATUS + DEFINE(USB_EP_TABLE_EP6IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP6IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP6OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP6OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_CNTH + DEFINE(USB_EP_TABLE_EP6OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP6OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_CNTL + DEFINE(USB_EP_TABLE_EP6OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP6OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_CTRL + DEFINE(USB_EP_TABLE_EP6OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP6OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP6OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP6OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_STATUS + DEFINE(USB_EP_TABLE_EP6OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP6OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP7IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP7IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP7IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP7IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP7IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP7IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_CNTH + DEFINE(USB_EP_TABLE_EP7IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP7IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP7IN_CNTL + DEFINE(USB_EP_TABLE_EP7IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP7IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_CTRL + DEFINE(USB_EP_TABLE_EP7IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP7IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP7IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP7IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP7IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP7IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP7IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_STATUS + DEFINE(USB_EP_TABLE_EP7IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP7IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP7OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP7OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_CNTH + DEFINE(USB_EP_TABLE_EP7OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP7OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_CNTL + DEFINE(USB_EP_TABLE_EP7OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP7OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_CTRL + DEFINE(USB_EP_TABLE_EP7OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP7OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP7OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP7OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_STATUS + DEFINE(USB_EP_TABLE_EP7OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP7OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP8IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP8IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP8IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP8IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP8IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP8IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_CNTH + DEFINE(USB_EP_TABLE_EP8IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP8IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP8IN_CNTL + DEFINE(USB_EP_TABLE_EP8IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP8IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_CTRL + DEFINE(USB_EP_TABLE_EP8IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP8IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP8IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP8IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP8IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP8IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP8IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_STATUS + DEFINE(USB_EP_TABLE_EP8IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP8IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP8OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP8OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_CNTH + DEFINE(USB_EP_TABLE_EP8OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP8OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_CNTL + DEFINE(USB_EP_TABLE_EP8OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP8OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_CTRL + DEFINE(USB_EP_TABLE_EP8OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP8OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP8OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP8OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_STATUS + DEFINE(USB_EP_TABLE_EP8OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP8OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP9IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP9IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP9IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP9IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP9IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP9IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_CNTH + DEFINE(USB_EP_TABLE_EP9IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP9IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP9IN_CNTL + DEFINE(USB_EP_TABLE_EP9IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP9IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_CTRL + DEFINE(USB_EP_TABLE_EP9IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP9IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP9IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP9IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP9IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP9IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP9IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_STATUS + DEFINE(USB_EP_TABLE_EP9IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP9IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP9OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP9OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_CNTH + DEFINE(USB_EP_TABLE_EP9OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP9OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_CNTL + DEFINE(USB_EP_TABLE_EP9OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP9OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_CTRL + DEFINE(USB_EP_TABLE_EP9OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP9OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP9OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP9OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_STATUS + DEFINE(USB_EP_TABLE_EP9OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP9OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_FRAMENUMH + DEFINE(USB_EP_TABLE_FRAMENUMH) +#else + MISSING(USB_EP_TABLE_FRAMENUMH) +#endif + +#ifdef USB_EP_TABLE_FRAMENUML + DEFINE(USB_EP_TABLE_FRAMENUML) +#else + MISSING(USB_EP_TABLE_FRAMENUML) +#endif + +#ifdef USB_FIFORP + DEFINE(USB_FIFORP) +#else + MISSING(USB_FIFORP) +#endif + +#ifdef USB_FIFOWP + DEFINE(USB_FIFOWP) +#else + MISSING(USB_FIFOWP) +#endif + +#ifdef USB_INTCTRLA + DEFINE(USB_INTCTRLA) +#else + MISSING(USB_INTCTRLA) +#endif + +#ifdef USB_INTCTRLB + DEFINE(USB_INTCTRLB) +#else + MISSING(USB_INTCTRLB) +#endif + +#ifdef USB_INTFLAGSACLR + DEFINE(USB_INTFLAGSACLR) +#else + MISSING(USB_INTFLAGSACLR) +#endif + +#ifdef USB_INTFLAGSASET + DEFINE(USB_INTFLAGSASET) +#else + MISSING(USB_INTFLAGSASET) +#endif + +#ifdef USB_INTFLAGSBCLR + DEFINE(USB_INTFLAGSBCLR) +#else + MISSING(USB_INTFLAGSBCLR) +#endif + +#ifdef USB_INTFLAGSBSET + DEFINE(USB_INTFLAGSBSET) +#else + MISSING(USB_INTFLAGSBSET) +#endif + +#ifdef USB_STATUS + DEFINE(USB_STATUS) +#else + MISSING(USB_STATUS) +#endif + +#ifdef USIBR + DEFINE(USIBR) +#else + MISSING(USIBR) +#endif + +#ifdef USICR + DEFINE(USICR) +#else + MISSING(USICR) +#endif + +#ifdef USIDR + DEFINE(USIDR) +#else + MISSING(USIDR) +#endif + +#ifdef USIPP + DEFINE(USIPP) +#else + MISSING(USIPP) +#endif + +#ifdef USISR + DEFINE(USISR) +#else + MISSING(USISR) +#endif + +#ifdef USPCR + DEFINE(USPCR) +#else + MISSING(USPCR) +#endif + +#ifdef USPDR + DEFINE(USPDR) +#else + MISSING(USPDR) +#endif + +#ifdef USPSR + DEFINE(USPSR) +#else + MISSING(USPSR) +#endif + +#ifdef USR + DEFINE(USR) +#else + MISSING(USR) +#endif + +#ifdef VADAC0 + DEFINE(VADAC0) +#else + MISSING(VADAC0) +#endif + +#ifdef VADAC1 + DEFINE(VADAC1) +#else + MISSING(VADAC1) +#endif + +#ifdef VADAC2 + DEFINE(VADAC2) +#else + MISSING(VADAC2) +#endif + +#ifdef VADAC3 + DEFINE(VADAC3) +#else + MISSING(VADAC3) +#endif + +#ifdef VADC + DEFINE(VADC) +#else + MISSING(VADC) +#endif + +#ifdef VADCH + DEFINE(VADCH) +#else + MISSING(VADCH) +#endif + +#ifdef VADCL + DEFINE(VADCL) +#else + MISSING(VADCL) +#endif + +#ifdef VADCSR + DEFINE(VADCSR) +#else + MISSING(VADCSR) +#endif + +#ifdef VADIC + DEFINE(VADIC) +#else + MISSING(VADIC) +#endif + +#ifdef VADICH + DEFINE(VADICH) +#else + MISSING(VADICH) +#endif + +#ifdef VADICL + DEFINE(VADICL) +#else + MISSING(VADICL) +#endif + +#ifdef VADMUX + DEFINE(VADMUX) +#else + MISSING(VADMUX) +#endif + +#ifdef VBAT_BACKUP0 + DEFINE(VBAT_BACKUP0) +#else + MISSING(VBAT_BACKUP0) +#endif + +#ifdef VBAT_BACKUP1 + DEFINE(VBAT_BACKUP1) +#else + MISSING(VBAT_BACKUP1) +#endif + +#ifdef VBAT_CTRL + DEFINE(VBAT_CTRL) +#else + MISSING(VBAT_CTRL) +#endif + +#ifdef VBAT_STATUS + DEFINE(VBAT_STATUS) +#else + MISSING(VBAT_STATUS) +#endif + +#ifdef VCOTUNE + DEFINE(VCOTUNE) +#else + MISSING(VCOTUNE) +#endif + +#ifdef VELACC1 + DEFINE(VELACC1) +#else + MISSING(VELACC1) +#endif + +#ifdef VELACC2 + DEFINE(VELACC2) +#else + MISSING(VELACC2) +#endif + +#ifdef VELACC3 + DEFINE(VELACC3) +#else + MISSING(VELACC3) +#endif + +#ifdef VELCVEL + DEFINE(VELCVEL) +#else + MISSING(VELCVEL) +#endif + +#ifdef VELDEC1 + DEFINE(VELDEC1) +#else + MISSING(VELDEC1) +#endif + +#ifdef VELDEC2 + DEFINE(VELDEC2) +#else + MISSING(VELDEC2) +#endif + +#ifdef VELDEC3 + DEFINE(VELDEC3) +#else + MISSING(VELDEC3) +#endif + +#ifdef VELHI1 + DEFINE(VELHI1) +#else + MISSING(VELHI1) +#endif + +#ifdef VELHI2 + DEFINE(VELHI2) +#else + MISSING(VELHI2) +#endif + +#ifdef VELHI3 + DEFINE(VELHI3) +#else + MISSING(VELHI3) +#endif + +#ifdef VELIFLG + DEFINE(VELIFLG) +#else + MISSING(VELIFLG) +#endif + +#ifdef VELIMSK + DEFINE(VELIMSK) +#else + MISSING(VELIMSK) +#endif + +#ifdef VELLOW1 + DEFINE(VELLOW1) +#else + MISSING(VELLOW1) +#endif + +#ifdef VELLOW2 + DEFINE(VELLOW2) +#else + MISSING(VELLOW2) +#endif + +#ifdef VELLOW3 + DEFINE(VELLOW3) +#else + MISSING(VELLOW3) +#endif + +#ifdef VELSTB + DEFINE(VELSTB) +#else + MISSING(VELSTB) +#endif + +#ifdef VELTVEL + DEFINE(VELTVEL) +#else + MISSING(VELTVEL) +#endif + +#ifdef VELVGCTL + DEFINE(VELVGCTL) +#else + MISSING(VELVGCTL) +#endif + +#ifdef VERSION_NUM + DEFINE(VERSION_NUM) +#else + MISSING(VERSION_NUM) +#endif + +#ifdef VLMCSR + DEFINE(VLMCSR) +#else + MISSING(VLMCSR) +#endif + +#ifdef VMCSR + DEFINE(VMCSR) +#else + MISSING(VMCSR) +#endif + +#ifdef VPORT0_DIR + DEFINE(VPORT0_DIR) +#else + MISSING(VPORT0_DIR) +#endif + +#ifdef VPORT0_IN + DEFINE(VPORT0_IN) +#else + MISSING(VPORT0_IN) +#endif + +#ifdef VPORT0_INTFLAGS + DEFINE(VPORT0_INTFLAGS) +#else + MISSING(VPORT0_INTFLAGS) +#endif + +#ifdef VPORT0_OUT + DEFINE(VPORT0_OUT) +#else + MISSING(VPORT0_OUT) +#endif + +#ifdef VPORT1_DIR + DEFINE(VPORT1_DIR) +#else + MISSING(VPORT1_DIR) +#endif + +#ifdef VPORT1_IN + DEFINE(VPORT1_IN) +#else + MISSING(VPORT1_IN) +#endif + +#ifdef VPORT1_INTFLAGS + DEFINE(VPORT1_INTFLAGS) +#else + MISSING(VPORT1_INTFLAGS) +#endif + +#ifdef VPORT1_OUT + DEFINE(VPORT1_OUT) +#else + MISSING(VPORT1_OUT) +#endif + +#ifdef VPORT2_DIR + DEFINE(VPORT2_DIR) +#else + MISSING(VPORT2_DIR) +#endif + +#ifdef VPORT2_IN + DEFINE(VPORT2_IN) +#else + MISSING(VPORT2_IN) +#endif + +#ifdef VPORT2_INTFLAGS + DEFINE(VPORT2_INTFLAGS) +#else + MISSING(VPORT2_INTFLAGS) +#endif + +#ifdef VPORT2_OUT + DEFINE(VPORT2_OUT) +#else + MISSING(VPORT2_OUT) +#endif + +#ifdef VPORT3_DIR + DEFINE(VPORT3_DIR) +#else + MISSING(VPORT3_DIR) +#endif + +#ifdef VPORT3_IN + DEFINE(VPORT3_IN) +#else + MISSING(VPORT3_IN) +#endif + +#ifdef VPORT3_INTFLAGS + DEFINE(VPORT3_INTFLAGS) +#else + MISSING(VPORT3_INTFLAGS) +#endif + +#ifdef VPORT3_OUT + DEFINE(VPORT3_OUT) +#else + MISSING(VPORT3_OUT) +#endif + +#ifdef VREG_CTRL + DEFINE(VREG_CTRL) +#else + MISSING(VREG_CTRL) +#endif + +#ifdef WDTCKD + DEFINE(WDTCKD) +#else + MISSING(WDTCKD) +#endif + +#ifdef WDTCLR + DEFINE(WDTCLR) +#else + MISSING(WDTCLR) +#endif + +#ifdef WDTCR + DEFINE(WDTCR) +#else + MISSING(WDTCR) +#endif + +#ifdef WDTCSR + DEFINE(WDTCSR) +#else + MISSING(WDTCSR) +#endif + +#ifdef WDT_CTRL + DEFINE(WDT_CTRL) +#else + MISSING(WDT_CTRL) +#endif + +#ifdef WDT_STATUS + DEFINE(WDT_STATUS) +#else + MISSING(WDT_STATUS) +#endif + +#ifdef WDT_WINCTRL + DEFINE(WDT_WINCTRL) +#else + MISSING(WDT_WINCTRL) +#endif + +#ifdef WUTCSR + DEFINE(WUTCSR) +#else + MISSING(WUTCSR) +#endif + +#ifdef XAH_CTRL_0 + DEFINE(XAH_CTRL_0) +#else + MISSING(XAH_CTRL_0) +#endif + +#ifdef XAH_CTRL_1 + DEFINE(XAH_CTRL_1) +#else + MISSING(XAH_CTRL_1) +#endif + +#ifdef XDIV + DEFINE(XDIV) +#else + MISSING(XDIV) +#endif + +#ifdef XMCRA + DEFINE(XMCRA) +#else + MISSING(XMCRA) +#endif + +#ifdef XMCRB + DEFINE(XMCRB) +#else + MISSING(XMCRB) +#endif + +#ifdef XOSC_CTRL + DEFINE(XOSC_CTRL) +#else + MISSING(XOSC_CTRL) +#endif \ No newline at end of file diff --git a/firmware/Nanpy/generated_mcu.h b/firmware/Nanpy/generated_mcu.h new file mode 100644 index 0000000..dfce6ac --- /dev/null +++ b/firmware/Nanpy/generated_mcu.h @@ -0,0 +1,1287 @@ + +// this file was generated by codegen.py + +// __AVR_LIBC_VERSION_STRING__ = "1.8.0" +// __AVR_LIBC_DATE_STRING__ = "20111228" + + +#ifdef __AVR_AT43USB320__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT43USB320__" +#endif + +#ifdef __AVR_AT43USB355__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT43USB355__" +#endif + +#ifdef __AVR_AT76C711__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT76C711__" +#endif + +#ifdef __AVR_AT86RF401__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT86RF401__" +#endif + +#ifdef __AVR_AT90C8534__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90C8534__" +#endif + +#ifdef __AVR_AT90CAN128__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90CAN128__" +#endif + +#ifdef __AVR_AT90CAN32__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90CAN32__" +#endif + +#ifdef __AVR_AT90CAN64__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90CAN64__" +#endif + +#ifdef __AVR_AT90PWM1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM1__" +#endif + +#ifdef __AVR_AT90PWM216__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM216__" +#endif + +#ifdef __AVR_AT90PWM2B__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM2B__" +#endif + +#ifdef __AVR_AT90PWM2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM2__" +#endif + +#ifdef __AVR_AT90PWM316__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM316__" +#endif + +#ifdef __AVR_AT90PWM3B__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM3B__" +#endif + +#ifdef __AVR_AT90PWM3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM3__" +#endif + +#ifdef __AVR_AT90PWM81__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM81__" +#endif + +#ifdef __AVR_AT90S1200__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S1200__" +#endif + +#ifdef __AVR_AT90S2313__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2313__" +#endif + +#ifdef __AVR_AT90S2323__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2323__" +#endif + +#ifdef __AVR_AT90S2333__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2333__" +#endif + +#ifdef __AVR_AT90S2343__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2343__" +#endif + +#ifdef __AVR_AT90S4414__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S4414__" +#endif + +#ifdef __AVR_AT90S4433__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S4433__" +#endif + +#ifdef __AVR_AT90S4434__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S4434__" +#endif + +#ifdef __AVR_AT90S8515__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S8515__" +#endif + +#ifdef __AVR_AT90S8535__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S8535__" +#endif + +#ifdef __AVR_AT90SCR100__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90SCR100__" +#endif + +#ifdef __AVR_AT90USB1286__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB1286__" +#endif + +#ifdef __AVR_AT90USB1287__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB1287__" +#endif + +#ifdef __AVR_AT90USB162__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB162__" +#endif + +#ifdef __AVR_AT90USB646__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB646__" +#endif + +#ifdef __AVR_AT90USB647__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB647__" +#endif + +#ifdef __AVR_AT90USB82__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB82__" +#endif + +#ifdef __AVR_AT94K__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT94K__" +#endif + +#ifdef __AVR_ATA6289__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATA6289__" +#endif + +#ifdef __AVR_ATmega103__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega103__" +#endif + +#ifdef __AVR_ATmega1280__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega1280__" +#endif + +#ifdef __AVR_ATmega1281__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega1281__" +#endif + +#ifdef __AVR_ATmega1284P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega1284P__" +#endif + +#ifdef __AVR_ATmega128RFA1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega128RFA1__" +#endif + +#ifdef __AVR_ATmega128__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega128__" +#endif + +#ifdef __AVR_ATmega161__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega161__" +#endif + +#ifdef __AVR_ATmega162__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega162__" +#endif + +#ifdef __AVR_ATmega163__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega163__" +#endif + +#ifdef __AVR_ATmega164A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega164A__" +#endif + +#ifdef __AVR_ATmega164P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega164P__" +#endif + +#ifdef __AVR_ATmega164__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega164__" +#endif + +#ifdef __AVR_ATmega165A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega165A__" +#endif + +#ifdef __AVR_ATmega165P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega165P__" +#endif + +#ifdef __AVR_ATmega165__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega165__" +#endif + +#ifdef __AVR_ATmega168A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega168A__" +#endif + +#ifdef __AVR_ATmega168P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega168P__" +#endif + +#ifdef __AVR_ATmega168__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega168__" +#endif + +#ifdef __AVR_ATmega169A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169A__" +#endif + +#ifdef __AVR_ATmega169PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169PA__" +#endif + +#ifdef __AVR_ATmega169P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169P__" +#endif + +#ifdef __AVR_ATmega169__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169__" +#endif + +#ifdef __AVR_ATmega16A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16A__" +#endif + +#ifdef __AVR_ATmega16HVA2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVA2__" +#endif + +#ifdef __AVR_ATmega16HVA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVA__" +#endif + +#ifdef __AVR_ATmega16HVBREVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVBREVB__" +#endif + +#ifdef __AVR_ATmega16HVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVB__" +#endif + +#ifdef __AVR_ATmega16M1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16M1__" +#endif + +#ifdef __AVR_ATmega16U2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16U2__" +#endif + +#ifdef __AVR_ATmega16U4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16U4__" +#endif + +#ifdef __AVR_ATmega16__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16__" +#endif + +#ifdef __AVR_ATmega2560__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega2560__" +#endif + +#ifdef __AVR_ATmega2561__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega2561__" +#endif + +#ifdef __AVR_ATmega323__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega323__" +#endif + +#ifdef __AVR_ATmega324A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega324A__" +#endif + +#ifdef __AVR_ATmega324PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega324PA__" +#endif + +#ifdef __AVR_ATmega324P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega324P__" +#endif + +#ifdef __AVR_ATmega3250A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3250A__" +#endif + +#ifdef __AVR_ATmega3250P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3250P__" +#endif + +#ifdef __AVR_ATmega3250__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3250__" +#endif + +#ifdef __AVR_ATmega325A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega325A__" +#endif + +#ifdef __AVR_ATmega325P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega325P__" +#endif + +#ifdef __AVR_ATmega325__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega325__" +#endif + +#ifdef __AVR_ATmega328P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega328P__" +#endif + +#ifdef __AVR_ATmega328__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega328__" +#endif + +#ifdef __AVR_ATmega3290A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3290A__" +#endif + +#ifdef __AVR_ATmega3290P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3290P__" +#endif + +#ifdef __AVR_ATmega3290__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3290__" +#endif + +#ifdef __AVR_ATmega329A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329A__" +#endif + +#ifdef __AVR_ATmega329PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329PA__" +#endif + +#ifdef __AVR_ATmega329P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329P__" +#endif + +#ifdef __AVR_ATmega329__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329__" +#endif + +#ifdef __AVR_ATmega32C1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32C1__" +#endif + +#ifdef __AVR_ATmega32HVBREVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32HVBREVB__" +#endif + +#ifdef __AVR_ATmega32HVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32HVB__" +#endif + +#ifdef __AVR_ATmega32M1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32M1__" +#endif + +#ifdef __AVR_ATmega32U2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32U2__" +#endif + +#ifdef __AVR_ATmega32U4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32U4__" +#endif + +#ifdef __AVR_ATmega32U6__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32U6__" +#endif + +#ifdef __AVR_ATmega32__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32__" +#endif + +#ifdef __AVR_ATmega406__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega406__" +#endif + +#ifdef __AVR_ATmega48A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega48A__" +#endif + +#ifdef __AVR_ATmega48P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega48P__" +#endif + +#ifdef __AVR_ATmega48__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega48__" +#endif + +#ifdef __AVR_ATmega640__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega640__" +#endif + +#ifdef __AVR_ATmega644A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644A__" +#endif + +#ifdef __AVR_ATmega644PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644PA__" +#endif + +#ifdef __AVR_ATmega644P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644P__" +#endif + +#ifdef __AVR_ATmega644__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644__" +#endif + +#ifdef __AVR_ATmega6450A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6450A__" +#endif + +#ifdef __AVR_ATmega6450P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6450P__" +#endif + +#ifdef __AVR_ATmega6450__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6450__" +#endif + +#ifdef __AVR_ATmega645A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega645A__" +#endif + +#ifdef __AVR_ATmega645P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega645P__" +#endif + +#ifdef __AVR_ATmega645__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega645__" +#endif + +#ifdef __AVR_ATmega6490A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6490A__" +#endif + +#ifdef __AVR_ATmega6490P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6490P__" +#endif + +#ifdef __AVR_ATmega6490__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6490__" +#endif + +#ifdef __AVR_ATmega649A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega649A__" +#endif + +#ifdef __AVR_ATmega649P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega649P__" +#endif + +#ifdef __AVR_ATmega649__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega649__" +#endif + +#ifdef __AVR_ATmega64C1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64C1__" +#endif + +#ifdef __AVR_ATmega64HVE__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64HVE__" +#endif + +#ifdef __AVR_ATmega64M1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64M1__" +#endif + +#ifdef __AVR_ATmega64__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64__" +#endif + +#ifdef __AVR_ATmega8515__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8515__" +#endif + +#ifdef __AVR_ATmega8535__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8535__" +#endif + +#ifdef __AVR_ATmega88A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88A__" +#endif + +#ifdef __AVR_ATmega88PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88PA__" +#endif + +#ifdef __AVR_ATmega88P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88P__" +#endif + +#ifdef __AVR_ATmega88__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88__" +#endif + +#ifdef __AVR_ATmega8HVA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8HVA__" +#endif + +#ifdef __AVR_ATmega8U2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8U2__" +#endif + +#ifdef __AVR_ATmega8__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8__" +#endif + +#ifdef __AVR_ATtiny10__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny10__" +#endif + +#ifdef __AVR_ATtiny11__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny11__" +#endif + +#ifdef __AVR_ATtiny12__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny12__" +#endif + +#ifdef __AVR_ATtiny13A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny13A__" +#endif + +#ifdef __AVR_ATtiny13__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny13__" +#endif + +#ifdef __AVR_ATtiny15__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny15__" +#endif + +#ifdef __AVR_ATtiny167__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny167__" +#endif + +#ifdef __AVR_ATtiny20__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny20__" +#endif + +#ifdef __AVR_ATtiny22__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny22__" +#endif + +#ifdef __AVR_ATtiny2313A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny2313A__" +#endif + +#ifdef __AVR_ATtiny2313__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny2313__" +#endif + +#ifdef __AVR_ATtiny24A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny24A__" +#endif + +#ifdef __AVR_ATtiny24__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny24__" +#endif + +#ifdef __AVR_ATtiny25__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny25__" +#endif + +#ifdef __AVR_ATtiny261A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny261A__" +#endif + +#ifdef __AVR_ATtiny261__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny261__" +#endif + +#ifdef __AVR_ATtiny26__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny26__" +#endif + +#ifdef __AVR_ATtiny28__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny28__" +#endif + +#ifdef __AVR_ATtiny40__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny40__" +#endif + +#ifdef __AVR_ATtiny4313__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny4313__" +#endif + +#ifdef __AVR_ATtiny43U__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny43U__" +#endif + +#ifdef __AVR_ATtiny44A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny44A__" +#endif + +#ifdef __AVR_ATtiny44__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny44__" +#endif + +#ifdef __AVR_ATtiny45__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny45__" +#endif + +#ifdef __AVR_ATtiny461A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny461A__" +#endif + +#ifdef __AVR_ATtiny461__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny461__" +#endif + +#ifdef __AVR_ATtiny48__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny48__" +#endif + +#ifdef __AVR_ATtiny4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny4__" +#endif + +#ifdef __AVR_ATtiny5__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny5__" +#endif + +#ifdef __AVR_ATtiny84A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny84A__" +#endif + +#ifdef __AVR_ATtiny84__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny84__" +#endif + +#ifdef __AVR_ATtiny85__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny85__" +#endif + +#ifdef __AVR_ATtiny861A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny861A__" +#endif + +#ifdef __AVR_ATtiny861__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny861__" +#endif + +#ifdef __AVR_ATtiny87__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny87__" +#endif + +#ifdef __AVR_ATtiny88__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny88__" +#endif + +#ifdef __AVR_ATtiny9__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny9__" +#endif + +#ifdef __AVR_ATxmega128A1U__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128A1U__" +#endif + +#ifdef __AVR_ATxmega128A1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128A1__" +#endif + +#ifdef __AVR_ATxmega128A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128A3__" +#endif + +#ifdef __AVR_ATxmega128D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128D3__" +#endif + +#ifdef __AVR_ATxmega16A4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega16A4__" +#endif + +#ifdef __AVR_ATxmega16D4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega16D4__" +#endif + +#ifdef __AVR_ATxmega192A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega192A3__" +#endif + +#ifdef __AVR_ATxmega192D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega192D3__" +#endif + +#ifdef __AVR_ATxmega256A3B__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega256A3B__" +#endif + +#ifdef __AVR_ATxmega256A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega256A3__" +#endif + +#ifdef __AVR_ATxmega256D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega256D3__" +#endif + +#ifdef __AVR_ATxmega32A4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega32A4__" +#endif + +#ifdef __AVR_ATxmega32D4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega32D4__" +#endif + +#ifdef __AVR_ATxmega64A1U__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64A1U__" +#endif + +#ifdef __AVR_ATxmega64A1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64A1__" +#endif + +#ifdef __AVR_ATxmega64A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64A3__" +#endif + +#ifdef __AVR_ATxmega64D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64D3__" +#endif \ No newline at end of file From 5739ee49ae996cd25e3b9ee1cea9ad304d6f5959 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:19:49 +0100 Subject: [PATCH 125/344] new classes:Watchdog,Define,Register,ArduinoCore,ArduinoPin, pwm --- firmware/Nanpy/ArduinoCoreClass.cpp | 67 ++++++++ firmware/Nanpy/ArduinoCoreClass.h | 14 ++ firmware/Nanpy/DefineClass.cpp | 99 +++++++++++ firmware/Nanpy/DefineClass.h | 14 ++ firmware/Nanpy/Nanpy.ino | 38 +++-- firmware/Nanpy/RegisterClass.cpp | 106 ++++++++++++ firmware/Nanpy/RegisterClass.h | 13 ++ firmware/Nanpy/WatchdogClass.cpp | 27 +++ firmware/Nanpy/WatchdogClass.h | 14 ++ firmware/Nanpy/intdefs.h | 17 ++ nanpy/arduinocore.py | 74 +++++++++ nanpy/arduinopin.py | 178 ++++++++++++++++++++ nanpy/define.py | 40 +++++ nanpy/pwm.py | 244 ++++++++++++++++++++++++++++ nanpy/resgister.py | 85 ++++++++++ nanpy/watchdog.py | 36 ++++ 16 files changed, 1055 insertions(+), 11 deletions(-) create mode 100644 firmware/Nanpy/ArduinoCoreClass.cpp create mode 100644 firmware/Nanpy/ArduinoCoreClass.h create mode 100644 firmware/Nanpy/DefineClass.cpp create mode 100644 firmware/Nanpy/DefineClass.h create mode 100644 firmware/Nanpy/RegisterClass.cpp create mode 100644 firmware/Nanpy/RegisterClass.h create mode 100644 firmware/Nanpy/WatchdogClass.cpp create mode 100644 firmware/Nanpy/WatchdogClass.h create mode 100644 firmware/Nanpy/intdefs.h create mode 100644 nanpy/arduinocore.py create mode 100644 nanpy/arduinopin.py create mode 100644 nanpy/define.py create mode 100644 nanpy/pwm.py create mode 100644 nanpy/resgister.py create mode 100644 nanpy/watchdog.py diff --git a/firmware/Nanpy/ArduinoCoreClass.cpp b/firmware/Nanpy/ArduinoCoreClass.cpp new file mode 100644 index 0000000..600b504 --- /dev/null +++ b/firmware/Nanpy/ArduinoCoreClass.cpp @@ -0,0 +1,67 @@ +#include +#include "ArduinoCoreClass.h" +#include + +#define RETURN_GLOBAL_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x()); } +#define RETURN_PIN_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x(m->getInt(0))); } +#define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(*x(m->getInt(0))); } + +int totalPinCount() +{ + // HACK! + for (int i = 0; i < 100; i++) + { + byte x = digitalPinToBitMask(i); + bool ok = false; + for (int j = 0; j < 8; j++) + { + if (x == (1 << j)) + { + ok = true; + break; + } + } + + if (!ok) + { + return i; + } + } + return -1; +} + +// http://code.google.com/p/tinkerit/wiki/SecretVoltmeter +long readVcc() +{ + long result; + // Read 1.1V reference against AVcc + ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); + delay(2); // Wait for Vref to settle + ADCSRA |= _BV(ADSC); // Convert + while (bit_is_set(ADCSRA, ADSC)) + ; + result = ADCL; + result |= ADCH << 8; + result = 1126400L / result; // Back-calculate AVcc in mV + return result; +} + + +void nanpy::ArduinoCoreClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getClass(), "ArduinoCore") == 0) + { + RETURN_PIN_FUNC(digitalPinToBitMask); + RETURN_PIN_FUNC(digitalPinToPort); + RETURN_PIN_FUNC(digitalPinToTimer); + RETURN_PIN_FUNC(analogInPinToBit); + + RETURN_PORT_FUNC(portModeRegister); + RETURN_PORT_FUNC(portOutputRegister); + RETURN_PORT_FUNC(portInputRegister); + + RETURN_GLOBAL_FUNC(totalPinCount); + RETURN_GLOBAL_FUNC(readVcc); + } +} + diff --git a/firmware/Nanpy/ArduinoCoreClass.h b/firmware/Nanpy/ArduinoCoreClass.h new file mode 100644 index 0000000..cb5e936 --- /dev/null +++ b/firmware/Nanpy/ArduinoCoreClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class ArduinoCoreClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + + }; +}; + diff --git a/firmware/Nanpy/DefineClass.cpp b/firmware/Nanpy/DefineClass.cpp new file mode 100644 index 0000000..21b6e4f --- /dev/null +++ b/firmware/Nanpy/DefineClass.cpp @@ -0,0 +1,99 @@ +#include +#include "DefineClass.h" +#include +#include "generated_mcu.h" + +// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html + +// example: +// char string_A0[] PROGMEM = "A0"; +#define DEFINE(x) const char string_##x[] PROGMEM = #x; +#include "intdefs.h" +#undef DEFINE + +const char * const name_table[] PROGMEM = +{ +// example: +// string_A0, +#define DEFINE(x) string_##x, +#include "intdefs.h" +#undef DEFINE +}; + +const int32_t value_table[] PROGMEM = +{ +// example: +// A0, +#define DEFINE(x) x, +#include "intdefs.h" +#undef DEFINE +}; + +#define LONGEST_STRING_IN_INTDEFS_H 21 + +#define COUNT_INT_DEFS sizeof(name_table)/sizeof(name_table[0]) + +#define COUNT_STR_DEFS 4 +// __TIME__, __DATE__, __VERSION__, MCU + +void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getClass(), "Define") == 0) + { + if (strcmp(m->getName(), "count") == 0) + { + m->returns(COUNT_INT_DEFS + COUNT_STR_DEFS); + } + if (strcmp(m->getName(), "name") == 0) + { + int index = m->getInt(0); + switch (index) + { + case 0: + m->returns("__TIME__"); + break; + case 1: + m->returns("__DATE__"); + break; + case 2: + m->returns("__VERSION__"); + break; + case 3: + m->returns("MCU"); + break; + + default: + index -= COUNT_STR_DEFS; + char buffer[LONGEST_STRING_IN_INTDEFS_H]; + strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); + m->returns(buffer); + } + } + if (strcmp(m->getName(), "value") == 0) + { + int index = m->getInt(0); + switch (index) + { + case 0: + m->returns(__TIME__); + break; + case 1: + m->returns(__DATE__); + break; + case 2: + m->returns(__VERSION__); + break; + case 3: + m->returns(MCU); + break; + + default: + index -= COUNT_STR_DEFS; + int32_t value = pgm_read_dword(&(value_table[index])); + m->returns(value); + } + } + + } +} +; diff --git a/firmware/Nanpy/DefineClass.h b/firmware/Nanpy/DefineClass.h new file mode 100644 index 0000000..0327fe8 --- /dev/null +++ b/firmware/Nanpy/DefineClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class DefineClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + + }; +}; + diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index 88e4c66..e273b83 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -19,21 +19,38 @@ #include "ComChannel.h" #include "EEPROMClass.h" +#include "DefineClass.h" +#include "ArduinoCoreClass.h" +#include "WatchdogClass.h" +#include "RegisterClass.h" + +#include + using namespace nanpy; MethodDescriptor *m = NULL; void setup() { - - REGISTER_CLASS(nanpy::EEPROMClass); - REGISTER_CLASS(ArduinoClass); - REGISTER_CLASS(LiquidCrystalClass); - REGISTER_CLASS(OneWireClass); - REGISTER_CLASS(DallasTemperatureClass); - REGISTER_CLASS(StepperClass); - REGISTER_CLASS(ServoClass); - REGISTER_CLASS(ToneClass); - REGISTER_CLASS(CapacitiveSensorClass); + + // disable watchdog (http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html) + MCUSR = 0; + wdt_disable(); + + REGISTER_CLASS(nanpy::EEPROMClass); // 0.3 k + REGISTER_CLASS(ArduinoClass); // 0.8 k + REGISTER_CLASS(LiquidCrystalClass); // 2.3 k + REGISTER_CLASS(OneWireClass); // 1.7 k + REGISTER_CLASS(DallasTemperatureClass); // 6.1 k + REGISTER_CLASS(StepperClass); // 0.8 k + REGISTER_CLASS(ServoClass); // 2.5 k + REGISTER_CLASS(ToneClass); // 2.2 k + REGISTER_CLASS(CapacitiveSensorClass); // 2.2 k + + // new classes + //REGISTER_CLASS(DefineClass); // 0.6 k + //REGISTER_CLASS(ArduinoCoreClass); // 0.7 k + //REGISTER_CLASS(WatchdogClass); // 0.2 k + //REGISTER_CLASS(RegisterClass); // 1.5 k ComChannel::connect(); } @@ -44,4 +61,3 @@ void loop() { Register::elaborate(m); } } - diff --git a/firmware/Nanpy/RegisterClass.cpp b/firmware/Nanpy/RegisterClass.cpp new file mode 100644 index 0000000..5035ce0 --- /dev/null +++ b/firmware/Nanpy/RegisterClass.cpp @@ -0,0 +1,106 @@ +#include +#include "RegisterClass.h" +#include + +// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html + +#define MISSING(x) + +// example: +// char string_OCR2A[] PROGMEM = "OCR2A"; +#define DEFINE(x) const char string_##x[] PROGMEM = #x; +#include "generated_avr_registers.h" +#undef DEFINE + +const char * const name_table[] PROGMEM = +{ +// example: +// string_OCR2A, +#define DEFINE(x) string_##x, +#include "generated_avr_registers.h" +#undef DEFINE +}; + +#define DEFINE(x) (uint16_t)(&x), +const uint16_t reg_list[] PROGMEM = +{ +#include "generated_avr_registers.h" +}; +#undef DEFINE + +#define DEFINE(x) sizeof(x), +const uint16_t sizeof_list[] PROGMEM = +{ +#include "generated_avr_registers.h" +}; +#undef DEFINE + +const int REG_COUNT = sizeof(sizeof_list) / sizeof(sizeof_list[0]); + +#define LONGEST_REGISTER_NAME 21 + +void nanpy::RegisterClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getClass(), "_Registers") == 0) + { + if (strcmp(m->getName(), "count") == 0) + { + m->returns(REG_COUNT); + } + else if (strcmp(m->getName(), "name") == 0) + { + word regindex = m->getInt(0); + char buffer[LONGEST_REGISTER_NAME]; + strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[regindex]))); + m->returns(buffer); + } + else + { + word regindex = m->getInt(0); + word regvalue = m->getInt(1); + + word regaddr = pgm_read_word(®_list[regindex]); + byte regsize = pgm_read_byte(&sizeof_list[regindex]); + + volatile byte* preg8 = (volatile byte*) regaddr; + volatile word* preg16 = (volatile word*) regaddr; + + if (strcmp(m->getName(), "read") == 0) + { + switch (regsize) + { + case 1: + m->returns(*preg8); + break; + case 2: + m->returns(*preg16); + break; + } + } + else if (strcmp(m->getName(), "write") == 0) + { + switch (regsize) + { + case 1: + *preg8 = (byte) regvalue; + break; + case 2: + *preg16 = regvalue; + break; + } + m->returns(0); + } + else if (strcmp(m->getName(), "address") == 0) + { + m->returns(regaddr); + } + else if (strcmp(m->getName(), "size") == 0) + { + m->returns(regsize); + } + + } + } +} +; + diff --git a/firmware/Nanpy/RegisterClass.h b/firmware/Nanpy/RegisterClass.h new file mode 100644 index 0000000..a31fb1e --- /dev/null +++ b/firmware/Nanpy/RegisterClass.h @@ -0,0 +1,13 @@ +#pragma once +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class RegisterClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + + }; +}; + diff --git a/firmware/Nanpy/WatchdogClass.cpp b/firmware/Nanpy/WatchdogClass.cpp new file mode 100644 index 0000000..f277ab6 --- /dev/null +++ b/firmware/Nanpy/WatchdogClass.cpp @@ -0,0 +1,27 @@ +#include +#include "WatchdogClass.h" +#include +#include + +void nanpy::WatchdogClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getClass(), "Watchdog") == 0) + { + if (strcmp(m->getName(), "wdt_reset") == 0) + { + wdt_reset(); + m->returns(0); + } + if (strcmp(m->getName(), "wdt_enable") == 0) + { + wdt_enable(m->getInt(0)); + m->returns(0); + } + if (strcmp(m->getName(), "wdt_disable") == 0) + { + wdt_disable(); + m->returns(0); + } + } +} +; diff --git a/firmware/Nanpy/WatchdogClass.h b/firmware/Nanpy/WatchdogClass.h new file mode 100644 index 0000000..cc1b5e2 --- /dev/null +++ b/firmware/Nanpy/WatchdogClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class WatchdogClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + + }; +}; + diff --git a/firmware/Nanpy/intdefs.h b/firmware/Nanpy/intdefs.h new file mode 100644 index 0000000..a97a6f1 --- /dev/null +++ b/firmware/Nanpy/intdefs.h @@ -0,0 +1,17 @@ + + +DEFINE(RAMEND) +DEFINE(XRAMEND) +DEFINE(E2END) +DEFINE(FLASHEND) +DEFINE(SPM_PAGESIZE) +DEFINE(E2PAGESIZE) +DEFINE(F_CPU) +DEFINE(ARDUINO) +DEFINE(SS) +DEFINE(MOSI) +DEFINE(MISO) +DEFINE(SCK) +DEFINE(A0) +DEFINE(__AVR_LIBC_DATE_) +DEFINE(__AVR_LIBC_VERSION__) diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py new file mode 100644 index 0000000..6018c94 --- /dev/null +++ b/nanpy/arduinocore.py @@ -0,0 +1,74 @@ +from nanpy.arduinoboard import arduinoclassmethod, returns +from nanpy.define import Define +from nanpy.memo import memoized + + +class ArduinoCore(object): + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def digitalPinToBitMask(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def digitalPinToPort(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def portModeRegister(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def digitalPinToTimer(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def analogInPinToBit(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def portOutputRegister(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def portInputRegister(cls, pin): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def totalPinCount(cls): + pass + + @classmethod + @returns(lambda x: int(x) / 1000.0) + @arduinoclassmethod + def readVcc(cls): + """VCC in Volt.""" + + @classmethod + def model(cls): + """""" + s = Define.asDict().get('MCU') + return s.strip('_').split('_')[-1] diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py new file mode 100644 index 0000000..758f04d --- /dev/null +++ b/nanpy/arduinopin.py @@ -0,0 +1,178 @@ +from nanpy.arduino import Arduino +from nanpy.arduinoboard import arduinoclassmethod +from nanpy.arduinoboard import returns +from nanpy.arduinocore import ArduinoCore +from nanpy.define import Define +from nanpy.memo import memoized +from nanpy.pwm import ArduinoPwmPin +import sys + +HIGH = Arduino.HIGH +LOW = Arduino.LOW +INPUT = Arduino.INPUT +OUTPUT = Arduino.OUTPUT + +# from six +PY3 = sys.version_info[0] == 3 +if PY3: + string_types = str, +else: + string_types = basestring, + + +def name2int(pin_name, A0): + try: + if isinstance(pin_name, string_types): + if pin_name[0] == 'D': + nr = int(pin_name[1:]) + if nr >= A0: + raise ValueError('invalid pin id:%r' % pin_name) + elif pin_name[0] == 'A': + nr = int(pin_name[1:]) + A0 + else: + nr = int(pin_name) + else: + nr = int(pin_name) + except IndexError: + raise ValueError('invalid pin id:%r' % pin_name) + return nr + + +class ArduinoPin(object): + + @classmethod + @memoized + def count_analog(cls): + return len(cls.analog_names()) + + @classmethod + @memoized + def count_digital(cls): + return len(cls.digital_names()) + + @classmethod + @memoized + def count(cls): + return cls.count_analog() + cls.count_digital() + + @classmethod + @memoized + def digital_names(cls): + A0 = Define.asDict()['A0'] + return ['D%s' % x for x in range(0, A0)] + + @classmethod + @memoized + def analog_names(cls): + A0 = Define.asDict()['A0'] + return ( + ['A%s' % (x - A0) for x in range(A0, ArduinoCore.totalPinCount())] + ) + + def __init__(self, name): + self.A0 = Define.asDict()['A0'] + self.nr = name2int(name, self.A0) + if self.nr >= ArduinoCore.totalPinCount(): + raise ValueError('pin %s (Nr:%s) not in range' % + (name, self.nr)) + + @property + @memoized + def pwm(self): + return ArduinoPwmPin(self.nr) + + @property + def is_digital(self): + return self.nr < self.A0 + + @property + def is_analog(self): + return not self.is_digital + + @property + def avr_port(self): + x = ArduinoCore.digitalPinToPort(self.nr) + return chr(ord('A') + x - 1) + + @property + def avr_bit(self): + bitmask = ArduinoCore.digitalPinToBitMask(self.nr) + i = 0 + while bitmask != 1: + bitmask >>= 1 + i += 1 + return i + + @property + def avr_pin(self): + return 'P%s%s' % (self.avr_port, self.avr_bit) + + @property + def name(self): + if self.is_digital: + return 'D%s' % self.nr + else: + return 'A%s' % self.nr_analog + + @property + def nr_analog(self): + x = self.nr - self.A0 + if x >= 0: + return x + + @property + def programming_function(self): + d = Define.asDict() + if self.nr == d['MISO']: + return 'MISO' + if self.nr == d['MOSI']: + return 'MOSI' + if self.nr == d['SCK']: + return 'SCK' + if self.nr == d['SS']: + return 'SS' + + def reset(self): + self.write_mode(INPUT) + self.write_pullup(LOW) + if self.pwm.available: + self.pwm.reset() + + def write_pullup(self, value): + self.write_mode(INPUT) + return self.write_digital_value(value) + + def read_digital_value(self, direction=None): + if direction is not None: + self.write_mode(direction) + return Arduino.digitalRead(self.nr) + + def write_digital_value(self, value, direction=None): + if direction == INPUT: + raise ValueError('write_digital_value() to INPUT??') + if direction is not None: + self.write_mode(direction) + value = 1 if value else 0 + return Arduino.digitalWrite(self.nr, value) + + digital_value = property(read_digital_value, write_digital_value) + + def read_analog_value(self): + if not self.is_analog: + return None + return Arduino.analogRead(self.nr) + analog_value = property(read_analog_value) + + def read_mode(self): + return Arduino.pinModeRead(self.nr) + + def write_mode(self, value): + return Arduino.pinMode(self.nr, value) + mode = property(read_mode, write_mode) + +# def read_pwm_value(self): +# return +# +# def write_pwm_value(self, value): +# return Arduino.analogWrite(self.nr, value) +# pwm_value = property(read_pwm_value, write_pwm_value) diff --git a/nanpy/define.py b/nanpy/define.py new file mode 100644 index 0000000..8124c10 --- /dev/null +++ b/nanpy/define.py @@ -0,0 +1,40 @@ +from nanpy.arduinoboard import arduinoclassmethod, returns +from nanpy.memo import memoized + + +def auto_convert(x): + try: + return int(x) + except ValueError: + return x + + +class Define(object): + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def count(cls): + pass + + @classmethod + @memoized + @arduinoclassmethod + def name(cls, index): + pass + + @classmethod + @memoized + @returns(auto_convert) + @arduinoclassmethod + def value(cls, index): + pass + + @classmethod + @memoized + def asDict(cls): + d = dict() + for i in range(cls.count()): + d[cls.name(i)] = cls.value(i) + return d diff --git a/nanpy/pwm.py b/nanpy/pwm.py new file mode 100644 index 0000000..16a7f02 --- /dev/null +++ b/nanpy/pwm.py @@ -0,0 +1,244 @@ +from __future__ import division +from nanpy.memo import memoized +from nanpy.arduino import Arduino +from nanpy.arduinocore import ArduinoCore +from nanpy.define import Define +from nanpy.resgister import Register +import logging + +log = logging.getLogger(__name__) + + +class PwmError(Exception): + pass + + +class BiDict(): + + def __init__(self, dic): + self.norm = dic + self.inv = dict([(v, k) for k, v in dic.items()]) + +base_divisor = { + 3: 512, + 5: 256, + 6: 256, + 9: 512, + 10: 512, + 11: 512, +} + + +_div1 = BiDict({ + # 0: None, + 1: 1, + 2: 8, + 3: 64, + 4: 256, + 5: 1024, + # 6: None, + # 7: None, + }) +_div2 = BiDict({ + # 0: None, + 1: 1, + 2: 8, + 3: 32, + 4: 64, + 5: 128, + 6: 256, + 7: 1024, + }) +divisor_mapping = { + 3: _div2, + 5: _div1, + 6: _div1, + 9: _div1, + 10: _div1, + 11: _div2, +} + +TIMERS_A = ['NOT_ON_TIMER', + 'TCCR0A', + 'TCCR0A', + 'TCCR1A', + 'TCCR1A', + None, # TODO: atmega8 + 'TCCR2A', + 'TCCR2A', + ] + +TIMERS_B = ['NOT_ON_TIMER', + 'TCCR0B', + 'TCCR0B', + 'TCCR1B', + 'TCCR1B', + 'TCCR2', + 'TCCR2B', + 'TCCR2B', + ] + +timer_mask = 7 # 0b111 + +# TODO: pwm_mode read/write +# TODO: read mappings + + +class ArduinoPwmPin(object): + DEFAULT_DIVISOR = 64 + + def __init__(self, nr): + self.nr = nr + self.F_CPU = Define().asDict().get('F_CPU') + + def reset(self): + if not self.available: + return + self.write_divisor(self.DEFAULT_DIVISOR) + + @property + def available(self): + timer_id = self._timer_id() + return timer_id > 0 and timer_id < len(TIMERS_B) +# return self.nr in timer_register + + def _check(self): + if not self.available: + raise PwmError('pwm not available for pin: %s' % self.nr) + + def write_value(self, value): + self._check() +# assert self.mcu.pins.read_mode(self.nr) == OUTPUT + Arduino.analogWrite(self.nr, value) + + @property + def divisors_available(self): + try: + return list(divisor_mapping[self.nr].norm.values()) + except KeyError: + return [] + + def read_divisor(self): + self._check() + d = divisor_mapping[self.nr] + return d.norm[self.read_timer_mode()] + + def write_divisor(self, value): + self._check() + d = divisor_mapping[self.nr] + self.write_timer_mode(d.inv[value]) + divisor = property(read_divisor, write_divisor) + + def _timer_id(self): + return ArduinoCore.digitalPinToTimer(self.nr) + + def _timer_register_name(self, variant='B'): + self._check() + i = self._timer_id() + return dict(A=TIMERS_A, B=TIMERS_B)[variant][i] + + @property + def timer_register_name_a(self): + return self._timer_register_name(variant='A') + + @property + def timer_register_name_b(self): + return self._timer_register_name(variant='B') + + def read_timer_mode(self): + reg_name = self.timer_register_name_b + return Register(reg_name).read_value() & timer_mask + + def write_timer_mode(self, value): + assert value <= 7 + reg_name = self.timer_register_name_b + reg = Register(reg_name) + old = reg.value & ~timer_mask + reg.value = (old | value) + + timer_mode = property(read_timer_mode, write_timer_mode) + + @property + def base_divisor(self): + self._check() + return base_divisor[self.nr] + + def calculate_frequency(self, divisor): + return 1.0 * self.F_CPU / self.base_divisor / divisor + + @property + def frequencies_available(self): + ls = sorted([self.calculate_frequency(x) + for x in self.divisors_available]) + return ls + + def read_frequency(self): + self._check() + wgm = self.read_wgm() + if wgm == 14: + # high freq mode + return self.F_CPU / Register('ICR1').value + else: + return self.calculate_frequency(self.read_divisor()) + + def write_frequency(self, value): + self._check() + d = divisor_mapping[self.nr] + for x in self.divisors_available: + f = self.calculate_frequency(x) + if abs(f - value) <= 1: + self.write_timer_mode(d.inv[x]) + return + frequency = property(read_frequency, write_frequency) + + def read_wgm(self): + """Waveform generation mode.""" + self._check() + rega = self.timer_register_name_a + regb = self.timer_register_name_b + if regb == 'TCCR1B': + maskb = 24 # 0b00011000 + else: + maskb = 8 # 0b00001000 + maska = 3 # 0b00000011 + a = Register(rega).value & maska + b = Register(regb).value & maskb + return a + (b >> 1) + + wgm = property(read_wgm, None) + + def _check_high_freq(self): + # TODO: read config + if self.nr not in [9, 10]: + raise PwmError('high freq pwm not available for pin: %s' % self.nr) + + def set_high_freq_around_pwm(self, top, fill): + 'F_CPU/divisor' + # TODO: + d = top + self._check_high_freq() + assert d >= 2 + + self.write_divisor(1) + self.write_value(128) + + TCCR1A = Register('TCCR1A') + TCCR1B = Register('TCCR1B') + TCNT1 = Register('TCNT1') + ICR1 = Register('ICR1') + OCR1A = Register('OCR1A') + OCR1B = Register('OCR1B') + + TCCR1A.value = 2 + \ + (240 & TCCR1A.value) # 0b00000010 + (0b11110000 & reg.TCCR1A) + TCCR1B.value = 25 # 0b00011001 + + TCNT1.value = 0 + ICR1.value = d + OCR1A.value = fill + OCR1B.value = fill + + def set_high_freq_around(self, freq): + top = int(self.F_CPU / freq + 0.5) + assert 1 < top < (1 << 16) + self.set_high_freq_around_pwm(top, int(top / 2)) diff --git a/nanpy/resgister.py b/nanpy/resgister.py new file mode 100644 index 0000000..fcfd292 --- /dev/null +++ b/nanpy/resgister.py @@ -0,0 +1,85 @@ +from nanpy.arduinoboard import arduinoclassmethod, returns +from nanpy.memo import memoized + + +class _Registers(object): + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def count(cls): + pass + + @classmethod + @returns(int) + @arduinoclassmethod + def read(cls, index): + pass + + @classmethod + @arduinoclassmethod + def write(cls, index, value): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def address(cls, index): + pass + + @classmethod + @memoized + @returns(int) + @arduinoclassmethod + def size(cls, index): + pass + + @classmethod + @memoized + @arduinoclassmethod + def name(cls, index): + pass + + @classmethod + @memoized + def name_index_dict(cls): + d = dict() + for i in range(cls.count()): + d[cls.name(i)] = i + return d + + +class Register(object): + + @classmethod + @memoized + def names(cls): + return sorted(_Registers.name_index_dict().keys()) + + def __init__(self, name): + try: + self.index = _Registers.name_index_dict()[name] + except KeyError: + raise ValueError('Unknown register: %s' % name) + + def read_value(self): + return _Registers.read(self.index) + + def write_value(self, value): + return _Registers.write(self.index, value) + + value = property(read_value, write_value) + + @property + def name(self): + return _Registers.name(self.index) + + @property + def address(self): + return _Registers.address(self.index) + + @property + def size(self): + return _Registers.size(self.index) diff --git a/nanpy/watchdog.py b/nanpy/watchdog.py new file mode 100644 index 0000000..ec11094 --- /dev/null +++ b/nanpy/watchdog.py @@ -0,0 +1,36 @@ +from nanpy.arduinoboard import arduinoclassmethod +import time + + +class Watchdog(object): + WDTO_15MS = 0 + WDTO_30MS = 1 + WDTO_60MS = 2 + WDTO_120MS = 3 + WDTO_250MS = 4 + WDTO_500MS = 5 + WDTO_1S = 6 + WDTO_2S = 7 + WDTO_4S = 8 + WDTO_8S = 9 + + @classmethod + @arduinoclassmethod + def wdt_reset(cls): + pass + + @classmethod + @arduinoclassmethod + def wdt_enable(cls, value): + pass + + @classmethod + @arduinoclassmethod + def wdt_disable(cls): + pass + + @classmethod + def soft_reset(cls): + '''http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset''' + cls.wdt_enable(cls.WDTO_15MS) + time.sleep(0.1) From 5486f7d3fca0a886cfa6d15a33a6b2ad0d45a916 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:20:56 +0100 Subject: [PATCH 126/344] tests --- tests/__init__.py | 0 tests/config.py | 7 ++ tests/test_arduino.py | 25 +++++++ tests/test_arduinocore.py | 26 ++++++++ tests/test_define.py | 28 ++++++++ tests/test_pin.py | 137 ++++++++++++++++++++++++++++++++++++++ tests/test_pwm.py | 76 +++++++++++++++++++++ tests/test_register.py | 44 ++++++++++++ tests/util.py | 30 +++++++++ tox.ini | 15 +++++ 10 files changed, 388 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/config.py create mode 100644 tests/test_arduino.py create mode 100644 tests/test_arduinocore.py create mode 100644 tests/test_define.py create mode 100644 tests/test_pin.py create mode 100644 tests/test_pwm.py create mode 100644 tests/test_register.py create mode 100644 tests/util.py create mode 100644 tox.ini diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/config.py b/tests/config.py new file mode 100644 index 0000000..6aed61c --- /dev/null +++ b/tests/config.py @@ -0,0 +1,7 @@ +config = dict( + A0=14, + ARDUINO=105, + F_CPU=20000000.0, + MCU='__AVR_ATmega328P__', + model='ATmega328P', +) diff --git a/tests/test_arduino.py b/tests/test_arduino.py new file mode 100644 index 0000000..2d6b7a9 --- /dev/null +++ b/tests/test_arduino.py @@ -0,0 +1,25 @@ +from config import config +from nanpy.arduino import Arduino +from nanpy.watchdog import Watchdog +from nose.tools import eq_, ok_ +from tests.util import ok_an + + +def setup(): + Watchdog.soft_reset() + +def teardown(): + pass + +def test(): + ok_(Arduino.millis()>1) + + ok_an(Arduino.analogRead(0)) + + + eq_(Arduino.pinModeRead(13), 0) + Arduino.pinMode(13,1) + eq_(Arduino.pinModeRead(13), 1) + Arduino.pinMode(13,0) + eq_(Arduino.pinModeRead(13), 0) + diff --git a/tests/test_arduinocore.py b/tests/test_arduinocore.py new file mode 100644 index 0000000..b9311a4 --- /dev/null +++ b/tests/test_arduinocore.py @@ -0,0 +1,26 @@ +from config import config +from nanpy.arduinocore import ArduinoCore +from nanpy.watchdog import Watchdog +from nose.tools import eq_, ok_ +from tests.util import ok_vcc + + +def setup(): + Watchdog.soft_reset() + +def teardown(): + pass + + +def test(): + eq_(ArduinoCore.digitalPinToBitMask(2), 4) + eq_(ArduinoCore.digitalPinToPort(2), 4) + eq_(ArduinoCore.portModeRegister(2), 0) + eq_(ArduinoCore.digitalPinToTimer(2), 0) + eq_(ArduinoCore.analogInPinToBit(2), 2) + + eq_(ArduinoCore.portOutputRegister(2), 0) + eq_(ArduinoCore.portInputRegister(2), 0) + eq_(ArduinoCore.totalPinCount(), 20) + ok_vcc(ArduinoCore.readVcc()) + eq_(ArduinoCore.model(), config['model']) diff --git a/tests/test_define.py b/tests/test_define.py new file mode 100644 index 0000000..68860f3 --- /dev/null +++ b/tests/test_define.py @@ -0,0 +1,28 @@ +from config import config +from nanpy.define import Define +from nanpy.watchdog import Watchdog +from nose.tools import eq_, ok_ +from util import exc_ + + +def setup(): + Watchdog.soft_reset() + +def teardown(): + pass + + +def test_defs(): + d = Define.asDict() + print (d) + eq_(d['A0'], config['A0']) + eq_(d['ARDUINO'], config['ARDUINO']) + eq_(d['F_CPU'], config['F_CPU']) + eq_(d['MCU'], config['MCU']) + ok_('xx' not in d) + ok_(len(d.keys()) > 15, len(d.keys())) + + for x in d: + assert x.strip(), 'empty define:-->%s<--' % x + + diff --git a/tests/test_pin.py b/tests/test_pin.py new file mode 100644 index 0000000..6a3008a --- /dev/null +++ b/tests/test_pin.py @@ -0,0 +1,137 @@ +from config import config +from nanpy.arduinopin import ArduinoPin +from nanpy.resgister import Register +from nanpy.watchdog import Watchdog +from nose.tools import eq_, ok_ +from tests.util import ok_an +from util import exc_ +import time + +def setup(): + Watchdog.soft_reset() + +def teardown(): + pass + +INPUT, OUTPUT = 0, 1 + +def test_pin_nr(): + pin = ArduinoPin(8) + + eq_(pin.nr, 8) + eq_(pin.nr_analog, None) + + pin = ArduinoPin(14) + eq_(pin.nr, 14) + eq_(pin.nr_analog, 0) + + pin = ArduinoPin('A1') + eq_(pin.nr, 15) + eq_(pin.nr_analog, 1) + + pin = ArduinoPin('D9') + eq_(pin.nr, 9) + eq_(pin.nr_analog, None) + + pin = ArduinoPin('A2') + eq_(pin.nr, 16) + eq_(pin.nr_analog, 2) + + +def test_is(): + eq_(ArduinoPin(8).is_digital, True) + eq_(ArduinoPin(8).is_analog, False) + eq_(ArduinoPin('A2').is_digital, False) + eq_(ArduinoPin('A2').is_analog, True) + + +def test_name(): + eq_(ArduinoPin(8).name, 'D8') + eq_(ArduinoPin('D8').name, 'D8') + eq_(ArduinoPin(15).name, 'A1') + eq_(ArduinoPin('A2').name, 'A2') + + +def test_dig(): + pin = ArduinoPin(8) + pin.reset() + + pin.write_mode(OUTPUT) + + pin.write_digital_value(1) + + + eq_(pin.read_digital_value(), 1) + eq_(pin.digital_value, 1) + + pin.write_mode(INPUT) + pin.write_mode(OUTPUT) + + pin.write_digital_value(0) + eq_(pin.read_digital_value(), 0) + eq_(pin.digital_value, 0) + + pin.write_mode(INPUT) + pin.write_mode(OUTPUT) + + pin.write_mode(INPUT) + pin.write_pullup(True) + + eq_(pin.read_digital_value(), 1) + eq_(pin.digital_value, 1) + + + + +def test_an(): + pin = ArduinoPin('A0') + pin.mode = INPUT + ok_an(pin.read_analog_value()) + ok_an(pin.analog_value) + + pin.write_pullup(True) + + ok_an(pin.read_analog_value(), pullup=True) + + +def test_mode(): + pin = ArduinoPin(8) + pin.reset() + + eq_(pin.mode, INPUT) + eq_(pin.read_mode(), INPUT) + eq_(Register('DDRB').value, 0) + + pin.write_mode(OUTPUT) + eq_(pin.mode, OUTPUT) + eq_(pin.read_mode(), OUTPUT) + eq_(Register('DDRB').value, 1) + + Register('DDRB').value = 0 + eq_(pin.mode, INPUT) + + pin.mode = OUTPUT + eq_(pin.mode, OUTPUT) + + pin.reset() + eq_(pin.mode, INPUT) + + +def test_pullup(): + pin = ArduinoPin(8) + pin.write_pullup(True) + + + +def test_pin_range(): + eq_(ArduinoPin.count(), 20) + eq_(ArduinoPin.count_analog(), 6) + eq_(ArduinoPin.count_digital(), 14) + +# eq_(ArduinoPin.range_all, range(0, 20)) +# eq_(ArduinoPin.range_analog, range(14, 20)) +# eq_(ArduinoPin.range_digital, range(0, 14)) + + ArduinoPin('A5') + exc_(ValueError, lambda: ArduinoPin('A6')) + exc_(ValueError, lambda: ArduinoPin('D14')) diff --git a/tests/test_pwm.py b/tests/test_pwm.py new file mode 100644 index 0000000..cabc5a0 --- /dev/null +++ b/tests/test_pwm.py @@ -0,0 +1,76 @@ +from config import config +from nanpy.arduinopin import ArduinoPin +from nanpy.resgister import Register +from nanpy.watchdog import Watchdog +from nose.tools import eq_ + + +def setup(): + Watchdog.soft_reset() + +def teardown(): + pass + +INPUT, OUTPUT = 0, 1 +F_CPU = config.get('F_CPU') + +def test_pwm(): + pin8 = ArduinoPin(8) + pin9 = ArduinoPin(9) + + TCCR1B = Register('TCCR1B') + + eq_(pin8.pwm.available, False) + eq_(pin9.pwm.available, True) + eq_(pin9.pwm.timer_register_name_b, 'TCCR1B') + eq_(pin9.pwm.base_divisor, 512) + eq_(pin9.pwm.divisors_available, [1, 8, 64, 256, 1024]) + + frequencies = [F_CPU / 2 ** 9, + F_CPU / 2 ** 12, + F_CPU / 2 ** 15, + F_CPU / 2 ** 17, + F_CPU / 2 ** 19, + ] + frequencies.sort() + eq_(pin9.pwm.frequencies_available, frequencies) + + TCCR1B.value = 3 + eq_(TCCR1B.value, 3) + + eq_(pin9.pwm.read_divisor(), 2 ** 6) + eq_(pin9.pwm.divisor, 2 ** 6) + eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 15) + eq_(pin9.pwm.frequency, F_CPU / 2 ** 15) + + pin9.pwm.write_frequency(int(F_CPU / 2 ** 19)) + eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 19) + eq_(TCCR1B.value, 5) + + TCCR1B.value = 2 + eq_(pin9.pwm.read_divisor(), 2 ** 3) + eq_(pin9.pwm.divisor, 2 ** 3) + eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 12) + eq_(pin9.pwm.frequency, F_CPU / 2 ** 12) + eq_(TCCR1B.value, 2) + + pin9.pwm.divisor = 2 ** 10 + eq_(pin9.pwm.read_divisor(), 2 ** 10) + eq_(pin9.pwm.divisor, 2 ** 10) + eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 19) + eq_(pin9.pwm.frequency, F_CPU / 2 ** 19) + eq_(TCCR1B.value, 5) + + pin9.pwm.write_frequency(F_CPU / 2 ** 9) + eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 9) + eq_(TCCR1B.value, 1) + + pin9.pwm.frequency = F_CPU / 2 ** 17 + eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 17) + eq_(TCCR1B.value, 4) + + TCCR1B.value = 3 + eq_(TCCR1B.value, 3) + + + pin9.pwm.write_value(45) diff --git a/tests/test_register.py b/tests/test_register.py new file mode 100644 index 0000000..0b68517 --- /dev/null +++ b/tests/test_register.py @@ -0,0 +1,44 @@ +from config import config +from nanpy.arduino import Arduino +from nanpy.arduinocore import ArduinoCore +from nanpy.resgister import Register +from nanpy.watchdog import Watchdog +from nose.tools import eq_, ok_, eq_, ok_ +from util import exc_ +import time + + + +def setup(): + Watchdog.soft_reset() + +def teardown(): + pass + + +def test_registers(): + print (Register.names()) + ok_(len(Register.names()) > 77) + + eq_(Register('DDRB').read_value(), 0) + eq_(Register('DDRB').value, 0) + exc_(ValueError, lambda x: Register('xxx').value, 0) + + Register('DDRB').write_value(5) + eq_(Register('DDRB').value, 5) + Register('DDRB').value = 3 + eq_(Register('DDRB').value, 3) + Register('DDRB').write_value(0) + + eq_(Register('DDRB').address, 0x24) + eq_(Register('DDRB').name, 'DDRB') + eq_(Register('DDRB').size, 1) + + + # 9 bit + eq_(Register('EEAR').size, 2) + Register('EEAR').value = 511 + eq_(Register('EEAR').value, 511) + + + diff --git a/tests/util.py b/tests/util.py new file mode 100644 index 0000000..e03fdbb --- /dev/null +++ b/tests/util.py @@ -0,0 +1,30 @@ +from nose.tools import ok_ + + +def exc_(excClass, callableObj, *args, **kwargs): + """Fail unless an exception of class excClass is thrown + by callableObj when invoked with arguments args and keyword + arguments kwargs. If a different type of exception is + thrown, it will not be caught, and the test case will be + deemed to have suffered an error, exactly as for an + unexpected exception. + """ + try: + callableObj(*args, **kwargs) + except excClass: + return + else: + if hasattr(excClass, '__name__'): + excName = excClass.__name__ + else: + excName = str(excClass) + raise Exception("%s not raised" % excName) + +def ok_an(x, pullup=False): + print (x) + ok_(x in range(1024)) + +def ok_vcc(vcc): + print ('vcc=', vcc) + ok_(vcc < 5.5) + ok_(vcc > 3) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2d0b09d --- /dev/null +++ b/tox.ini @@ -0,0 +1,15 @@ + +[tox] +envlist = py25,py26,py27,py31,py32,py33 + +[testenv] +deps= + nose + pyserial + +setenv= + PYTHONPATH= +changedir=tests + +commands=nosetests + From 52bae93df7f167a9b7245b068fdedb598644883f Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:28:47 +0100 Subject: [PATCH 127/344] activate new classes, deactivate DallasTemperatureClass --- firmware/Nanpy/Nanpy.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index e273b83..cba09d2 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -40,17 +40,17 @@ void setup() { REGISTER_CLASS(ArduinoClass); // 0.8 k REGISTER_CLASS(LiquidCrystalClass); // 2.3 k REGISTER_CLASS(OneWireClass); // 1.7 k - REGISTER_CLASS(DallasTemperatureClass); // 6.1 k +// REGISTER_CLASS(DallasTemperatureClass); // 6.1 k REGISTER_CLASS(StepperClass); // 0.8 k REGISTER_CLASS(ServoClass); // 2.5 k REGISTER_CLASS(ToneClass); // 2.2 k REGISTER_CLASS(CapacitiveSensorClass); // 2.2 k // new classes - //REGISTER_CLASS(DefineClass); // 0.6 k - //REGISTER_CLASS(ArduinoCoreClass); // 0.7 k - //REGISTER_CLASS(WatchdogClass); // 0.2 k - //REGISTER_CLASS(RegisterClass); // 1.5 k + REGISTER_CLASS(DefineClass); // 0.6 k + REGISTER_CLASS(ArduinoCoreClass); // 0.7 k + REGISTER_CLASS(WatchdogClass); // 0.2 k + REGISTER_CLASS(RegisterClass); // 1.5 k ComChannel::connect(); } From 8ffb50dd1d7eeda8cb4fd92190197b0f8eac56ad Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Dec 2013 20:37:56 +0100 Subject: [PATCH 128/344] new examples --- examples/dump.py | 79 +++++++++++++++++++++++++++++++++++++++++ examples/highfreqpwm.py | 17 +++++++++ examples/reset.py | 3 ++ 3 files changed, 99 insertions(+) create mode 100644 examples/dump.py create mode 100644 examples/highfreqpwm.py create mode 100755 examples/reset.py diff --git a/examples/dump.py b/examples/dump.py new file mode 100644 index 0000000..7686f5b --- /dev/null +++ b/examples/dump.py @@ -0,0 +1,79 @@ +from dicts.sorteddict import SortedDict +from entrypoint2 import entrypoint +from nanpy.arduino import Arduino +from nanpy.arduinocore import ArduinoCore +from nanpy.arduinopin import ArduinoPin +from nanpy.define import Define +from nanpy.resgister import Register +from nanpy.serialmanager import serial_manager +import inspect + +FORMAT = '%-20s = %20s' + + +def dump(obj, selected_names=None): + if selected_names: + ls = selected_names + else: + ls = dir(obj) + for attr in ls: + if not attr.startswith('__'): + if not inspect.ismethod(getattr(obj, attr)): + print FORMAT % (attr, getattr(obj, attr)) + + +def dump_dict(d): + for defname in sorted(d.keys()): + defvalue = d[defname] + print FORMAT % (defname, defvalue) + + +@entrypoint +def usbdump(): + serial_manager.connect('/dev/ttyS0') + + print FORMAT % ('totalPinCount', ArduinoCore.totalPinCount()) + print FORMAT % ('readVcc', ArduinoCore.readVcc()), 'V' + print FORMAT % ('millis', Arduino.millis() / 1000.0), 'sec' + + print + print '================================' + print 'pins:' + print '================================' + + print FORMAT % ('digital_names', ArduinoPin.digital_names()) + print FORMAT % ('analog_names', ArduinoPin.analog_names()) + + for nr in range(ArduinoCore.totalPinCount()): + print '---------- nr=%s ---------------' % nr + pin = ArduinoPin(nr) + dump( + pin, + 'name nr nr_analog is_digital is_analog avr_pin mode digital_value analog_value programming_function'.split()) + if pin.pwm.available: + print '--- pwm ---' + dump(pin.pwm, '''frequency frequencies_available base_divisor divisor divisors_available + timer_mode + timer_register_name_a + timer_register_name_b + wgm + '''.split()) + + print + print '================================' + print 'defines:' + print '================================' + dump_dict(Define.asDict()) + + print + print '================================' + print 'registers:' + print '================================' + for x in Register.names(): + r = Register(x) + if r.size == 2: + v = '0x%04X' % (r.value) + else: + v = ' 0x%02X' % (r.value) + + print '%-20s = %s @0x%2X (size:%s)' % (r.name, v, r.address, r.size) diff --git a/examples/highfreqpwm.py b/examples/highfreqpwm.py new file mode 100644 index 0000000..576caae --- /dev/null +++ b/examples/highfreqpwm.py @@ -0,0 +1,17 @@ +from nanpy.arduinopin import ArduinoPin + +FREQ = 10007 + + +def main(): + pin9 = ArduinoPin(9) + pin9.mode = 1 + pin9.write_digital_value(1) + pwm = pin9.pwm + print 'set frequency=%s Hz' % FREQ + pwm.set_high_freq_around(FREQ) + print 'real frequency=%s Hz' % pwm.read_frequency() + + +if __name__ == '__main__': + main() diff --git a/examples/reset.py b/examples/reset.py new file mode 100755 index 0000000..aa5967b --- /dev/null +++ b/examples/reset.py @@ -0,0 +1,3 @@ +from nanpy.watchdog import Watchdog + +Watchdog.soft_reset() From 6052c548b471adf8e0032241be0cd3286d0edbee Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 17 Dec 2013 21:18:31 +0100 Subject: [PATCH 129/344] Removed Makefile. Closes #2 --- README.md | 26 +-- firmware/Makefile | 1 - firmware/arduino.mk | 447 -------------------------------------------- setup.py | 3 + 4 files changed, 6 insertions(+), 471 deletions(-) delete mode 100644 firmware/Makefile delete mode 100644 firmware/arduino.mk diff --git a/README.md b/README.md index 77bd10c..8626f93 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ Nanpy ===== - Use your Arduino board with Python. Description ----------- - The main purpose of Nanpy is making programmers' life easier, giving them something to create prototypes faster and use Arduino in a simpler way, thanks to a simple and powerful language like Python. Also Nanpy can run on RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use it for communicating with Arduino :) Let's start with a classic example, turn on a led placed in the 13th pin.. @@ -25,7 +23,6 @@ really straightforward now, isn't it? :) Multithreading -------------- - What happens if you call methods in an async context? Nothing bad, all works! every call is mutually exclusive.. For example, suppose that two threads need to write on the same Lcd and in different positions at the same time... well, just call printString on the Lcd object specifying the position (row and column) #Thread_1 @@ -40,32 +37,18 @@ What happens if you call methods in an async context? Nothing bad, all works! ev Dependencies ------------ - -#### Python (2.2 or later) -- python-distribute (http://pypi.python.org/pypi/distribute) - python-serial -- edam's Arduino makefile (http://ed.am/dev/make/arduino-mk, included) How to build and install ------------------------ +You need to build the firmware for your Arduino first, so upload it on your Arduino IDE and compile! -You need to build the firmware for your Arduino first, you can find it in the firmware directory: - - cd firmware - export BOARD=uno (in case you use UNO board. Type 'make boards' for a complete list) - make - -and then upload it on your board: +To install Nanpy just type: - make upload - -To install Nanpy just type (as root): - - python setup.py install + # python setup.py install How to use ---------- - ### Serial communication Nanpy autodetects the serial port for you, anyway you can specify another serial port manually: @@ -83,15 +66,12 @@ Import all the modules you need :) How to contribute ----------------- - Nanpy needs a lot of work to be a great instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at Donate ------ - Do you want to support us with a coffee? We need it to code all night long! if you like this project and you want to support it with some cents, please donate :) https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J License ------- - This software is released under MIT License. Copyright (c) 2012-2013 Andrea Stagi diff --git a/firmware/Makefile b/firmware/Makefile deleted file mode 100644 index 29ebe54..0000000 --- a/firmware/Makefile +++ /dev/null @@ -1 +0,0 @@ -include arduino.mk diff --git a/firmware/arduino.mk b/firmware/arduino.mk deleted file mode 100644 index 3028d5d..0000000 --- a/firmware/arduino.mk +++ /dev/null @@ -1,447 +0,0 @@ -#_______________________________________________________________________________ -# -# edam's Arduino makefile -#_______________________________________________________________________________ -# version 0.5 -# -# Copyright (C) 2011, 2012, 2013 Tim Marston . -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -#_______________________________________________________________________________ -# -# -# This is a general purpose makefile for use with Arduino hardware and -# software. It works with the arduino-1.0 and later software releases. It -# should work GNU/Linux and OS X. To download the latest version of this -# makefile visit the following website where you can also find documentation on -# it's use. (The following text can only really be considered a reference.) -# -# http://ed.am/dev/make/arduino-mk -# -# This makefile can be used as a drop-in replacement for the Arduino IDE's -# build system. To use it, just copy arduino.mk in to your project directory. -# Or, you could save it somewhere (I keep mine at ~/src/arduino.mk) and create -# a symlink to it in your project directory, named "Makefile". For example: -# -# $ ln -s ~/src/arduino.mk Makefile -# -# The Arduino software (version 1.0 or later) is required. On GNU/Linux you -# can probably install the software from your package manager. If you are -# using Debian (or a derivative), try `apt-get install arduino`. Otherwise, -# you can download the Arduino software manually from http://arduino.cc/. It -# is suggested that you install it at ~/opt/arduino (or /Applications on OS X) -# if you are unsure. -# -# If you downloaded the Arduino software manually and unpacked it somewhere -# other than ~/opt/arduino (or /Applications), you will need to set up the -# ARDUINODIR environment variable to be the path where you unpacked it. (If -# unset, ARDUINODIR defaults to some sensible places). You could set this in -# your ~/.profile by adding something like this: -# -# export ARDUINODIR=~/somewhere/arduino-1.0 -# -# For each project, you will also need to set BOARD to the type of Arduino -# you're building for. Type `make boards` for a list of acceptable values. -# For example: -# -# $ export BOARD=uno -# $ make -# -# You may also need to set SERIALDEV if it is not detected correctly. -# -# The presence of a .ino (or .pde) file causes the arduino.mk to automatically -# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp -# files in the project directory (or any "util" or "utility" subdirectories) -# are automatically included in the build and are scanned for Arduino libraries -# that have been #included. Note, there can only be one .ino (or .pde) file in -# a project directory and if you want to be compatible with the Arduino IDE, it -# should be called the same as the directory name. -# -# Alternatively, if you want to manually specify build variables, create a -# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. -# (There is no need to define TARGET). You can also specify the BOARD here, if -# the project has a specific one. Here is an example Makefile: -# -# SOURCES := main.cc other.cc -# LIBRARIES := EEPROM -# BOARD := pro5v -# include ~/src/arduino.mk -# -# Here is a complete list of configuration parameters: -# -# ARDUINODIR The path where the Arduino software is installed on your system. -# -# ARDUINOCONST The Arduino software version, as an integer, used to define the -# ARDUINO version constant. This defaults to 100 if undefined. -# -# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess -# based on where avrdude is. If set empty, no avrdude.conf is -# passed to avrdude (so the system default is used). -# -# AVRDUDEFLAGS Specify any additional flags for avrdude. The usual flags, -# required to build the project, will be appended to this. -# -# AVRTOOLSPATH A space-separated list of directories that is searched in order -# when looking for the avr build tools. This defaults to PATH, -# followed by subdirectories in ARDUINODIR. -# -# BOARD Specify a target board type. Run `make boards` to see available -# board types. -# -# CPPFLAGS Specify any additional flags for the compiler. The usual flags, -# required to build the project, will be appended to this. -# -# LINKFLAGS Specify any additional flags for the linker. The usual flags, -# required to build the project, will be appended to this. -# -# LIBRARIES A list of Arduino libraries to build and include. This is set -# automatically if a .ino (or .pde) is found. -# -# LIBRARYPATH A space-separated list of directories that is searched in order -# when looking for Arduino libraries. This defaults to "libs", -# "libraries" (in the project directory), then your sketchbook -# "libraries" directory, then the Arduino libraries directory. -# -# SERIALDEV The POSIX device name of the serial device that is the Arduino. -# If unspecified, an attempt is made to guess the name of a -# connected Arduino's serial device, which may work in some cases. -# -# SOURCES A list of all source files of whatever language. The language -# type is determined by the file extension. This is set -# automatically if a .ino (or .pde) is found. -# -# TARGET The name of the target file. This is set automatically if a -# .ino (or .pde) is found, but it is not necessary to set it -# otherwise. -# -# This makefile also defines the following goals for use on the command line -# when you run make: -# -# all This is the default if no goal is specified. It builds the -# target. -# -# target Builds the target. -# -# upload Uploads the target (building it, as necessary) to an attached -# Arduino. -# -# clean Deletes files created during the build. -# -# boards Display a list of available board names, so that you can set the -# BOARD environment variable appropriately. -# -# monitor Start `screen` on the serial device. This is meant to be an -# equivalent to the Arduino serial monitor. -# -# size Displays size information about the built target. -# -# bootloader Burns the bootloader for your board to it. -# -# Builds the specified file, either an object file or the target, -# from those that that would be built for the project. -#_______________________________________________________________________________ -# - -# default arduino software directory, check software exists -ifndef ARDUINODIR -ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino \ - /Applications/Arduino.app/Contents/Resources/Java \ - $(HOME)/Applications/Arduino.app/Contents/Resources/Java)) -endif -ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" -$(error ARDUINODIR is not set correctly; arduino software not found) -endif - -# default arduino version -ARDUINOCONST ?= 100 - -# default path for avr tools -AVRTOOLSPATH ?= $(subst :, , $(PATH)) $(ARDUINODIR)/hardware/tools \ - $(ARDUINODIR)/hardware/tools/avr/bin - -# default path to find libraries -LIBRARYPATH ?= libraries libs $(SKETCHBOOKDIR)/libraries $(ARDUINODIR)/libraries - -# default serial device to a poor guess (something that might be an arduino) -SERIALDEVGUESS := 0 -ifndef SERIALDEV -SERIALDEV := $(firstword $(wildcard \ - /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) -SERIALDEVGUESS := 1 -endif - -# no board? -ifndef BOARD -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is unset. Type 'make boards' to see possible values) -endif -endif -endif - -# obtain board parameters from the arduino boards.txt file -BOARDSFILE := $(ARDUINODIR)/hardware/arduino/boards.txt -readboardsparam = $(shell sed -ne "s/$(BOARD).$(1)=\(.*\)/\1/p" $(BOARDSFILE)) -BOARD_BUILD_MCU := $(call readboardsparam,build.mcu) -BOARD_BUILD_FCPU := $(call readboardsparam,build.f_cpu) -BOARD_BUILD_VARIANT := $(call readboardsparam,build.variant) -BOARD_UPLOAD_SPEED := $(call readboardsparam,upload.speed) -BOARD_UPLOAD_PROTOCOL := $(call readboardsparam,upload.protocol) -BOARD_USB_VID := $(call readboardsparam,build.vid) -BOARD_USB_PID := $(call readboardsparam,build.pid) -BOARD_BOOTLOADER_UNLOCK := $(call readboardsparam,bootloader.unlock_bits) -BOARD_BOOTLOADER_LOCK := $(call readboardsparam,bootloader.lock_bits) -BOARD_BOOTLOADER_LFUSES := $(call readboardsparam,bootloader.low_fuses) -BOARD_BOOTLOADER_HFUSES := $(call readboardsparam,bootloader.high_fuses) -BOARD_BOOTLOADER_EFUSES := $(call readboardsparam,bootloader.extended_fuses) -BOARD_BOOTLOADER_PATH := $(call readboardsparam,bootloader.path) -BOARD_BOOTLOADER_FILE := $(call readboardsparam,bootloader.file) - -# obtain preferences from the IDE's preferences.txt -PREFERENCESFILE := $(firstword $(wildcard \ - $(HOME)/.arduino/preferences.txt $(HOME)/Library/Arduino/preferences.txt)) -ifneq "$(PREFERENCESFILE)" "" -readpreferencesparam = $(shell sed -ne "s/$(1)=\(.*\)/\1/p" $(PREFERENCESFILE)) -SKETCHBOOKDIR := $(call readpreferencesparam,sketchbook.path) -endif - -# invalid board? -ifeq "$(BOARD_BUILD_MCU)" "" -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is invalid. Type 'make boards' to see possible values) -endif -endif -endif - -# auto mode? -INOFILE := $(wildcard *.ino *.pde) -ifdef INOFILE -ifneq "$(words $(INOFILE))" "1" -$(error There is more than one .pde or .ino file in this directory!) -endif - -# automatically determine sources and targeet -TARGET := $(basename $(INOFILE)) -SOURCES := $(INOFILE) \ - $(wildcard *.c *.cc *.cpp *.C) \ - $(wildcard $(addprefix util/, *.c *.cc *.cpp *.C)) \ - $(wildcard $(addprefix utility/, *.c *.cc *.cpp *.C)) - -# automatically determine included libraries -LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \ - $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) - -endif - -# software -findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) -CC := $(call findsoftware,avr-gcc) -CXX := $(call findsoftware,avr-g++) -LD := $(call findsoftware,avr-ld) -AR := $(call findsoftware,avr-ar) -OBJCOPY := $(call findsoftware,avr-objcopy) -AVRDUDE := $(call findsoftware,avrdude) -AVRSIZE := $(call findsoftware,avr-size) - -# directories -ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino -LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \ - $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH))))) -LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS)) - -# files -TARGET := $(if $(TARGET),$(TARGET),a.out) -OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) -DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) -ARDUINOLIB := .lib/arduino.a -ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \ - $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) -BOOTLOADERHEX := $(addprefix \ - $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \ - $(BOARD_BOOTLOADER_FILE)) - -# avrdude confifuration -ifeq "$(AVRDUDECONF)" "" -ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" -AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf -else -AVRDUDECONF := $(wildcard $(AVRDUDE).conf) -endif -endif - -# flags -CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) -CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) -CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR) -CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ -CPPFLAGS += $(addprefix -I , $(LIBRARYDIRS)) -CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep -CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h -AVRDUDEFLAGS += $(addprefix -C , $(AVRDUDECONF)) -DV -AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) -AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) -LINKFLAGS += -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) - -# figure out which arg to use with stty (for OS X, GNU and busybox stty) -STTYFARG := $(shell stty --help 2>&1 | \ - grep -q 'illegal option' && echo -f || echo -F) - -# include dependencies -ifneq "$(MAKECMDGOALS)" "clean" --include $(DEPFILES) -endif - -# default rule -.DEFAULT_GOAL := all - -#_______________________________________________________________________________ -# RULES - -.PHONY: all target upload clean boards monitor size bootloader - -all: target - -target: $(TARGET).hex - -upload: target - @echo "\nUploading to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } -ifeq "$(BOARD_BOOTLOADER_PATH)" "caterina" - stty $(STTYFARG) $(SERIALDEV) speed 1200 - sleep 1 -else - stty $(STTYFARG) $(SERIALDEV) hupcl -endif - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i - -clean: - rm -f $(OBJECTS) - rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ - rm -rf .lib .dep - -boards: - @echo "Available values for BOARD:" - @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDSFILE) | \ - sed -Ee 's/([^.]+)\.name=(.*)/\1 \2/' \ - -e 's/(.{12}) *(.*)/\1 \2/' - -monitor: - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test -n `which screen` || { \ - echo "error: can't find GNU screen, you might need to install it." >&2 \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - screen $(SERIALDEV) - -size: $(TARGET).elf - echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf - -bootloader: - @echo "Burning bootloader to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - stty $(STTYFARG) $(SERIALDEV) hupcl - $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m - $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m - $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m -ifneq "$(BOARD_BOOTLOADER_EFUSES)" "" - $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m -endif -ifneq "$(BOOTLOADERHEX)" "" - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i -endif - $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m - -# building the target - -$(TARGET).hex: $(TARGET).elf - $(OBJCOPY) -O ihex -R .eeprom $< $@ - -.INTERMEDIATE: $(TARGET).elf - -$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) - $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@ - -%.o: %.c - mkdir -p .dep/$(dir $<) - $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cpp - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cc - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.C - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.ino - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -%.o: %.pde - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -# building the arduino library - -$(ARDUINOLIB): $(ARDUINOLIBOBJS) - $(AR) rcs $@ $? - -.lib/%.c.o: %.c - mkdir -p $(dir $@) - $(COMPILE.c) -o $@ $< - -.lib/%.cpp.o: %.cpp - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.cc.o: %.cc - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.C.o: %.C - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -# Local Variables: -# mode: makefile -# tab-width: 4 -# End: \ No newline at end of file diff --git a/setup.py b/setup.py index ef69c88..54a3b14 100644 --- a/setup.py +++ b/setup.py @@ -11,4 +11,7 @@ url="http://github.com/nanpy/nanpy", packages = find_packages(), keywords= "arduino library prototype", + install_requires=[ + "python-serial", + ], zip_safe = True) From cda71c2f33fd405e5e2195d80e7b8f2a7109de1f Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 17 Dec 2013 21:29:29 +0100 Subject: [PATCH 130/344] Removed makefile files --- firmware/Nanpy/Makefile | 1 - firmware/Nanpy/arduino.mk | 447 -------------------------------------- 2 files changed, 448 deletions(-) delete mode 100644 firmware/Nanpy/Makefile delete mode 100644 firmware/Nanpy/arduino.mk diff --git a/firmware/Nanpy/Makefile b/firmware/Nanpy/Makefile deleted file mode 100644 index 29ebe54..0000000 --- a/firmware/Nanpy/Makefile +++ /dev/null @@ -1 +0,0 @@ -include arduino.mk diff --git a/firmware/Nanpy/arduino.mk b/firmware/Nanpy/arduino.mk deleted file mode 100644 index 3028d5d..0000000 --- a/firmware/Nanpy/arduino.mk +++ /dev/null @@ -1,447 +0,0 @@ -#_______________________________________________________________________________ -# -# edam's Arduino makefile -#_______________________________________________________________________________ -# version 0.5 -# -# Copyright (C) 2011, 2012, 2013 Tim Marston . -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -#_______________________________________________________________________________ -# -# -# This is a general purpose makefile for use with Arduino hardware and -# software. It works with the arduino-1.0 and later software releases. It -# should work GNU/Linux and OS X. To download the latest version of this -# makefile visit the following website where you can also find documentation on -# it's use. (The following text can only really be considered a reference.) -# -# http://ed.am/dev/make/arduino-mk -# -# This makefile can be used as a drop-in replacement for the Arduino IDE's -# build system. To use it, just copy arduino.mk in to your project directory. -# Or, you could save it somewhere (I keep mine at ~/src/arduino.mk) and create -# a symlink to it in your project directory, named "Makefile". For example: -# -# $ ln -s ~/src/arduino.mk Makefile -# -# The Arduino software (version 1.0 or later) is required. On GNU/Linux you -# can probably install the software from your package manager. If you are -# using Debian (or a derivative), try `apt-get install arduino`. Otherwise, -# you can download the Arduino software manually from http://arduino.cc/. It -# is suggested that you install it at ~/opt/arduino (or /Applications on OS X) -# if you are unsure. -# -# If you downloaded the Arduino software manually and unpacked it somewhere -# other than ~/opt/arduino (or /Applications), you will need to set up the -# ARDUINODIR environment variable to be the path where you unpacked it. (If -# unset, ARDUINODIR defaults to some sensible places). You could set this in -# your ~/.profile by adding something like this: -# -# export ARDUINODIR=~/somewhere/arduino-1.0 -# -# For each project, you will also need to set BOARD to the type of Arduino -# you're building for. Type `make boards` for a list of acceptable values. -# For example: -# -# $ export BOARD=uno -# $ make -# -# You may also need to set SERIALDEV if it is not detected correctly. -# -# The presence of a .ino (or .pde) file causes the arduino.mk to automatically -# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp -# files in the project directory (or any "util" or "utility" subdirectories) -# are automatically included in the build and are scanned for Arduino libraries -# that have been #included. Note, there can only be one .ino (or .pde) file in -# a project directory and if you want to be compatible with the Arduino IDE, it -# should be called the same as the directory name. -# -# Alternatively, if you want to manually specify build variables, create a -# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. -# (There is no need to define TARGET). You can also specify the BOARD here, if -# the project has a specific one. Here is an example Makefile: -# -# SOURCES := main.cc other.cc -# LIBRARIES := EEPROM -# BOARD := pro5v -# include ~/src/arduino.mk -# -# Here is a complete list of configuration parameters: -# -# ARDUINODIR The path where the Arduino software is installed on your system. -# -# ARDUINOCONST The Arduino software version, as an integer, used to define the -# ARDUINO version constant. This defaults to 100 if undefined. -# -# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess -# based on where avrdude is. If set empty, no avrdude.conf is -# passed to avrdude (so the system default is used). -# -# AVRDUDEFLAGS Specify any additional flags for avrdude. The usual flags, -# required to build the project, will be appended to this. -# -# AVRTOOLSPATH A space-separated list of directories that is searched in order -# when looking for the avr build tools. This defaults to PATH, -# followed by subdirectories in ARDUINODIR. -# -# BOARD Specify a target board type. Run `make boards` to see available -# board types. -# -# CPPFLAGS Specify any additional flags for the compiler. The usual flags, -# required to build the project, will be appended to this. -# -# LINKFLAGS Specify any additional flags for the linker. The usual flags, -# required to build the project, will be appended to this. -# -# LIBRARIES A list of Arduino libraries to build and include. This is set -# automatically if a .ino (or .pde) is found. -# -# LIBRARYPATH A space-separated list of directories that is searched in order -# when looking for Arduino libraries. This defaults to "libs", -# "libraries" (in the project directory), then your sketchbook -# "libraries" directory, then the Arduino libraries directory. -# -# SERIALDEV The POSIX device name of the serial device that is the Arduino. -# If unspecified, an attempt is made to guess the name of a -# connected Arduino's serial device, which may work in some cases. -# -# SOURCES A list of all source files of whatever language. The language -# type is determined by the file extension. This is set -# automatically if a .ino (or .pde) is found. -# -# TARGET The name of the target file. This is set automatically if a -# .ino (or .pde) is found, but it is not necessary to set it -# otherwise. -# -# This makefile also defines the following goals for use on the command line -# when you run make: -# -# all This is the default if no goal is specified. It builds the -# target. -# -# target Builds the target. -# -# upload Uploads the target (building it, as necessary) to an attached -# Arduino. -# -# clean Deletes files created during the build. -# -# boards Display a list of available board names, so that you can set the -# BOARD environment variable appropriately. -# -# monitor Start `screen` on the serial device. This is meant to be an -# equivalent to the Arduino serial monitor. -# -# size Displays size information about the built target. -# -# bootloader Burns the bootloader for your board to it. -# -# Builds the specified file, either an object file or the target, -# from those that that would be built for the project. -#_______________________________________________________________________________ -# - -# default arduino software directory, check software exists -ifndef ARDUINODIR -ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino \ - /Applications/Arduino.app/Contents/Resources/Java \ - $(HOME)/Applications/Arduino.app/Contents/Resources/Java)) -endif -ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" -$(error ARDUINODIR is not set correctly; arduino software not found) -endif - -# default arduino version -ARDUINOCONST ?= 100 - -# default path for avr tools -AVRTOOLSPATH ?= $(subst :, , $(PATH)) $(ARDUINODIR)/hardware/tools \ - $(ARDUINODIR)/hardware/tools/avr/bin - -# default path to find libraries -LIBRARYPATH ?= libraries libs $(SKETCHBOOKDIR)/libraries $(ARDUINODIR)/libraries - -# default serial device to a poor guess (something that might be an arduino) -SERIALDEVGUESS := 0 -ifndef SERIALDEV -SERIALDEV := $(firstword $(wildcard \ - /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) -SERIALDEVGUESS := 1 -endif - -# no board? -ifndef BOARD -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is unset. Type 'make boards' to see possible values) -endif -endif -endif - -# obtain board parameters from the arduino boards.txt file -BOARDSFILE := $(ARDUINODIR)/hardware/arduino/boards.txt -readboardsparam = $(shell sed -ne "s/$(BOARD).$(1)=\(.*\)/\1/p" $(BOARDSFILE)) -BOARD_BUILD_MCU := $(call readboardsparam,build.mcu) -BOARD_BUILD_FCPU := $(call readboardsparam,build.f_cpu) -BOARD_BUILD_VARIANT := $(call readboardsparam,build.variant) -BOARD_UPLOAD_SPEED := $(call readboardsparam,upload.speed) -BOARD_UPLOAD_PROTOCOL := $(call readboardsparam,upload.protocol) -BOARD_USB_VID := $(call readboardsparam,build.vid) -BOARD_USB_PID := $(call readboardsparam,build.pid) -BOARD_BOOTLOADER_UNLOCK := $(call readboardsparam,bootloader.unlock_bits) -BOARD_BOOTLOADER_LOCK := $(call readboardsparam,bootloader.lock_bits) -BOARD_BOOTLOADER_LFUSES := $(call readboardsparam,bootloader.low_fuses) -BOARD_BOOTLOADER_HFUSES := $(call readboardsparam,bootloader.high_fuses) -BOARD_BOOTLOADER_EFUSES := $(call readboardsparam,bootloader.extended_fuses) -BOARD_BOOTLOADER_PATH := $(call readboardsparam,bootloader.path) -BOARD_BOOTLOADER_FILE := $(call readboardsparam,bootloader.file) - -# obtain preferences from the IDE's preferences.txt -PREFERENCESFILE := $(firstword $(wildcard \ - $(HOME)/.arduino/preferences.txt $(HOME)/Library/Arduino/preferences.txt)) -ifneq "$(PREFERENCESFILE)" "" -readpreferencesparam = $(shell sed -ne "s/$(1)=\(.*\)/\1/p" $(PREFERENCESFILE)) -SKETCHBOOKDIR := $(call readpreferencesparam,sketchbook.path) -endif - -# invalid board? -ifeq "$(BOARD_BUILD_MCU)" "" -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is invalid. Type 'make boards' to see possible values) -endif -endif -endif - -# auto mode? -INOFILE := $(wildcard *.ino *.pde) -ifdef INOFILE -ifneq "$(words $(INOFILE))" "1" -$(error There is more than one .pde or .ino file in this directory!) -endif - -# automatically determine sources and targeet -TARGET := $(basename $(INOFILE)) -SOURCES := $(INOFILE) \ - $(wildcard *.c *.cc *.cpp *.C) \ - $(wildcard $(addprefix util/, *.c *.cc *.cpp *.C)) \ - $(wildcard $(addprefix utility/, *.c *.cc *.cpp *.C)) - -# automatically determine included libraries -LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \ - $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) - -endif - -# software -findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) -CC := $(call findsoftware,avr-gcc) -CXX := $(call findsoftware,avr-g++) -LD := $(call findsoftware,avr-ld) -AR := $(call findsoftware,avr-ar) -OBJCOPY := $(call findsoftware,avr-objcopy) -AVRDUDE := $(call findsoftware,avrdude) -AVRSIZE := $(call findsoftware,avr-size) - -# directories -ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino -LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \ - $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH))))) -LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS)) - -# files -TARGET := $(if $(TARGET),$(TARGET),a.out) -OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) -DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) -ARDUINOLIB := .lib/arduino.a -ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \ - $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) -BOOTLOADERHEX := $(addprefix \ - $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \ - $(BOARD_BOOTLOADER_FILE)) - -# avrdude confifuration -ifeq "$(AVRDUDECONF)" "" -ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" -AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf -else -AVRDUDECONF := $(wildcard $(AVRDUDE).conf) -endif -endif - -# flags -CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) -CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) -CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR) -CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ -CPPFLAGS += $(addprefix -I , $(LIBRARYDIRS)) -CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep -CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h -AVRDUDEFLAGS += $(addprefix -C , $(AVRDUDECONF)) -DV -AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) -AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) -LINKFLAGS += -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) - -# figure out which arg to use with stty (for OS X, GNU and busybox stty) -STTYFARG := $(shell stty --help 2>&1 | \ - grep -q 'illegal option' && echo -f || echo -F) - -# include dependencies -ifneq "$(MAKECMDGOALS)" "clean" --include $(DEPFILES) -endif - -# default rule -.DEFAULT_GOAL := all - -#_______________________________________________________________________________ -# RULES - -.PHONY: all target upload clean boards monitor size bootloader - -all: target - -target: $(TARGET).hex - -upload: target - @echo "\nUploading to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } -ifeq "$(BOARD_BOOTLOADER_PATH)" "caterina" - stty $(STTYFARG) $(SERIALDEV) speed 1200 - sleep 1 -else - stty $(STTYFARG) $(SERIALDEV) hupcl -endif - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i - -clean: - rm -f $(OBJECTS) - rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ - rm -rf .lib .dep - -boards: - @echo "Available values for BOARD:" - @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDSFILE) | \ - sed -Ee 's/([^.]+)\.name=(.*)/\1 \2/' \ - -e 's/(.{12}) *(.*)/\1 \2/' - -monitor: - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test -n `which screen` || { \ - echo "error: can't find GNU screen, you might need to install it." >&2 \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - screen $(SERIALDEV) - -size: $(TARGET).elf - echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf - -bootloader: - @echo "Burning bootloader to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - stty $(STTYFARG) $(SERIALDEV) hupcl - $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m - $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m - $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m -ifneq "$(BOARD_BOOTLOADER_EFUSES)" "" - $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m -endif -ifneq "$(BOOTLOADERHEX)" "" - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i -endif - $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m - -# building the target - -$(TARGET).hex: $(TARGET).elf - $(OBJCOPY) -O ihex -R .eeprom $< $@ - -.INTERMEDIATE: $(TARGET).elf - -$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) - $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@ - -%.o: %.c - mkdir -p .dep/$(dir $<) - $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cpp - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cc - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.C - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.ino - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -%.o: %.pde - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -# building the arduino library - -$(ARDUINOLIB): $(ARDUINOLIBOBJS) - $(AR) rcs $@ $? - -.lib/%.c.o: %.c - mkdir -p $(dir $@) - $(COMPILE.c) -o $@ $< - -.lib/%.cpp.o: %.cpp - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.cc.o: %.cc - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.C.o: %.C - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -# Local Variables: -# mode: makefile -# tab-width: 4 -# End: \ No newline at end of file From 4a114663f300eadd4a5a5c29747d23a1ed87a0e2 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 09:05:10 +0100 Subject: [PATCH 131/344] test the "make" process --- tests/config.py | 2 ++ tests/test_make.py | 15 +++++++++++++++ tests/util.py | 6 ++++++ tox.ini | 5 +++-- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/test_make.py diff --git a/tests/config.py b/tests/config.py index 6aed61c..f4ecba3 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,3 +1,5 @@ + +# custom board with 20MHz quartz and ATMEGA328P config = dict( A0=14, ARDUINO=105, diff --git a/tests/test_make.py b/tests/test_make.py new file mode 100644 index 0000000..8d9ba66 --- /dev/null +++ b/tests/test_make.py @@ -0,0 +1,15 @@ +from easyprocess import EasyProcess +from nose.tools import eq_ +from path import path +from util import tmpdir + + +FIRMWARE = path(__file__).parent.parent.abspath() / 'firmware' / 'Nanpy' + + +def test_make(): + dest = path(tmpdir()) / 'Nanpy' + FIRMWARE.copytree(dest) + + p = EasyProcess('make size BOARD=uno', cwd=dest).call() + eq_(p.return_code, 0) diff --git a/tests/util.py b/tests/util.py index e03fdbb..d2e2631 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,4 +1,5 @@ from nose.tools import ok_ +import tempfile def exc_(excClass, callableObj, *args, **kwargs): @@ -28,3 +29,8 @@ def ok_vcc(vcc): print ('vcc=', vcc) ok_(vcc < 5.5) ok_(vcc > 3) + + +def tmpdir(dir=None, suffix=''): + x = tempfile.mkdtemp(suffix=suffix, prefix='nanpy_test_', dir=dir) + return x diff --git a/tox.ini b/tox.ini index 2d0b09d..27af1b0 100644 --- a/tox.ini +++ b/tox.ini @@ -6,10 +6,11 @@ envlist = py25,py26,py27,py31,py32,py33 deps= nose pyserial - + easyprocess + path.py setenv= PYTHONPATH= changedir=tests -commands=nosetests +commands=nosetests -v From d4379e9e61a66c8e8041d095d7b616d618a098f7 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 12:04:09 +0100 Subject: [PATCH 132/344] documentation --- codegen/README.md | 47 +++++++++++++++++++++++++++++++++ examples/dump.py | 3 +++ examples/highfreqpwm.py | 3 +++ examples/reset.py | 10 +++++++ nanpy/arduinocore.py | 50 ++++++++++++++++++++++++++++------- nanpy/arduinopin.py | 58 ++++++++++++++++++++++++++++++++++------- nanpy/define.py | 10 +++++++ nanpy/pwm.py | 24 +++++++++++++++-- nanpy/resgister.py | 39 +++++++++++++++++++++++++++ nanpy/watchdog.py | 28 ++++++++++++++++---- tests/README.md | 8 ++++++ 11 files changed, 254 insertions(+), 26 deletions(-) create mode 100644 codegen/README.md create mode 100644 tests/README.md diff --git a/codegen/README.md b/codegen/README.md new file mode 100644 index 0000000..3c841c8 --- /dev/null +++ b/codegen/README.md @@ -0,0 +1,47 @@ +Code generation +================ + +C code is generated for AVR type and registers. +All information is parsed from AVR Libc header files. + +dependencies: + + - path.py + - AVR Libc (http://www.nongnu.org/avr-libc/) + + sudo apt-get install python-pip avr-libc + sudo pip install path.py + +running from project directory: + + python codegen/__init__.py + +generated files: + + - firmware/Nanpy/generated_mcu.h + - firmware/Nanpy/generated_avr_registers.h + + +generated_mcu.h +----------------- + +This is a list of all known AVR types, "MCU" is defined to the type name. +Example: + + #ifdef __AVR_ATmega328P__ + # ifdef MCU + # error "MCU is already defined" + # endif + # define MCU "__AVR_ATmega328P__" + #endif + +generated_avr_registers.h +--------------------------- +This is a list of all known register names. +Example: + + #ifdef DDRB + DEFINE(DDRB) + #else + MISSING(DDRB) + #endif diff --git a/examples/dump.py b/examples/dump.py index 7686f5b..161097d 100644 --- a/examples/dump.py +++ b/examples/dump.py @@ -1,3 +1,6 @@ +'''Dump all possible values from the AVR +''' + from dicts.sorteddict import SortedDict from entrypoint2 import entrypoint from nanpy.arduino import Arduino diff --git a/examples/highfreqpwm.py b/examples/highfreqpwm.py index 576caae..3ed0d67 100644 --- a/examples/highfreqpwm.py +++ b/examples/highfreqpwm.py @@ -1,3 +1,6 @@ +'''High frequency PWM mode demo +''' + from nanpy.arduinopin import ArduinoPin FREQ = 10007 diff --git a/examples/reset.py b/examples/reset.py index aa5967b..d967555 100755 --- a/examples/reset.py +++ b/examples/reset.py @@ -1,3 +1,13 @@ +"""soft reset demo.""" + from nanpy.watchdog import Watchdog +from nanpy.arduino import Arduino + + +def print_millis(): + print ('uptime: %s sec' % (Arduino.millis() / 1000.0)) +print_millis() +print ('soft reset') Watchdog.soft_reset() +print_millis() diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py index 6018c94..76f71d3 100644 --- a/nanpy/arduinocore.py +++ b/nanpy/arduinocore.py @@ -5,70 +5,100 @@ class ArduinoCore(object): + """Access to Arduino functions which are not part of the public API. + + There are some additional funtions implemented in C + + """ + @classmethod @memoized @returns(int) @arduinoclassmethod def digitalPinToBitMask(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def digitalPinToPort(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def portModeRegister(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def digitalPinToTimer(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def analogInPinToBit(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def portOutputRegister(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def portInputRegister(cls, pin): - pass + """nonpublic Arduino function.""" @classmethod @memoized @returns(int) @arduinoclassmethod def totalPinCount(cls): - pass + """total pin count. + + The C implementation is a hack. + + """ @classmethod @returns(lambda x: int(x) / 1000.0) @arduinoclassmethod def readVcc(cls): - """VCC in Volt.""" + """VCC in Volt. This works on Arduinos with a 328 or 168 only. + + Source: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter + + How it works + + The Arduino 328 and 168 have a built in precision voltage reference of 1.1V. + This is used sometimes for precision measurement, + although for Arduino it usually makes more sense to measure against Vcc, + the positive power rail. + The chip has an internal switch that selects which pin the analogue to digital converter reads. + That switch has a few leftover connections, so the chip designers wired them up to useful signals. + One of those signals is that 1.1V reference. + So if you measure how large the known 1.1V reference is in comparison to Vcc, + you can back-calculate what Vcc is with a little algebra. That is how this works. + + """ @classmethod def model(cls): - """""" + """The model of the AVR. + + Example: ATmega328P + + """ s = Define.asDict().get('MCU') return s.strip('_').split('_')[-1] diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py index 758f04d..3bbe9d5 100644 --- a/nanpy/arduinopin.py +++ b/nanpy/arduinopin.py @@ -1,6 +1,4 @@ from nanpy.arduino import Arduino -from nanpy.arduinoboard import arduinoclassmethod -from nanpy.arduinoboard import returns from nanpy.arduinocore import ArduinoCore from nanpy.define import Define from nanpy.memo import memoized @@ -40,36 +38,51 @@ def name2int(pin_name, A0): class ArduinoPin(object): + '''Object-oriented representation of an Arduino pin + + Examples: + + # they do the same + ArduinoPin(0).value + ArduinoPin('D0').value + ArduinoPin('D0').read_value() + ''' @classmethod @memoized def count_analog(cls): + """Count of analog pins.""" return len(cls.analog_names()) @classmethod @memoized def count_digital(cls): + """Count of digital pins.""" return len(cls.digital_names()) @classmethod @memoized def count(cls): + """Count of all pins.""" return cls.count_analog() + cls.count_digital() @classmethod @memoized def digital_names(cls): + """List of digital pin names.""" A0 = Define.asDict()['A0'] return ['D%s' % x for x in range(0, A0)] @classmethod @memoized def analog_names(cls): + """List of analog pin names.""" A0 = Define.asDict()['A0'] return ( ['A%s' % (x - A0) for x in range(A0, ArduinoCore.totalPinCount())] ) def __init__(self, name): + """name can be int or string.""" self.A0 = Define.asDict()['A0'] self.nr = name2int(name, self.A0) if self.nr >= ArduinoCore.totalPinCount(): @@ -79,6 +92,8 @@ def __init__(self, name): @property @memoized def pwm(self): + '''Object-oriented representation of the pin PWM functionality + ''' return ArduinoPwmPin(self.nr) @property @@ -91,11 +106,15 @@ def is_analog(self): @property def avr_port(self): + '''AVR port name (example: "B") + ''' x = ArduinoCore.digitalPinToPort(self.nr) return chr(ord('A') + x - 1) @property def avr_bit(self): + '''AVR bit name (example: "2") + ''' bitmask = ArduinoCore.digitalPinToBitMask(self.nr) i = 0 while bitmask != 1: @@ -105,10 +124,19 @@ def avr_bit(self): @property def avr_pin(self): + '''AVR pin name (example: "PB2") + ''' return 'P%s%s' % (self.avr_port, self.avr_bit) @property def name(self): + """Arduino pin name. + + D -> digital + A -> analog + (examples: "D2", "A0") + + """ if self.is_digital: return 'D%s' % self.nr else: @@ -122,6 +150,7 @@ def nr_analog(self): @property def programming_function(self): + """programming function (MISO, MOSI, SCK or SS)""" d = Define.asDict() if self.nr == d['MISO']: return 'MISO' @@ -133,21 +162,35 @@ def programming_function(self): return 'SS' def reset(self): + '''reset to the pin default state: INPUT, no pullup + ''' self.write_mode(INPUT) self.write_pullup(LOW) if self.pwm.available: self.pwm.reset() def write_pullup(self, value): + """set pullup (0/1)""" self.write_mode(INPUT) return self.write_digital_value(value) def read_digital_value(self, direction=None): + """read digital value (0/1) + + direction can be set, if 'direction' parameter exists + + """ if direction is not None: self.write_mode(direction) return Arduino.digitalRead(self.nr) def write_digital_value(self, value, direction=None): + """write digital value (0/1) + + direction can be set, if 'direction' parameter exists, and it is + not INPUT + + """ if direction == INPUT: raise ValueError('write_digital_value() to INPUT??') if direction is not None: @@ -158,21 +201,18 @@ def write_digital_value(self, value, direction=None): digital_value = property(read_digital_value, write_digital_value) def read_analog_value(self): + '''read analog value (0-1023) + ''' if not self.is_analog: return None return Arduino.analogRead(self.nr) analog_value = property(read_analog_value) def read_mode(self): + """read mode (0/1)""" return Arduino.pinModeRead(self.nr) def write_mode(self, value): + """write mode (0/1)""" return Arduino.pinMode(self.nr, value) mode = property(read_mode, write_mode) - -# def read_pwm_value(self): -# return -# -# def write_pwm_value(self, value): -# return Arduino.analogWrite(self.nr, value) -# pwm_value = property(read_pwm_value, write_pwm_value) diff --git a/nanpy/define.py b/nanpy/define.py index 8124c10..ba024fe 100644 --- a/nanpy/define.py +++ b/nanpy/define.py @@ -11,6 +11,15 @@ def auto_convert(x): class Define(object): + """Access to firmware constants. + + Examples: + + Define.asDict().get('F_CPU') # AVR frequency + Define.asDict().get('__DATE__') # firmware upload date + + """ + @classmethod @memoized @returns(int) @@ -34,6 +43,7 @@ def value(cls, index): @classmethod @memoized def asDict(cls): + """return all constants and their values in a dictionary.""" d = dict() for i in range(cls.count()): d[cls.name(i)] = cls.value(i) diff --git a/nanpy/pwm.py b/nanpy/pwm.py index 16a7f02..65fba8c 100644 --- a/nanpy/pwm.py +++ b/nanpy/pwm.py @@ -1,5 +1,4 @@ from __future__ import division -from nanpy.memo import memoized from nanpy.arduino import Arduino from nanpy.arduinocore import ArduinoCore from nanpy.define import Define @@ -85,6 +84,9 @@ def __init__(self, dic): class ArduinoPwmPin(object): + + '''Object-oriented representation of the pin PWM functionality + ''' DEFAULT_DIVISOR = 64 def __init__(self, nr): @@ -92,12 +94,15 @@ def __init__(self, nr): self.F_CPU = Define().asDict().get('F_CPU') def reset(self): + '''reset to the PWM default state: default frequency is set + ''' if not self.available: return self.write_divisor(self.DEFAULT_DIVISOR) @property def available(self): + """PWM is available for this pin?""" timer_id = self._timer_id() return timer_id > 0 and timer_id < len(TIMERS_B) # return self.nr in timer_register @@ -107,23 +112,27 @@ def _check(self): raise PwmError('pwm not available for pin: %s' % self.nr) def write_value(self, value): + """same as analogWrite.""" self._check() # assert self.mcu.pins.read_mode(self.nr) == OUTPUT Arduino.analogWrite(self.nr, value) @property def divisors_available(self): + """list of available divisors.""" try: return list(divisor_mapping[self.nr].norm.values()) except KeyError: return [] def read_divisor(self): + """read current divisor.""" self._check() d = divisor_mapping[self.nr] return d.norm[self.read_timer_mode()] def write_divisor(self, value): + """write current divisor.""" self._check() d = divisor_mapping[self.nr] self.write_timer_mode(d.inv[value]) @@ -168,6 +177,7 @@ def calculate_frequency(self, divisor): @property def frequencies_available(self): + """list of available frequencies.""" ls = sorted([self.calculate_frequency(x) for x in self.divisors_available]) return ls @@ -192,7 +202,7 @@ def write_frequency(self, value): frequency = property(read_frequency, write_frequency) def read_wgm(self): - """Waveform generation mode.""" + """read waveform generation mode.""" self._check() rega = self.timer_register_name_a regb = self.timer_register_name_b @@ -239,6 +249,16 @@ def set_high_freq_around_pwm(self, top, fill): OCR1B.value = fill def set_high_freq_around(self, freq): + """set high frequency mode, and try to set frequency as close as + possible. + + available frequencies: F_CPU/N (N=2..65535) + + Example: F_CPU=16000000 (default) -> frequencies=244Hz-8MHz + + TODO: test it on more AVRs, read config from firmware + + """ top = int(self.F_CPU / freq + 0.5) assert 1 < top < (1 << 16) self.set_high_freq_around_pwm(top, int(top / 2)) diff --git a/nanpy/resgister.py b/nanpy/resgister.py index fcfd292..09d6bd4 100644 --- a/nanpy/resgister.py +++ b/nanpy/resgister.py @@ -53,33 +53,72 @@ def name_index_dict(cls): class Register(object): + """Direct access to AVR registers.""" + @classmethod @memoized def names(cls): + """Get all register names as a sorted list.""" return sorted(_Registers.name_index_dict().keys()) def __init__(self, name): + """""" try: self.index = _Registers.name_index_dict()[name] except KeyError: raise ValueError('Unknown register: %s' % name) def read_value(self): + """Read register value. + + Example: + + Register('DDRB').read_value() + + """ return _Registers.read(self.index) def write_value(self, value): + """Write register value. + + Example: + + Register('DDRB').write_value(1) + + """ return _Registers.write(self.index, value) value = property(read_value, write_value) @property def name(self): + """Register name. + + Example: + + Register('DDRB').name + + """ return _Registers.name(self.index) @property def address(self): + """Register address. + + Example: + + Register('DDRB').address + + """ return _Registers.address(self.index) @property def size(self): + """Register size in bytes. 1 or 2. + + Example: + + Register('DDRB').size + + """ return _Registers.size(self.index) diff --git a/nanpy/watchdog.py b/nanpy/watchdog.py index ec11094..4b001b4 100644 --- a/nanpy/watchdog.py +++ b/nanpy/watchdog.py @@ -3,6 +3,12 @@ class Watchdog(object): + + """Direct access to watchdog timer. + + Details: http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html + + """ WDTO_15MS = 0 WDTO_30MS = 1 WDTO_60MS = 2 @@ -17,20 +23,32 @@ class Watchdog(object): @classmethod @arduinoclassmethod def wdt_reset(cls): - pass + """Reset the watchdog timer. + + When the watchdog timer is enabled, + a call to this instruction is required before the timer expires, + otherwise a watchdog-initiated device reset will occur. + + """ @classmethod @arduinoclassmethod - def wdt_enable(cls, value): - pass + def wdt_enable(cls, timeout): + """Enable the watchdog timer, configuring it for expiry after + timeout.""" @classmethod @arduinoclassmethod def wdt_disable(cls): - pass + """Disable the watchdog timer, if possible.""" @classmethod def soft_reset(cls): - '''http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset''' + """Resets the AVR, the registers will be reset to their known, default + settings. + + Details: http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset + + """ cls.wdt_enable(cls.WDTO_15MS) time.sleep(0.1) diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..65fcecf --- /dev/null +++ b/tests/README.md @@ -0,0 +1,8 @@ +Testing +============ + + - Install tox (http://tox.readthedocs.org) + - connect Arduino with Nanpy firmware + - run tox in project directory: + + tox \ No newline at end of file From cab2a5320502b0365347af7df35a7df65a95a5fc Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 16:28:09 +0100 Subject: [PATCH 133/344] rafactor baudrate into variable (#10) --- nanpy/serialmanager.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 9f82981..2dace46 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -3,6 +3,9 @@ import fnmatch import sys +DEFAULT_BAUDRATE = 9600 + + def _auto_detect_serial_unix(preferred_list=['*']): import glob glist = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') @@ -33,17 +36,18 @@ def readline(self): class SerialManager(object): - def __init__(self): + def __init__(self, baudrate=DEFAULT_BAUDRATE): + self.baudrate = baudrate available_ports = _auto_detect_serial_unix() try: - self._serial = serial.Serial(available_ports[0], 9600, timeout=1) + self._serial = serial.Serial(available_ports[0], self.baudrate, timeout=1) time.sleep(2) except: print("Error trying to connect to Arduino") self._serial = NoneSerialManager() def connect(self, device): - self._serial = serial.Serial(device, 9600) + self._serial = serial.Serial(device, self.baudrate) time.sleep(2) def write(self, value): From 6f97e4dbbcf693a338d9dff46631f46a3f400d41 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 16:50:57 +0100 Subject: [PATCH 134/344] raise exception if there is no reply on serial line (#10) --- nanpy/serialmanager.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 2dace46..7816713 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -6,6 +6,10 @@ DEFAULT_BAUDRATE = 9600 +class SerialManagerError(Exception): + pass + + def _auto_detect_serial_unix(preferred_list=['*']): import glob glist = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') @@ -47,15 +51,19 @@ def __init__(self, baudrate=DEFAULT_BAUDRATE): self._serial = NoneSerialManager() def connect(self, device): - self._serial = serial.Serial(device, self.baudrate) + self._serial = serial.Serial(device, self.baudrate, timeout=1) time.sleep(2) def write(self, value): self._serial.write(bytes(value, 'latin-1')) def readline(self): - return self._serial.readline().decode() - + s = self._serial.readline().decode() + if not len(s): + raise SerialManagerError('Serial timeout!') + return s + + class SerialManagerPy2(SerialManager): def __init__(self): From 42896085f5ca24ef8bc43ff00063bda7c25c3c02 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 16:56:03 +0100 Subject: [PATCH 135/344] serial port auto-detection is optional --- nanpy/serialmanager.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 7816713..0faf1be 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -40,15 +40,18 @@ def readline(self): class SerialManager(object): - def __init__(self, baudrate=DEFAULT_BAUDRATE): + def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): self.baudrate = baudrate - available_ports = _auto_detect_serial_unix() - try: - self._serial = serial.Serial(available_ports[0], self.baudrate, timeout=1) - time.sleep(2) - except: - print("Error trying to connect to Arduino") - self._serial = NoneSerialManager() + if device: + self.connect(device) + else: + # auto detection? + available_ports = _auto_detect_serial_unix() + try: + self.connect(available_ports[0]) + except: + print("Error trying to connect to Arduino") + self._serial = NoneSerialManager() def connect(self, device): self._serial = serial.Serial(device, self.baudrate, timeout=1) From ed0ebd84de94cf44f14bd07eebf0e044f40e0f8b Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 17:03:31 +0100 Subject: [PATCH 136/344] add /dev/ttyS0 and /dev/ttyS1 to port auto-detection (#10) --- nanpy/serialmanager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 0faf1be..21a6373 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -13,6 +13,7 @@ class SerialManagerError(Exception): def _auto_detect_serial_unix(preferred_list=['*']): import glob glist = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glist += ['/dev/ttyS0', '/dev/ttyS1'] ret = [] for d in glist: From e87fa5963175d0d66d172dc60c3b30a418f4d831 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 17:09:58 +0100 Subject: [PATCH 137/344] firmware configuration in cfg.h (#10) --- firmware/Nanpy/ComChannel.h | 2 +- firmware/Nanpy/cfg.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 firmware/Nanpy/cfg.h diff --git a/firmware/Nanpy/ComChannel.h b/firmware/Nanpy/ComChannel.h index 258b285..90876cc 100755 --- a/firmware/Nanpy/ComChannel.h +++ b/firmware/Nanpy/ComChannel.h @@ -1,7 +1,7 @@ #ifndef COM_CHANNEL #define COM_CHANNEL -#define BAUDRATE 9600 +#include "cfg.h" #include diff --git a/firmware/Nanpy/cfg.h b/firmware/Nanpy/cfg.h new file mode 100644 index 0000000..67abbb1 --- /dev/null +++ b/firmware/Nanpy/cfg.h @@ -0,0 +1,3 @@ +#pragma once + +#define BAUDRATE 9600 From 58a2c35a777c64a681622d8556168428968bba35 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 18 Dec 2013 17:10:25 +0100 Subject: [PATCH 138/344] default baudrate=115200 (#10) --- firmware/Nanpy/cfg.h | 2 +- nanpy/serialmanager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/Nanpy/cfg.h b/firmware/Nanpy/cfg.h index 67abbb1..ecbcc66 100644 --- a/firmware/Nanpy/cfg.h +++ b/firmware/Nanpy/cfg.h @@ -1,3 +1,3 @@ #pragma once -#define BAUDRATE 9600 +#define BAUDRATE 115200 diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 21a6373..71d986c 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -3,7 +3,7 @@ import fnmatch import sys -DEFAULT_BAUDRATE = 9600 +DEFAULT_BAUDRATE = 115200 class SerialManagerError(Exception): From b4d41f9bbea036e6a5f7b9c9110c1ca81e3a5e2c Mon Sep 17 00:00:00 2001 From: Laurent Desarmes Date: Sat, 28 Dec 2013 18:00:53 +0100 Subject: [PATCH 139/344] add getBool method --- firmware/Nanpy/MethodDescriptor.cpp | 4 ++++ firmware/Nanpy/MethodDescriptor.h | 1 + 2 files changed, 5 insertions(+) diff --git a/firmware/Nanpy/MethodDescriptor.cpp b/firmware/Nanpy/MethodDescriptor.cpp index 1fa3cf8..f962acf 100755 --- a/firmware/Nanpy/MethodDescriptor.cpp +++ b/firmware/Nanpy/MethodDescriptor.cpp @@ -32,6 +32,10 @@ int nanpy::MethodDescriptor::getNArgs() { return this->n_args; }; +bool nanpy::MethodDescriptor::getBool(int n) { + return this->stack[n] == "True" ? true : false; +}; + int nanpy::MethodDescriptor::getInt(int n) { return atoi(this->stack[n]); }; diff --git a/firmware/Nanpy/MethodDescriptor.h b/firmware/Nanpy/MethodDescriptor.h index ad3e89c..e8bc793 100644 --- a/firmware/Nanpy/MethodDescriptor.h +++ b/firmware/Nanpy/MethodDescriptor.h @@ -18,6 +18,7 @@ namespace nanpy { int getNArgs(); char* getClass(); int getObjectId(); + bool getBool(int n); int getInt(int n); float getFloat(int n); double getDouble(int n); From ee7f314a0b7863d5f70e88ec3ff50535cbbfc350 Mon Sep 17 00:00:00 2001 From: Laurent Desarmes Date: Sat, 28 Dec 2013 18:01:41 +0100 Subject: [PATCH 140/344] support for the DHT sensor library https://github.com/adafruit/DHT-sensor-library --- firmware/Nanpy/DHTClass.cpp | 29 ++++ firmware/Nanpy/DHTClass.h | 18 ++ firmware/Nanpy/Nanpy.ino | 3 + firmware/Nanpy/libraries/DHTsensor/DHT.cpp | 161 ++++++++++++++++++ firmware/Nanpy/libraries/DHTsensor/DHT.h | 39 +++++ firmware/Nanpy/libraries/DHTsensor/README.txt | 3 + .../examples/DHTtester/DHTtester.pde | 44 +++++ nanpy/__init__.py | 1 + nanpy/dht.py | 28 +++ 9 files changed, 326 insertions(+) create mode 100644 firmware/Nanpy/DHTClass.cpp create mode 100644 firmware/Nanpy/DHTClass.h create mode 100644 firmware/Nanpy/libraries/DHTsensor/DHT.cpp create mode 100644 firmware/Nanpy/libraries/DHTsensor/DHT.h create mode 100644 firmware/Nanpy/libraries/DHTsensor/README.txt create mode 100644 firmware/Nanpy/libraries/DHTsensor/examples/DHTtester/DHTtester.pde create mode 100644 nanpy/dht.py diff --git a/firmware/Nanpy/DHTClass.cpp b/firmware/Nanpy/DHTClass.cpp new file mode 100644 index 0000000..9585f68 --- /dev/null +++ b/firmware/Nanpy/DHTClass.cpp @@ -0,0 +1,29 @@ +#include +#include +#include "DHTClass.h" +#include + +void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { + if (strcmp(m->getClass(), "DHT") == 0) { + + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + v.insert(new DHT (m->getInt(0), m->getInt(1), m->getInt(2))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "begin") == 0) { + v[m->getObjectId()]->begin(); + m->returns(0); + } + + if (strcmp(m->getName(), "readHumidity") == 0) { + m->returns(v[m->getObjectId()]->readHumidity()); + } + + if (strcmp(m->getName(), "readTemperature") == 0) { + m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); + } + } +}; diff --git a/firmware/Nanpy/DHTClass.h b/firmware/Nanpy/DHTClass.h new file mode 100644 index 0000000..86e8823 --- /dev/null +++ b/firmware/Nanpy/DHTClass.h @@ -0,0 +1,18 @@ +#ifndef DHT_CLASS +#define DHT_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class DHT; + +namespace nanpy { + class DHTClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + + }; +} + +#endif diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index cba09d2..69dd3e5 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -5,6 +5,7 @@ #include #include #include +#include #include "BaseClass.h" #include "ArduinoClass.h" @@ -18,6 +19,7 @@ #include "MethodDescriptor.h" #include "ComChannel.h" #include "EEPROMClass.h" +#include "DHTClass.h" #include "DefineClass.h" #include "ArduinoCoreClass.h" @@ -51,6 +53,7 @@ void setup() { REGISTER_CLASS(ArduinoCoreClass); // 0.7 k REGISTER_CLASS(WatchdogClass); // 0.2 k REGISTER_CLASS(RegisterClass); // 1.5 k + REGISTER_CLASS(DHTClass); ComChannel::connect(); } diff --git a/firmware/Nanpy/libraries/DHTsensor/DHT.cpp b/firmware/Nanpy/libraries/DHTsensor/DHT.cpp new file mode 100644 index 0000000..efa1d39 --- /dev/null +++ b/firmware/Nanpy/libraries/DHTsensor/DHT.cpp @@ -0,0 +1,161 @@ +/* DHT library + +MIT license +written by Adafruit Industries +*/ + +#include "DHT.h" + +DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { + _pin = pin; + _type = type; + _count = count; + firstreading = true; +} + +void DHT::begin(void) { + // set up the pins! + pinMode(_pin, INPUT); + digitalWrite(_pin, HIGH); + _lastreadtime = 0; +} + +//boolean S == Scale. True == Farenheit; False == Celcius +float DHT::readTemperature(bool S) { + float f; + + if (read()) { + switch (_type) { + case DHT11: + f = data[2]; + if(S) + f = convertCtoF(f); + + return f; + case DHT22: + case DHT21: + f = data[2] & 0x7F; + f *= 256; + f += data[3]; + f /= 10; + if (data[2] & 0x80) + f *= -1; + if(S) + f = convertCtoF(f); + + return f; + } + } + Serial.print("Read fail"); + return NAN; +} + +float DHT::convertCtoF(float c) { + return c * 9 / 5 + 32; +} + +float DHT::readHumidity(void) { + float f; + if (read()) { + switch (_type) { + case DHT11: + f = data[0]; + return f; + case DHT22: + case DHT21: + f = data[0]; + f *= 256; + f += data[1]; + f /= 10; + return f; + } + } + Serial.print("Read fail"); + return NAN; +} + + +boolean DHT::read(void) { + uint8_t laststate = HIGH; + uint8_t counter = 0; + uint8_t j = 0, i; + unsigned long currenttime; + + // pull the pin high and wait 250 milliseconds + digitalWrite(_pin, HIGH); + delay(250); + + currenttime = millis(); + if (currenttime < _lastreadtime) { + // ie there was a rollover + _lastreadtime = 0; + } + if (!firstreading && ((currenttime - _lastreadtime) < 2000)) { + return true; // return last correct measurement + //delay(2000 - (currenttime - _lastreadtime)); + } + firstreading = false; + /* + Serial.print("Currtime: "); Serial.print(currenttime); + Serial.print(" Lasttime: "); Serial.print(_lastreadtime); + */ + _lastreadtime = millis(); + + data[0] = data[1] = data[2] = data[3] = data[4] = 0; + + // now pull it low for ~20 milliseconds + pinMode(_pin, OUTPUT); + digitalWrite(_pin, LOW); + delay(20); + cli(); + digitalWrite(_pin, HIGH); + delayMicroseconds(40); + pinMode(_pin, INPUT); + + // read in timings + for ( i=0; i< MAXTIMINGS; i++) { + counter = 0; + while (digitalRead(_pin) == laststate) { + counter++; + delayMicroseconds(1); + if (counter == 255) { + break; + } + } + laststate = digitalRead(_pin); + + if (counter == 255) break; + + // ignore first 3 transitions + if ((i >= 4) && (i%2 == 0)) { + // shove each bit into the storage bytes + data[j/8] <<= 1; + if (counter > _count) + data[j/8] |= 1; + j++; + } + + } + + sei(); + + /* + Serial.println(j, DEC); + Serial.print(data[0], HEX); Serial.print(", "); + Serial.print(data[1], HEX); Serial.print(", "); + Serial.print(data[2], HEX); Serial.print(", "); + Serial.print(data[3], HEX); Serial.print(", "); + Serial.print(data[4], HEX); Serial.print(" =? "); + Serial.println(data[0] + data[1] + data[2] + data[3], HEX); + */ + + // check we read 40 bits and that the checksum matches + if ((j >= 40) && + (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) { + return true; + } + + + return false; + +} diff --git a/firmware/Nanpy/libraries/DHTsensor/DHT.h b/firmware/Nanpy/libraries/DHTsensor/DHT.h new file mode 100644 index 0000000..1c78c87 --- /dev/null +++ b/firmware/Nanpy/libraries/DHTsensor/DHT.h @@ -0,0 +1,39 @@ +#ifndef DHT_H +#define DHT_H +#if ARDUINO >= 100 + #include "Arduino.h" +#else + #include "WProgram.h" +#endif + +/* DHT library + +MIT license +written by Adafruit Industries +*/ + +// how many timing transitions we need to keep track of. 2 * number bits + extra +#define MAXTIMINGS 85 + +#define DHT11 11 +#define DHT22 22 +#define DHT21 21 +#define AM2301 21 + +class DHT { + private: + uint8_t data[6]; + uint8_t _pin, _type, _count; + boolean read(void); + unsigned long _lastreadtime; + boolean firstreading; + + public: + DHT(uint8_t pin, uint8_t type, uint8_t count=6); + void begin(void); + float readTemperature(bool S=false); + float convertCtoF(float); + float readHumidity(void); + +}; +#endif diff --git a/firmware/Nanpy/libraries/DHTsensor/README.txt b/firmware/Nanpy/libraries/DHTsensor/README.txt new file mode 100644 index 0000000..4dfcbab --- /dev/null +++ b/firmware/Nanpy/libraries/DHTsensor/README.txt @@ -0,0 +1,3 @@ +This is an Arduino library for the DHT series of low cost temperature/humidity sensors. + +To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT. Check that the DHT folder contains DHT.cpp and DHT.h. Place the DHT library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. \ No newline at end of file diff --git a/firmware/Nanpy/libraries/DHTsensor/examples/DHTtester/DHTtester.pde b/firmware/Nanpy/libraries/DHTsensor/examples/DHTtester/DHTtester.pde new file mode 100644 index 0000000..8f40790 --- /dev/null +++ b/firmware/Nanpy/libraries/DHTsensor/examples/DHTtester/DHTtester.pde @@ -0,0 +1,44 @@ +// Example testing sketch for various DHT humidity/temperature sensors +// Written by ladyada, public domain + +#include "DHT.h" + +#define DHTPIN 2 // what pin we're connected to + +// Uncomment whatever type you're using! +//#define DHTTYPE DHT11 // DHT 11 +#define DHTTYPE DHT22 // DHT 22 (AM2302) +//#define DHTTYPE DHT21 // DHT 21 (AM2301) + +// Connect pin 1 (on the left) of the sensor to +5V +// Connect pin 2 of the sensor to whatever your DHTPIN is +// Connect pin 4 (on the right) of the sensor to GROUND +// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor + +DHT dht(DHTPIN, DHTTYPE); + +void setup() { + Serial.begin(9600); + Serial.println("DHTxx test!"); + + dht.begin(); +} + +void loop() { + // Reading temperature or humidity takes about 250 milliseconds! + // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) + float h = dht.readHumidity(); + float t = dht.readTemperature(); + + // check if returns are valid, if they are NaN (not a number) then something went wrong! + if (isnan(t) || isnan(h)) { + Serial.println("Failed to read from DHT"); + } else { + Serial.print("Humidity: "); + Serial.print(h); + Serial.print(" %\t"); + Serial.print("Temperature: "); + Serial.print(t); + Serial.println(" *C"); + } +} diff --git a/nanpy/__init__.py b/nanpy/__init__.py index abc7651..738dcfd 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -22,3 +22,4 @@ from nanpy.dallastemperature import DallasTemperature from nanpy.tone import Tone from nanpy.capacitivesensor import CapacitiveSensor +from nanpy.dht import DHT diff --git a/nanpy/dht.py b/nanpy/dht.py new file mode 100644 index 0000000..a82a08d --- /dev/null +++ b/nanpy/dht.py @@ -0,0 +1,28 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import (arduinoobjectmethod, returns) + +class DHT(ArduinoObject): + + DHT11 = 11 + DHT22 = 22 + DHT21 = 21 + AM2301 = 21 + + def __init__(self, pin, _type, count = 6): + ArduinoObject.__init__(self) + self.id = self.call('new', pin, _type, count) + + @returns(int) + @arduinoobjectmethod + def begin(self): + pass + + @returns(float) + @arduinoobjectmethod + def readHumidity(self): + pass + + @returns(float) + @arduinoobjectmethod + def readTemperature(self, value = False): + pass From ce69deab20cf91510cbbc76854ebe2e8f51839b4 Mon Sep 17 00:00:00 2001 From: Laurent Desarmes Date: Sun, 29 Dec 2013 14:01:14 +0100 Subject: [PATCH 141/344] a simple example to read from a DHT sensor --- examples/dht.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 examples/dht.py diff --git a/examples/dht.py b/examples/dht.py new file mode 100755 index 0000000..363a371 --- /dev/null +++ b/examples/dht.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +# a simple example to read from a DHT sensor + +from nanpy import DHT + +# http://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor +# DHT sensor connected to digital pin 10 +dht = DHT(10,DHT.DHT22) + +print("temperature is %f degrees Celcius" % dht.readTemperature()) +print("temperature is %f degrees Celcius" % dht.readTemperature(False)) +print("temperature is %f degrees Fahrenheit" % dht.readTemperature(True)) +print("humidity is %f %%" % dht.readHumidity()) + From f110873f6d258ee8b57a583d11b78599199f81ff Mon Sep 17 00:00:00 2001 From: Laurent Desarmes Date: Sun, 29 Dec 2013 14:02:57 +0100 Subject: [PATCH 142/344] begin is called when instantiating the class --- firmware/Nanpy/DHTClass.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/firmware/Nanpy/DHTClass.cpp b/firmware/Nanpy/DHTClass.cpp index 9585f68..65b1284 100644 --- a/firmware/Nanpy/DHTClass.cpp +++ b/firmware/Nanpy/DHTClass.cpp @@ -4,26 +4,28 @@ #include void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { - if (strcmp(m->getClass(), "DHT") == 0) { + if (strcmp(m->getClass(), "DHT") == 0) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); - if (strcmp(m->getName(),"new") == 0) { - v.insert(new DHT (m->getInt(0), m->getInt(1), m->getInt(2))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "begin") == 0) { - v[m->getObjectId()]->begin(); - m->returns(0); - } + if (strcmp(m->getName(),"new") == 0) { + DHT* dht; + if (m->getNArgs() == 3) { + dht = new DHT (m->getInt(0), m->getInt(1), m->getInt(2)); + } else { + dht = new DHT (m->getInt(0), m->getInt(1)); + } + dht->begin(); + v.insert(dht); + m->returns(v.getLastIndex()); + } - if (strcmp(m->getName(), "readHumidity") == 0) { - m->returns(v[m->getObjectId()]->readHumidity()); - } + if (strcmp(m->getName(), "readHumidity") == 0) { + m->returns(v[m->getObjectId()]->readHumidity()); + } - if (strcmp(m->getName(), "readTemperature") == 0) { - m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); - } + if (strcmp(m->getName(), "readTemperature") == 0) { + m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); } + } }; From 7207af210a179f046085d44d2e052a65437d78d2 Mon Sep 17 00:00:00 2001 From: Laurent Desarmes Date: Sun, 29 Dec 2013 14:03:54 +0100 Subject: [PATCH 143/344] strcmp !!! :-) --- firmware/Nanpy/MethodDescriptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/Nanpy/MethodDescriptor.cpp b/firmware/Nanpy/MethodDescriptor.cpp index f962acf..3b4002d 100755 --- a/firmware/Nanpy/MethodDescriptor.cpp +++ b/firmware/Nanpy/MethodDescriptor.cpp @@ -33,7 +33,7 @@ int nanpy::MethodDescriptor::getNArgs() { }; bool nanpy::MethodDescriptor::getBool(int n) { - return this->stack[n] == "True" ? true : false; + return strcmp(this->stack[n], "True") == 0 ? true : false; }; int nanpy::MethodDescriptor::getInt(int n) { From 0b657c35564a2d2b9dcf8ae64277668eb12236cf Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 16:46:36 +0100 Subject: [PATCH 144/344] fix setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 54a3b14..a28be48 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,6 @@ packages = find_packages(), keywords= "arduino library prototype", install_requires=[ - "python-serial", + "pyserial", ], zip_safe = True) From e46a60d5ad52646b1c6a7f94632852182690ddb3 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 17:51:56 +0100 Subject: [PATCH 145/344] more doc --- examples/clock.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/clock.py b/examples/clock.py index c89ab36..e87d70d 100755 --- a/examples/clock.py +++ b/examples/clock.py @@ -13,7 +13,9 @@ time = int(response.tx_time) -lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) +pins = [7, 8, 9, 10, 11, 12] +cols, rows = 16, 2 +lcd = Lcd(pins, [cols, rows]) while (1): lcd.setCursor(0, 0) From a71dd1f451a15027fbb530f32de49556b3791a76 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 17:48:01 +0100 Subject: [PATCH 146/344] fix DHT lib path header name and directory name should be the same --- firmware/Nanpy/libraries/{DHTsensor => DHT}/DHT.cpp | 0 firmware/Nanpy/libraries/{DHTsensor => DHT}/DHT.h | 0 firmware/Nanpy/libraries/{DHTsensor => DHT}/README.txt | 0 .../libraries/{DHTsensor => DHT}/examples/DHTtester/DHTtester.pde | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename firmware/Nanpy/libraries/{DHTsensor => DHT}/DHT.cpp (100%) rename firmware/Nanpy/libraries/{DHTsensor => DHT}/DHT.h (100%) rename firmware/Nanpy/libraries/{DHTsensor => DHT}/README.txt (100%) rename firmware/Nanpy/libraries/{DHTsensor => DHT}/examples/DHTtester/DHTtester.pde (100%) diff --git a/firmware/Nanpy/libraries/DHTsensor/DHT.cpp b/firmware/Nanpy/libraries/DHT/DHT.cpp similarity index 100% rename from firmware/Nanpy/libraries/DHTsensor/DHT.cpp rename to firmware/Nanpy/libraries/DHT/DHT.cpp diff --git a/firmware/Nanpy/libraries/DHTsensor/DHT.h b/firmware/Nanpy/libraries/DHT/DHT.h similarity index 100% rename from firmware/Nanpy/libraries/DHTsensor/DHT.h rename to firmware/Nanpy/libraries/DHT/DHT.h diff --git a/firmware/Nanpy/libraries/DHTsensor/README.txt b/firmware/Nanpy/libraries/DHT/README.txt similarity index 100% rename from firmware/Nanpy/libraries/DHTsensor/README.txt rename to firmware/Nanpy/libraries/DHT/README.txt diff --git a/firmware/Nanpy/libraries/DHTsensor/examples/DHTtester/DHTtester.pde b/firmware/Nanpy/libraries/DHT/examples/DHTtester/DHTtester.pde similarity index 100% rename from firmware/Nanpy/libraries/DHTsensor/examples/DHTtester/DHTtester.pde rename to firmware/Nanpy/libraries/DHT/examples/DHTtester/DHTtester.pde From 6e886c81130a7c5fb5bfdbd392bc69384d6e5178 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 17:56:42 +0100 Subject: [PATCH 147/344] restore makefiles for testing --- firmware/Nanpy/Makefile | 1 + firmware/Nanpy/arduino.mk | 447 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 448 insertions(+) create mode 100644 firmware/Nanpy/Makefile create mode 100644 firmware/Nanpy/arduino.mk diff --git a/firmware/Nanpy/Makefile b/firmware/Nanpy/Makefile new file mode 100644 index 0000000..29ebe54 --- /dev/null +++ b/firmware/Nanpy/Makefile @@ -0,0 +1 @@ +include arduino.mk diff --git a/firmware/Nanpy/arduino.mk b/firmware/Nanpy/arduino.mk new file mode 100644 index 0000000..3028d5d --- /dev/null +++ b/firmware/Nanpy/arduino.mk @@ -0,0 +1,447 @@ +#_______________________________________________________________________________ +# +# edam's Arduino makefile +#_______________________________________________________________________________ +# version 0.5 +# +# Copyright (C) 2011, 2012, 2013 Tim Marston . +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +#_______________________________________________________________________________ +# +# +# This is a general purpose makefile for use with Arduino hardware and +# software. It works with the arduino-1.0 and later software releases. It +# should work GNU/Linux and OS X. To download the latest version of this +# makefile visit the following website where you can also find documentation on +# it's use. (The following text can only really be considered a reference.) +# +# http://ed.am/dev/make/arduino-mk +# +# This makefile can be used as a drop-in replacement for the Arduino IDE's +# build system. To use it, just copy arduino.mk in to your project directory. +# Or, you could save it somewhere (I keep mine at ~/src/arduino.mk) and create +# a symlink to it in your project directory, named "Makefile". For example: +# +# $ ln -s ~/src/arduino.mk Makefile +# +# The Arduino software (version 1.0 or later) is required. On GNU/Linux you +# can probably install the software from your package manager. If you are +# using Debian (or a derivative), try `apt-get install arduino`. Otherwise, +# you can download the Arduino software manually from http://arduino.cc/. It +# is suggested that you install it at ~/opt/arduino (or /Applications on OS X) +# if you are unsure. +# +# If you downloaded the Arduino software manually and unpacked it somewhere +# other than ~/opt/arduino (or /Applications), you will need to set up the +# ARDUINODIR environment variable to be the path where you unpacked it. (If +# unset, ARDUINODIR defaults to some sensible places). You could set this in +# your ~/.profile by adding something like this: +# +# export ARDUINODIR=~/somewhere/arduino-1.0 +# +# For each project, you will also need to set BOARD to the type of Arduino +# you're building for. Type `make boards` for a list of acceptable values. +# For example: +# +# $ export BOARD=uno +# $ make +# +# You may also need to set SERIALDEV if it is not detected correctly. +# +# The presence of a .ino (or .pde) file causes the arduino.mk to automatically +# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp +# files in the project directory (or any "util" or "utility" subdirectories) +# are automatically included in the build and are scanned for Arduino libraries +# that have been #included. Note, there can only be one .ino (or .pde) file in +# a project directory and if you want to be compatible with the Arduino IDE, it +# should be called the same as the directory name. +# +# Alternatively, if you want to manually specify build variables, create a +# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. +# (There is no need to define TARGET). You can also specify the BOARD here, if +# the project has a specific one. Here is an example Makefile: +# +# SOURCES := main.cc other.cc +# LIBRARIES := EEPROM +# BOARD := pro5v +# include ~/src/arduino.mk +# +# Here is a complete list of configuration parameters: +# +# ARDUINODIR The path where the Arduino software is installed on your system. +# +# ARDUINOCONST The Arduino software version, as an integer, used to define the +# ARDUINO version constant. This defaults to 100 if undefined. +# +# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess +# based on where avrdude is. If set empty, no avrdude.conf is +# passed to avrdude (so the system default is used). +# +# AVRDUDEFLAGS Specify any additional flags for avrdude. The usual flags, +# required to build the project, will be appended to this. +# +# AVRTOOLSPATH A space-separated list of directories that is searched in order +# when looking for the avr build tools. This defaults to PATH, +# followed by subdirectories in ARDUINODIR. +# +# BOARD Specify a target board type. Run `make boards` to see available +# board types. +# +# CPPFLAGS Specify any additional flags for the compiler. The usual flags, +# required to build the project, will be appended to this. +# +# LINKFLAGS Specify any additional flags for the linker. The usual flags, +# required to build the project, will be appended to this. +# +# LIBRARIES A list of Arduino libraries to build and include. This is set +# automatically if a .ino (or .pde) is found. +# +# LIBRARYPATH A space-separated list of directories that is searched in order +# when looking for Arduino libraries. This defaults to "libs", +# "libraries" (in the project directory), then your sketchbook +# "libraries" directory, then the Arduino libraries directory. +# +# SERIALDEV The POSIX device name of the serial device that is the Arduino. +# If unspecified, an attempt is made to guess the name of a +# connected Arduino's serial device, which may work in some cases. +# +# SOURCES A list of all source files of whatever language. The language +# type is determined by the file extension. This is set +# automatically if a .ino (or .pde) is found. +# +# TARGET The name of the target file. This is set automatically if a +# .ino (or .pde) is found, but it is not necessary to set it +# otherwise. +# +# This makefile also defines the following goals for use on the command line +# when you run make: +# +# all This is the default if no goal is specified. It builds the +# target. +# +# target Builds the target. +# +# upload Uploads the target (building it, as necessary) to an attached +# Arduino. +# +# clean Deletes files created during the build. +# +# boards Display a list of available board names, so that you can set the +# BOARD environment variable appropriately. +# +# monitor Start `screen` on the serial device. This is meant to be an +# equivalent to the Arduino serial monitor. +# +# size Displays size information about the built target. +# +# bootloader Burns the bootloader for your board to it. +# +# Builds the specified file, either an object file or the target, +# from those that that would be built for the project. +#_______________________________________________________________________________ +# + +# default arduino software directory, check software exists +ifndef ARDUINODIR +ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino \ + /Applications/Arduino.app/Contents/Resources/Java \ + $(HOME)/Applications/Arduino.app/Contents/Resources/Java)) +endif +ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" +$(error ARDUINODIR is not set correctly; arduino software not found) +endif + +# default arduino version +ARDUINOCONST ?= 100 + +# default path for avr tools +AVRTOOLSPATH ?= $(subst :, , $(PATH)) $(ARDUINODIR)/hardware/tools \ + $(ARDUINODIR)/hardware/tools/avr/bin + +# default path to find libraries +LIBRARYPATH ?= libraries libs $(SKETCHBOOKDIR)/libraries $(ARDUINODIR)/libraries + +# default serial device to a poor guess (something that might be an arduino) +SERIALDEVGUESS := 0 +ifndef SERIALDEV +SERIALDEV := $(firstword $(wildcard \ + /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) +SERIALDEVGUESS := 1 +endif + +# no board? +ifndef BOARD +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is unset. Type 'make boards' to see possible values) +endif +endif +endif + +# obtain board parameters from the arduino boards.txt file +BOARDSFILE := $(ARDUINODIR)/hardware/arduino/boards.txt +readboardsparam = $(shell sed -ne "s/$(BOARD).$(1)=\(.*\)/\1/p" $(BOARDSFILE)) +BOARD_BUILD_MCU := $(call readboardsparam,build.mcu) +BOARD_BUILD_FCPU := $(call readboardsparam,build.f_cpu) +BOARD_BUILD_VARIANT := $(call readboardsparam,build.variant) +BOARD_UPLOAD_SPEED := $(call readboardsparam,upload.speed) +BOARD_UPLOAD_PROTOCOL := $(call readboardsparam,upload.protocol) +BOARD_USB_VID := $(call readboardsparam,build.vid) +BOARD_USB_PID := $(call readboardsparam,build.pid) +BOARD_BOOTLOADER_UNLOCK := $(call readboardsparam,bootloader.unlock_bits) +BOARD_BOOTLOADER_LOCK := $(call readboardsparam,bootloader.lock_bits) +BOARD_BOOTLOADER_LFUSES := $(call readboardsparam,bootloader.low_fuses) +BOARD_BOOTLOADER_HFUSES := $(call readboardsparam,bootloader.high_fuses) +BOARD_BOOTLOADER_EFUSES := $(call readboardsparam,bootloader.extended_fuses) +BOARD_BOOTLOADER_PATH := $(call readboardsparam,bootloader.path) +BOARD_BOOTLOADER_FILE := $(call readboardsparam,bootloader.file) + +# obtain preferences from the IDE's preferences.txt +PREFERENCESFILE := $(firstword $(wildcard \ + $(HOME)/.arduino/preferences.txt $(HOME)/Library/Arduino/preferences.txt)) +ifneq "$(PREFERENCESFILE)" "" +readpreferencesparam = $(shell sed -ne "s/$(1)=\(.*\)/\1/p" $(PREFERENCESFILE)) +SKETCHBOOKDIR := $(call readpreferencesparam,sketchbook.path) +endif + +# invalid board? +ifeq "$(BOARD_BUILD_MCU)" "" +ifneq "$(MAKECMDGOALS)" "boards" +ifneq "$(MAKECMDGOALS)" "clean" +$(error BOARD is invalid. Type 'make boards' to see possible values) +endif +endif +endif + +# auto mode? +INOFILE := $(wildcard *.ino *.pde) +ifdef INOFILE +ifneq "$(words $(INOFILE))" "1" +$(error There is more than one .pde or .ino file in this directory!) +endif + +# automatically determine sources and targeet +TARGET := $(basename $(INOFILE)) +SOURCES := $(INOFILE) \ + $(wildcard *.c *.cc *.cpp *.C) \ + $(wildcard $(addprefix util/, *.c *.cc *.cpp *.C)) \ + $(wildcard $(addprefix utility/, *.c *.cc *.cpp *.C)) + +# automatically determine included libraries +LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \ + $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) + +endif + +# software +findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) +CC := $(call findsoftware,avr-gcc) +CXX := $(call findsoftware,avr-g++) +LD := $(call findsoftware,avr-ld) +AR := $(call findsoftware,avr-ar) +OBJCOPY := $(call findsoftware,avr-objcopy) +AVRDUDE := $(call findsoftware,avrdude) +AVRSIZE := $(call findsoftware,avr-size) + +# directories +ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino +LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \ + $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH))))) +LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS)) + +# files +TARGET := $(if $(TARGET),$(TARGET),a.out) +OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) +DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) +ARDUINOLIB := .lib/arduino.a +ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \ + $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) +BOOTLOADERHEX := $(addprefix \ + $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \ + $(BOARD_BOOTLOADER_FILE)) + +# avrdude confifuration +ifeq "$(AVRDUDECONF)" "" +ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" +AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf +else +AVRDUDECONF := $(wildcard $(AVRDUDE).conf) +endif +endif + +# flags +CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections +CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums +CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) +CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) +CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) +CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR) +CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ +CPPFLAGS += $(addprefix -I , $(LIBRARYDIRS)) +CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep +CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h +AVRDUDEFLAGS += $(addprefix -C , $(AVRDUDECONF)) -DV +AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) +AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) +LINKFLAGS += -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) + +# figure out which arg to use with stty (for OS X, GNU and busybox stty) +STTYFARG := $(shell stty --help 2>&1 | \ + grep -q 'illegal option' && echo -f || echo -F) + +# include dependencies +ifneq "$(MAKECMDGOALS)" "clean" +-include $(DEPFILES) +endif + +# default rule +.DEFAULT_GOAL := all + +#_______________________________________________________________________________ +# RULES + +.PHONY: all target upload clean boards monitor size bootloader + +all: target + +target: $(TARGET).hex + +upload: target + @echo "\nUploading to board..." + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } +ifeq "$(BOARD_BOOTLOADER_PATH)" "caterina" + stty $(STTYFARG) $(SERIALDEV) speed 1200 + sleep 1 +else + stty $(STTYFARG) $(SERIALDEV) hupcl +endif + $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i + +clean: + rm -f $(OBJECTS) + rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ + rm -rf .lib .dep + +boards: + @echo "Available values for BOARD:" + @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDSFILE) | \ + sed -Ee 's/([^.]+)\.name=(.*)/\1 \2/' \ + -e 's/(.{12}) *(.*)/\1 \2/' + +monitor: + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test -n `which screen` || { \ + echo "error: can't find GNU screen, you might need to install it." >&2 \ + exit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + screen $(SERIALDEV) + +size: $(TARGET).elf + echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf + +bootloader: + @echo "Burning bootloader to board..." + @test -n "$(SERIALDEV)" || { \ + echo "error: SERIALDEV could not be determined automatically." >&2; \ + exit 1; } + @test 0 -eq $(SERIALDEVGUESS) || { \ + echo "*GUESSING* at serial device:" $(SERIALDEV); \ + echo; } + stty $(STTYFARG) $(SERIALDEV) hupcl + $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m + $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m + $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m +ifneq "$(BOARD_BOOTLOADER_EFUSES)" "" + $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m +endif +ifneq "$(BOOTLOADERHEX)" "" + $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i +endif + $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m + +# building the target + +$(TARGET).hex: $(TARGET).elf + $(OBJCOPY) -O ihex -R .eeprom $< $@ + +.INTERMEDIATE: $(TARGET).elf + +$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) + $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@ + +%.o: %.c + mkdir -p .dep/$(dir $<) + $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.cpp + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.cc + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.C + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< + +%.o: %.ino + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< + +%.o: %.pde + mkdir -p .dep/$(dir $<) + $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< + +# building the arduino library + +$(ARDUINOLIB): $(ARDUINOLIBOBJS) + $(AR) rcs $@ $? + +.lib/%.c.o: %.c + mkdir -p $(dir $@) + $(COMPILE.c) -o $@ $< + +.lib/%.cpp.o: %.cpp + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +.lib/%.cc.o: %.cc + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +.lib/%.C.o: %.C + mkdir -p $(dir $@) + $(COMPILE.cpp) -o $@ $< + +# Local Variables: +# mode: makefile +# tab-width: 4 +# End: \ No newline at end of file From ef914837c7de64f01bcdf10e4782511f388fee9c Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 17:58:24 +0100 Subject: [PATCH 148/344] new firmware classes: counter, info --- firmware/Nanpy/CounterClass.cpp | 35 +++ firmware/Nanpy/CounterClass.h | 15 + firmware/Nanpy/FreqCount.cpp | 115 ++++++++ firmware/Nanpy/FreqCount.h | 14 + firmware/Nanpy/InfoClass.cpp | 26 ++ firmware/Nanpy/InfoClass.h | 15 + firmware/Nanpy/timers.h | 501 ++++++++++++++++++++++++++++++++ 7 files changed, 721 insertions(+) create mode 100644 firmware/Nanpy/CounterClass.cpp create mode 100644 firmware/Nanpy/CounterClass.h create mode 100644 firmware/Nanpy/FreqCount.cpp create mode 100644 firmware/Nanpy/FreqCount.h create mode 100644 firmware/Nanpy/InfoClass.cpp create mode 100644 firmware/Nanpy/InfoClass.h create mode 100644 firmware/Nanpy/timers.h diff --git a/firmware/Nanpy/CounterClass.cpp b/firmware/Nanpy/CounterClass.cpp new file mode 100644 index 0000000..6a8a6d9 --- /dev/null +++ b/firmware/Nanpy/CounterClass.cpp @@ -0,0 +1,35 @@ +#include "cfg.h" + +#if USE_Counter + +#include "CounterClass.h" +#include "FreqCount.h" + +const char* nanpy::CounterClass::get_firmware_id() +{ + return "Counter"; +} + +void nanpy::CounterClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getName(), "begin") == 0) + { + FreqCount.begin(m->getInt(0)); + m->returns(0); + } + if (strcmp(m->getName(), "available") == 0) + { + m->returns(FreqCount.available()); + } + if (strcmp(m->getName(), "read") == 0) + { + m->returns(FreqCount.read()); + } + if (strcmp(m->getName(), "end") == 0) + { + FreqCount.end(); + m->returns(0); + } +} + +#endif diff --git a/firmware/Nanpy/CounterClass.h b/firmware/Nanpy/CounterClass.h new file mode 100644 index 0000000..d148990 --- /dev/null +++ b/firmware/Nanpy/CounterClass.h @@ -0,0 +1,15 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class CounterClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; + diff --git a/firmware/Nanpy/FreqCount.cpp b/firmware/Nanpy/FreqCount.cpp new file mode 100644 index 0000000..78f000f --- /dev/null +++ b/firmware/Nanpy/FreqCount.cpp @@ -0,0 +1,115 @@ + +/* FreqCount Library, for measuring frequencies + * http://www.pjrc.com/teensy/td_libs_FreqCount.html + * Copyright (c) 2011 PJRC.COM, LLC - Paul Stoffregen + * + * Version 1.0 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// FreqCount Library was so modified that it can be included in Nanpy + +#include "cfg.h" +#ifdef USE_Counter + +#include "FreqCount.h" +#include "timers.h" + +static uint16_t count_msw; +static uint32_t count_prev; +static volatile uint32_t count_output; +static volatile uint8_t count_ready; +static uint16_t gate_length; +static uint16_t gate_index; + + +void FreqCountClass::begin(uint16_t msec) +{ + if (msec < 10) return; + gate_index = 0; + count_msw = 0; + count_prev = 0; + count_ready = 0; + counter_init(); + gate_length = timer_init(msec); + uint8_t status = SREG; + cli(); + timer_start(); + timer_isr_latency_delay(); + counter_start(); + SREG = status; +} + +uint8_t FreqCountClass::available(void) +{ + return count_ready; +} + +uint32_t FreqCountClass::read(void) +{ + uint32_t count; + uint8_t status; + + status = SREG; + cli(); + count = count_output; + count_ready = 0; + SREG = status; + return count; +} + +void FreqCountClass::end(void) +{ + timer_shutdown(); + counter_shutdown(); +} + + +ISR(TIMER_ISR_VECTOR) +{ + uint16_t count_lsw; + uint32_t count; + uint16_t index, length; + + count_lsw = counter_read(); + if (counter_overflow()) { + counter_overflow_reset(); + count_msw++; + } + index = gate_index + 1; + length = gate_length; + if (index >= length) { + gate_index = 0; + count = ((uint32_t)count_msw << 16) + count_lsw; + count_output = count - count_prev; + count_prev = count; + count_ready = 1; + restore_other_interrupts(); + } else { + if (index == length - 1) disable_other_interrupts(); + gate_index = index; + } +} + + +FreqCountClass FreqCount; + + +#endif diff --git a/firmware/Nanpy/FreqCount.h b/firmware/Nanpy/FreqCount.h new file mode 100644 index 0000000..dc74526 --- /dev/null +++ b/firmware/Nanpy/FreqCount.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +class FreqCountClass { +public: + static void begin(uint16_t msec); + static uint8_t available(void); + static uint32_t read(void); + static void end(void); +}; + +extern FreqCountClass FreqCount; + diff --git a/firmware/Nanpy/InfoClass.cpp b/firmware/Nanpy/InfoClass.cpp new file mode 100644 index 0000000..2ec9ec1 --- /dev/null +++ b/firmware/Nanpy/InfoClass.cpp @@ -0,0 +1,26 @@ +#include "cfg.h" + +#if USE_Info + +#include "InfoClass.h" +#include + +const char* nanpy::InfoClass::get_firmware_id() +{ + return "Info"; +} + +void nanpy::InfoClass::elaborate(nanpy::MethodDescriptor* m) +{ + nanpy::SlimArray * classes = Register::get_classes(); + if (strcmp(m->getName(), "count") == 0) + { + m->returns(classes->getSize()); + } + if (strcmp(m->getName(), "name") == 0) + { + int index = m->getInt(0); + m->returns(classes->get(index)->get_firmware_id()); + } +} +#endif diff --git a/firmware/Nanpy/InfoClass.h b/firmware/Nanpy/InfoClass.h new file mode 100644 index 0000000..7f9dce2 --- /dev/null +++ b/firmware/Nanpy/InfoClass.h @@ -0,0 +1,15 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class InfoClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; + diff --git a/firmware/Nanpy/timers.h b/firmware/Nanpy/timers.h new file mode 100644 index 0000000..6a8c3f5 --- /dev/null +++ b/firmware/Nanpy/timers.h @@ -0,0 +1,501 @@ + +#ifndef FreqCount_timers_h_ +#define FreqCount_timers_h_ + +#include +#include + +// Arduino Mega +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + // #define COUNTER_USE_TIMER1 // T1 is not connected + // #define COUNTER_USE_TIMER3 // T3 is not connected + // #define COUNTER_USE_TIMER4 // T4 is not connected + #define COUNTER_USE_TIMER5 // T5 is pin 47 + #define TIMER_USE_TIMER2 + +// Teensy 2.0 +#elif defined(__AVR_ATmega32U4__) + #define COUNTER_USE_TIMER1 // T1 is pin 11 (has LED connected) + #define TIMER_USE_TIMER4H + +// Teensy++ 1.0 & 2.0 +#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) + #define COUNTER_USE_TIMER1 // T1 is pin 6 (has LED connected) + //#define COUNTER_USE_TIMER3 // T3 is pin 13 + #define TIMER_USE_TIMER2 + +// Sanguino +#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) + #define COUNTER_USE_TIMER1 // T1 is pin 1 + #define TIMER_USE_TIMER2 + +// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc +#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) + #define COUNTER_USE_TIMER1 // T1 is pin 5 + #define TIMER_USE_TIMER2 + +#else + #error "Unknown chip, please edit me with timer+counter definitions" + +#endif + + +/**********************************************/ +/* Counter Hardware Abstraction */ +/**********************************************/ + +#if defined(COUNTER_USE_TIMER1) // 16 bit Timer 1 + +static uint8_t saveTCCR1A, saveTCCR1B; + +static inline void counter_init(void) +{ + saveTCCR1A = TCCR1A; + saveTCCR1B = TCCR1B; + TCCR1B = 0; + TCCR1A = 0; + TCNT1 = 0; + TIFR1 = (1<= 16000000L + #define TIMER2_OCR2A_1MS_VAL 124 // div 125 + #define TIMER2_TCCR2B_1MS_VAL (1<> 3; + OCR2A = TIMER2_OCR2A_8MS_VAL; + startTCCR2B = TIMER2_TCCR2B_8MS_VAL; + } else if ((msec & 3) == 0) { + gate_len = msec >> 2; + OCR2A = TIMER2_OCR2A_4MS_VAL; + startTCCR2B = TIMER2_TCCR2B_4MS_VAL; + } else if ((msec & 1) == 0) { + gate_len = msec >> 1; + OCR2A = TIMER2_OCR2A_2MS_VAL; + startTCCR2B = TIMER2_TCCR2B_2MS_VAL; + } else { + gate_len = msec; + OCR2A = TIMER2_OCR2A_1MS_VAL; + startTCCR2B = TIMER2_TCCR2B_1MS_VAL; + } + TIFR2 = (1<: +2 326: 1f 92 push r1 +2 328: 0f 92 push r0 +1 32a: 0f b6 in r0, 0x3f ; 63 +2 32c: 0f 92 push r0 +1 32e: 11 24 eor r1, r1 +2 330: ef 92 push r14 +2 332: ff 92 push r15 +2 334: 0f 93 push r16 +2 336: 1f 93 push r17 +2 338: 2f 93 push r18 +2 33a: 3f 93 push r19 +2 33c: 4f 93 push r20 +2 33e: 5f 93 push r21 +2 340: 8f 93 push r24 +2 342: 9f 93 push r25 +2 344: af 93 push r26 +2 346: bf 93 push r27 +*/ +#define TIMER_LATENCY_CYCLES 34 + + + +#elif defined(TIMER_USE_TIMER4H) // 10 bit "high speed" Timer 4 + +#define TIMER4H_OCR4C_VAL 124 // always div 125 +#if F_CPU == 16000000L + #define TIMER4H_TCCR4B_1MS_VAL (1<> 3; + startTCCR4B = TIMER4H_TCCR4B_8MS_VAL | (1<> 2; + startTCCR4B = TIMER4H_TCCR4B_4MS_VAL | (1<> 1; + startTCCR4B = TIMER4H_TCCR4B_2MS_VAL | (1< Date: Sun, 29 Dec 2013 18:01:56 +0100 Subject: [PATCH 149/344] configurable firmware, optional short strings for communication --- firmware/Nanpy/ArduinoClass.cpp | 26 ++---- firmware/Nanpy/ArduinoClass.h | 1 + firmware/Nanpy/ArduinoCoreClass.cpp | 68 +++----------- firmware/Nanpy/ArduinoCoreClass.h | 1 + firmware/Nanpy/BaseClass.cpp | 6 ++ firmware/Nanpy/BaseClass.h | 21 ++++- firmware/Nanpy/CapacitiveSensorClass.cpp | 15 ++- firmware/Nanpy/CapacitiveSensorClass.h | 1 + firmware/Nanpy/DHTClass.cpp | 14 ++- firmware/Nanpy/DHTClass.h | 1 + firmware/Nanpy/DallasTemperatureClass.cpp | 15 ++- firmware/Nanpy/DallasTemperatureClass.h | 1 + firmware/Nanpy/DefineClass.cpp | 109 ++++++++++++---------- firmware/Nanpy/DefineClass.h | 1 + firmware/Nanpy/EEPROMClass.cpp | 13 ++- firmware/Nanpy/EEPROMClass.h | 1 + firmware/Nanpy/LiquidCrystalClass.cpp | 14 ++- firmware/Nanpy/LiquidCrystalClass.h | 1 + firmware/Nanpy/Nanpy.ino | 38 ++++---- firmware/Nanpy/OneWireClass.cpp | 16 +++- firmware/Nanpy/OneWireClass.h | 1 + firmware/Nanpy/RegisterClass.cpp | 109 ++++++++++++---------- firmware/Nanpy/RegisterClass.h | 1 + firmware/Nanpy/ServoClass.cpp | 16 +++- firmware/Nanpy/ServoClass.h | 1 + firmware/Nanpy/StepperClass.cpp | 17 +++- firmware/Nanpy/StepperClass.h | 1 + firmware/Nanpy/ToneClass.cpp | 14 ++- firmware/Nanpy/ToneClass.h | 1 + firmware/Nanpy/WatchdogClass.cpp | 40 ++++---- firmware/Nanpy/WatchdogClass.h | 1 + firmware/Nanpy/cfg.h | 30 ++++++ 32 files changed, 350 insertions(+), 245 deletions(-) create mode 100644 firmware/Nanpy/BaseClass.cpp diff --git a/firmware/Nanpy/ArduinoClass.cpp b/firmware/Nanpy/ArduinoClass.cpp index f6ad0f8..27ae76d 100644 --- a/firmware/Nanpy/ArduinoClass.cpp +++ b/firmware/Nanpy/ArduinoClass.cpp @@ -3,50 +3,40 @@ #include -byte pinModeRead(int pin) +const char* nanpy::ArduinoClass::get_firmware_id() { - byte bitmask = digitalPinToBitMask(pin); - word port = digitalPinToPort(pin); - byte reg = *portModeRegister(port); - byte mode = (reg & bitmask) ? 1 : 0; - return mode; + return "A"; } void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getClass(), "Arduino") == 0) { - if (strcmp(m->getName(), "digitalWrite") == 0) { + if (strcmp(m->getName(), "dw") == 0) { // digitalWrite digitalWrite(m->getInt(0), m->getInt(1)); m->returns(0); } - if (strcmp(m->getName(), "digitalRead") == 0) { + if (strcmp(m->getName(), "r") == 0) { // digitalRead m->returns(digitalRead(m->getInt(0))); } - if (strcmp(m->getName(), "analogWrite") == 0) { + if (strcmp(m->getName(), "aw") == 0) { // analogWrite analogWrite(m->getInt(0), m->getInt(1)); m->returns(0); } - if (strcmp(m->getName(), "analogRead") == 0) { + if (strcmp(m->getName(), "a") == 0) { // analogRead m->returns(analogRead(m->getInt(0))); } - if (strcmp(m->getName(), "pinMode") == 0) { + if (strcmp(m->getName(), "pm") == 0) { // pinMode pinMode(m->getInt(0), m->getInt(1)); m->returns(0); } - if (strcmp(m->getName(), "pinModeRead") == 0) { - m->returns(pinModeRead(m->getInt(0))); - } - if (strcmp(m->getName(), "delay") == 0) { m->returns(0); } - if (strcmp(m->getName(), "millis") == 0) { + if (strcmp(m->getName(), "m") == 0) { // millis m->returns(millis()); } - } }; diff --git a/firmware/Nanpy/ArduinoClass.h b/firmware/Nanpy/ArduinoClass.h index 34a0a9d..c3ca79a 100644 --- a/firmware/Nanpy/ArduinoClass.h +++ b/firmware/Nanpy/ArduinoClass.h @@ -9,6 +9,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; }; diff --git a/firmware/Nanpy/ArduinoCoreClass.cpp b/firmware/Nanpy/ArduinoCoreClass.cpp index 600b504..55ac6ff 100644 --- a/firmware/Nanpy/ArduinoCoreClass.cpp +++ b/firmware/Nanpy/ArduinoCoreClass.cpp @@ -1,67 +1,29 @@ +#include "cfg.h" + +#if USE_ArduinoCore + #include #include "ArduinoCoreClass.h" #include -#define RETURN_GLOBAL_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x()); } #define RETURN_PIN_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x(m->getInt(0))); } #define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(*x(m->getInt(0))); } -int totalPinCount() +const char* nanpy::ArduinoCoreClass::get_firmware_id() { - // HACK! - for (int i = 0; i < 100; i++) - { - byte x = digitalPinToBitMask(i); - bool ok = false; - for (int j = 0; j < 8; j++) - { - if (x == (1 << j)) - { - ok = true; - break; - } - } - - if (!ok) - { - return i; - } - } - return -1; + return "Core"; } -// http://code.google.com/p/tinkerit/wiki/SecretVoltmeter -long readVcc() -{ - long result; - // Read 1.1V reference against AVcc - ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); - delay(2); // Wait for Vref to settle - ADCSRA |= _BV(ADSC); // Convert - while (bit_is_set(ADCSRA, ADSC)) - ; - result = ADCL; - result |= ADCH << 8; - result = 1126400L / result; // Back-calculate AVcc in mV - return result; -} - - void nanpy::ArduinoCoreClass::elaborate(nanpy::MethodDescriptor* m) { - if (strcmp(m->getClass(), "ArduinoCore") == 0) - { - RETURN_PIN_FUNC(digitalPinToBitMask); - RETURN_PIN_FUNC(digitalPinToPort); - RETURN_PIN_FUNC(digitalPinToTimer); - RETURN_PIN_FUNC(analogInPinToBit); - - RETURN_PORT_FUNC(portModeRegister); - RETURN_PORT_FUNC(portOutputRegister); - RETURN_PORT_FUNC(portInputRegister); - - RETURN_GLOBAL_FUNC(totalPinCount); - RETURN_GLOBAL_FUNC(readVcc); - } + RETURN_PIN_FUNC(digitalPinToBitMask); + RETURN_PIN_FUNC(digitalPinToPort); + RETURN_PIN_FUNC(digitalPinToTimer); + RETURN_PIN_FUNC(analogInPinToBit); + + RETURN_PORT_FUNC(portModeRegister); + RETURN_PORT_FUNC(portOutputRegister); + RETURN_PORT_FUNC(portInputRegister); } +#endif diff --git a/firmware/Nanpy/ArduinoCoreClass.h b/firmware/Nanpy/ArduinoCoreClass.h index cb5e936..df1def5 100644 --- a/firmware/Nanpy/ArduinoCoreClass.h +++ b/firmware/Nanpy/ArduinoCoreClass.h @@ -8,6 +8,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; }; diff --git a/firmware/Nanpy/BaseClass.cpp b/firmware/Nanpy/BaseClass.cpp new file mode 100644 index 0000000..333413f --- /dev/null +++ b/firmware/Nanpy/BaseClass.cpp @@ -0,0 +1,6 @@ + +#include "BaseClass.h" + +using namespace nanpy; + +SlimArray Register::classes; diff --git a/firmware/Nanpy/BaseClass.h b/firmware/Nanpy/BaseClass.h index 59764df..159c402 100644 --- a/firmware/Nanpy/BaseClass.h +++ b/firmware/Nanpy/BaseClass.h @@ -1,6 +1,7 @@ #ifndef BASE_CLASS #define BASE_CLASS +#include "cfg.h" #include "SlimArray.h" #include "MethodDescriptor.h" @@ -10,6 +11,7 @@ namespace nanpy { public: virtual void elaborate( nanpy::MethodDescriptor* m ) = 0; + virtual const char* get_firmware_id() = 0; }; @@ -30,19 +32,29 @@ namespace nanpy { }; - static nanpy::SlimArray classes; class Register { + static nanpy::SlimArray classes; public: template static void registerClass() { - classes.insert((nanpy::BaseClass*)new T()); + nanpy::BaseClass* obj = (nanpy::BaseClass*)new T(); + classes.insert(obj); + } + + static nanpy::SlimArray * get_classes() { + return &classes; } static void elaborate(nanpy::MethodDescriptor* m) { for(int i = 0 ; i < classes.getSize() ; i++) - classes[i]->elaborate(m); + { + if (strcmp(m->getClass(), classes[i]->get_firmware_id()) == 0) + { + classes[i]->elaborate(m); + } + } if(m != NULL) { delete(m); @@ -53,6 +65,7 @@ namespace nanpy { }; } -#define REGISTER_CLASS(cls) Register::registerClass(); +#define REGISTER_CLASS_CONDITIONAL(cls, condition) if(condition) Register::registerClass(); +#define REGISTER_CLASS(cls) REGISTER_CLASS_CONDITIONAL(cls, 1); #endif diff --git a/firmware/Nanpy/CapacitiveSensorClass.cpp b/firmware/Nanpy/CapacitiveSensorClass.cpp index ee758d1..1860d68 100644 --- a/firmware/Nanpy/CapacitiveSensorClass.cpp +++ b/firmware/Nanpy/CapacitiveSensorClass.cpp @@ -1,10 +1,17 @@ +#include "cfg.h" + +#if USE_CapacitiveSensor + #include #include #include "CapacitiveSensorClass.h" -void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getClass(), "CapacitiveSensor") == 0) { +const char* nanpy::CapacitiveSensorClass::get_firmware_id() +{ + return "CapacitiveSensor"; +} +void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { @@ -19,6 +26,6 @@ void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "capacitiveSensorRaw") == 0) { m->returns(v[m->getObjectId()]->capacitiveSensorRaw(m->getInt(0))); } - - } }; + +#endif diff --git a/firmware/Nanpy/CapacitiveSensorClass.h b/firmware/Nanpy/CapacitiveSensorClass.h index 63d3566..92ab2df 100644 --- a/firmware/Nanpy/CapacitiveSensorClass.h +++ b/firmware/Nanpy/CapacitiveSensorClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/DHTClass.cpp b/firmware/Nanpy/DHTClass.cpp index 65b1284..49c41de 100644 --- a/firmware/Nanpy/DHTClass.cpp +++ b/firmware/Nanpy/DHTClass.cpp @@ -1,11 +1,18 @@ +#include "cfg.h" + +#if USE_DHT + #include #include #include "DHTClass.h" #include -void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { - if (strcmp(m->getClass(), "DHT") == 0) { +const char* nanpy::DHTClass::get_firmware_id() +{ + return "DHT"; +} +void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { @@ -27,5 +34,6 @@ void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(), "readTemperature") == 0) { m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); } - } }; + +#endif diff --git a/firmware/Nanpy/DHTClass.h b/firmware/Nanpy/DHTClass.h index 86e8823..b14cd8f 100644 --- a/firmware/Nanpy/DHTClass.h +++ b/firmware/Nanpy/DHTClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/DallasTemperatureClass.cpp b/firmware/Nanpy/DallasTemperatureClass.cpp index 0e11977..80b8941 100644 --- a/firmware/Nanpy/DallasTemperatureClass.cpp +++ b/firmware/Nanpy/DallasTemperatureClass.cpp @@ -1,13 +1,19 @@ +#include "cfg.h" + +#if USE_DallasTemperature + #include #include #include #include "DallasTemperatureClass.h" #include -void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { - - if (strcmp(m->getClass(), "DallasTemperature") == 0) { +const char* nanpy::DallasTemperatureClass::get_firmware_id() +{ + return "DallasTemperature"; +} +void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { @@ -82,6 +88,5 @@ void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "getDeviceCount") == 0) { m->returns(v[m->getObjectId()]->getDeviceCount()); } - - } }; +#endif diff --git a/firmware/Nanpy/DallasTemperatureClass.h b/firmware/Nanpy/DallasTemperatureClass.h index d03b237..30639c5 100644 --- a/firmware/Nanpy/DallasTemperatureClass.h +++ b/firmware/Nanpy/DallasTemperatureClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/DefineClass.cpp b/firmware/Nanpy/DefineClass.cpp index 21b6e4f..328512d 100644 --- a/firmware/Nanpy/DefineClass.cpp +++ b/firmware/Nanpy/DefineClass.cpp @@ -1,3 +1,7 @@ +#include "cfg.h" + +#if USE_Define + #include #include "DefineClass.h" #include @@ -11,7 +15,7 @@ #include "intdefs.h" #undef DEFINE -const char * const name_table[] PROGMEM = +const char * const name_table[] PROGMEM = { // example: // string_A0, @@ -36,64 +40,67 @@ const int32_t value_table[] PROGMEM = #define COUNT_STR_DEFS 4 // __TIME__, __DATE__, __VERSION__, MCU +const char* nanpy::DefineClass::get_firmware_id() +{ + return "D"; +} + void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) { - if (strcmp(m->getClass(), "Define") == 0) + if (strcmp(m->getName(), "c") == 0) // count { - if (strcmp(m->getName(), "count") == 0) - { - m->returns(COUNT_INT_DEFS + COUNT_STR_DEFS); - } - if (strcmp(m->getName(), "name") == 0) + m->returns(COUNT_INT_DEFS + COUNT_STR_DEFS); + } + if (strcmp(m->getName(), "n") == 0) // name + { + int index = m->getInt(0); + switch (index) { - int index = m->getInt(0); - switch (index) - { - case 0: - m->returns("__TIME__"); - break; - case 1: - m->returns("__DATE__"); - break; - case 2: - m->returns("__VERSION__"); - break; - case 3: - m->returns("MCU"); - break; + case 0: + m->returns("__TIME__"); + break; + case 1: + m->returns("__DATE__"); + break; + case 2: + m->returns("__VERSION__"); + break; + case 3: + m->returns("MCU"); + break; - default: - index -= COUNT_STR_DEFS; - char buffer[LONGEST_STRING_IN_INTDEFS_H]; - strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); - m->returns(buffer); - } + default: + index -= COUNT_STR_DEFS; + char buffer[LONGEST_STRING_IN_INTDEFS_H]; + strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); + m->returns(buffer); } - if (strcmp(m->getName(), "value") == 0) + } + if (strcmp(m->getName(), "v") == 0) // value + { + int index = m->getInt(0); + switch (index) { - int index = m->getInt(0); - switch (index) - { - case 0: - m->returns(__TIME__); - break; - case 1: - m->returns(__DATE__); - break; - case 2: - m->returns(__VERSION__); - break; - case 3: - m->returns(MCU); - break; + case 0: + m->returns(__TIME__); + break; + case 1: + m->returns(__DATE__); + break; + case 2: + m->returns(__VERSION__); + break; + case 3: + m->returns(MCU); + break; - default: - index -= COUNT_STR_DEFS; - int32_t value = pgm_read_dword(&(value_table[index])); - m->returns(value); - } + default: + index -= COUNT_STR_DEFS; + int32_t value = pgm_read_dword(&(value_table[index])); + m->returns(value); } - } + } -; + +#endif diff --git a/firmware/Nanpy/DefineClass.h b/firmware/Nanpy/DefineClass.h index 0327fe8..3cd7d0a 100644 --- a/firmware/Nanpy/DefineClass.h +++ b/firmware/Nanpy/DefineClass.h @@ -8,6 +8,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; }; diff --git a/firmware/Nanpy/EEPROMClass.cpp b/firmware/Nanpy/EEPROMClass.cpp index da095da..349f176 100644 --- a/firmware/Nanpy/EEPROMClass.cpp +++ b/firmware/Nanpy/EEPROMClass.cpp @@ -1,9 +1,17 @@ +#include "cfg.h" + +#if USE_EEPROM + #include #include "EEPROMClass.h" #include +const char* nanpy::EEPROMClass::get_firmware_id() +{ + return "EEPROM"; +} + void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getClass(), "EEPROM") == 0) { if (strcmp(m->getName(), "write") == 0) { EEPROM.write(m->getInt(0), m->getInt(1)); m->returns(0); @@ -15,5 +23,6 @@ void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "size") == 0) { m->returns(E2END+1); } - } }; + +#endif diff --git a/firmware/Nanpy/EEPROMClass.h b/firmware/Nanpy/EEPROMClass.h index 1fe20d1..06cae2e 100644 --- a/firmware/Nanpy/EEPROMClass.h +++ b/firmware/Nanpy/EEPROMClass.h @@ -9,6 +9,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/LiquidCrystalClass.cpp b/firmware/Nanpy/LiquidCrystalClass.cpp index f30c871..a75f550 100644 --- a/firmware/Nanpy/LiquidCrystalClass.cpp +++ b/firmware/Nanpy/LiquidCrystalClass.cpp @@ -1,12 +1,19 @@ +#include "cfg.h" + +#if USE_LiquidCrystal + #include #include #include "LiquidCrystalClass.h" #include #include -void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getClass(), "Lcd") == 0) { +const char* nanpy::LiquidCrystalClass::get_firmware_id() +{ + return "Lcd"; +} +void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { @@ -31,6 +38,5 @@ void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); m->returns(0); } - - } }; +#endif diff --git a/firmware/Nanpy/LiquidCrystalClass.h b/firmware/Nanpy/LiquidCrystalClass.h index 8e1e572..4811ced 100644 --- a/firmware/Nanpy/LiquidCrystalClass.h +++ b/firmware/Nanpy/LiquidCrystalClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index 69dd3e5..ff57a33 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -1,3 +1,5 @@ +#include "cfg.h" + #include #include #include @@ -25,6 +27,8 @@ #include "ArduinoCoreClass.h" #include "WatchdogClass.h" #include "RegisterClass.h" +#include "CounterClass.h" +#include "InfoClass.h" #include @@ -38,22 +42,24 @@ void setup() { MCUSR = 0; wdt_disable(); - REGISTER_CLASS(nanpy::EEPROMClass); // 0.3 k - REGISTER_CLASS(ArduinoClass); // 0.8 k - REGISTER_CLASS(LiquidCrystalClass); // 2.3 k - REGISTER_CLASS(OneWireClass); // 1.7 k -// REGISTER_CLASS(DallasTemperatureClass); // 6.1 k - REGISTER_CLASS(StepperClass); // 0.8 k - REGISTER_CLASS(ServoClass); // 2.5 k - REGISTER_CLASS(ToneClass); // 2.2 k - REGISTER_CLASS(CapacitiveSensorClass); // 2.2 k - - // new classes - REGISTER_CLASS(DefineClass); // 0.6 k - REGISTER_CLASS(ArduinoCoreClass); // 0.7 k - REGISTER_CLASS(WatchdogClass); // 0.2 k - REGISTER_CLASS(RegisterClass); // 1.5 k - REGISTER_CLASS(DHTClass); + REGISTER_CLASS(ArduinoClass); // 0.8 k + + REGISTER_CLASS_CONDITIONAL(nanpy::EEPROMClass, USE_EEPROM); // 0.3 k + REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass, USE_LiquidCrystal); // 2.3 k + REGISTER_CLASS_CONDITIONAL(OneWireClass, USE_OneWire); // 1.7 k + REGISTER_CLASS_CONDITIONAL(DallasTemperatureClass, USE_DallasTemperature); // 6.1 k + REGISTER_CLASS_CONDITIONAL(StepperClass, USE_Stepper); // 0.8 k + REGISTER_CLASS_CONDITIONAL(ServoClass, USE_Servo); // 2.5 k + REGISTER_CLASS_CONDITIONAL(ToneClass, USE_Tone); // 2.2 k + REGISTER_CLASS_CONDITIONAL(CapacitiveSensorClass, USE_CapacitiveSensor); // 2.2 k + REGISTER_CLASS_CONDITIONAL(DefineClass, USE_Define); // 0.6 k + REGISTER_CLASS_CONDITIONAL(ArduinoCoreClass, USE_ArduinoCore); // + REGISTER_CLASS_CONDITIONAL(WatchdogClass, USE_Watchdog); // 0.2 k + REGISTER_CLASS_CONDITIONAL(RegisterClass, USE_Register); // 1.5 k + + REGISTER_CLASS_CONDITIONAL(CounterClass, USE_Counter); // + REGISTER_CLASS_CONDITIONAL(InfoClass, USE_Info); // + REGISTER_CLASS_CONDITIONAL(DHTClass, USE_DHT); ComChannel::connect(); } diff --git a/firmware/Nanpy/OneWireClass.cpp b/firmware/Nanpy/OneWireClass.cpp index 37bf799..a0c036a 100644 --- a/firmware/Nanpy/OneWireClass.cpp +++ b/firmware/Nanpy/OneWireClass.cpp @@ -1,11 +1,17 @@ +#include "cfg.h" + +#if USE_OneWire + #include #include "OneWireClass.h" #include -void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { - - if (strcmp(m->getClass(), "OneWire") == 0) { +const char* nanpy::OneWireClass::get_firmware_id() +{ + return "OneWire"; +} +void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(), "new") == 0) { @@ -65,6 +71,6 @@ void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "read") == 0) { m->returns(v[m->getObjectId()]->read()); } - - } }; + +#endif diff --git a/firmware/Nanpy/OneWireClass.h b/firmware/Nanpy/OneWireClass.h index aff3bf9..52e4842 100644 --- a/firmware/Nanpy/OneWireClass.h +++ b/firmware/Nanpy/OneWireClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/RegisterClass.cpp b/firmware/Nanpy/RegisterClass.cpp index 5035ce0..6d576ad 100644 --- a/firmware/Nanpy/RegisterClass.cpp +++ b/firmware/Nanpy/RegisterClass.cpp @@ -1,3 +1,7 @@ +#include "cfg.h" + +#if USE_Register + #include #include "RegisterClass.h" #include @@ -39,68 +43,71 @@ const int REG_COUNT = sizeof(sizeof_list) / sizeof(sizeof_list[0]); #define LONGEST_REGISTER_NAME 21 +const char* nanpy::RegisterClass::get_firmware_id() +{ + return "R"; +} + void nanpy::RegisterClass::elaborate(nanpy::MethodDescriptor* m) { - if (strcmp(m->getClass(), "_Registers") == 0) + if (strcmp(m->getName(), "c") == 0) // count { - if (strcmp(m->getName(), "count") == 0) - { - m->returns(REG_COUNT); - } - else if (strcmp(m->getName(), "name") == 0) - { - word regindex = m->getInt(0); - char buffer[LONGEST_REGISTER_NAME]; - strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[regindex]))); - m->returns(buffer); - } - else - { - word regindex = m->getInt(0); - word regvalue = m->getInt(1); + m->returns(REG_COUNT); + } + else if (strcmp(m->getName(), "n") == 0) // name + { + word regindex = m->getInt(0); + char buffer[LONGEST_REGISTER_NAME]; + strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[regindex]))); + m->returns(buffer); + } + else + { + word regindex = m->getInt(0); + word regvalue = m->getInt(1); - word regaddr = pgm_read_word(®_list[regindex]); - byte regsize = pgm_read_byte(&sizeof_list[regindex]); + word regaddr = pgm_read_word(®_list[regindex]); + byte regsize = pgm_read_byte(&sizeof_list[regindex]); - volatile byte* preg8 = (volatile byte*) regaddr; - volatile word* preg16 = (volatile word*) regaddr; + volatile byte* preg8 = (volatile byte*) regaddr; + volatile word* preg16 = (volatile word*) regaddr; - if (strcmp(m->getName(), "read") == 0) - { - switch (regsize) - { - case 1: - m->returns(*preg8); - break; - case 2: - m->returns(*preg16); - break; - } - } - else if (strcmp(m->getName(), "write") == 0) - { - switch (regsize) - { - case 1: - *preg8 = (byte) regvalue; - break; - case 2: - *preg16 = regvalue; - break; - } - m->returns(0); - } - else if (strcmp(m->getName(), "address") == 0) + if (strcmp(m->getName(), "r") == 0) // read + { + switch (regsize) { - m->returns(regaddr); + case 1: + m->returns(*preg8); + break; + case 2: + m->returns(*preg16); + break; } - else if (strcmp(m->getName(), "size") == 0) + } + else if (strcmp(m->getName(), "w") == 0) // write + { + switch (regsize) { - m->returns(regsize); + case 1: + *preg8 = (byte) regvalue; + break; + case 2: + *preg16 = regvalue; + break; } - + m->returns(0); + } + else if (strcmp(m->getName(), "a") == 0) // address + { + m->returns(regaddr); } + else if (strcmp(m->getName(), "s") == 0) // size + { + m->returns(regsize); + } + } } -; + +#endif diff --git a/firmware/Nanpy/RegisterClass.h b/firmware/Nanpy/RegisterClass.h index a31fb1e..d30bb9c 100644 --- a/firmware/Nanpy/RegisterClass.h +++ b/firmware/Nanpy/RegisterClass.h @@ -7,6 +7,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; }; diff --git a/firmware/Nanpy/ServoClass.cpp b/firmware/Nanpy/ServoClass.cpp index 2bcb788..6dce594 100644 --- a/firmware/Nanpy/ServoClass.cpp +++ b/firmware/Nanpy/ServoClass.cpp @@ -1,11 +1,18 @@ +#include "cfg.h" + +#if USE_Servo + #include #include #include "ServoClass.h" #include -void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getClass(), "Servo") == 0) { +const char* nanpy::ServoClass::get_firmware_id() +{ + return "Servo"; +} +void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { @@ -40,6 +47,7 @@ void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "attached") == 0) { m->returns(v[m->getObjectId()]->attached()); } +} + +#endif - } -}; diff --git a/firmware/Nanpy/ServoClass.h b/firmware/Nanpy/ServoClass.h index 535d7ef..e35fad2 100644 --- a/firmware/Nanpy/ServoClass.h +++ b/firmware/Nanpy/ServoClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/StepperClass.cpp b/firmware/Nanpy/StepperClass.cpp index 1266bed..319344a 100644 --- a/firmware/Nanpy/StepperClass.cpp +++ b/firmware/Nanpy/StepperClass.cpp @@ -1,11 +1,18 @@ +#include "cfg.h" + +#if USE_Stepper + #include #include #include "StepperClass.h" #include -void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { - if (strcmp(m->getClass(), "Stepper") == 0) { +const char* nanpy::StepperClass::get_firmware_id() +{ + return "Stepper"; +} +void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { @@ -23,6 +30,8 @@ void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { v[m->getObjectId()]->step(m->getInt(0)); m->returns(0); } +} + + +#endif - } -}; diff --git a/firmware/Nanpy/StepperClass.h b/firmware/Nanpy/StepperClass.h index bf0382f..7311f17 100644 --- a/firmware/Nanpy/StepperClass.h +++ b/firmware/Nanpy/StepperClass.h @@ -11,6 +11,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/ToneClass.cpp b/firmware/Nanpy/ToneClass.cpp index 1ff7dd9..b810f32 100644 --- a/firmware/Nanpy/ToneClass.cpp +++ b/firmware/Nanpy/ToneClass.cpp @@ -1,10 +1,17 @@ +#include "cfg.h" + +#if USE_Tone + #include #include "ToneClass.h" #include -void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getClass(), "Tone") == 0) { +const char* nanpy::ToneClass::get_firmware_id() +{ + return "Tone"; +} +void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { @@ -21,6 +28,5 @@ void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { v[m->getObjectId()]->stop(); m->returns(0); } - - } }; +#endif diff --git a/firmware/Nanpy/ToneClass.h b/firmware/Nanpy/ToneClass.h index 4e06cb7..629bbd9 100644 --- a/firmware/Nanpy/ToneClass.h +++ b/firmware/Nanpy/ToneClass.h @@ -118,6 +118,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; } diff --git a/firmware/Nanpy/WatchdogClass.cpp b/firmware/Nanpy/WatchdogClass.cpp index f277ab6..306e2d6 100644 --- a/firmware/Nanpy/WatchdogClass.cpp +++ b/firmware/Nanpy/WatchdogClass.cpp @@ -1,27 +1,33 @@ +#include "cfg.h" + +#if USE_Watchdog + #include #include "WatchdogClass.h" #include #include +const char* nanpy::WatchdogClass::get_firmware_id() +{ + return "Watchdog"; +} + void nanpy::WatchdogClass::elaborate(nanpy::MethodDescriptor* m) { - if (strcmp(m->getClass(), "Watchdog") == 0) + if (strcmp(m->getName(), "reset") == 0) + { + wdt_reset(); + m->returns(0); + } + if (strcmp(m->getName(), "enable") == 0) + { + wdt_enable(m->getInt(0)); + m->returns(0); + } + if (strcmp(m->getName(), "disable") == 0) { - if (strcmp(m->getName(), "wdt_reset") == 0) - { - wdt_reset(); - m->returns(0); - } - if (strcmp(m->getName(), "wdt_enable") == 0) - { - wdt_enable(m->getInt(0)); - m->returns(0); - } - if (strcmp(m->getName(), "wdt_disable") == 0) - { - wdt_disable(); - m->returns(0); - } + wdt_disable(); + m->returns(0); } } -; +#endif diff --git a/firmware/Nanpy/WatchdogClass.h b/firmware/Nanpy/WatchdogClass.h index cc1b5e2..2c21644 100644 --- a/firmware/Nanpy/WatchdogClass.h +++ b/firmware/Nanpy/WatchdogClass.h @@ -8,6 +8,7 @@ namespace nanpy { public: void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); }; }; diff --git a/firmware/Nanpy/cfg.h b/firmware/Nanpy/cfg.h index ecbcc66..0a88c94 100644 --- a/firmware/Nanpy/cfg.h +++ b/firmware/Nanpy/cfg.h @@ -1,3 +1,33 @@ #pragma once #define BAUDRATE 115200 + +#define USE_Servo 1 +#define USE_Tone 0 +#define USE_LiquidCrystal 1 +#define USE_Stepper 1 +#define USE_EEPROM 1 +#define USE_Define 1 +#define USE_ArduinoCore 1 +#define USE_Watchdog 1 +#define USE_Register 1 +#define USE_Info 1 + +// conflicts Tone +#define USE_Counter 1 + + +// external libraries should be installed for the following features: +#define USE_OneWire 1 +#define USE_DallasTemperature 0 +#define USE_CapacitiveSensor 1 +#define USE_DHT 1 + + + + +#if USE_Tone +# if USE_Counter +# error "USE_Tone conflicts with USE_Counter!" +# endif +#endif From ec5f79bbe00745eaecbc13467864f8bc9b090144 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:02:35 +0100 Subject: [PATCH 150/344] more doc --- nanpy/lcd.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 5c9a9c5..4e99ca0 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -3,8 +3,12 @@ class Lcd(ArduinoObject): - def __init__(self, pins, begin): - ArduinoObject.__init__(self) + def __init__(self, pins, begin, connection=None): + ''' + :param pins: [rs, enable, d4, d5, d6, d7] + :param begin: [cols, rows] + ''' + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pins, begin) @arduinoobjectmethod From 9f434fdda4a06287e1a22b292c303e16f775b9a1 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:16:37 +0100 Subject: [PATCH 151/344] remove 2 sec sleep --- nanpy/serialmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 71d986c..227f884 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -56,7 +56,7 @@ def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): def connect(self, device): self._serial = serial.Serial(device, self.baudrate, timeout=1) - time.sleep(2) +# time.sleep(2) def write(self, value): self._serial.write(bytes(value, 'latin-1')) From f1c70a23f2514624baab2e58c1579b5e770fd7cc Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:18:38 +0100 Subject: [PATCH 152/344] refactoring serial-manager --- nanpy/serialmanager.py | 56 +++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 227f884..f4cea96 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -1,11 +1,16 @@ -import serial -import time +from nanpy.memo import memoized import fnmatch +import logging +import serial import sys +import time DEFAULT_BAUDRATE = 115200 +PY3 = sys.version_info[0] == 3 + + class SerialManagerError(Exception): pass @@ -27,6 +32,7 @@ def _auto_detect_serial_unix(preferred_list=['*']): ret.append(d) return ret + class NoneSerialManager(object): def write(self, val): @@ -37,10 +43,10 @@ def read(self): def readline(self): return "" - + class SerialManager(object): - + def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): self.baudrate = baudrate if device: @@ -59,25 +65,45 @@ def connect(self, device): # time.sleep(2) def write(self, value): - self._serial.write(bytes(value, 'latin-1')) + if PY3: + self._serial.write(bytes(value, 'latin-1')) + else: + self._serial.write(value) def readline(self): s = self._serial.readline().decode() if not len(s): raise SerialManagerError('Serial timeout!') return s - - -class SerialManagerPy2(SerialManager): - def __init__(self): - SerialManager.__init__(self) + def flush_input(self): + '''Flush input buffer, discarding all it's contents.''' + self._serial.flushInput() + + +# TODO: remove it +# created only for compaibility +class SerialManagerCompatibility(object): + def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): + self.baudrate = baudrate + self.device = device + + @property + @memoized + def manager(self): + return SerialManager(self.device, self.baudrate) + + def connect(self, device): + return self.manager.connect(device) def write(self, value): - self._serial.write(value) + return self.manager.write(value) + + def readline(self): + return self.manager.readline() + + def flush_input(self): + return self.manager.flush_input() -if sys.version_info[0] == 2: - serial_manager = SerialManagerPy2() -elif sys.version_info[0] == 3: - serial_manager = SerialManager() +serial_manager = SerialManagerCompatibility() From c253caf7f4701b19765c214f002af59418e7cbdc Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:19:16 +0100 Subject: [PATCH 153/344] SerialManager: logging --- nanpy/serialmanager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index f4cea96..fdabd5d 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -7,6 +7,7 @@ DEFAULT_BAUDRATE = 115200 +log = logging.getLogger(__name__) PY3 = sys.version_info[0] == 3 @@ -65,13 +66,16 @@ def connect(self, device): # time.sleep(2) def write(self, value): + log.debug('sending:%s' % repr(value)) if PY3: self._serial.write(bytes(value, 'latin-1')) else: self._serial.write(value) def readline(self): - s = self._serial.readline().decode() + s = self._serial.readline() + log.debug('received:%s' % repr(s)) + s = s.decode() if not len(s): raise SerialManagerError('Serial timeout!') return s From e3d8bd265f1b165b97179a1e041f177fef51846a Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:19:40 +0100 Subject: [PATCH 154/344] SerialManager: flush after connecting --- nanpy/serialmanager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index fdabd5d..8b00a02 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -64,6 +64,7 @@ def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): def connect(self, device): self._serial = serial.Serial(device, self.baudrate, timeout=1) # time.sleep(2) + self.flush_input() def write(self, value): log.debug('sending:%s' % repr(value)) From db14413511112c79205c413bca6dcbcd6096a6a2 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:21:53 +0100 Subject: [PATCH 155/344] object based interface, firmware_id --- nanpy/arduino.py | 29 +++---- nanpy/arduinoboard.py | 138 +++++++++++++++++++++++++++------ nanpy/arduinocore.py | 95 +++++------------------ nanpy/arduinopin.py | 173 ++++++++++++++++++++++++++++-------------- nanpy/define.py | 77 +++++++++++++------ nanpy/pwm.py | 37 +++++---- nanpy/resgister.py | 167 ++++++++++++++++++++++++++-------------- nanpy/watchdog.py | 39 ++++------ 8 files changed, 452 insertions(+), 303 deletions(-) diff --git a/nanpy/arduino.py b/nanpy/arduino.py index d16acec..41e89f6 100644 --- a/nanpy/arduino.py +++ b/nanpy/arduino.py @@ -1,54 +1,47 @@ -from nanpy.arduinoboard import (arduinoclassmethod, returns) +from nanpy.arduinoboard import arduinoclassmethod, returns, FirmwareClass import time -class Arduino(object): +class Arduino(FirmwareClass): + firmware_id = 'A' - HIGH = 1 - LOW = 0 - INPUT = 0 - OUTPUT = 1 + LOW, HIGH = 0, 1 + INPUT, OUTPUT = 0, 1 @classmethod - @arduinoclassmethod + @arduinoclassmethod('dw') def digitalWrite(cls, pin, value): pass @classmethod @returns(int) - @arduinoclassmethod + @arduinoclassmethod('r') def digitalRead(cls, pin): pass @classmethod - @arduinoclassmethod + @arduinoclassmethod('aw') def analogWrite(cls, pin, value): pass @classmethod @returns(int) - @arduinoclassmethod + @arduinoclassmethod('a') def analogRead(cls, pin): pass @classmethod - @arduinoclassmethod + @arduinoclassmethod('pm') def pinMode(cls, pin, mode): pass - @classmethod - @returns(int) - @arduinoclassmethod - def pinModeRead(cls, pin): - pass - @classmethod def delay(cls, value): time.sleep(float(value)/1000) @classmethod @returns(int) - @arduinoclassmethod + @arduinoclassmethod('m') def millis(cls): pass diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index ba86d62..7e1f9d2 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -3,20 +3,29 @@ mutex = Lock() -def _write(data): - serial_manager.write('%s\0' % str(data)) -def return_value(): - return serial_manager.readline().replace('\r\n', '') +def _write(data, connection): + if connection: + connection.write('%s\0' % str(data)) + else: + serial_manager.write('%s\0' % str(data)) -def _call(namespace, id, args): + +def return_value(connection): + if connection: + return connection.readline().replace('\r\n', '') + else: + return serial_manager.readline().replace('\r\n', '') + + +def _call(namespace, id, args, connection): toprint = [] nel = 0 mutex.acquire() - _write(namespace) - _write(id) + _write(namespace, connection) + _write(id, connection) for arg in args: if type(arg) == type(list()): @@ -29,50 +38,131 @@ def _call(namespace, id, args): toprint.append(arg) nel += 1 - _write(nel - 1) + _write(nel - 1, connection) for elprint in toprint: - _write(elprint) + _write(elprint, connection) - ret = return_value() + ret = return_value(connection) mutex.release() return ret + def returns(fconv): def wrapf(func): def wrapper(self, *args, **kwargs): - try: +# try: return fconv(func(self, *args, **kwargs)) - except ValueError: - return -1 +# except ValueError: +# return -1 return wrapper return wrapf + def arduinoobjectmethod(funct, *args, **kwargs): def wrapper(self, *args, **kwargs): call_pars = [funct.__name__] call_pars.extend(args) funct(self, *args, **kwargs) - return _call(self.namespace, self.id, call_pars) + connection = self.connection if hasattr(self, 'connection') else None + return _call(self.namespace, self.id, call_pars, connection=connection) return wrapper -def arduinoclassmethod(funct): - def wrapper(cls, *args, **kwargs): - call_pars = [funct.__name__] - call_pars.extend(args) - funct(cls, *args, **kwargs) - return _call(cls.__name__, 0, call_pars) - return wrapper +# def arduinoclassmethod(funct): +# def wrapper(cls, *args, **kwargs): +# call_pars = [funct.__name__] +# call_pars.extend(args) +# funct(cls, *args, **kwargs) +# return _call(cls.__name__, 0, call_pars) +# return wrapper + + +def class_get_firmware_id(cls): + if hasattr(cls, 'get_firmware_id'): + return cls.get_firmware_id() + elif hasattr(cls, 'firmware_id'): + return cls.firmware_id + else: + return cls.__name__ + + +def arduinoclassmethod(param): + is_func = hasattr(param, '__call__') + if is_func: + funct = param + + def wrapper(cls, *args, **kwargs): + cls_name = class_get_firmware_id(cls) + call_pars = [funct.__name__] + call_pars.extend(args) + funct(cls, *args, **kwargs) + return _call(cls_name, 0, call_pars, connection=None) + return wrapper + else: + name = param + + def wrapper2(funct): + def wrapper(cls, *args, **kwargs): + cls_name = class_get_firmware_id(cls) + call_pars = [name] + call_pars.extend(args) + funct(cls, *args, **kwargs) + return _call(cls_name, 0, call_pars, connection=None) + return wrapper + return wrapper2 + + +def _wrapper3(name): + def wrapper2(funct): + def wrapper(obj, *args, **kwargs): + cls_name = class_get_firmware_id(obj.__class__) + connection = obj.connection if hasattr(obj, 'connection') else None + call_pars = [name if name else funct.__name__] + call_pars.extend(args) + funct(obj, *args, **kwargs) + return _call(cls_name, 0, call_pars, connection=connection) + return wrapper + return wrapper2 + + +def arduinomethod(param): + is_func = hasattr(param, '__call__') + if is_func: + funct = param + name = None + return _wrapper3(name)(funct) + else: + name = param + return _wrapper3(name) + class ArduinoObject(object): + connection=None - def __init__(self): + def __init__(self, connection=None): self.namespace = self.__class__.__name__ self.id = 0 + self.connection = connection def call(self, *args): - return _call(self.namespace, self.id, args) + return _call(self.namespace, self.id, args, self.connection) def __del__(self): - return _call(self.namespace, self.id, ["remove"]) + return _call(self.namespace, self.id, ["remove"], self.connection) + + +class FirmwareClass(object): + connection = None + firmware_id = None + + @classmethod + def get_firmware_id(cls): + if cls.firmware_id: + return cls.firmware_id + else: + return cls.__name__ + + def __init__(self, connection=None): + self.connection = connection + diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py index 76f71d3..e43d19a 100644 --- a/nanpy/arduinocore.py +++ b/nanpy/arduinocore.py @@ -1,104 +1,49 @@ -from nanpy.arduinoboard import arduinoclassmethod, returns -from nanpy.define import Define +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware from nanpy.memo import memoized -class ArduinoCore(object): +@check4firmware +class ArduinoCore(FirmwareClass): + """Access to Arduino functions which are not part of the public API.""" - """Access to Arduino functions which are not part of the public API. + firmware_id = 'Core' - There are some additional funtions implemented in C - - """ - - @classmethod @memoized @returns(int) - @arduinoclassmethod - def digitalPinToBitMask(cls, pin): + @arduinomethod + def digitalPinToBitMask(self, pin): """nonpublic Arduino function.""" - @classmethod @memoized @returns(int) - @arduinoclassmethod - def digitalPinToPort(cls, pin): + @arduinomethod + def digitalPinToPort(self, pin): """nonpublic Arduino function.""" - @classmethod - @memoized @returns(int) - @arduinoclassmethod - def portModeRegister(cls, pin): + @arduinomethod + def portModeRegister(self, port): """nonpublic Arduino function.""" - @classmethod @memoized @returns(int) - @arduinoclassmethod - def digitalPinToTimer(cls, pin): + @arduinomethod + def digitalPinToTimer(self, pin): """nonpublic Arduino function.""" - @classmethod @memoized @returns(int) - @arduinoclassmethod - def analogInPinToBit(cls, pin): + @arduinomethod + def analogInPinToBit(self, pin): """nonpublic Arduino function.""" - @classmethod - @memoized @returns(int) - @arduinoclassmethod - def portOutputRegister(cls, pin): + @arduinomethod + def portOutputRegister(self, port): """nonpublic Arduino function.""" - @classmethod - @memoized @returns(int) - @arduinoclassmethod - def portInputRegister(cls, pin): + @arduinomethod + def portInputRegister(self, port): """nonpublic Arduino function.""" - - @classmethod - @memoized - @returns(int) - @arduinoclassmethod - def totalPinCount(cls): - """total pin count. - - The C implementation is a hack. - - """ - - @classmethod - @returns(lambda x: int(x) / 1000.0) - @arduinoclassmethod - def readVcc(cls): - """VCC in Volt. This works on Arduinos with a 328 or 168 only. - - Source: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter - - How it works - - The Arduino 328 and 168 have a built in precision voltage reference of 1.1V. - This is used sometimes for precision measurement, - although for Arduino it usually makes more sense to measure against Vcc, - the positive power rail. - The chip has an internal switch that selects which pin the analogue to digital converter reads. - That switch has a few leftover connections, so the chip designers wired them up to useful signals. - One of those signals is that 1.1V reference. - So if you measure how large the known 1.1V reference is in comparison to Vcc, - you can back-calculate what Vcc is with a little algebra. That is how this works. - - """ - - @classmethod - def model(cls): - """The model of the AVR. - - Example: ATmega328P - - """ - s = Define.asDict().get('MCU') - return s.strip('_').split('_')[-1] diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py index 3bbe9d5..420cb84 100644 --- a/nanpy/arduinopin.py +++ b/nanpy/arduinopin.py @@ -1,14 +1,9 @@ -from nanpy.arduino import Arduino -from nanpy.arduinocore import ArduinoCore -from nanpy.define import Define from nanpy.memo import memoized from nanpy.pwm import ArduinoPwmPin import sys -HIGH = Arduino.HIGH -LOW = Arduino.LOW -INPUT = Arduino.INPUT -OUTPUT = Arduino.OUTPUT +LOW, HIGH = 0, 1 +INPUT, OUTPUT = 0, 1 # from six PY3 = sys.version_info[0] == 3 @@ -18,6 +13,10 @@ string_types = basestring, +class PinError(Exception): + pass + + def name2int(pin_name, A0): try: if isinstance(pin_name, string_types): @@ -43,49 +42,21 @@ class ArduinoPin(object): Examples: # they do the same - ArduinoPin(0).value - ArduinoPin('D0').value - ArduinoPin('D0').read_value() + a=ArduinoTree() + a.pin.get(0).value + a.pin.get('D0').value + a.pin.get('D0').read_value() ''' - @classmethod - @memoized - def count_analog(cls): - """Count of analog pins.""" - return len(cls.analog_names()) - - @classmethod - @memoized - def count_digital(cls): - """Count of digital pins.""" - return len(cls.digital_names()) - - @classmethod - @memoized - def count(cls): - """Count of all pins.""" - return cls.count_analog() + cls.count_digital() - - @classmethod - @memoized - def digital_names(cls): - """List of digital pin names.""" - A0 = Define.asDict()['A0'] - return ['D%s' % x for x in range(0, A0)] - @classmethod - @memoized - def analog_names(cls): - """List of analog pin names.""" - A0 = Define.asDict()['A0'] - return ( - ['A%s' % (x - A0) for x in range(A0, ArduinoCore.totalPinCount())] - ) - - def __init__(self, name): + def __init__(self, name, total_pin_count, define, register, core, api): """name can be int or string.""" - self.A0 = Define.asDict()['A0'] + self.register = register + self.core = core + self.api = api + self.define = define + self.A0 = define.get('A0') self.nr = name2int(name, self.A0) - if self.nr >= ArduinoCore.totalPinCount(): + if self.nr >= total_pin_count: raise ValueError('pin %s (Nr:%s) not in range' % (name, self.nr)) @@ -94,7 +65,14 @@ def __init__(self, name): def pwm(self): '''Object-oriented representation of the pin PWM functionality ''' - return ArduinoPwmPin(self.nr) + return ( + ArduinoPwmPin( + self.nr, + self.define, + self.register, + self.core, + self.api) + ) @property def is_digital(self): @@ -108,14 +86,14 @@ def is_analog(self): def avr_port(self): '''AVR port name (example: "B") ''' - x = ArduinoCore.digitalPinToPort(self.nr) + x = self.core.digitalPinToPort(self.nr) return chr(ord('A') + x - 1) @property def avr_bit(self): '''AVR bit name (example: "2") ''' - bitmask = ArduinoCore.digitalPinToBitMask(self.nr) + bitmask = self.core.digitalPinToBitMask(self.nr) i = 0 while bitmask != 1: bitmask >>= 1 @@ -151,14 +129,13 @@ def nr_analog(self): @property def programming_function(self): """programming function (MISO, MOSI, SCK or SS)""" - d = Define.asDict() - if self.nr == d['MISO']: + if self.nr == self.define.get('MISO'): return 'MISO' - if self.nr == d['MOSI']: + if self.nr == self.define.get('MOSI'): return 'MOSI' - if self.nr == d['SCK']: + if self.nr == self.define.get('SCK'): return 'SCK' - if self.nr == d['SS']: + if self.nr == self.define.get('SS'): return 'SS' def reset(self): @@ -182,7 +159,7 @@ def read_digital_value(self, direction=None): """ if direction is not None: self.write_mode(direction) - return Arduino.digitalRead(self.nr) + return self.api.digitalRead(self.nr) def write_digital_value(self, value, direction=None): """write digital value (0/1) @@ -196,7 +173,7 @@ def write_digital_value(self, value, direction=None): if direction is not None: self.write_mode(direction) value = 1 if value else 0 - return Arduino.digitalWrite(self.nr, value) + return self.api.digitalWrite(self.nr, value) digital_value = property(read_digital_value, write_digital_value) @@ -205,14 +182,92 @@ def read_analog_value(self): ''' if not self.is_analog: return None - return Arduino.analogRead(self.nr) + return self.api.analogRead(self.nr) analog_value = property(read_analog_value) def read_mode(self): """read mode (0/1)""" - return Arduino.pinModeRead(self.nr) + bitmask = self.core.digitalPinToBitMask(self.nr) + port = self.core.digitalPinToPort(self.nr) + reg = self.core.portModeRegister(port) + mode = OUTPUT if reg & bitmask else INPUT + return mode def write_mode(self, value): """write mode (0/1)""" - return Arduino.pinMode(self.nr, value) + return self.api.pinMode(self.nr, value) mode = property(read_mode, write_mode) + + +class PinFeature(object): + + def __init__(self, define, register, core, api): + self.A0 = define.get('A0') + self.define = define + self.register = register + self.core = core + self.api = api + + @memoized + def get(self, name): + return ( + ArduinoPin( + name, + self.count, + self.define, + self.register, + self.core, + self.api) + ) + + @property + @memoized + def count_analog(self): + """Count of analog pins.""" + return len(self.names_analog) + + @property + @memoized + def count_digital(self): + """Count of digital pins.""" + return len(self.names_digital) + + @property + @memoized + def count(self): + """Count of all pins. + + HACK! + + """ + # HACK! + for i in range(100): + x = self.core.digitalPinToBitMask(i) + ok = False + for j in range(8): + if x == (1 << j): + ok = True + break + + if not ok: + return i + raise PinError('Can not calculate pin count!') + + @property + def names(self): + """List of all pin names.""" + return self.names_digital + self.names_analog + + @property + def names_digital(self): + """List of digital pin names.""" + A0 = self.A0 + return ['D%s' % x for x in range(0, A0)] + + @property + def names_analog(self): + """List of analog pin names.""" + A0 = self.A0 + return ( + ['A%s' % (x - A0) for x in range(A0, self.count)] + ) diff --git a/nanpy/define.py b/nanpy/define.py index ba024fe..397d43d 100644 --- a/nanpy/define.py +++ b/nanpy/define.py @@ -1,4 +1,5 @@ -from nanpy.arduinoboard import arduinoclassmethod, returns +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware from nanpy.memo import memoized @@ -9,42 +10,70 @@ def auto_convert(x): return x -class Define(object): +@check4firmware +class DefineArray(FirmwareClass): + firmware_id = 'D' - """Access to firmware constants. - - Examples: - - Define.asDict().get('F_CPU') # AVR frequency - Define.asDict().get('__DATE__') # firmware upload date - - """ - - @classmethod + @property @memoized @returns(int) - @arduinoclassmethod - def count(cls): + @arduinomethod('c') + def count(self): pass - @classmethod @memoized - @arduinoclassmethod - def name(cls, index): + @arduinomethod('n') + def name(self, index): pass - @classmethod @memoized @returns(auto_convert) - @arduinoclassmethod - def value(cls, index): + @arduinomethod('v') + def value(self, index): pass - @classmethod + +class DefineFeature(object): + + """Access to firmware constants. + + Examples: + + a=ArduinoTree() + a.define.get('F_CPU') # AVR frequency + a.define.get('__DATE__') # firmware upload date + + """ + + def __init__(self, connection=None): + self._arr = DefineArray(connection) + + @property @memoized - def asDict(cls): + def as_dict(self): """return all constants and their values in a dictionary.""" d = dict() - for i in range(cls.count()): - d[cls.name(i)] = cls.value(i) + for i in range(self._arr.count): + d[self._arr.name(i)] = self._arr.value(i) + assert len(d) return d + + @property + def names(self): + return sorted(self.as_dict.keys()) + + @property + @memoized + def count(self): + return len(self.as_dict) + + def get(self, name): + """get a constant. + + Examples: + + a=ArduinoTree() + a.define.get('F_CPU') # AVR frequency + + """ + return self.as_dict.get(name) diff --git a/nanpy/pwm.py b/nanpy/pwm.py index 65fba8c..685e9f1 100644 --- a/nanpy/pwm.py +++ b/nanpy/pwm.py @@ -1,8 +1,4 @@ from __future__ import division -from nanpy.arduino import Arduino -from nanpy.arduinocore import ArduinoCore -from nanpy.define import Define -from nanpy.resgister import Register import logging log = logging.getLogger(__name__) @@ -89,9 +85,12 @@ class ArduinoPwmPin(object): ''' DEFAULT_DIVISOR = 64 - def __init__(self, nr): + def __init__(self, nr, define, register, core, api): self.nr = nr - self.F_CPU = Define().asDict().get('F_CPU') + self.register = register + self.F_CPU = define.get('F_CPU') + self.api = api + self.core = core def reset(self): '''reset to the PWM default state: default frequency is set @@ -115,7 +114,7 @@ def write_value(self, value): """same as analogWrite.""" self._check() # assert self.mcu.pins.read_mode(self.nr) == OUTPUT - Arduino.analogWrite(self.nr, value) + self.api.analogWrite(self.nr, value) @property def divisors_available(self): @@ -139,7 +138,7 @@ def write_divisor(self, value): divisor = property(read_divisor, write_divisor) def _timer_id(self): - return ArduinoCore.digitalPinToTimer(self.nr) + return self.core.digitalPinToTimer(self.nr) def _timer_register_name(self, variant='B'): self._check() @@ -156,12 +155,12 @@ def timer_register_name_b(self): def read_timer_mode(self): reg_name = self.timer_register_name_b - return Register(reg_name).read_value() & timer_mask + return self.register.get(reg_name).read_value() & timer_mask def write_timer_mode(self, value): assert value <= 7 reg_name = self.timer_register_name_b - reg = Register(reg_name) + reg = self.register.get(reg_name) old = reg.value & ~timer_mask reg.value = (old | value) @@ -187,7 +186,7 @@ def read_frequency(self): wgm = self.read_wgm() if wgm == 14: # high freq mode - return self.F_CPU / Register('ICR1').value + return self.F_CPU / self.register.get('ICR1').value else: return self.calculate_frequency(self.read_divisor()) @@ -211,8 +210,8 @@ def read_wgm(self): else: maskb = 8 # 0b00001000 maska = 3 # 0b00000011 - a = Register(rega).value & maska - b = Register(regb).value & maskb + a = self.register.get(rega).value & maska + b = self.register.get(regb).value & maskb return a + (b >> 1) wgm = property(read_wgm, None) @@ -232,12 +231,12 @@ def set_high_freq_around_pwm(self, top, fill): self.write_divisor(1) self.write_value(128) - TCCR1A = Register('TCCR1A') - TCCR1B = Register('TCCR1B') - TCNT1 = Register('TCNT1') - ICR1 = Register('ICR1') - OCR1A = Register('OCR1A') - OCR1B = Register('OCR1B') + TCCR1A = self.register.get('TCCR1A') + TCCR1B = self.register.get('TCCR1B') + TCNT1 = self.register.get('TCNT1') + ICR1 = self.register.get('ICR1') + OCR1A = self.register.get('OCR1A') + OCR1B = self.register.get('OCR1B') TCCR1A.value = 2 + \ (240 & TCCR1A.value) # 0b00000010 + (0b11110000 & reg.TCCR1A) diff --git a/nanpy/resgister.py b/nanpy/resgister.py index 09d6bd4..6efd239 100644 --- a/nanpy/resgister.py +++ b/nanpy/resgister.py @@ -1,124 +1,175 @@ -from nanpy.arduinoboard import arduinoclassmethod, returns +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware from nanpy.memo import memoized -class _Registers(object): +@check4firmware +class RegisterArray(FirmwareClass): + firmware_id = 'R' - @classmethod @memoized @returns(int) - @arduinoclassmethod - def count(cls): + @arduinomethod('c') + def count(self): pass - @classmethod @returns(int) - @arduinoclassmethod - def read(cls, index): + @arduinomethod('r') + def read(self, index): pass - @classmethod - @arduinoclassmethod - def write(cls, index, value): + @arduinomethod('w') + def write(self, index, value): pass - @classmethod @memoized @returns(int) - @arduinoclassmethod - def address(cls, index): + @arduinomethod('a') + def address(self, index): pass - @classmethod @memoized @returns(int) - @arduinoclassmethod - def size(cls, index): + @arduinomethod('s') + def size(self, index): pass - @classmethod @memoized - @arduinoclassmethod - def name(cls, index): + @arduinomethod('n') + def name(self, index): pass - @classmethod - @memoized - def name_index_dict(cls): - d = dict() - for i in range(cls.count()): - d[cls.name(i)] = i - return d - class Register(object): - """Direct access to AVR registers.""" - - @classmethod - @memoized - def names(cls): - """Get all register names as a sorted list.""" - return sorted(_Registers.name_index_dict().keys()) + """Representation of an AVR register.""" - def __init__(self, name): + def __init__(self, index, arr): """""" - try: - self.index = _Registers.name_index_dict()[name] - except KeyError: - raise ValueError('Unknown register: %s' % name) + self._arr = arr + self.index = index def read_value(self): """Read register value. - Example: + Examples: - Register('DDRB').read_value() + a=ArduinoTree() + a.register.get('DDRB').read_value() """ - return _Registers.read(self.index) + return self._arr.read(self.index) def write_value(self, value): """Write register value. - Example: + Examples: - Register('DDRB').write_value(1) + a=ArduinoTree() + a.register.get('DDRB').write_value(1) """ - return _Registers.write(self.index, value) + return self._arr.write(self.index, value) value = property(read_value, write_value) @property def name(self): """Register name. - - Example: - - Register('DDRB').name - """ - return _Registers.name(self.index) + return self._arr.name(self.index) @property def address(self): """Register address. - Example: + Examples: - Register('DDRB').address + a=ArduinoTree() + a.register.get('DDRB').address """ - return _Registers.address(self.index) + return self._arr.address(self.index) @property def size(self): """Register size in bytes. 1 or 2. - Example: + Examples: - Register('DDRB').size + a=ArduinoTree() + a.register.get('DDRB').size """ - return _Registers.size(self.index) + return self._arr.size(self.index) + + +class RegisterProxy(object): + + """Proxy object to allow easy register access. + + Examples: + + a=ArduinoTree() + a.register.proxy.DDRB = 1 + print( a.register.proxy.DDRB ) + + """ + + def __init__(self, arr, name_index_dict): + self._name_index_dict = name_index_dict + self._arr = arr + + def __getattr__(self, name): + if name in ['_name_index_dict', '_arr']: + return object.__getattribute__(self, name) + + index = self._name_index_dict[name] + return self._arr.read(index) + + def __setattr__(self, name, value): + if name in ['_name_index_dict', '_arr']: + self.__dict__[name] = value + return + + index = self._name_index_dict[name] + return self._arr.write(index, value) + + +class RegisterFeature(object): + + def __init__(self, connection=None): + self._arr = RegisterArray(connection) + + @property + @memoized + def name_index_dict(self): + d = dict() + for i in range(self._arr.count()): + d[self._arr.name(i)] = i + assert len(d) + return d + + @property + def names(self): + """Get all register names as a sorted list.""" + return sorted(self.name_index_dict.keys()) + + @property + @memoized + def count(self): + """Get register count.""" + return len(self.name_index_dict.keys()) + + @memoized + def get(self, name): + try: + index = self.name_index_dict[name] + except KeyError: + raise ValueError('Unknown register: %s' % name) + return Register(index, self._arr) + + @property + @memoized + def proxy(self): + return RegisterProxy(self._arr, self.name_index_dict) diff --git a/nanpy/watchdog.py b/nanpy/watchdog.py index 4b001b4..6427f42 100644 --- a/nanpy/watchdog.py +++ b/nanpy/watchdog.py @@ -1,8 +1,9 @@ -from nanpy.arduinoboard import arduinoclassmethod -import time +from nanpy.arduinoboard import arduinomethod, FirmwareClass +from nanpy.classinfo import check4firmware -class Watchdog(object): +@check4firmware +class Watchdog(FirmwareClass): """Direct access to watchdog timer. @@ -20,10 +21,9 @@ class Watchdog(object): WDTO_4S = 8 WDTO_8S = 9 - @classmethod - @arduinoclassmethod - def wdt_reset(cls): - """Reset the watchdog timer. + @arduinomethod + def reset(self): + """Reset the watchdog timer. (wdt_reset) When the watchdog timer is enabled, a call to this instruction is required before the timer expires, @@ -31,24 +31,11 @@ def wdt_reset(cls): """ - @classmethod - @arduinoclassmethod - def wdt_enable(cls, timeout): + @arduinomethod + def enable(self, timeout): """Enable the watchdog timer, configuring it for expiry after - timeout.""" + timeout. (wdt_enable)""" - @classmethod - @arduinoclassmethod - def wdt_disable(cls): - """Disable the watchdog timer, if possible.""" - - @classmethod - def soft_reset(cls): - """Resets the AVR, the registers will be reset to their known, default - settings. - - Details: http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset - - """ - cls.wdt_enable(cls.WDTO_15MS) - time.sleep(0.1) + @arduinomethod + def disable(self): + """Disable the watchdog timer, if possible. (wdt_disable)""" From 1cc746f939b41271a9c14cfec6a684a20fe05d7c Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:22:38 +0100 Subject: [PATCH 156/344] remove test dependency: path.py --- tests/test_make.py | 10 +++++----- tox.ini | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_make.py b/tests/test_make.py index 8d9ba66..f3b8392 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -1,15 +1,15 @@ from easyprocess import EasyProcess from nose.tools import eq_ -from path import path from util import tmpdir +import os +import shutil -FIRMWARE = path(__file__).parent.parent.abspath() / 'firmware' / 'Nanpy' +FIRMWARE = os.path.dirname( __file__ ) + '/../firmware/Nanpy' def test_make(): - dest = path(tmpdir()) / 'Nanpy' - FIRMWARE.copytree(dest) - + dest = tmpdir() + '/Nanpy' + shutil.copytree(FIRMWARE, dest) p = EasyProcess('make size BOARD=uno', cwd=dest).call() eq_(p.return_code, 0) diff --git a/tox.ini b/tox.ini index 27af1b0..6e58527 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,6 @@ deps= nose pyserial easyprocess - path.py setenv= PYTHONPATH= changedir=tests From 4e3dca92e8702e0a2bb144e932f7763b77b2634a Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:24:18 +0100 Subject: [PATCH 157/344] new object based classes --- nanpy/arduinoapi.py | 39 ++++++++++++++ nanpy/arduinotree.py | 112 ++++++++++++++++++++++++++++++++++++++++ nanpy/classinfo.py | 71 +++++++++++++++++++++++++ nanpy/counter.py | 83 +++++++++++++++++++++++++++++ nanpy/eepromobj.py | 24 +++++++++ nanpy/nullconnection.py | 10 ++++ nanpy/vcc.py | 40 ++++++++++++++ 7 files changed, 379 insertions(+) create mode 100644 nanpy/arduinoapi.py create mode 100644 nanpy/arduinotree.py create mode 100644 nanpy/classinfo.py create mode 100644 nanpy/counter.py create mode 100644 nanpy/eepromobj.py create mode 100644 nanpy/nullconnection.py create mode 100644 nanpy/vcc.py diff --git a/nanpy/arduinoapi.py b/nanpy/arduinoapi.py new file mode 100644 index 0000000..5aaf9fb --- /dev/null +++ b/nanpy/arduinoapi.py @@ -0,0 +1,39 @@ +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware + + +@check4firmware +class ArduinoApi(FirmwareClass): + + """access to Arduino public API functions.""" + firmware_id = 'A' + + LOW, HIGH = 0, 1 + INPUT, OUTPUT = 0, 1 + + @arduinomethod('dw') + def digitalWrite(self, pin, value): + pass + + @returns(int) + @arduinomethod('r') + def digitalRead(self, pin): + pass + + @arduinomethod('aw') + def analogWrite(self, pin, value): + pass + + @returns(int) + @arduinomethod('a') + def analogRead(self, pin): + pass + + @arduinomethod('pm') + def pinMode(self, pin, mode): + pass + + @returns(int) + @arduinomethod('m') + def millis(self): + pass diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py new file mode 100644 index 0000000..2ef4cda --- /dev/null +++ b/nanpy/arduinotree.py @@ -0,0 +1,112 @@ +from __future__ import division +from nanpy.arduinoapi import ArduinoApi +from nanpy.arduinocore import ArduinoCore +from nanpy.arduinopin import PinFeature +from nanpy.classinfo import ClassInfo +from nanpy.counter import Counter +from nanpy.define import DefineFeature +from nanpy.eepromobj import EepromLib +from nanpy.memo import memoized +from nanpy.resgister import RegisterFeature +from nanpy.serialmanager import SerialManager +from nanpy.vcc import Vcc +from nanpy.watchdog import Watchdog +import time + + +class ArduinoTree(object): + + """Object tree model of an Arduino. + + Examples: + + a=ArduinoTree() + a.pin.get(9).read_digital_value() + + """ + + def __init__(self, connection=None): + '' + self.connection = connection + if not connection: + self.connection = SerialManager() + if not hasattr(self.connection, 'classinfo'): + self.connection.classinfo = ClassInfo(self.connection) + + @property + @memoized + def api(self): + """Access to Arduino API.""" + return ArduinoApi(self.connection) + + @property + @memoized + def pin(self): + """Object-oriented representation of an Arduino pin""" + return PinFeature(self.define, self.register, self.core, self.api) + + @property + @memoized + def define(self): + """Access to firmware constants.""" + return DefineFeature(self.connection) + + @property + @memoized + def register(self): + """Direct access to AVR registers.""" + return RegisterFeature(self.connection) + + @property + @memoized + def watchdog(self): + """Direct access to watchdog timer.""" + return Watchdog(self.connection) + + @property + @memoized + def eeprom(self): + """Access to EEPROM.""" + return EepromLib(self.connection) + + @property + @memoized + def counter(self): + """Access to counter.""" + return Counter(self.connection, F_CPU=self.define.get('F_CPU')) + + @property + @memoized + def core(self): + """Access to Arduino functions which are not part of the public API.""" + return ArduinoCore(self.connection) + + @property + @memoized + def vcc(self): + """Access to VCC.""" + return Vcc(self.register) + + @property + def avr_name(self): + """The name of the AVR. + + Example: ATmega328P + + """ + s = self.define.get('MCU') + return s.strip('_').split('_')[-1] + + def soft_reset(self): + """Resets the AVR, the registers will be reset to their known, default + settings. + + Details: http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset + + """ + self.watchdog.enable(self.watchdog.WDTO_60MS) + time.sleep(0.2) + + # TODO: after restart the first read is not correct (why?) + # This command helps cleaning the read buffer + self.connection.flush_input() diff --git a/nanpy/classinfo.py b/nanpy/classinfo.py new file mode 100644 index 0000000..6d29810 --- /dev/null +++ b/nanpy/classinfo.py @@ -0,0 +1,71 @@ +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.memo import memoized + + +class FirmwareError(Exception): + pass + + +def check4firmware(cls): + if not hasattr(check4firmware, 'names'): + check4firmware.names = dict() + cls_name = cls.get_firmware_id() + assert cls_name not in check4firmware.names.keys() + check4firmware.names[cls_name] = cls + + def getinstance(connection): + if cls_name == 'Info': + return cls(connection) + + if connection is not None: + if not hasattr(connection, 'classinfo'): + connection.classinfo = ClassInfo(connection) + if cls_name not in connection.classinfo.firmware_id_list: + raise FirmwareError( + '''%s ['%s'] is missing from firmware!''' % + (cls, cls_name)) + return cls(connection) +# getinstance.__name__ = cls.__name__ + return getinstance + + +@check4firmware +class ClassInfoArray(FirmwareClass): + firmware_id = 'Info' + + @property + @memoized + @returns(int) + @arduinomethod + def count(self): + pass + + @memoized + @arduinomethod + def name(self, index): + pass + + +class ClassInfo(object): + + """Which classes are compiled into the firmware?""" + + def __init__(self, connection): + self.firmware_class_status = dict() + self.unknown_firmware_ids = [] + + self._arr = ClassInfoArray(connection=connection) + + ls = [self._arr.name(i) for i in range(self._arr.count)] + assert len(ls) + self.firmware_id_list = sorted(ls) + + for cls in check4firmware.names.values(): + self.firmware_class_status[cls.__name__] = False + + for x in self.firmware_id_list: + cls = check4firmware.names.get(x) + if cls: + self.firmware_class_status[cls.__name__] = True + else: + self.unknown_firmware_ids.append(x) diff --git a/nanpy/counter.py b/nanpy/counter.py new file mode 100644 index 0000000..ff111d7 --- /dev/null +++ b/nanpy/counter.py @@ -0,0 +1,83 @@ +from __future__ import division +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware +import time + + +@check4firmware +class CounterLib(FirmwareClass): + firmware_id = 'Counter' + + @arduinomethod + def begin(self, gate_time_ms): + pass + + @arduinomethod + def end(self): + pass + + @returns(bool) + @arduinomethod + def available(self): + pass + + @returns(int) + @arduinomethod + def read(self): + pass + + +class Counter(object): + + """Access to counter. + + Examples: + + Counter.read() + + original lib: http://www.pjrc.com/teensy/td_libs_FreqCount.html + + """ + def __init__(self, connection=None, F_CPU=None): + self.connection = connection + self.lib = CounterLib(connection) + self.multiplier = 1 + if F_CPU: + self.multiplier = self.calculate_multiplier(F_CPU) + + def calculate_multiplier(self, F_CPU): + multiplier = 1 + # calculate multiplier for non supported frequencies + if F_CPU > 16000000: + multiplier = F_CPU / 16000000 + elif F_CPU > 8000000: + multiplier = F_CPU / 8000000 + elif F_CPU > 4000000: + multiplier = F_CPU / 4000000 + elif F_CPU > 2000000: + multiplier = F_CPU / 2000000 + elif F_CPU > 1000000: + multiplier = F_CPU / 1000000 + else: + multiplier = 1000000 / F_CPU + return multiplier + + def read(self, gate_time=1): + """read pulse count under ``gate_time`` seconds.""" + gate_time_ms = int(1000 * gate_time) + self.lib.begin(gate_time_ms) + try: + time.sleep(gate_time * 1.1) + n = self.lib.read() + finally: + self.lib.end() + return n * self.multiplier + + def read_frequency(self, gate_time=1): + """read frequency in hertz using ``gate_time`` in seconds.""" + return self.read(gate_time) / gate_time + + def error(self, gate_time=1): + """frequency measurement error in hertz using ``gate_time`` in + seconds.""" + return self.multiplier / gate_time diff --git a/nanpy/eepromobj.py b/nanpy/eepromobj.py new file mode 100644 index 0000000..1b72b9c --- /dev/null +++ b/nanpy/eepromobj.py @@ -0,0 +1,24 @@ +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware +from nanpy.memo import memoized + + +@check4firmware +class EepromLib(FirmwareClass): + firmware_id = 'EEPROM' + + @arduinomethod + def write(self, address, value): + pass + + @returns(int) + @arduinomethod + def read(self, address): + pass + + @property + @memoized + @returns(int) + @arduinomethod + def size(self): + pass diff --git a/nanpy/nullconnection.py b/nanpy/nullconnection.py new file mode 100644 index 0000000..e24ff94 --- /dev/null +++ b/nanpy/nullconnection.py @@ -0,0 +1,10 @@ +class NullConnection(object): + + def write(self, value): + print('sending:%s' % repr(value)) + + def readline(self): + return '' + + def flush_input(self): + """Flush input buffer, discarding all it's contents.""" diff --git a/nanpy/vcc.py b/nanpy/vcc.py new file mode 100644 index 0000000..2f01a3f --- /dev/null +++ b/nanpy/vcc.py @@ -0,0 +1,40 @@ +import time + + +class Vcc(object): + + def __init__(self, register): + self.register = register + + def read(self): + """VCC in Volt. This works on Arduinos with a 328 or 168 only. + + Source: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter + + How it works + + The Arduino 328 and 168 have a built in precision voltage reference of 1.1V. + This is used sometimes for precision measurement, + although for Arduino it usually makes more sense to measure against Vcc, + the positive power rail. + The chip has an internal switch that selects which pin the analogue to digital converter reads. + That switch has a few leftover connections, so the chip designers wired them up to useful signals. + One of those signals is that 1.1V reference. + So if you measure how large the known 1.1V reference is in comparison to Vcc, + you can back-calculate what Vcc is with a little algebra. That is how this works. + + """ + + reg = self.register.proxy + # 0b01001110 = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1) + reg.ADMUX = 0x4E + # Wait for Vref to settle + time.sleep(0.002) + # Convert + reg.ADCSRA |= 0x40 # 0b01000000 = _BV(ADSC) + while reg.ADCSRA & 0x40: # bit_is_set(ADCSRA, ADSC) + time.sleep(0.001) + result = reg.ADCL | (reg.ADCH << 8) + bandgap_voltage = 1.1 # Volt + result = (bandgap_voltage * 1023) / result + return result From a1c7cf9a2022268d0834acc52e8cdcf37bdc6ac4 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:24:39 +0100 Subject: [PATCH 158/344] new examples --- examples/dump.py | 82 -------------------------------- examples/highfreqpwm.py | 20 -------- examples/reset.py | 13 ----- nanpy/examples/__init__.py | 0 nanpy/examples/boottime.py | 15 ++++++ nanpy/examples/counterdemo.py | 26 ++++++++++ nanpy/examples/dump.py | 89 +++++++++++++++++++++++++++++++++++ nanpy/examples/highfreqpwm.py | 21 +++++++++ nanpy/examples/reset.py | 18 +++++++ 9 files changed, 169 insertions(+), 115 deletions(-) delete mode 100644 examples/dump.py delete mode 100644 examples/highfreqpwm.py delete mode 100755 examples/reset.py create mode 100644 nanpy/examples/__init__.py create mode 100644 nanpy/examples/boottime.py create mode 100644 nanpy/examples/counterdemo.py create mode 100644 nanpy/examples/dump.py create mode 100644 nanpy/examples/highfreqpwm.py create mode 100755 nanpy/examples/reset.py diff --git a/examples/dump.py b/examples/dump.py deleted file mode 100644 index 161097d..0000000 --- a/examples/dump.py +++ /dev/null @@ -1,82 +0,0 @@ -'''Dump all possible values from the AVR -''' - -from dicts.sorteddict import SortedDict -from entrypoint2 import entrypoint -from nanpy.arduino import Arduino -from nanpy.arduinocore import ArduinoCore -from nanpy.arduinopin import ArduinoPin -from nanpy.define import Define -from nanpy.resgister import Register -from nanpy.serialmanager import serial_manager -import inspect - -FORMAT = '%-20s = %20s' - - -def dump(obj, selected_names=None): - if selected_names: - ls = selected_names - else: - ls = dir(obj) - for attr in ls: - if not attr.startswith('__'): - if not inspect.ismethod(getattr(obj, attr)): - print FORMAT % (attr, getattr(obj, attr)) - - -def dump_dict(d): - for defname in sorted(d.keys()): - defvalue = d[defname] - print FORMAT % (defname, defvalue) - - -@entrypoint -def usbdump(): - serial_manager.connect('/dev/ttyS0') - - print FORMAT % ('totalPinCount', ArduinoCore.totalPinCount()) - print FORMAT % ('readVcc', ArduinoCore.readVcc()), 'V' - print FORMAT % ('millis', Arduino.millis() / 1000.0), 'sec' - - print - print '================================' - print 'pins:' - print '================================' - - print FORMAT % ('digital_names', ArduinoPin.digital_names()) - print FORMAT % ('analog_names', ArduinoPin.analog_names()) - - for nr in range(ArduinoCore.totalPinCount()): - print '---------- nr=%s ---------------' % nr - pin = ArduinoPin(nr) - dump( - pin, - 'name nr nr_analog is_digital is_analog avr_pin mode digital_value analog_value programming_function'.split()) - if pin.pwm.available: - print '--- pwm ---' - dump(pin.pwm, '''frequency frequencies_available base_divisor divisor divisors_available - timer_mode - timer_register_name_a - timer_register_name_b - wgm - '''.split()) - - print - print '================================' - print 'defines:' - print '================================' - dump_dict(Define.asDict()) - - print - print '================================' - print 'registers:' - print '================================' - for x in Register.names(): - r = Register(x) - if r.size == 2: - v = '0x%04X' % (r.value) - else: - v = ' 0x%02X' % (r.value) - - print '%-20s = %s @0x%2X (size:%s)' % (r.name, v, r.address, r.size) diff --git a/examples/highfreqpwm.py b/examples/highfreqpwm.py deleted file mode 100644 index 3ed0d67..0000000 --- a/examples/highfreqpwm.py +++ /dev/null @@ -1,20 +0,0 @@ -'''High frequency PWM mode demo -''' - -from nanpy.arduinopin import ArduinoPin - -FREQ = 10007 - - -def main(): - pin9 = ArduinoPin(9) - pin9.mode = 1 - pin9.write_digital_value(1) - pwm = pin9.pwm - print 'set frequency=%s Hz' % FREQ - pwm.set_high_freq_around(FREQ) - print 'real frequency=%s Hz' % pwm.read_frequency() - - -if __name__ == '__main__': - main() diff --git a/examples/reset.py b/examples/reset.py deleted file mode 100755 index d967555..0000000 --- a/examples/reset.py +++ /dev/null @@ -1,13 +0,0 @@ -"""soft reset demo.""" - -from nanpy.watchdog import Watchdog -from nanpy.arduino import Arduino - - -def print_millis(): - print ('uptime: %s sec' % (Arduino.millis() / 1000.0)) - -print_millis() -print ('soft reset') -Watchdog.soft_reset() -print_millis() diff --git a/nanpy/examples/__init__.py b/nanpy/examples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nanpy/examples/boottime.py b/nanpy/examples/boottime.py new file mode 100644 index 0000000..e25e965 --- /dev/null +++ b/nanpy/examples/boottime.py @@ -0,0 +1,15 @@ +from nanpy.arduinotree import ArduinoTree +import time + + +def boot_time(): + a = ArduinoTree() + a.watchdog.enable(a.watchdog.WDTO_500MS) + time.sleep(1) + a.connection.flush_input() + x = a.api.millis() + return 1000 - 500 - x + + +if __name__ == '__main__': + print ('boot_time %s ms' % boot_time()) diff --git a/nanpy/examples/counterdemo.py b/nanpy/examples/counterdemo.py new file mode 100644 index 0000000..8ea55a8 --- /dev/null +++ b/nanpy/examples/counterdemo.py @@ -0,0 +1,26 @@ +from nanpy.arduinotree import ArduinoTree +import time + + +GATE_TIME = 0.7 # sec +F = 9765 # Hz + + +def counterdemo(): + a = ArduinoTree() + p = a.pin.get(5) + a.soft_reset() + print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) + p.write_mode(1) + p.pwm.write_value(128) + p.pwm.frequency = F + print ('frequency set: %s' % p.pwm.frequency) + t1 = time.time() + fread = a.counter.read_frequency(GATE_TIME) + t2 = time.time() + print ('frequency read: %s' % fread) + print ('gate time: %s sec' % (GATE_TIME)) + print ('time elapsed: %s sec' % (t2 - t1)) + +if __name__ == '__main__': + counterdemo() diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py new file mode 100644 index 0000000..dc427b1 --- /dev/null +++ b/nanpy/examples/dump.py @@ -0,0 +1,89 @@ +"""Dump all possible values from the AVR.""" + +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager +from pprint import pprint +import inspect + +FORMAT = '%-20s = %20s' + + +def dump(obj, selected_names=None): + if selected_names: + ls = selected_names + else: + ls = dir(obj) + for attr in ls: + if not attr.startswith('__'): + if not inspect.ismethod(getattr(obj, attr)): + print(FORMAT % (attr, getattr(obj, attr))) + + +def dump_dict(d): + for defname in sorted(d.keys()): + defvalue = d[defname] + print(FORMAT % (defname, defvalue)) + + +def dumpall(): + connection = SerialManager() + a = ArduinoTree(connection=connection) + + print((FORMAT + ' V') % ('read_vcc', a.vcc.read())) + print((FORMAT + ' sec') % ('millis', a.api.millis() / 1000.0)) + + print('') + print('================================') + print('firmware classes:') + print('================================') + print('status:') + pprint(a.connection.classinfo.firmware_class_status) + print('unknown ids:') + pprint(a.connection.classinfo.unknown_firmware_ids) + + print('') + print('================================') + print('pins:') + print('================================') + + print(FORMAT % ('total_pin_count', a.pin.count)) + print(FORMAT % ('digital_names', a.pin.names_digital)) + print(FORMAT % ('analog_names', a.pin.names_analog)) + + for nr in range(a.pin.count): + print('---------- nr=%s ---------------' % nr) + pin = a.pin.get(nr) + dump( + pin, + 'name nr nr_analog is_digital is_analog avr_pin mode digital_value analog_value programming_function'.split()) + if pin.pwm.available: + print('--- pwm ---') + dump(pin.pwm, '''frequency frequencies_available base_divisor divisor divisors_available + timer_mode + timer_register_name_a + timer_register_name_b + wgm + '''.split()) + + print('') + print('================================') + print('defines:') + print('================================') + dump_dict(a.define.as_dict) + + print('') + print('================================') + print('registers:') + print('================================') + for x in a.register.names: + r = a.register.get(x) + if r.size == 2: + v = '0x%04X' % (r.value) + else: + v = ' 0x%02X' % (r.value) + + print('%-20s = %s @0x%2X (size:%s)' % (r.name, v, r.address, r.size)) + + +if __name__ == '__main__': + dumpall() diff --git a/nanpy/examples/highfreqpwm.py b/nanpy/examples/highfreqpwm.py new file mode 100644 index 0000000..211e5b5 --- /dev/null +++ b/nanpy/examples/highfreqpwm.py @@ -0,0 +1,21 @@ +'''High frequency PWM mode demo +''' + +from nanpy.arduinotree import ArduinoTree + +FREQ = 10007 + + +def highfreqpwm(): + a = ArduinoTree() + pin9 = a.pin.get(9) + pin9.mode = 1 + pin9.write_digital_value(1) + pwm = pin9.pwm + print ('set frequency=%s Hz' % FREQ) + pwm.set_high_freq_around(FREQ) + print ('real frequency=%s Hz' % pwm.read_frequency()) + + +if __name__ == '__main__': + highfreqpwm() diff --git a/nanpy/examples/reset.py b/nanpy/examples/reset.py new file mode 100755 index 0000000..82e5991 --- /dev/null +++ b/nanpy/examples/reset.py @@ -0,0 +1,18 @@ +"""soft reset demo.""" + +from nanpy.arduinotree import ArduinoTree + + +def print_millis(a): + print ('uptime: %s sec' % (a.api.millis() / 1000.0)) + + +def reset_demo(): + a = ArduinoTree() + print_millis(a) + print ('soft reset') + a.soft_reset() + print_millis(a) + +if __name__ == '__main__': + reset_demo() From 1e89c16503f7f18d118df20718b4ccb5dcab2fac Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:25:31 +0100 Subject: [PATCH 159/344] reworked tests --- tests/test_arduino.py | 25 ------- tests/test_arduinocore.py | 26 ------- tests/test_memo.py | 36 ++++++++++ tests/test_register.py | 44 ------------ tests/{ => test_serial}/config.py | 2 +- tests/test_serial/test.py | 25 +++++++ tests/test_serial/test_arduino.py | 21 ++++++ tests/test_serial/test_arduinocore.py | 20 ++++++ tests/test_serial/test_counter.py | 43 ++++++++++++ tests/{ => test_serial}/test_define.py | 23 ++++--- tests/test_serial/test_eeprom.py | 18 +++++ tests/test_serial/test_examples.py | 30 +++++++++ tests/test_serial/test_old.py | 17 +++++ tests/{ => test_serial}/test_pin.py | 93 +++++++++++++------------- tests/{ => test_serial}/test_pwm.py | 31 ++++----- tests/test_serial/test_register.py | 51 ++++++++++++++ tests/test_serial/test_reset.py | 13 ++++ tests/test_serial/test_watchdog.py | 16 +++++ tests/util.py | 26 ++++--- 19 files changed, 383 insertions(+), 177 deletions(-) delete mode 100644 tests/test_arduino.py delete mode 100644 tests/test_arduinocore.py create mode 100644 tests/test_memo.py delete mode 100644 tests/test_register.py rename tests/{ => test_serial}/config.py (84%) create mode 100644 tests/test_serial/test.py create mode 100644 tests/test_serial/test_arduino.py create mode 100644 tests/test_serial/test_arduinocore.py create mode 100644 tests/test_serial/test_counter.py rename tests/{ => test_serial}/test_define.py (53%) create mode 100644 tests/test_serial/test_eeprom.py create mode 100644 tests/test_serial/test_examples.py create mode 100644 tests/test_serial/test_old.py rename tests/{ => test_serial}/test_pin.py (51%) rename tests/{ => test_serial}/test_pwm.py (76%) create mode 100644 tests/test_serial/test_register.py create mode 100644 tests/test_serial/test_reset.py create mode 100644 tests/test_serial/test_watchdog.py diff --git a/tests/test_arduino.py b/tests/test_arduino.py deleted file mode 100644 index 2d6b7a9..0000000 --- a/tests/test_arduino.py +++ /dev/null @@ -1,25 +0,0 @@ -from config import config -from nanpy.arduino import Arduino -from nanpy.watchdog import Watchdog -from nose.tools import eq_, ok_ -from tests.util import ok_an - - -def setup(): - Watchdog.soft_reset() - -def teardown(): - pass - -def test(): - ok_(Arduino.millis()>1) - - ok_an(Arduino.analogRead(0)) - - - eq_(Arduino.pinModeRead(13), 0) - Arduino.pinMode(13,1) - eq_(Arduino.pinModeRead(13), 1) - Arduino.pinMode(13,0) - eq_(Arduino.pinModeRead(13), 0) - diff --git a/tests/test_arduinocore.py b/tests/test_arduinocore.py deleted file mode 100644 index b9311a4..0000000 --- a/tests/test_arduinocore.py +++ /dev/null @@ -1,26 +0,0 @@ -from config import config -from nanpy.arduinocore import ArduinoCore -from nanpy.watchdog import Watchdog -from nose.tools import eq_, ok_ -from tests.util import ok_vcc - - -def setup(): - Watchdog.soft_reset() - -def teardown(): - pass - - -def test(): - eq_(ArduinoCore.digitalPinToBitMask(2), 4) - eq_(ArduinoCore.digitalPinToPort(2), 4) - eq_(ArduinoCore.portModeRegister(2), 0) - eq_(ArduinoCore.digitalPinToTimer(2), 0) - eq_(ArduinoCore.analogInPinToBit(2), 2) - - eq_(ArduinoCore.portOutputRegister(2), 0) - eq_(ArduinoCore.portInputRegister(2), 0) - eq_(ArduinoCore.totalPinCount(), 20) - ok_vcc(ArduinoCore.readVcc()) - eq_(ArduinoCore.model(), config['model']) diff --git a/tests/test_memo.py b/tests/test_memo.py new file mode 100644 index 0000000..c7359df --- /dev/null +++ b/tests/test_memo.py @@ -0,0 +1,36 @@ +from nanpy.memo import memoized +from nose.tools import eq_ + + +class TestClass(object): + i = 1 + + @memoized + def met(self, x): + TestClass.i += 1 + return TestClass.i + + +def test1(): + o = TestClass() + eq_(o.i, 1) + o.met(3) + eq_(o.i, 2) + o.met(3) + eq_(o.i, 2) + o.met(4) + eq_(o.i, 3) + o.met(4) + o.met(4) + o.met(3) + o.met(3) + o.met(4) + eq_(o.i, 3) + + o2 = TestClass() + eq_(o.i, 3) + o2.met(4) + o2.met(4) + o2.met(4) + o2.met(4) + eq_(o.i, 4) diff --git a/tests/test_register.py b/tests/test_register.py deleted file mode 100644 index 0b68517..0000000 --- a/tests/test_register.py +++ /dev/null @@ -1,44 +0,0 @@ -from config import config -from nanpy.arduino import Arduino -from nanpy.arduinocore import ArduinoCore -from nanpy.resgister import Register -from nanpy.watchdog import Watchdog -from nose.tools import eq_, ok_, eq_, ok_ -from util import exc_ -import time - - - -def setup(): - Watchdog.soft_reset() - -def teardown(): - pass - - -def test_registers(): - print (Register.names()) - ok_(len(Register.names()) > 77) - - eq_(Register('DDRB').read_value(), 0) - eq_(Register('DDRB').value, 0) - exc_(ValueError, lambda x: Register('xxx').value, 0) - - Register('DDRB').write_value(5) - eq_(Register('DDRB').value, 5) - Register('DDRB').value = 3 - eq_(Register('DDRB').value, 3) - Register('DDRB').write_value(0) - - eq_(Register('DDRB').address, 0x24) - eq_(Register('DDRB').name, 'DDRB') - eq_(Register('DDRB').size, 1) - - - # 9 bit - eq_(Register('EEAR').size, 2) - Register('EEAR').value = 511 - eq_(Register('EEAR').value, 511) - - - diff --git a/tests/config.py b/tests/test_serial/config.py similarity index 84% rename from tests/config.py rename to tests/test_serial/config.py index f4ecba3..64b9458 100644 --- a/tests/config.py +++ b/tests/test_serial/config.py @@ -5,5 +5,5 @@ ARDUINO=105, F_CPU=20000000.0, MCU='__AVR_ATmega328P__', - model='ATmega328P', + avr_name='ATmega328P', ) diff --git a/tests/test_serial/test.py b/tests/test_serial/test.py new file mode 100644 index 0000000..7eeab4d --- /dev/null +++ b/tests/test_serial/test.py @@ -0,0 +1,25 @@ +from config import config +from nanpy.arduinotree import ArduinoTree +from nanpy.resgister import RegisterFeature +from nanpy.vcc import Vcc +from nose.tools import eq_, ok_ +from tests.util import ok_vcc, soft_reset + + +def setup(): + soft_reset() + + +def test_avr_name(): + a = ArduinoTree() + eq_(a.avr_name, config['avr_name']) + + +def test_vcc(): + a = ArduinoTree() + ok_vcc(a.vcc.read()) + + +def test_vcc2(): + vcc = Vcc(RegisterFeature()) + ok_vcc(vcc.read()) diff --git a/tests/test_serial/test_arduino.py b/tests/test_serial/test_arduino.py new file mode 100644 index 0000000..8b41ee1 --- /dev/null +++ b/tests/test_serial/test_arduino.py @@ -0,0 +1,21 @@ +from nose.tools import eq_, ok_ +from tests.util import ok_an, soft_reset +from nanpy.arduinotree import ArduinoTree + + +def setup(): + soft_reset() + + +def test(): + a = ArduinoTree() + pin13 = a.pin.get(13) + ok_(a.api.millis() > 1) + + ok_an(a.api.analogRead(0)) + + eq_(pin13.read_mode(), 0) + a.api.pinMode(13, 1) + eq_(pin13.read_mode(), 1) + a.api.pinMode(13, 0) + eq_(pin13.read_mode(), 0) diff --git a/tests/test_serial/test_arduinocore.py b/tests/test_serial/test_arduinocore.py new file mode 100644 index 0000000..0a7a062 --- /dev/null +++ b/tests/test_serial/test_arduinocore.py @@ -0,0 +1,20 @@ +from tests.util import soft_reset +from nanpy.arduinotree import ArduinoTree +from nose.tools import eq_ +from nose.tools import ok_ + + +def setup(): + soft_reset() + + +def test(): + a = ArduinoTree() + eq_(a.core.digitalPinToBitMask(2), 4) + eq_(a.core.digitalPinToPort(2), 4) + eq_(a.core.portModeRegister(2), 0) + eq_(a.core.digitalPinToTimer(2), 0) + eq_(a.core.analogInPinToBit(2), 2) + + eq_(a.core.portOutputRegister(2), 0) + eq_(a.core.portInputRegister(2), 0) diff --git a/tests/test_serial/test_counter.py b/tests/test_serial/test_counter.py new file mode 100644 index 0000000..d7e8fb5 --- /dev/null +++ b/tests/test_serial/test_counter.py @@ -0,0 +1,43 @@ +from __future__ import with_statement +from nanpy.arduinotree import ArduinoTree +from nanpy.counter import Counter +from nose.tools import ok_, eq_ +from config import config +from tests.util import soft_reset +import time + +OUTPUT = 1 + + +def setup(): + soft_reset() + + +def test_counter(): + a = ArduinoTree() + p = a.pin.get(5) + p.write_mode(OUTPUT) + p.pwm.write_value(128) + + counter1 = a.counter + counter2 = Counter(F_CPU=config['F_CPU']) + + print ('frequencies_available: %s' % p.pwm.frequencies_available) + for fset in p.pwm.frequencies_available: + p.pwm.frequency = fset + print('---------------------------') + print('fset=%s' % fset) + print('---------------------------') + for ms in [10, 20, 50, 100, 200, 500, 1000]: + print ('gate=%s ms' % ms) + t = ms / 1000.0 + error = a.counter.error(t) + print ('error=%s' % error) + + f1 = counter1.read_frequency(t) + f2 = counter2.read_frequency(t) + print (f1, f2) + diff1 = abs(f1 - fset) + diff2 = abs(f2 - fset) + ok_(diff1 <= (1.1 * error)) + ok_(diff2 <= (1.1 * error)) diff --git a/tests/test_define.py b/tests/test_serial/test_define.py similarity index 53% rename from tests/test_define.py rename to tests/test_serial/test_define.py index 68860f3..3fe5d88 100644 --- a/tests/test_define.py +++ b/tests/test_serial/test_define.py @@ -1,22 +1,23 @@ from config import config -from nanpy.define import Define -from nanpy.watchdog import Watchdog from nose.tools import eq_, ok_ -from util import exc_ +from tests.util import soft_reset +from nanpy.arduinotree import ArduinoTree +from nanpy.define import DefineFeature def setup(): - Watchdog.soft_reset() - -def teardown(): - pass + soft_reset() def test_defs(): - d = Define.asDict() + a = ArduinoTree() + d = a.define.as_dict print (d) - eq_(d['A0'], config['A0']) + + eq_(a.define.get('ARDUINO'), config['ARDUINO']) eq_(d['ARDUINO'], config['ARDUINO']) + + eq_(d['A0'], config['A0']) eq_(d['F_CPU'], config['F_CPU']) eq_(d['MCU'], config['MCU']) ok_('xx' not in d) @@ -26,3 +27,7 @@ def test_defs(): assert x.strip(), 'empty define:-->%s<--' % x +def test_defs2(): + a = ArduinoTree() + define = DefineFeature() + eq_(define.as_dict, a.define.as_dict) diff --git a/tests/test_serial/test_eeprom.py b/tests/test_serial/test_eeprom.py new file mode 100644 index 0000000..aef7082 --- /dev/null +++ b/tests/test_serial/test_eeprom.py @@ -0,0 +1,18 @@ +from nose.tools import eq_ +from nose.tools import ok_ +from nose.tools import eq_ +from nose.tools import ok_ +from tests.util import soft_reset +from tests.util import exc_ +from nanpy.arduinotree import ArduinoTree + + +def setup(): + soft_reset() + + +def test(): + a = ArduinoTree() + + eq_(a.eeprom.size, 1024) + eq_(a.eeprom.read(17), 255) diff --git a/tests/test_serial/test_examples.py b/tests/test_serial/test_examples.py new file mode 100644 index 0000000..754c785 --- /dev/null +++ b/tests/test_serial/test_examples.py @@ -0,0 +1,30 @@ +from nanpy.examples.boottime import boot_time +from nanpy.examples.counterdemo import counterdemo +from nanpy.examples.dump import dumpall +from nanpy.examples.highfreqpwm import highfreqpwm +from nanpy.examples.reset import reset_demo +from tests.util import soft_reset + + +def setup(): + soft_reset() + + +def test_dump(): + dumpall() + + +def test_boot_time(): + boot_time() + + +def test_reset_demo(): + reset_demo() + + +def test_highfreqpwm(): + highfreqpwm() + + +def test_counter(): + counterdemo() diff --git a/tests/test_serial/test_old.py b/tests/test_serial/test_old.py new file mode 100644 index 0000000..d12faa9 --- /dev/null +++ b/tests/test_serial/test_old.py @@ -0,0 +1,17 @@ +from nanpy.arduino import Arduino +from nose.tools import eq_, ok_ +from tests.util import ok_an, soft_reset + + +def setup(): + soft_reset() + + +def test(): + ok_(Arduino.millis()>1) + + ok_an(Arduino.analogRead(0)) + + Arduino.pinMode(13,1) + Arduino.pinMode(13,0) + diff --git a/tests/test_pin.py b/tests/test_serial/test_pin.py similarity index 51% rename from tests/test_pin.py rename to tests/test_serial/test_pin.py index 6a3008a..bafc545 100644 --- a/tests/test_pin.py +++ b/tests/test_serial/test_pin.py @@ -1,66 +1,65 @@ -from config import config -from nanpy.arduinopin import ArduinoPin -from nanpy.resgister import Register -from nanpy.watchdog import Watchdog -from nose.tools import eq_, ok_ -from tests.util import ok_an -from util import exc_ -import time +from nose.tools import eq_ +from nose.tools import ok_ +from tests.util import ok_an, soft_reset, exc_ +from nanpy.arduinotree import ArduinoTree + def setup(): - Watchdog.soft_reset() + soft_reset() -def teardown(): - pass INPUT, OUTPUT = 0, 1 + def test_pin_nr(): - pin = ArduinoPin(8) + a = ArduinoTree() + pin = a.pin.get(8) eq_(pin.nr, 8) eq_(pin.nr_analog, None) - pin = ArduinoPin(14) + pin = a.pin.get(14) eq_(pin.nr, 14) eq_(pin.nr_analog, 0) - pin = ArduinoPin('A1') + pin = a.pin.get('A1') eq_(pin.nr, 15) eq_(pin.nr_analog, 1) - pin = ArduinoPin('D9') + pin = a.pin.get('D9') eq_(pin.nr, 9) eq_(pin.nr_analog, None) - pin = ArduinoPin('A2') + pin = a.pin.get('A2') eq_(pin.nr, 16) eq_(pin.nr_analog, 2) def test_is(): - eq_(ArduinoPin(8).is_digital, True) - eq_(ArduinoPin(8).is_analog, False) - eq_(ArduinoPin('A2').is_digital, False) - eq_(ArduinoPin('A2').is_analog, True) + a = ArduinoTree() + eq_(a.pin.get(8).is_digital, True) + eq_(a.pin.get(8).is_analog, False) + eq_(a.pin.get('A2').is_digital, False) + eq_(a.pin.get('A2').is_analog, True) def test_name(): - eq_(ArduinoPin(8).name, 'D8') - eq_(ArduinoPin('D8').name, 'D8') - eq_(ArduinoPin(15).name, 'A1') - eq_(ArduinoPin('A2').name, 'A2') + a = ArduinoTree() + eq_(a.pin.get(8).name, 'D8') + eq_(a.pin.get('D8').name, 'D8') + eq_(a.pin.get(15).name, 'A1') + eq_(a.pin.get('A2').name, 'A2') def test_dig(): - pin = ArduinoPin(8) + a = ArduinoTree() + pin = a.pin.get(8) pin.reset() pin.write_mode(OUTPUT) pin.write_digital_value(1) - eq_(pin.read_digital_value(), 1) eq_(pin.digital_value, 1) @@ -81,10 +80,9 @@ def test_dig(): eq_(pin.digital_value, 1) - - def test_an(): - pin = ArduinoPin('A0') + a = ArduinoTree() + pin = a.pin.get('A0') pin.mode = INPUT ok_an(pin.read_analog_value()) ok_an(pin.analog_value) @@ -95,19 +93,21 @@ def test_an(): def test_mode(): - pin = ArduinoPin(8) + a = ArduinoTree() + DDRB = a.register.get('DDRB') + pin = a.pin.get(8) pin.reset() eq_(pin.mode, INPUT) eq_(pin.read_mode(), INPUT) - eq_(Register('DDRB').value, 0) + eq_(DDRB.value, 0) pin.write_mode(OUTPUT) eq_(pin.mode, OUTPUT) eq_(pin.read_mode(), OUTPUT) - eq_(Register('DDRB').value, 1) + eq_(DDRB.value, 1) - Register('DDRB').value = 0 + DDRB.value = 0 eq_(pin.mode, INPUT) pin.mode = OUTPUT @@ -118,20 +118,21 @@ def test_mode(): def test_pullup(): - pin = ArduinoPin(8) + a = ArduinoTree() + pin = a.pin.get(8) pin.write_pullup(True) - def test_pin_range(): - eq_(ArduinoPin.count(), 20) - eq_(ArduinoPin.count_analog(), 6) - eq_(ArduinoPin.count_digital(), 14) - -# eq_(ArduinoPin.range_all, range(0, 20)) -# eq_(ArduinoPin.range_analog, range(14, 20)) -# eq_(ArduinoPin.range_digital, range(0, 14)) - - ArduinoPin('A5') - exc_(ValueError, lambda: ArduinoPin('A6')) - exc_(ValueError, lambda: ArduinoPin('D14')) + a = ArduinoTree() + eq_(a.pin.count, 20) + eq_(a.pin.count_analog, 6) + eq_(a.pin.count_digital, 14) + +# eq_(a.pin.get.range_all, range(0, 20)) +# eq_(a.pin.get.range_analog, range(14, 20)) +# eq_(a.pin.get.range_digital, range(0, 14)) + + a.pin.get('A5') + exc_(ValueError, lambda: a.pin.get('A6')) + exc_(ValueError, lambda: a.pin.get('D14')) diff --git a/tests/test_pwm.py b/tests/test_serial/test_pwm.py similarity index 76% rename from tests/test_pwm.py rename to tests/test_serial/test_pwm.py index cabc5a0..5fc9266 100644 --- a/tests/test_pwm.py +++ b/tests/test_serial/test_pwm.py @@ -1,24 +1,23 @@ from config import config -from nanpy.arduinopin import ArduinoPin -from nanpy.resgister import Register -from nanpy.watchdog import Watchdog from nose.tools import eq_ +from tests.util import soft_reset +from nanpy.arduinotree import ArduinoTree def setup(): - Watchdog.soft_reset() + soft_reset() -def teardown(): - pass INPUT, OUTPUT = 0, 1 F_CPU = config.get('F_CPU') + def test_pwm(): - pin8 = ArduinoPin(8) - pin9 = ArduinoPin(9) + a = ArduinoTree() + pin8 = a.pin.get(8) + pin9 = a.pin.get(9) - TCCR1B = Register('TCCR1B') + TCCR1B = a.register.get('TCCR1B') eq_(pin8.pwm.available, False) eq_(pin9.pwm.available, True) @@ -26,13 +25,12 @@ def test_pwm(): eq_(pin9.pwm.base_divisor, 512) eq_(pin9.pwm.divisors_available, [1, 8, 64, 256, 1024]) - frequencies = [F_CPU / 2 ** 9, - F_CPU / 2 ** 12, - F_CPU / 2 ** 15, - F_CPU / 2 ** 17, - F_CPU / 2 ** 19, - ] - frequencies.sort() + frequencies = sorted([F_CPU / 2 ** 9, + F_CPU / 2 ** 12, + F_CPU / 2 ** 15, + F_CPU / 2 ** 17, + F_CPU / 2 ** 19, + ]) eq_(pin9.pwm.frequencies_available, frequencies) TCCR1B.value = 3 @@ -72,5 +70,4 @@ def test_pwm(): TCCR1B.value = 3 eq_(TCCR1B.value, 3) - pin9.pwm.write_value(45) diff --git a/tests/test_serial/test_register.py b/tests/test_serial/test_register.py new file mode 100644 index 0000000..8f523cd --- /dev/null +++ b/tests/test_serial/test_register.py @@ -0,0 +1,51 @@ +from nose.tools import eq_, ok_, eq_, ok_ +from tests.util import soft_reset, exc_ +from nanpy.arduinotree import ArduinoTree + + +def setup(): + soft_reset() + + +def test_registers(): + a = ArduinoTree() + print (a.register.names) + ok_(len(a.register.names) > 77) + + eq_(a.register.get('DDRB').read_value(), 0) + eq_(a.register.get('DDRB').value, 0) + exc_(ValueError, lambda x: a.register.get('xxx').value, 0) + + a.register.get('DDRB').write_value(5) + eq_(a.register.get('DDRB').value, 5) + a.register.get('DDRB').value = 3 + eq_(a.register.get('DDRB').value, 3) + a.register.get('DDRB').write_value(0) + + eq_(a.register.get('DDRB').address, 0x24) + eq_(a.register.get('DDRB').name, 'DDRB') + eq_(a.register.get('DDRB').size, 1) + + # 9 bit + eq_(a.register.get('EEAR').size, 2) + a.register.get('EEAR').value = 511 + eq_(a.register.get('EEAR').value, 511) + + +def test_register_proxy(): + a = ArduinoTree() + r = a.register.proxy + + eq_(r.DDRB, 0) + + r.DDRB = 5 + eq_(r.DDRB, 5) + r.DDRB = 3 + eq_(r.DDRB, 3) + eq_(a.register.get('DDRB').value, 3) + + r.DDRB = 0 + + # 9 bit + r.EEAR = 511 + eq_(r.EEAR, 511) diff --git a/tests/test_serial/test_reset.py b/tests/test_serial/test_reset.py new file mode 100644 index 0000000..5addb75 --- /dev/null +++ b/tests/test_serial/test_reset.py @@ -0,0 +1,13 @@ +from nanpy.arduinotree import ArduinoTree + + +# set it to 1000 for a good test (4 minutes) +REPEAT_TEST = 10 + + +def test_long(): + a = ArduinoTree() + for x in range(REPEAT_TEST): + print (x, ('uptime: %s sec' % (a.api.millis() / 1000.0))) + a.soft_reset() + diff --git a/tests/test_serial/test_watchdog.py b/tests/test_serial/test_watchdog.py new file mode 100644 index 0000000..a1ab76b --- /dev/null +++ b/tests/test_serial/test_watchdog.py @@ -0,0 +1,16 @@ +from nanpy.arduinotree import ArduinoTree +from nanpy.watchdog import Watchdog + + +def test(): + a = ArduinoTree(connection=None) + a.watchdog.reset() + a.watchdog.enable(a.watchdog.WDTO_1S) + a.watchdog.disable() + + +def test2(): + watchdog = Watchdog(connection=None) + watchdog.reset() + watchdog.enable(watchdog.WDTO_1S) + watchdog.disable() diff --git a/tests/util.py b/tests/util.py index d2e2631..ca34c73 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,14 +1,16 @@ +from nanpy.arduinotree import ArduinoTree from nose.tools import ok_ import tempfile def exc_(excClass, callableObj, *args, **kwargs): - """Fail unless an exception of class excClass is thrown - by callableObj when invoked with arguments args and keyword - arguments kwargs. If a different type of exception is - thrown, it will not be caught, and the test case will be - deemed to have suffered an error, exactly as for an - unexpected exception. + """Fail unless an exception of class excClass is thrown by callableObj when + invoked with arguments args and keyword arguments kwargs. + + If a different type of exception is thrown, it will not be caught, + and the test case will be deemed to have suffered an error, exactly + as for an unexpected exception. + """ try: callableObj(*args, **kwargs) @@ -19,13 +21,15 @@ def exc_(excClass, callableObj, *args, **kwargs): excName = excClass.__name__ else: excName = str(excClass) - raise Exception("%s not raised" % excName) - + raise Exception('%s not raised' % excName) + + def ok_an(x, pullup=False): print (x) ok_(x in range(1024)) -def ok_vcc(vcc): + +def ok_vcc(vcc): print ('vcc=', vcc) ok_(vcc < 5.5) ok_(vcc > 3) @@ -34,3 +38,7 @@ def ok_vcc(vcc): def tmpdir(dir=None, suffix=''): x = tempfile.mkdtemp(suffix=suffix, prefix='nanpy_test_', dir=dir) return x + + +def soft_reset(): + ArduinoTree().soft_reset() From 5d138dd945161fd7eda39b6704f30fe28d540cc4 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 18:35:25 +0100 Subject: [PATCH 160/344] remove py25 support --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6e58527..c9f0669 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -envlist = py25,py26,py27,py31,py32,py33 +envlist = py26,py27,py31,py32,py33 [testenv] deps= From 3269af206dfbce72a0251236ef639403e26323b1 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 20:49:44 +0100 Subject: [PATCH 161/344] SerialManager: 2 sec sleep, autodetection skippable, lazy open (#10) - configurable (default:2 sec) sleep after connect - port autodetection can be skipped - connect only if necessary (lazy open) --- nanpy/serialmanager.py | 65 ++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 8b00a02..1baf2fc 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -47,26 +47,31 @@ def readline(self): class SerialManager(object): + _serial = None - def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): + def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE, sleep_after_connect=2): + self.device = device self.baudrate = baudrate + self.sleep_after_connect = sleep_after_connect + + def connect(self, device=None): if device: - self.connect(device) - else: - # auto detection? - available_ports = _auto_detect_serial_unix() - try: - self.connect(available_ports[0]) - except: - print("Error trying to connect to Arduino") - self._serial = NoneSerialManager() - - def connect(self, device): - self._serial = serial.Serial(device, self.baudrate, timeout=1) -# time.sleep(2) - self.flush_input() + self.device = device + + if not self.device: + ports = _auto_detect_serial_unix() + assert len(ports), "No port was set, and no port was found!" + self.device = ports[0] + log.debug('opening port:%s [%s baud]' % (self.device, self.baudrate)) + assert self.device + self._serial = serial.Serial(self.device, self.baudrate, timeout=1) + if self.sleep_after_connect: + time.sleep(self.sleep_after_connect) + self._serial.flushInput() def write(self, value): + if not self._serial: + self.connect() log.debug('sending:%s' % repr(value)) if PY3: self._serial.write(bytes(value, 'latin-1')) @@ -74,6 +79,8 @@ def write(self, value): self._serial.write(value) def readline(self): + if not self._serial: + self.connect() s = self._serial.readline() log.debug('received:%s' % repr(s)) s = s.decode() @@ -83,32 +90,10 @@ def readline(self): def flush_input(self): '''Flush input buffer, discarding all it's contents.''' + if not self._serial: + self.connect() self._serial.flushInput() -# TODO: remove it -# created only for compaibility -class SerialManagerCompatibility(object): - def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE): - self.baudrate = baudrate - self.device = device - - @property - @memoized - def manager(self): - return SerialManager(self.device, self.baudrate) - - def connect(self, device): - return self.manager.connect(device) - - def write(self, value): - return self.manager.write(value) - - def readline(self): - return self.manager.readline() - - def flush_input(self): - return self.manager.flush_input() - -serial_manager = SerialManagerCompatibility() +serial_manager = SerialManager() From 3cb95521759fdc135ee72199eb3e4dfc9bbc0ab8 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 29 Dec 2013 20:50:27 +0100 Subject: [PATCH 162/344] speed up tests (skip sleep) --- nanpy/arduinotree.py | 4 ++-- nanpy/examples/dump.py | 3 +-- tests/README.md | 3 ++- tests/test_make.py | 2 +- tests/test_serial/common.py | 12 ++++++++++++ tests/test_serial/config.py | 3 +++ tests/test_serial/test.py | 5 +++-- tests/test_serial/test_arduino.py | 7 ++++--- tests/test_serial/test_arduinocore.py | 4 ++-- tests/test_serial/test_counter.py | 5 ++--- tests/test_serial/test_define.py | 4 ++-- tests/test_serial/test_eeprom.py | 10 +++------- tests/test_serial/test_examples.py | 4 ++-- tests/test_serial/test_old.py | 14 +++++++------- tests/test_serial/test_pin.py | 5 +++-- tests/test_serial/test_pwm.py | 4 ++-- tests/test_serial/test_register.py | 5 +++-- tests/test_serial/test_reset.py | 5 ++++- tests/test_serial/test_watchdog.py | 5 +++++ tests/util.py | 5 +---- 20 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 tests/test_serial/common.py diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index 2ef4cda..8d0c510 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -8,7 +8,7 @@ from nanpy.eepromobj import EepromLib from nanpy.memo import memoized from nanpy.resgister import RegisterFeature -from nanpy.serialmanager import SerialManager +from nanpy.serialmanager import SerialManager, serial_manager from nanpy.vcc import Vcc from nanpy.watchdog import Watchdog import time @@ -29,7 +29,7 @@ def __init__(self, connection=None): '' self.connection = connection if not connection: - self.connection = SerialManager() + self.connection = serial_manager if not hasattr(self.connection, 'classinfo'): self.connection.classinfo = ClassInfo(self.connection) diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py index dc427b1..441ff5c 100644 --- a/nanpy/examples/dump.py +++ b/nanpy/examples/dump.py @@ -26,8 +26,7 @@ def dump_dict(d): def dumpall(): - connection = SerialManager() - a = ArduinoTree(connection=connection) + a = ArduinoTree() print((FORMAT + ' V') % ('read_vcc', a.vcc.read())) print((FORMAT + ' sec') % ('millis', a.api.millis() / 1000.0)) diff --git a/tests/README.md b/tests/README.md index 65fcecf..9d14451 100644 --- a/tests/README.md +++ b/tests/README.md @@ -3,6 +3,7 @@ Testing - Install tox (http://tox.readthedocs.org) - connect Arduino with Nanpy firmware + - edit config.py - run tox in project directory: - tox \ No newline at end of file + tox diff --git a/tests/test_make.py b/tests/test_make.py index f3b8392..2f8a37a 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -5,7 +5,7 @@ import shutil -FIRMWARE = os.path.dirname( __file__ ) + '/../firmware/Nanpy' +FIRMWARE = os.path.dirname(__file__) + '/../firmware/Nanpy' def test_make(): diff --git a/tests/test_serial/common.py b/tests/test_serial/common.py new file mode 100644 index 0000000..0aabcf9 --- /dev/null +++ b/tests/test_serial/common.py @@ -0,0 +1,12 @@ +from config import config +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import serial_manager + + +def soft_reset(): + serial_manager.sleep_after_connect = config['sleep_after_connect'] + ArduinoTree().soft_reset() + + +def setup(): + soft_reset() diff --git a/tests/test_serial/config.py b/tests/test_serial/config.py index 64b9458..d18cd24 100644 --- a/tests/test_serial/config.py +++ b/tests/test_serial/config.py @@ -6,4 +6,7 @@ F_CPU=20000000.0, MCU='__AVR_ATmega328P__', avr_name='ATmega328P', + sleep_after_connect=0, ) + +# sleep_after_connect=2 is required for most of the boards ! diff --git a/tests/test_serial/test.py b/tests/test_serial/test.py index 7eeab4d..69078a7 100644 --- a/tests/test_serial/test.py +++ b/tests/test_serial/test.py @@ -3,11 +3,12 @@ from nanpy.resgister import RegisterFeature from nanpy.vcc import Vcc from nose.tools import eq_, ok_ -from tests.util import ok_vcc, soft_reset +from tests.util import ok_vcc +import common def setup(): - soft_reset() + common.setup() def test_avr_name(): diff --git a/tests/test_serial/test_arduino.py b/tests/test_serial/test_arduino.py index 8b41ee1..aeea59c 100644 --- a/tests/test_serial/test_arduino.py +++ b/tests/test_serial/test_arduino.py @@ -1,10 +1,11 @@ -from nose.tools import eq_, ok_ -from tests.util import ok_an, soft_reset from nanpy.arduinotree import ArduinoTree +from nose.tools import eq_, ok_ +from tests.util import ok_an +import common def setup(): - soft_reset() + common.setup() def test(): diff --git a/tests/test_serial/test_arduinocore.py b/tests/test_serial/test_arduinocore.py index 0a7a062..0b2578a 100644 --- a/tests/test_serial/test_arduinocore.py +++ b/tests/test_serial/test_arduinocore.py @@ -1,11 +1,11 @@ -from tests.util import soft_reset +import common from nanpy.arduinotree import ArduinoTree from nose.tools import eq_ from nose.tools import ok_ def setup(): - soft_reset() + common.setup() def test(): diff --git a/tests/test_serial/test_counter.py b/tests/test_serial/test_counter.py index d7e8fb5..5d2d4cf 100644 --- a/tests/test_serial/test_counter.py +++ b/tests/test_serial/test_counter.py @@ -3,14 +3,13 @@ from nanpy.counter import Counter from nose.tools import ok_, eq_ from config import config -from tests.util import soft_reset -import time +import common OUTPUT = 1 def setup(): - soft_reset() + common.setup() def test_counter(): diff --git a/tests/test_serial/test_define.py b/tests/test_serial/test_define.py index 3fe5d88..74eef95 100644 --- a/tests/test_serial/test_define.py +++ b/tests/test_serial/test_define.py @@ -1,12 +1,12 @@ from config import config from nose.tools import eq_, ok_ -from tests.util import soft_reset +import common from nanpy.arduinotree import ArduinoTree from nanpy.define import DefineFeature def setup(): - soft_reset() + common.setup() def test_defs(): diff --git a/tests/test_serial/test_eeprom.py b/tests/test_serial/test_eeprom.py index aef7082..5382155 100644 --- a/tests/test_serial/test_eeprom.py +++ b/tests/test_serial/test_eeprom.py @@ -1,14 +1,10 @@ -from nose.tools import eq_ -from nose.tools import ok_ -from nose.tools import eq_ -from nose.tools import ok_ -from tests.util import soft_reset -from tests.util import exc_ from nanpy.arduinotree import ArduinoTree +from nose.tools import eq_ +import common def setup(): - soft_reset() + common.setup() def test(): diff --git a/tests/test_serial/test_examples.py b/tests/test_serial/test_examples.py index 754c785..c63cece 100644 --- a/tests/test_serial/test_examples.py +++ b/tests/test_serial/test_examples.py @@ -3,11 +3,11 @@ from nanpy.examples.dump import dumpall from nanpy.examples.highfreqpwm import highfreqpwm from nanpy.examples.reset import reset_demo -from tests.util import soft_reset +import common def setup(): - soft_reset() + common.setup() def test_dump(): diff --git a/tests/test_serial/test_old.py b/tests/test_serial/test_old.py index d12faa9..076c596 100644 --- a/tests/test_serial/test_old.py +++ b/tests/test_serial/test_old.py @@ -1,17 +1,17 @@ from nanpy.arduino import Arduino from nose.tools import eq_, ok_ -from tests.util import ok_an, soft_reset +from tests.util import ok_an +import common def setup(): - soft_reset() + common.setup() def test(): - ok_(Arduino.millis()>1) - + ok_(Arduino.millis() > 1) + ok_an(Arduino.analogRead(0)) - - Arduino.pinMode(13,1) - Arduino.pinMode(13,0) + Arduino.pinMode(13, 1) + Arduino.pinMode(13, 0) diff --git a/tests/test_serial/test_pin.py b/tests/test_serial/test_pin.py index bafc545..d6115aa 100644 --- a/tests/test_serial/test_pin.py +++ b/tests/test_serial/test_pin.py @@ -1,11 +1,12 @@ from nose.tools import eq_ from nose.tools import ok_ -from tests.util import ok_an, soft_reset, exc_ +from tests.util import ok_an, exc_ from nanpy.arduinotree import ArduinoTree +import common def setup(): - soft_reset() + common.setup() INPUT, OUTPUT = 0, 1 diff --git a/tests/test_serial/test_pwm.py b/tests/test_serial/test_pwm.py index 5fc9266..f96f09a 100644 --- a/tests/test_serial/test_pwm.py +++ b/tests/test_serial/test_pwm.py @@ -1,11 +1,11 @@ from config import config from nose.tools import eq_ -from tests.util import soft_reset from nanpy.arduinotree import ArduinoTree +import common def setup(): - soft_reset() + common.setup() INPUT, OUTPUT = 0, 1 diff --git a/tests/test_serial/test_register.py b/tests/test_serial/test_register.py index 8f523cd..606486c 100644 --- a/tests/test_serial/test_register.py +++ b/tests/test_serial/test_register.py @@ -1,10 +1,11 @@ from nose.tools import eq_, ok_, eq_, ok_ -from tests.util import soft_reset, exc_ +from tests.util import exc_ from nanpy.arduinotree import ArduinoTree +import common def setup(): - soft_reset() + common.setup() def test_registers(): diff --git a/tests/test_serial/test_reset.py b/tests/test_serial/test_reset.py index 5addb75..6079222 100644 --- a/tests/test_serial/test_reset.py +++ b/tests/test_serial/test_reset.py @@ -1,6 +1,10 @@ from nanpy.arduinotree import ArduinoTree +import common +def setup(): + common.setup() + # set it to 1000 for a good test (4 minutes) REPEAT_TEST = 10 @@ -10,4 +14,3 @@ def test_long(): for x in range(REPEAT_TEST): print (x, ('uptime: %s sec' % (a.api.millis() / 1000.0))) a.soft_reset() - diff --git a/tests/test_serial/test_watchdog.py b/tests/test_serial/test_watchdog.py index a1ab76b..84b1298 100644 --- a/tests/test_serial/test_watchdog.py +++ b/tests/test_serial/test_watchdog.py @@ -1,5 +1,10 @@ from nanpy.arduinotree import ArduinoTree from nanpy.watchdog import Watchdog +import common + + +def setup(): + common.setup() def test(): diff --git a/tests/util.py b/tests/util.py index ca34c73..a8977e0 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,4 +1,5 @@ from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import serial_manager from nose.tools import ok_ import tempfile @@ -38,7 +39,3 @@ def ok_vcc(vcc): def tmpdir(dir=None, suffix=''): x = tempfile.mkdtemp(suffix=suffix, prefix='nanpy_test_', dir=dir) return x - - -def soft_reset(): - ArduinoTree().soft_reset() From 654e5a10e61f06a50d47439fcadbc2bf02f2c8d2 Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 30 Dec 2013 08:35:05 +0100 Subject: [PATCH 163/344] exception instead of assert --- nanpy/serialmanager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 1baf2fc..05a16f7 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -60,7 +60,8 @@ def connect(self, device=None): if not self.device: ports = _auto_detect_serial_unix() - assert len(ports), "No port was set, and no port was found!" + if not len(ports): + raise SerialManagerError("No port was set, and no port was found!") self.device = ports[0] log.debug('opening port:%s [%s baud]' % (self.device, self.baudrate)) assert self.device From a04ff2e09860a499bf774f4fa4a1b015d5170817 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 09:13:58 +0100 Subject: [PATCH 164/344] renames: nr -> pin_number, name2int -> to_pin_number --- nanpy/arduinopin.py | 53 +++++++++++++++++++---------------- nanpy/examples/dump.py | 8 +++--- tests/test.py | 26 +++++++++++++++++ tests/test_serial/test_pin.py | 20 ++++++------- 4 files changed, 69 insertions(+), 38 deletions(-) create mode 100644 tests/test.py diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py index 420cb84..98df136 100644 --- a/nanpy/arduinopin.py +++ b/nanpy/arduinopin.py @@ -17,17 +17,22 @@ class PinError(Exception): pass -def name2int(pin_name, A0): +def to_pin_number(pin_name, A0=None): try: if isinstance(pin_name, string_types): if pin_name[0] == 'D': nr = int(pin_name[1:]) - if nr >= A0: - raise ValueError('invalid pin id:%r' % pin_name) + if A0 is not None: + if nr >= A0: + raise ValueError('invalid pin id:%r' % pin_name) elif pin_name[0] == 'A': + if A0 is None: + raise ValueError('A0 is None, but analog pin was set! (%s)' % pin_name) nr = int(pin_name[1:]) + A0 else: nr = int(pin_name) + elif hasattr(pin_name, 'pin_number'): + nr=pin_name.pin_number else: nr = int(pin_name) except IndexError: @@ -55,10 +60,10 @@ def __init__(self, name, total_pin_count, define, register, core, api): self.api = api self.define = define self.A0 = define.get('A0') - self.nr = name2int(name, self.A0) - if self.nr >= total_pin_count: + self.pin_number = to_pin_number(name, self.A0) + if self.pin_number >= total_pin_count: raise ValueError('pin %s (Nr:%s) not in range' % - (name, self.nr)) + (name, self.pin_number)) @property @memoized @@ -67,7 +72,7 @@ def pwm(self): ''' return ( ArduinoPwmPin( - self.nr, + self.pin_number, self.define, self.register, self.core, @@ -76,7 +81,7 @@ def pwm(self): @property def is_digital(self): - return self.nr < self.A0 + return self.pin_number < self.A0 @property def is_analog(self): @@ -86,14 +91,14 @@ def is_analog(self): def avr_port(self): '''AVR port name (example: "B") ''' - x = self.core.digitalPinToPort(self.nr) + x = self.core.digitalPinToPort(self.pin_number) return chr(ord('A') + x - 1) @property def avr_bit(self): '''AVR bit name (example: "2") ''' - bitmask = self.core.digitalPinToBitMask(self.nr) + bitmask = self.core.digitalPinToBitMask(self.pin_number) i = 0 while bitmask != 1: bitmask >>= 1 @@ -116,26 +121,26 @@ def name(self): """ if self.is_digital: - return 'D%s' % self.nr + return 'D%s' % self.pin_number else: - return 'A%s' % self.nr_analog + return 'A%s' % self.pin_number_analog @property - def nr_analog(self): - x = self.nr - self.A0 + def pin_number_analog(self): + x = self.pin_number - self.A0 if x >= 0: return x @property def programming_function(self): """programming function (MISO, MOSI, SCK or SS)""" - if self.nr == self.define.get('MISO'): + if self.pin_number == self.define.get('MISO'): return 'MISO' - if self.nr == self.define.get('MOSI'): + if self.pin_number == self.define.get('MOSI'): return 'MOSI' - if self.nr == self.define.get('SCK'): + if self.pin_number == self.define.get('SCK'): return 'SCK' - if self.nr == self.define.get('SS'): + if self.pin_number == self.define.get('SS'): return 'SS' def reset(self): @@ -159,7 +164,7 @@ def read_digital_value(self, direction=None): """ if direction is not None: self.write_mode(direction) - return self.api.digitalRead(self.nr) + return self.api.digitalRead(self.pin_number) def write_digital_value(self, value, direction=None): """write digital value (0/1) @@ -173,7 +178,7 @@ def write_digital_value(self, value, direction=None): if direction is not None: self.write_mode(direction) value = 1 if value else 0 - return self.api.digitalWrite(self.nr, value) + return self.api.digitalWrite(self.pin_number, value) digital_value = property(read_digital_value, write_digital_value) @@ -182,20 +187,20 @@ def read_analog_value(self): ''' if not self.is_analog: return None - return self.api.analogRead(self.nr) + return self.api.analogRead(self.pin_number) analog_value = property(read_analog_value) def read_mode(self): """read mode (0/1)""" - bitmask = self.core.digitalPinToBitMask(self.nr) - port = self.core.digitalPinToPort(self.nr) + bitmask = self.core.digitalPinToBitMask(self.pin_number) + port = self.core.digitalPinToPort(self.pin_number) reg = self.core.portModeRegister(port) mode = OUTPUT if reg & bitmask else INPUT return mode def write_mode(self, value): """write mode (0/1)""" - return self.api.pinMode(self.nr, value) + return self.api.pinMode(self.pin_number, value) mode = property(read_mode, write_mode) diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py index 441ff5c..13fdc29 100644 --- a/nanpy/examples/dump.py +++ b/nanpy/examples/dump.py @@ -49,12 +49,12 @@ def dumpall(): print(FORMAT % ('digital_names', a.pin.names_digital)) print(FORMAT % ('analog_names', a.pin.names_analog)) - for nr in range(a.pin.count): - print('---------- nr=%s ---------------' % nr) - pin = a.pin.get(nr) + for pin_number in range(a.pin.count): + print('---------- pin_number=%s ---------------' % pin_number) + pin = a.pin.get(pin_number) dump( pin, - 'name nr nr_analog is_digital is_analog avr_pin mode digital_value analog_value programming_function'.split()) + 'name pin_number pin_number_analog is_digital is_analog avr_pin mode digital_value analog_value programming_function'.split()) if pin.pwm.available: print('--- pwm ---') dump(pin.pwm, '''frequency frequencies_available base_divisor divisor divisors_available diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..1407e6f --- /dev/null +++ b/tests/test.py @@ -0,0 +1,26 @@ +from nanpy.arduinopin import to_pin_number +from nose.tools import eq_ +from tests.util import exc_ + + +def test_to_pin_number(): + eq_(to_pin_number(0), 0) + eq_(to_pin_number(1, A0=None), 1) + eq_(to_pin_number(20, A0=5), 20) + + eq_(to_pin_number('D0', A0=None), 0) + eq_(to_pin_number('D7', A0=8), 7) + exc_(ValueError, lambda: to_pin_number('D7', A0=7)) + eq_(to_pin_number('D20', A0=21), 20) + + eq_(to_pin_number('A0', A0=0), 0) + eq_(to_pin_number('A0', A0=7), 7) + eq_(to_pin_number('A15', A0=5), 20) + exc_(ValueError, lambda: to_pin_number('A7', A0=None)) + + class Dummy(object): + pass + obj = Dummy() + obj.pin_number = 23 + eq_(to_pin_number(obj, A0=0), 23) + diff --git a/tests/test_serial/test_pin.py b/tests/test_serial/test_pin.py index d6115aa..4482d9a 100644 --- a/tests/test_serial/test_pin.py +++ b/tests/test_serial/test_pin.py @@ -16,24 +16,24 @@ def test_pin_nr(): a = ArduinoTree() pin = a.pin.get(8) - eq_(pin.nr, 8) - eq_(pin.nr_analog, None) + eq_(pin.pin_number, 8) + eq_(pin.pin_number_analog, None) pin = a.pin.get(14) - eq_(pin.nr, 14) - eq_(pin.nr_analog, 0) + eq_(pin.pin_number, 14) + eq_(pin.pin_number_analog, 0) pin = a.pin.get('A1') - eq_(pin.nr, 15) - eq_(pin.nr_analog, 1) + eq_(pin.pin_number, 15) + eq_(pin.pin_number_analog, 1) pin = a.pin.get('D9') - eq_(pin.nr, 9) - eq_(pin.nr_analog, None) + eq_(pin.pin_number, 9) + eq_(pin.pin_number_analog, None) pin = a.pin.get('A2') - eq_(pin.nr, 16) - eq_(pin.nr_analog, 2) + eq_(pin.pin_number, 16) + eq_(pin.pin_number_analog, 2) def test_is(): From be575c36aed36083f1538c61e620060dc3dfe842 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 09:18:00 +0100 Subject: [PATCH 165/344] shiftOut --- firmware/Nanpy/ArduinoClass.cpp | 6 +++++ nanpy/arduinoapi.py | 15 +++++++++++++ nanpy/shiftout.py | 36 ++++++++++++++++++++++++++++++ tests/test_serial/test_shiftout.py | 31 +++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 nanpy/shiftout.py create mode 100644 tests/test_serial/test_shiftout.py diff --git a/firmware/Nanpy/ArduinoClass.cpp b/firmware/Nanpy/ArduinoClass.cpp index 27ae76d..10543d8 100644 --- a/firmware/Nanpy/ArduinoClass.cpp +++ b/firmware/Nanpy/ArduinoClass.cpp @@ -39,4 +39,10 @@ void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "m") == 0) { // millis m->returns(millis()); } + + if (strcmp(m->getName(), "s") == 0) { // shiftOut + // shiftOut(dataPin, clockPin, bitOrder, value) + shiftOut(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); + m->returns(0); + } }; diff --git a/nanpy/arduinoapi.py b/nanpy/arduinoapi.py index 5aaf9fb..5dbe53d 100644 --- a/nanpy/arduinoapi.py +++ b/nanpy/arduinoapi.py @@ -10,6 +10,7 @@ class ArduinoApi(FirmwareClass): LOW, HIGH = 0, 1 INPUT, OUTPUT = 0, 1 + LSBFIRST, MSBFIRST = 0, 1 @arduinomethod('dw') def digitalWrite(self, pin, value): @@ -37,3 +38,17 @@ def pinMode(self, pin, mode): @arduinomethod('m') def millis(self): pass + + @returns(int) + @arduinomethod('s') + def shiftOut(self, dataPin, clockPin, bitOrder, value): + """Shifts out a byte of data one bit at a time. + + :param dataPin: the pin on which to output each bit (int) + :param clockPin: the pin to toggle once the dataPin has been set to the correct value (int) + :param bitOrder: which order to shift out the bits; either MSBFIRST or LSBFIRST. + :param value: the data to shift out. (byte) + + http://arduino.cc/en/Reference/shiftOut + + """ diff --git a/nanpy/shiftout.py b/nanpy/shiftout.py new file mode 100644 index 0000000..1d82820 --- /dev/null +++ b/nanpy/shiftout.py @@ -0,0 +1,36 @@ +from nanpy.arduinoapi import ArduinoApi +from nanpy.arduinopin import to_pin_number + + +class ShiftOut(object): + LSBFIRST, MSBFIRST = 0, 1 + + def __init__(self, data_pin, clock_pin, + bit_order=0, connection=None, A0=None): + """Shifts out a byte of data one bit at a time. + + :param data_pin: the pin on which to output each bit (int or string) + :param clock_pin: the pin to toggle once the dataPin has been set to the correct value (int or string) + :param bit_order: which order to shift out the bits; either MSBFIRST or LSBFIRST. + + """ + if connection and hasattr(connection, 'shiftOut'): + self._shiftOut_func = connection.shiftOut + else: + api = ArduinoApi(connection=connection) + self._shiftOut_func = api.shiftOut + self.bit_order = bit_order + self.data_pin_number = to_pin_number(data_pin, A0) + self.clock_pin_number = to_pin_number(clock_pin, A0) + + def write_data(self, data): + """Shifts out a byte of data one bit at a time. + + :param data: the data to shift out. (byte) + + """ + self._shiftOut_func( + self.data_pin_number, + self.clock_pin_number, + self.bit_order, + data) diff --git a/tests/test_serial/test_shiftout.py b/tests/test_serial/test_shiftout.py new file mode 100644 index 0000000..a252454 --- /dev/null +++ b/tests/test_serial/test_shiftout.py @@ -0,0 +1,31 @@ +from __future__ import with_statement +from config import config +from nanpy.arduinotree import ArduinoTree +from nanpy.shiftout import ShiftOut +from nose.tools import ok_ +from nose.tools import eq_ +import common + + +A0 = config['A0'] + + +def setup(): + common.setup() + + +def test_shift1(): + s = ShiftOut('D13', 'D12', 0, A0=A0) + s.write_data(0b01010101) + + +def test_shift2(): + s = ShiftOut(13, 'A1', 0, A0=A0) + s.write_data(0b01010101) + + +def test_shift3(): + a = ArduinoTree() + p = a.pin.get(13) + s = ShiftOut(p, 12, 0, A0=A0) + s.write_data(0b01010101) From b5855b371d6d82fd9e2f5aa70965c012dd62868a Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 09:21:01 +0100 Subject: [PATCH 166/344] support AD9850 --- nanpy/ad9850.py | 101 +++++++++++++++++++++++++++++ nanpy/examples/dds.py | 20 ++++++ tests/test_serial/test_examples.py | 6 ++ 3 files changed, 127 insertions(+) create mode 100644 nanpy/ad9850.py create mode 100644 nanpy/examples/dds.py diff --git a/nanpy/ad9850.py b/nanpy/ad9850.py new file mode 100644 index 0000000..1a6aa3b --- /dev/null +++ b/nanpy/ad9850.py @@ -0,0 +1,101 @@ +from __future__ import division +from nanpy.arduinotree import ArduinoTree +from nanpy.memo import memoized +from nanpy.shiftout import ShiftOut + + +LOW, HIGH = 0, 1 +OUTPUT = 1 + + +class AD9850(object): + + """controllling the AD9850 DDS module. + + code is based on this info: http://nr8o.dhlpilotcentral.com/?p=83 + + """ + clock = 125000000 # note 125 MHz clock on 9850 + _frequency = 0 + + def __init__(self, pin_names, connection=None): + ''' + :param pin_names: [W_CLK, FQ_UD, DATA, RESET] + W_CLK // Pin 8 - connect to AD9850 module word load clock pin (CLK) + FQ_UD // Pin 9 - connect to freq update pin (FQ) + DATA // Pin 10 - connect to serial data load pin (DATA) + RESET // Pin 11 - connect to reset pin (RST). + ''' + self.connection = connection + self.pin_names = dict( + W_CLK=pin_names[0], + FQ_UD=pin_names[1], + DATA=pin_names[2], + RESET=pin_names[3]) + + @property + @memoized + def arduino(self): + return ArduinoTree(connection=self.connection) + + def create_pin_object(self, name): + return self.arduino.pin.get(self.pin_names[name]) + + @property + @memoized + def W_CLK(self): + return self.create_pin_object('W_CLK') + + @property + @memoized + def FQ_UD(self): + return self.create_pin_object('FQ_UD') + + @property + @memoized + def DATA(self): + return self.create_pin_object('DATA') + + @property + @memoized + def RESET(self): + return self.create_pin_object('RESET') + + @property + @memoized + def shift(self): + return ShiftOut(self.DATA, self.W_CLK, 0, connection=self.connection) + + def pulse_high(self, pin): + pin.write_digital_value(HIGH) + pin.write_digital_value(LOW) + + def setup(self): + self.FQ_UD.write_mode(OUTPUT) + self.W_CLK.write_mode(OUTPUT) + self.DATA.write_mode(OUTPUT) + self.RESET.write_mode(OUTPUT) + + self.pulse_high(self.RESET) + self.pulse_high(self.W_CLK) + # this pulse enables serial mode - Datasheet page 12 figure 10 + self.pulse_high(self.FQ_UD) + + def tfr_byte(self, value): + self.shift.write_data(value) + + def write_frequency(self, frequency): + # frequency calc from datasheet page 8 = + # * /2^32 + CONST = 4294967295 # 2^32 - 1 + freq = frequency * CONST / self.clock + freq = int(freq) + for b in range(4): + self.tfr_byte((freq >> (8 * b)) & 0xFF) + + self.tfr_byte(0x000) # Final control byte, all 0 for 9850 chip + self.pulse_high(self.FQ_UD) # Done! Should see output + self._frequency = frequency + + # frequency read is not implemented + frequency = property(lambda self: self._frequency, write_frequency) diff --git a/nanpy/examples/dds.py b/nanpy/examples/dds.py new file mode 100644 index 0000000..7a1d775 --- /dev/null +++ b/nanpy/examples/dds.py @@ -0,0 +1,20 @@ +from nanpy.ad9850 import AD9850 + +# http://nr8o.dhlpilotcentral.com/?p=83 +W_CLK = 'A5' # Pin 8 - connect to AD9850 module word load clock pin (CLK) +FQ_UD = 'A4' # Pin 9 - connect to freq update pin (FQ) +DATA = 'A3' # Pin 10 - connect to serial data load pin (DATA) +RESET = 'A2' # Pin 11 - connect to reset pin (RST). + +F = 440 # Hz + + +def dds(): + dds = AD9850([W_CLK, FQ_UD, DATA, RESET]) + + dds.setup() + dds.write_frequency(F) + + +if __name__ == '__main__': + dds() diff --git a/tests/test_serial/test_examples.py b/tests/test_serial/test_examples.py index c63cece..3169702 100644 --- a/tests/test_serial/test_examples.py +++ b/tests/test_serial/test_examples.py @@ -1,5 +1,7 @@ from nanpy.examples.boottime import boot_time +from nanpy.examples.checkspeed import checkspeed from nanpy.examples.counterdemo import counterdemo +from nanpy.examples.dds import dds from nanpy.examples.dump import dumpall from nanpy.examples.highfreqpwm import highfreqpwm from nanpy.examples.reset import reset_demo @@ -28,3 +30,7 @@ def test_highfreqpwm(): def test_counter(): counterdemo() + + +def test_dds(): + dds() From a0d265d49dbc4d082fe6ea8ce318a5cdca2bf48b Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 09:21:27 +0100 Subject: [PATCH 167/344] new example: checkspeed --- nanpy/examples/checkspeed.py | 68 ++++++++++++++++++++++++++++++ tests/test_serial/test_examples.py | 4 ++ 2 files changed, 72 insertions(+) create mode 100644 nanpy/examples/checkspeed.py diff --git a/nanpy/examples/checkspeed.py b/nanpy/examples/checkspeed.py new file mode 100644 index 0000000..65e1e73 --- /dev/null +++ b/nanpy/examples/checkspeed.py @@ -0,0 +1,68 @@ +from nanpy.ad9850 import AD9850 +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import serial_manager +import time + + +def measure(a, n, f, root='a'): + start = time.time() + for x in range(n): + cmd = root + '.' + f + try: + locals()[root] = a + exec (cmd) + except: + print (cmd) + raise + dt = time.time() - start + print ('%-35s %8.2f ms per call, %5.0f call per second' % (f, 1000.0 * dt / n, 1.0 / dt * n)) + + +def checkspeed(n): + serial_manager.connect() + a = ArduinoTree() + + print ('performance test for ArduinoTree()') + print ('n=%s' % n) + print('') + + a.avr_name # init cache + measure(a, n, 'avr_name') + + measure(a, n, 'api.digitalRead(0)') + measure(a, n, 'api.digitalWrite(0,0)') + measure(a, n, 'api.analogRead(0)') + measure(a, n, 'api.analogWrite(0,0)') + measure(a, n, 'api.pinMode(0,0)') + measure(a, n, 'api.millis()') + measure(a, n, 'api.shiftOut(0, 1, 0, 15)') + + a.define.get('__TIME__') # init cache + measure(a, n, 'define.get("__TIME__")') + + a.register.get('DDRB') # init cache + measure(a, n, 'register.get("DDRB").read_value()') + measure(a, n, 'register.get("DDRB").address') + measure(a, n, 'register.get("DDRB").size') + + a.vcc.read() # init cache + measure(a, n, 'vcc.read()') + + measure(a, n, 'pin.get(0).read_digital_value()') + measure(a, n, 'pin.get(0).read_mode()') + + a.eeprom.size # init cache + measure(a, n, 'eeprom.size') + measure(a, n, 'eeprom.read(0)') + + print('') + print ('performance test for AD9850()') + print('') + + ad9850 = AD9850([0, 1, 2, 3]) + measure(ad9850, n, 'setup()', root='ad9850') + measure(ad9850, n, 'write_frequency(400)', root='ad9850') + + +if __name__ == '__main__': + checkspeed(n=100) diff --git a/tests/test_serial/test_examples.py b/tests/test_serial/test_examples.py index 3169702..dcabb29 100644 --- a/tests/test_serial/test_examples.py +++ b/tests/test_serial/test_examples.py @@ -34,3 +34,7 @@ def test_counter(): def test_dds(): dds() + + +def test_checkspeed(): + checkspeed(n=1) From 5f816c1db00fbc4978f0b49f27366bc116dcc53e Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 09:29:17 +0100 Subject: [PATCH 168/344] fix module name --- nanpy/arduinotree.py | 2 +- nanpy/{resgister.py => register.py} | 0 tests/test_serial/test.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename nanpy/{resgister.py => register.py} (100%) diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index 8d0c510..f3708e8 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -7,7 +7,7 @@ from nanpy.define import DefineFeature from nanpy.eepromobj import EepromLib from nanpy.memo import memoized -from nanpy.resgister import RegisterFeature +from nanpy.register import RegisterFeature from nanpy.serialmanager import SerialManager, serial_manager from nanpy.vcc import Vcc from nanpy.watchdog import Watchdog diff --git a/nanpy/resgister.py b/nanpy/register.py similarity index 100% rename from nanpy/resgister.py rename to nanpy/register.py diff --git a/tests/test_serial/test.py b/tests/test_serial/test.py index 69078a7..9e27cd2 100644 --- a/tests/test_serial/test.py +++ b/tests/test_serial/test.py @@ -1,6 +1,6 @@ from config import config from nanpy.arduinotree import ArduinoTree -from nanpy.resgister import RegisterFeature +from nanpy.register import RegisterFeature from nanpy.vcc import Vcc from nose.tools import eq_, ok_ from tests.util import ok_vcc From b5b238be7bc13c8c141bc8fbebb3dd4c56ec0b04 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 16:08:22 +0100 Subject: [PATCH 169/344] optimize DefineClass --- firmware/Nanpy/DefineClass.cpp | 20 ++++++++++---------- firmware/Nanpy/intdefs.h | 4 ++-- nanpy/define.py | 8 +++++++- tests/test_serial/test_define.py | 8 ++++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/firmware/Nanpy/DefineClass.cpp b/firmware/Nanpy/DefineClass.cpp index 328512d..ab27dca 100644 --- a/firmware/Nanpy/DefineClass.cpp +++ b/firmware/Nanpy/DefineClass.cpp @@ -56,21 +56,21 @@ void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) int index = m->getInt(0); switch (index) { - case 0: + case COUNT_INT_DEFS + 0: m->returns("__TIME__"); break; - case 1: + case COUNT_INT_DEFS + 1: m->returns("__DATE__"); break; - case 2: + case COUNT_INT_DEFS + 2: m->returns("__VERSION__"); break; - case 3: + case COUNT_INT_DEFS + 3: m->returns("MCU"); break; default: - index -= COUNT_STR_DEFS; +// index -= COUNT_STR_DEFS; char buffer[LONGEST_STRING_IN_INTDEFS_H]; strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); m->returns(buffer); @@ -81,21 +81,21 @@ void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) int index = m->getInt(0); switch (index) { - case 0: + case COUNT_INT_DEFS + 0: m->returns(__TIME__); break; - case 1: + case COUNT_INT_DEFS + 1: m->returns(__DATE__); break; - case 2: + case COUNT_INT_DEFS + 2: m->returns(__VERSION__); break; - case 3: + case COUNT_INT_DEFS + 3: m->returns(MCU); break; default: - index -= COUNT_STR_DEFS; +// index -= COUNT_STR_DEFS; int32_t value = pgm_read_dword(&(value_table[index])); m->returns(value); } diff --git a/firmware/Nanpy/intdefs.h b/firmware/Nanpy/intdefs.h index a97a6f1..296a453 100644 --- a/firmware/Nanpy/intdefs.h +++ b/firmware/Nanpy/intdefs.h @@ -1,5 +1,6 @@ - +// frequently used constants should be placed first +DEFINE(A0) DEFINE(RAMEND) DEFINE(XRAMEND) DEFINE(E2END) @@ -12,6 +13,5 @@ DEFINE(SS) DEFINE(MOSI) DEFINE(MISO) DEFINE(SCK) -DEFINE(A0) DEFINE(__AVR_LIBC_DATE_) DEFINE(__AVR_LIBC_VERSION__) diff --git a/nanpy/define.py b/nanpy/define.py index 397d43d..d7bdfe8 100644 --- a/nanpy/define.py +++ b/nanpy/define.py @@ -76,4 +76,10 @@ def get(self, name): a.define.get('F_CPU') # AVR frequency """ - return self.as_dict.get(name) + count = self._arr.count + assert count + for i in range(count): + n = self._arr.name(i) + if n == name: + return self._arr.value(i) + raise ValueError('% was not found!' % name) diff --git a/tests/test_serial/test_define.py b/tests/test_serial/test_define.py index 74eef95..8639d57 100644 --- a/tests/test_serial/test_define.py +++ b/tests/test_serial/test_define.py @@ -11,6 +11,9 @@ def setup(): def test_defs(): a = ArduinoTree() + + eq_(a.define.get('A0'), config['A0']) + d = a.define.as_dict print (d) @@ -23,6 +26,11 @@ def test_defs(): ok_('xx' not in d) ok_(len(d.keys()) > 15, len(d.keys())) + ARDUINO = a.define.get('ARDUINO') + ok_(ARDUINO >= 100) + ok_(ARDUINO < 200) + + for x in d: assert x.strip(), 'empty define:-->%s<--' % x From f9d51c3c5702f0da7df62d88e8c0734157105616 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 16:08:53 +0100 Subject: [PATCH 170/344] use NUM_DIGITAL_PINS constant --- firmware/Nanpy/intdefs.h | 1 + nanpy/arduinopin.py | 16 +--------------- tests/test_serial/test_define.py | 3 +++ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/firmware/Nanpy/intdefs.h b/firmware/Nanpy/intdefs.h index 296a453..9ad0eee 100644 --- a/firmware/Nanpy/intdefs.h +++ b/firmware/Nanpy/intdefs.h @@ -1,6 +1,7 @@ // frequently used constants should be placed first DEFINE(A0) +DEFINE(NUM_DIGITAL_PINS) DEFINE(RAMEND) DEFINE(XRAMEND) DEFINE(E2END) diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py index 98df136..13e53f3 100644 --- a/nanpy/arduinopin.py +++ b/nanpy/arduinopin.py @@ -241,22 +241,8 @@ def count_digital(self): @memoized def count(self): """Count of all pins. - - HACK! - """ - # HACK! - for i in range(100): - x = self.core.digitalPinToBitMask(i) - ok = False - for j in range(8): - if x == (1 << j): - ok = True - break - - if not ok: - return i - raise PinError('Can not calculate pin count!') + return self.define.get('NUM_DIGITAL_PINS') @property def names(self): diff --git a/tests/test_serial/test_define.py b/tests/test_serial/test_define.py index 8639d57..9a45ad1 100644 --- a/tests/test_serial/test_define.py +++ b/tests/test_serial/test_define.py @@ -30,6 +30,9 @@ def test_defs(): ok_(ARDUINO >= 100) ok_(ARDUINO < 200) + NUM_DIGITAL_PINS = a.define.get('NUM_DIGITAL_PINS') + ok_(NUM_DIGITAL_PINS >= 10) + ok_(NUM_DIGITAL_PINS < 1000) for x in d: assert x.strip(), 'empty define:-->%s<--' % x From 021aecce0c272eef7878c94611cd01ca28b6a0ce Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 5 Jan 2014 16:19:46 +0100 Subject: [PATCH 171/344] explicit use of SerialManager in examples --- nanpy/examples/boottime.py | 4 +++- nanpy/examples/checkspeed.py | 11 +++++++---- nanpy/examples/counterdemo.py | 4 +++- nanpy/examples/dds.py | 4 +++- nanpy/examples/dump.py | 4 +++- nanpy/examples/highfreqpwm.py | 7 ++++--- nanpy/examples/reset.py | 4 +++- 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/nanpy/examples/boottime.py b/nanpy/examples/boottime.py index e25e965..b838798 100644 --- a/nanpy/examples/boottime.py +++ b/nanpy/examples/boottime.py @@ -1,9 +1,11 @@ from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager import time def boot_time(): - a = ArduinoTree() + connection = SerialManager() + a = ArduinoTree(connection=connection) a.watchdog.enable(a.watchdog.WDTO_500MS) time.sleep(1) a.connection.flush_input() diff --git a/nanpy/examples/checkspeed.py b/nanpy/examples/checkspeed.py index 65e1e73..20e3e58 100644 --- a/nanpy/examples/checkspeed.py +++ b/nanpy/examples/checkspeed.py @@ -1,7 +1,7 @@ from nanpy.ad9850 import AD9850 from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import serial_manager import time +from nanpy.serialmanager import SerialManager def measure(a, n, f, root='a'): @@ -15,12 +15,15 @@ def measure(a, n, f, root='a'): print (cmd) raise dt = time.time() - start - print ('%-35s %8.2f ms per call, %5.0f call per second' % (f, 1000.0 * dt / n, 1.0 / dt * n)) + print ( + '%-35s %8.2f ms per call, %5.0f call per second' % + (f, 1000.0 * dt / n, 1.0 / dt * n)) def checkspeed(n): - serial_manager.connect() - a = ArduinoTree() + connection = SerialManager() + connection.connect() + a = ArduinoTree(connection=connection) print ('performance test for ArduinoTree()') print ('n=%s' % n) diff --git a/nanpy/examples/counterdemo.py b/nanpy/examples/counterdemo.py index 8ea55a8..5c6850f 100644 --- a/nanpy/examples/counterdemo.py +++ b/nanpy/examples/counterdemo.py @@ -1,5 +1,6 @@ from nanpy.arduinotree import ArduinoTree import time +from nanpy.serialmanager import SerialManager GATE_TIME = 0.7 # sec @@ -7,7 +8,8 @@ def counterdemo(): - a = ArduinoTree() + connection = SerialManager() + a = ArduinoTree(connection=connection) p = a.pin.get(5) a.soft_reset() print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) diff --git a/nanpy/examples/dds.py b/nanpy/examples/dds.py index 7a1d775..6e72c7c 100644 --- a/nanpy/examples/dds.py +++ b/nanpy/examples/dds.py @@ -1,4 +1,5 @@ from nanpy.ad9850 import AD9850 +from nanpy.serialmanager import SerialManager # http://nr8o.dhlpilotcentral.com/?p=83 W_CLK = 'A5' # Pin 8 - connect to AD9850 module word load clock pin (CLK) @@ -10,7 +11,8 @@ def dds(): - dds = AD9850([W_CLK, FQ_UD, DATA, RESET]) + connection = SerialManager() + dds = AD9850([W_CLK, FQ_UD, DATA, RESET], connection=connection) dds.setup() dds.write_frequency(F) diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py index 13fdc29..84fced8 100644 --- a/nanpy/examples/dump.py +++ b/nanpy/examples/dump.py @@ -4,6 +4,7 @@ from nanpy.serialmanager import SerialManager from pprint import pprint import inspect +from nanpy.serialmanager import SerialManager FORMAT = '%-20s = %20s' @@ -26,7 +27,8 @@ def dump_dict(d): def dumpall(): - a = ArduinoTree() + connection = SerialManager() + a = ArduinoTree(connection=connection) print((FORMAT + ' V') % ('read_vcc', a.vcc.read())) print((FORMAT + ' sec') % ('millis', a.api.millis() / 1000.0)) diff --git a/nanpy/examples/highfreqpwm.py b/nanpy/examples/highfreqpwm.py index 211e5b5..e3a5234 100644 --- a/nanpy/examples/highfreqpwm.py +++ b/nanpy/examples/highfreqpwm.py @@ -1,13 +1,14 @@ -'''High frequency PWM mode demo -''' +"""High frequency PWM mode demo.""" from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager FREQ = 10007 def highfreqpwm(): - a = ArduinoTree() + connection = SerialManager() + a = ArduinoTree(connection=connection) pin9 = a.pin.get(9) pin9.mode = 1 pin9.write_digital_value(1) diff --git a/nanpy/examples/reset.py b/nanpy/examples/reset.py index 82e5991..9d30873 100755 --- a/nanpy/examples/reset.py +++ b/nanpy/examples/reset.py @@ -1,6 +1,7 @@ """soft reset demo.""" from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager def print_millis(a): @@ -8,7 +9,8 @@ def print_millis(a): def reset_demo(): - a = ArduinoTree() + connection = SerialManager() + a = ArduinoTree(connection=connection) print_millis(a) print ('soft reset') a.soft_reset() From 1cc1bd17342721b4483e599281ae3d40cca08346 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 12 Jan 2014 11:54:14 +0100 Subject: [PATCH 172/344] fix counter for 16MHz --- nanpy/counter.py | 13 +++++++------ tests/test.py | 13 +++++++++++++ tests/test_serial/config.py | 25 +++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/nanpy/counter.py b/nanpy/counter.py index ff111d7..1747748 100644 --- a/nanpy/counter.py +++ b/nanpy/counter.py @@ -45,18 +45,19 @@ def __init__(self, connection=None, F_CPU=None): if F_CPU: self.multiplier = self.calculate_multiplier(F_CPU) - def calculate_multiplier(self, F_CPU): + @classmethod + def calculate_multiplier(cls, F_CPU): multiplier = 1 # calculate multiplier for non supported frequencies - if F_CPU > 16000000: + if F_CPU >= 16000000: multiplier = F_CPU / 16000000 - elif F_CPU > 8000000: + elif F_CPU >= 8000000: multiplier = F_CPU / 8000000 - elif F_CPU > 4000000: + elif F_CPU >= 4000000: multiplier = F_CPU / 4000000 - elif F_CPU > 2000000: + elif F_CPU >= 2000000: multiplier = F_CPU / 2000000 - elif F_CPU > 1000000: + elif F_CPU >= 1000000: multiplier = F_CPU / 1000000 else: multiplier = 1000000 / F_CPU diff --git a/tests/test.py b/tests/test.py index 1407e6f..dd7874d 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,4 +1,5 @@ from nanpy.arduinopin import to_pin_number +from nanpy.counter import Counter from nose.tools import eq_ from tests.util import exc_ @@ -24,3 +25,15 @@ class Dummy(object): obj.pin_number = 23 eq_(to_pin_number(obj, A0=0), 23) + +def test_calculate_multiplier(): + Mhz = 1e6 + + eq_(Counter.calculate_multiplier(16 * Mhz), 1) + eq_(Counter.calculate_multiplier(8 * Mhz), 1) + eq_(Counter.calculate_multiplier(4 * Mhz), 1) + eq_(Counter.calculate_multiplier(2 * Mhz), 1) + eq_(Counter.calculate_multiplier(1 * Mhz), 1) + + eq_(Counter.calculate_multiplier(20 * Mhz), 20 / 16.0) + eq_(Counter.calculate_multiplier(10 * Mhz), 10 / 8.0) diff --git a/tests/test_serial/config.py b/tests/test_serial/config.py index d18cd24..cde65e8 100644 --- a/tests/test_serial/config.py +++ b/tests/test_serial/config.py @@ -1,12 +1,33 @@ +# sleep_after_connect=2 is required for most of the boards ! + # custom board with 20MHz quartz and ATMEGA328P +# config = dict( +# A0=14, +# ARDUINO=105, +# F_CPU=20000000.0, +# MCU='__AVR_ATmega328P__', +# avr_name='ATmega328P', +# sleep_after_connect=0, +# ) + +# custom board with 16MHz quartz and ATMEGA328P config = dict( A0=14, ARDUINO=105, - F_CPU=20000000.0, + F_CPU=16000000.0, MCU='__AVR_ATmega328P__', avr_name='ATmega328P', sleep_after_connect=0, ) -# sleep_after_connect=2 is required for most of the boards ! + +# Uno (not tested) +# config = dict( +# A0=14, +# ARDUINO=105, +# F_CPU=16000000.0, +# MCU='__AVR_ATmega328__', +# avr_name='ATmega328', +# sleep_after_connect=2, +# ) From 235f68e300b1941b36349111f0921ac506859b72 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 22 Feb 2014 03:48:50 +0100 Subject: [PATCH 173/344] Disable features requiring external libs --- firmware/Nanpy/cfg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/Nanpy/cfg.h b/firmware/Nanpy/cfg.h index 0a88c94..764f302 100644 --- a/firmware/Nanpy/cfg.h +++ b/firmware/Nanpy/cfg.h @@ -18,10 +18,10 @@ // external libraries should be installed for the following features: -#define USE_OneWire 1 +#define USE_OneWire 0 #define USE_DallasTemperature 0 -#define USE_CapacitiveSensor 1 -#define USE_DHT 1 +#define USE_CapacitiveSensor 0 +#define USE_DHT 0 From 0b7e9340aca47e37698720d33b069f5c7263abfc Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 22 Feb 2014 04:02:54 +0100 Subject: [PATCH 174/344] Added configuration description to README, fixed contributors --- README.md | 4 ++++ THANKS | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7782500..3c5ac23 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ To install Nanpy Python library just type (as root): How to use ---------- +### Configure your Nanpy firmware + +You can use cfg.h file to configure your Nanpy firmware, selecting the features you want to include. Actually all the features requiring external libraries are disabled. You can also change the baud rate. + ### Serial communication Nanpy autodetects the serial port for you, anyway you can specify another serial port manually: diff --git a/THANKS b/THANKS index 5ccfb5c..65656cd 100644 --- a/THANKS +++ b/THANKS @@ -1,10 +1,12 @@ +Written by +---------- +- Andrea Stagi (https://github.com/astagi) +- Ponty (https://github.com/ponty) + Contributors ------------ - Kevin Ng (kevin.ngkf@gmail.com) -- Ponty (khttps://github.com/ponty) - Andrea Grandi (https://github.com/andreagrandi) - Tim Marston (tim@ed.am) - -Testers -------- -- Fernando Molina (twitter @F_M_A) - Leonardo boards +- Fernando Molina (Twitter @F_M_A) +- Laurent Désarmes (https://github.com/llaurent) From 25117ac884224afa2a0a93cadd4f242276a3d098 Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 24 Feb 2014 19:34:32 +0100 Subject: [PATCH 175/344] new feature: RAM read/write portInputRegister, portModeRegister, portOutputRegister were also modified to result RAM address instead of RAM value. --- firmware/Nanpy/ArduinoCoreClass.cpp | 2 +- firmware/Nanpy/Nanpy.ino | 2 ++ firmware/Nanpy/RAMClass.cpp | 29 ++++++++++++++++++++++++++ firmware/Nanpy/RAMClass.h | 17 +++++++++++++++ firmware/Nanpy/cfg.h | 1 + nanpy/arduinocore.py | 26 ++++++++++++++++------- nanpy/arduinopin.py | 12 +++++++---- nanpy/arduinotree.py | 9 +++++++- nanpy/examples/ramdump.py | 30 +++++++++++++++++++++++++++ nanpy/ram.py | 24 +++++++++++++++++++++ tests/test_serial/test_arduinocore.py | 23 +++++++++++++++++--- tests/test_serial/test_examples.py | 5 +++++ 12 files changed, 164 insertions(+), 16 deletions(-) create mode 100644 firmware/Nanpy/RAMClass.cpp create mode 100644 firmware/Nanpy/RAMClass.h create mode 100755 nanpy/examples/ramdump.py create mode 100644 nanpy/ram.py diff --git a/firmware/Nanpy/ArduinoCoreClass.cpp b/firmware/Nanpy/ArduinoCoreClass.cpp index 55ac6ff..b56bc63 100644 --- a/firmware/Nanpy/ArduinoCoreClass.cpp +++ b/firmware/Nanpy/ArduinoCoreClass.cpp @@ -7,7 +7,7 @@ #include #define RETURN_PIN_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x(m->getInt(0))); } -#define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(*x(m->getInt(0))); } +#define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns((uint16_t)x(m->getInt(0))); } const char* nanpy::ArduinoCoreClass::get_firmware_id() { diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index ff57a33..53ca76a 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -21,6 +21,7 @@ #include "MethodDescriptor.h" #include "ComChannel.h" #include "EEPROMClass.h" +#include "RAMClass.h" #include "DHTClass.h" #include "DefineClass.h" @@ -45,6 +46,7 @@ void setup() { REGISTER_CLASS(ArduinoClass); // 0.8 k REGISTER_CLASS_CONDITIONAL(nanpy::EEPROMClass, USE_EEPROM); // 0.3 k + REGISTER_CLASS_CONDITIONAL(nanpy::RAMClass, USE_RAM); // REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass, USE_LiquidCrystal); // 2.3 k REGISTER_CLASS_CONDITIONAL(OneWireClass, USE_OneWire); // 1.7 k REGISTER_CLASS_CONDITIONAL(DallasTemperatureClass, USE_DallasTemperature); // 6.1 k diff --git a/firmware/Nanpy/RAMClass.cpp b/firmware/Nanpy/RAMClass.cpp new file mode 100644 index 0000000..85528e0 --- /dev/null +++ b/firmware/Nanpy/RAMClass.cpp @@ -0,0 +1,29 @@ +#include "cfg.h" + +#if USE_RAM + +#include "RAMClass.h" +#include + +const char* nanpy::RAMClass::get_firmware_id() +{ + return "RAM"; +} + +void nanpy::RAMClass::elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "write") == 0) { + uint8_t* p = (uint8_t*)(m->getInt(0)); + *p = m->getInt(1); + m->returns(0); + } + if (strcmp(m->getName(), "read") == 0) { + uint8_t* p = (uint8_t*)(m->getInt(0)); + m->returns(*p); + } + + if (strcmp(m->getName(), "size") == 0) { + m->returns(RAMEND+1); + } +}; + +#endif diff --git a/firmware/Nanpy/RAMClass.h b/firmware/Nanpy/RAMClass.h new file mode 100644 index 0000000..bd234a2 --- /dev/null +++ b/firmware/Nanpy/RAMClass.h @@ -0,0 +1,17 @@ +#ifndef RAM_CLASS +#define RAM_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class RAMClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/firmware/Nanpy/cfg.h b/firmware/Nanpy/cfg.h index 764f302..0a3cd5c 100644 --- a/firmware/Nanpy/cfg.h +++ b/firmware/Nanpy/cfg.h @@ -7,6 +7,7 @@ #define USE_LiquidCrystal 1 #define USE_Stepper 1 #define USE_EEPROM 1 +#define USE_RAM 1 #define USE_Define 1 #define USE_ArduinoCore 1 #define USE_Watchdog 1 diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py index e43d19a..a83b812 100644 --- a/nanpy/arduinocore.py +++ b/nanpy/arduinocore.py @@ -5,6 +5,7 @@ @check4firmware class ArduinoCore(FirmwareClass): + """Access to Arduino functions which are not part of the public API.""" firmware_id = 'Core' @@ -21,11 +22,6 @@ def digitalPinToBitMask(self, pin): def digitalPinToPort(self, pin): """nonpublic Arduino function.""" - @returns(int) - @arduinomethod - def portModeRegister(self, port): - """nonpublic Arduino function.""" - @memoized @returns(int) @arduinomethod @@ -41,9 +37,25 @@ def analogInPinToBit(self, pin): @returns(int) @arduinomethod def portOutputRegister(self, port): - """nonpublic Arduino function.""" + """nonpublic Arduino function. + + @return: RAM address + + """ @returns(int) @arduinomethod def portInputRegister(self, port): - """nonpublic Arduino function.""" + """nonpublic Arduino function. + + @return: RAM address + + """ + @returns(int) + @arduinomethod + def portModeRegister(self, port): + """nonpublic Arduino function. + + @return: RAM address + + """ diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py index 13e53f3..55b9ad2 100644 --- a/nanpy/arduinopin.py +++ b/nanpy/arduinopin.py @@ -53,10 +53,11 @@ class ArduinoPin(object): a.pin.get('D0').read_value() ''' - def __init__(self, name, total_pin_count, define, register, core, api): + def __init__(self, name, total_pin_count, define, register, core, ram, api): """name can be int or string.""" self.register = register self.core = core + self.ram = ram self.api = api self.define = define self.A0 = define.get('A0') @@ -194,8 +195,9 @@ def read_mode(self): """read mode (0/1)""" bitmask = self.core.digitalPinToBitMask(self.pin_number) port = self.core.digitalPinToPort(self.pin_number) - reg = self.core.portModeRegister(port) - mode = OUTPUT if reg & bitmask else INPUT + reg_address = self.core.portModeRegister(port) + reg_value = self.ram.read(reg_address) + mode = OUTPUT if reg_value & bitmask else INPUT return mode def write_mode(self, value): @@ -206,11 +208,12 @@ def write_mode(self, value): class PinFeature(object): - def __init__(self, define, register, core, api): + def __init__(self, define, register, core, ram, api): self.A0 = define.get('A0') self.define = define self.register = register self.core = core + self.ram = ram self.api = api @memoized @@ -222,6 +225,7 @@ def get(self, name): self.define, self.register, self.core, + self.ram, self.api) ) diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index f3708e8..b8ea09a 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -7,6 +7,7 @@ from nanpy.define import DefineFeature from nanpy.eepromobj import EepromLib from nanpy.memo import memoized +from nanpy.ram import RAM from nanpy.register import RegisterFeature from nanpy.serialmanager import SerialManager, serial_manager from nanpy.vcc import Vcc @@ -43,7 +44,7 @@ def api(self): @memoized def pin(self): """Object-oriented representation of an Arduino pin""" - return PinFeature(self.define, self.register, self.core, self.api) + return PinFeature(self.define, self.register, self.core, self.ram, self.api) @property @memoized @@ -69,6 +70,12 @@ def eeprom(self): """Access to EEPROM.""" return EepromLib(self.connection) + @property + @memoized + def ram(self): + """Access to RAM.""" + return RAM(self.connection) + @property @memoized def counter(self): diff --git a/nanpy/examples/ramdump.py b/nanpy/examples/ramdump.py new file mode 100755 index 0000000..6e62bf1 --- /dev/null +++ b/nanpy/examples/ramdump.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# Description: read all RAM + +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager +import sys + + +def display(a_list, size): + for i in range(0, size // 16 - 1): + for j in range(0, 15): + sys.stdout.write('%02x:' % a_list[j + i * 16]) + print + + +def ramdump(): + connection = SerialManager() + a = ArduinoTree(connection=connection) + size = a.ram.size + data_list = [] + for i in range(0, size): + s = a.ram.read(i) + data_list.append(s) + print('Reading RAM (%s bytes)...' % size) + display(data_list, size) + + +if __name__ == '__main__': + ramdump() diff --git a/nanpy/ram.py b/nanpy/ram.py new file mode 100644 index 0000000..bf06207 --- /dev/null +++ b/nanpy/ram.py @@ -0,0 +1,24 @@ +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware +from nanpy.memo import memoized + + +@check4firmware +class RAM(FirmwareClass): + firmware_id = 'RAM' + + @arduinomethod + def write(self, address, value): + pass + + @returns(int) + @arduinomethod + def read(self, address): + pass + + @property + @memoized + @returns(int) + @arduinomethod + def size(self): + pass diff --git a/tests/test_serial/test_arduinocore.py b/tests/test_serial/test_arduinocore.py index 0b2578a..16d5523 100644 --- a/tests/test_serial/test_arduinocore.py +++ b/tests/test_serial/test_arduinocore.py @@ -12,9 +12,26 @@ def test(): a = ArduinoTree() eq_(a.core.digitalPinToBitMask(2), 4) eq_(a.core.digitalPinToPort(2), 4) - eq_(a.core.portModeRegister(2), 0) eq_(a.core.digitalPinToTimer(2), 0) eq_(a.core.analogInPinToBit(2), 2) - eq_(a.core.portOutputRegister(2), 0) - eq_(a.core.portInputRegister(2), 0) + +def test_ports(): + a = ArduinoTree() + eq_(a.core.portInputRegister(0), 0) # NOT_A_PORT + eq_(a.core.portInputRegister(1), 0) # NOT_A_PORT + eq_(a.core.portInputRegister(2), 35) # PINB + eq_(a.core.portInputRegister(3), 38) # PINC + eq_(a.core.portInputRegister(4), 41) # PIND + + eq_(a.core.portModeRegister(0), 0) # NOT_A_PORT + eq_(a.core.portModeRegister(1), 0) # NOT_A_PORT + eq_(a.core.portModeRegister(2), 36) # DDRB + eq_(a.core.portModeRegister(3), 39) # DDRC + eq_(a.core.portModeRegister(4), 42) # DDRD + + eq_(a.core.portOutputRegister(0), 0) # NOT_A_PORT + eq_(a.core.portOutputRegister(1), 0) # NOT_A_PORT + eq_(a.core.portOutputRegister(2), 37) # PORTB + eq_(a.core.portOutputRegister(3), 40) # PORTC + eq_(a.core.portOutputRegister(4), 43) # PORTD diff --git a/tests/test_serial/test_examples.py b/tests/test_serial/test_examples.py index dcabb29..326e6bb 100644 --- a/tests/test_serial/test_examples.py +++ b/tests/test_serial/test_examples.py @@ -4,6 +4,7 @@ from nanpy.examples.dds import dds from nanpy.examples.dump import dumpall from nanpy.examples.highfreqpwm import highfreqpwm +from nanpy.examples.ramdump import ramdump from nanpy.examples.reset import reset_demo import common @@ -38,3 +39,7 @@ def test_dds(): def test_checkspeed(): checkspeed(n=1) + + +def test_ramdump(): + ramdump() From fe9e2e2590bfdaf6ae2e217717aeaa53536da756 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 25 Feb 2014 13:17:41 +0100 Subject: [PATCH 176/344] Moving examples under nanpy/examples to make examples part of the distribution --- {examples => nanpy/examples}/blink.py | 0 {examples => nanpy/examples}/clock.py | 0 {examples => nanpy/examples}/dallastemperature.py | 0 {examples => nanpy/examples}/dht.py | 0 {examples => nanpy/examples}/eepromread.py | 0 {examples => nanpy/examples}/melody.py | 0 {examples => nanpy/examples}/mytemperaturelib.py | 0 {examples => nanpy/examples}/stepper.py | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename {examples => nanpy/examples}/blink.py (100%) rename {examples => nanpy/examples}/clock.py (100%) rename {examples => nanpy/examples}/dallastemperature.py (100%) rename {examples => nanpy/examples}/dht.py (100%) rename {examples => nanpy/examples}/eepromread.py (100%) rename {examples => nanpy/examples}/melody.py (100%) rename {examples => nanpy/examples}/mytemperaturelib.py (100%) rename {examples => nanpy/examples}/stepper.py (100%) diff --git a/examples/blink.py b/nanpy/examples/blink.py similarity index 100% rename from examples/blink.py rename to nanpy/examples/blink.py diff --git a/examples/clock.py b/nanpy/examples/clock.py similarity index 100% rename from examples/clock.py rename to nanpy/examples/clock.py diff --git a/examples/dallastemperature.py b/nanpy/examples/dallastemperature.py similarity index 100% rename from examples/dallastemperature.py rename to nanpy/examples/dallastemperature.py diff --git a/examples/dht.py b/nanpy/examples/dht.py similarity index 100% rename from examples/dht.py rename to nanpy/examples/dht.py diff --git a/examples/eepromread.py b/nanpy/examples/eepromread.py similarity index 100% rename from examples/eepromread.py rename to nanpy/examples/eepromread.py diff --git a/examples/melody.py b/nanpy/examples/melody.py similarity index 100% rename from examples/melody.py rename to nanpy/examples/melody.py diff --git a/examples/mytemperaturelib.py b/nanpy/examples/mytemperaturelib.py similarity index 100% rename from examples/mytemperaturelib.py rename to nanpy/examples/mytemperaturelib.py diff --git a/examples/stepper.py b/nanpy/examples/stepper.py similarity index 100% rename from examples/stepper.py rename to nanpy/examples/stepper.py From ba580ec0bd0d0e12237e67ce6567774597015b1a Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 25 Feb 2014 13:19:31 +0100 Subject: [PATCH 177/344] if instead of ifdef for FreqCounter --- firmware/Nanpy/FreqCount.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/Nanpy/FreqCount.cpp b/firmware/Nanpy/FreqCount.cpp index 78f000f..c74dd8b 100644 --- a/firmware/Nanpy/FreqCount.cpp +++ b/firmware/Nanpy/FreqCount.cpp @@ -27,7 +27,7 @@ // FreqCount Library was so modified that it can be included in Nanpy #include "cfg.h" -#ifdef USE_Counter +#if USE_Counter #include "FreqCount.h" #include "timers.h" From 4e5718d1fef01ae82f23e75162cd8400aaf3d601 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 25 Feb 2014 14:21:19 +0100 Subject: [PATCH 178/344] Removed useless code, do not track cfg.h --- firmware/Nanpy/Nanpy.ino | 25 +++++++++++++------------ firmware/Nanpy/cfg.h | 34 ---------------------------------- sample_cfg.h | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 46 deletions(-) delete mode 100644 firmware/Nanpy/cfg.h create mode 100644 sample_cfg.h diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index 53ca76a..231260c 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -1,13 +1,10 @@ #include "cfg.h" -#include -#include -#include -#include -#include -#include -#include -#include +#if USE_Tone +# if USE_Counter +# error "USE_Tone conflicts with USE_Counter!" +# endif +#endif #include "BaseClass.h" #include "ArduinoClass.h" @@ -31,7 +28,9 @@ #include "CounterClass.h" #include "InfoClass.h" -#include +#if defined(__AVR__) + #include +#endif using namespace nanpy; @@ -39,9 +38,11 @@ MethodDescriptor *m = NULL; void setup() { - // disable watchdog (http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html) - MCUSR = 0; - wdt_disable(); + #ifdef MCUSR + // disable watchdog (http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html) + MCUSR = 0; + wdt_disable(); + #endif REGISTER_CLASS(ArduinoClass); // 0.8 k diff --git a/firmware/Nanpy/cfg.h b/firmware/Nanpy/cfg.h deleted file mode 100644 index 0a3cd5c..0000000 --- a/firmware/Nanpy/cfg.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#define BAUDRATE 115200 - -#define USE_Servo 1 -#define USE_Tone 0 -#define USE_LiquidCrystal 1 -#define USE_Stepper 1 -#define USE_EEPROM 1 -#define USE_RAM 1 -#define USE_Define 1 -#define USE_ArduinoCore 1 -#define USE_Watchdog 1 -#define USE_Register 1 -#define USE_Info 1 - -// conflicts Tone -#define USE_Counter 1 - - -// external libraries should be installed for the following features: -#define USE_OneWire 0 -#define USE_DallasTemperature 0 -#define USE_CapacitiveSensor 0 -#define USE_DHT 0 - - - - -#if USE_Tone -# if USE_Counter -# error "USE_Tone conflicts with USE_Counter!" -# endif -#endif diff --git a/sample_cfg.h b/sample_cfg.h new file mode 100644 index 0000000..4134cf7 --- /dev/null +++ b/sample_cfg.h @@ -0,0 +1,22 @@ +#pragma once + +#define BAUDRATE 115200 + +#define USE_Servo 0 +#define USE_Tone 0 +#define USE_LiquidCrystal 0 +#define USE_Stepper 0 +#define USE_EEPROM 0 +#define USE_RAM 0 +#define USE_Define 0 +#define USE_ArduinoCore 0 +#define USE_Watchdog 0 +#define USE_Register 0 +#define USE_Info 0 +#define USE_Counter 0 + +// external libraries should be installed for the following features: +#define USE_OneWire 0 +#define USE_DallasTemperature 0 +#define USE_CapacitiveSensor 0 +#define USE_DHT 0 \ No newline at end of file From 006ffd95a7add8cc6e151d238b31414dae663cf5 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 25 Feb 2014 14:29:35 +0100 Subject: [PATCH 179/344] Better firmware configuration --- .gitignore | 1 + README.md | 5 ++++- sample_cfg.h => firmware/sample_cfg.h | 0 3 files changed, 5 insertions(+), 1 deletion(-) rename sample_cfg.h => firmware/sample_cfg.h (100%) diff --git a/.gitignore b/.gitignore index 76b38e3..6ce2d35 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ build/ dist/ nanpy.egg-info/ *.sh +cfg.h #Arduino *.o diff --git a/README.md b/README.md index 3c5ac23..4efb089 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,10 @@ How to use ---------- ### Configure your Nanpy firmware -You can use cfg.h file to configure your Nanpy firmware, selecting the features you want to include. Actually all the features requiring external libraries are disabled. You can also change the baud rate. + $ cd firmware + $ ./configure.sh + +You can use Nanpy/cfg.h generated file to configure your Nanpy firmware, selecting the features you want to include and the baud rate. ### Serial communication diff --git a/sample_cfg.h b/firmware/sample_cfg.h similarity index 100% rename from sample_cfg.h rename to firmware/sample_cfg.h From e123eb0b458794922bced19e52745f180ab392d4 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 25 Feb 2014 15:08:18 +0100 Subject: [PATCH 180/344] Added Tone class --- firmware/Nanpy/Tone.cpp | 16 ++++++++++++++++ firmware/Nanpy/Tone.h | 18 ++++++++++++++++++ firmware/Nanpy/ToneClass.h | 20 ++------------------ 3 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 firmware/Nanpy/Tone.cpp create mode 100644 firmware/Nanpy/Tone.h diff --git a/firmware/Nanpy/Tone.cpp b/firmware/Nanpy/Tone.cpp new file mode 100644 index 0000000..d107d20 --- /dev/null +++ b/firmware/Nanpy/Tone.cpp @@ -0,0 +1,16 @@ +#include "Tone.h" +#include + +void Tone::play(int note, int duration) { + #if defined(__AVR__) + tone(pin, note, duration); + delay(duration * 1.30); + noTone(pin); + #endif +} + +void Tone::stop(void) { + #if defined(__AVR__) + noTone(pin); + #endif +} \ No newline at end of file diff --git a/firmware/Nanpy/Tone.h b/firmware/Nanpy/Tone.h new file mode 100644 index 0000000..70ac9a9 --- /dev/null +++ b/firmware/Nanpy/Tone.h @@ -0,0 +1,18 @@ +#ifndef TONE_H +#define TONE_H + +class Tone { + + private: + + int pin; + + public: + + Tone(int pin) : pin(pin) {} + void play(int note, int duration); + void stop(void); + +}; + +#endif \ No newline at end of file diff --git a/firmware/Nanpy/ToneClass.h b/firmware/Nanpy/ToneClass.h index 629bbd9..311e41e 100644 --- a/firmware/Nanpy/ToneClass.h +++ b/firmware/Nanpy/ToneClass.h @@ -94,25 +94,9 @@ #define NOTE_D8 4699 #define NOTE_DS8 4978 -namespace nanpy { - - class Tone { - - private: +#include "Tone.h" - int pin; - - public: - - Tone(int pin) : pin(pin) {} - void play(int note, int duration) { - tone(pin, note, duration); - delay(duration * 1.30); - noTone(pin); - } - void stop(void) {noTone(pin);} - - }; +namespace nanpy { class ToneClass: public ObjectsManager { From b7e76c13b5e0c5dc453bd164c9bf4aabaeebd999 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Wed, 26 Feb 2014 03:57:19 +0100 Subject: [PATCH 181/344] Restored includes, fixes #20 --- firmware/Nanpy/Nanpy.ino | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index 231260c..805bcca 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -6,6 +6,38 @@ # endif #endif +#if USE_EEPROM +#include +#endif + +#if USE_Servo +#include +#endif + +#if USE_LiquidCrystal +#include +#endif + +#if USE_Stepper +#include +#endif + +#if USE_OneWire +#include +#endif + +#if USE_DallasTemperature +#include +#endif + +#if USE_CapacitiveSensor +#include +#endif + +#if USE_DHT +#include +#endif + #include "BaseClass.h" #include "ArduinoClass.h" #include "OneWireClass.h" From ada385326ddd78003c3bcca1cfdc3949cf525f0f Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 26 Feb 2014 18:08:29 +0100 Subject: [PATCH 182/344] put Tone under namespace --- firmware/Nanpy/Tone.cpp | 6 +++--- firmware/Nanpy/Tone.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/firmware/Nanpy/Tone.cpp b/firmware/Nanpy/Tone.cpp index d107d20..d93a5e4 100644 --- a/firmware/Nanpy/Tone.cpp +++ b/firmware/Nanpy/Tone.cpp @@ -1,7 +1,7 @@ #include "Tone.h" #include -void Tone::play(int note, int duration) { +void nanpy::Tone::play(int note, int duration) { #if defined(__AVR__) tone(pin, note, duration); delay(duration * 1.30); @@ -9,8 +9,8 @@ void Tone::play(int note, int duration) { #endif } -void Tone::stop(void) { +void nanpy::Tone::stop(void) { #if defined(__AVR__) noTone(pin); #endif -} \ No newline at end of file +} diff --git a/firmware/Nanpy/Tone.h b/firmware/Nanpy/Tone.h index 70ac9a9..9b5558f 100644 --- a/firmware/Nanpy/Tone.h +++ b/firmware/Nanpy/Tone.h @@ -1,6 +1,7 @@ #ifndef TONE_H #define TONE_H +namespace nanpy { class Tone { private: @@ -14,5 +15,6 @@ class Tone { void stop(void); }; +} -#endif \ No newline at end of file +#endif From 331c7d8f7722df66576965dc1d610b3cfd265de8 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 26 Feb 2014 17:45:27 +0100 Subject: [PATCH 183/344] put Tone inside #if #endif --- firmware/Nanpy/Tone.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/firmware/Nanpy/Tone.cpp b/firmware/Nanpy/Tone.cpp index d93a5e4..441c0c4 100644 --- a/firmware/Nanpy/Tone.cpp +++ b/firmware/Nanpy/Tone.cpp @@ -1,3 +1,7 @@ +#include "cfg.h" + +#if USE_Tone + #include "Tone.h" #include @@ -14,3 +18,5 @@ void nanpy::Tone::stop(void) { noTone(pin); #endif } + +#endif From a718ec4c38806c213fc22c3b09cb91feae32dc25 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 26 Feb 2014 18:19:56 +0100 Subject: [PATCH 184/344] rename Tone to ToneWrapper Strange behavior: Tone.cpp file makes Arduino link tone() function, which conflicts Counter. --- firmware/Nanpy/ToneClass.cpp | 4 ++-- firmware/Nanpy/ToneClass.h | 4 ++-- firmware/Nanpy/{Tone.cpp => ToneWrapper.cpp} | 6 +++--- firmware/Nanpy/{Tone.h => ToneWrapper.h} | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) rename firmware/Nanpy/{Tone.cpp => ToneWrapper.cpp} (67%) rename firmware/Nanpy/{Tone.h => ToneWrapper.h} (57%) diff --git a/firmware/Nanpy/ToneClass.cpp b/firmware/Nanpy/ToneClass.cpp index b810f32..7c27b6b 100644 --- a/firmware/Nanpy/ToneClass.cpp +++ b/firmware/Nanpy/ToneClass.cpp @@ -12,10 +12,10 @@ const char* nanpy::ToneClass::get_firmware_id() } void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); + ObjectsManager::elaborate(m); if (strcmp(m->getName(),"new") == 0) { - v.insert(new Tone (m->getInt(0))); + v.insert(new ToneWrapper (m->getInt(0))); m->returns(v.getLastIndex()); } diff --git a/firmware/Nanpy/ToneClass.h b/firmware/Nanpy/ToneClass.h index 311e41e..75bcefa 100644 --- a/firmware/Nanpy/ToneClass.h +++ b/firmware/Nanpy/ToneClass.h @@ -94,11 +94,11 @@ #define NOTE_D8 4699 #define NOTE_DS8 4978 -#include "Tone.h" +#include "ToneWrapper.h" namespace nanpy { - class ToneClass: public ObjectsManager { + class ToneClass: public ObjectsManager { public: void elaborate( nanpy::MethodDescriptor* m ); diff --git a/firmware/Nanpy/Tone.cpp b/firmware/Nanpy/ToneWrapper.cpp similarity index 67% rename from firmware/Nanpy/Tone.cpp rename to firmware/Nanpy/ToneWrapper.cpp index 441c0c4..8854bad 100644 --- a/firmware/Nanpy/Tone.cpp +++ b/firmware/Nanpy/ToneWrapper.cpp @@ -2,10 +2,10 @@ #if USE_Tone -#include "Tone.h" +#include "ToneWrapper.h" #include -void nanpy::Tone::play(int note, int duration) { +void nanpy::ToneWrapper::play(int note, int duration) { #if defined(__AVR__) tone(pin, note, duration); delay(duration * 1.30); @@ -13,7 +13,7 @@ void nanpy::Tone::play(int note, int duration) { #endif } -void nanpy::Tone::stop(void) { +void nanpy::ToneWrapper::stop(void) { #if defined(__AVR__) noTone(pin); #endif diff --git a/firmware/Nanpy/Tone.h b/firmware/Nanpy/ToneWrapper.h similarity index 57% rename from firmware/Nanpy/Tone.h rename to firmware/Nanpy/ToneWrapper.h index 9b5558f..bd64b18 100644 --- a/firmware/Nanpy/Tone.h +++ b/firmware/Nanpy/ToneWrapper.h @@ -1,8 +1,8 @@ -#ifndef TONE_H -#define TONE_H +#ifndef TONE_WRAPPER_H +#define TONE_WRAPPER_H namespace nanpy { -class Tone { +class ToneWrapper { private: @@ -10,7 +10,7 @@ class Tone { public: - Tone(int pin) : pin(pin) {} + ToneWrapper(int pin) : pin(pin) {} void play(int note, int duration); void stop(void); From 650e9439fea9e5f4fb49a62e7bc919749f1bc322 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 27 Feb 2014 19:12:19 +0100 Subject: [PATCH 185/344] new RAM.free() function --- firmware/Nanpy/RAMClass.cpp | 6 ++++ firmware/Nanpy/freeram.c | 64 +++++++++++++++++++++++++++++++++++++ firmware/Nanpy/freeram.h | 15 +++++++++ nanpy/examples/ramdump.py | 7 ++-- nanpy/ram.py | 5 +++ 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 firmware/Nanpy/freeram.c create mode 100644 firmware/Nanpy/freeram.h diff --git a/firmware/Nanpy/RAMClass.cpp b/firmware/Nanpy/RAMClass.cpp index 85528e0..1059a77 100644 --- a/firmware/Nanpy/RAMClass.cpp +++ b/firmware/Nanpy/RAMClass.cpp @@ -4,6 +4,8 @@ #include "RAMClass.h" #include +#include "freeram.h" + const char* nanpy::RAMClass::get_firmware_id() { @@ -24,6 +26,10 @@ void nanpy::RAMClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "size") == 0) { m->returns(RAMEND+1); } + + if (strcmp(m->getName(), "free") == 0) { + m->returns(free_ram2()); + } }; #endif diff --git a/firmware/Nanpy/freeram.c b/firmware/Nanpy/freeram.c new file mode 100644 index 0000000..5142d6e --- /dev/null +++ b/firmware/Nanpy/freeram.c @@ -0,0 +1,64 @@ + +#include +#include + + +extern unsigned int __bss_end; +extern unsigned int __heap_start; +extern void *__brkval; +extern unsigned int __data_start; + +/// return available RAM +int free_ram1() +{ + /// copy from http://arduino.cc/playground/Code/AvailableMemory + int free_memory; + + if ((int) __brkval == 0) + free_memory = ((int) &free_memory) - ((int) &__bss_end); + else + free_memory = ((int) &free_memory) - ((int) __brkval); + + return free_memory; +} + +/// return available RAM +/*! This function places the current value of the heap and stack pointers in the + * variables. You can call it from any place in your code and save the data for + * outputting or displaying later. This allows you to check at different parts of + * your program flow. + * The stack pointer starts at the top of RAM and grows downwards. The heap pointer + * starts just above the static variables etc. and grows upwards. SP should always + * be larger than HP or you'll be in big trouble! The smaller the gap, the more + * careful you need to be. Julian Gall 6-Feb-2009. + */ +int free_ram2() +{ + /// copy from http://arduino.cc/playground/Code/AvailableMemory + uint8_t * heapptr, *stackptr; + + stackptr = (uint8_t *) malloc(4); // use stackptr temporarily + heapptr = stackptr; // save value of heap pointer + free(stackptr); // free up the memory again (sets stackptr to 0) + stackptr = (uint8_t *) (SP); // save value of stack pointer + return (int) (stackptr - heapptr); +} + +/// return available RAM + +/// this function will return the number of bytes currently free in RAM +/// written by David A. Mellis +/// based on code by Rob Faludi http://www.faludi.com +int free_ram3() +{ + /// copy from http://arduino.cc/playground/Code/AvailableMemory + int size = (int) RAMEND - (int) &__data_start; + uint8_t *buf; + + while ((buf = (uint8_t *) malloc(--size)) == NULL) + ; + + free(buf); + + return size; +} diff --git a/firmware/Nanpy/freeram.h b/firmware/Nanpy/freeram.h new file mode 100644 index 0000000..c0ba485 --- /dev/null +++ b/firmware/Nanpy/freeram.h @@ -0,0 +1,15 @@ +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +int free_ram1(); +int free_ram2(); +int free_ram3(); + +#ifdef __cplusplus +} +#endif + diff --git a/nanpy/examples/ramdump.py b/nanpy/examples/ramdump.py index 6e62bf1..8782fb0 100755 --- a/nanpy/examples/ramdump.py +++ b/nanpy/examples/ramdump.py @@ -9,7 +9,7 @@ def display(a_list, size): for i in range(0, size // 16 - 1): - for j in range(0, 15): + for j in range(16): sys.stdout.write('%02x:' % a_list[j + i * 16]) print @@ -18,11 +18,14 @@ def ramdump(): connection = SerialManager() a = ArduinoTree(connection=connection) size = a.ram.size + free = a.ram.free() + print('Reading RAM (%s bytes, %s bytes free)...' % (size, free)) + data_list = [] for i in range(0, size): s = a.ram.read(i) data_list.append(s) - print('Reading RAM (%s bytes)...' % size) + display(data_list, size) diff --git a/nanpy/ram.py b/nanpy/ram.py index bf06207..3b0ecfc 100644 --- a/nanpy/ram.py +++ b/nanpy/ram.py @@ -22,3 +22,8 @@ def read(self, address): @arduinomethod def size(self): pass + + @returns(int) + @arduinomethod + def free(self): + pass From c58bd87889717b6bc6b7af04da7f29e5a8f75a1f Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 27 Feb 2014 19:14:54 +0100 Subject: [PATCH 186/344] eeprom example: 16 bytes in one line, remove spaces --- nanpy/examples/eepromread.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/examples/eepromread.py b/nanpy/examples/eepromread.py index 08ab865..32aa0fb 100755 --- a/nanpy/examples/eepromread.py +++ b/nanpy/examples/eepromread.py @@ -12,8 +12,8 @@ def display(a_list): for i in range(0, EEPROM_SIZE//16-1): - for j in range(0, 15): - sys.stdout.write( "%x : " % a_list[j+i*16]) + for j in range(16): + sys.stdout.write("%02x:" % a_list[j + i * 16]) print From 647504a7d8a41f562ff634f998fdbaee4fa7b8eb Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 27 Feb 2014 19:16:26 +0100 Subject: [PATCH 187/344] cache portOutputRegister, portInputRegister, portModeRegister return values --- nanpy/arduinocore.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py index a83b812..eebcfea 100644 --- a/nanpy/arduinocore.py +++ b/nanpy/arduinocore.py @@ -34,6 +34,7 @@ def digitalPinToTimer(self, pin): def analogInPinToBit(self, pin): """nonpublic Arduino function.""" + @memoized @returns(int) @arduinomethod def portOutputRegister(self, port): @@ -43,6 +44,7 @@ def portOutputRegister(self, port): """ + @memoized @returns(int) @arduinomethod def portInputRegister(self, port): @@ -51,6 +53,8 @@ def portInputRegister(self, port): @return: RAM address """ + + @memoized @returns(int) @arduinomethod def portModeRegister(self, port): From 36ab8c87fff8c3cdfde492bafef835b9bd6c435c Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 27 Feb 2014 19:17:03 +0100 Subject: [PATCH 188/344] use object based interface in more examples --- nanpy/__init__.py | 2 ++ nanpy/examples/blink.py | 12 ++++++++---- nanpy/examples/clock.py | 9 ++++++--- nanpy/examples/eepromread.py | 15 ++++++++------- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 738dcfd..ac7d4a0 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -23,3 +23,5 @@ from nanpy.tone import Tone from nanpy.capacitivesensor import CapacitiveSensor from nanpy.dht import DHT +from nanpy.arduinoapi import ArduinoApi +from nanpy.eepromobj import EepromLib diff --git a/nanpy/examples/blink.py b/nanpy/examples/blink.py index 0363cd2..17bf75b 100755 --- a/nanpy/examples/blink.py +++ b/nanpy/examples/blink.py @@ -4,11 +4,15 @@ # Description: keeps your led blinking # Dependencies: None -from nanpy import Arduino +from nanpy import (ArduinoApi, SerialManager) +from time import sleep -Arduino.pinMode(13, Arduino.OUTPUT) +connection = SerialManager() +a = ArduinoApi(connection=connection) + +a.pinMode(13, a.OUTPUT) for i in range(10000): - Arduino.digitalWrite(13, (i + 1) % 2) - Arduino.delay(200) + a.digitalWrite(13, (i + 1) % 2) + sleep(0.2) diff --git a/nanpy/examples/clock.py b/nanpy/examples/clock.py index e87d70d..7ee71ba 100755 --- a/nanpy/examples/clock.py +++ b/nanpy/examples/clock.py @@ -5,8 +5,11 @@ # Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/) import ntplib -from nanpy import (Arduino, Lcd) +from nanpy import (SerialManager, Lcd) from datetime import datetime +from time import sleep + +connection = SerialManager() ntp_client = ntplib.NTPClient() response = ntp_client.request('europe.pool.ntp.org', version=3) @@ -15,7 +18,7 @@ pins = [7, 8, 9, 10, 11, 12] cols, rows = 16, 2 -lcd = Lcd(pins, [cols, rows]) +lcd = Lcd(pins, [cols, rows], connection=connection) while (1): lcd.setCursor(0, 0) @@ -26,5 +29,5 @@ time_format = '%H %M' lcd.setCursor(0, 1) lcd.printString((datetime.fromtimestamp(time)).strftime(time_format)) - Arduino.delay(1000) + sleep(1) time += 1 diff --git a/nanpy/examples/eepromread.py b/nanpy/examples/eepromread.py index 32aa0fb..76404e4 100755 --- a/nanpy/examples/eepromread.py +++ b/nanpy/examples/eepromread.py @@ -1,17 +1,18 @@ #!/usr/bin/env python -# Author: Kevin Ng +# Author: Kevin Ng # Description: read from EEPROM # Dependencies: None -from nanpy import EEPROM +from nanpy import (EepromLib, SerialManager) import sys -EEPROM_SIZE = EEPROM.size() +connection = SerialManager() +e = EepromLib(connection=connection) def display(a_list): - for i in range(0, EEPROM_SIZE//16-1): + for i in range(0, e.size // 16 - 1): for j in range(16): sys.stdout.write("%02x:" % a_list[j + i * 16]) print @@ -19,12 +20,12 @@ def display(a_list): def read_eeprom(): data_list = [] - for i in range(0, EEPROM_SIZE): - s = EEPROM.read(i) + for i in range(0, e.size): + s = e.read(i) data_list.append(s) return data_list if __name__ == "__main__": - print("Reading eeprom (%s bytes)..." % EEPROM_SIZE) + print("Reading eeprom (%s bytes)..." % e.size) display(read_eeprom()) From 29d43ca5875670e42f62d65427567bf93d8c8b16 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 27 Feb 2014 19:17:51 +0100 Subject: [PATCH 189/344] use object based interface in README --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4efb089..0c54ace 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,18 @@ The main purpose of Nanpy is making programmers' life easier, giving them someth Let's start with a classic example, turn on a led placed in the 13th pin.. - Arduino.pinMode(13, Arduino.OUTPUT) - Arduino.digitalWrite(13, Arduino.HIGH) + connection = SerialManager() + a = ArduinoApi(connection=connection) + a.pinMode(13, a.OUTPUT) + a.digitalWrite(13, a.HIGH) There are a lot of projects able to do that. Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. We started supporting OneWire, Lcd, Stepper and Servo library and they're still incomplete. Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print something! - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + connection = SerialManager() + lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2], connection=connection) lcd.printString("Hello World!") really straightforward now, isn't it? :) @@ -56,8 +59,8 @@ You can use Nanpy/cfg.h generated file to configure your Nanpy firmware, selecti Nanpy autodetects the serial port for you, anyway you can specify another serial port manually: - from nanpy import serial_manager - serial_manager.connect('/dev/ttyACM1') + from nanpy import SerialManager + connection = SerialManager(device='/dev/ttyACM1') ### Import modules From cf2de5df7e67b57e8283df7e8d3bb16ed56fef6b Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 28 Feb 2014 08:03:51 +0100 Subject: [PATCH 190/344] enable some modules in sample cfg.h --- firmware/sample_cfg.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/firmware/sample_cfg.h b/firmware/sample_cfg.h index 4134cf7..c481492 100644 --- a/firmware/sample_cfg.h +++ b/firmware/sample_cfg.h @@ -2,21 +2,21 @@ #define BAUDRATE 115200 -#define USE_Servo 0 -#define USE_Tone 0 -#define USE_LiquidCrystal 0 -#define USE_Stepper 0 -#define USE_EEPROM 0 -#define USE_RAM 0 -#define USE_Define 0 -#define USE_ArduinoCore 0 -#define USE_Watchdog 0 -#define USE_Register 0 -#define USE_Info 0 +#define USE_Servo 1 +#define USE_Tone 1 +#define USE_LiquidCrystal 1 +#define USE_Stepper 1 +#define USE_EEPROM 1 +#define USE_RAM 1 +#define USE_Define 1 +#define USE_ArduinoCore 1 +#define USE_Watchdog 1 +#define USE_Register 1 +#define USE_Info 1 #define USE_Counter 0 // external libraries should be installed for the following features: #define USE_OneWire 0 #define USE_DallasTemperature 0 #define USE_CapacitiveSensor 0 -#define USE_DHT 0 \ No newline at end of file +#define USE_DHT 0 From a8006177baafb10383b2fd02b33b33cb35bc5d89 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 28 Feb 2014 08:04:25 +0100 Subject: [PATCH 191/344] default BOARD is uno in makefile --- firmware/Nanpy/arduino.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/Nanpy/arduino.mk b/firmware/Nanpy/arduino.mk index 3028d5d..b9acb8d 100644 --- a/firmware/Nanpy/arduino.mk +++ b/firmware/Nanpy/arduino.mk @@ -191,7 +191,8 @@ endif ifndef BOARD ifneq "$(MAKECMDGOALS)" "boards" ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is unset. Type 'make boards' to see possible values) +#$(error BOARD is unset. Type 'make boards' to see possible values) +BOARD := uno endif endif endif From b5a8c6cf7487216c2cd23e358dede0d4a51fecab Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 28 Feb 2014 08:05:19 +0100 Subject: [PATCH 192/344] move watchdog related code into WatchdogClass.cpp --- firmware/Nanpy/Nanpy.ino | 11 +---------- firmware/Nanpy/WatchdogClass.cpp | 15 +++++++++++++++ firmware/Nanpy/WatchdogClass.h | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino index 805bcca..e93f94e 100644 --- a/firmware/Nanpy/Nanpy.ino +++ b/firmware/Nanpy/Nanpy.ino @@ -60,21 +60,12 @@ #include "CounterClass.h" #include "InfoClass.h" -#if defined(__AVR__) - #include -#endif - using namespace nanpy; MethodDescriptor *m = NULL; void setup() { - - #ifdef MCUSR - // disable watchdog (http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html) - MCUSR = 0; - wdt_disable(); - #endif + disable_watchdog_at_startup(); REGISTER_CLASS(ArduinoClass); // 0.8 k diff --git a/firmware/Nanpy/WatchdogClass.cpp b/firmware/Nanpy/WatchdogClass.cpp index 306e2d6..165129b 100644 --- a/firmware/Nanpy/WatchdogClass.cpp +++ b/firmware/Nanpy/WatchdogClass.cpp @@ -30,4 +30,19 @@ void nanpy::WatchdogClass::elaborate(nanpy::MethodDescriptor* m) m->returns(0); } } + #endif + +void disable_watchdog_at_startup() +{ + // disable watchdog at startup + // http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html + // "the watchdog timer remains active even after a system reset (except a power-on condition), + // using the fastest prescaler value (approximately 15 ms). + // It is therefore required to turn off the watchdog early during program startup,.." + // "..clearing the watchdog reset flag before disabling the watchdog is required, according to the datasheet." +#ifdef MCUSR + MCUSR = 0; +#endif + wdt_disable(); +} diff --git a/firmware/Nanpy/WatchdogClass.h b/firmware/Nanpy/WatchdogClass.h index 2c21644..8383785 100644 --- a/firmware/Nanpy/WatchdogClass.h +++ b/firmware/Nanpy/WatchdogClass.h @@ -13,3 +13,4 @@ namespace nanpy { }; }; +void disable_watchdog_at_startup(); From 17bec1025e52bdf5c9f6b8ced39cffa8116f0691 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 28 Feb 2014 19:28:54 +0100 Subject: [PATCH 193/344] Added Anthony Goodhew to contributors --- THANKS => CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) rename THANKS => CONTRIBUTORS (87%) diff --git a/THANKS b/CONTRIBUTORS similarity index 87% rename from THANKS rename to CONTRIBUTORS index 65656cd..8290d0f 100644 --- a/THANKS +++ b/CONTRIBUTORS @@ -10,3 +10,4 @@ Contributors - Tim Marston (tim@ed.am) - Fernando Molina (Twitter @F_M_A) - Laurent Désarmes (https://github.com/llaurent) +- Anthony Goodhew (tony.goodhew@ntlworld.com) From 840ee8f9774c4ea579c200267b3da932aca4431d Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 4 Mar 2014 16:00:35 +0100 Subject: [PATCH 194/344] Fixed watch dog disable at startup issue --- firmware/Nanpy/WatchdogClass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/Nanpy/WatchdogClass.cpp b/firmware/Nanpy/WatchdogClass.cpp index 165129b..3305fbf 100644 --- a/firmware/Nanpy/WatchdogClass.cpp +++ b/firmware/Nanpy/WatchdogClass.cpp @@ -43,6 +43,6 @@ void disable_watchdog_at_startup() // "..clearing the watchdog reset flag before disabling the watchdog is required, according to the datasheet." #ifdef MCUSR MCUSR = 0; -#endif wdt_disable(); +#endif } From 8a8e7ba9e1348418d117706adab2fda458ec6f7b Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 4 Mar 2014 16:14:20 +0100 Subject: [PATCH 195/344] Separate makefile stuff --- .gitignore | 5 +++++ {firmware/Nanpy => tests/makefile_stuff}/Makefile | 0 {firmware/Nanpy => tests/makefile_stuff}/arduino.mk | 0 .../libraries/CapacitiveSensor/CapacitiveSensor.cpp | 0 .../libraries/CapacitiveSensor/CapacitiveSensor.h | 0 .../makefile_stuff}/libraries/CapacitiveSensor/README.md | 0 .../CapacitiveSensorSketch/CapacitiveSensorSketch.pde | 0 .../makefile_stuff}/libraries/CapacitiveSensor/keywords.txt | 0 .../Nanpy => tests/makefile_stuff}/libraries/DHT/DHT.cpp | 0 {firmware/Nanpy => tests/makefile_stuff}/libraries/DHT/DHT.h | 0 .../Nanpy => tests/makefile_stuff}/libraries/DHT/README.txt | 0 .../libraries/DHT/examples/DHTtester/DHTtester.pde | 0 .../libraries/DallasTemperature/DallasTemperature.cpp | 0 .../libraries/DallasTemperature/DallasTemperature.h | 0 .../makefile_stuff}/libraries/DallasTemperature/README.TXT | 0 .../makefile_stuff}/libraries/DallasTemperature/change.txt | 0 .../libraries/DallasTemperature/examples/Alarm/Alarm.pde | 0 .../DallasTemperature/examples/AlarmHandler/AlarmHandler.pde | 0 .../DallasTemperature/examples/Multiple/Multiple.pde | 0 .../libraries/DallasTemperature/examples/Simple/Simple.pde | 0 .../libraries/DallasTemperature/examples/Single/Single.pde | 0 .../libraries/DallasTemperature/examples/Tester/Tester.pde | 0 .../examples/WaitForConversion/WaitForConversion.pde | 0 .../examples/WaitForConversion2/WaitForConversion2.pde | 0 .../makefile_stuff}/libraries/DallasTemperature/keywords.txt | 0 .../makefile_stuff}/libraries/OneWire/OneWire.cpp | 0 .../makefile_stuff}/libraries/OneWire/OneWire.h | 0 .../examples/DS18x20_Temperature/DS18x20_Temperature.pde | 0 .../OneWire/examples/DS2408_Switch/DS2408_Switch.pde | 0 .../libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde | 0 .../makefile_stuff}/libraries/OneWire/keywords.txt | 0 31 files changed, 5 insertions(+) rename {firmware/Nanpy => tests/makefile_stuff}/Makefile (100%) rename {firmware/Nanpy => tests/makefile_stuff}/arduino.mk (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/CapacitiveSensor/CapacitiveSensor.cpp (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/CapacitiveSensor/CapacitiveSensor.h (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/CapacitiveSensor/README.md (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/CapacitiveSensor/keywords.txt (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DHT/DHT.cpp (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DHT/DHT.h (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DHT/README.txt (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DHT/examples/DHTtester/DHTtester.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/DallasTemperature.cpp (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/DallasTemperature.h (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/README.TXT (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/change.txt (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/Alarm/Alarm.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/Multiple/Multiple.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/Simple/Simple.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/Single/Single.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/Tester/Tester.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/DallasTemperature/keywords.txt (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/OneWire/OneWire.cpp (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/OneWire/OneWire.h (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde (100%) rename {firmware/Nanpy => tests/makefile_stuff}/libraries/OneWire/keywords.txt (100%) diff --git a/.gitignore b/.gitignore index 6ce2d35..f7dbde5 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ cfg.h #hidden files .* !.gitignore + +#Internal dev +firmware/Nanpy/arduino.mk +firmware/Nanpy/Makefile +firmware/Nanpy/libraries diff --git a/firmware/Nanpy/Makefile b/tests/makefile_stuff/Makefile similarity index 100% rename from firmware/Nanpy/Makefile rename to tests/makefile_stuff/Makefile diff --git a/firmware/Nanpy/arduino.mk b/tests/makefile_stuff/arduino.mk similarity index 100% rename from firmware/Nanpy/arduino.mk rename to tests/makefile_stuff/arduino.mk diff --git a/firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.cpp b/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.cpp similarity index 100% rename from firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.cpp rename to tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.cpp diff --git a/firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.h b/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.h similarity index 100% rename from firmware/Nanpy/libraries/CapacitiveSensor/CapacitiveSensor.h rename to tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.h diff --git a/firmware/Nanpy/libraries/CapacitiveSensor/README.md b/tests/makefile_stuff/libraries/CapacitiveSensor/README.md similarity index 100% rename from firmware/Nanpy/libraries/CapacitiveSensor/README.md rename to tests/makefile_stuff/libraries/CapacitiveSensor/README.md diff --git a/firmware/Nanpy/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde b/tests/makefile_stuff/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde similarity index 100% rename from firmware/Nanpy/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde rename to tests/makefile_stuff/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde diff --git a/firmware/Nanpy/libraries/CapacitiveSensor/keywords.txt b/tests/makefile_stuff/libraries/CapacitiveSensor/keywords.txt similarity index 100% rename from firmware/Nanpy/libraries/CapacitiveSensor/keywords.txt rename to tests/makefile_stuff/libraries/CapacitiveSensor/keywords.txt diff --git a/firmware/Nanpy/libraries/DHT/DHT.cpp b/tests/makefile_stuff/libraries/DHT/DHT.cpp similarity index 100% rename from firmware/Nanpy/libraries/DHT/DHT.cpp rename to tests/makefile_stuff/libraries/DHT/DHT.cpp diff --git a/firmware/Nanpy/libraries/DHT/DHT.h b/tests/makefile_stuff/libraries/DHT/DHT.h similarity index 100% rename from firmware/Nanpy/libraries/DHT/DHT.h rename to tests/makefile_stuff/libraries/DHT/DHT.h diff --git a/firmware/Nanpy/libraries/DHT/README.txt b/tests/makefile_stuff/libraries/DHT/README.txt similarity index 100% rename from firmware/Nanpy/libraries/DHT/README.txt rename to tests/makefile_stuff/libraries/DHT/README.txt diff --git a/firmware/Nanpy/libraries/DHT/examples/DHTtester/DHTtester.pde b/tests/makefile_stuff/libraries/DHT/examples/DHTtester/DHTtester.pde similarity index 100% rename from firmware/Nanpy/libraries/DHT/examples/DHTtester/DHTtester.pde rename to tests/makefile_stuff/libraries/DHT/examples/DHTtester/DHTtester.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.cpp b/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.cpp similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.cpp rename to tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.cpp diff --git a/firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.h b/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.h similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/DallasTemperature.h rename to tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.h diff --git a/firmware/Nanpy/libraries/DallasTemperature/README.TXT b/tests/makefile_stuff/libraries/DallasTemperature/README.TXT similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/README.TXT rename to tests/makefile_stuff/libraries/DallasTemperature/README.TXT diff --git a/firmware/Nanpy/libraries/DallasTemperature/change.txt b/tests/makefile_stuff/libraries/DallasTemperature/change.txt similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/change.txt rename to tests/makefile_stuff/libraries/DallasTemperature/change.txt diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/Alarm/Alarm.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Alarm/Alarm.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/Alarm/Alarm.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/Alarm/Alarm.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/Multiple/Multiple.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Multiple/Multiple.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/Multiple/Multiple.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/Multiple/Multiple.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/Simple/Simple.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Simple/Simple.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/Simple/Simple.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/Simple/Simple.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/Single/Single.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Single/Single.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/Single/Single.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/Single/Single.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/Tester/Tester.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Tester/Tester.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/Tester/Tester.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/Tester/Tester.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde rename to tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde diff --git a/firmware/Nanpy/libraries/DallasTemperature/keywords.txt b/tests/makefile_stuff/libraries/DallasTemperature/keywords.txt similarity index 100% rename from firmware/Nanpy/libraries/DallasTemperature/keywords.txt rename to tests/makefile_stuff/libraries/DallasTemperature/keywords.txt diff --git a/firmware/Nanpy/libraries/OneWire/OneWire.cpp b/tests/makefile_stuff/libraries/OneWire/OneWire.cpp similarity index 100% rename from firmware/Nanpy/libraries/OneWire/OneWire.cpp rename to tests/makefile_stuff/libraries/OneWire/OneWire.cpp diff --git a/firmware/Nanpy/libraries/OneWire/OneWire.h b/tests/makefile_stuff/libraries/OneWire/OneWire.h similarity index 100% rename from firmware/Nanpy/libraries/OneWire/OneWire.h rename to tests/makefile_stuff/libraries/OneWire/OneWire.h diff --git a/firmware/Nanpy/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde b/tests/makefile_stuff/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde similarity index 100% rename from firmware/Nanpy/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde rename to tests/makefile_stuff/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde diff --git a/firmware/Nanpy/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde b/tests/makefile_stuff/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde similarity index 100% rename from firmware/Nanpy/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde rename to tests/makefile_stuff/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde diff --git a/firmware/Nanpy/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde b/tests/makefile_stuff/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde similarity index 100% rename from firmware/Nanpy/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde rename to tests/makefile_stuff/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde diff --git a/firmware/Nanpy/libraries/OneWire/keywords.txt b/tests/makefile_stuff/libraries/OneWire/keywords.txt similarity index 100% rename from firmware/Nanpy/libraries/OneWire/keywords.txt rename to tests/makefile_stuff/libraries/OneWire/keywords.txt From 93f2eee1ffb380a2a01a2adacf23c4d74fe96c96 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 4 Mar 2014 16:32:41 +0100 Subject: [PATCH 196/344] Check if running on AVR for freeram.c --- firmware/Nanpy/freeram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/Nanpy/freeram.c b/firmware/Nanpy/freeram.c index 5142d6e..48cefe8 100644 --- a/firmware/Nanpy/freeram.c +++ b/firmware/Nanpy/freeram.c @@ -1,4 +1,4 @@ - +#if defined(__AVR__) #include #include @@ -62,3 +62,4 @@ int free_ram3() return size; } +#endif \ No newline at end of file From 8a4d4d3bf9a7cba4f38ba18e8ff5963aa5401073 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 21 Mar 2014 19:03:40 +0100 Subject: [PATCH 197/344] Added missing configure.sh script --- .gitignore | 3 +-- firmware/configure.sh | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100755 firmware/configure.sh diff --git a/.gitignore b/.gitignore index f7dbde5..1d80c80 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,8 @@ build/ dist/ nanpy.egg-info/ -*.sh cfg.h - +setup_makefile.sh #Arduino *.o *.hex diff --git a/firmware/configure.sh b/firmware/configure.sh new file mode 100755 index 0000000..47f1183 --- /dev/null +++ b/firmware/configure.sh @@ -0,0 +1 @@ +cp sample_cfg.h Nanpy/cfg.h From af4bd8df7a6ce7cfb18fe13fae7a12e875fae8b5 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 21 Mar 2014 19:29:54 +0100 Subject: [PATCH 198/344] Removed firmware --- .gitignore | 11 +- README.md | 11 +- firmware/Nanpy/ArduinoClass.cpp | 48 - firmware/Nanpy/ArduinoClass.h | 17 - firmware/Nanpy/ArduinoCoreClass.cpp | 29 - firmware/Nanpy/ArduinoCoreClass.h | 15 - firmware/Nanpy/BaseClass.cpp | 6 - firmware/Nanpy/BaseClass.h | 71 - firmware/Nanpy/CapacitiveSensorClass.cpp | 31 - firmware/Nanpy/CapacitiveSensorClass.h | 19 - firmware/Nanpy/ComChannel.cpp | 68 - firmware/Nanpy/ComChannel.h | 27 - firmware/Nanpy/CounterClass.cpp | 35 - firmware/Nanpy/CounterClass.h | 15 - firmware/Nanpy/DHTClass.cpp | 39 - firmware/Nanpy/DHTClass.h | 19 - firmware/Nanpy/DallasTemperatureClass.cpp | 92 - firmware/Nanpy/DallasTemperatureClass.h | 19 - firmware/Nanpy/DefineClass.cpp | 106 - firmware/Nanpy/DefineClass.h | 15 - firmware/Nanpy/EEPROMClass.cpp | 28 - firmware/Nanpy/EEPROMClass.h | 17 - firmware/Nanpy/FreqCount.cpp | 115 - firmware/Nanpy/FreqCount.h | 14 - firmware/Nanpy/InfoClass.cpp | 26 - firmware/Nanpy/InfoClass.h | 15 - firmware/Nanpy/LiquidCrystalClass.cpp | 42 - firmware/Nanpy/LiquidCrystalClass.h | 20 - firmware/Nanpy/MethodDescriptor.cpp | 108 - firmware/Nanpy/MethodDescriptor.h | 39 - firmware/Nanpy/Nanpy.ino | 98 - firmware/Nanpy/OneWireClass.cpp | 76 - firmware/Nanpy/OneWireClass.h | 19 - firmware/Nanpy/RAMClass.cpp | 35 - firmware/Nanpy/RAMClass.h | 17 - firmware/Nanpy/RegisterClass.cpp | 113 - firmware/Nanpy/RegisterClass.h | 14 - firmware/Nanpy/ServoClass.cpp | 53 - firmware/Nanpy/ServoClass.h | 19 - firmware/Nanpy/SlimArray.h | 92 - firmware/Nanpy/StepperClass.cpp | 37 - firmware/Nanpy/StepperClass.h | 19 - firmware/Nanpy/ToneClass.cpp | 32 - firmware/Nanpy/ToneClass.h | 110 - firmware/Nanpy/ToneWrapper.cpp | 22 - firmware/Nanpy/ToneWrapper.h | 20 - firmware/Nanpy/WatchdogClass.cpp | 48 - firmware/Nanpy/WatchdogClass.h | 16 - firmware/Nanpy/freeram.c | 65 - firmware/Nanpy/freeram.h | 15 - firmware/Nanpy/generated_avr_registers.h | 13764 -------------------- firmware/Nanpy/generated_mcu.h | 1287 -- firmware/Nanpy/intdefs.h | 18 - firmware/Nanpy/timers.h | 501 - firmware/configure.sh | 1 - firmware/sample_cfg.h | 22 - 56 files changed, 3 insertions(+), 17627 deletions(-) delete mode 100644 firmware/Nanpy/ArduinoClass.cpp delete mode 100644 firmware/Nanpy/ArduinoClass.h delete mode 100644 firmware/Nanpy/ArduinoCoreClass.cpp delete mode 100644 firmware/Nanpy/ArduinoCoreClass.h delete mode 100644 firmware/Nanpy/BaseClass.cpp delete mode 100644 firmware/Nanpy/BaseClass.h delete mode 100644 firmware/Nanpy/CapacitiveSensorClass.cpp delete mode 100644 firmware/Nanpy/CapacitiveSensorClass.h delete mode 100755 firmware/Nanpy/ComChannel.cpp delete mode 100755 firmware/Nanpy/ComChannel.h delete mode 100644 firmware/Nanpy/CounterClass.cpp delete mode 100644 firmware/Nanpy/CounterClass.h delete mode 100644 firmware/Nanpy/DHTClass.cpp delete mode 100644 firmware/Nanpy/DHTClass.h delete mode 100644 firmware/Nanpy/DallasTemperatureClass.cpp delete mode 100644 firmware/Nanpy/DallasTemperatureClass.h delete mode 100644 firmware/Nanpy/DefineClass.cpp delete mode 100644 firmware/Nanpy/DefineClass.h delete mode 100644 firmware/Nanpy/EEPROMClass.cpp delete mode 100644 firmware/Nanpy/EEPROMClass.h delete mode 100644 firmware/Nanpy/FreqCount.cpp delete mode 100644 firmware/Nanpy/FreqCount.h delete mode 100644 firmware/Nanpy/InfoClass.cpp delete mode 100644 firmware/Nanpy/InfoClass.h delete mode 100644 firmware/Nanpy/LiquidCrystalClass.cpp delete mode 100644 firmware/Nanpy/LiquidCrystalClass.h delete mode 100755 firmware/Nanpy/MethodDescriptor.cpp delete mode 100644 firmware/Nanpy/MethodDescriptor.h delete mode 100644 firmware/Nanpy/Nanpy.ino delete mode 100644 firmware/Nanpy/OneWireClass.cpp delete mode 100644 firmware/Nanpy/OneWireClass.h delete mode 100644 firmware/Nanpy/RAMClass.cpp delete mode 100644 firmware/Nanpy/RAMClass.h delete mode 100644 firmware/Nanpy/RegisterClass.cpp delete mode 100644 firmware/Nanpy/RegisterClass.h delete mode 100644 firmware/Nanpy/ServoClass.cpp delete mode 100644 firmware/Nanpy/ServoClass.h delete mode 100644 firmware/Nanpy/SlimArray.h delete mode 100644 firmware/Nanpy/StepperClass.cpp delete mode 100644 firmware/Nanpy/StepperClass.h delete mode 100644 firmware/Nanpy/ToneClass.cpp delete mode 100644 firmware/Nanpy/ToneClass.h delete mode 100644 firmware/Nanpy/ToneWrapper.cpp delete mode 100644 firmware/Nanpy/ToneWrapper.h delete mode 100644 firmware/Nanpy/WatchdogClass.cpp delete mode 100644 firmware/Nanpy/WatchdogClass.h delete mode 100644 firmware/Nanpy/freeram.c delete mode 100644 firmware/Nanpy/freeram.h delete mode 100644 firmware/Nanpy/generated_avr_registers.h delete mode 100644 firmware/Nanpy/generated_mcu.h delete mode 100644 firmware/Nanpy/intdefs.h delete mode 100644 firmware/Nanpy/timers.h delete mode 100755 firmware/configure.sh delete mode 100644 firmware/sample_cfg.h diff --git a/.gitignore b/.gitignore index 1d80c80..7576ade 100644 --- a/.gitignore +++ b/.gitignore @@ -7,11 +7,7 @@ dist/ nanpy.egg-info/ cfg.h setup_makefile.sh -#Arduino -*.o -*.hex -*/.dep -*/.lib +firmware #Python *.pyc @@ -19,8 +15,3 @@ setup_makefile.sh #hidden files .* !.gitignore - -#Internal dev -firmware/Nanpy/arduino.mk -firmware/Nanpy/Makefile -firmware/Nanpy/libraries diff --git a/README.md b/README.md index 0c54ace..515c11e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ What happens if you call methods in an async context? Nothing bad, all works! ev How to build and install ------------------------ -You need to build the firmware for your Arduino first, copy firmware/Nanpy directory under your "sketchbook" directory, start Arduino program, open Sketchbook/Nanpy, select "Upload". +You need to build the firmware for your Arduino first, just clone the firmware repository at https://github.com/nanpy/firmware and follow the README to configure and build it. To install Nanpy Python library just type (as root): @@ -48,13 +48,6 @@ To install Nanpy Python library just type (as root): How to use ---------- -### Configure your Nanpy firmware - - $ cd firmware - $ ./configure.sh - -You can use Nanpy/cfg.h generated file to configure your Nanpy firmware, selecting the features you want to include and the baud rate. - ### Serial communication Nanpy autodetects the serial port for you, anyway you can specify another serial port manually: @@ -72,7 +65,7 @@ Import all the modules you need :) How to contribute ----------------- -Nanpy needs a lot of work to be a great instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at +Nanpy needs a lot of work to be a great tool. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at Donate ------ diff --git a/firmware/Nanpy/ArduinoClass.cpp b/firmware/Nanpy/ArduinoClass.cpp deleted file mode 100644 index 10543d8..0000000 --- a/firmware/Nanpy/ArduinoClass.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include "ArduinoClass.h" -#include - - -const char* nanpy::ArduinoClass::get_firmware_id() -{ - return "A"; -} - -void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "dw") == 0) { // digitalWrite - digitalWrite(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "r") == 0) { // digitalRead - m->returns(digitalRead(m->getInt(0))); - } - - if (strcmp(m->getName(), "aw") == 0) { // analogWrite - analogWrite(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "a") == 0) { // analogRead - m->returns(analogRead(m->getInt(0))); - } - - if (strcmp(m->getName(), "pm") == 0) { // pinMode - pinMode(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "delay") == 0) { - m->returns(0); - } - - if (strcmp(m->getName(), "m") == 0) { // millis - m->returns(millis()); - } - - if (strcmp(m->getName(), "s") == 0) { // shiftOut - // shiftOut(dataPin, clockPin, bitOrder, value) - shiftOut(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); - m->returns(0); - } -}; diff --git a/firmware/Nanpy/ArduinoClass.h b/firmware/Nanpy/ArduinoClass.h deleted file mode 100644 index c3ca79a..0000000 --- a/firmware/Nanpy/ArduinoClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ARDUINO_CLASS -#define ARDUINO_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class ArduinoClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - -#endif diff --git a/firmware/Nanpy/ArduinoCoreClass.cpp b/firmware/Nanpy/ArduinoCoreClass.cpp deleted file mode 100644 index b56bc63..0000000 --- a/firmware/Nanpy/ArduinoCoreClass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "cfg.h" - -#if USE_ArduinoCore - -#include -#include "ArduinoCoreClass.h" -#include - -#define RETURN_PIN_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x(m->getInt(0))); } -#define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns((uint16_t)x(m->getInt(0))); } - -const char* nanpy::ArduinoCoreClass::get_firmware_id() -{ - return "Core"; -} - -void nanpy::ArduinoCoreClass::elaborate(nanpy::MethodDescriptor* m) -{ - RETURN_PIN_FUNC(digitalPinToBitMask); - RETURN_PIN_FUNC(digitalPinToPort); - RETURN_PIN_FUNC(digitalPinToTimer); - RETURN_PIN_FUNC(analogInPinToBit); - - RETURN_PORT_FUNC(portModeRegister); - RETURN_PORT_FUNC(portOutputRegister); - RETURN_PORT_FUNC(portInputRegister); -} - -#endif diff --git a/firmware/Nanpy/ArduinoCoreClass.h b/firmware/Nanpy/ArduinoCoreClass.h deleted file mode 100644 index df1def5..0000000 --- a/firmware/Nanpy/ArduinoCoreClass.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class ArduinoCoreClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - diff --git a/firmware/Nanpy/BaseClass.cpp b/firmware/Nanpy/BaseClass.cpp deleted file mode 100644 index 333413f..0000000 --- a/firmware/Nanpy/BaseClass.cpp +++ /dev/null @@ -1,6 +0,0 @@ - -#include "BaseClass.h" - -using namespace nanpy; - -SlimArray Register::classes; diff --git a/firmware/Nanpy/BaseClass.h b/firmware/Nanpy/BaseClass.h deleted file mode 100644 index 159c402..0000000 --- a/firmware/Nanpy/BaseClass.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef BASE_CLASS -#define BASE_CLASS - -#include "cfg.h" -#include "SlimArray.h" -#include "MethodDescriptor.h" - -namespace nanpy { - - class BaseClass { - - public: - virtual void elaborate( nanpy::MethodDescriptor* m ) = 0; - virtual const char* get_firmware_id() = 0; - - }; - - template class ObjectsManager : public BaseClass { - - protected: - nanpy::SlimArray v; - - public: - ObjectsManager() {} - void elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - Serial.println("0"); - } - } - - }; - - - class Register { - static nanpy::SlimArray classes; - - public: - - template static void registerClass() { - nanpy::BaseClass* obj = (nanpy::BaseClass*)new T(); - classes.insert(obj); - } - - static nanpy::SlimArray * get_classes() { - return &classes; - } - - static void elaborate(nanpy::MethodDescriptor* m) { - for(int i = 0 ; i < classes.getSize() ; i++) - { - if (strcmp(m->getClass(), classes[i]->get_firmware_id()) == 0) - { - classes[i]->elaborate(m); - } - } - - if(m != NULL) { - delete(m); - m = NULL; - } - } - - }; -} - -#define REGISTER_CLASS_CONDITIONAL(cls, condition) if(condition) Register::registerClass(); -#define REGISTER_CLASS(cls) REGISTER_CLASS_CONDITIONAL(cls, 1); - -#endif diff --git a/firmware/Nanpy/CapacitiveSensorClass.cpp b/firmware/Nanpy/CapacitiveSensorClass.cpp deleted file mode 100644 index 1860d68..0000000 --- a/firmware/Nanpy/CapacitiveSensorClass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "cfg.h" - -#if USE_CapacitiveSensor - -#include -#include -#include "CapacitiveSensorClass.h" - -const char* nanpy::CapacitiveSensorClass::get_firmware_id() -{ - return "CapacitiveSensor"; -} - -void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new CapacitiveSensor(m->getInt(0), m->getInt(1))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "capacitiveSensor") == 0) { - m->returns(v[m->getObjectId()]->capacitiveSensor(m->getInt(0))); - } - - if (strcmp(m->getName(), "capacitiveSensorRaw") == 0) { - m->returns(v[m->getObjectId()]->capacitiveSensorRaw(m->getInt(0))); - } -}; - -#endif diff --git a/firmware/Nanpy/CapacitiveSensorClass.h b/firmware/Nanpy/CapacitiveSensorClass.h deleted file mode 100644 index 92ab2df..0000000 --- a/firmware/Nanpy/CapacitiveSensorClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CAPACITIVE_SENSOR_CLASS -#define CAPACITIVE_SENSOR_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class CapacitiveSensor; - -namespace nanpy { - class CapacitiveSensorClass : public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/ComChannel.cpp b/firmware/Nanpy/ComChannel.cpp deleted file mode 100755 index fe5a2a4..0000000 --- a/firmware/Nanpy/ComChannel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "ComChannel.h" -#include - -char* readLineFromSerial() -{ - char* buffer = (char*)malloc(30); - int i=0; - char ch = '0'; - do { - ch = Serial.read(); - if(ch != '\0' && ch < 255 && ch >= 0) { - buffer[i++] = ch; - } - } while(ch != '\0'); - char* buffer2 = (char*)malloc(i + 1); - buffer[i] = '\0'; - strcpy(buffer2, buffer); - free(buffer); - return buffer2; -}; - -bool nanpy::ComChannel::available() { - if (Serial.available() > 0) - return true; - else - return false; -} - -void nanpy::ComChannel::connect() { - Serial.begin(BAUDRATE); -} - -void nanpy::ComChannel::println(String& val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(const char* val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(int val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(unsigned int val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(float val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(double val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(long val) { - Serial.println(val); -} - -void nanpy::ComChannel::println(unsigned long val) { - Serial.println(val); -} - -char* nanpy::ComChannel::readLine() { - return readLineFromSerial(); -} - diff --git a/firmware/Nanpy/ComChannel.h b/firmware/Nanpy/ComChannel.h deleted file mode 100755 index 90876cc..0000000 --- a/firmware/Nanpy/ComChannel.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef COM_CHANNEL -#define COM_CHANNEL - -#include "cfg.h" - -#include - -namespace nanpy { - class ComChannel { - - public: - static bool available(); - static void connect(); - static void println(String& val); - static void println(const char* val); - static void println(int val); - static void println(unsigned int val); - static void println(float val); - static void println(double val); - static void println(long val); - static void println(unsigned long val); - static char* readLine(); - }; -} - -#endif - diff --git a/firmware/Nanpy/CounterClass.cpp b/firmware/Nanpy/CounterClass.cpp deleted file mode 100644 index 6a8a6d9..0000000 --- a/firmware/Nanpy/CounterClass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "cfg.h" - -#if USE_Counter - -#include "CounterClass.h" -#include "FreqCount.h" - -const char* nanpy::CounterClass::get_firmware_id() -{ - return "Counter"; -} - -void nanpy::CounterClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "begin") == 0) - { - FreqCount.begin(m->getInt(0)); - m->returns(0); - } - if (strcmp(m->getName(), "available") == 0) - { - m->returns(FreqCount.available()); - } - if (strcmp(m->getName(), "read") == 0) - { - m->returns(FreqCount.read()); - } - if (strcmp(m->getName(), "end") == 0) - { - FreqCount.end(); - m->returns(0); - } -} - -#endif diff --git a/firmware/Nanpy/CounterClass.h b/firmware/Nanpy/CounterClass.h deleted file mode 100644 index d148990..0000000 --- a/firmware/Nanpy/CounterClass.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class CounterClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - diff --git a/firmware/Nanpy/DHTClass.cpp b/firmware/Nanpy/DHTClass.cpp deleted file mode 100644 index 49c41de..0000000 --- a/firmware/Nanpy/DHTClass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "cfg.h" - -#if USE_DHT - -#include -#include -#include "DHTClass.h" -#include - -const char* nanpy::DHTClass::get_firmware_id() -{ - return "DHT"; -} - -void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - DHT* dht; - if (m->getNArgs() == 3) { - dht = new DHT (m->getInt(0), m->getInt(1), m->getInt(2)); - } else { - dht = new DHT (m->getInt(0), m->getInt(1)); - } - dht->begin(); - v.insert(dht); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "readHumidity") == 0) { - m->returns(v[m->getObjectId()]->readHumidity()); - } - - if (strcmp(m->getName(), "readTemperature") == 0) { - m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); - } -}; - -#endif diff --git a/firmware/Nanpy/DHTClass.h b/firmware/Nanpy/DHTClass.h deleted file mode 100644 index b14cd8f..0000000 --- a/firmware/Nanpy/DHTClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DHT_CLASS -#define DHT_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class DHT; - -namespace nanpy { - class DHTClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/DallasTemperatureClass.cpp b/firmware/Nanpy/DallasTemperatureClass.cpp deleted file mode 100644 index 80b8941..0000000 --- a/firmware/Nanpy/DallasTemperatureClass.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "cfg.h" - -#if USE_DallasTemperature - -#include -#include -#include -#include "DallasTemperatureClass.h" -#include - -const char* nanpy::DallasTemperatureClass::get_firmware_id() -{ - return "DallasTemperature"; -} - -void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - int prm = 0; - OneWire* wr = new OneWire(m->getInt(0)); - DallasTemperature* dt = new DallasTemperature(&(*wr)); - v.insert(dt); - dt->begin(); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "requestTemperatures") == 0) { - if (m->getNArgs() == 1) { - m->returns(v[m->getObjectId()]->requestTemperaturesByIndex(m->getInt(0))); - } else if (m->getNArgs() > 1) { - byte addr[8]; - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = (byte)m->getInt(i); - } - m->returns(v[m->getObjectId()]->requestTemperaturesByAddress(addr)); - } else { - v[m->getObjectId()]->requestTemperatures(); - m->returns(0); - } - } - - if (strcmp(m->getName(), "getTempC") == 0) { - if(m->getNArgs() == 1) { - m->returns(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); - } else { - byte addr[8]; - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = (byte)m->getInt(i); - } - m->returns(v[m->getObjectId()]->getTempC(addr)); - } - } - - if (strcmp(m->getName(), "getTempF") == 0) { - if(m->getNArgs() == 1) { - m->returns(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); - } else { - byte addr[8]; - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = (byte)m->getInt(i); - } - m->returns(v[m->getObjectId()]->getTempF(addr)); - } - } - - if (strcmp(m->getName(), "getAddress") == 0) { - byte addr[8]; - String addr_hex = String(); - if(!v[m->getObjectId()]->getAddress(addr, m->getInt(0))) { - m->returns(1); - return; - } - for( int cc = 0; cc < 7; cc++ ) - addr_hex += String(addr[cc]) + " "; - addr_hex += String(addr[7]); - m->returns(addr_hex); - } - - if (strcmp(m->getName(), "toFahrenheit") == 0) { - m->returns(DallasTemperature::toFahrenheit(m->getFloat(0))); - } - - if (strcmp(m->getName(), "toCelsius") == 0) { - m->returns(DallasTemperature::toCelsius(m->getFloat(0))); - } - - if (strcmp(m->getName(), "getDeviceCount") == 0) { - m->returns(v[m->getObjectId()]->getDeviceCount()); - } -}; -#endif diff --git a/firmware/Nanpy/DallasTemperatureClass.h b/firmware/Nanpy/DallasTemperatureClass.h deleted file mode 100644 index 30639c5..0000000 --- a/firmware/Nanpy/DallasTemperatureClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DALLAS_TEMP_CLASS -#define DALLAS_TEMP_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class DallasTemperature; - -namespace nanpy { - class DallasTemperatureClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/DefineClass.cpp b/firmware/Nanpy/DefineClass.cpp deleted file mode 100644 index ab27dca..0000000 --- a/firmware/Nanpy/DefineClass.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "cfg.h" - -#if USE_Define - -#include -#include "DefineClass.h" -#include -#include "generated_mcu.h" - -// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html - -// example: -// char string_A0[] PROGMEM = "A0"; -#define DEFINE(x) const char string_##x[] PROGMEM = #x; -#include "intdefs.h" -#undef DEFINE - -const char * const name_table[] PROGMEM = -{ -// example: -// string_A0, -#define DEFINE(x) string_##x, -#include "intdefs.h" -#undef DEFINE -}; - -const int32_t value_table[] PROGMEM = -{ -// example: -// A0, -#define DEFINE(x) x, -#include "intdefs.h" -#undef DEFINE -}; - -#define LONGEST_STRING_IN_INTDEFS_H 21 - -#define COUNT_INT_DEFS sizeof(name_table)/sizeof(name_table[0]) - -#define COUNT_STR_DEFS 4 -// __TIME__, __DATE__, __VERSION__, MCU - -const char* nanpy::DefineClass::get_firmware_id() -{ - return "D"; -} - -void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "c") == 0) // count - { - m->returns(COUNT_INT_DEFS + COUNT_STR_DEFS); - } - if (strcmp(m->getName(), "n") == 0) // name - { - int index = m->getInt(0); - switch (index) - { - case COUNT_INT_DEFS + 0: - m->returns("__TIME__"); - break; - case COUNT_INT_DEFS + 1: - m->returns("__DATE__"); - break; - case COUNT_INT_DEFS + 2: - m->returns("__VERSION__"); - break; - case COUNT_INT_DEFS + 3: - m->returns("MCU"); - break; - - default: -// index -= COUNT_STR_DEFS; - char buffer[LONGEST_STRING_IN_INTDEFS_H]; - strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); - m->returns(buffer); - } - } - if (strcmp(m->getName(), "v") == 0) // value - { - int index = m->getInt(0); - switch (index) - { - case COUNT_INT_DEFS + 0: - m->returns(__TIME__); - break; - case COUNT_INT_DEFS + 1: - m->returns(__DATE__); - break; - case COUNT_INT_DEFS + 2: - m->returns(__VERSION__); - break; - case COUNT_INT_DEFS + 3: - m->returns(MCU); - break; - - default: -// index -= COUNT_STR_DEFS; - int32_t value = pgm_read_dword(&(value_table[index])); - m->returns(value); - } - } - -} - -#endif diff --git a/firmware/Nanpy/DefineClass.h b/firmware/Nanpy/DefineClass.h deleted file mode 100644 index 3cd7d0a..0000000 --- a/firmware/Nanpy/DefineClass.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class DefineClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - diff --git a/firmware/Nanpy/EEPROMClass.cpp b/firmware/Nanpy/EEPROMClass.cpp deleted file mode 100644 index 349f176..0000000 --- a/firmware/Nanpy/EEPROMClass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "cfg.h" - -#if USE_EEPROM - -#include -#include "EEPROMClass.h" -#include - -const char* nanpy::EEPROMClass::get_firmware_id() -{ - return "EEPROM"; -} - -void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "write") == 0) { - EEPROM.write(m->getInt(0), m->getInt(1)); - m->returns(0); - } - if (strcmp(m->getName(), "read") == 0) { - m->returns(EEPROM.read(m->getInt(0))); - } - - if (strcmp(m->getName(), "size") == 0) { - m->returns(E2END+1); - } -}; - -#endif diff --git a/firmware/Nanpy/EEPROMClass.h b/firmware/Nanpy/EEPROMClass.h deleted file mode 100644 index 06cae2e..0000000 --- a/firmware/Nanpy/EEPROMClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef EEPROM_CLASS -#define EEPROM_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class EEPROMClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/FreqCount.cpp b/firmware/Nanpy/FreqCount.cpp deleted file mode 100644 index c74dd8b..0000000 --- a/firmware/Nanpy/FreqCount.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -/* FreqCount Library, for measuring frequencies - * http://www.pjrc.com/teensy/td_libs_FreqCount.html - * Copyright (c) 2011 PJRC.COM, LLC - Paul Stoffregen - * - * Version 1.0 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// FreqCount Library was so modified that it can be included in Nanpy - -#include "cfg.h" -#if USE_Counter - -#include "FreqCount.h" -#include "timers.h" - -static uint16_t count_msw; -static uint32_t count_prev; -static volatile uint32_t count_output; -static volatile uint8_t count_ready; -static uint16_t gate_length; -static uint16_t gate_index; - - -void FreqCountClass::begin(uint16_t msec) -{ - if (msec < 10) return; - gate_index = 0; - count_msw = 0; - count_prev = 0; - count_ready = 0; - counter_init(); - gate_length = timer_init(msec); - uint8_t status = SREG; - cli(); - timer_start(); - timer_isr_latency_delay(); - counter_start(); - SREG = status; -} - -uint8_t FreqCountClass::available(void) -{ - return count_ready; -} - -uint32_t FreqCountClass::read(void) -{ - uint32_t count; - uint8_t status; - - status = SREG; - cli(); - count = count_output; - count_ready = 0; - SREG = status; - return count; -} - -void FreqCountClass::end(void) -{ - timer_shutdown(); - counter_shutdown(); -} - - -ISR(TIMER_ISR_VECTOR) -{ - uint16_t count_lsw; - uint32_t count; - uint16_t index, length; - - count_lsw = counter_read(); - if (counter_overflow()) { - counter_overflow_reset(); - count_msw++; - } - index = gate_index + 1; - length = gate_length; - if (index >= length) { - gate_index = 0; - count = ((uint32_t)count_msw << 16) + count_lsw; - count_output = count - count_prev; - count_prev = count; - count_ready = 1; - restore_other_interrupts(); - } else { - if (index == length - 1) disable_other_interrupts(); - gate_index = index; - } -} - - -FreqCountClass FreqCount; - - -#endif diff --git a/firmware/Nanpy/FreqCount.h b/firmware/Nanpy/FreqCount.h deleted file mode 100644 index dc74526..0000000 --- a/firmware/Nanpy/FreqCount.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -class FreqCountClass { -public: - static void begin(uint16_t msec); - static uint8_t available(void); - static uint32_t read(void); - static void end(void); -}; - -extern FreqCountClass FreqCount; - diff --git a/firmware/Nanpy/InfoClass.cpp b/firmware/Nanpy/InfoClass.cpp deleted file mode 100644 index 2ec9ec1..0000000 --- a/firmware/Nanpy/InfoClass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "cfg.h" - -#if USE_Info - -#include "InfoClass.h" -#include - -const char* nanpy::InfoClass::get_firmware_id() -{ - return "Info"; -} - -void nanpy::InfoClass::elaborate(nanpy::MethodDescriptor* m) -{ - nanpy::SlimArray * classes = Register::get_classes(); - if (strcmp(m->getName(), "count") == 0) - { - m->returns(classes->getSize()); - } - if (strcmp(m->getName(), "name") == 0) - { - int index = m->getInt(0); - m->returns(classes->get(index)->get_firmware_id()); - } -} -#endif diff --git a/firmware/Nanpy/InfoClass.h b/firmware/Nanpy/InfoClass.h deleted file mode 100644 index 7f9dce2..0000000 --- a/firmware/Nanpy/InfoClass.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class InfoClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - diff --git a/firmware/Nanpy/LiquidCrystalClass.cpp b/firmware/Nanpy/LiquidCrystalClass.cpp deleted file mode 100644 index a75f550..0000000 --- a/firmware/Nanpy/LiquidCrystalClass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "cfg.h" - -#if USE_LiquidCrystal - -#include -#include -#include "LiquidCrystalClass.h" -#include -#include - -const char* nanpy::LiquidCrystalClass::get_firmware_id() -{ - return "Lcd"; -} - -void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - int prm = 0; - v.insert(new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), - m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); - v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "printString") == 0) { - if(m->getNArgs() == 3) { - v[m->getObjectId()]->setCursor(m->getInt(1), m->getInt(2)); - v[m->getObjectId()]->print(m->getString(0)); - } - else - v[m->getObjectId()]->print(m->getString(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "setCursor") == 0) { - v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); - m->returns(0); - } -}; -#endif diff --git a/firmware/Nanpy/LiquidCrystalClass.h b/firmware/Nanpy/LiquidCrystalClass.h deleted file mode 100644 index 4811ced..0000000 --- a/firmware/Nanpy/LiquidCrystalClass.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIQUID_CRYSTAL_CLASS -#define LIQUID_CRYSTAL_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class LiquidCrystal; - -namespace nanpy { - class LiquidCrystalClass : public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - - -#endif diff --git a/firmware/Nanpy/MethodDescriptor.cpp b/firmware/Nanpy/MethodDescriptor.cpp deleted file mode 100755 index 3b4002d..0000000 --- a/firmware/Nanpy/MethodDescriptor.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "MethodDescriptor.h" -#include -#include -#include "ComChannel.h" -#include - -nanpy::MethodDescriptor::MethodDescriptor() { - - this->classname = ComChannel::readLine(); - - char* buff; - - buff = ComChannel::readLine(); - this->objid = atoi(buff); - free(buff); - - buff = ComChannel::readLine(); - this->n_args = atoi(buff); - free(buff); - - this->name = ComChannel::readLine(); - - this->stack = (char**)malloc(sizeof(char*) * this->n_args); - - for(int n = 0; n < this->n_args; n++) { - this->stack[n] = ComChannel::readLine(); - } - -}; - -int nanpy::MethodDescriptor::getNArgs() { - return this->n_args; -}; - -bool nanpy::MethodDescriptor::getBool(int n) { - return strcmp(this->stack[n], "True") == 0 ? true : false; -}; - -int nanpy::MethodDescriptor::getInt(int n) { - return atoi(this->stack[n]); -}; - -float nanpy::MethodDescriptor::getFloat(int n) { - return atof(this->stack[n]); -}; - -double nanpy::MethodDescriptor::getDouble(int n) { - return atof(this->stack[n]); -}; - -char* nanpy::MethodDescriptor::getString(int n) { - return this->stack[n]; -}; - -char* nanpy::MethodDescriptor::getClass() { - return this->classname; -}; - -int nanpy::MethodDescriptor::getObjectId() { - return this->objid; -}; - -char* nanpy::MethodDescriptor::getName() { - return this->name; -}; - -void nanpy::MethodDescriptor::returns(String& val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(const char* val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(int val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(unsigned int val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(float val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(double val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(long val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(unsigned long val) { - ComChannel::println(val); -} - -nanpy::MethodDescriptor::~MethodDescriptor() { - delete(name); - delete(classname); - - for(int n = 0; n < this->n_args; n++) { - delete(this->stack[n]); - } - - delete(this->stack); -} diff --git a/firmware/Nanpy/MethodDescriptor.h b/firmware/Nanpy/MethodDescriptor.h deleted file mode 100644 index e8bc793..0000000 --- a/firmware/Nanpy/MethodDescriptor.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef METHOD_DESCRIPTOR -#define METHOD_DESCRIPTOR - -#include - -namespace nanpy { - class MethodDescriptor { - - private: - char *name; - int objid; - char* classname; - int n_args; - char **stack; - - public: - MethodDescriptor(); - int getNArgs(); - char* getClass(); - int getObjectId(); - bool getBool(int n); - int getInt(int n); - float getFloat(int n); - double getDouble(int n); - char* getString(int n); - char* getName(); - void returns(String& val); - void returns(const char* val); - void returns(int val); - void returns(unsigned int val); - void returns(float val); - void returns(double val); - void returns(long val); - void returns(unsigned long val); - ~MethodDescriptor(); - - }; -} -#endif diff --git a/firmware/Nanpy/Nanpy.ino b/firmware/Nanpy/Nanpy.ino deleted file mode 100644 index e93f94e..0000000 --- a/firmware/Nanpy/Nanpy.ino +++ /dev/null @@ -1,98 +0,0 @@ -#include "cfg.h" - -#if USE_Tone -# if USE_Counter -# error "USE_Tone conflicts with USE_Counter!" -# endif -#endif - -#if USE_EEPROM -#include -#endif - -#if USE_Servo -#include -#endif - -#if USE_LiquidCrystal -#include -#endif - -#if USE_Stepper -#include -#endif - -#if USE_OneWire -#include -#endif - -#if USE_DallasTemperature -#include -#endif - -#if USE_CapacitiveSensor -#include -#endif - -#if USE_DHT -#include -#endif - -#include "BaseClass.h" -#include "ArduinoClass.h" -#include "OneWireClass.h" -#include "StepperClass.h" -#include "ServoClass.h" -#include "DallasTemperatureClass.h" -#include "LiquidCrystalClass.h" -#include "CapacitiveSensorClass.h" -#include "ToneClass.h" -#include "MethodDescriptor.h" -#include "ComChannel.h" -#include "EEPROMClass.h" -#include "RAMClass.h" -#include "DHTClass.h" - -#include "DefineClass.h" -#include "ArduinoCoreClass.h" -#include "WatchdogClass.h" -#include "RegisterClass.h" -#include "CounterClass.h" -#include "InfoClass.h" - -using namespace nanpy; - -MethodDescriptor *m = NULL; - -void setup() { - disable_watchdog_at_startup(); - - REGISTER_CLASS(ArduinoClass); // 0.8 k - - REGISTER_CLASS_CONDITIONAL(nanpy::EEPROMClass, USE_EEPROM); // 0.3 k - REGISTER_CLASS_CONDITIONAL(nanpy::RAMClass, USE_RAM); // - REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass, USE_LiquidCrystal); // 2.3 k - REGISTER_CLASS_CONDITIONAL(OneWireClass, USE_OneWire); // 1.7 k - REGISTER_CLASS_CONDITIONAL(DallasTemperatureClass, USE_DallasTemperature); // 6.1 k - REGISTER_CLASS_CONDITIONAL(StepperClass, USE_Stepper); // 0.8 k - REGISTER_CLASS_CONDITIONAL(ServoClass, USE_Servo); // 2.5 k - REGISTER_CLASS_CONDITIONAL(ToneClass, USE_Tone); // 2.2 k - REGISTER_CLASS_CONDITIONAL(CapacitiveSensorClass, USE_CapacitiveSensor); // 2.2 k - REGISTER_CLASS_CONDITIONAL(DefineClass, USE_Define); // 0.6 k - REGISTER_CLASS_CONDITIONAL(ArduinoCoreClass, USE_ArduinoCore); // - REGISTER_CLASS_CONDITIONAL(WatchdogClass, USE_Watchdog); // 0.2 k - REGISTER_CLASS_CONDITIONAL(RegisterClass, USE_Register); // 1.5 k - - REGISTER_CLASS_CONDITIONAL(CounterClass, USE_Counter); // - REGISTER_CLASS_CONDITIONAL(InfoClass, USE_Info); // - REGISTER_CLASS_CONDITIONAL(DHTClass, USE_DHT); - - ComChannel::connect(); -} - -void loop() { - if(ComChannel::available()) { - m = new MethodDescriptor(); - Register::elaborate(m); - } -} diff --git a/firmware/Nanpy/OneWireClass.cpp b/firmware/Nanpy/OneWireClass.cpp deleted file mode 100644 index a0c036a..0000000 --- a/firmware/Nanpy/OneWireClass.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "cfg.h" - -#if USE_OneWire - -#include -#include "OneWireClass.h" -#include - -const char* nanpy::OneWireClass::get_firmware_id() -{ - return "OneWire"; -} - -void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new OneWire(m->getInt(0))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "search") == 0) { - byte addr[8]; - int res = v[m->getObjectId()]->search(addr); - - if(!res) { - v[m->getObjectId()]->reset_search(); - delay(250); - m->returns(1); - } - - else { - String addr_hex = String(); - for( int cc = 0; cc < 7; cc++ ) - addr_hex += String(addr[cc]) + " "; - addr_hex += String(addr[7]); - m->returns(addr_hex); - } - } - - if (strcmp(m->getName(), "reset_search") == 0) { - v[m->getObjectId()]->reset_search(); - m->returns(0); - } - - if (strcmp(m->getName(), "reset") == 0) { - m->returns(v[m->getObjectId()]->reset()); - } - - if (strcmp(m->getName(), "select") == 0) { - byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); - - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = (byte)m->getInt(i); - } - - v[m->getObjectId()]->select(addr); - - delete(addr); - m->returns(0); - } - - if (strcmp(m->getName(), "write") == 0) { - if(m->getNArgs() == 1) - v[m->getObjectId()]->write(m->getInt(0)); - else - v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "read") == 0) { - m->returns(v[m->getObjectId()]->read()); - } -}; - -#endif diff --git a/firmware/Nanpy/OneWireClass.h b/firmware/Nanpy/OneWireClass.h deleted file mode 100644 index 52e4842..0000000 --- a/firmware/Nanpy/OneWireClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ONE_WIRE_CLASS -#define ONE_WIRE_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class OneWire; - -namespace nanpy { - class OneWireClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/RAMClass.cpp b/firmware/Nanpy/RAMClass.cpp deleted file mode 100644 index 1059a77..0000000 --- a/firmware/Nanpy/RAMClass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "cfg.h" - -#if USE_RAM - -#include "RAMClass.h" -#include -#include "freeram.h" - - -const char* nanpy::RAMClass::get_firmware_id() -{ - return "RAM"; -} - -void nanpy::RAMClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "write") == 0) { - uint8_t* p = (uint8_t*)(m->getInt(0)); - *p = m->getInt(1); - m->returns(0); - } - if (strcmp(m->getName(), "read") == 0) { - uint8_t* p = (uint8_t*)(m->getInt(0)); - m->returns(*p); - } - - if (strcmp(m->getName(), "size") == 0) { - m->returns(RAMEND+1); - } - - if (strcmp(m->getName(), "free") == 0) { - m->returns(free_ram2()); - } -}; - -#endif diff --git a/firmware/Nanpy/RAMClass.h b/firmware/Nanpy/RAMClass.h deleted file mode 100644 index bd234a2..0000000 --- a/firmware/Nanpy/RAMClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RAM_CLASS -#define RAM_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class RAMClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/RegisterClass.cpp b/firmware/Nanpy/RegisterClass.cpp deleted file mode 100644 index 6d576ad..0000000 --- a/firmware/Nanpy/RegisterClass.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "cfg.h" - -#if USE_Register - -#include -#include "RegisterClass.h" -#include - -// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html - -#define MISSING(x) - -// example: -// char string_OCR2A[] PROGMEM = "OCR2A"; -#define DEFINE(x) const char string_##x[] PROGMEM = #x; -#include "generated_avr_registers.h" -#undef DEFINE - -const char * const name_table[] PROGMEM = -{ -// example: -// string_OCR2A, -#define DEFINE(x) string_##x, -#include "generated_avr_registers.h" -#undef DEFINE -}; - -#define DEFINE(x) (uint16_t)(&x), -const uint16_t reg_list[] PROGMEM = -{ -#include "generated_avr_registers.h" -}; -#undef DEFINE - -#define DEFINE(x) sizeof(x), -const uint16_t sizeof_list[] PROGMEM = -{ -#include "generated_avr_registers.h" -}; -#undef DEFINE - -const int REG_COUNT = sizeof(sizeof_list) / sizeof(sizeof_list[0]); - -#define LONGEST_REGISTER_NAME 21 - -const char* nanpy::RegisterClass::get_firmware_id() -{ - return "R"; -} - -void nanpy::RegisterClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "c") == 0) // count - { - m->returns(REG_COUNT); - } - else if (strcmp(m->getName(), "n") == 0) // name - { - word regindex = m->getInt(0); - char buffer[LONGEST_REGISTER_NAME]; - strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[regindex]))); - m->returns(buffer); - } - else - { - word regindex = m->getInt(0); - word regvalue = m->getInt(1); - - word regaddr = pgm_read_word(®_list[regindex]); - byte regsize = pgm_read_byte(&sizeof_list[regindex]); - - volatile byte* preg8 = (volatile byte*) regaddr; - volatile word* preg16 = (volatile word*) regaddr; - - if (strcmp(m->getName(), "r") == 0) // read - { - switch (regsize) - { - case 1: - m->returns(*preg8); - break; - case 2: - m->returns(*preg16); - break; - } - } - else if (strcmp(m->getName(), "w") == 0) // write - { - switch (regsize) - { - case 1: - *preg8 = (byte) regvalue; - break; - case 2: - *preg16 = regvalue; - break; - } - m->returns(0); - } - else if (strcmp(m->getName(), "a") == 0) // address - { - m->returns(regaddr); - } - else if (strcmp(m->getName(), "s") == 0) // size - { - m->returns(regsize); - } - - } -} - -#endif - diff --git a/firmware/Nanpy/RegisterClass.h b/firmware/Nanpy/RegisterClass.h deleted file mode 100644 index d30bb9c..0000000 --- a/firmware/Nanpy/RegisterClass.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class RegisterClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - diff --git a/firmware/Nanpy/ServoClass.cpp b/firmware/Nanpy/ServoClass.cpp deleted file mode 100644 index 6dce594..0000000 --- a/firmware/Nanpy/ServoClass.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "cfg.h" - -#if USE_Servo - -#include -#include -#include "ServoClass.h" -#include - -const char* nanpy::ServoClass::get_firmware_id() -{ - return "Servo"; -} - -void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - v.insert(new Servo()); - v[v.getLastIndex()]->attach(m->getInt(0)); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "write") == 0) { - v[m->getObjectId()]->write(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "read") == 0) { - m->returns(v[m->getObjectId()]->read()); - } - - if (strcmp(m->getName(), "writeMicroseconds") == 0) { - v[m->getObjectId()]->writeMicroseconds(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "readMicroseconds") == 0) { - m->returns(v[m->getObjectId()]->readMicroseconds()); - } - - if (strcmp(m->getName(), "detach") == 0) { - v[m->getObjectId()]->detach(); - m->returns(0); - } - - if (strcmp(m->getName(), "attached") == 0) { - m->returns(v[m->getObjectId()]->attached()); - } -} - -#endif - diff --git a/firmware/Nanpy/ServoClass.h b/firmware/Nanpy/ServoClass.h deleted file mode 100644 index e35fad2..0000000 --- a/firmware/Nanpy/ServoClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef SERVO_CLASS -#define SERVO_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class Servo; - -namespace nanpy { - class ServoClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/SlimArray.h b/firmware/Nanpy/SlimArray.h deleted file mode 100644 index 30cb23f..0000000 --- a/firmware/Nanpy/SlimArray.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SLIM_ARRAY -#define SLIM_ARRAY - -#include - -namespace nanpy { - template class SlimArray { - - private: - - int size; - int cur_size; - T *v; - - public: - - SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { - for(int i = 0; i < size; i++) - v[i] = 0; - cur_size = 0; - } - - SlimArray(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { - size = s; - for(int i = 0; i < size; i++) - v[i] = x[i]; - } - - void insert(T el) { - this->insert(cur_size, el); - } - - void remove(int pos) { - if(pos > size - 1) - return; - - T* newv = (T*)malloc(sizeof(T) * (size - 1)); - - int j = 0; - - for(int i = 0; i < size; i++) { - if(i != pos) { - newv[j] = v[i]; - j++; - } - } - - free(v); - v = newv; - cur_size--; - size--; - } - - void insert(int pos, T el) { - if(pos > size - 1) { - T* newv = (T*)malloc(sizeof(T) * (pos + 1)); - newv[pos] = el; - for(int i = 0; i < size; i++) - newv[i] = v[i]; - free(v); - size = pos + 1; - v = newv; - } else { - v[pos] = el; - } - cur_size++; - } - - T get(int pos) { - return v[pos]; - } - - T& operator[] ( int pos ) { - return v[pos]; - } - - int getSize() { - return this->size; - } - - int getLastIndex() { - return (this->cur_size - 1); - } - - ~SlimArray() { - free(v); - } - - }; -} - -#endif diff --git a/firmware/Nanpy/StepperClass.cpp b/firmware/Nanpy/StepperClass.cpp deleted file mode 100644 index 319344a..0000000 --- a/firmware/Nanpy/StepperClass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "cfg.h" - -#if USE_Stepper - -#include -#include -#include "StepperClass.h" -#include - -const char* nanpy::StepperClass::get_firmware_id() -{ - return "Stepper"; -} - -void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - int prm = 0; - v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "setSpeed") == 0) { - v[m->getObjectId()]->setSpeed(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "step") == 0) { - v[m->getObjectId()]->step(m->getInt(0)); - m->returns(0); - } -} - - -#endif - diff --git a/firmware/Nanpy/StepperClass.h b/firmware/Nanpy/StepperClass.h deleted file mode 100644 index 7311f17..0000000 --- a/firmware/Nanpy/StepperClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef STEPPER_CLASS -#define STEPPER_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class Stepper; - -namespace nanpy { - class StepperClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/ToneClass.cpp b/firmware/Nanpy/ToneClass.cpp deleted file mode 100644 index 7c27b6b..0000000 --- a/firmware/Nanpy/ToneClass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "cfg.h" - -#if USE_Tone - -#include -#include "ToneClass.h" -#include - -const char* nanpy::ToneClass::get_firmware_id() -{ - return "Tone"; -} - -void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - v.insert(new ToneWrapper (m->getInt(0))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "play") == 0) { - v[m->getObjectId()]->play(m->getInt(0), m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "stop") == 0) { - v[m->getObjectId()]->stop(); - m->returns(0); - } -}; -#endif diff --git a/firmware/Nanpy/ToneClass.h b/firmware/Nanpy/ToneClass.h deleted file mode 100644 index 75bcefa..0000000 --- a/firmware/Nanpy/ToneClass.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef TONE_CLASS -#define TONE_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -#define NOTE_B0 31 -#define NOTE_C1 33 -#define NOTE_CS1 35 -#define NOTE_D1 37 -#define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 -#define NOTE_FS1 46 -#define NOTE_G1 49 -#define NOTE_GS1 52 -#define NOTE_A1 55 -#define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 -#define NOTE_CS2 69 -#define NOTE_D2 73 -#define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 -#define NOTE_FS2 93 -#define NOTE_G2 98 -#define NOTE_GS2 104 -#define NOTE_A2 110 -#define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 -#define NOTE_CS3 139 -#define NOTE_D3 147 -#define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 -#define NOTE_FS3 185 -#define NOTE_G3 196 -#define NOTE_GS3 208 -#define NOTE_A3 220 -#define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 -#define NOTE_CS4 277 -#define NOTE_D4 294 -#define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 -#define NOTE_FS4 370 -#define NOTE_G4 392 -#define NOTE_GS4 415 -#define NOTE_A4 440 -#define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 -#define NOTE_CS5 554 -#define NOTE_D5 587 -#define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 -#define NOTE_FS5 740 -#define NOTE_G5 784 -#define NOTE_GS5 831 -#define NOTE_A5 880 -#define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 -#define NOTE_CS6 1109 -#define NOTE_D6 1175 -#define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 -#define NOTE_FS6 1480 -#define NOTE_G6 1568 -#define NOTE_GS6 1661 -#define NOTE_A6 1760 -#define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 -#define NOTE_CS7 2217 -#define NOTE_D7 2349 -#define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 -#define NOTE_FS7 2960 -#define NOTE_G7 3136 -#define NOTE_GS7 3322 -#define NOTE_A7 3520 -#define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 -#define NOTE_CS8 4435 -#define NOTE_D8 4699 -#define NOTE_DS8 4978 - -#include "ToneWrapper.h" - -namespace nanpy { - - class ToneClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/firmware/Nanpy/ToneWrapper.cpp b/firmware/Nanpy/ToneWrapper.cpp deleted file mode 100644 index 8854bad..0000000 --- a/firmware/Nanpy/ToneWrapper.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "cfg.h" - -#if USE_Tone - -#include "ToneWrapper.h" -#include - -void nanpy::ToneWrapper::play(int note, int duration) { - #if defined(__AVR__) - tone(pin, note, duration); - delay(duration * 1.30); - noTone(pin); - #endif -} - -void nanpy::ToneWrapper::stop(void) { - #if defined(__AVR__) - noTone(pin); - #endif -} - -#endif diff --git a/firmware/Nanpy/ToneWrapper.h b/firmware/Nanpy/ToneWrapper.h deleted file mode 100644 index bd64b18..0000000 --- a/firmware/Nanpy/ToneWrapper.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TONE_WRAPPER_H -#define TONE_WRAPPER_H - -namespace nanpy { -class ToneWrapper { - - private: - - int pin; - - public: - - ToneWrapper(int pin) : pin(pin) {} - void play(int note, int duration); - void stop(void); - -}; -} - -#endif diff --git a/firmware/Nanpy/WatchdogClass.cpp b/firmware/Nanpy/WatchdogClass.cpp deleted file mode 100644 index 3305fbf..0000000 --- a/firmware/Nanpy/WatchdogClass.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "cfg.h" - -#if USE_Watchdog - -#include -#include "WatchdogClass.h" -#include -#include - -const char* nanpy::WatchdogClass::get_firmware_id() -{ - return "Watchdog"; -} - -void nanpy::WatchdogClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "reset") == 0) - { - wdt_reset(); - m->returns(0); - } - if (strcmp(m->getName(), "enable") == 0) - { - wdt_enable(m->getInt(0)); - m->returns(0); - } - if (strcmp(m->getName(), "disable") == 0) - { - wdt_disable(); - m->returns(0); - } -} - -#endif - -void disable_watchdog_at_startup() -{ - // disable watchdog at startup - // http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html - // "the watchdog timer remains active even after a system reset (except a power-on condition), - // using the fastest prescaler value (approximately 15 ms). - // It is therefore required to turn off the watchdog early during program startup,.." - // "..clearing the watchdog reset flag before disabling the watchdog is required, according to the datasheet." -#ifdef MCUSR - MCUSR = 0; - wdt_disable(); -#endif -} diff --git a/firmware/Nanpy/WatchdogClass.h b/firmware/Nanpy/WatchdogClass.h deleted file mode 100644 index 8383785..0000000 --- a/firmware/Nanpy/WatchdogClass.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class WatchdogClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - -void disable_watchdog_at_startup(); diff --git a/firmware/Nanpy/freeram.c b/firmware/Nanpy/freeram.c deleted file mode 100644 index 48cefe8..0000000 --- a/firmware/Nanpy/freeram.c +++ /dev/null @@ -1,65 +0,0 @@ -#if defined(__AVR__) -#include -#include - - -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; -extern unsigned int __data_start; - -/// return available RAM -int free_ram1() -{ - /// copy from http://arduino.cc/playground/Code/AvailableMemory - int free_memory; - - if ((int) __brkval == 0) - free_memory = ((int) &free_memory) - ((int) &__bss_end); - else - free_memory = ((int) &free_memory) - ((int) __brkval); - - return free_memory; -} - -/// return available RAM -/*! This function places the current value of the heap and stack pointers in the - * variables. You can call it from any place in your code and save the data for - * outputting or displaying later. This allows you to check at different parts of - * your program flow. - * The stack pointer starts at the top of RAM and grows downwards. The heap pointer - * starts just above the static variables etc. and grows upwards. SP should always - * be larger than HP or you'll be in big trouble! The smaller the gap, the more - * careful you need to be. Julian Gall 6-Feb-2009. - */ -int free_ram2() -{ - /// copy from http://arduino.cc/playground/Code/AvailableMemory - uint8_t * heapptr, *stackptr; - - stackptr = (uint8_t *) malloc(4); // use stackptr temporarily - heapptr = stackptr; // save value of heap pointer - free(stackptr); // free up the memory again (sets stackptr to 0) - stackptr = (uint8_t *) (SP); // save value of stack pointer - return (int) (stackptr - heapptr); -} - -/// return available RAM - -/// this function will return the number of bytes currently free in RAM -/// written by David A. Mellis -/// based on code by Rob Faludi http://www.faludi.com -int free_ram3() -{ - /// copy from http://arduino.cc/playground/Code/AvailableMemory - int size = (int) RAMEND - (int) &__data_start; - uint8_t *buf; - - while ((buf = (uint8_t *) malloc(--size)) == NULL) - ; - - free(buf); - - return size; -} -#endif \ No newline at end of file diff --git a/firmware/Nanpy/freeram.h b/firmware/Nanpy/freeram.h deleted file mode 100644 index c0ba485..0000000 --- a/firmware/Nanpy/freeram.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -int free_ram1(); -int free_ram2(); -int free_ram3(); - -#ifdef __cplusplus -} -#endif - diff --git a/firmware/Nanpy/generated_avr_registers.h b/firmware/Nanpy/generated_avr_registers.h deleted file mode 100644 index caf238d..0000000 --- a/firmware/Nanpy/generated_avr_registers.h +++ /dev/null @@ -1,13764 +0,0 @@ - -// this file was generated by codegen.py - -// __AVR_LIBC_VERSION_STRING__ = "1.8.0" -// __AVR_LIBC_DATE_STRING__ = "20111228" - - -#ifdef AC0CON - DEFINE(AC0CON) -#else - MISSING(AC0CON) -#endif - -#ifdef AC1CON - DEFINE(AC1CON) -#else - MISSING(AC1CON) -#endif - -#ifdef AC1ECON - DEFINE(AC1ECON) -#else - MISSING(AC1ECON) -#endif - -#ifdef AC2CON - DEFINE(AC2CON) -#else - MISSING(AC2CON) -#endif - -#ifdef AC2ECON - DEFINE(AC2ECON) -#else - MISSING(AC2ECON) -#endif - -#ifdef AC3CON - DEFINE(AC3CON) -#else - MISSING(AC3CON) -#endif - -#ifdef AC3ECON - DEFINE(AC3ECON) -#else - MISSING(AC3ECON) -#endif - -#ifdef ACA_AC0CTRL - DEFINE(ACA_AC0CTRL) -#else - MISSING(ACA_AC0CTRL) -#endif - -#ifdef ACA_AC0MUXCTRL - DEFINE(ACA_AC0MUXCTRL) -#else - MISSING(ACA_AC0MUXCTRL) -#endif - -#ifdef ACA_AC1CTRL - DEFINE(ACA_AC1CTRL) -#else - MISSING(ACA_AC1CTRL) -#endif - -#ifdef ACA_AC1MUXCTRL - DEFINE(ACA_AC1MUXCTRL) -#else - MISSING(ACA_AC1MUXCTRL) -#endif - -#ifdef ACA_CTRLA - DEFINE(ACA_CTRLA) -#else - MISSING(ACA_CTRLA) -#endif - -#ifdef ACA_CTRLB - DEFINE(ACA_CTRLB) -#else - MISSING(ACA_CTRLB) -#endif - -#ifdef ACA_STATUS - DEFINE(ACA_STATUS) -#else - MISSING(ACA_STATUS) -#endif - -#ifdef ACA_WINCTRL - DEFINE(ACA_WINCTRL) -#else - MISSING(ACA_WINCTRL) -#endif - -#ifdef ACB_AC0CTRL - DEFINE(ACB_AC0CTRL) -#else - MISSING(ACB_AC0CTRL) -#endif - -#ifdef ACB_AC0MUXCTRL - DEFINE(ACB_AC0MUXCTRL) -#else - MISSING(ACB_AC0MUXCTRL) -#endif - -#ifdef ACB_AC1CTRL - DEFINE(ACB_AC1CTRL) -#else - MISSING(ACB_AC1CTRL) -#endif - -#ifdef ACB_AC1MUXCTRL - DEFINE(ACB_AC1MUXCTRL) -#else - MISSING(ACB_AC1MUXCTRL) -#endif - -#ifdef ACB_CTRLA - DEFINE(ACB_CTRLA) -#else - MISSING(ACB_CTRLA) -#endif - -#ifdef ACB_CTRLB - DEFINE(ACB_CTRLB) -#else - MISSING(ACB_CTRLB) -#endif - -#ifdef ACB_STATUS - DEFINE(ACB_STATUS) -#else - MISSING(ACB_STATUS) -#endif - -#ifdef ACB_WINCTRL - DEFINE(ACB_WINCTRL) -#else - MISSING(ACB_WINCTRL) -#endif - -#ifdef ACSR - DEFINE(ACSR) -#else - MISSING(ACSR) -#endif - -#ifdef ACSRA - DEFINE(ACSRA) -#else - MISSING(ACSRA) -#endif - -#ifdef ACSRB - DEFINE(ACSRB) -#else - MISSING(ACSRB) -#endif - -#ifdef ADC - DEFINE(ADC) -#else - MISSING(ADC) -#endif - -#ifdef ADCA_CAL - DEFINE(ADCA_CAL) -#else - MISSING(ADCA_CAL) -#endif - -#ifdef ADCA_CH0RES - DEFINE(ADCA_CH0RES) -#else - MISSING(ADCA_CH0RES) -#endif - -#ifdef ADCA_CH0_CTRL - DEFINE(ADCA_CH0_CTRL) -#else - MISSING(ADCA_CH0_CTRL) -#endif - -#ifdef ADCA_CH0_INTCTRL - DEFINE(ADCA_CH0_INTCTRL) -#else - MISSING(ADCA_CH0_INTCTRL) -#endif - -#ifdef ADCA_CH0_INTFLAGS - DEFINE(ADCA_CH0_INTFLAGS) -#else - MISSING(ADCA_CH0_INTFLAGS) -#endif - -#ifdef ADCA_CH0_MUXCTRL - DEFINE(ADCA_CH0_MUXCTRL) -#else - MISSING(ADCA_CH0_MUXCTRL) -#endif - -#ifdef ADCA_CH0_RES - DEFINE(ADCA_CH0_RES) -#else - MISSING(ADCA_CH0_RES) -#endif - -#ifdef ADCA_CH1RES - DEFINE(ADCA_CH1RES) -#else - MISSING(ADCA_CH1RES) -#endif - -#ifdef ADCA_CH1_CTRL - DEFINE(ADCA_CH1_CTRL) -#else - MISSING(ADCA_CH1_CTRL) -#endif - -#ifdef ADCA_CH1_INTCTRL - DEFINE(ADCA_CH1_INTCTRL) -#else - MISSING(ADCA_CH1_INTCTRL) -#endif - -#ifdef ADCA_CH1_INTFLAGS - DEFINE(ADCA_CH1_INTFLAGS) -#else - MISSING(ADCA_CH1_INTFLAGS) -#endif - -#ifdef ADCA_CH1_MUXCTRL - DEFINE(ADCA_CH1_MUXCTRL) -#else - MISSING(ADCA_CH1_MUXCTRL) -#endif - -#ifdef ADCA_CH1_RES - DEFINE(ADCA_CH1_RES) -#else - MISSING(ADCA_CH1_RES) -#endif - -#ifdef ADCA_CH2RES - DEFINE(ADCA_CH2RES) -#else - MISSING(ADCA_CH2RES) -#endif - -#ifdef ADCA_CH2_CTRL - DEFINE(ADCA_CH2_CTRL) -#else - MISSING(ADCA_CH2_CTRL) -#endif - -#ifdef ADCA_CH2_INTCTRL - DEFINE(ADCA_CH2_INTCTRL) -#else - MISSING(ADCA_CH2_INTCTRL) -#endif - -#ifdef ADCA_CH2_INTFLAGS - DEFINE(ADCA_CH2_INTFLAGS) -#else - MISSING(ADCA_CH2_INTFLAGS) -#endif - -#ifdef ADCA_CH2_MUXCTRL - DEFINE(ADCA_CH2_MUXCTRL) -#else - MISSING(ADCA_CH2_MUXCTRL) -#endif - -#ifdef ADCA_CH2_RES - DEFINE(ADCA_CH2_RES) -#else - MISSING(ADCA_CH2_RES) -#endif - -#ifdef ADCA_CH3RES - DEFINE(ADCA_CH3RES) -#else - MISSING(ADCA_CH3RES) -#endif - -#ifdef ADCA_CH3_CTRL - DEFINE(ADCA_CH3_CTRL) -#else - MISSING(ADCA_CH3_CTRL) -#endif - -#ifdef ADCA_CH3_INTCTRL - DEFINE(ADCA_CH3_INTCTRL) -#else - MISSING(ADCA_CH3_INTCTRL) -#endif - -#ifdef ADCA_CH3_INTFLAGS - DEFINE(ADCA_CH3_INTFLAGS) -#else - MISSING(ADCA_CH3_INTFLAGS) -#endif - -#ifdef ADCA_CH3_MUXCTRL - DEFINE(ADCA_CH3_MUXCTRL) -#else - MISSING(ADCA_CH3_MUXCTRL) -#endif - -#ifdef ADCA_CH3_RES - DEFINE(ADCA_CH3_RES) -#else - MISSING(ADCA_CH3_RES) -#endif - -#ifdef ADCA_CMP - DEFINE(ADCA_CMP) -#else - MISSING(ADCA_CMP) -#endif - -#ifdef ADCA_CTRLA - DEFINE(ADCA_CTRLA) -#else - MISSING(ADCA_CTRLA) -#endif - -#ifdef ADCA_CTRLB - DEFINE(ADCA_CTRLB) -#else - MISSING(ADCA_CTRLB) -#endif - -#ifdef ADCA_EVCTRL - DEFINE(ADCA_EVCTRL) -#else - MISSING(ADCA_EVCTRL) -#endif - -#ifdef ADCA_INTFLAGS - DEFINE(ADCA_INTFLAGS) -#else - MISSING(ADCA_INTFLAGS) -#endif - -#ifdef ADCA_PRESCALER - DEFINE(ADCA_PRESCALER) -#else - MISSING(ADCA_PRESCALER) -#endif - -#ifdef ADCA_REFCTRL - DEFINE(ADCA_REFCTRL) -#else - MISSING(ADCA_REFCTRL) -#endif - -#ifdef ADCA_TEMP - DEFINE(ADCA_TEMP) -#else - MISSING(ADCA_TEMP) -#endif - -#ifdef ADCB_CAL - DEFINE(ADCB_CAL) -#else - MISSING(ADCB_CAL) -#endif - -#ifdef ADCB_CH0RES - DEFINE(ADCB_CH0RES) -#else - MISSING(ADCB_CH0RES) -#endif - -#ifdef ADCB_CH0_CTRL - DEFINE(ADCB_CH0_CTRL) -#else - MISSING(ADCB_CH0_CTRL) -#endif - -#ifdef ADCB_CH0_INTCTRL - DEFINE(ADCB_CH0_INTCTRL) -#else - MISSING(ADCB_CH0_INTCTRL) -#endif - -#ifdef ADCB_CH0_INTFLAGS - DEFINE(ADCB_CH0_INTFLAGS) -#else - MISSING(ADCB_CH0_INTFLAGS) -#endif - -#ifdef ADCB_CH0_MUXCTRL - DEFINE(ADCB_CH0_MUXCTRL) -#else - MISSING(ADCB_CH0_MUXCTRL) -#endif - -#ifdef ADCB_CH0_RES - DEFINE(ADCB_CH0_RES) -#else - MISSING(ADCB_CH0_RES) -#endif - -#ifdef ADCB_CH1RES - DEFINE(ADCB_CH1RES) -#else - MISSING(ADCB_CH1RES) -#endif - -#ifdef ADCB_CH1_CTRL - DEFINE(ADCB_CH1_CTRL) -#else - MISSING(ADCB_CH1_CTRL) -#endif - -#ifdef ADCB_CH1_INTCTRL - DEFINE(ADCB_CH1_INTCTRL) -#else - MISSING(ADCB_CH1_INTCTRL) -#endif - -#ifdef ADCB_CH1_INTFLAGS - DEFINE(ADCB_CH1_INTFLAGS) -#else - MISSING(ADCB_CH1_INTFLAGS) -#endif - -#ifdef ADCB_CH1_MUXCTRL - DEFINE(ADCB_CH1_MUXCTRL) -#else - MISSING(ADCB_CH1_MUXCTRL) -#endif - -#ifdef ADCB_CH1_RES - DEFINE(ADCB_CH1_RES) -#else - MISSING(ADCB_CH1_RES) -#endif - -#ifdef ADCB_CH2RES - DEFINE(ADCB_CH2RES) -#else - MISSING(ADCB_CH2RES) -#endif - -#ifdef ADCB_CH2_CTRL - DEFINE(ADCB_CH2_CTRL) -#else - MISSING(ADCB_CH2_CTRL) -#endif - -#ifdef ADCB_CH2_INTCTRL - DEFINE(ADCB_CH2_INTCTRL) -#else - MISSING(ADCB_CH2_INTCTRL) -#endif - -#ifdef ADCB_CH2_INTFLAGS - DEFINE(ADCB_CH2_INTFLAGS) -#else - MISSING(ADCB_CH2_INTFLAGS) -#endif - -#ifdef ADCB_CH2_MUXCTRL - DEFINE(ADCB_CH2_MUXCTRL) -#else - MISSING(ADCB_CH2_MUXCTRL) -#endif - -#ifdef ADCB_CH2_RES - DEFINE(ADCB_CH2_RES) -#else - MISSING(ADCB_CH2_RES) -#endif - -#ifdef ADCB_CH3RES - DEFINE(ADCB_CH3RES) -#else - MISSING(ADCB_CH3RES) -#endif - -#ifdef ADCB_CH3_CTRL - DEFINE(ADCB_CH3_CTRL) -#else - MISSING(ADCB_CH3_CTRL) -#endif - -#ifdef ADCB_CH3_INTCTRL - DEFINE(ADCB_CH3_INTCTRL) -#else - MISSING(ADCB_CH3_INTCTRL) -#endif - -#ifdef ADCB_CH3_INTFLAGS - DEFINE(ADCB_CH3_INTFLAGS) -#else - MISSING(ADCB_CH3_INTFLAGS) -#endif - -#ifdef ADCB_CH3_MUXCTRL - DEFINE(ADCB_CH3_MUXCTRL) -#else - MISSING(ADCB_CH3_MUXCTRL) -#endif - -#ifdef ADCB_CH3_RES - DEFINE(ADCB_CH3_RES) -#else - MISSING(ADCB_CH3_RES) -#endif - -#ifdef ADCB_CMP - DEFINE(ADCB_CMP) -#else - MISSING(ADCB_CMP) -#endif - -#ifdef ADCB_CTRLA - DEFINE(ADCB_CTRLA) -#else - MISSING(ADCB_CTRLA) -#endif - -#ifdef ADCB_CTRLB - DEFINE(ADCB_CTRLB) -#else - MISSING(ADCB_CTRLB) -#endif - -#ifdef ADCB_EVCTRL - DEFINE(ADCB_EVCTRL) -#else - MISSING(ADCB_EVCTRL) -#endif - -#ifdef ADCB_INTFLAGS - DEFINE(ADCB_INTFLAGS) -#else - MISSING(ADCB_INTFLAGS) -#endif - -#ifdef ADCB_PRESCALER - DEFINE(ADCB_PRESCALER) -#else - MISSING(ADCB_PRESCALER) -#endif - -#ifdef ADCB_REFCTRL - DEFINE(ADCB_REFCTRL) -#else - MISSING(ADCB_REFCTRL) -#endif - -#ifdef ADCB_TEMP - DEFINE(ADCB_TEMP) -#else - MISSING(ADCB_TEMP) -#endif - -#ifdef ADCH - DEFINE(ADCH) -#else - MISSING(ADCH) -#endif - -#ifdef ADCL - DEFINE(ADCL) -#else - MISSING(ADCL) -#endif - -#ifdef ADCRA - DEFINE(ADCRA) -#else - MISSING(ADCRA) -#endif - -#ifdef ADCRB - DEFINE(ADCRB) -#else - MISSING(ADCRB) -#endif - -#ifdef ADCRC - DEFINE(ADCRC) -#else - MISSING(ADCRC) -#endif - -#ifdef ADCRD - DEFINE(ADCRD) -#else - MISSING(ADCRD) -#endif - -#ifdef ADCRE - DEFINE(ADCRE) -#else - MISSING(ADCRE) -#endif - -#ifdef ADCSR - DEFINE(ADCSR) -#else - MISSING(ADCSR) -#endif - -#ifdef ADCSRA - DEFINE(ADCSRA) -#else - MISSING(ADCSRA) -#endif - -#ifdef ADCSRB - DEFINE(ADCSRB) -#else - MISSING(ADCSRB) -#endif - -#ifdef ADCSRC - DEFINE(ADCSRC) -#else - MISSING(ADCSRC) -#endif - -#ifdef ADCW - DEFINE(ADCW) -#else - MISSING(ADCW) -#endif - -#ifdef ADCWH - DEFINE(ADCWH) -#else - MISSING(ADCWH) -#endif - -#ifdef ADCWL - DEFINE(ADCWL) -#else - MISSING(ADCWL) -#endif - -#ifdef ADIFR - DEFINE(ADIFR) -#else - MISSING(ADIFR) -#endif - -#ifdef ADIMR - DEFINE(ADIMR) -#else - MISSING(ADIMR) -#endif - -#ifdef ADMUX - DEFINE(ADMUX) -#else - MISSING(ADMUX) -#endif - -#ifdef ADRSLT - DEFINE(ADRSLT) -#else - MISSING(ADRSLT) -#endif - -#ifdef ADRSLTH - DEFINE(ADRSLTH) -#else - MISSING(ADRSLTH) -#endif - -#ifdef ADRSLTHI - DEFINE(ADRSLTHI) -#else - MISSING(ADRSLTHI) -#endif - -#ifdef ADRSLTL - DEFINE(ADRSLTL) -#else - MISSING(ADRSLTL) -#endif - -#ifdef ADRSLTLO - DEFINE(ADRSLTLO) -#else - MISSING(ADRSLTLO) -#endif - -#ifdef ADSCSRA - DEFINE(ADSCSRA) -#else - MISSING(ADSCSRA) -#endif - -#ifdef ADSCSRB - DEFINE(ADSCSRB) -#else - MISSING(ADSCSRB) -#endif - -#ifdef AESACR - DEFINE(AESACR) -#else - MISSING(AESACR) -#endif - -#ifdef AESADDR - DEFINE(AESADDR) -#else - MISSING(AESADDR) -#endif - -#ifdef AESCR - DEFINE(AESCR) -#else - MISSING(AESCR) -#endif - -#ifdef AESDR - DEFINE(AESDR) -#else - MISSING(AESDR) -#endif - -#ifdef AES_CTRL - DEFINE(AES_CTRL) -#else - MISSING(AES_CTRL) -#endif - -#ifdef AES_INTCTRL - DEFINE(AES_INTCTRL) -#else - MISSING(AES_INTCTRL) -#endif - -#ifdef AES_KEY - DEFINE(AES_KEY) -#else - MISSING(AES_KEY) -#endif - -#ifdef AES_STATE - DEFINE(AES_STATE) -#else - MISSING(AES_STATE) -#endif - -#ifdef AES_STATUS - DEFINE(AES_STATUS) -#else - MISSING(AES_STATUS) -#endif - -#ifdef AGPDDR - DEFINE(AGPDDR) -#else - MISSING(AGPDDR) -#endif - -#ifdef AGPPIN - DEFINE(AGPPIN) -#else - MISSING(AGPPIN) -#endif - -#ifdef AGPPORT - DEFINE(AGPPORT) -#else - MISSING(AGPPORT) -#endif - -#ifdef AMISCR - DEFINE(AMISCR) -#else - MISSING(AMISCR) -#endif - -#ifdef AMP0CSR - DEFINE(AMP0CSR) -#else - MISSING(AMP0CSR) -#endif - -#ifdef AMP1CSR - DEFINE(AMP1CSR) -#else - MISSING(AMP1CSR) -#endif - -#ifdef AMP2CSR - DEFINE(AMP2CSR) -#else - MISSING(AMP2CSR) -#endif - -#ifdef AMUXCTL - DEFINE(AMUXCTL) -#else - MISSING(AMUXCTL) -#endif - -#ifdef ANT_DIV - DEFINE(ANT_DIV) -#else - MISSING(ANT_DIV) -#endif - -#ifdef ASSR - DEFINE(ASSR) -#else - MISSING(ASSR) -#endif - -#ifdef AVR_CONFIG - DEFINE(AVR_CONFIG) -#else - MISSING(AVR_CONFIG) -#endif - -#ifdef AWEXC_CTRL - DEFINE(AWEXC_CTRL) -#else - MISSING(AWEXC_CTRL) -#endif - -#ifdef AWEXC_DTBOTH - DEFINE(AWEXC_DTBOTH) -#else - MISSING(AWEXC_DTBOTH) -#endif - -#ifdef AWEXC_DTBOTHBUF - DEFINE(AWEXC_DTBOTHBUF) -#else - MISSING(AWEXC_DTBOTHBUF) -#endif - -#ifdef AWEXC_DTHS - DEFINE(AWEXC_DTHS) -#else - MISSING(AWEXC_DTHS) -#endif - -#ifdef AWEXC_DTHSBUF - DEFINE(AWEXC_DTHSBUF) -#else - MISSING(AWEXC_DTHSBUF) -#endif - -#ifdef AWEXC_DTLS - DEFINE(AWEXC_DTLS) -#else - MISSING(AWEXC_DTLS) -#endif - -#ifdef AWEXC_DTLSBUF - DEFINE(AWEXC_DTLSBUF) -#else - MISSING(AWEXC_DTLSBUF) -#endif - -#ifdef AWEXC_FDCTRL - DEFINE(AWEXC_FDCTRL) -#else - MISSING(AWEXC_FDCTRL) -#endif - -#ifdef AWEXC_FDEMASK - DEFINE(AWEXC_FDEMASK) -#else - MISSING(AWEXC_FDEMASK) -#endif - -#ifdef AWEXC_OUTOVEN - DEFINE(AWEXC_OUTOVEN) -#else - MISSING(AWEXC_OUTOVEN) -#endif - -#ifdef AWEXC_STATUS - DEFINE(AWEXC_STATUS) -#else - MISSING(AWEXC_STATUS) -#endif - -#ifdef AWEXE_CTRL - DEFINE(AWEXE_CTRL) -#else - MISSING(AWEXE_CTRL) -#endif - -#ifdef AWEXE_DTBOTH - DEFINE(AWEXE_DTBOTH) -#else - MISSING(AWEXE_DTBOTH) -#endif - -#ifdef AWEXE_DTBOTHBUF - DEFINE(AWEXE_DTBOTHBUF) -#else - MISSING(AWEXE_DTBOTHBUF) -#endif - -#ifdef AWEXE_DTHS - DEFINE(AWEXE_DTHS) -#else - MISSING(AWEXE_DTHS) -#endif - -#ifdef AWEXE_DTHSBUF - DEFINE(AWEXE_DTHSBUF) -#else - MISSING(AWEXE_DTHSBUF) -#endif - -#ifdef AWEXE_DTLS - DEFINE(AWEXE_DTLS) -#else - MISSING(AWEXE_DTLS) -#endif - -#ifdef AWEXE_DTLSBUF - DEFINE(AWEXE_DTLSBUF) -#else - MISSING(AWEXE_DTLSBUF) -#endif - -#ifdef AWEXE_FDCTRL - DEFINE(AWEXE_FDCTRL) -#else - MISSING(AWEXE_FDCTRL) -#endif - -#ifdef AWEXE_FDEMASK - DEFINE(AWEXE_FDEMASK) -#else - MISSING(AWEXE_FDEMASK) -#endif - -#ifdef AWEXE_OUTOVEN - DEFINE(AWEXE_OUTOVEN) -#else - MISSING(AWEXE_OUTOVEN) -#endif - -#ifdef AWEXE_STATUS - DEFINE(AWEXE_STATUS) -#else - MISSING(AWEXE_STATUS) -#endif - -#ifdef BATMON - DEFINE(BATMON) -#else - MISSING(BATMON) -#endif - -#ifdef BGCAL - DEFINE(BGCAL) -#else - MISSING(BGCAL) -#endif - -#ifdef BGCCR - DEFINE(BGCCR) -#else - MISSING(BGCCR) -#endif - -#ifdef BGCR - DEFINE(BGCR) -#else - MISSING(BGCR) -#endif - -#ifdef BGCRA - DEFINE(BGCRA) -#else - MISSING(BGCRA) -#endif - -#ifdef BGCRB - DEFINE(BGCRB) -#else - MISSING(BGCRB) -#endif - -#ifdef BGCRR - DEFINE(BGCRR) -#else - MISSING(BGCRR) -#endif - -#ifdef BGCSR - DEFINE(BGCSR) -#else - MISSING(BGCSR) -#endif - -#ifdef BGCSRA - DEFINE(BGCSRA) -#else - MISSING(BGCSRA) -#endif - -#ifdef BGLR - DEFINE(BGLR) -#else - MISSING(BGLR) -#endif - -#ifdef BGPDDR - DEFINE(BGPDDR) -#else - MISSING(BGPDDR) -#endif - -#ifdef BGPPIN - DEFINE(BGPPIN) -#else - MISSING(BGPPIN) -#endif - -#ifdef BGPPORT - DEFINE(BGPPORT) -#else - MISSING(BGPPORT) -#endif - -#ifdef BL_CONFIG - DEFINE(BL_CONFIG) -#else - MISSING(BL_CONFIG) -#endif - -#ifdef BODCR - DEFINE(BODCR) -#else - MISSING(BODCR) -#endif - -#ifdef BPCHCD - DEFINE(BPCHCD) -#else - MISSING(BPCHCD) -#endif - -#ifdef BPCOCD - DEFINE(BPCOCD) -#else - MISSING(BPCOCD) -#endif - -#ifdef BPCR - DEFINE(BPCR) -#else - MISSING(BPCR) -#endif - -#ifdef BPDHCD - DEFINE(BPDHCD) -#else - MISSING(BPDHCD) -#endif - -#ifdef BPDOCD - DEFINE(BPDOCD) -#else - MISSING(BPDOCD) -#endif - -#ifdef BPDUV - DEFINE(BPDUV) -#else - MISSING(BPDUV) -#endif - -#ifdef BPHCTR - DEFINE(BPHCTR) -#else - MISSING(BPHCTR) -#endif - -#ifdef BPIFR - DEFINE(BPIFR) -#else - MISSING(BPIFR) -#endif - -#ifdef BPIMSK - DEFINE(BPIMSK) -#else - MISSING(BPIMSK) -#endif - -#ifdef BPIR - DEFINE(BPIR) -#else - MISSING(BPIR) -#endif - -#ifdef BPOCD - DEFINE(BPOCD) -#else - MISSING(BPOCD) -#endif - -#ifdef BPOCTR - DEFINE(BPOCTR) -#else - MISSING(BPOCTR) -#endif - -#ifdef BPPLR - DEFINE(BPPLR) -#else - MISSING(BPPLR) -#endif - -#ifdef BPSCD - DEFINE(BPSCD) -#else - MISSING(BPSCD) -#endif - -#ifdef BPSCTR - DEFINE(BPSCTR) -#else - MISSING(BPSCTR) -#endif - -#ifdef BTCNT - DEFINE(BTCNT) -#else - MISSING(BTCNT) -#endif - -#ifdef BTCR - DEFINE(BTCR) -#else - MISSING(BTCR) -#endif - -#ifdef B_DET - DEFINE(B_DET) -#else - MISSING(B_DET) -#endif - -#ifdef CADAC0 - DEFINE(CADAC0) -#else - MISSING(CADAC0) -#endif - -#ifdef CADAC1 - DEFINE(CADAC1) -#else - MISSING(CADAC1) -#endif - -#ifdef CADAC2 - DEFINE(CADAC2) -#else - MISSING(CADAC2) -#endif - -#ifdef CADAC3 - DEFINE(CADAC3) -#else - MISSING(CADAC3) -#endif - -#ifdef CADCSRA - DEFINE(CADCSRA) -#else - MISSING(CADCSRA) -#endif - -#ifdef CADCSRB - DEFINE(CADCSRB) -#else - MISSING(CADCSRB) -#endif - -#ifdef CADCSRC - DEFINE(CADCSRC) -#else - MISSING(CADCSRC) -#endif - -#ifdef CADIC - DEFINE(CADIC) -#else - MISSING(CADIC) -#endif - -#ifdef CADICH - DEFINE(CADICH) -#else - MISSING(CADICH) -#endif - -#ifdef CADICL - DEFINE(CADICL) -#else - MISSING(CADICL) -#endif - -#ifdef CADRC - DEFINE(CADRC) -#else - MISSING(CADRC) -#endif - -#ifdef CADRCC - DEFINE(CADRCC) -#else - MISSING(CADRCC) -#endif - -#ifdef CADRCL - DEFINE(CADRCL) -#else - MISSING(CADRCL) -#endif - -#ifdef CADRCLH - DEFINE(CADRCLH) -#else - MISSING(CADRCLH) -#endif - -#ifdef CADRCLL - DEFINE(CADRCLL) -#else - MISSING(CADRCLL) -#endif - -#ifdef CADRDC - DEFINE(CADRDC) -#else - MISSING(CADRDC) -#endif - -#ifdef CANBT1 - DEFINE(CANBT1) -#else - MISSING(CANBT1) -#endif - -#ifdef CANBT2 - DEFINE(CANBT2) -#else - MISSING(CANBT2) -#endif - -#ifdef CANBT3 - DEFINE(CANBT3) -#else - MISSING(CANBT3) -#endif - -#ifdef CANCDMOB - DEFINE(CANCDMOB) -#else - MISSING(CANCDMOB) -#endif - -#ifdef CANEN - DEFINE(CANEN) -#else - MISSING(CANEN) -#endif - -#ifdef CANEN1 - DEFINE(CANEN1) -#else - MISSING(CANEN1) -#endif - -#ifdef CANEN2 - DEFINE(CANEN2) -#else - MISSING(CANEN2) -#endif - -#ifdef CANGCON - DEFINE(CANGCON) -#else - MISSING(CANGCON) -#endif - -#ifdef CANGIE - DEFINE(CANGIE) -#else - MISSING(CANGIE) -#endif - -#ifdef CANGIT - DEFINE(CANGIT) -#else - MISSING(CANGIT) -#endif - -#ifdef CANGSTA - DEFINE(CANGSTA) -#else - MISSING(CANGSTA) -#endif - -#ifdef CANHPMOB - DEFINE(CANHPMOB) -#else - MISSING(CANHPMOB) -#endif - -#ifdef CANIDM1 - DEFINE(CANIDM1) -#else - MISSING(CANIDM1) -#endif - -#ifdef CANIDM2 - DEFINE(CANIDM2) -#else - MISSING(CANIDM2) -#endif - -#ifdef CANIDM3 - DEFINE(CANIDM3) -#else - MISSING(CANIDM3) -#endif - -#ifdef CANIDM4 - DEFINE(CANIDM4) -#else - MISSING(CANIDM4) -#endif - -#ifdef CANIDT1 - DEFINE(CANIDT1) -#else - MISSING(CANIDT1) -#endif - -#ifdef CANIDT2 - DEFINE(CANIDT2) -#else - MISSING(CANIDT2) -#endif - -#ifdef CANIDT3 - DEFINE(CANIDT3) -#else - MISSING(CANIDT3) -#endif - -#ifdef CANIDT4 - DEFINE(CANIDT4) -#else - MISSING(CANIDT4) -#endif - -#ifdef CANIE - DEFINE(CANIE) -#else - MISSING(CANIE) -#endif - -#ifdef CANIE1 - DEFINE(CANIE1) -#else - MISSING(CANIE1) -#endif - -#ifdef CANIE2 - DEFINE(CANIE2) -#else - MISSING(CANIE2) -#endif - -#ifdef CANMSG - DEFINE(CANMSG) -#else - MISSING(CANMSG) -#endif - -#ifdef CANPAGE - DEFINE(CANPAGE) -#else - MISSING(CANPAGE) -#endif - -#ifdef CANREC - DEFINE(CANREC) -#else - MISSING(CANREC) -#endif - -#ifdef CANSIT - DEFINE(CANSIT) -#else - MISSING(CANSIT) -#endif - -#ifdef CANSIT1 - DEFINE(CANSIT1) -#else - MISSING(CANSIT1) -#endif - -#ifdef CANSIT2 - DEFINE(CANSIT2) -#else - MISSING(CANSIT2) -#endif - -#ifdef CANSTM - DEFINE(CANSTM) -#else - MISSING(CANSTM) -#endif - -#ifdef CANSTMH - DEFINE(CANSTMH) -#else - MISSING(CANSTMH) -#endif - -#ifdef CANSTML - DEFINE(CANSTML) -#else - MISSING(CANSTML) -#endif - -#ifdef CANSTMOB - DEFINE(CANSTMOB) -#else - MISSING(CANSTMOB) -#endif - -#ifdef CANTCON - DEFINE(CANTCON) -#else - MISSING(CANTCON) -#endif - -#ifdef CANTEC - DEFINE(CANTEC) -#else - MISSING(CANTEC) -#endif - -#ifdef CANTIM - DEFINE(CANTIM) -#else - MISSING(CANTIM) -#endif - -#ifdef CANTIMH - DEFINE(CANTIMH) -#else - MISSING(CANTIMH) -#endif - -#ifdef CANTIML - DEFINE(CANTIML) -#else - MISSING(CANTIML) -#endif - -#ifdef CANTTC - DEFINE(CANTTC) -#else - MISSING(CANTTC) -#endif - -#ifdef CANTTCH - DEFINE(CANTTCH) -#else - MISSING(CANTTCH) -#endif - -#ifdef CANTTCL - DEFINE(CANTTCL) -#else - MISSING(CANTTCL) -#endif - -#ifdef CBCR - DEFINE(CBCR) -#else - MISSING(CBCR) -#endif - -#ifdef CBPTR - DEFINE(CBPTR) -#else - MISSING(CBPTR) -#endif - -#ifdef CBTR1 - DEFINE(CBTR1) -#else - MISSING(CBTR1) -#endif - -#ifdef CBTR2 - DEFINE(CBTR2) -#else - MISSING(CBTR2) -#endif - -#ifdef CBTR3 - DEFINE(CBTR3) -#else - MISSING(CBTR3) -#endif - -#ifdef CCA_THRES - DEFINE(CCA_THRES) -#else - MISSING(CCA_THRES) -#endif - -#ifdef CCFLG - DEFINE(CCFLG) -#else - MISSING(CCFLG) -#endif - -#ifdef CCISR - DEFINE(CCISR) -#else - MISSING(CCISR) -#endif - -#ifdef CCP - DEFINE(CCP) -#else - MISSING(CCP) -#endif - -#ifdef CCSR - DEFINE(CCSR) -#else - MISSING(CCSR) -#endif - -#ifdef CDIVCAN - DEFINE(CDIVCAN) -#else - MISSING(CDIVCAN) -#endif - -#ifdef CEFR - DEFINE(CEFR) -#else - MISSING(CEFR) -#endif - -#ifdef CGPDDR - DEFINE(CGPDDR) -#else - MISSING(CGPDDR) -#endif - -#ifdef CGPPIN - DEFINE(CGPPIN) -#else - MISSING(CGPPIN) -#endif - -#ifdef CGPPORT - DEFINE(CGPPORT) -#else - MISSING(CGPPORT) -#endif - -#ifdef CHGDCSR - DEFINE(CHGDCSR) -#else - MISSING(CHGDCSR) -#endif - -#ifdef CIDAH0 - DEFINE(CIDAH0) -#else - MISSING(CIDAH0) -#endif - -#ifdef CIDAH1 - DEFINE(CIDAH1) -#else - MISSING(CIDAH1) -#endif - -#ifdef CIER - DEFINE(CIER) -#else - MISSING(CIER) -#endif - -#ifdef CKSEL0 - DEFINE(CKSEL0) -#else - MISSING(CKSEL0) -#endif - -#ifdef CKSEL1 - DEFINE(CKSEL1) -#else - MISSING(CKSEL1) -#endif - -#ifdef CKSTA - DEFINE(CKSTA) -#else - MISSING(CKSTA) -#endif - -#ifdef CLKCSR - DEFINE(CLKCSR) -#else - MISSING(CLKCSR) -#endif - -#ifdef CLKMSR - DEFINE(CLKMSR) -#else - MISSING(CLKMSR) -#endif - -#ifdef CLKPR - DEFINE(CLKPR) -#else - MISSING(CLKPR) -#endif - -#ifdef CLKPSR - DEFINE(CLKPSR) -#else - MISSING(CLKPSR) -#endif - -#ifdef CLKSEL0 - DEFINE(CLKSEL0) -#else - MISSING(CLKSEL0) -#endif - -#ifdef CLKSEL1 - DEFINE(CLKSEL1) -#else - MISSING(CLKSEL1) -#endif - -#ifdef CLKSELR - DEFINE(CLKSELR) -#else - MISSING(CLKSELR) -#endif - -#ifdef CLKSTA - DEFINE(CLKSTA) -#else - MISSING(CLKSTA) -#endif - -#ifdef CLK_CNTR - DEFINE(CLK_CNTR) -#else - MISSING(CLK_CNTR) -#endif - -#ifdef CLK_CTRL - DEFINE(CLK_CTRL) -#else - MISSING(CLK_CTRL) -#endif - -#ifdef CLK_LOCK - DEFINE(CLK_LOCK) -#else - MISSING(CLK_LOCK) -#endif - -#ifdef CLK_PSCTRL - DEFINE(CLK_PSCTRL) -#else - MISSING(CLK_PSCTRL) -#endif - -#ifdef CLK_RTCCTRL - DEFINE(CLK_RTCCTRL) -#else - MISSING(CLK_RTCCTRL) -#endif - -#ifdef CLK_USBCTRL - DEFINE(CLK_USBCTRL) -#else - MISSING(CLK_USBCTRL) -#endif - -#ifdef CMCR - DEFINE(CMCR) -#else - MISSING(CMCR) -#endif - -#ifdef CMIMR - DEFINE(CMIMR) -#else - MISSING(CMIMR) -#endif - -#ifdef CMSR - DEFINE(CMSR) -#else - MISSING(CMSR) -#endif - -#ifdef COSDAC - DEFINE(COSDAC) -#else - MISSING(COSDAC) -#endif - -#ifdef COSDACH - DEFINE(COSDACH) -#else - MISSING(COSDACH) -#endif - -#ifdef COSDACL - DEFINE(COSDACL) -#else - MISSING(COSDACL) -#endif - -#ifdef CPU_CCP - DEFINE(CPU_CCP) -#else - MISSING(CPU_CCP) -#endif - -#ifdef CPU_EIND - DEFINE(CPU_EIND) -#else - MISSING(CPU_EIND) -#endif - -#ifdef CPU_RAMPD - DEFINE(CPU_RAMPD) -#else - MISSING(CPU_RAMPD) -#endif - -#ifdef CPU_RAMPX - DEFINE(CPU_RAMPX) -#else - MISSING(CPU_RAMPX) -#endif - -#ifdef CPU_RAMPY - DEFINE(CPU_RAMPY) -#else - MISSING(CPU_RAMPY) -#endif - -#ifdef CPU_RAMPZ - DEFINE(CPU_RAMPZ) -#else - MISSING(CPU_RAMPZ) -#endif - -#ifdef CPU_SPH - DEFINE(CPU_SPH) -#else - MISSING(CPU_SPH) -#endif - -#ifdef CPU_SPL - DEFINE(CPU_SPL) -#else - MISSING(CPU_SPL) -#endif - -#ifdef CPU_SREG - DEFINE(CPU_SREG) -#else - MISSING(CPU_SREG) -#endif - -#ifdef CRAFEN - DEFINE(CRAFEN) -#else - MISSING(CRAFEN) -#endif - -#ifdef CRC_CHECKSUM0 - DEFINE(CRC_CHECKSUM0) -#else - MISSING(CRC_CHECKSUM0) -#endif - -#ifdef CRC_CHECKSUM1 - DEFINE(CRC_CHECKSUM1) -#else - MISSING(CRC_CHECKSUM1) -#endif - -#ifdef CRC_CHECKSUM2 - DEFINE(CRC_CHECKSUM2) -#else - MISSING(CRC_CHECKSUM2) -#endif - -#ifdef CRC_CHECKSUM3 - DEFINE(CRC_CHECKSUM3) -#else - MISSING(CRC_CHECKSUM3) -#endif - -#ifdef CRC_CTRL - DEFINE(CRC_CTRL) -#else - MISSING(CRC_CTRL) -#endif - -#ifdef CRC_DATAIN - DEFINE(CRC_DATAIN) -#else - MISSING(CRC_DATAIN) -#endif - -#ifdef CRC_STATUS - DEFINE(CRC_STATUS) -#else - MISSING(CRC_STATUS) -#endif - -#ifdef CRXERR - DEFINE(CRXERR) -#else - MISSING(CRXERR) -#endif - -#ifdef CSMA_BE - DEFINE(CSMA_BE) -#else - MISSING(CSMA_BE) -#endif - -#ifdef CSMA_SEED_0 - DEFINE(CSMA_SEED_0) -#else - MISSING(CSMA_SEED_0) -#endif - -#ifdef CSMA_SEED_1 - DEFINE(CSMA_SEED_1) -#else - MISSING(CSMA_SEED_1) -#endif - -#ifdef CTARR - DEFINE(CTARR) -#else - MISSING(CTARR) -#endif - -#ifdef CTXERR - DEFINE(CTXERR) -#else - MISSING(CTXERR) -#endif - -#ifdef CURIRED - DEFINE(CURIRED) -#else - MISSING(CURIRED) -#endif - -#ifdef CURIRUN - DEFINE(CURIRUN) -#else - MISSING(CURIRUN) -#endif - -#ifdef CURRDLY - DEFINE(CURRDLY) -#else - MISSING(CURRDLY) -#endif - -#ifdef CVER - DEFINE(CVER) -#else - MISSING(CVER) -#endif - -#ifdef DAC - DEFINE(DAC) -#else - MISSING(DAC) -#endif - -#ifdef DACA_CH0DATA - DEFINE(DACA_CH0DATA) -#else - MISSING(DACA_CH0DATA) -#endif - -#ifdef DACA_CH0GAINCAL - DEFINE(DACA_CH0GAINCAL) -#else - MISSING(DACA_CH0GAINCAL) -#endif - -#ifdef DACA_CH0OFFSETCAL - DEFINE(DACA_CH0OFFSETCAL) -#else - MISSING(DACA_CH0OFFSETCAL) -#endif - -#ifdef DACA_CH1DATA - DEFINE(DACA_CH1DATA) -#else - MISSING(DACA_CH1DATA) -#endif - -#ifdef DACA_CH1GAINCAL - DEFINE(DACA_CH1GAINCAL) -#else - MISSING(DACA_CH1GAINCAL) -#endif - -#ifdef DACA_CH1OFFSETCAL - DEFINE(DACA_CH1OFFSETCAL) -#else - MISSING(DACA_CH1OFFSETCAL) -#endif - -#ifdef DACA_CTRLA - DEFINE(DACA_CTRLA) -#else - MISSING(DACA_CTRLA) -#endif - -#ifdef DACA_CTRLB - DEFINE(DACA_CTRLB) -#else - MISSING(DACA_CTRLB) -#endif - -#ifdef DACA_CTRLC - DEFINE(DACA_CTRLC) -#else - MISSING(DACA_CTRLC) -#endif - -#ifdef DACA_EVCTRL - DEFINE(DACA_EVCTRL) -#else - MISSING(DACA_EVCTRL) -#endif - -#ifdef DACA_GAINCAL - DEFINE(DACA_GAINCAL) -#else - MISSING(DACA_GAINCAL) -#endif - -#ifdef DACA_OFFSETCAL - DEFINE(DACA_OFFSETCAL) -#else - MISSING(DACA_OFFSETCAL) -#endif - -#ifdef DACA_STATUS - DEFINE(DACA_STATUS) -#else - MISSING(DACA_STATUS) -#endif - -#ifdef DACA_TIMCTRL - DEFINE(DACA_TIMCTRL) -#else - MISSING(DACA_TIMCTRL) -#endif - -#ifdef DACB_CH0DATA - DEFINE(DACB_CH0DATA) -#else - MISSING(DACB_CH0DATA) -#endif - -#ifdef DACB_CH0GAINCAL - DEFINE(DACB_CH0GAINCAL) -#else - MISSING(DACB_CH0GAINCAL) -#endif - -#ifdef DACB_CH0OFFSETCAL - DEFINE(DACB_CH0OFFSETCAL) -#else - MISSING(DACB_CH0OFFSETCAL) -#endif - -#ifdef DACB_CH1DATA - DEFINE(DACB_CH1DATA) -#else - MISSING(DACB_CH1DATA) -#endif - -#ifdef DACB_CH1GAINCAL - DEFINE(DACB_CH1GAINCAL) -#else - MISSING(DACB_CH1GAINCAL) -#endif - -#ifdef DACB_CH1OFFSETCAL - DEFINE(DACB_CH1OFFSETCAL) -#else - MISSING(DACB_CH1OFFSETCAL) -#endif - -#ifdef DACB_CTRLA - DEFINE(DACB_CTRLA) -#else - MISSING(DACB_CTRLA) -#endif - -#ifdef DACB_CTRLB - DEFINE(DACB_CTRLB) -#else - MISSING(DACB_CTRLB) -#endif - -#ifdef DACB_CTRLC - DEFINE(DACB_CTRLC) -#else - MISSING(DACB_CTRLC) -#endif - -#ifdef DACB_EVCTRL - DEFINE(DACB_EVCTRL) -#else - MISSING(DACB_EVCTRL) -#endif - -#ifdef DACB_GAINCAL - DEFINE(DACB_GAINCAL) -#else - MISSING(DACB_GAINCAL) -#endif - -#ifdef DACB_OFFSETCAL - DEFINE(DACB_OFFSETCAL) -#else - MISSING(DACB_OFFSETCAL) -#endif - -#ifdef DACB_STATUS - DEFINE(DACB_STATUS) -#else - MISSING(DACB_STATUS) -#endif - -#ifdef DACB_TIMCTRL - DEFINE(DACB_TIMCTRL) -#else - MISSING(DACB_TIMCTRL) -#endif - -#ifdef DACCTRL - DEFINE(DACCTRL) -#else - MISSING(DACCTRL) -#endif - -#ifdef DACH - DEFINE(DACH) -#else - MISSING(DACH) -#endif - -#ifdef DACL - DEFINE(DACL) -#else - MISSING(DACL) -#endif - -#ifdef DACON - DEFINE(DACON) -#else - MISSING(DACON) -#endif - -#ifdef DACVAL - DEFINE(DACVAL) -#else - MISSING(DACVAL) -#endif - -#ifdef DACVALH - DEFINE(DACVALH) -#else - MISSING(DACVALH) -#endif - -#ifdef DACVALHI - DEFINE(DACVALHI) -#else - MISSING(DACVALHI) -#endif - -#ifdef DACVALL - DEFINE(DACVALL) -#else - MISSING(DACVALL) -#endif - -#ifdef DACVALLO - DEFINE(DACVALLO) -#else - MISSING(DACVALLO) -#endif - -#ifdef DCCR - DEFINE(DCCR) -#else - MISSING(DCCR) -#endif - -#ifdef DDRA - DEFINE(DDRA) -#else - MISSING(DDRA) -#endif - -#ifdef DDRB - DEFINE(DDRB) -#else - MISSING(DDRB) -#endif - -#ifdef DDRC - DEFINE(DDRC) -#else - MISSING(DDRC) -#endif - -#ifdef DDRD - DEFINE(DDRD) -#else - MISSING(DDRD) -#endif - -#ifdef DDRE - DEFINE(DDRE) -#else - MISSING(DDRE) -#endif - -#ifdef DDRF - DEFINE(DDRF) -#else - MISSING(DDRF) -#endif - -#ifdef DDRG - DEFINE(DDRG) -#else - MISSING(DDRG) -#endif - -#ifdef DDRH - DEFINE(DDRH) -#else - MISSING(DDRH) -#endif - -#ifdef DDRJ - DEFINE(DDRJ) -#else - MISSING(DDRJ) -#endif - -#ifdef DDRK - DEFINE(DDRK) -#else - MISSING(DDRK) -#endif - -#ifdef DDRL - DEFINE(DDRL) -#else - MISSING(DDRL) -#endif - -#ifdef DEEAR - DEFINE(DEEAR) -#else - MISSING(DEEAR) -#endif - -#ifdef DEEARL - DEFINE(DEEARL) -#else - MISSING(DEEARL) -#endif - -#ifdef DEECR - DEFINE(DEECR) -#else - MISSING(DEECR) -#endif - -#ifdef DEEDR - DEFINE(DEEDR) -#else - MISSING(DEEDR) -#endif - -#ifdef DFLLRC2M_CALA - DEFINE(DFLLRC2M_CALA) -#else - MISSING(DFLLRC2M_CALA) -#endif - -#ifdef DFLLRC2M_CALB - DEFINE(DFLLRC2M_CALB) -#else - MISSING(DFLLRC2M_CALB) -#endif - -#ifdef DFLLRC2M_COMP0 - DEFINE(DFLLRC2M_COMP0) -#else - MISSING(DFLLRC2M_COMP0) -#endif - -#ifdef DFLLRC2M_COMP1 - DEFINE(DFLLRC2M_COMP1) -#else - MISSING(DFLLRC2M_COMP1) -#endif - -#ifdef DFLLRC2M_COMP2 - DEFINE(DFLLRC2M_COMP2) -#else - MISSING(DFLLRC2M_COMP2) -#endif - -#ifdef DFLLRC2M_CTRL - DEFINE(DFLLRC2M_CTRL) -#else - MISSING(DFLLRC2M_CTRL) -#endif - -#ifdef DFLLRC32M_CALA - DEFINE(DFLLRC32M_CALA) -#else - MISSING(DFLLRC32M_CALA) -#endif - -#ifdef DFLLRC32M_CALB - DEFINE(DFLLRC32M_CALB) -#else - MISSING(DFLLRC32M_CALB) -#endif - -#ifdef DFLLRC32M_COMP0 - DEFINE(DFLLRC32M_COMP0) -#else - MISSING(DFLLRC32M_COMP0) -#endif - -#ifdef DFLLRC32M_COMP1 - DEFINE(DFLLRC32M_COMP1) -#else - MISSING(DFLLRC32M_COMP1) -#endif - -#ifdef DFLLRC32M_COMP2 - DEFINE(DFLLRC32M_COMP2) -#else - MISSING(DFLLRC32M_COMP2) -#endif - -#ifdef DFLLRC32M_CTRL - DEFINE(DFLLRC32M_CTRL) -#else - MISSING(DFLLRC32M_CTRL) -#endif - -#ifdef DIDR - DEFINE(DIDR) -#else - MISSING(DIDR) -#endif - -#ifdef DIDR0 - DEFINE(DIDR0) -#else - MISSING(DIDR0) -#endif - -#ifdef DIDR1 - DEFINE(DIDR1) -#else - MISSING(DIDR1) -#endif - -#ifdef DIDR2 - DEFINE(DIDR2) -#else - MISSING(DIDR2) -#endif - -#ifdef DMA_CH0_ADDRCTRL - DEFINE(DMA_CH0_ADDRCTRL) -#else - MISSING(DMA_CH0_ADDRCTRL) -#endif - -#ifdef DMA_CH0_CTRLA - DEFINE(DMA_CH0_CTRLA) -#else - MISSING(DMA_CH0_CTRLA) -#endif - -#ifdef DMA_CH0_CTRLB - DEFINE(DMA_CH0_CTRLB) -#else - MISSING(DMA_CH0_CTRLB) -#endif - -#ifdef DMA_CH0_DESTADDR0 - DEFINE(DMA_CH0_DESTADDR0) -#else - MISSING(DMA_CH0_DESTADDR0) -#endif - -#ifdef DMA_CH0_DESTADDR1 - DEFINE(DMA_CH0_DESTADDR1) -#else - MISSING(DMA_CH0_DESTADDR1) -#endif - -#ifdef DMA_CH0_DESTADDR2 - DEFINE(DMA_CH0_DESTADDR2) -#else - MISSING(DMA_CH0_DESTADDR2) -#endif - -#ifdef DMA_CH0_REPCNT - DEFINE(DMA_CH0_REPCNT) -#else - MISSING(DMA_CH0_REPCNT) -#endif - -#ifdef DMA_CH0_SRCADDR0 - DEFINE(DMA_CH0_SRCADDR0) -#else - MISSING(DMA_CH0_SRCADDR0) -#endif - -#ifdef DMA_CH0_SRCADDR1 - DEFINE(DMA_CH0_SRCADDR1) -#else - MISSING(DMA_CH0_SRCADDR1) -#endif - -#ifdef DMA_CH0_SRCADDR2 - DEFINE(DMA_CH0_SRCADDR2) -#else - MISSING(DMA_CH0_SRCADDR2) -#endif - -#ifdef DMA_CH0_TRFCNT - DEFINE(DMA_CH0_TRFCNT) -#else - MISSING(DMA_CH0_TRFCNT) -#endif - -#ifdef DMA_CH0_TRIGSRC - DEFINE(DMA_CH0_TRIGSRC) -#else - MISSING(DMA_CH0_TRIGSRC) -#endif - -#ifdef DMA_CH1_ADDRCTRL - DEFINE(DMA_CH1_ADDRCTRL) -#else - MISSING(DMA_CH1_ADDRCTRL) -#endif - -#ifdef DMA_CH1_CTRLA - DEFINE(DMA_CH1_CTRLA) -#else - MISSING(DMA_CH1_CTRLA) -#endif - -#ifdef DMA_CH1_CTRLB - DEFINE(DMA_CH1_CTRLB) -#else - MISSING(DMA_CH1_CTRLB) -#endif - -#ifdef DMA_CH1_DESTADDR0 - DEFINE(DMA_CH1_DESTADDR0) -#else - MISSING(DMA_CH1_DESTADDR0) -#endif - -#ifdef DMA_CH1_DESTADDR1 - DEFINE(DMA_CH1_DESTADDR1) -#else - MISSING(DMA_CH1_DESTADDR1) -#endif - -#ifdef DMA_CH1_DESTADDR2 - DEFINE(DMA_CH1_DESTADDR2) -#else - MISSING(DMA_CH1_DESTADDR2) -#endif - -#ifdef DMA_CH1_REPCNT - DEFINE(DMA_CH1_REPCNT) -#else - MISSING(DMA_CH1_REPCNT) -#endif - -#ifdef DMA_CH1_SRCADDR0 - DEFINE(DMA_CH1_SRCADDR0) -#else - MISSING(DMA_CH1_SRCADDR0) -#endif - -#ifdef DMA_CH1_SRCADDR1 - DEFINE(DMA_CH1_SRCADDR1) -#else - MISSING(DMA_CH1_SRCADDR1) -#endif - -#ifdef DMA_CH1_SRCADDR2 - DEFINE(DMA_CH1_SRCADDR2) -#else - MISSING(DMA_CH1_SRCADDR2) -#endif - -#ifdef DMA_CH1_TRFCNT - DEFINE(DMA_CH1_TRFCNT) -#else - MISSING(DMA_CH1_TRFCNT) -#endif - -#ifdef DMA_CH1_TRIGSRC - DEFINE(DMA_CH1_TRIGSRC) -#else - MISSING(DMA_CH1_TRIGSRC) -#endif - -#ifdef DMA_CH2_ADDRCTRL - DEFINE(DMA_CH2_ADDRCTRL) -#else - MISSING(DMA_CH2_ADDRCTRL) -#endif - -#ifdef DMA_CH2_CTRLA - DEFINE(DMA_CH2_CTRLA) -#else - MISSING(DMA_CH2_CTRLA) -#endif - -#ifdef DMA_CH2_CTRLB - DEFINE(DMA_CH2_CTRLB) -#else - MISSING(DMA_CH2_CTRLB) -#endif - -#ifdef DMA_CH2_DESTADDR0 - DEFINE(DMA_CH2_DESTADDR0) -#else - MISSING(DMA_CH2_DESTADDR0) -#endif - -#ifdef DMA_CH2_DESTADDR1 - DEFINE(DMA_CH2_DESTADDR1) -#else - MISSING(DMA_CH2_DESTADDR1) -#endif - -#ifdef DMA_CH2_DESTADDR2 - DEFINE(DMA_CH2_DESTADDR2) -#else - MISSING(DMA_CH2_DESTADDR2) -#endif - -#ifdef DMA_CH2_REPCNT - DEFINE(DMA_CH2_REPCNT) -#else - MISSING(DMA_CH2_REPCNT) -#endif - -#ifdef DMA_CH2_SRCADDR0 - DEFINE(DMA_CH2_SRCADDR0) -#else - MISSING(DMA_CH2_SRCADDR0) -#endif - -#ifdef DMA_CH2_SRCADDR1 - DEFINE(DMA_CH2_SRCADDR1) -#else - MISSING(DMA_CH2_SRCADDR1) -#endif - -#ifdef DMA_CH2_SRCADDR2 - DEFINE(DMA_CH2_SRCADDR2) -#else - MISSING(DMA_CH2_SRCADDR2) -#endif - -#ifdef DMA_CH2_TRFCNT - DEFINE(DMA_CH2_TRFCNT) -#else - MISSING(DMA_CH2_TRFCNT) -#endif - -#ifdef DMA_CH2_TRIGSRC - DEFINE(DMA_CH2_TRIGSRC) -#else - MISSING(DMA_CH2_TRIGSRC) -#endif - -#ifdef DMA_CH3_ADDRCTRL - DEFINE(DMA_CH3_ADDRCTRL) -#else - MISSING(DMA_CH3_ADDRCTRL) -#endif - -#ifdef DMA_CH3_CTRLA - DEFINE(DMA_CH3_CTRLA) -#else - MISSING(DMA_CH3_CTRLA) -#endif - -#ifdef DMA_CH3_CTRLB - DEFINE(DMA_CH3_CTRLB) -#else - MISSING(DMA_CH3_CTRLB) -#endif - -#ifdef DMA_CH3_DESTADDR0 - DEFINE(DMA_CH3_DESTADDR0) -#else - MISSING(DMA_CH3_DESTADDR0) -#endif - -#ifdef DMA_CH3_DESTADDR1 - DEFINE(DMA_CH3_DESTADDR1) -#else - MISSING(DMA_CH3_DESTADDR1) -#endif - -#ifdef DMA_CH3_DESTADDR2 - DEFINE(DMA_CH3_DESTADDR2) -#else - MISSING(DMA_CH3_DESTADDR2) -#endif - -#ifdef DMA_CH3_REPCNT - DEFINE(DMA_CH3_REPCNT) -#else - MISSING(DMA_CH3_REPCNT) -#endif - -#ifdef DMA_CH3_SRCADDR0 - DEFINE(DMA_CH3_SRCADDR0) -#else - MISSING(DMA_CH3_SRCADDR0) -#endif - -#ifdef DMA_CH3_SRCADDR1 - DEFINE(DMA_CH3_SRCADDR1) -#else - MISSING(DMA_CH3_SRCADDR1) -#endif - -#ifdef DMA_CH3_SRCADDR2 - DEFINE(DMA_CH3_SRCADDR2) -#else - MISSING(DMA_CH3_SRCADDR2) -#endif - -#ifdef DMA_CH3_TRFCNT - DEFINE(DMA_CH3_TRFCNT) -#else - MISSING(DMA_CH3_TRFCNT) -#endif - -#ifdef DMA_CH3_TRIGSRC - DEFINE(DMA_CH3_TRIGSRC) -#else - MISSING(DMA_CH3_TRIGSRC) -#endif - -#ifdef DMA_CTRL - DEFINE(DMA_CTRL) -#else - MISSING(DMA_CTRL) -#endif - -#ifdef DMA_INTFLAGS - DEFINE(DMA_INTFLAGS) -#else - MISSING(DMA_INTFLAGS) -#endif - -#ifdef DMA_STATUS - DEFINE(DMA_STATUS) -#else - MISSING(DMA_STATUS) -#endif - -#ifdef DMA_TEMP - DEFINE(DMA_TEMP) -#else - MISSING(DMA_TEMP) -#endif - -#ifdef DPDS0 - DEFINE(DPDS0) -#else - MISSING(DPDS0) -#endif - -#ifdef DPDS1 - DEFINE(DPDS1) -#else - MISSING(DPDS1) -#endif - -#ifdef DRTRAM0 - DEFINE(DRTRAM0) -#else - MISSING(DRTRAM0) -#endif - -#ifdef DRTRAM1 - DEFINE(DRTRAM1) -#else - MISSING(DRTRAM1) -#endif - -#ifdef DRTRAM2 - DEFINE(DRTRAM2) -#else - MISSING(DRTRAM2) -#endif - -#ifdef DRTRAM3 - DEFINE(DRTRAM3) -#else - MISSING(DRTRAM3) -#endif - -#ifdef DT1 - DEFINE(DT1) -#else - MISSING(DT1) -#endif - -#ifdef DT1A - DEFINE(DT1A) -#else - MISSING(DT1A) -#endif - -#ifdef DT1B - DEFINE(DT1B) -#else - MISSING(DT1B) -#endif - -#ifdef DT4 - DEFINE(DT4) -#else - MISSING(DT4) -#endif - -#ifdef DTPS1 - DEFINE(DTPS1) -#else - MISSING(DTPS1) -#endif - -#ifdef DWDR - DEFINE(DWDR) -#else - MISSING(DWDR) -#endif - -#ifdef EBI_CS0_BASEADDR - DEFINE(EBI_CS0_BASEADDR) -#else - MISSING(EBI_CS0_BASEADDR) -#endif - -#ifdef EBI_CS0_CTRLA - DEFINE(EBI_CS0_CTRLA) -#else - MISSING(EBI_CS0_CTRLA) -#endif - -#ifdef EBI_CS0_CTRLB - DEFINE(EBI_CS0_CTRLB) -#else - MISSING(EBI_CS0_CTRLB) -#endif - -#ifdef EBI_CS1_BASEADDR - DEFINE(EBI_CS1_BASEADDR) -#else - MISSING(EBI_CS1_BASEADDR) -#endif - -#ifdef EBI_CS1_CTRLA - DEFINE(EBI_CS1_CTRLA) -#else - MISSING(EBI_CS1_CTRLA) -#endif - -#ifdef EBI_CS1_CTRLB - DEFINE(EBI_CS1_CTRLB) -#else - MISSING(EBI_CS1_CTRLB) -#endif - -#ifdef EBI_CS2_BASEADDR - DEFINE(EBI_CS2_BASEADDR) -#else - MISSING(EBI_CS2_BASEADDR) -#endif - -#ifdef EBI_CS2_CTRLA - DEFINE(EBI_CS2_CTRLA) -#else - MISSING(EBI_CS2_CTRLA) -#endif - -#ifdef EBI_CS2_CTRLB - DEFINE(EBI_CS2_CTRLB) -#else - MISSING(EBI_CS2_CTRLB) -#endif - -#ifdef EBI_CS3_BASEADDR - DEFINE(EBI_CS3_BASEADDR) -#else - MISSING(EBI_CS3_BASEADDR) -#endif - -#ifdef EBI_CS3_CTRLA - DEFINE(EBI_CS3_CTRLA) -#else - MISSING(EBI_CS3_CTRLA) -#endif - -#ifdef EBI_CS3_CTRLB - DEFINE(EBI_CS3_CTRLB) -#else - MISSING(EBI_CS3_CTRLB) -#endif - -#ifdef EBI_CTRL - DEFINE(EBI_CTRL) -#else - MISSING(EBI_CTRL) -#endif - -#ifdef EBI_INITDLY - DEFINE(EBI_INITDLY) -#else - MISSING(EBI_INITDLY) -#endif - -#ifdef EBI_REFRESH - DEFINE(EBI_REFRESH) -#else - MISSING(EBI_REFRESH) -#endif - -#ifdef EBI_SDRAMCTRLA - DEFINE(EBI_SDRAMCTRLA) -#else - MISSING(EBI_SDRAMCTRLA) -#endif - -#ifdef EBI_SDRAMCTRLB - DEFINE(EBI_SDRAMCTRLB) -#else - MISSING(EBI_SDRAMCTRLB) -#endif - -#ifdef EBI_SDRAMCTRLC - DEFINE(EBI_SDRAMCTRLC) -#else - MISSING(EBI_SDRAMCTRLC) -#endif - -#ifdef EEAR - DEFINE(EEAR) -#else - MISSING(EEAR) -#endif - -#ifdef EEARH - DEFINE(EEARH) -#else - MISSING(EEARH) -#endif - -#ifdef EEARL - DEFINE(EEARL) -#else - MISSING(EEARL) -#endif - -#ifdef EECR - DEFINE(EECR) -#else - MISSING(EECR) -#endif - -#ifdef EEDR - DEFINE(EEDR) -#else - MISSING(EEDR) -#endif - -#ifdef EICR - DEFINE(EICR) -#else - MISSING(EICR) -#endif - -#ifdef EICRA - DEFINE(EICRA) -#else - MISSING(EICRA) -#endif - -#ifdef EICRB - DEFINE(EICRB) -#else - MISSING(EICRB) -#endif - -#ifdef EIFR - DEFINE(EIFR) -#else - MISSING(EIFR) -#endif - -#ifdef EIMF - DEFINE(EIMF) -#else - MISSING(EIMF) -#endif - -#ifdef EIMSK - DEFINE(EIMSK) -#else - MISSING(EIMSK) -#endif - -#ifdef EIND - DEFINE(EIND) -#else - MISSING(EIND) -#endif - -#ifdef EIRR - DEFINE(EIRR) -#else - MISSING(EIRR) -#endif - -#ifdef EMCUCR - DEFINE(EMCUCR) -#else - MISSING(EMCUCR) -#endif - -#ifdef ETIFR - DEFINE(ETIFR) -#else - MISSING(ETIFR) -#endif - -#ifdef ETIMSK - DEFINE(ETIMSK) -#else - MISSING(ETIMSK) -#endif - -#ifdef EUCSRA - DEFINE(EUCSRA) -#else - MISSING(EUCSRA) -#endif - -#ifdef EUCSRB - DEFINE(EUCSRB) -#else - MISSING(EUCSRB) -#endif - -#ifdef EUCSRC - DEFINE(EUCSRC) -#else - MISSING(EUCSRC) -#endif - -#ifdef EUDR - DEFINE(EUDR) -#else - MISSING(EUDR) -#endif - -#ifdef EVSYS_CH0CTRL - DEFINE(EVSYS_CH0CTRL) -#else - MISSING(EVSYS_CH0CTRL) -#endif - -#ifdef EVSYS_CH0MUX - DEFINE(EVSYS_CH0MUX) -#else - MISSING(EVSYS_CH0MUX) -#endif - -#ifdef EVSYS_CH1CTRL - DEFINE(EVSYS_CH1CTRL) -#else - MISSING(EVSYS_CH1CTRL) -#endif - -#ifdef EVSYS_CH1MUX - DEFINE(EVSYS_CH1MUX) -#else - MISSING(EVSYS_CH1MUX) -#endif - -#ifdef EVSYS_CH2CTRL - DEFINE(EVSYS_CH2CTRL) -#else - MISSING(EVSYS_CH2CTRL) -#endif - -#ifdef EVSYS_CH2MUX - DEFINE(EVSYS_CH2MUX) -#else - MISSING(EVSYS_CH2MUX) -#endif - -#ifdef EVSYS_CH3CTRL - DEFINE(EVSYS_CH3CTRL) -#else - MISSING(EVSYS_CH3CTRL) -#endif - -#ifdef EVSYS_CH3MUX - DEFINE(EVSYS_CH3MUX) -#else - MISSING(EVSYS_CH3MUX) -#endif - -#ifdef EVSYS_CH4CTRL - DEFINE(EVSYS_CH4CTRL) -#else - MISSING(EVSYS_CH4CTRL) -#endif - -#ifdef EVSYS_CH4MUX - DEFINE(EVSYS_CH4MUX) -#else - MISSING(EVSYS_CH4MUX) -#endif - -#ifdef EVSYS_CH5CTRL - DEFINE(EVSYS_CH5CTRL) -#else - MISSING(EVSYS_CH5CTRL) -#endif - -#ifdef EVSYS_CH5MUX - DEFINE(EVSYS_CH5MUX) -#else - MISSING(EVSYS_CH5MUX) -#endif - -#ifdef EVSYS_CH6CTRL - DEFINE(EVSYS_CH6CTRL) -#else - MISSING(EVSYS_CH6CTRL) -#endif - -#ifdef EVSYS_CH6MUX - DEFINE(EVSYS_CH6MUX) -#else - MISSING(EVSYS_CH6MUX) -#endif - -#ifdef EVSYS_CH7CTRL - DEFINE(EVSYS_CH7CTRL) -#else - MISSING(EVSYS_CH7CTRL) -#endif - -#ifdef EVSYS_CH7MUX - DEFINE(EVSYS_CH7MUX) -#else - MISSING(EVSYS_CH7MUX) -#endif - -#ifdef EVSYS_DATA - DEFINE(EVSYS_DATA) -#else - MISSING(EVSYS_DATA) -#endif - -#ifdef EVSYS_STROBE - DEFINE(EVSYS_STROBE) -#else - MISSING(EVSYS_STROBE) -#endif - -#ifdef EXOCR1A - DEFINE(EXOCR1A) -#else - MISSING(EXOCR1A) -#endif - -#ifdef EXOCR1AH - DEFINE(EXOCR1AH) -#else - MISSING(EXOCR1AH) -#endif - -#ifdef EXOCR1AL - DEFINE(EXOCR1AL) -#else - MISSING(EXOCR1AL) -#endif - -#ifdef EXOCR1B - DEFINE(EXOCR1B) -#else - MISSING(EXOCR1B) -#endif - -#ifdef EXOCR1BH - DEFINE(EXOCR1BH) -#else - MISSING(EXOCR1BH) -#endif - -#ifdef EXOCR1BL - DEFINE(EXOCR1BL) -#else - MISSING(EXOCR1BL) -#endif - -#ifdef EXTCCR0 - DEFINE(EXTCCR0) -#else - MISSING(EXTCCR0) -#endif - -#ifdef EXTCCR1A - DEFINE(EXTCCR1A) -#else - MISSING(EXTCCR1A) -#endif - -#ifdef EXTCCR1B - DEFINE(EXTCCR1B) -#else - MISSING(EXTCCR1B) -#endif - -#ifdef EXTCNT - DEFINE(EXTCNT) -#else - MISSING(EXTCNT) -#endif - -#ifdef EXTCNT1 - DEFINE(EXTCNT1) -#else - MISSING(EXTCNT1) -#endif - -#ifdef EXTCNT1H - DEFINE(EXTCNT1H) -#else - MISSING(EXTCNT1H) -#endif - -#ifdef EXTCNT1L - DEFINE(EXTCNT1L) -#else - MISSING(EXTCNT1L) -#endif - -#ifdef EXTIFR - DEFINE(EXTIFR) -#else - MISSING(EXTIFR) -#endif - -#ifdef EXTIMSK - DEFINE(EXTIMSK) -#else - MISSING(EXTIMSK) -#endif - -#ifdef FCSR - DEFINE(FCSR) -#else - MISSING(FCSR) -#endif - -#ifdef FISCR - DEFINE(FISCR) -#else - MISSING(FISCR) -#endif - -#ifdef FISUA - DEFINE(FISUA) -#else - MISSING(FISUA) -#endif - -#ifdef FISUB - DEFINE(FISUB) -#else - MISSING(FISUB) -#endif - -#ifdef FISUC - DEFINE(FISUC) -#else - MISSING(FISUC) -#endif - -#ifdef FISUD - DEFINE(FISUD) -#else - MISSING(FISUD) -#endif - -#ifdef FOSCCAL - DEFINE(FOSCCAL) -#else - MISSING(FOSCCAL) -#endif - -#ifdef FPGAD - DEFINE(FPGAD) -#else - MISSING(FPGAD) -#endif - -#ifdef FPGAX - DEFINE(FPGAX) -#else - MISSING(FPGAX) -#endif - -#ifdef FPGAY - DEFINE(FPGAY) -#else - MISSING(FPGAY) -#endif - -#ifdef FPGAZ - DEFINE(FPGAZ) -#else - MISSING(FPGAZ) -#endif - -#ifdef FRCCAL - DEFINE(FRCCAL) -#else - MISSING(FRCCAL) -#endif - -#ifdef FTN_CTRL - DEFINE(FTN_CTRL) -#else - MISSING(FTN_CTRL) -#endif - -#ifdef GAINDAC - DEFINE(GAINDAC) -#else - MISSING(GAINDAC) -#endif - -#ifdef GICR - DEFINE(GICR) -#else - MISSING(GICR) -#endif - -#ifdef GIFR - DEFINE(GIFR) -#else - MISSING(GIFR) -#endif - -#ifdef GIMSK - DEFINE(GIMSK) -#else - MISSING(GIMSK) -#endif - -#ifdef GIPR - DEFINE(GIPR) -#else - MISSING(GIPR) -#endif - -#ifdef GPIO0 - DEFINE(GPIO0) -#else - MISSING(GPIO0) -#endif - -#ifdef GPIO1 - DEFINE(GPIO1) -#else - MISSING(GPIO1) -#endif - -#ifdef GPIO2 - DEFINE(GPIO2) -#else - MISSING(GPIO2) -#endif - -#ifdef GPIO3 - DEFINE(GPIO3) -#else - MISSING(GPIO3) -#endif - -#ifdef GPIO4 - DEFINE(GPIO4) -#else - MISSING(GPIO4) -#endif - -#ifdef GPIO5 - DEFINE(GPIO5) -#else - MISSING(GPIO5) -#endif - -#ifdef GPIO6 - DEFINE(GPIO6) -#else - MISSING(GPIO6) -#endif - -#ifdef GPIO7 - DEFINE(GPIO7) -#else - MISSING(GPIO7) -#endif - -#ifdef GPIO8 - DEFINE(GPIO8) -#else - MISSING(GPIO8) -#endif - -#ifdef GPIO9 - DEFINE(GPIO9) -#else - MISSING(GPIO9) -#endif - -#ifdef GPIOA - DEFINE(GPIOA) -#else - MISSING(GPIOA) -#endif - -#ifdef GPIOB - DEFINE(GPIOB) -#else - MISSING(GPIOB) -#endif - -#ifdef GPIOC - DEFINE(GPIOC) -#else - MISSING(GPIOC) -#endif - -#ifdef GPIOD - DEFINE(GPIOD) -#else - MISSING(GPIOD) -#endif - -#ifdef GPIOE - DEFINE(GPIOE) -#else - MISSING(GPIOE) -#endif - -#ifdef GPIOF - DEFINE(GPIOF) -#else - MISSING(GPIOF) -#endif - -#ifdef GPIOR0 - DEFINE(GPIOR0) -#else - MISSING(GPIOR0) -#endif - -#ifdef GPIOR1 - DEFINE(GPIOR1) -#else - MISSING(GPIOR1) -#endif - -#ifdef GPIOR2 - DEFINE(GPIOR2) -#else - MISSING(GPIOR2) -#endif - -#ifdef GPIOR3 - DEFINE(GPIOR3) -#else - MISSING(GPIOR3) -#endif - -#ifdef GPIOR4 - DEFINE(GPIOR4) -#else - MISSING(GPIOR4) -#endif - -#ifdef GPIOR5 - DEFINE(GPIOR5) -#else - MISSING(GPIOR5) -#endif - -#ifdef GPIOR6 - DEFINE(GPIOR6) -#else - MISSING(GPIOR6) -#endif - -#ifdef GPIOR7 - DEFINE(GPIOR7) -#else - MISSING(GPIOR7) -#endif - -#ifdef GPIOR8 - DEFINE(GPIOR8) -#else - MISSING(GPIOR8) -#endif - -#ifdef GPIOR9 - DEFINE(GPIOR9) -#else - MISSING(GPIOR9) -#endif - -#ifdef GPIORA - DEFINE(GPIORA) -#else - MISSING(GPIORA) -#endif - -#ifdef GPIORB - DEFINE(GPIORB) -#else - MISSING(GPIORB) -#endif - -#ifdef GPIORC - DEFINE(GPIORC) -#else - MISSING(GPIORC) -#endif - -#ifdef GPIORD - DEFINE(GPIORD) -#else - MISSING(GPIORD) -#endif - -#ifdef GPIORE - DEFINE(GPIORE) -#else - MISSING(GPIORE) -#endif - -#ifdef GPIORF - DEFINE(GPIORF) -#else - MISSING(GPIORF) -#endif - -#ifdef GPIO_GPIO0 - DEFINE(GPIO_GPIO0) -#else - MISSING(GPIO_GPIO0) -#endif - -#ifdef GPIO_GPIO1 - DEFINE(GPIO_GPIO1) -#else - MISSING(GPIO_GPIO1) -#endif - -#ifdef GPIO_GPIO2 - DEFINE(GPIO_GPIO2) -#else - MISSING(GPIO_GPIO2) -#endif - -#ifdef GPIO_GPIO3 - DEFINE(GPIO_GPIO3) -#else - MISSING(GPIO_GPIO3) -#endif - -#ifdef GPIO_GPIO4 - DEFINE(GPIO_GPIO4) -#else - MISSING(GPIO_GPIO4) -#endif - -#ifdef GPIO_GPIO5 - DEFINE(GPIO_GPIO5) -#else - MISSING(GPIO_GPIO5) -#endif - -#ifdef GPIO_GPIO6 - DEFINE(GPIO_GPIO6) -#else - MISSING(GPIO_GPIO6) -#endif - -#ifdef GPIO_GPIO7 - DEFINE(GPIO_GPIO7) -#else - MISSING(GPIO_GPIO7) -#endif - -#ifdef GPIO_GPIO8 - DEFINE(GPIO_GPIO8) -#else - MISSING(GPIO_GPIO8) -#endif - -#ifdef GPIO_GPIO9 - DEFINE(GPIO_GPIO9) -#else - MISSING(GPIO_GPIO9) -#endif - -#ifdef GPIO_GPIOA - DEFINE(GPIO_GPIOA) -#else - MISSING(GPIO_GPIOA) -#endif - -#ifdef GPIO_GPIOB - DEFINE(GPIO_GPIOB) -#else - MISSING(GPIO_GPIOB) -#endif - -#ifdef GPIO_GPIOC - DEFINE(GPIO_GPIOC) -#else - MISSING(GPIO_GPIOC) -#endif - -#ifdef GPIO_GPIOD - DEFINE(GPIO_GPIOD) -#else - MISSING(GPIO_GPIOD) -#endif - -#ifdef GPIO_GPIOE - DEFINE(GPIO_GPIOE) -#else - MISSING(GPIO_GPIOE) -#endif - -#ifdef GPIO_GPIOF - DEFINE(GPIO_GPIOF) -#else - MISSING(GPIO_GPIOF) -#endif - -#ifdef GPIO_GPIOR0 - DEFINE(GPIO_GPIOR0) -#else - MISSING(GPIO_GPIOR0) -#endif - -#ifdef GPIO_GPIOR1 - DEFINE(GPIO_GPIOR1) -#else - MISSING(GPIO_GPIOR1) -#endif - -#ifdef GPIO_GPIOR2 - DEFINE(GPIO_GPIOR2) -#else - MISSING(GPIO_GPIOR2) -#endif - -#ifdef GPIO_GPIOR3 - DEFINE(GPIO_GPIOR3) -#else - MISSING(GPIO_GPIOR3) -#endif - -#ifdef GPIO_GPIOR4 - DEFINE(GPIO_GPIOR4) -#else - MISSING(GPIO_GPIOR4) -#endif - -#ifdef GPIO_GPIOR5 - DEFINE(GPIO_GPIOR5) -#else - MISSING(GPIO_GPIOR5) -#endif - -#ifdef GPIO_GPIOR6 - DEFINE(GPIO_GPIOR6) -#else - MISSING(GPIO_GPIOR6) -#endif - -#ifdef GPIO_GPIOR7 - DEFINE(GPIO_GPIOR7) -#else - MISSING(GPIO_GPIOR7) -#endif - -#ifdef GPIO_GPIOR8 - DEFINE(GPIO_GPIOR8) -#else - MISSING(GPIO_GPIOR8) -#endif - -#ifdef GPIO_GPIOR9 - DEFINE(GPIO_GPIOR9) -#else - MISSING(GPIO_GPIOR9) -#endif - -#ifdef GPIO_GPIORA - DEFINE(GPIO_GPIORA) -#else - MISSING(GPIO_GPIORA) -#endif - -#ifdef GPIO_GPIORB - DEFINE(GPIO_GPIORB) -#else - MISSING(GPIO_GPIORB) -#endif - -#ifdef GPIO_GPIORC - DEFINE(GPIO_GPIORC) -#else - MISSING(GPIO_GPIORC) -#endif - -#ifdef GPIO_GPIORD - DEFINE(GPIO_GPIORD) -#else - MISSING(GPIO_GPIORD) -#endif - -#ifdef GPIO_GPIORE - DEFINE(GPIO_GPIORE) -#else - MISSING(GPIO_GPIORE) -#endif - -#ifdef GPIO_GPIORF - DEFINE(GPIO_GPIORF) -#else - MISSING(GPIO_GPIORF) -#endif - -#ifdef GTCCR - DEFINE(GTCCR) -#else - MISSING(GTCCR) -#endif - -#ifdef HIRESC_CTRLA - DEFINE(HIRESC_CTRLA) -#else - MISSING(HIRESC_CTRLA) -#endif - -#ifdef HIRESD_CTRLA - DEFINE(HIRESD_CTRLA) -#else - MISSING(HIRESD_CTRLA) -#endif - -#ifdef HIRESE_CTRLA - DEFINE(HIRESE_CTRLA) -#else - MISSING(HIRESE_CTRLA) -#endif - -#ifdef HIRESF_CTRLA - DEFINE(HIRESF_CTRLA) -#else - MISSING(HIRESF_CTRLA) -#endif - -#ifdef HSSPICFG - DEFINE(HSSPICFG) -#else - MISSING(HSSPICFG) -#endif - -#ifdef HSSPICNT - DEFINE(HSSPICNT) -#else - MISSING(HSSPICNT) -#endif - -#ifdef HSSPICR - DEFINE(HSSPICR) -#else - MISSING(HSSPICR) -#endif - -#ifdef HSSPIDMAB - DEFINE(HSSPIDMAB) -#else - MISSING(HSSPIDMAB) -#endif - -#ifdef HSSPIDMACS - DEFINE(HSSPIDMACS) -#else - MISSING(HSSPIDMACS) -#endif - -#ifdef HSSPIDMAD - DEFINE(HSSPIDMAD) -#else - MISSING(HSSPIDMAD) -#endif - -#ifdef HSSPIDMADH - DEFINE(HSSPIDMADH) -#else - MISSING(HSSPIDMADH) -#endif - -#ifdef HSSPIDMADL - DEFINE(HSSPIDMADL) -#else - MISSING(HSSPIDMADL) -#endif - -#ifdef HSSPIGTR - DEFINE(HSSPIGTR) -#else - MISSING(HSSPIGTR) -#endif - -#ifdef HSSPIIER - DEFINE(HSSPIIER) -#else - MISSING(HSSPIIER) -#endif - -#ifdef HSSPIIR - DEFINE(HSSPIIR) -#else - MISSING(HSSPIIR) -#endif - -#ifdef HSSPIRDR - DEFINE(HSSPIRDR) -#else - MISSING(HSSPIRDR) -#endif - -#ifdef HSSPISR - DEFINE(HSSPISR) -#else - MISSING(HSSPISR) -#endif - -#ifdef HSSPITDR - DEFINE(HSSPITDR) -#else - MISSING(HSSPITDR) -#endif - -#ifdef HSSPITO - DEFINE(HSSPITO) -#else - MISSING(HSSPITO) -#endif - -#ifdef HSSPITOH - DEFINE(HSSPITOH) -#else - MISSING(HSSPITOH) -#endif - -#ifdef HSSPITOL - DEFINE(HSSPITOL) -#else - MISSING(HSSPITOL) -#endif - -#ifdef ICR - DEFINE(ICR) -#else - MISSING(ICR) -#endif - -#ifdef ICR0 - DEFINE(ICR0) -#else - MISSING(ICR0) -#endif - -#ifdef ICR0H - DEFINE(ICR0H) -#else - MISSING(ICR0H) -#endif - -#ifdef ICR0L - DEFINE(ICR0L) -#else - MISSING(ICR0L) -#endif - -#ifdef ICR1 - DEFINE(ICR1) -#else - MISSING(ICR1) -#endif - -#ifdef ICR1H - DEFINE(ICR1H) -#else - MISSING(ICR1H) -#endif - -#ifdef ICR1L - DEFINE(ICR1L) -#else - MISSING(ICR1L) -#endif - -#ifdef ICR3 - DEFINE(ICR3) -#else - MISSING(ICR3) -#endif - -#ifdef ICR3H - DEFINE(ICR3H) -#else - MISSING(ICR3H) -#endif - -#ifdef ICR3L - DEFINE(ICR3L) -#else - MISSING(ICR3L) -#endif - -#ifdef ICR4 - DEFINE(ICR4) -#else - MISSING(ICR4) -#endif - -#ifdef ICR4H - DEFINE(ICR4H) -#else - MISSING(ICR4H) -#endif - -#ifdef ICR4L - DEFINE(ICR4L) -#else - MISSING(ICR4L) -#endif - -#ifdef ICR5 - DEFINE(ICR5) -#else - MISSING(ICR5) -#endif - -#ifdef ICR5H - DEFINE(ICR5H) -#else - MISSING(ICR5H) -#endif - -#ifdef ICR5L - DEFINE(ICR5L) -#else - MISSING(ICR5L) -#endif - -#ifdef IDXCTRL - DEFINE(IDXCTRL) -#else - MISSING(IDXCTRL) -#endif - -#ifdef IDXIFLG - DEFINE(IDXIFLG) -#else - MISSING(IDXIFLG) -#endif - -#ifdef IDXIMSK - DEFINE(IDXIMSK) -#else - MISSING(IDXIMSK) -#endif - -#ifdef IDXMSDT - DEFINE(IDXMSDT) -#else - MISSING(IDXMSDT) -#endif - -#ifdef IDXSTRB - DEFINE(IDXSTRB) -#else - MISSING(IDXSTRB) -#endif - -#ifdef IEEE_ADDR_0 - DEFINE(IEEE_ADDR_0) -#else - MISSING(IEEE_ADDR_0) -#endif - -#ifdef IEEE_ADDR_1 - DEFINE(IEEE_ADDR_1) -#else - MISSING(IEEE_ADDR_1) -#endif - -#ifdef IEEE_ADDR_2 - DEFINE(IEEE_ADDR_2) -#else - MISSING(IEEE_ADDR_2) -#endif - -#ifdef IEEE_ADDR_3 - DEFINE(IEEE_ADDR_3) -#else - MISSING(IEEE_ADDR_3) -#endif - -#ifdef IEEE_ADDR_4 - DEFINE(IEEE_ADDR_4) -#else - MISSING(IEEE_ADDR_4) -#endif - -#ifdef IEEE_ADDR_5 - DEFINE(IEEE_ADDR_5) -#else - MISSING(IEEE_ADDR_5) -#endif - -#ifdef IEEE_ADDR_6 - DEFINE(IEEE_ADDR_6) -#else - MISSING(IEEE_ADDR_6) -#endif - -#ifdef IEEE_ADDR_7 - DEFINE(IEEE_ADDR_7) -#else - MISSING(IEEE_ADDR_7) -#endif - -#ifdef IFR - DEFINE(IFR) -#else - MISSING(IFR) -#endif - -#ifdef INOCR1A - DEFINE(INOCR1A) -#else - MISSING(INOCR1A) -#endif - -#ifdef INOCR1AH - DEFINE(INOCR1AH) -#else - MISSING(INOCR1AH) -#endif - -#ifdef INOCR1AL - DEFINE(INOCR1AL) -#else - MISSING(INOCR1AL) -#endif - -#ifdef INOCR1B - DEFINE(INOCR1B) -#else - MISSING(INOCR1B) -#endif - -#ifdef INOCR1BH - DEFINE(INOCR1BH) -#else - MISSING(INOCR1BH) -#endif - -#ifdef INOCR1BL - DEFINE(INOCR1BL) -#else - MISSING(INOCR1BL) -#endif - -#ifdef INTCCR0 - DEFINE(INTCCR0) -#else - MISSING(INTCCR0) -#endif - -#ifdef INTCCR1A - DEFINE(INTCCR1A) -#else - MISSING(INTCCR1A) -#endif - -#ifdef INTCCR1B - DEFINE(INTCCR1B) -#else - MISSING(INTCCR1B) -#endif - -#ifdef INTCNT - DEFINE(INTCNT) -#else - MISSING(INTCNT) -#endif - -#ifdef INTCNT1 - DEFINE(INTCNT1) -#else - MISSING(INTCNT1) -#endif - -#ifdef INTCNT1H - DEFINE(INTCNT1H) -#else - MISSING(INTCNT1H) -#endif - -#ifdef INTCNT1L - DEFINE(INTCNT1L) -#else - MISSING(INTCNT1L) -#endif - -#ifdef INTIFR - DEFINE(INTIFR) -#else - MISSING(INTIFR) -#endif - -#ifdef INTIMSK - DEFINE(INTIMSK) -#else - MISSING(INTIMSK) -#endif - -#ifdef IOF - DEFINE(IOF) -#else - MISSING(IOF) -#endif - -#ifdef IO_DATIN - DEFINE(IO_DATIN) -#else - MISSING(IO_DATIN) -#endif - -#ifdef IO_DATOUT - DEFINE(IO_DATOUT) -#else - MISSING(IO_DATOUT) -#endif - -#ifdef IO_ENAB - DEFINE(IO_ENAB) -#else - MISSING(IO_ENAB) -#endif - -#ifdef IPA - DEFINE(IPA) -#else - MISSING(IPA) -#endif - -#ifdef IPAH - DEFINE(IPAH) -#else - MISSING(IPAH) -#endif - -#ifdef IPAL - DEFINE(IPAL) -#else - MISSING(IPAL) -#endif - -#ifdef IPCR - DEFINE(IPCR) -#else - MISSING(IPCR) -#endif - -#ifdef IPD - DEFINE(IPD) -#else - MISSING(IPD) -#endif - -#ifdef IPDH - DEFINE(IPDH) -#else - MISSING(IPDH) -#endif - -#ifdef IPDL - DEFINE(IPDL) -#else - MISSING(IPDL) -#endif - -#ifdef IRCOM_CTRL - DEFINE(IRCOM_CTRL) -#else - MISSING(IRCOM_CTRL) -#endif - -#ifdef IRCOM_RXPLCTRL - DEFINE(IRCOM_RXPLCTRL) -#else - MISSING(IRCOM_RXPLCTRL) -#endif - -#ifdef IRCOM_TXPLCTRL - DEFINE(IRCOM_TXPLCTRL) -#else - MISSING(IRCOM_TXPLCTRL) -#endif - -#ifdef IRDAMOD - DEFINE(IRDAMOD) -#else - MISSING(IRDAMOD) -#endif - -#ifdef IRQ_MASK - DEFINE(IRQ_MASK) -#else - MISSING(IRQ_MASK) -#endif - -#ifdef IRQ_STATUS - DEFINE(IRQ_STATUS) -#else - MISSING(IRQ_STATUS) -#endif - -#ifdef KBER - DEFINE(KBER) -#else - MISSING(KBER) -#endif - -#ifdef KBFR - DEFINE(KBFR) -#else - MISSING(KBFR) -#endif - -#ifdef KBLSR - DEFINE(KBLSR) -#else - MISSING(KBLSR) -#endif - -#ifdef LCDCCR - DEFINE(LCDCCR) -#else - MISSING(LCDCCR) -#endif - -#ifdef LCDCRA - DEFINE(LCDCRA) -#else - MISSING(LCDCRA) -#endif - -#ifdef LCDCRB - DEFINE(LCDCRB) -#else - MISSING(LCDCRB) -#endif - -#ifdef LCDDR0 - DEFINE(LCDDR0) -#else - MISSING(LCDDR0) -#endif - -#ifdef LCDDR00 - DEFINE(LCDDR00) -#else - MISSING(LCDDR00) -#endif - -#ifdef LCDDR01 - DEFINE(LCDDR01) -#else - MISSING(LCDDR01) -#endif - -#ifdef LCDDR02 - DEFINE(LCDDR02) -#else - MISSING(LCDDR02) -#endif - -#ifdef LCDDR03 - DEFINE(LCDDR03) -#else - MISSING(LCDDR03) -#endif - -#ifdef LCDDR04 - DEFINE(LCDDR04) -#else - MISSING(LCDDR04) -#endif - -#ifdef LCDDR05 - DEFINE(LCDDR05) -#else - MISSING(LCDDR05) -#endif - -#ifdef LCDDR06 - DEFINE(LCDDR06) -#else - MISSING(LCDDR06) -#endif - -#ifdef LCDDR07 - DEFINE(LCDDR07) -#else - MISSING(LCDDR07) -#endif - -#ifdef LCDDR08 - DEFINE(LCDDR08) -#else - MISSING(LCDDR08) -#endif - -#ifdef LCDDR09 - DEFINE(LCDDR09) -#else - MISSING(LCDDR09) -#endif - -#ifdef LCDDR1 - DEFINE(LCDDR1) -#else - MISSING(LCDDR1) -#endif - -#ifdef LCDDR10 - DEFINE(LCDDR10) -#else - MISSING(LCDDR10) -#endif - -#ifdef LCDDR11 - DEFINE(LCDDR11) -#else - MISSING(LCDDR11) -#endif - -#ifdef LCDDR12 - DEFINE(LCDDR12) -#else - MISSING(LCDDR12) -#endif - -#ifdef LCDDR13 - DEFINE(LCDDR13) -#else - MISSING(LCDDR13) -#endif - -#ifdef LCDDR14 - DEFINE(LCDDR14) -#else - MISSING(LCDDR14) -#endif - -#ifdef LCDDR15 - DEFINE(LCDDR15) -#else - MISSING(LCDDR15) -#endif - -#ifdef LCDDR16 - DEFINE(LCDDR16) -#else - MISSING(LCDDR16) -#endif - -#ifdef LCDDR17 - DEFINE(LCDDR17) -#else - MISSING(LCDDR17) -#endif - -#ifdef LCDDR18 - DEFINE(LCDDR18) -#else - MISSING(LCDDR18) -#endif - -#ifdef LCDDR19 - DEFINE(LCDDR19) -#else - MISSING(LCDDR19) -#endif - -#ifdef LCDDR2 - DEFINE(LCDDR2) -#else - MISSING(LCDDR2) -#endif - -#ifdef LCDDR3 - DEFINE(LCDDR3) -#else - MISSING(LCDDR3) -#endif - -#ifdef LCDDR4 - DEFINE(LCDDR4) -#else - MISSING(LCDDR4) -#endif - -#ifdef LCDDR5 - DEFINE(LCDDR5) -#else - MISSING(LCDDR5) -#endif - -#ifdef LCDDR6 - DEFINE(LCDDR6) -#else - MISSING(LCDDR6) -#endif - -#ifdef LCDDR7 - DEFINE(LCDDR7) -#else - MISSING(LCDDR7) -#endif - -#ifdef LCDDR8 - DEFINE(LCDDR8) -#else - MISSING(LCDDR8) -#endif - -#ifdef LCDDR9 - DEFINE(LCDDR9) -#else - MISSING(LCDDR9) -#endif - -#ifdef LCDFRR - DEFINE(LCDFRR) -#else - MISSING(LCDFRR) -#endif - -#ifdef LEDCR - DEFINE(LEDCR) -#else - MISSING(LEDCR) -#endif - -#ifdef LFCAL - DEFINE(LFCAL) -#else - MISSING(LFCAL) -#endif - -#ifdef LFCALH - DEFINE(LFCALH) -#else - MISSING(LFCALH) -#endif - -#ifdef LFCALL - DEFINE(LFCALL) -#else - MISSING(LFCALL) -#endif - -#ifdef LFCDR - DEFINE(LFCDR) -#else - MISSING(LFCDR) -#endif - -#ifdef LFFR - DEFINE(LFFR) -#else - MISSING(LFFR) -#endif - -#ifdef LFHCR - DEFINE(LFHCR) -#else - MISSING(LFHCR) -#endif - -#ifdef LFIDC - DEFINE(LFIDC) -#else - MISSING(LFIDC) -#endif - -#ifdef LFIDCH - DEFINE(LFIDCH) -#else - MISSING(LFIDCH) -#endif - -#ifdef LFIDCL - DEFINE(LFIDCL) -#else - MISSING(LFIDCL) -#endif - -#ifdef LFIMR - DEFINE(LFIMR) -#else - MISSING(LFIMR) -#endif - -#ifdef LFRB - DEFINE(LFRB) -#else - MISSING(LFRB) -#endif - -#ifdef LFRCR - DEFINE(LFRCR) -#else - MISSING(LFRCR) -#endif - -#ifdef LFRR - DEFINE(LFRR) -#else - MISSING(LFRR) -#endif - -#ifdef LFSR0 - DEFINE(LFSR0) -#else - MISSING(LFSR0) -#endif - -#ifdef LFSR1 - DEFINE(LFSR1) -#else - MISSING(LFSR1) -#endif - -#ifdef LFSR2 - DEFINE(LFSR2) -#else - MISSING(LFSR2) -#endif - -#ifdef LFSR3 - DEFINE(LFSR3) -#else - MISSING(LFSR3) -#endif - -#ifdef LINBRR - DEFINE(LINBRR) -#else - MISSING(LINBRR) -#endif - -#ifdef LINBRRH - DEFINE(LINBRRH) -#else - MISSING(LINBRRH) -#endif - -#ifdef LINBRRL - DEFINE(LINBRRL) -#else - MISSING(LINBRRL) -#endif - -#ifdef LINBTR - DEFINE(LINBTR) -#else - MISSING(LINBTR) -#endif - -#ifdef LINCR - DEFINE(LINCR) -#else - MISSING(LINCR) -#endif - -#ifdef LINDAT - DEFINE(LINDAT) -#else - MISSING(LINDAT) -#endif - -#ifdef LINDLR - DEFINE(LINDLR) -#else - MISSING(LINDLR) -#endif - -#ifdef LINENIR - DEFINE(LINENIR) -#else - MISSING(LINENIR) -#endif - -#ifdef LINERR - DEFINE(LINERR) -#else - MISSING(LINERR) -#endif - -#ifdef LINIDR - DEFINE(LINIDR) -#else - MISSING(LINIDR) -#endif - -#ifdef LINSEL - DEFINE(LINSEL) -#else - MISSING(LINSEL) -#endif - -#ifdef LINSIR - DEFINE(LINSIR) -#else - MISSING(LINSIR) -#endif - -#ifdef LLCR - DEFINE(LLCR) -#else - MISSING(LLCR) -#endif - -#ifdef LLDRH - DEFINE(LLDRH) -#else - MISSING(LLDRH) -#endif - -#ifdef LLDRL - DEFINE(LLDRL) -#else - MISSING(LLDRL) -#endif - -#ifdef LOCKDET1 - DEFINE(LOCKDET1) -#else - MISSING(LOCKDET1) -#endif - -#ifdef LOCKDET2 - DEFINE(LOCKDET2) -#else - MISSING(LOCKDET2) -#endif - -#ifdef MAN_ID_0 - DEFINE(MAN_ID_0) -#else - MISSING(MAN_ID_0) -#endif - -#ifdef MAN_ID_1 - DEFINE(MAN_ID_1) -#else - MISSING(MAN_ID_1) -#endif - -#ifdef MCSR - DEFINE(MCSR) -#else - MISSING(MCSR) -#endif - -#ifdef MCUCR - DEFINE(MCUCR) -#else - MISSING(MCUCR) -#endif - -#ifdef MCUCS - DEFINE(MCUCS) -#else - MISSING(MCUCS) -#endif - -#ifdef MCUCSR - DEFINE(MCUCSR) -#else - MISSING(MCUCSR) -#endif - -#ifdef MCUR - DEFINE(MCUR) -#else - MISSING(MCUR) -#endif - -#ifdef MCUSR - DEFINE(MCUSR) -#else - MISSING(MCUSR) -#endif - -#ifdef MCU_ANAINIT - DEFINE(MCU_ANAINIT) -#else - MISSING(MCU_ANAINIT) -#endif - -#ifdef MCU_AWEXLOCK - DEFINE(MCU_AWEXLOCK) -#else - MISSING(MCU_AWEXLOCK) -#endif - -#ifdef MCU_DEVID0 - DEFINE(MCU_DEVID0) -#else - MISSING(MCU_DEVID0) -#endif - -#ifdef MCU_DEVID1 - DEFINE(MCU_DEVID1) -#else - MISSING(MCU_DEVID1) -#endif - -#ifdef MCU_DEVID2 - DEFINE(MCU_DEVID2) -#else - MISSING(MCU_DEVID2) -#endif - -#ifdef MCU_EVSYSLOCK - DEFINE(MCU_EVSYSLOCK) -#else - MISSING(MCU_EVSYSLOCK) -#endif - -#ifdef MCU_JTAGUID - DEFINE(MCU_JTAGUID) -#else - MISSING(MCU_JTAGUID) -#endif - -#ifdef MCU_MCUCR - DEFINE(MCU_MCUCR) -#else - MISSING(MCU_MCUCR) -#endif - -#ifdef MCU_REVID - DEFINE(MCU_REVID) -#else - MISSING(MCU_REVID) -#endif - -#ifdef MODCR - DEFINE(MODCR) -#else - MISSING(MODCR) -#endif - -#ifdef MONDR - DEFINE(MONDR) -#else - MISSING(MONDR) -#endif - -#ifdef MSELR - DEFINE(MSELR) -#else - MISSING(MSELR) -#endif - -#ifdef MSMCR - DEFINE(MSMCR) -#else - MISSING(MSMCR) -#endif - -#ifdef MSPCR - DEFINE(MSPCR) -#else - MISSING(MSPCR) -#endif - -#ifdef MSPDR - DEFINE(MSPDR) -#else - MISSING(MSPDR) -#endif - -#ifdef MSPSR - DEFINE(MSPSR) -#else - MISSING(MSPSR) -#endif - -#ifdef MSVCAL - DEFINE(MSVCAL) -#else - MISSING(MSVCAL) -#endif - -#ifdef MUBRR - DEFINE(MUBRR) -#else - MISSING(MUBRR) -#endif - -#ifdef MUBRRH - DEFINE(MUBRRH) -#else - MISSING(MUBRRH) -#endif - -#ifdef MUBRRL - DEFINE(MUBRRL) -#else - MISSING(MUBRRL) -#endif - -#ifdef NEMCR - DEFINE(NEMCR) -#else - MISSING(NEMCR) -#endif - -#ifdef NVMCMD - DEFINE(NVMCMD) -#else - MISSING(NVMCMD) -#endif - -#ifdef NVMCSR - DEFINE(NVMCSR) -#else - MISSING(NVMCSR) -#endif - -#ifdef NVM_ADDR0 - DEFINE(NVM_ADDR0) -#else - MISSING(NVM_ADDR0) -#endif - -#ifdef NVM_ADDR1 - DEFINE(NVM_ADDR1) -#else - MISSING(NVM_ADDR1) -#endif - -#ifdef NVM_ADDR2 - DEFINE(NVM_ADDR2) -#else - MISSING(NVM_ADDR2) -#endif - -#ifdef NVM_CMD - DEFINE(NVM_CMD) -#else - MISSING(NVM_CMD) -#endif - -#ifdef NVM_CTRLA - DEFINE(NVM_CTRLA) -#else - MISSING(NVM_CTRLA) -#endif - -#ifdef NVM_CTRLB - DEFINE(NVM_CTRLB) -#else - MISSING(NVM_CTRLB) -#endif - -#ifdef NVM_DATA0 - DEFINE(NVM_DATA0) -#else - MISSING(NVM_DATA0) -#endif - -#ifdef NVM_DATA1 - DEFINE(NVM_DATA1) -#else - MISSING(NVM_DATA1) -#endif - -#ifdef NVM_DATA2 - DEFINE(NVM_DATA2) -#else - MISSING(NVM_DATA2) -#endif - -#ifdef NVM_INTCTRL - DEFINE(NVM_INTCTRL) -#else - MISSING(NVM_INTCTRL) -#endif - -#ifdef NVM_LOCKBITS - DEFINE(NVM_LOCKBITS) -#else - MISSING(NVM_LOCKBITS) -#endif - -#ifdef NVM_STATUS - DEFINE(NVM_STATUS) -#else - MISSING(NVM_STATUS) -#endif - -#ifdef OCDR - DEFINE(OCDR) -#else - MISSING(OCDR) -#endif - -#ifdef OCD_OCDR0 - DEFINE(OCD_OCDR0) -#else - MISSING(OCD_OCDR0) -#endif - -#ifdef OCD_OCDR1 - DEFINE(OCD_OCDR1) -#else - MISSING(OCD_OCDR1) -#endif - -#ifdef OCR0 - DEFINE(OCR0) -#else - MISSING(OCR0) -#endif - -#ifdef OCR0A - DEFINE(OCR0A) -#else - MISSING(OCR0A) -#endif - -#ifdef OCR0AH - DEFINE(OCR0AH) -#else - MISSING(OCR0AH) -#endif - -#ifdef OCR0AL - DEFINE(OCR0AL) -#else - MISSING(OCR0AL) -#endif - -#ifdef OCR0B - DEFINE(OCR0B) -#else - MISSING(OCR0B) -#endif - -#ifdef OCR0BH - DEFINE(OCR0BH) -#else - MISSING(OCR0BH) -#endif - -#ifdef OCR0BL - DEFINE(OCR0BL) -#else - MISSING(OCR0BL) -#endif - -#ifdef OCR0RA - DEFINE(OCR0RA) -#else - MISSING(OCR0RA) -#endif - -#ifdef OCR0RAH - DEFINE(OCR0RAH) -#else - MISSING(OCR0RAH) -#endif - -#ifdef OCR0RAL - DEFINE(OCR0RAL) -#else - MISSING(OCR0RAL) -#endif - -#ifdef OCR0RB - DEFINE(OCR0RB) -#else - MISSING(OCR0RB) -#endif - -#ifdef OCR0RBH - DEFINE(OCR0RBH) -#else - MISSING(OCR0RBH) -#endif - -#ifdef OCR0RBL - DEFINE(OCR0RBL) -#else - MISSING(OCR0RBL) -#endif - -#ifdef OCR0SA - DEFINE(OCR0SA) -#else - MISSING(OCR0SA) -#endif - -#ifdef OCR0SAH - DEFINE(OCR0SAH) -#else - MISSING(OCR0SAH) -#endif - -#ifdef OCR0SAL - DEFINE(OCR0SAL) -#else - MISSING(OCR0SAL) -#endif - -#ifdef OCR0SB - DEFINE(OCR0SB) -#else - MISSING(OCR0SB) -#endif - -#ifdef OCR0SBH - DEFINE(OCR0SBH) -#else - MISSING(OCR0SBH) -#endif - -#ifdef OCR0SBL - DEFINE(OCR0SBL) -#else - MISSING(OCR0SBL) -#endif - -#ifdef OCR1 - DEFINE(OCR1) -#else - MISSING(OCR1) -#endif - -#ifdef OCR1A - DEFINE(OCR1A) -#else - MISSING(OCR1A) -#endif - -#ifdef OCR1AH - DEFINE(OCR1AH) -#else - MISSING(OCR1AH) -#endif - -#ifdef OCR1AL - DEFINE(OCR1AL) -#else - MISSING(OCR1AL) -#endif - -#ifdef OCR1B - DEFINE(OCR1B) -#else - MISSING(OCR1B) -#endif - -#ifdef OCR1BH - DEFINE(OCR1BH) -#else - MISSING(OCR1BH) -#endif - -#ifdef OCR1BL - DEFINE(OCR1BL) -#else - MISSING(OCR1BL) -#endif - -#ifdef OCR1C - DEFINE(OCR1C) -#else - MISSING(OCR1C) -#endif - -#ifdef OCR1CH - DEFINE(OCR1CH) -#else - MISSING(OCR1CH) -#endif - -#ifdef OCR1CL - DEFINE(OCR1CL) -#else - MISSING(OCR1CL) -#endif - -#ifdef OCR1D - DEFINE(OCR1D) -#else - MISSING(OCR1D) -#endif - -#ifdef OCR1H - DEFINE(OCR1H) -#else - MISSING(OCR1H) -#endif - -#ifdef OCR1L - DEFINE(OCR1L) -#else - MISSING(OCR1L) -#endif - -#ifdef OCR1RA - DEFINE(OCR1RA) -#else - MISSING(OCR1RA) -#endif - -#ifdef OCR1RAH - DEFINE(OCR1RAH) -#else - MISSING(OCR1RAH) -#endif - -#ifdef OCR1RAL - DEFINE(OCR1RAL) -#else - MISSING(OCR1RAL) -#endif - -#ifdef OCR1RB - DEFINE(OCR1RB) -#else - MISSING(OCR1RB) -#endif - -#ifdef OCR1RBH - DEFINE(OCR1RBH) -#else - MISSING(OCR1RBH) -#endif - -#ifdef OCR1RBL - DEFINE(OCR1RBL) -#else - MISSING(OCR1RBL) -#endif - -#ifdef OCR1SA - DEFINE(OCR1SA) -#else - MISSING(OCR1SA) -#endif - -#ifdef OCR1SAH - DEFINE(OCR1SAH) -#else - MISSING(OCR1SAH) -#endif - -#ifdef OCR1SAL - DEFINE(OCR1SAL) -#else - MISSING(OCR1SAL) -#endif - -#ifdef OCR1SB - DEFINE(OCR1SB) -#else - MISSING(OCR1SB) -#endif - -#ifdef OCR1SBH - DEFINE(OCR1SBH) -#else - MISSING(OCR1SBH) -#endif - -#ifdef OCR1SBL - DEFINE(OCR1SBL) -#else - MISSING(OCR1SBL) -#endif - -#ifdef OCR2 - DEFINE(OCR2) -#else - MISSING(OCR2) -#endif - -#ifdef OCR2A - DEFINE(OCR2A) -#else - MISSING(OCR2A) -#endif - -#ifdef OCR2B - DEFINE(OCR2B) -#else - MISSING(OCR2B) -#endif - -#ifdef OCR2RA - DEFINE(OCR2RA) -#else - MISSING(OCR2RA) -#endif - -#ifdef OCR2RAH - DEFINE(OCR2RAH) -#else - MISSING(OCR2RAH) -#endif - -#ifdef OCR2RAL - DEFINE(OCR2RAL) -#else - MISSING(OCR2RAL) -#endif - -#ifdef OCR2RB - DEFINE(OCR2RB) -#else - MISSING(OCR2RB) -#endif - -#ifdef OCR2RBH - DEFINE(OCR2RBH) -#else - MISSING(OCR2RBH) -#endif - -#ifdef OCR2RBL - DEFINE(OCR2RBL) -#else - MISSING(OCR2RBL) -#endif - -#ifdef OCR2SA - DEFINE(OCR2SA) -#else - MISSING(OCR2SA) -#endif - -#ifdef OCR2SAH - DEFINE(OCR2SAH) -#else - MISSING(OCR2SAH) -#endif - -#ifdef OCR2SAL - DEFINE(OCR2SAL) -#else - MISSING(OCR2SAL) -#endif - -#ifdef OCR2SB - DEFINE(OCR2SB) -#else - MISSING(OCR2SB) -#endif - -#ifdef OCR2SBH - DEFINE(OCR2SBH) -#else - MISSING(OCR2SBH) -#endif - -#ifdef OCR2SBL - DEFINE(OCR2SBL) -#else - MISSING(OCR2SBL) -#endif - -#ifdef OCR3A - DEFINE(OCR3A) -#else - MISSING(OCR3A) -#endif - -#ifdef OCR3AH - DEFINE(OCR3AH) -#else - MISSING(OCR3AH) -#endif - -#ifdef OCR3AL - DEFINE(OCR3AL) -#else - MISSING(OCR3AL) -#endif - -#ifdef OCR3B - DEFINE(OCR3B) -#else - MISSING(OCR3B) -#endif - -#ifdef OCR3BH - DEFINE(OCR3BH) -#else - MISSING(OCR3BH) -#endif - -#ifdef OCR3BL - DEFINE(OCR3BL) -#else - MISSING(OCR3BL) -#endif - -#ifdef OCR3C - DEFINE(OCR3C) -#else - MISSING(OCR3C) -#endif - -#ifdef OCR3CH - DEFINE(OCR3CH) -#else - MISSING(OCR3CH) -#endif - -#ifdef OCR3CL - DEFINE(OCR3CL) -#else - MISSING(OCR3CL) -#endif - -#ifdef OCR4A - DEFINE(OCR4A) -#else - MISSING(OCR4A) -#endif - -#ifdef OCR4AH - DEFINE(OCR4AH) -#else - MISSING(OCR4AH) -#endif - -#ifdef OCR4AL - DEFINE(OCR4AL) -#else - MISSING(OCR4AL) -#endif - -#ifdef OCR4B - DEFINE(OCR4B) -#else - MISSING(OCR4B) -#endif - -#ifdef OCR4BH - DEFINE(OCR4BH) -#else - MISSING(OCR4BH) -#endif - -#ifdef OCR4BL - DEFINE(OCR4BL) -#else - MISSING(OCR4BL) -#endif - -#ifdef OCR4C - DEFINE(OCR4C) -#else - MISSING(OCR4C) -#endif - -#ifdef OCR4CH - DEFINE(OCR4CH) -#else - MISSING(OCR4CH) -#endif - -#ifdef OCR4CL - DEFINE(OCR4CL) -#else - MISSING(OCR4CL) -#endif - -#ifdef OCR4D - DEFINE(OCR4D) -#else - MISSING(OCR4D) -#endif - -#ifdef OCR5A - DEFINE(OCR5A) -#else - MISSING(OCR5A) -#endif - -#ifdef OCR5AH - DEFINE(OCR5AH) -#else - MISSING(OCR5AH) -#endif - -#ifdef OCR5AL - DEFINE(OCR5AL) -#else - MISSING(OCR5AL) -#endif - -#ifdef OCR5B - DEFINE(OCR5B) -#else - MISSING(OCR5B) -#endif - -#ifdef OCR5BH - DEFINE(OCR5BH) -#else - MISSING(OCR5BH) -#endif - -#ifdef OCR5BL - DEFINE(OCR5BL) -#else - MISSING(OCR5BL) -#endif - -#ifdef OCR5C - DEFINE(OCR5C) -#else - MISSING(OCR5C) -#endif - -#ifdef OCR5CH - DEFINE(OCR5CH) -#else - MISSING(OCR5CH) -#endif - -#ifdef OCR5CL - DEFINE(OCR5CL) -#else - MISSING(OCR5CL) -#endif - -#ifdef OCRA1 - DEFINE(OCRA1) -#else - MISSING(OCRA1) -#endif - -#ifdef OCRA1H - DEFINE(OCRA1H) -#else - MISSING(OCRA1H) -#endif - -#ifdef OCRA1L - DEFINE(OCRA1L) -#else - MISSING(OCRA1L) -#endif - -#ifdef OCRB1 - DEFINE(OCRB1) -#else - MISSING(OCRB1) -#endif - -#ifdef OCRB1H - DEFINE(OCRB1H) -#else - MISSING(OCRB1H) -#endif - -#ifdef OCRB1L - DEFINE(OCRB1L) -#else - MISSING(OCRB1L) -#endif - -#ifdef OSCCAL - DEFINE(OSCCAL) -#else - MISSING(OSCCAL) -#endif - -#ifdef OSC_CTRL - DEFINE(OSC_CTRL) -#else - MISSING(OSC_CTRL) -#endif - -#ifdef OSC_DFLLCTRL - DEFINE(OSC_DFLLCTRL) -#else - MISSING(OSC_DFLLCTRL) -#endif - -#ifdef OSC_PLLCTRL - DEFINE(OSC_PLLCTRL) -#else - MISSING(OSC_PLLCTRL) -#endif - -#ifdef OSC_RC32KCAL - DEFINE(OSC_RC32KCAL) -#else - MISSING(OSC_RC32KCAL) -#endif - -#ifdef OSC_STATUS - DEFINE(OSC_STATUS) -#else - MISSING(OSC_STATUS) -#endif - -#ifdef OSC_XOSCCTRL - DEFINE(OSC_XOSCCTRL) -#else - MISSING(OSC_XOSCCTRL) -#endif - -#ifdef OSC_XOSCFAIL - DEFINE(OSC_XOSCFAIL) -#else - MISSING(OSC_XOSCFAIL) -#endif - -#ifdef OSICSR - DEFINE(OSICSR) -#else - MISSING(OSICSR) -#endif - -#ifdef OTGCON - DEFINE(OTGCON) -#else - MISSING(OTGCON) -#endif - -#ifdef OTGIEN - DEFINE(OTGIEN) -#else - MISSING(OTGIEN) -#endif - -#ifdef OTGINT - DEFINE(OTGINT) -#else - MISSING(OTGINT) -#endif - -#ifdef OTGTCON - DEFINE(OTGTCON) -#else - MISSING(OTGTCON) -#endif - -#ifdef PACR - DEFINE(PACR) -#else - MISSING(PACR) -#endif - -#ifdef PAN_ID_0 - DEFINE(PAN_ID_0) -#else - MISSING(PAN_ID_0) -#endif - -#ifdef PAN_ID_1 - DEFINE(PAN_ID_1) -#else - MISSING(PAN_ID_1) -#endif - -#ifdef PART_NUM - DEFINE(PART_NUM) -#else - MISSING(PART_NUM) -#endif - -#ifdef PASDLY2 - DEFINE(PASDLY2) -#else - MISSING(PASDLY2) -#endif - -#ifdef PBOV - DEFINE(PBOV) -#else - MISSING(PBOV) -#endif - -#ifdef PCICR - DEFINE(PCICR) -#else - MISSING(PCICR) -#endif - -#ifdef PCIFR - DEFINE(PCIFR) -#else - MISSING(PCIFR) -#endif - -#ifdef PCMSK - DEFINE(PCMSK) -#else - MISSING(PCMSK) -#endif - -#ifdef PCMSK0 - DEFINE(PCMSK0) -#else - MISSING(PCMSK0) -#endif - -#ifdef PCMSK1 - DEFINE(PCMSK1) -#else - MISSING(PCMSK1) -#endif - -#ifdef PCMSK2 - DEFINE(PCMSK2) -#else - MISSING(PCMSK2) -#endif - -#ifdef PCMSK3 - DEFINE(PCMSK3) -#else - MISSING(PCMSK3) -#endif - -#ifdef PCNF - DEFINE(PCNF) -#else - MISSING(PCNF) -#endif - -#ifdef PCNF0 - DEFINE(PCNF0) -#else - MISSING(PCNF0) -#endif - -#ifdef PCNF1 - DEFINE(PCNF1) -#else - MISSING(PCNF1) -#endif - -#ifdef PCNF2 - DEFINE(PCNF2) -#else - MISSING(PCNF2) -#endif - -#ifdef PCNFE2 - DEFINE(PCNFE2) -#else - MISSING(PCNFE2) -#endif - -#ifdef PCTL - DEFINE(PCTL) -#else - MISSING(PCTL) -#endif - -#ifdef PCTL0 - DEFINE(PCTL0) -#else - MISSING(PCTL0) -#endif - -#ifdef PCTL1 - DEFINE(PCTL1) -#else - MISSING(PCTL1) -#endif - -#ifdef PCTL2 - DEFINE(PCTL2) -#else - MISSING(PCTL2) -#endif - -#ifdef PERIPHEN - DEFINE(PERIPHEN) -#else - MISSING(PERIPHEN) -#endif - -#ifdef PFRC0A - DEFINE(PFRC0A) -#else - MISSING(PFRC0A) -#endif - -#ifdef PFRC0B - DEFINE(PFRC0B) -#else - MISSING(PFRC0B) -#endif - -#ifdef PFRC1A - DEFINE(PFRC1A) -#else - MISSING(PFRC1A) -#endif - -#ifdef PFRC1B - DEFINE(PFRC1B) -#else - MISSING(PFRC1B) -#endif - -#ifdef PFRC2A - DEFINE(PFRC2A) -#else - MISSING(PFRC2A) -#endif - -#ifdef PFRC2B - DEFINE(PFRC2B) -#else - MISSING(PFRC2B) -#endif - -#ifdef PHY_CC_CCA - DEFINE(PHY_CC_CCA) -#else - MISSING(PHY_CC_CCA) -#endif - -#ifdef PHY_ED_LEVEL - DEFINE(PHY_ED_LEVEL) -#else - MISSING(PHY_ED_LEVEL) -#endif - -#ifdef PHY_RSSI - DEFINE(PHY_RSSI) -#else - MISSING(PHY_RSSI) -#endif - -#ifdef PHY_TX_PWR - DEFINE(PHY_TX_PWR) -#else - MISSING(PHY_TX_PWR) -#endif - -#ifdef PICR0 - DEFINE(PICR0) -#else - MISSING(PICR0) -#endif - -#ifdef PICR0H - DEFINE(PICR0H) -#else - MISSING(PICR0H) -#endif - -#ifdef PICR0L - DEFINE(PICR0L) -#else - MISSING(PICR0L) -#endif - -#ifdef PICR1 - DEFINE(PICR1) -#else - MISSING(PICR1) -#endif - -#ifdef PICR1H - DEFINE(PICR1H) -#else - MISSING(PICR1H) -#endif - -#ifdef PICR1L - DEFINE(PICR1L) -#else - MISSING(PICR1L) -#endif - -#ifdef PICR2 - DEFINE(PICR2) -#else - MISSING(PICR2) -#endif - -#ifdef PICR2H - DEFINE(PICR2H) -#else - MISSING(PICR2H) -#endif - -#ifdef PICR2L - DEFINE(PICR2L) -#else - MISSING(PICR2L) -#endif - -#ifdef PIFR - DEFINE(PIFR) -#else - MISSING(PIFR) -#endif - -#ifdef PIFR0 - DEFINE(PIFR0) -#else - MISSING(PIFR0) -#endif - -#ifdef PIFR1 - DEFINE(PIFR1) -#else - MISSING(PIFR1) -#endif - -#ifdef PIFR2 - DEFINE(PIFR2) -#else - MISSING(PIFR2) -#endif - -#ifdef PIM - DEFINE(PIM) -#else - MISSING(PIM) -#endif - -#ifdef PIM0 - DEFINE(PIM0) -#else - MISSING(PIM0) -#endif - -#ifdef PIM1 - DEFINE(PIM1) -#else - MISSING(PIM1) -#endif - -#ifdef PIM2 - DEFINE(PIM2) -#else - MISSING(PIM2) -#endif - -#ifdef PINA - DEFINE(PINA) -#else - MISSING(PINA) -#endif - -#ifdef PINB - DEFINE(PINB) -#else - MISSING(PINB) -#endif - -#ifdef PINC - DEFINE(PINC) -#else - MISSING(PINC) -#endif - -#ifdef PIND - DEFINE(PIND) -#else - MISSING(PIND) -#endif - -#ifdef PINE - DEFINE(PINE) -#else - MISSING(PINE) -#endif - -#ifdef PINF - DEFINE(PINF) -#else - MISSING(PINF) -#endif - -#ifdef PING - DEFINE(PING) -#else - MISSING(PING) -#endif - -#ifdef PINH - DEFINE(PINH) -#else - MISSING(PINH) -#endif - -#ifdef PINJ - DEFINE(PINJ) -#else - MISSING(PINJ) -#endif - -#ifdef PINK - DEFINE(PINK) -#else - MISSING(PINK) -#endif - -#ifdef PINL - DEFINE(PINL) -#else - MISSING(PINL) -#endif - -#ifdef PLLCR - DEFINE(PLLCR) -#else - MISSING(PLLCR) -#endif - -#ifdef PLLCSR - DEFINE(PLLCSR) -#else - MISSING(PLLCSR) -#endif - -#ifdef PLLFRQ - DEFINE(PLLFRQ) -#else - MISSING(PLLFRQ) -#endif - -#ifdef PLL_CF - DEFINE(PLL_CF) -#else - MISSING(PLL_CF) -#endif - -#ifdef PLL_DCU - DEFINE(PLL_DCU) -#else - MISSING(PLL_DCU) -#endif - -#ifdef PMIC0 - DEFINE(PMIC0) -#else - MISSING(PMIC0) -#endif - -#ifdef PMIC1 - DEFINE(PMIC1) -#else - MISSING(PMIC1) -#endif - -#ifdef PMIC2 - DEFINE(PMIC2) -#else - MISSING(PMIC2) -#endif - -#ifdef PMIC_CTRL - DEFINE(PMIC_CTRL) -#else - MISSING(PMIC_CTRL) -#endif - -#ifdef PMIC_INTPRI - DEFINE(PMIC_INTPRI) -#else - MISSING(PMIC_INTPRI) -#endif - -#ifdef PMIC_STATUS - DEFINE(PMIC_STATUS) -#else - MISSING(PMIC_STATUS) -#endif - -#ifdef POC - DEFINE(POC) -#else - MISSING(POC) -#endif - -#ifdef POCR0RA - DEFINE(POCR0RA) -#else - MISSING(POCR0RA) -#endif - -#ifdef POCR0RAH - DEFINE(POCR0RAH) -#else - MISSING(POCR0RAH) -#endif - -#ifdef POCR0RAL - DEFINE(POCR0RAL) -#else - MISSING(POCR0RAL) -#endif - -#ifdef POCR0SA - DEFINE(POCR0SA) -#else - MISSING(POCR0SA) -#endif - -#ifdef POCR0SAH - DEFINE(POCR0SAH) -#else - MISSING(POCR0SAH) -#endif - -#ifdef POCR0SAL - DEFINE(POCR0SAL) -#else - MISSING(POCR0SAL) -#endif - -#ifdef POCR0SB - DEFINE(POCR0SB) -#else - MISSING(POCR0SB) -#endif - -#ifdef POCR0SBH - DEFINE(POCR0SBH) -#else - MISSING(POCR0SBH) -#endif - -#ifdef POCR0SBL - DEFINE(POCR0SBL) -#else - MISSING(POCR0SBL) -#endif - -#ifdef POCR1RA - DEFINE(POCR1RA) -#else - MISSING(POCR1RA) -#endif - -#ifdef POCR1RAH - DEFINE(POCR1RAH) -#else - MISSING(POCR1RAH) -#endif - -#ifdef POCR1RAL - DEFINE(POCR1RAL) -#else - MISSING(POCR1RAL) -#endif - -#ifdef POCR1SA - DEFINE(POCR1SA) -#else - MISSING(POCR1SA) -#endif - -#ifdef POCR1SAH - DEFINE(POCR1SAH) -#else - MISSING(POCR1SAH) -#endif - -#ifdef POCR1SAL - DEFINE(POCR1SAL) -#else - MISSING(POCR1SAL) -#endif - -#ifdef POCR1SB - DEFINE(POCR1SB) -#else - MISSING(POCR1SB) -#endif - -#ifdef POCR1SBH - DEFINE(POCR1SBH) -#else - MISSING(POCR1SBH) -#endif - -#ifdef POCR1SBL - DEFINE(POCR1SBL) -#else - MISSING(POCR1SBL) -#endif - -#ifdef POCR2RA - DEFINE(POCR2RA) -#else - MISSING(POCR2RA) -#endif - -#ifdef POCR2RAH - DEFINE(POCR2RAH) -#else - MISSING(POCR2RAH) -#endif - -#ifdef POCR2RAL - DEFINE(POCR2RAL) -#else - MISSING(POCR2RAL) -#endif - -#ifdef POCR2SA - DEFINE(POCR2SA) -#else - MISSING(POCR2SA) -#endif - -#ifdef POCR2SAH - DEFINE(POCR2SAH) -#else - MISSING(POCR2SAH) -#endif - -#ifdef POCR2SAL - DEFINE(POCR2SAL) -#else - MISSING(POCR2SAL) -#endif - -#ifdef POCR2SB - DEFINE(POCR2SB) -#else - MISSING(POCR2SB) -#endif - -#ifdef POCR2SBH - DEFINE(POCR2SBH) -#else - MISSING(POCR2SBH) -#endif - -#ifdef POCR2SBL - DEFINE(POCR2SBL) -#else - MISSING(POCR2SBL) -#endif - -#ifdef POCR_RB - DEFINE(POCR_RB) -#else - MISSING(POCR_RB) -#endif - -#ifdef POCR_RBH - DEFINE(POCR_RBH) -#else - MISSING(POCR_RBH) -#endif - -#ifdef POCR_RBL - DEFINE(POCR_RBL) -#else - MISSING(POCR_RBL) -#endif - -#ifdef POCRxRB - DEFINE(POCRxRB) -#else - MISSING(POCRxRB) -#endif - -#ifdef POCRxRBH - DEFINE(POCRxRBH) -#else - MISSING(POCRxRBH) -#endif - -#ifdef POCRxRBL - DEFINE(POCRxRBL) -#else - MISSING(POCRxRBL) -#endif - -#ifdef POM2 - DEFINE(POM2) -#else - MISSING(POM2) -#endif - -#ifdef PORTA - DEFINE(PORTA) -#else - MISSING(PORTA) -#endif - -#ifdef PORTA_DIR - DEFINE(PORTA_DIR) -#else - MISSING(PORTA_DIR) -#endif - -#ifdef PORTA_DIRCLR - DEFINE(PORTA_DIRCLR) -#else - MISSING(PORTA_DIRCLR) -#endif - -#ifdef PORTA_DIRSET - DEFINE(PORTA_DIRSET) -#else - MISSING(PORTA_DIRSET) -#endif - -#ifdef PORTA_DIRTGL - DEFINE(PORTA_DIRTGL) -#else - MISSING(PORTA_DIRTGL) -#endif - -#ifdef PORTA_IN - DEFINE(PORTA_IN) -#else - MISSING(PORTA_IN) -#endif - -#ifdef PORTA_INT0MASK - DEFINE(PORTA_INT0MASK) -#else - MISSING(PORTA_INT0MASK) -#endif - -#ifdef PORTA_INT1MASK - DEFINE(PORTA_INT1MASK) -#else - MISSING(PORTA_INT1MASK) -#endif - -#ifdef PORTA_INTCTRL - DEFINE(PORTA_INTCTRL) -#else - MISSING(PORTA_INTCTRL) -#endif - -#ifdef PORTA_INTFLAGS - DEFINE(PORTA_INTFLAGS) -#else - MISSING(PORTA_INTFLAGS) -#endif - -#ifdef PORTA_OUT - DEFINE(PORTA_OUT) -#else - MISSING(PORTA_OUT) -#endif - -#ifdef PORTA_OUTCLR - DEFINE(PORTA_OUTCLR) -#else - MISSING(PORTA_OUTCLR) -#endif - -#ifdef PORTA_OUTSET - DEFINE(PORTA_OUTSET) -#else - MISSING(PORTA_OUTSET) -#endif - -#ifdef PORTA_OUTTGL - DEFINE(PORTA_OUTTGL) -#else - MISSING(PORTA_OUTTGL) -#endif - -#ifdef PORTA_PIN0CTRL - DEFINE(PORTA_PIN0CTRL) -#else - MISSING(PORTA_PIN0CTRL) -#endif - -#ifdef PORTA_PIN1CTRL - DEFINE(PORTA_PIN1CTRL) -#else - MISSING(PORTA_PIN1CTRL) -#endif - -#ifdef PORTA_PIN2CTRL - DEFINE(PORTA_PIN2CTRL) -#else - MISSING(PORTA_PIN2CTRL) -#endif - -#ifdef PORTA_PIN3CTRL - DEFINE(PORTA_PIN3CTRL) -#else - MISSING(PORTA_PIN3CTRL) -#endif - -#ifdef PORTA_PIN4CTRL - DEFINE(PORTA_PIN4CTRL) -#else - MISSING(PORTA_PIN4CTRL) -#endif - -#ifdef PORTA_PIN5CTRL - DEFINE(PORTA_PIN5CTRL) -#else - MISSING(PORTA_PIN5CTRL) -#endif - -#ifdef PORTA_PIN6CTRL - DEFINE(PORTA_PIN6CTRL) -#else - MISSING(PORTA_PIN6CTRL) -#endif - -#ifdef PORTA_PIN7CTRL - DEFINE(PORTA_PIN7CTRL) -#else - MISSING(PORTA_PIN7CTRL) -#endif - -#ifdef PORTB - DEFINE(PORTB) -#else - MISSING(PORTB) -#endif - -#ifdef PORTB_DIR - DEFINE(PORTB_DIR) -#else - MISSING(PORTB_DIR) -#endif - -#ifdef PORTB_DIRCLR - DEFINE(PORTB_DIRCLR) -#else - MISSING(PORTB_DIRCLR) -#endif - -#ifdef PORTB_DIRSET - DEFINE(PORTB_DIRSET) -#else - MISSING(PORTB_DIRSET) -#endif - -#ifdef PORTB_DIRTGL - DEFINE(PORTB_DIRTGL) -#else - MISSING(PORTB_DIRTGL) -#endif - -#ifdef PORTB_IN - DEFINE(PORTB_IN) -#else - MISSING(PORTB_IN) -#endif - -#ifdef PORTB_INT0MASK - DEFINE(PORTB_INT0MASK) -#else - MISSING(PORTB_INT0MASK) -#endif - -#ifdef PORTB_INT1MASK - DEFINE(PORTB_INT1MASK) -#else - MISSING(PORTB_INT1MASK) -#endif - -#ifdef PORTB_INTCTRL - DEFINE(PORTB_INTCTRL) -#else - MISSING(PORTB_INTCTRL) -#endif - -#ifdef PORTB_INTFLAGS - DEFINE(PORTB_INTFLAGS) -#else - MISSING(PORTB_INTFLAGS) -#endif - -#ifdef PORTB_OUT - DEFINE(PORTB_OUT) -#else - MISSING(PORTB_OUT) -#endif - -#ifdef PORTB_OUTCLR - DEFINE(PORTB_OUTCLR) -#else - MISSING(PORTB_OUTCLR) -#endif - -#ifdef PORTB_OUTSET - DEFINE(PORTB_OUTSET) -#else - MISSING(PORTB_OUTSET) -#endif - -#ifdef PORTB_OUTTGL - DEFINE(PORTB_OUTTGL) -#else - MISSING(PORTB_OUTTGL) -#endif - -#ifdef PORTB_PIN0CTRL - DEFINE(PORTB_PIN0CTRL) -#else - MISSING(PORTB_PIN0CTRL) -#endif - -#ifdef PORTB_PIN1CTRL - DEFINE(PORTB_PIN1CTRL) -#else - MISSING(PORTB_PIN1CTRL) -#endif - -#ifdef PORTB_PIN2CTRL - DEFINE(PORTB_PIN2CTRL) -#else - MISSING(PORTB_PIN2CTRL) -#endif - -#ifdef PORTB_PIN3CTRL - DEFINE(PORTB_PIN3CTRL) -#else - MISSING(PORTB_PIN3CTRL) -#endif - -#ifdef PORTB_PIN4CTRL - DEFINE(PORTB_PIN4CTRL) -#else - MISSING(PORTB_PIN4CTRL) -#endif - -#ifdef PORTB_PIN5CTRL - DEFINE(PORTB_PIN5CTRL) -#else - MISSING(PORTB_PIN5CTRL) -#endif - -#ifdef PORTB_PIN6CTRL - DEFINE(PORTB_PIN6CTRL) -#else - MISSING(PORTB_PIN6CTRL) -#endif - -#ifdef PORTB_PIN7CTRL - DEFINE(PORTB_PIN7CTRL) -#else - MISSING(PORTB_PIN7CTRL) -#endif - -#ifdef PORTC - DEFINE(PORTC) -#else - MISSING(PORTC) -#endif - -#ifdef PORTCFG_CLKEVOUT - DEFINE(PORTCFG_CLKEVOUT) -#else - MISSING(PORTCFG_CLKEVOUT) -#endif - -#ifdef PORTCFG_MPCMASK - DEFINE(PORTCFG_MPCMASK) -#else - MISSING(PORTCFG_MPCMASK) -#endif - -#ifdef PORTCFG_VPCTRLA - DEFINE(PORTCFG_VPCTRLA) -#else - MISSING(PORTCFG_VPCTRLA) -#endif - -#ifdef PORTCFG_VPCTRLB - DEFINE(PORTCFG_VPCTRLB) -#else - MISSING(PORTCFG_VPCTRLB) -#endif - -#ifdef PORTCR - DEFINE(PORTCR) -#else - MISSING(PORTCR) -#endif - -#ifdef PORTC_DIR - DEFINE(PORTC_DIR) -#else - MISSING(PORTC_DIR) -#endif - -#ifdef PORTC_DIRCLR - DEFINE(PORTC_DIRCLR) -#else - MISSING(PORTC_DIRCLR) -#endif - -#ifdef PORTC_DIRSET - DEFINE(PORTC_DIRSET) -#else - MISSING(PORTC_DIRSET) -#endif - -#ifdef PORTC_DIRTGL - DEFINE(PORTC_DIRTGL) -#else - MISSING(PORTC_DIRTGL) -#endif - -#ifdef PORTC_IN - DEFINE(PORTC_IN) -#else - MISSING(PORTC_IN) -#endif - -#ifdef PORTC_INT0MASK - DEFINE(PORTC_INT0MASK) -#else - MISSING(PORTC_INT0MASK) -#endif - -#ifdef PORTC_INT1MASK - DEFINE(PORTC_INT1MASK) -#else - MISSING(PORTC_INT1MASK) -#endif - -#ifdef PORTC_INTCTRL - DEFINE(PORTC_INTCTRL) -#else - MISSING(PORTC_INTCTRL) -#endif - -#ifdef PORTC_INTFLAGS - DEFINE(PORTC_INTFLAGS) -#else - MISSING(PORTC_INTFLAGS) -#endif - -#ifdef PORTC_OUT - DEFINE(PORTC_OUT) -#else - MISSING(PORTC_OUT) -#endif - -#ifdef PORTC_OUTCLR - DEFINE(PORTC_OUTCLR) -#else - MISSING(PORTC_OUTCLR) -#endif - -#ifdef PORTC_OUTSET - DEFINE(PORTC_OUTSET) -#else - MISSING(PORTC_OUTSET) -#endif - -#ifdef PORTC_OUTTGL - DEFINE(PORTC_OUTTGL) -#else - MISSING(PORTC_OUTTGL) -#endif - -#ifdef PORTC_PIN0CTRL - DEFINE(PORTC_PIN0CTRL) -#else - MISSING(PORTC_PIN0CTRL) -#endif - -#ifdef PORTC_PIN1CTRL - DEFINE(PORTC_PIN1CTRL) -#else - MISSING(PORTC_PIN1CTRL) -#endif - -#ifdef PORTC_PIN2CTRL - DEFINE(PORTC_PIN2CTRL) -#else - MISSING(PORTC_PIN2CTRL) -#endif - -#ifdef PORTC_PIN3CTRL - DEFINE(PORTC_PIN3CTRL) -#else - MISSING(PORTC_PIN3CTRL) -#endif - -#ifdef PORTC_PIN4CTRL - DEFINE(PORTC_PIN4CTRL) -#else - MISSING(PORTC_PIN4CTRL) -#endif - -#ifdef PORTC_PIN5CTRL - DEFINE(PORTC_PIN5CTRL) -#else - MISSING(PORTC_PIN5CTRL) -#endif - -#ifdef PORTC_PIN6CTRL - DEFINE(PORTC_PIN6CTRL) -#else - MISSING(PORTC_PIN6CTRL) -#endif - -#ifdef PORTC_PIN7CTRL - DEFINE(PORTC_PIN7CTRL) -#else - MISSING(PORTC_PIN7CTRL) -#endif - -#ifdef PORTD - DEFINE(PORTD) -#else - MISSING(PORTD) -#endif - -#ifdef PORTD_DIR - DEFINE(PORTD_DIR) -#else - MISSING(PORTD_DIR) -#endif - -#ifdef PORTD_DIRCLR - DEFINE(PORTD_DIRCLR) -#else - MISSING(PORTD_DIRCLR) -#endif - -#ifdef PORTD_DIRSET - DEFINE(PORTD_DIRSET) -#else - MISSING(PORTD_DIRSET) -#endif - -#ifdef PORTD_DIRTGL - DEFINE(PORTD_DIRTGL) -#else - MISSING(PORTD_DIRTGL) -#endif - -#ifdef PORTD_IN - DEFINE(PORTD_IN) -#else - MISSING(PORTD_IN) -#endif - -#ifdef PORTD_INT0MASK - DEFINE(PORTD_INT0MASK) -#else - MISSING(PORTD_INT0MASK) -#endif - -#ifdef PORTD_INT1MASK - DEFINE(PORTD_INT1MASK) -#else - MISSING(PORTD_INT1MASK) -#endif - -#ifdef PORTD_INTCTRL - DEFINE(PORTD_INTCTRL) -#else - MISSING(PORTD_INTCTRL) -#endif - -#ifdef PORTD_INTFLAGS - DEFINE(PORTD_INTFLAGS) -#else - MISSING(PORTD_INTFLAGS) -#endif - -#ifdef PORTD_OUT - DEFINE(PORTD_OUT) -#else - MISSING(PORTD_OUT) -#endif - -#ifdef PORTD_OUTCLR - DEFINE(PORTD_OUTCLR) -#else - MISSING(PORTD_OUTCLR) -#endif - -#ifdef PORTD_OUTSET - DEFINE(PORTD_OUTSET) -#else - MISSING(PORTD_OUTSET) -#endif - -#ifdef PORTD_OUTTGL - DEFINE(PORTD_OUTTGL) -#else - MISSING(PORTD_OUTTGL) -#endif - -#ifdef PORTD_PIN0CTRL - DEFINE(PORTD_PIN0CTRL) -#else - MISSING(PORTD_PIN0CTRL) -#endif - -#ifdef PORTD_PIN1CTRL - DEFINE(PORTD_PIN1CTRL) -#else - MISSING(PORTD_PIN1CTRL) -#endif - -#ifdef PORTD_PIN2CTRL - DEFINE(PORTD_PIN2CTRL) -#else - MISSING(PORTD_PIN2CTRL) -#endif - -#ifdef PORTD_PIN3CTRL - DEFINE(PORTD_PIN3CTRL) -#else - MISSING(PORTD_PIN3CTRL) -#endif - -#ifdef PORTD_PIN4CTRL - DEFINE(PORTD_PIN4CTRL) -#else - MISSING(PORTD_PIN4CTRL) -#endif - -#ifdef PORTD_PIN5CTRL - DEFINE(PORTD_PIN5CTRL) -#else - MISSING(PORTD_PIN5CTRL) -#endif - -#ifdef PORTD_PIN6CTRL - DEFINE(PORTD_PIN6CTRL) -#else - MISSING(PORTD_PIN6CTRL) -#endif - -#ifdef PORTD_PIN7CTRL - DEFINE(PORTD_PIN7CTRL) -#else - MISSING(PORTD_PIN7CTRL) -#endif - -#ifdef PORTE - DEFINE(PORTE) -#else - MISSING(PORTE) -#endif - -#ifdef PORTE_DIR - DEFINE(PORTE_DIR) -#else - MISSING(PORTE_DIR) -#endif - -#ifdef PORTE_DIRCLR - DEFINE(PORTE_DIRCLR) -#else - MISSING(PORTE_DIRCLR) -#endif - -#ifdef PORTE_DIRSET - DEFINE(PORTE_DIRSET) -#else - MISSING(PORTE_DIRSET) -#endif - -#ifdef PORTE_DIRTGL - DEFINE(PORTE_DIRTGL) -#else - MISSING(PORTE_DIRTGL) -#endif - -#ifdef PORTE_IN - DEFINE(PORTE_IN) -#else - MISSING(PORTE_IN) -#endif - -#ifdef PORTE_INT0MASK - DEFINE(PORTE_INT0MASK) -#else - MISSING(PORTE_INT0MASK) -#endif - -#ifdef PORTE_INT1MASK - DEFINE(PORTE_INT1MASK) -#else - MISSING(PORTE_INT1MASK) -#endif - -#ifdef PORTE_INTCTRL - DEFINE(PORTE_INTCTRL) -#else - MISSING(PORTE_INTCTRL) -#endif - -#ifdef PORTE_INTFLAGS - DEFINE(PORTE_INTFLAGS) -#else - MISSING(PORTE_INTFLAGS) -#endif - -#ifdef PORTE_OUT - DEFINE(PORTE_OUT) -#else - MISSING(PORTE_OUT) -#endif - -#ifdef PORTE_OUTCLR - DEFINE(PORTE_OUTCLR) -#else - MISSING(PORTE_OUTCLR) -#endif - -#ifdef PORTE_OUTSET - DEFINE(PORTE_OUTSET) -#else - MISSING(PORTE_OUTSET) -#endif - -#ifdef PORTE_OUTTGL - DEFINE(PORTE_OUTTGL) -#else - MISSING(PORTE_OUTTGL) -#endif - -#ifdef PORTE_PIN0CTRL - DEFINE(PORTE_PIN0CTRL) -#else - MISSING(PORTE_PIN0CTRL) -#endif - -#ifdef PORTE_PIN1CTRL - DEFINE(PORTE_PIN1CTRL) -#else - MISSING(PORTE_PIN1CTRL) -#endif - -#ifdef PORTE_PIN2CTRL - DEFINE(PORTE_PIN2CTRL) -#else - MISSING(PORTE_PIN2CTRL) -#endif - -#ifdef PORTE_PIN3CTRL - DEFINE(PORTE_PIN3CTRL) -#else - MISSING(PORTE_PIN3CTRL) -#endif - -#ifdef PORTE_PIN4CTRL - DEFINE(PORTE_PIN4CTRL) -#else - MISSING(PORTE_PIN4CTRL) -#endif - -#ifdef PORTE_PIN5CTRL - DEFINE(PORTE_PIN5CTRL) -#else - MISSING(PORTE_PIN5CTRL) -#endif - -#ifdef PORTE_PIN6CTRL - DEFINE(PORTE_PIN6CTRL) -#else - MISSING(PORTE_PIN6CTRL) -#endif - -#ifdef PORTE_PIN7CTRL - DEFINE(PORTE_PIN7CTRL) -#else - MISSING(PORTE_PIN7CTRL) -#endif - -#ifdef PORTF - DEFINE(PORTF) -#else - MISSING(PORTF) -#endif - -#ifdef PORTF_DIR - DEFINE(PORTF_DIR) -#else - MISSING(PORTF_DIR) -#endif - -#ifdef PORTF_DIRCLR - DEFINE(PORTF_DIRCLR) -#else - MISSING(PORTF_DIRCLR) -#endif - -#ifdef PORTF_DIRSET - DEFINE(PORTF_DIRSET) -#else - MISSING(PORTF_DIRSET) -#endif - -#ifdef PORTF_DIRTGL - DEFINE(PORTF_DIRTGL) -#else - MISSING(PORTF_DIRTGL) -#endif - -#ifdef PORTF_IN - DEFINE(PORTF_IN) -#else - MISSING(PORTF_IN) -#endif - -#ifdef PORTF_INT0MASK - DEFINE(PORTF_INT0MASK) -#else - MISSING(PORTF_INT0MASK) -#endif - -#ifdef PORTF_INT1MASK - DEFINE(PORTF_INT1MASK) -#else - MISSING(PORTF_INT1MASK) -#endif - -#ifdef PORTF_INTCTRL - DEFINE(PORTF_INTCTRL) -#else - MISSING(PORTF_INTCTRL) -#endif - -#ifdef PORTF_INTFLAGS - DEFINE(PORTF_INTFLAGS) -#else - MISSING(PORTF_INTFLAGS) -#endif - -#ifdef PORTF_OUT - DEFINE(PORTF_OUT) -#else - MISSING(PORTF_OUT) -#endif - -#ifdef PORTF_OUTCLR - DEFINE(PORTF_OUTCLR) -#else - MISSING(PORTF_OUTCLR) -#endif - -#ifdef PORTF_OUTSET - DEFINE(PORTF_OUTSET) -#else - MISSING(PORTF_OUTSET) -#endif - -#ifdef PORTF_OUTTGL - DEFINE(PORTF_OUTTGL) -#else - MISSING(PORTF_OUTTGL) -#endif - -#ifdef PORTF_PIN0CTRL - DEFINE(PORTF_PIN0CTRL) -#else - MISSING(PORTF_PIN0CTRL) -#endif - -#ifdef PORTF_PIN1CTRL - DEFINE(PORTF_PIN1CTRL) -#else - MISSING(PORTF_PIN1CTRL) -#endif - -#ifdef PORTF_PIN2CTRL - DEFINE(PORTF_PIN2CTRL) -#else - MISSING(PORTF_PIN2CTRL) -#endif - -#ifdef PORTF_PIN3CTRL - DEFINE(PORTF_PIN3CTRL) -#else - MISSING(PORTF_PIN3CTRL) -#endif - -#ifdef PORTF_PIN4CTRL - DEFINE(PORTF_PIN4CTRL) -#else - MISSING(PORTF_PIN4CTRL) -#endif - -#ifdef PORTF_PIN5CTRL - DEFINE(PORTF_PIN5CTRL) -#else - MISSING(PORTF_PIN5CTRL) -#endif - -#ifdef PORTF_PIN6CTRL - DEFINE(PORTF_PIN6CTRL) -#else - MISSING(PORTF_PIN6CTRL) -#endif - -#ifdef PORTF_PIN7CTRL - DEFINE(PORTF_PIN7CTRL) -#else - MISSING(PORTF_PIN7CTRL) -#endif - -#ifdef PORTG - DEFINE(PORTG) -#else - MISSING(PORTG) -#endif - -#ifdef PORTH - DEFINE(PORTH) -#else - MISSING(PORTH) -#endif - -#ifdef PORTH_DIR - DEFINE(PORTH_DIR) -#else - MISSING(PORTH_DIR) -#endif - -#ifdef PORTH_DIRCLR - DEFINE(PORTH_DIRCLR) -#else - MISSING(PORTH_DIRCLR) -#endif - -#ifdef PORTH_DIRSET - DEFINE(PORTH_DIRSET) -#else - MISSING(PORTH_DIRSET) -#endif - -#ifdef PORTH_DIRTGL - DEFINE(PORTH_DIRTGL) -#else - MISSING(PORTH_DIRTGL) -#endif - -#ifdef PORTH_IN - DEFINE(PORTH_IN) -#else - MISSING(PORTH_IN) -#endif - -#ifdef PORTH_INT0MASK - DEFINE(PORTH_INT0MASK) -#else - MISSING(PORTH_INT0MASK) -#endif - -#ifdef PORTH_INT1MASK - DEFINE(PORTH_INT1MASK) -#else - MISSING(PORTH_INT1MASK) -#endif - -#ifdef PORTH_INTCTRL - DEFINE(PORTH_INTCTRL) -#else - MISSING(PORTH_INTCTRL) -#endif - -#ifdef PORTH_INTFLAGS - DEFINE(PORTH_INTFLAGS) -#else - MISSING(PORTH_INTFLAGS) -#endif - -#ifdef PORTH_OUT - DEFINE(PORTH_OUT) -#else - MISSING(PORTH_OUT) -#endif - -#ifdef PORTH_OUTCLR - DEFINE(PORTH_OUTCLR) -#else - MISSING(PORTH_OUTCLR) -#endif - -#ifdef PORTH_OUTSET - DEFINE(PORTH_OUTSET) -#else - MISSING(PORTH_OUTSET) -#endif - -#ifdef PORTH_OUTTGL - DEFINE(PORTH_OUTTGL) -#else - MISSING(PORTH_OUTTGL) -#endif - -#ifdef PORTH_PIN0CTRL - DEFINE(PORTH_PIN0CTRL) -#else - MISSING(PORTH_PIN0CTRL) -#endif - -#ifdef PORTH_PIN1CTRL - DEFINE(PORTH_PIN1CTRL) -#else - MISSING(PORTH_PIN1CTRL) -#endif - -#ifdef PORTH_PIN2CTRL - DEFINE(PORTH_PIN2CTRL) -#else - MISSING(PORTH_PIN2CTRL) -#endif - -#ifdef PORTH_PIN3CTRL - DEFINE(PORTH_PIN3CTRL) -#else - MISSING(PORTH_PIN3CTRL) -#endif - -#ifdef PORTH_PIN4CTRL - DEFINE(PORTH_PIN4CTRL) -#else - MISSING(PORTH_PIN4CTRL) -#endif - -#ifdef PORTH_PIN5CTRL - DEFINE(PORTH_PIN5CTRL) -#else - MISSING(PORTH_PIN5CTRL) -#endif - -#ifdef PORTH_PIN6CTRL - DEFINE(PORTH_PIN6CTRL) -#else - MISSING(PORTH_PIN6CTRL) -#endif - -#ifdef PORTH_PIN7CTRL - DEFINE(PORTH_PIN7CTRL) -#else - MISSING(PORTH_PIN7CTRL) -#endif - -#ifdef PORTJ - DEFINE(PORTJ) -#else - MISSING(PORTJ) -#endif - -#ifdef PORTJ_DIR - DEFINE(PORTJ_DIR) -#else - MISSING(PORTJ_DIR) -#endif - -#ifdef PORTJ_DIRCLR - DEFINE(PORTJ_DIRCLR) -#else - MISSING(PORTJ_DIRCLR) -#endif - -#ifdef PORTJ_DIRSET - DEFINE(PORTJ_DIRSET) -#else - MISSING(PORTJ_DIRSET) -#endif - -#ifdef PORTJ_DIRTGL - DEFINE(PORTJ_DIRTGL) -#else - MISSING(PORTJ_DIRTGL) -#endif - -#ifdef PORTJ_IN - DEFINE(PORTJ_IN) -#else - MISSING(PORTJ_IN) -#endif - -#ifdef PORTJ_INT0MASK - DEFINE(PORTJ_INT0MASK) -#else - MISSING(PORTJ_INT0MASK) -#endif - -#ifdef PORTJ_INT1MASK - DEFINE(PORTJ_INT1MASK) -#else - MISSING(PORTJ_INT1MASK) -#endif - -#ifdef PORTJ_INTCTRL - DEFINE(PORTJ_INTCTRL) -#else - MISSING(PORTJ_INTCTRL) -#endif - -#ifdef PORTJ_INTFLAGS - DEFINE(PORTJ_INTFLAGS) -#else - MISSING(PORTJ_INTFLAGS) -#endif - -#ifdef PORTJ_OUT - DEFINE(PORTJ_OUT) -#else - MISSING(PORTJ_OUT) -#endif - -#ifdef PORTJ_OUTCLR - DEFINE(PORTJ_OUTCLR) -#else - MISSING(PORTJ_OUTCLR) -#endif - -#ifdef PORTJ_OUTSET - DEFINE(PORTJ_OUTSET) -#else - MISSING(PORTJ_OUTSET) -#endif - -#ifdef PORTJ_OUTTGL - DEFINE(PORTJ_OUTTGL) -#else - MISSING(PORTJ_OUTTGL) -#endif - -#ifdef PORTJ_PIN0CTRL - DEFINE(PORTJ_PIN0CTRL) -#else - MISSING(PORTJ_PIN0CTRL) -#endif - -#ifdef PORTJ_PIN1CTRL - DEFINE(PORTJ_PIN1CTRL) -#else - MISSING(PORTJ_PIN1CTRL) -#endif - -#ifdef PORTJ_PIN2CTRL - DEFINE(PORTJ_PIN2CTRL) -#else - MISSING(PORTJ_PIN2CTRL) -#endif - -#ifdef PORTJ_PIN3CTRL - DEFINE(PORTJ_PIN3CTRL) -#else - MISSING(PORTJ_PIN3CTRL) -#endif - -#ifdef PORTJ_PIN4CTRL - DEFINE(PORTJ_PIN4CTRL) -#else - MISSING(PORTJ_PIN4CTRL) -#endif - -#ifdef PORTJ_PIN5CTRL - DEFINE(PORTJ_PIN5CTRL) -#else - MISSING(PORTJ_PIN5CTRL) -#endif - -#ifdef PORTJ_PIN6CTRL - DEFINE(PORTJ_PIN6CTRL) -#else - MISSING(PORTJ_PIN6CTRL) -#endif - -#ifdef PORTJ_PIN7CTRL - DEFINE(PORTJ_PIN7CTRL) -#else - MISSING(PORTJ_PIN7CTRL) -#endif - -#ifdef PORTK - DEFINE(PORTK) -#else - MISSING(PORTK) -#endif - -#ifdef PORTK_DIR - DEFINE(PORTK_DIR) -#else - MISSING(PORTK_DIR) -#endif - -#ifdef PORTK_DIRCLR - DEFINE(PORTK_DIRCLR) -#else - MISSING(PORTK_DIRCLR) -#endif - -#ifdef PORTK_DIRSET - DEFINE(PORTK_DIRSET) -#else - MISSING(PORTK_DIRSET) -#endif - -#ifdef PORTK_DIRTGL - DEFINE(PORTK_DIRTGL) -#else - MISSING(PORTK_DIRTGL) -#endif - -#ifdef PORTK_IN - DEFINE(PORTK_IN) -#else - MISSING(PORTK_IN) -#endif - -#ifdef PORTK_INT0MASK - DEFINE(PORTK_INT0MASK) -#else - MISSING(PORTK_INT0MASK) -#endif - -#ifdef PORTK_INT1MASK - DEFINE(PORTK_INT1MASK) -#else - MISSING(PORTK_INT1MASK) -#endif - -#ifdef PORTK_INTCTRL - DEFINE(PORTK_INTCTRL) -#else - MISSING(PORTK_INTCTRL) -#endif - -#ifdef PORTK_INTFLAGS - DEFINE(PORTK_INTFLAGS) -#else - MISSING(PORTK_INTFLAGS) -#endif - -#ifdef PORTK_OUT - DEFINE(PORTK_OUT) -#else - MISSING(PORTK_OUT) -#endif - -#ifdef PORTK_OUTCLR - DEFINE(PORTK_OUTCLR) -#else - MISSING(PORTK_OUTCLR) -#endif - -#ifdef PORTK_OUTSET - DEFINE(PORTK_OUTSET) -#else - MISSING(PORTK_OUTSET) -#endif - -#ifdef PORTK_OUTTGL - DEFINE(PORTK_OUTTGL) -#else - MISSING(PORTK_OUTTGL) -#endif - -#ifdef PORTK_PIN0CTRL - DEFINE(PORTK_PIN0CTRL) -#else - MISSING(PORTK_PIN0CTRL) -#endif - -#ifdef PORTK_PIN1CTRL - DEFINE(PORTK_PIN1CTRL) -#else - MISSING(PORTK_PIN1CTRL) -#endif - -#ifdef PORTK_PIN2CTRL - DEFINE(PORTK_PIN2CTRL) -#else - MISSING(PORTK_PIN2CTRL) -#endif - -#ifdef PORTK_PIN3CTRL - DEFINE(PORTK_PIN3CTRL) -#else - MISSING(PORTK_PIN3CTRL) -#endif - -#ifdef PORTK_PIN4CTRL - DEFINE(PORTK_PIN4CTRL) -#else - MISSING(PORTK_PIN4CTRL) -#endif - -#ifdef PORTK_PIN5CTRL - DEFINE(PORTK_PIN5CTRL) -#else - MISSING(PORTK_PIN5CTRL) -#endif - -#ifdef PORTK_PIN6CTRL - DEFINE(PORTK_PIN6CTRL) -#else - MISSING(PORTK_PIN6CTRL) -#endif - -#ifdef PORTK_PIN7CTRL - DEFINE(PORTK_PIN7CTRL) -#else - MISSING(PORTK_PIN7CTRL) -#endif - -#ifdef PORTL - DEFINE(PORTL) -#else - MISSING(PORTL) -#endif - -#ifdef PORTQ_DIR - DEFINE(PORTQ_DIR) -#else - MISSING(PORTQ_DIR) -#endif - -#ifdef PORTQ_DIRCLR - DEFINE(PORTQ_DIRCLR) -#else - MISSING(PORTQ_DIRCLR) -#endif - -#ifdef PORTQ_DIRSET - DEFINE(PORTQ_DIRSET) -#else - MISSING(PORTQ_DIRSET) -#endif - -#ifdef PORTQ_DIRTGL - DEFINE(PORTQ_DIRTGL) -#else - MISSING(PORTQ_DIRTGL) -#endif - -#ifdef PORTQ_IN - DEFINE(PORTQ_IN) -#else - MISSING(PORTQ_IN) -#endif - -#ifdef PORTQ_INT0MASK - DEFINE(PORTQ_INT0MASK) -#else - MISSING(PORTQ_INT0MASK) -#endif - -#ifdef PORTQ_INT1MASK - DEFINE(PORTQ_INT1MASK) -#else - MISSING(PORTQ_INT1MASK) -#endif - -#ifdef PORTQ_INTCTRL - DEFINE(PORTQ_INTCTRL) -#else - MISSING(PORTQ_INTCTRL) -#endif - -#ifdef PORTQ_INTFLAGS - DEFINE(PORTQ_INTFLAGS) -#else - MISSING(PORTQ_INTFLAGS) -#endif - -#ifdef PORTQ_OUT - DEFINE(PORTQ_OUT) -#else - MISSING(PORTQ_OUT) -#endif - -#ifdef PORTQ_OUTCLR - DEFINE(PORTQ_OUTCLR) -#else - MISSING(PORTQ_OUTCLR) -#endif - -#ifdef PORTQ_OUTSET - DEFINE(PORTQ_OUTSET) -#else - MISSING(PORTQ_OUTSET) -#endif - -#ifdef PORTQ_OUTTGL - DEFINE(PORTQ_OUTTGL) -#else - MISSING(PORTQ_OUTTGL) -#endif - -#ifdef PORTQ_PIN0CTRL - DEFINE(PORTQ_PIN0CTRL) -#else - MISSING(PORTQ_PIN0CTRL) -#endif - -#ifdef PORTQ_PIN1CTRL - DEFINE(PORTQ_PIN1CTRL) -#else - MISSING(PORTQ_PIN1CTRL) -#endif - -#ifdef PORTQ_PIN2CTRL - DEFINE(PORTQ_PIN2CTRL) -#else - MISSING(PORTQ_PIN2CTRL) -#endif - -#ifdef PORTQ_PIN3CTRL - DEFINE(PORTQ_PIN3CTRL) -#else - MISSING(PORTQ_PIN3CTRL) -#endif - -#ifdef PORTQ_PIN4CTRL - DEFINE(PORTQ_PIN4CTRL) -#else - MISSING(PORTQ_PIN4CTRL) -#endif - -#ifdef PORTQ_PIN5CTRL - DEFINE(PORTQ_PIN5CTRL) -#else - MISSING(PORTQ_PIN5CTRL) -#endif - -#ifdef PORTQ_PIN6CTRL - DEFINE(PORTQ_PIN6CTRL) -#else - MISSING(PORTQ_PIN6CTRL) -#endif - -#ifdef PORTQ_PIN7CTRL - DEFINE(PORTQ_PIN7CTRL) -#else - MISSING(PORTQ_PIN7CTRL) -#endif - -#ifdef PORTR_DIR - DEFINE(PORTR_DIR) -#else - MISSING(PORTR_DIR) -#endif - -#ifdef PORTR_DIRCLR - DEFINE(PORTR_DIRCLR) -#else - MISSING(PORTR_DIRCLR) -#endif - -#ifdef PORTR_DIRSET - DEFINE(PORTR_DIRSET) -#else - MISSING(PORTR_DIRSET) -#endif - -#ifdef PORTR_DIRTGL - DEFINE(PORTR_DIRTGL) -#else - MISSING(PORTR_DIRTGL) -#endif - -#ifdef PORTR_IN - DEFINE(PORTR_IN) -#else - MISSING(PORTR_IN) -#endif - -#ifdef PORTR_INT0MASK - DEFINE(PORTR_INT0MASK) -#else - MISSING(PORTR_INT0MASK) -#endif - -#ifdef PORTR_INT1MASK - DEFINE(PORTR_INT1MASK) -#else - MISSING(PORTR_INT1MASK) -#endif - -#ifdef PORTR_INTCTRL - DEFINE(PORTR_INTCTRL) -#else - MISSING(PORTR_INTCTRL) -#endif - -#ifdef PORTR_INTFLAGS - DEFINE(PORTR_INTFLAGS) -#else - MISSING(PORTR_INTFLAGS) -#endif - -#ifdef PORTR_OUT - DEFINE(PORTR_OUT) -#else - MISSING(PORTR_OUT) -#endif - -#ifdef PORTR_OUTCLR - DEFINE(PORTR_OUTCLR) -#else - MISSING(PORTR_OUTCLR) -#endif - -#ifdef PORTR_OUTSET - DEFINE(PORTR_OUTSET) -#else - MISSING(PORTR_OUTSET) -#endif - -#ifdef PORTR_OUTTGL - DEFINE(PORTR_OUTTGL) -#else - MISSING(PORTR_OUTTGL) -#endif - -#ifdef PORTR_PIN0CTRL - DEFINE(PORTR_PIN0CTRL) -#else - MISSING(PORTR_PIN0CTRL) -#endif - -#ifdef PORTR_PIN1CTRL - DEFINE(PORTR_PIN1CTRL) -#else - MISSING(PORTR_PIN1CTRL) -#endif - -#ifdef PORTR_PIN2CTRL - DEFINE(PORTR_PIN2CTRL) -#else - MISSING(PORTR_PIN2CTRL) -#endif - -#ifdef PORTR_PIN3CTRL - DEFINE(PORTR_PIN3CTRL) -#else - MISSING(PORTR_PIN3CTRL) -#endif - -#ifdef PORTR_PIN4CTRL - DEFINE(PORTR_PIN4CTRL) -#else - MISSING(PORTR_PIN4CTRL) -#endif - -#ifdef PORTR_PIN5CTRL - DEFINE(PORTR_PIN5CTRL) -#else - MISSING(PORTR_PIN5CTRL) -#endif - -#ifdef PORTR_PIN6CTRL - DEFINE(PORTR_PIN6CTRL) -#else - MISSING(PORTR_PIN6CTRL) -#endif - -#ifdef PORTR_PIN7CTRL - DEFINE(PORTR_PIN7CTRL) -#else - MISSING(PORTR_PIN7CTRL) -#endif - -#ifdef PRELD - DEFINE(PRELD) -#else - MISSING(PRELD) -#endif - -#ifdef PRR - DEFINE(PRR) -#else - MISSING(PRR) -#endif - -#ifdef PRR0 - DEFINE(PRR0) -#else - MISSING(PRR0) -#endif - -#ifdef PRR1 - DEFINE(PRR1) -#else - MISSING(PRR1) -#endif - -#ifdef PRR2 - DEFINE(PRR2) -#else - MISSING(PRR2) -#endif - -#ifdef PR_PRGEN - DEFINE(PR_PRGEN) -#else - MISSING(PR_PRGEN) -#endif - -#ifdef PR_PRPA - DEFINE(PR_PRPA) -#else - MISSING(PR_PRPA) -#endif - -#ifdef PR_PRPB - DEFINE(PR_PRPB) -#else - MISSING(PR_PRPB) -#endif - -#ifdef PR_PRPC - DEFINE(PR_PRPC) -#else - MISSING(PR_PRPC) -#endif - -#ifdef PR_PRPD - DEFINE(PR_PRPD) -#else - MISSING(PR_PRPD) -#endif - -#ifdef PR_PRPE - DEFINE(PR_PRPE) -#else - MISSING(PR_PRPE) -#endif - -#ifdef PR_PRPF - DEFINE(PR_PRPF) -#else - MISSING(PR_PRPF) -#endif - -#ifdef PS2CON - DEFINE(PS2CON) -#else - MISSING(PS2CON) -#endif - -#ifdef PSOC0 - DEFINE(PSOC0) -#else - MISSING(PSOC0) -#endif - -#ifdef PSOC1 - DEFINE(PSOC1) -#else - MISSING(PSOC1) -#endif - -#ifdef PSOC2 - DEFINE(PSOC2) -#else - MISSING(PSOC2) -#endif - -#ifdef PSYNC - DEFINE(PSYNC) -#else - MISSING(PSYNC) -#endif - -#ifdef PUEA - DEFINE(PUEA) -#else - MISSING(PUEA) -#endif - -#ifdef PUEB - DEFINE(PUEB) -#else - MISSING(PUEB) -#endif - -#ifdef PUEC - DEFINE(PUEC) -#else - MISSING(PUEC) -#endif - -#ifdef PWMCTL - DEFINE(PWMCTL) -#else - MISSING(PWMCTL) -#endif - -#ifdef PWMMSK - DEFINE(PWMMSK) -#else - MISSING(PWMMSK) -#endif - -#ifdef PWMPER - DEFINE(PWMPER) -#else - MISSING(PWMPER) -#endif - -#ifdef PWMSFRQ - DEFINE(PWMSFRQ) -#else - MISSING(PWMSFRQ) -#endif - -#ifdef PWR_ATTEN - DEFINE(PWR_ATTEN) -#else - MISSING(PWR_ATTEN) -#endif - -#ifdef QTCSR - DEFINE(QTCSR) -#else - MISSING(QTCSR) -#endif - -#ifdef RAMAR - DEFINE(RAMAR) -#else - MISSING(RAMAR) -#endif - -#ifdef RAMDR - DEFINE(RAMDR) -#else - MISSING(RAMDR) -#endif - -#ifdef RAMPD - DEFINE(RAMPD) -#else - MISSING(RAMPD) -#endif - -#ifdef RAMPX - DEFINE(RAMPX) -#else - MISSING(RAMPX) -#endif - -#ifdef RAMPY - DEFINE(RAMPY) -#else - MISSING(RAMPY) -#endif - -#ifdef RAMPZ - DEFINE(RAMPZ) -#else - MISSING(RAMPZ) -#endif - -#ifdef RCCTRL - DEFINE(RCCTRL) -#else - MISSING(RCCTRL) -#endif - -#ifdef RDWDR - DEFINE(RDWDR) -#else - MISSING(RDWDR) -#endif - -#ifdef REGCR - DEFINE(REGCR) -#else - MISSING(REGCR) -#endif - -#ifdef RNGCR - DEFINE(RNGCR) -#else - MISSING(RNGCR) -#endif - -#ifdef ROCR - DEFINE(ROCR) -#else - MISSING(ROCR) -#endif - -#ifdef RSTFLR - DEFINE(RSTFLR) -#else - MISSING(RSTFLR) -#endif - -#ifdef RST_CTRL - DEFINE(RST_CTRL) -#else - MISSING(RST_CTRL) -#endif - -#ifdef RST_STATUS - DEFINE(RST_STATUS) -#else - MISSING(RST_STATUS) -#endif - -#ifdef RTC32_CTRL - DEFINE(RTC32_CTRL) -#else - MISSING(RTC32_CTRL) -#endif - -#ifdef RTC32_INTCTRL - DEFINE(RTC32_INTCTRL) -#else - MISSING(RTC32_INTCTRL) -#endif - -#ifdef RTC32_INTFLAGS - DEFINE(RTC32_INTFLAGS) -#else - MISSING(RTC32_INTFLAGS) -#endif - -#ifdef RTC32_SYNCCTRL - DEFINE(RTC32_SYNCCTRL) -#else - MISSING(RTC32_SYNCCTRL) -#endif - -#ifdef RTC_CNT - DEFINE(RTC_CNT) -#else - MISSING(RTC_CNT) -#endif - -#ifdef RTC_COMP - DEFINE(RTC_COMP) -#else - MISSING(RTC_COMP) -#endif - -#ifdef RTC_CTRL - DEFINE(RTC_CTRL) -#else - MISSING(RTC_CTRL) -#endif - -#ifdef RTC_INTCTRL - DEFINE(RTC_INTCTRL) -#else - MISSING(RTC_INTCTRL) -#endif - -#ifdef RTC_INTFLAGS - DEFINE(RTC_INTFLAGS) -#else - MISSING(RTC_INTFLAGS) -#endif - -#ifdef RTC_PER - DEFINE(RTC_PER) -#else - MISSING(RTC_PER) -#endif - -#ifdef RTC_STATUS - DEFINE(RTC_STATUS) -#else - MISSING(RTC_STATUS) -#endif - -#ifdef RTC_TEMP - DEFINE(RTC_TEMP) -#else - MISSING(RTC_TEMP) -#endif - -#ifdef RXB - DEFINE(RXB) -#else - MISSING(RXB) -#endif - -#ifdef RX_CTRL - DEFINE(RX_CTRL) -#else - MISSING(RX_CTRL) -#endif - -#ifdef RX_SYN - DEFINE(RX_SYN) -#else - MISSING(RX_SYN) -#endif - -#ifdef SCBTSRHH - DEFINE(SCBTSRHH) -#else - MISSING(SCBTSRHH) -#endif - -#ifdef SCBTSRHL - DEFINE(SCBTSRHL) -#else - MISSING(SCBTSRHL) -#endif - -#ifdef SCBTSRLH - DEFINE(SCBTSRLH) -#else - MISSING(SCBTSRLH) -#endif - -#ifdef SCBTSRLL - DEFINE(SCBTSRLL) -#else - MISSING(SCBTSRLL) -#endif - -#ifdef SCCNTHH - DEFINE(SCCNTHH) -#else - MISSING(SCCNTHH) -#endif - -#ifdef SCCNTHL - DEFINE(SCCNTHL) -#else - MISSING(SCCNTHL) -#endif - -#ifdef SCCNTLH - DEFINE(SCCNTLH) -#else - MISSING(SCCNTLH) -#endif - -#ifdef SCCNTLL - DEFINE(SCCNTLL) -#else - MISSING(SCCNTLL) -#endif - -#ifdef SCCON - DEFINE(SCCON) -#else - MISSING(SCCON) -#endif - -#ifdef SCCR - DEFINE(SCCR) -#else - MISSING(SCCR) -#endif - -#ifdef SCCR0 - DEFINE(SCCR0) -#else - MISSING(SCCR0) -#endif - -#ifdef SCCR1 - DEFINE(SCCR1) -#else - MISSING(SCCR1) -#endif - -#ifdef SCETU - DEFINE(SCETU) -#else - MISSING(SCETU) -#endif - -#ifdef SCETUH - DEFINE(SCETUH) -#else - MISSING(SCETUH) -#endif - -#ifdef SCETUL - DEFINE(SCETUL) -#else - MISSING(SCETUL) -#endif - -#ifdef SCGT - DEFINE(SCGT) -#else - MISSING(SCGT) -#endif - -#ifdef SCGTH - DEFINE(SCGTH) -#else - MISSING(SCGTH) -#endif - -#ifdef SCGTL - DEFINE(SCGTL) -#else - MISSING(SCGTL) -#endif - -#ifdef SCIBUF - DEFINE(SCIBUF) -#else - MISSING(SCIBUF) -#endif - -#ifdef SCICLK - DEFINE(SCICLK) -#else - MISSING(SCICLK) -#endif - -#ifdef SCICR - DEFINE(SCICR) -#else - MISSING(SCICR) -#endif - -#ifdef SCIER - DEFINE(SCIER) -#else - MISSING(SCIER) -#endif - -#ifdef SCIIR - DEFINE(SCIIR) -#else - MISSING(SCIIR) -#endif - -#ifdef SCIO - DEFINE(SCIO) -#else - MISSING(SCIO) -#endif - -#ifdef SCIRQM - DEFINE(SCIRQM) -#else - MISSING(SCIRQM) -#endif - -#ifdef SCIRQS - DEFINE(SCIRQS) -#else - MISSING(SCIRQS) -#endif - -#ifdef SCISR - DEFINE(SCISR) -#else - MISSING(SCISR) -#endif - -#ifdef SCOCR1HH - DEFINE(SCOCR1HH) -#else - MISSING(SCOCR1HH) -#endif - -#ifdef SCOCR1HL - DEFINE(SCOCR1HL) -#else - MISSING(SCOCR1HL) -#endif - -#ifdef SCOCR1LH - DEFINE(SCOCR1LH) -#else - MISSING(SCOCR1LH) -#endif - -#ifdef SCOCR1LL - DEFINE(SCOCR1LL) -#else - MISSING(SCOCR1LL) -#endif - -#ifdef SCOCR2HH - DEFINE(SCOCR2HH) -#else - MISSING(SCOCR2HH) -#endif - -#ifdef SCOCR2HL - DEFINE(SCOCR2HL) -#else - MISSING(SCOCR2HL) -#endif - -#ifdef SCOCR2LH - DEFINE(SCOCR2LH) -#else - MISSING(SCOCR2LH) -#endif - -#ifdef SCOCR2LL - DEFINE(SCOCR2LL) -#else - MISSING(SCOCR2LL) -#endif - -#ifdef SCOCR3HH - DEFINE(SCOCR3HH) -#else - MISSING(SCOCR3HH) -#endif - -#ifdef SCOCR3HL - DEFINE(SCOCR3HL) -#else - MISSING(SCOCR3HL) -#endif - -#ifdef SCOCR3LH - DEFINE(SCOCR3LH) -#else - MISSING(SCOCR3LH) -#endif - -#ifdef SCOCR3LL - DEFINE(SCOCR3LL) -#else - MISSING(SCOCR3LL) -#endif - -#ifdef SCR - DEFINE(SCR) -#else - MISSING(SCR) -#endif - -#ifdef SCSR - DEFINE(SCSR) -#else - MISSING(SCSR) -#endif - -#ifdef SCSW - DEFINE(SCSW) -#else - MISSING(SCSW) -#endif - -#ifdef SCTSRHH - DEFINE(SCTSRHH) -#else - MISSING(SCTSRHH) -#endif - -#ifdef SCTSRHL - DEFINE(SCTSRHL) -#else - MISSING(SCTSRHL) -#endif - -#ifdef SCTSRLH - DEFINE(SCTSRLH) -#else - MISSING(SCTSRLH) -#endif - -#ifdef SCTSRLL - DEFINE(SCTSRLL) -#else - MISSING(SCTSRLL) -#endif - -#ifdef SCWT0 - DEFINE(SCWT0) -#else - MISSING(SCWT0) -#endif - -#ifdef SCWT1 - DEFINE(SCWT1) -#else - MISSING(SCWT1) -#endif - -#ifdef SCWT2 - DEFINE(SCWT2) -#else - MISSING(SCWT2) -#endif - -#ifdef SCWT3 - DEFINE(SCWT3) -#else - MISSING(SCWT3) -#endif - -#ifdef SFD_VALUE - DEFINE(SFD_VALUE) -#else - MISSING(SFD_VALUE) -#endif - -#ifdef SFIOR - DEFINE(SFIOR) -#else - MISSING(SFIOR) -#endif - -#ifdef SFTCR - DEFINE(SFTCR) -#else - MISSING(SFTCR) -#endif - -#ifdef SHORT_ADDR_0 - DEFINE(SHORT_ADDR_0) -#else - MISSING(SHORT_ADDR_0) -#endif - -#ifdef SHORT_ADDR_1 - DEFINE(SHORT_ADDR_1) -#else - MISSING(SHORT_ADDR_1) -#endif - -#ifdef SIMSK - DEFINE(SIMSK) -#else - MISSING(SIMSK) -#endif - -#ifdef SINDAC - DEFINE(SINDAC) -#else - MISSING(SINDAC) -#endif - -#ifdef SINDACH - DEFINE(SINDACH) -#else - MISSING(SINDACH) -#endif - -#ifdef SINDACL - DEFINE(SINDACL) -#else - MISSING(SINDACL) -#endif - -#ifdef SLEEP_CTRL - DEFINE(SLEEP_CTRL) -#else - MISSING(SLEEP_CTRL) -#endif - -#ifdef SMCR - DEFINE(SMCR) -#else - MISSING(SMCR) -#endif - -#ifdef SMONCR - DEFINE(SMONCR) -#else - MISSING(SMONCR) -#endif - -#ifdef SOSCCALA - DEFINE(SOSCCALA) -#else - MISSING(SOSCCALA) -#endif - -#ifdef SOSCCALB - DEFINE(SOSCCALB) -#else - MISSING(SOSCCALB) -#endif - -#ifdef SP - DEFINE(SP) -#else - MISSING(SP) -#endif - -#ifdef SPCR - DEFINE(SPCR) -#else - MISSING(SPCR) -#endif - -#ifdef SPCR0 - DEFINE(SPCR0) -#else - MISSING(SPCR0) -#endif - -#ifdef SPDR - DEFINE(SPDR) -#else - MISSING(SPDR) -#endif - -#ifdef SPH - DEFINE(SPH) -#else - MISSING(SPH) -#endif - -#ifdef SPIC_CTRL - DEFINE(SPIC_CTRL) -#else - MISSING(SPIC_CTRL) -#endif - -#ifdef SPIC_DATA - DEFINE(SPIC_DATA) -#else - MISSING(SPIC_DATA) -#endif - -#ifdef SPIC_INTCTRL - DEFINE(SPIC_INTCTRL) -#else - MISSING(SPIC_INTCTRL) -#endif - -#ifdef SPIC_STATUS - DEFINE(SPIC_STATUS) -#else - MISSING(SPIC_STATUS) -#endif - -#ifdef SPID_CTRL - DEFINE(SPID_CTRL) -#else - MISSING(SPID_CTRL) -#endif - -#ifdef SPID_DATA - DEFINE(SPID_DATA) -#else - MISSING(SPID_DATA) -#endif - -#ifdef SPID_INTCTRL - DEFINE(SPID_INTCTRL) -#else - MISSING(SPID_INTCTRL) -#endif - -#ifdef SPID_STATUS - DEFINE(SPID_STATUS) -#else - MISSING(SPID_STATUS) -#endif - -#ifdef SPIE_CTRL - DEFINE(SPIE_CTRL) -#else - MISSING(SPIE_CTRL) -#endif - -#ifdef SPIE_DATA - DEFINE(SPIE_DATA) -#else - MISSING(SPIE_DATA) -#endif - -#ifdef SPIE_INTCTRL - DEFINE(SPIE_INTCTRL) -#else - MISSING(SPIE_INTCTRL) -#endif - -#ifdef SPIE_STATUS - DEFINE(SPIE_STATUS) -#else - MISSING(SPIE_STATUS) -#endif - -#ifdef SPIF_CTRL - DEFINE(SPIF_CTRL) -#else - MISSING(SPIF_CTRL) -#endif - -#ifdef SPIF_DATA - DEFINE(SPIF_DATA) -#else - MISSING(SPIF_DATA) -#endif - -#ifdef SPIF_INTCTRL - DEFINE(SPIF_INTCTRL) -#else - MISSING(SPIF_INTCTRL) -#endif - -#ifdef SPIF_STATUS - DEFINE(SPIF_STATUS) -#else - MISSING(SPIF_STATUS) -#endif - -#ifdef SPL - DEFINE(SPL) -#else - MISSING(SPL) -#endif - -#ifdef SPMCR - DEFINE(SPMCR) -#else - MISSING(SPMCR) -#endif - -#ifdef SPMCSR - DEFINE(SPMCSR) -#else - MISSING(SPMCSR) -#endif - -#ifdef SPSR - DEFINE(SPSR) -#else - MISSING(SPSR) -#endif - -#ifdef SPSR0 - DEFINE(SPSR0) -#else - MISSING(SPSR0) -#endif - -#ifdef SPWMCTL - DEFINE(SPWMCTL) -#else - MISSING(SPWMCTL) -#endif - -#ifdef SRCCAL - DEFINE(SRCCAL) -#else - MISSING(SRCCAL) -#endif - -#ifdef SREG - DEFINE(SREG) -#else - MISSING(SREG) -#endif - -#ifdef SSFR - DEFINE(SSFR) -#else - MISSING(SSFR) -#endif - -#ifdef STAT - DEFINE(STAT) -#else - MISSING(STAT) -#endif - -#ifdef SVCR - DEFINE(SVCR) -#else - MISSING(SVCR) -#endif - -#ifdef T0CR - DEFINE(T0CR) -#else - MISSING(T0CR) -#endif - -#ifdef T10IFR - DEFINE(T10IFR) -#else - MISSING(T10IFR) -#endif - -#ifdef T1CR - DEFINE(T1CR) -#else - MISSING(T1CR) -#endif - -#ifdef T2COR - DEFINE(T2COR) -#else - MISSING(T2COR) -#endif - -#ifdef T2CORH - DEFINE(T2CORH) -#else - MISSING(T2CORH) -#endif - -#ifdef T2CORL - DEFINE(T2CORL) -#else - MISSING(T2CORL) -#endif - -#ifdef T2CRA - DEFINE(T2CRA) -#else - MISSING(T2CRA) -#endif - -#ifdef T2CRB - DEFINE(T2CRB) -#else - MISSING(T2CRB) -#endif - -#ifdef T2ICR - DEFINE(T2ICR) -#else - MISSING(T2ICR) -#endif - -#ifdef T2ICRH - DEFINE(T2ICRH) -#else - MISSING(T2ICRH) -#endif - -#ifdef T2ICRL - DEFINE(T2ICRL) -#else - MISSING(T2ICRL) -#endif - -#ifdef T2IFR - DEFINE(T2IFR) -#else - MISSING(T2IFR) -#endif - -#ifdef T2IMR - DEFINE(T2IMR) -#else - MISSING(T2IMR) -#endif - -#ifdef T2MDR - DEFINE(T2MDR) -#else - MISSING(T2MDR) -#endif - -#ifdef T2MRA - DEFINE(T2MRA) -#else - MISSING(T2MRA) -#endif - -#ifdef T2MRB - DEFINE(T2MRB) -#else - MISSING(T2MRB) -#endif - -#ifdef T3CORA - DEFINE(T3CORA) -#else - MISSING(T3CORA) -#endif - -#ifdef T3CORAH - DEFINE(T3CORAH) -#else - MISSING(T3CORAH) -#endif - -#ifdef T3CORAL - DEFINE(T3CORAL) -#else - MISSING(T3CORAL) -#endif - -#ifdef T3CORB - DEFINE(T3CORB) -#else - MISSING(T3CORB) -#endif - -#ifdef T3CORBH - DEFINE(T3CORBH) -#else - MISSING(T3CORBH) -#endif - -#ifdef T3CORBL - DEFINE(T3CORBL) -#else - MISSING(T3CORBL) -#endif - -#ifdef T3CRA - DEFINE(T3CRA) -#else - MISSING(T3CRA) -#endif - -#ifdef T3CRB - DEFINE(T3CRB) -#else - MISSING(T3CRB) -#endif - -#ifdef T3ICR - DEFINE(T3ICR) -#else - MISSING(T3ICR) -#endif - -#ifdef T3ICRH - DEFINE(T3ICRH) -#else - MISSING(T3ICRH) -#endif - -#ifdef T3ICRL - DEFINE(T3ICRL) -#else - MISSING(T3ICRL) -#endif - -#ifdef T3IFR - DEFINE(T3IFR) -#else - MISSING(T3IFR) -#endif - -#ifdef T3IMR - DEFINE(T3IMR) -#else - MISSING(T3IMR) -#endif - -#ifdef T3MRA - DEFINE(T3MRA) -#else - MISSING(T3MRA) -#endif - -#ifdef T3MRB - DEFINE(T3MRB) -#else - MISSING(T3MRB) -#endif - -#ifdef TC1H - DEFINE(TC1H) -#else - MISSING(TC1H) -#endif - -#ifdef TC4H - DEFINE(TC4H) -#else - MISSING(TC4H) -#endif - -#ifdef TCC0_CCA - DEFINE(TCC0_CCA) -#else - MISSING(TCC0_CCA) -#endif - -#ifdef TCC0_CCABUF - DEFINE(TCC0_CCABUF) -#else - MISSING(TCC0_CCABUF) -#endif - -#ifdef TCC0_CCB - DEFINE(TCC0_CCB) -#else - MISSING(TCC0_CCB) -#endif - -#ifdef TCC0_CCBBUF - DEFINE(TCC0_CCBBUF) -#else - MISSING(TCC0_CCBBUF) -#endif - -#ifdef TCC0_CCC - DEFINE(TCC0_CCC) -#else - MISSING(TCC0_CCC) -#endif - -#ifdef TCC0_CCCBUF - DEFINE(TCC0_CCCBUF) -#else - MISSING(TCC0_CCCBUF) -#endif - -#ifdef TCC0_CCD - DEFINE(TCC0_CCD) -#else - MISSING(TCC0_CCD) -#endif - -#ifdef TCC0_CCDBUF - DEFINE(TCC0_CCDBUF) -#else - MISSING(TCC0_CCDBUF) -#endif - -#ifdef TCC0_CNT - DEFINE(TCC0_CNT) -#else - MISSING(TCC0_CNT) -#endif - -#ifdef TCC0_CTRLA - DEFINE(TCC0_CTRLA) -#else - MISSING(TCC0_CTRLA) -#endif - -#ifdef TCC0_CTRLB - DEFINE(TCC0_CTRLB) -#else - MISSING(TCC0_CTRLB) -#endif - -#ifdef TCC0_CTRLC - DEFINE(TCC0_CTRLC) -#else - MISSING(TCC0_CTRLC) -#endif - -#ifdef TCC0_CTRLD - DEFINE(TCC0_CTRLD) -#else - MISSING(TCC0_CTRLD) -#endif - -#ifdef TCC0_CTRLE - DEFINE(TCC0_CTRLE) -#else - MISSING(TCC0_CTRLE) -#endif - -#ifdef TCC0_CTRLFCLR - DEFINE(TCC0_CTRLFCLR) -#else - MISSING(TCC0_CTRLFCLR) -#endif - -#ifdef TCC0_CTRLFSET - DEFINE(TCC0_CTRLFSET) -#else - MISSING(TCC0_CTRLFSET) -#endif - -#ifdef TCC0_CTRLGCLR - DEFINE(TCC0_CTRLGCLR) -#else - MISSING(TCC0_CTRLGCLR) -#endif - -#ifdef TCC0_CTRLGSET - DEFINE(TCC0_CTRLGSET) -#else - MISSING(TCC0_CTRLGSET) -#endif - -#ifdef TCC0_INTCTRLA - DEFINE(TCC0_INTCTRLA) -#else - MISSING(TCC0_INTCTRLA) -#endif - -#ifdef TCC0_INTCTRLB - DEFINE(TCC0_INTCTRLB) -#else - MISSING(TCC0_INTCTRLB) -#endif - -#ifdef TCC0_INTFLAGS - DEFINE(TCC0_INTFLAGS) -#else - MISSING(TCC0_INTFLAGS) -#endif - -#ifdef TCC0_PER - DEFINE(TCC0_PER) -#else - MISSING(TCC0_PER) -#endif - -#ifdef TCC0_PERBUF - DEFINE(TCC0_PERBUF) -#else - MISSING(TCC0_PERBUF) -#endif - -#ifdef TCC0_TEMP - DEFINE(TCC0_TEMP) -#else - MISSING(TCC0_TEMP) -#endif - -#ifdef TCC1_CCA - DEFINE(TCC1_CCA) -#else - MISSING(TCC1_CCA) -#endif - -#ifdef TCC1_CCABUF - DEFINE(TCC1_CCABUF) -#else - MISSING(TCC1_CCABUF) -#endif - -#ifdef TCC1_CCB - DEFINE(TCC1_CCB) -#else - MISSING(TCC1_CCB) -#endif - -#ifdef TCC1_CCBBUF - DEFINE(TCC1_CCBBUF) -#else - MISSING(TCC1_CCBBUF) -#endif - -#ifdef TCC1_CNT - DEFINE(TCC1_CNT) -#else - MISSING(TCC1_CNT) -#endif - -#ifdef TCC1_CTRLA - DEFINE(TCC1_CTRLA) -#else - MISSING(TCC1_CTRLA) -#endif - -#ifdef TCC1_CTRLB - DEFINE(TCC1_CTRLB) -#else - MISSING(TCC1_CTRLB) -#endif - -#ifdef TCC1_CTRLC - DEFINE(TCC1_CTRLC) -#else - MISSING(TCC1_CTRLC) -#endif - -#ifdef TCC1_CTRLD - DEFINE(TCC1_CTRLD) -#else - MISSING(TCC1_CTRLD) -#endif - -#ifdef TCC1_CTRLE - DEFINE(TCC1_CTRLE) -#else - MISSING(TCC1_CTRLE) -#endif - -#ifdef TCC1_CTRLFCLR - DEFINE(TCC1_CTRLFCLR) -#else - MISSING(TCC1_CTRLFCLR) -#endif - -#ifdef TCC1_CTRLFSET - DEFINE(TCC1_CTRLFSET) -#else - MISSING(TCC1_CTRLFSET) -#endif - -#ifdef TCC1_CTRLGCLR - DEFINE(TCC1_CTRLGCLR) -#else - MISSING(TCC1_CTRLGCLR) -#endif - -#ifdef TCC1_CTRLGSET - DEFINE(TCC1_CTRLGSET) -#else - MISSING(TCC1_CTRLGSET) -#endif - -#ifdef TCC1_INTCTRLA - DEFINE(TCC1_INTCTRLA) -#else - MISSING(TCC1_INTCTRLA) -#endif - -#ifdef TCC1_INTCTRLB - DEFINE(TCC1_INTCTRLB) -#else - MISSING(TCC1_INTCTRLB) -#endif - -#ifdef TCC1_INTFLAGS - DEFINE(TCC1_INTFLAGS) -#else - MISSING(TCC1_INTFLAGS) -#endif - -#ifdef TCC1_PER - DEFINE(TCC1_PER) -#else - MISSING(TCC1_PER) -#endif - -#ifdef TCC1_PERBUF - DEFINE(TCC1_PERBUF) -#else - MISSING(TCC1_PERBUF) -#endif - -#ifdef TCC1_TEMP - DEFINE(TCC1_TEMP) -#else - MISSING(TCC1_TEMP) -#endif - -#ifdef TCCR0 - DEFINE(TCCR0) -#else - MISSING(TCCR0) -#endif - -#ifdef TCCR0A - DEFINE(TCCR0A) -#else - MISSING(TCCR0A) -#endif - -#ifdef TCCR0B - DEFINE(TCCR0B) -#else - MISSING(TCCR0B) -#endif - -#ifdef TCCR0C - DEFINE(TCCR0C) -#else - MISSING(TCCR0C) -#endif - -#ifdef TCCR1 - DEFINE(TCCR1) -#else - MISSING(TCCR1) -#endif - -#ifdef TCCR1A - DEFINE(TCCR1A) -#else - MISSING(TCCR1A) -#endif - -#ifdef TCCR1B - DEFINE(TCCR1B) -#else - MISSING(TCCR1B) -#endif - -#ifdef TCCR1C - DEFINE(TCCR1C) -#else - MISSING(TCCR1C) -#endif - -#ifdef TCCR1D - DEFINE(TCCR1D) -#else - MISSING(TCCR1D) -#endif - -#ifdef TCCR1E - DEFINE(TCCR1E) -#else - MISSING(TCCR1E) -#endif - -#ifdef TCCR2 - DEFINE(TCCR2) -#else - MISSING(TCCR2) -#endif - -#ifdef TCCR2A - DEFINE(TCCR2A) -#else - MISSING(TCCR2A) -#endif - -#ifdef TCCR2B - DEFINE(TCCR2B) -#else - MISSING(TCCR2B) -#endif - -#ifdef TCCR3A - DEFINE(TCCR3A) -#else - MISSING(TCCR3A) -#endif - -#ifdef TCCR3B - DEFINE(TCCR3B) -#else - MISSING(TCCR3B) -#endif - -#ifdef TCCR3C - DEFINE(TCCR3C) -#else - MISSING(TCCR3C) -#endif - -#ifdef TCCR4A - DEFINE(TCCR4A) -#else - MISSING(TCCR4A) -#endif - -#ifdef TCCR4B - DEFINE(TCCR4B) -#else - MISSING(TCCR4B) -#endif - -#ifdef TCCR4C - DEFINE(TCCR4C) -#else - MISSING(TCCR4C) -#endif - -#ifdef TCCR4D - DEFINE(TCCR4D) -#else - MISSING(TCCR4D) -#endif - -#ifdef TCCR4E - DEFINE(TCCR4E) -#else - MISSING(TCCR4E) -#endif - -#ifdef TCCR5A - DEFINE(TCCR5A) -#else - MISSING(TCCR5A) -#endif - -#ifdef TCCR5B - DEFINE(TCCR5B) -#else - MISSING(TCCR5B) -#endif - -#ifdef TCCR5C - DEFINE(TCCR5C) -#else - MISSING(TCCR5C) -#endif - -#ifdef TCD0_CCA - DEFINE(TCD0_CCA) -#else - MISSING(TCD0_CCA) -#endif - -#ifdef TCD0_CCABUF - DEFINE(TCD0_CCABUF) -#else - MISSING(TCD0_CCABUF) -#endif - -#ifdef TCD0_CCB - DEFINE(TCD0_CCB) -#else - MISSING(TCD0_CCB) -#endif - -#ifdef TCD0_CCBBUF - DEFINE(TCD0_CCBBUF) -#else - MISSING(TCD0_CCBBUF) -#endif - -#ifdef TCD0_CCC - DEFINE(TCD0_CCC) -#else - MISSING(TCD0_CCC) -#endif - -#ifdef TCD0_CCCBUF - DEFINE(TCD0_CCCBUF) -#else - MISSING(TCD0_CCCBUF) -#endif - -#ifdef TCD0_CCD - DEFINE(TCD0_CCD) -#else - MISSING(TCD0_CCD) -#endif - -#ifdef TCD0_CCDBUF - DEFINE(TCD0_CCDBUF) -#else - MISSING(TCD0_CCDBUF) -#endif - -#ifdef TCD0_CNT - DEFINE(TCD0_CNT) -#else - MISSING(TCD0_CNT) -#endif - -#ifdef TCD0_CTRLA - DEFINE(TCD0_CTRLA) -#else - MISSING(TCD0_CTRLA) -#endif - -#ifdef TCD0_CTRLB - DEFINE(TCD0_CTRLB) -#else - MISSING(TCD0_CTRLB) -#endif - -#ifdef TCD0_CTRLC - DEFINE(TCD0_CTRLC) -#else - MISSING(TCD0_CTRLC) -#endif - -#ifdef TCD0_CTRLD - DEFINE(TCD0_CTRLD) -#else - MISSING(TCD0_CTRLD) -#endif - -#ifdef TCD0_CTRLE - DEFINE(TCD0_CTRLE) -#else - MISSING(TCD0_CTRLE) -#endif - -#ifdef TCD0_CTRLFCLR - DEFINE(TCD0_CTRLFCLR) -#else - MISSING(TCD0_CTRLFCLR) -#endif - -#ifdef TCD0_CTRLFSET - DEFINE(TCD0_CTRLFSET) -#else - MISSING(TCD0_CTRLFSET) -#endif - -#ifdef TCD0_CTRLGCLR - DEFINE(TCD0_CTRLGCLR) -#else - MISSING(TCD0_CTRLGCLR) -#endif - -#ifdef TCD0_CTRLGSET - DEFINE(TCD0_CTRLGSET) -#else - MISSING(TCD0_CTRLGSET) -#endif - -#ifdef TCD0_INTCTRLA - DEFINE(TCD0_INTCTRLA) -#else - MISSING(TCD0_INTCTRLA) -#endif - -#ifdef TCD0_INTCTRLB - DEFINE(TCD0_INTCTRLB) -#else - MISSING(TCD0_INTCTRLB) -#endif - -#ifdef TCD0_INTFLAGS - DEFINE(TCD0_INTFLAGS) -#else - MISSING(TCD0_INTFLAGS) -#endif - -#ifdef TCD0_PER - DEFINE(TCD0_PER) -#else - MISSING(TCD0_PER) -#endif - -#ifdef TCD0_PERBUF - DEFINE(TCD0_PERBUF) -#else - MISSING(TCD0_PERBUF) -#endif - -#ifdef TCD0_TEMP - DEFINE(TCD0_TEMP) -#else - MISSING(TCD0_TEMP) -#endif - -#ifdef TCD1_CCA - DEFINE(TCD1_CCA) -#else - MISSING(TCD1_CCA) -#endif - -#ifdef TCD1_CCABUF - DEFINE(TCD1_CCABUF) -#else - MISSING(TCD1_CCABUF) -#endif - -#ifdef TCD1_CCB - DEFINE(TCD1_CCB) -#else - MISSING(TCD1_CCB) -#endif - -#ifdef TCD1_CCBBUF - DEFINE(TCD1_CCBBUF) -#else - MISSING(TCD1_CCBBUF) -#endif - -#ifdef TCD1_CNT - DEFINE(TCD1_CNT) -#else - MISSING(TCD1_CNT) -#endif - -#ifdef TCD1_CTRLA - DEFINE(TCD1_CTRLA) -#else - MISSING(TCD1_CTRLA) -#endif - -#ifdef TCD1_CTRLB - DEFINE(TCD1_CTRLB) -#else - MISSING(TCD1_CTRLB) -#endif - -#ifdef TCD1_CTRLC - DEFINE(TCD1_CTRLC) -#else - MISSING(TCD1_CTRLC) -#endif - -#ifdef TCD1_CTRLD - DEFINE(TCD1_CTRLD) -#else - MISSING(TCD1_CTRLD) -#endif - -#ifdef TCD1_CTRLE - DEFINE(TCD1_CTRLE) -#else - MISSING(TCD1_CTRLE) -#endif - -#ifdef TCD1_CTRLFCLR - DEFINE(TCD1_CTRLFCLR) -#else - MISSING(TCD1_CTRLFCLR) -#endif - -#ifdef TCD1_CTRLFSET - DEFINE(TCD1_CTRLFSET) -#else - MISSING(TCD1_CTRLFSET) -#endif - -#ifdef TCD1_CTRLGCLR - DEFINE(TCD1_CTRLGCLR) -#else - MISSING(TCD1_CTRLGCLR) -#endif - -#ifdef TCD1_CTRLGSET - DEFINE(TCD1_CTRLGSET) -#else - MISSING(TCD1_CTRLGSET) -#endif - -#ifdef TCD1_INTCTRLA - DEFINE(TCD1_INTCTRLA) -#else - MISSING(TCD1_INTCTRLA) -#endif - -#ifdef TCD1_INTCTRLB - DEFINE(TCD1_INTCTRLB) -#else - MISSING(TCD1_INTCTRLB) -#endif - -#ifdef TCD1_INTFLAGS - DEFINE(TCD1_INTFLAGS) -#else - MISSING(TCD1_INTFLAGS) -#endif - -#ifdef TCD1_PER - DEFINE(TCD1_PER) -#else - MISSING(TCD1_PER) -#endif - -#ifdef TCD1_PERBUF - DEFINE(TCD1_PERBUF) -#else - MISSING(TCD1_PERBUF) -#endif - -#ifdef TCD1_TEMP - DEFINE(TCD1_TEMP) -#else - MISSING(TCD1_TEMP) -#endif - -#ifdef TCE0_CCA - DEFINE(TCE0_CCA) -#else - MISSING(TCE0_CCA) -#endif - -#ifdef TCE0_CCABUF - DEFINE(TCE0_CCABUF) -#else - MISSING(TCE0_CCABUF) -#endif - -#ifdef TCE0_CCB - DEFINE(TCE0_CCB) -#else - MISSING(TCE0_CCB) -#endif - -#ifdef TCE0_CCBBUF - DEFINE(TCE0_CCBBUF) -#else - MISSING(TCE0_CCBBUF) -#endif - -#ifdef TCE0_CCC - DEFINE(TCE0_CCC) -#else - MISSING(TCE0_CCC) -#endif - -#ifdef TCE0_CCCBUF - DEFINE(TCE0_CCCBUF) -#else - MISSING(TCE0_CCCBUF) -#endif - -#ifdef TCE0_CCD - DEFINE(TCE0_CCD) -#else - MISSING(TCE0_CCD) -#endif - -#ifdef TCE0_CCDBUF - DEFINE(TCE0_CCDBUF) -#else - MISSING(TCE0_CCDBUF) -#endif - -#ifdef TCE0_CNT - DEFINE(TCE0_CNT) -#else - MISSING(TCE0_CNT) -#endif - -#ifdef TCE0_CTRLA - DEFINE(TCE0_CTRLA) -#else - MISSING(TCE0_CTRLA) -#endif - -#ifdef TCE0_CTRLB - DEFINE(TCE0_CTRLB) -#else - MISSING(TCE0_CTRLB) -#endif - -#ifdef TCE0_CTRLC - DEFINE(TCE0_CTRLC) -#else - MISSING(TCE0_CTRLC) -#endif - -#ifdef TCE0_CTRLD - DEFINE(TCE0_CTRLD) -#else - MISSING(TCE0_CTRLD) -#endif - -#ifdef TCE0_CTRLE - DEFINE(TCE0_CTRLE) -#else - MISSING(TCE0_CTRLE) -#endif - -#ifdef TCE0_CTRLFCLR - DEFINE(TCE0_CTRLFCLR) -#else - MISSING(TCE0_CTRLFCLR) -#endif - -#ifdef TCE0_CTRLFSET - DEFINE(TCE0_CTRLFSET) -#else - MISSING(TCE0_CTRLFSET) -#endif - -#ifdef TCE0_CTRLGCLR - DEFINE(TCE0_CTRLGCLR) -#else - MISSING(TCE0_CTRLGCLR) -#endif - -#ifdef TCE0_CTRLGSET - DEFINE(TCE0_CTRLGSET) -#else - MISSING(TCE0_CTRLGSET) -#endif - -#ifdef TCE0_INTCTRLA - DEFINE(TCE0_INTCTRLA) -#else - MISSING(TCE0_INTCTRLA) -#endif - -#ifdef TCE0_INTCTRLB - DEFINE(TCE0_INTCTRLB) -#else - MISSING(TCE0_INTCTRLB) -#endif - -#ifdef TCE0_INTFLAGS - DEFINE(TCE0_INTFLAGS) -#else - MISSING(TCE0_INTFLAGS) -#endif - -#ifdef TCE0_PER - DEFINE(TCE0_PER) -#else - MISSING(TCE0_PER) -#endif - -#ifdef TCE0_PERBUF - DEFINE(TCE0_PERBUF) -#else - MISSING(TCE0_PERBUF) -#endif - -#ifdef TCE0_TEMP - DEFINE(TCE0_TEMP) -#else - MISSING(TCE0_TEMP) -#endif - -#ifdef TCE1_CCA - DEFINE(TCE1_CCA) -#else - MISSING(TCE1_CCA) -#endif - -#ifdef TCE1_CCABUF - DEFINE(TCE1_CCABUF) -#else - MISSING(TCE1_CCABUF) -#endif - -#ifdef TCE1_CCB - DEFINE(TCE1_CCB) -#else - MISSING(TCE1_CCB) -#endif - -#ifdef TCE1_CCBBUF - DEFINE(TCE1_CCBBUF) -#else - MISSING(TCE1_CCBBUF) -#endif - -#ifdef TCE1_CNT - DEFINE(TCE1_CNT) -#else - MISSING(TCE1_CNT) -#endif - -#ifdef TCE1_CTRLA - DEFINE(TCE1_CTRLA) -#else - MISSING(TCE1_CTRLA) -#endif - -#ifdef TCE1_CTRLB - DEFINE(TCE1_CTRLB) -#else - MISSING(TCE1_CTRLB) -#endif - -#ifdef TCE1_CTRLC - DEFINE(TCE1_CTRLC) -#else - MISSING(TCE1_CTRLC) -#endif - -#ifdef TCE1_CTRLD - DEFINE(TCE1_CTRLD) -#else - MISSING(TCE1_CTRLD) -#endif - -#ifdef TCE1_CTRLE - DEFINE(TCE1_CTRLE) -#else - MISSING(TCE1_CTRLE) -#endif - -#ifdef TCE1_CTRLFCLR - DEFINE(TCE1_CTRLFCLR) -#else - MISSING(TCE1_CTRLFCLR) -#endif - -#ifdef TCE1_CTRLFSET - DEFINE(TCE1_CTRLFSET) -#else - MISSING(TCE1_CTRLFSET) -#endif - -#ifdef TCE1_CTRLGCLR - DEFINE(TCE1_CTRLGCLR) -#else - MISSING(TCE1_CTRLGCLR) -#endif - -#ifdef TCE1_CTRLGSET - DEFINE(TCE1_CTRLGSET) -#else - MISSING(TCE1_CTRLGSET) -#endif - -#ifdef TCE1_INTCTRLA - DEFINE(TCE1_INTCTRLA) -#else - MISSING(TCE1_INTCTRLA) -#endif - -#ifdef TCE1_INTCTRLB - DEFINE(TCE1_INTCTRLB) -#else - MISSING(TCE1_INTCTRLB) -#endif - -#ifdef TCE1_INTFLAGS - DEFINE(TCE1_INTFLAGS) -#else - MISSING(TCE1_INTFLAGS) -#endif - -#ifdef TCE1_PER - DEFINE(TCE1_PER) -#else - MISSING(TCE1_PER) -#endif - -#ifdef TCE1_PERBUF - DEFINE(TCE1_PERBUF) -#else - MISSING(TCE1_PERBUF) -#endif - -#ifdef TCE1_TEMP - DEFINE(TCE1_TEMP) -#else - MISSING(TCE1_TEMP) -#endif - -#ifdef TCF0_CCA - DEFINE(TCF0_CCA) -#else - MISSING(TCF0_CCA) -#endif - -#ifdef TCF0_CCABUF - DEFINE(TCF0_CCABUF) -#else - MISSING(TCF0_CCABUF) -#endif - -#ifdef TCF0_CCB - DEFINE(TCF0_CCB) -#else - MISSING(TCF0_CCB) -#endif - -#ifdef TCF0_CCBBUF - DEFINE(TCF0_CCBBUF) -#else - MISSING(TCF0_CCBBUF) -#endif - -#ifdef TCF0_CCC - DEFINE(TCF0_CCC) -#else - MISSING(TCF0_CCC) -#endif - -#ifdef TCF0_CCCBUF - DEFINE(TCF0_CCCBUF) -#else - MISSING(TCF0_CCCBUF) -#endif - -#ifdef TCF0_CCD - DEFINE(TCF0_CCD) -#else - MISSING(TCF0_CCD) -#endif - -#ifdef TCF0_CCDBUF - DEFINE(TCF0_CCDBUF) -#else - MISSING(TCF0_CCDBUF) -#endif - -#ifdef TCF0_CNT - DEFINE(TCF0_CNT) -#else - MISSING(TCF0_CNT) -#endif - -#ifdef TCF0_CTRLA - DEFINE(TCF0_CTRLA) -#else - MISSING(TCF0_CTRLA) -#endif - -#ifdef TCF0_CTRLB - DEFINE(TCF0_CTRLB) -#else - MISSING(TCF0_CTRLB) -#endif - -#ifdef TCF0_CTRLC - DEFINE(TCF0_CTRLC) -#else - MISSING(TCF0_CTRLC) -#endif - -#ifdef TCF0_CTRLD - DEFINE(TCF0_CTRLD) -#else - MISSING(TCF0_CTRLD) -#endif - -#ifdef TCF0_CTRLE - DEFINE(TCF0_CTRLE) -#else - MISSING(TCF0_CTRLE) -#endif - -#ifdef TCF0_CTRLFCLR - DEFINE(TCF0_CTRLFCLR) -#else - MISSING(TCF0_CTRLFCLR) -#endif - -#ifdef TCF0_CTRLFSET - DEFINE(TCF0_CTRLFSET) -#else - MISSING(TCF0_CTRLFSET) -#endif - -#ifdef TCF0_CTRLGCLR - DEFINE(TCF0_CTRLGCLR) -#else - MISSING(TCF0_CTRLGCLR) -#endif - -#ifdef TCF0_CTRLGSET - DEFINE(TCF0_CTRLGSET) -#else - MISSING(TCF0_CTRLGSET) -#endif - -#ifdef TCF0_INTCTRLA - DEFINE(TCF0_INTCTRLA) -#else - MISSING(TCF0_INTCTRLA) -#endif - -#ifdef TCF0_INTCTRLB - DEFINE(TCF0_INTCTRLB) -#else - MISSING(TCF0_INTCTRLB) -#endif - -#ifdef TCF0_INTFLAGS - DEFINE(TCF0_INTFLAGS) -#else - MISSING(TCF0_INTFLAGS) -#endif - -#ifdef TCF0_PER - DEFINE(TCF0_PER) -#else - MISSING(TCF0_PER) -#endif - -#ifdef TCF0_PERBUF - DEFINE(TCF0_PERBUF) -#else - MISSING(TCF0_PERBUF) -#endif - -#ifdef TCF0_TEMP - DEFINE(TCF0_TEMP) -#else - MISSING(TCF0_TEMP) -#endif - -#ifdef TCF1_CCA - DEFINE(TCF1_CCA) -#else - MISSING(TCF1_CCA) -#endif - -#ifdef TCF1_CCABUF - DEFINE(TCF1_CCABUF) -#else - MISSING(TCF1_CCABUF) -#endif - -#ifdef TCF1_CCB - DEFINE(TCF1_CCB) -#else - MISSING(TCF1_CCB) -#endif - -#ifdef TCF1_CCBBUF - DEFINE(TCF1_CCBBUF) -#else - MISSING(TCF1_CCBBUF) -#endif - -#ifdef TCF1_CNT - DEFINE(TCF1_CNT) -#else - MISSING(TCF1_CNT) -#endif - -#ifdef TCF1_CTRLA - DEFINE(TCF1_CTRLA) -#else - MISSING(TCF1_CTRLA) -#endif - -#ifdef TCF1_CTRLB - DEFINE(TCF1_CTRLB) -#else - MISSING(TCF1_CTRLB) -#endif - -#ifdef TCF1_CTRLC - DEFINE(TCF1_CTRLC) -#else - MISSING(TCF1_CTRLC) -#endif - -#ifdef TCF1_CTRLD - DEFINE(TCF1_CTRLD) -#else - MISSING(TCF1_CTRLD) -#endif - -#ifdef TCF1_CTRLE - DEFINE(TCF1_CTRLE) -#else - MISSING(TCF1_CTRLE) -#endif - -#ifdef TCF1_CTRLFCLR - DEFINE(TCF1_CTRLFCLR) -#else - MISSING(TCF1_CTRLFCLR) -#endif - -#ifdef TCF1_CTRLFSET - DEFINE(TCF1_CTRLFSET) -#else - MISSING(TCF1_CTRLFSET) -#endif - -#ifdef TCF1_CTRLGCLR - DEFINE(TCF1_CTRLGCLR) -#else - MISSING(TCF1_CTRLGCLR) -#endif - -#ifdef TCF1_CTRLGSET - DEFINE(TCF1_CTRLGSET) -#else - MISSING(TCF1_CTRLGSET) -#endif - -#ifdef TCF1_INTCTRLA - DEFINE(TCF1_INTCTRLA) -#else - MISSING(TCF1_INTCTRLA) -#endif - -#ifdef TCF1_INTCTRLB - DEFINE(TCF1_INTCTRLB) -#else - MISSING(TCF1_INTCTRLB) -#endif - -#ifdef TCF1_INTFLAGS - DEFINE(TCF1_INTFLAGS) -#else - MISSING(TCF1_INTFLAGS) -#endif - -#ifdef TCF1_PER - DEFINE(TCF1_PER) -#else - MISSING(TCF1_PER) -#endif - -#ifdef TCF1_PERBUF - DEFINE(TCF1_PERBUF) -#else - MISSING(TCF1_PERBUF) -#endif - -#ifdef TCF1_TEMP - DEFINE(TCF1_TEMP) -#else - MISSING(TCF1_TEMP) -#endif - -#ifdef TCNT0 - DEFINE(TCNT0) -#else - MISSING(TCNT0) -#endif - -#ifdef TCNT0H - DEFINE(TCNT0H) -#else - MISSING(TCNT0H) -#endif - -#ifdef TCNT0L - DEFINE(TCNT0L) -#else - MISSING(TCNT0L) -#endif - -#ifdef TCNT1 - DEFINE(TCNT1) -#else - MISSING(TCNT1) -#endif - -#ifdef TCNT1H - DEFINE(TCNT1H) -#else - MISSING(TCNT1H) -#endif - -#ifdef TCNT1L - DEFINE(TCNT1L) -#else - MISSING(TCNT1L) -#endif - -#ifdef TCNT2 - DEFINE(TCNT2) -#else - MISSING(TCNT2) -#endif - -#ifdef TCNT3 - DEFINE(TCNT3) -#else - MISSING(TCNT3) -#endif - -#ifdef TCNT3H - DEFINE(TCNT3H) -#else - MISSING(TCNT3H) -#endif - -#ifdef TCNT3L - DEFINE(TCNT3L) -#else - MISSING(TCNT3L) -#endif - -#ifdef TCNT4 - DEFINE(TCNT4) -#else - MISSING(TCNT4) -#endif - -#ifdef TCNT4H - DEFINE(TCNT4H) -#else - MISSING(TCNT4H) -#endif - -#ifdef TCNT4L - DEFINE(TCNT4L) -#else - MISSING(TCNT4L) -#endif - -#ifdef TCNT5 - DEFINE(TCNT5) -#else - MISSING(TCNT5) -#endif - -#ifdef TCNT5H - DEFINE(TCNT5H) -#else - MISSING(TCNT5H) -#endif - -#ifdef TCNT5L - DEFINE(TCNT5L) -#else - MISSING(TCNT5L) -#endif - -#ifdef TIFR - DEFINE(TIFR) -#else - MISSING(TIFR) -#endif - -#ifdef TIFR0 - DEFINE(TIFR0) -#else - MISSING(TIFR0) -#endif - -#ifdef TIFR1 - DEFINE(TIFR1) -#else - MISSING(TIFR1) -#endif - -#ifdef TIFR2 - DEFINE(TIFR2) -#else - MISSING(TIFR2) -#endif - -#ifdef TIFR3 - DEFINE(TIFR3) -#else - MISSING(TIFR3) -#endif - -#ifdef TIFR4 - DEFINE(TIFR4) -#else - MISSING(TIFR4) -#endif - -#ifdef TIFR5 - DEFINE(TIFR5) -#else - MISSING(TIFR5) -#endif - -#ifdef TIMSK - DEFINE(TIMSK) -#else - MISSING(TIMSK) -#endif - -#ifdef TIMSK0 - DEFINE(TIMSK0) -#else - MISSING(TIMSK0) -#endif - -#ifdef TIMSK1 - DEFINE(TIMSK1) -#else - MISSING(TIMSK1) -#endif - -#ifdef TIMSK2 - DEFINE(TIMSK2) -#else - MISSING(TIMSK2) -#endif - -#ifdef TIMSK3 - DEFINE(TIMSK3) -#else - MISSING(TIMSK3) -#endif - -#ifdef TIMSK4 - DEFINE(TIMSK4) -#else - MISSING(TIMSK4) -#endif - -#ifdef TIMSK5 - DEFINE(TIMSK5) -#else - MISSING(TIMSK5) -#endif - -#ifdef TRXFBEND - DEFINE(TRXFBEND) -#else - MISSING(TRXFBEND) -#endif - -#ifdef TRXFBST - DEFINE(TRXFBST) -#else - MISSING(TRXFBST) -#endif - -#ifdef TRXPR - DEFINE(TRXPR) -#else - MISSING(TRXPR) -#endif - -#ifdef TRX_CTRL_0 - DEFINE(TRX_CTRL_0) -#else - MISSING(TRX_CTRL_0) -#endif - -#ifdef TRX_CTRL_1 - DEFINE(TRX_CTRL_1) -#else - MISSING(TRX_CTRL_1) -#endif - -#ifdef TRX_CTRL_2 - DEFINE(TRX_CTRL_2) -#else - MISSING(TRX_CTRL_2) -#endif - -#ifdef TRX_STATE - DEFINE(TRX_STATE) -#else - MISSING(TRX_STATE) -#endif - -#ifdef TRX_STATUS - DEFINE(TRX_STATUS) -#else - MISSING(TRX_STATUS) -#endif - -#ifdef TSCR - DEFINE(TSCR) -#else - MISSING(TSCR) -#endif - -#ifdef TST_CTRL_DIGI - DEFINE(TST_CTRL_DIGI) -#else - MISSING(TST_CTRL_DIGI) -#endif - -#ifdef TST_RX_LENGTH - DEFINE(TST_RX_LENGTH) -#else - MISSING(TST_RX_LENGTH) -#endif - -#ifdef TWAMR - DEFINE(TWAMR) -#else - MISSING(TWAMR) -#endif - -#ifdef TWAR - DEFINE(TWAR) -#else - MISSING(TWAR) -#endif - -#ifdef TWBCSR - DEFINE(TWBCSR) -#else - MISSING(TWBCSR) -#endif - -#ifdef TWBR - DEFINE(TWBR) -#else - MISSING(TWBR) -#endif - -#ifdef TWCR - DEFINE(TWCR) -#else - MISSING(TWCR) -#endif - -#ifdef TWDR - DEFINE(TWDR) -#else - MISSING(TWDR) -#endif - -#ifdef TWHSR - DEFINE(TWHSR) -#else - MISSING(TWHSR) -#endif - -#ifdef TWIC_CTRL - DEFINE(TWIC_CTRL) -#else - MISSING(TWIC_CTRL) -#endif - -#ifdef TWIC_MASTER_ADDR - DEFINE(TWIC_MASTER_ADDR) -#else - MISSING(TWIC_MASTER_ADDR) -#endif - -#ifdef TWIC_MASTER_BAUD - DEFINE(TWIC_MASTER_BAUD) -#else - MISSING(TWIC_MASTER_BAUD) -#endif - -#ifdef TWIC_MASTER_CTRLA - DEFINE(TWIC_MASTER_CTRLA) -#else - MISSING(TWIC_MASTER_CTRLA) -#endif - -#ifdef TWIC_MASTER_CTRLB - DEFINE(TWIC_MASTER_CTRLB) -#else - MISSING(TWIC_MASTER_CTRLB) -#endif - -#ifdef TWIC_MASTER_CTRLC - DEFINE(TWIC_MASTER_CTRLC) -#else - MISSING(TWIC_MASTER_CTRLC) -#endif - -#ifdef TWIC_MASTER_DATA - DEFINE(TWIC_MASTER_DATA) -#else - MISSING(TWIC_MASTER_DATA) -#endif - -#ifdef TWIC_MASTER_STATUS - DEFINE(TWIC_MASTER_STATUS) -#else - MISSING(TWIC_MASTER_STATUS) -#endif - -#ifdef TWIC_SLAVE_ADDR - DEFINE(TWIC_SLAVE_ADDR) -#else - MISSING(TWIC_SLAVE_ADDR) -#endif - -#ifdef TWIC_SLAVE_ADDRMASK - DEFINE(TWIC_SLAVE_ADDRMASK) -#else - MISSING(TWIC_SLAVE_ADDRMASK) -#endif - -#ifdef TWIC_SLAVE_CTRLA - DEFINE(TWIC_SLAVE_CTRLA) -#else - MISSING(TWIC_SLAVE_CTRLA) -#endif - -#ifdef TWIC_SLAVE_CTRLB - DEFINE(TWIC_SLAVE_CTRLB) -#else - MISSING(TWIC_SLAVE_CTRLB) -#endif - -#ifdef TWIC_SLAVE_DATA - DEFINE(TWIC_SLAVE_DATA) -#else - MISSING(TWIC_SLAVE_DATA) -#endif - -#ifdef TWIC_SLAVE_STATUS - DEFINE(TWIC_SLAVE_STATUS) -#else - MISSING(TWIC_SLAVE_STATUS) -#endif - -#ifdef TWID_CTRL - DEFINE(TWID_CTRL) -#else - MISSING(TWID_CTRL) -#endif - -#ifdef TWID_MASTER_ADDR - DEFINE(TWID_MASTER_ADDR) -#else - MISSING(TWID_MASTER_ADDR) -#endif - -#ifdef TWID_MASTER_BAUD - DEFINE(TWID_MASTER_BAUD) -#else - MISSING(TWID_MASTER_BAUD) -#endif - -#ifdef TWID_MASTER_CTRLA - DEFINE(TWID_MASTER_CTRLA) -#else - MISSING(TWID_MASTER_CTRLA) -#endif - -#ifdef TWID_MASTER_CTRLB - DEFINE(TWID_MASTER_CTRLB) -#else - MISSING(TWID_MASTER_CTRLB) -#endif - -#ifdef TWID_MASTER_CTRLC - DEFINE(TWID_MASTER_CTRLC) -#else - MISSING(TWID_MASTER_CTRLC) -#endif - -#ifdef TWID_MASTER_DATA - DEFINE(TWID_MASTER_DATA) -#else - MISSING(TWID_MASTER_DATA) -#endif - -#ifdef TWID_MASTER_STATUS - DEFINE(TWID_MASTER_STATUS) -#else - MISSING(TWID_MASTER_STATUS) -#endif - -#ifdef TWID_SLAVE_ADDR - DEFINE(TWID_SLAVE_ADDR) -#else - MISSING(TWID_SLAVE_ADDR) -#endif - -#ifdef TWID_SLAVE_ADDRMASK - DEFINE(TWID_SLAVE_ADDRMASK) -#else - MISSING(TWID_SLAVE_ADDRMASK) -#endif - -#ifdef TWID_SLAVE_CTRLA - DEFINE(TWID_SLAVE_CTRLA) -#else - MISSING(TWID_SLAVE_CTRLA) -#endif - -#ifdef TWID_SLAVE_CTRLB - DEFINE(TWID_SLAVE_CTRLB) -#else - MISSING(TWID_SLAVE_CTRLB) -#endif - -#ifdef TWID_SLAVE_DATA - DEFINE(TWID_SLAVE_DATA) -#else - MISSING(TWID_SLAVE_DATA) -#endif - -#ifdef TWID_SLAVE_STATUS - DEFINE(TWID_SLAVE_STATUS) -#else - MISSING(TWID_SLAVE_STATUS) -#endif - -#ifdef TWIE_CTRL - DEFINE(TWIE_CTRL) -#else - MISSING(TWIE_CTRL) -#endif - -#ifdef TWIE_MASTER_ADDR - DEFINE(TWIE_MASTER_ADDR) -#else - MISSING(TWIE_MASTER_ADDR) -#endif - -#ifdef TWIE_MASTER_BAUD - DEFINE(TWIE_MASTER_BAUD) -#else - MISSING(TWIE_MASTER_BAUD) -#endif - -#ifdef TWIE_MASTER_CTRLA - DEFINE(TWIE_MASTER_CTRLA) -#else - MISSING(TWIE_MASTER_CTRLA) -#endif - -#ifdef TWIE_MASTER_CTRLB - DEFINE(TWIE_MASTER_CTRLB) -#else - MISSING(TWIE_MASTER_CTRLB) -#endif - -#ifdef TWIE_MASTER_CTRLC - DEFINE(TWIE_MASTER_CTRLC) -#else - MISSING(TWIE_MASTER_CTRLC) -#endif - -#ifdef TWIE_MASTER_DATA - DEFINE(TWIE_MASTER_DATA) -#else - MISSING(TWIE_MASTER_DATA) -#endif - -#ifdef TWIE_MASTER_STATUS - DEFINE(TWIE_MASTER_STATUS) -#else - MISSING(TWIE_MASTER_STATUS) -#endif - -#ifdef TWIE_SLAVE_ADDR - DEFINE(TWIE_SLAVE_ADDR) -#else - MISSING(TWIE_SLAVE_ADDR) -#endif - -#ifdef TWIE_SLAVE_ADDRMASK - DEFINE(TWIE_SLAVE_ADDRMASK) -#else - MISSING(TWIE_SLAVE_ADDRMASK) -#endif - -#ifdef TWIE_SLAVE_CTRLA - DEFINE(TWIE_SLAVE_CTRLA) -#else - MISSING(TWIE_SLAVE_CTRLA) -#endif - -#ifdef TWIE_SLAVE_CTRLB - DEFINE(TWIE_SLAVE_CTRLB) -#else - MISSING(TWIE_SLAVE_CTRLB) -#endif - -#ifdef TWIE_SLAVE_DATA - DEFINE(TWIE_SLAVE_DATA) -#else - MISSING(TWIE_SLAVE_DATA) -#endif - -#ifdef TWIE_SLAVE_STATUS - DEFINE(TWIE_SLAVE_STATUS) -#else - MISSING(TWIE_SLAVE_STATUS) -#endif - -#ifdef TWIF_CTRL - DEFINE(TWIF_CTRL) -#else - MISSING(TWIF_CTRL) -#endif - -#ifdef TWIF_MASTER_ADDR - DEFINE(TWIF_MASTER_ADDR) -#else - MISSING(TWIF_MASTER_ADDR) -#endif - -#ifdef TWIF_MASTER_BAUD - DEFINE(TWIF_MASTER_BAUD) -#else - MISSING(TWIF_MASTER_BAUD) -#endif - -#ifdef TWIF_MASTER_CTRLA - DEFINE(TWIF_MASTER_CTRLA) -#else - MISSING(TWIF_MASTER_CTRLA) -#endif - -#ifdef TWIF_MASTER_CTRLB - DEFINE(TWIF_MASTER_CTRLB) -#else - MISSING(TWIF_MASTER_CTRLB) -#endif - -#ifdef TWIF_MASTER_CTRLC - DEFINE(TWIF_MASTER_CTRLC) -#else - MISSING(TWIF_MASTER_CTRLC) -#endif - -#ifdef TWIF_MASTER_DATA - DEFINE(TWIF_MASTER_DATA) -#else - MISSING(TWIF_MASTER_DATA) -#endif - -#ifdef TWIF_MASTER_STATUS - DEFINE(TWIF_MASTER_STATUS) -#else - MISSING(TWIF_MASTER_STATUS) -#endif - -#ifdef TWIF_SLAVE_ADDR - DEFINE(TWIF_SLAVE_ADDR) -#else - MISSING(TWIF_SLAVE_ADDR) -#endif - -#ifdef TWIF_SLAVE_ADDRMASK - DEFINE(TWIF_SLAVE_ADDRMASK) -#else - MISSING(TWIF_SLAVE_ADDRMASK) -#endif - -#ifdef TWIF_SLAVE_CTRLA - DEFINE(TWIF_SLAVE_CTRLA) -#else - MISSING(TWIF_SLAVE_CTRLA) -#endif - -#ifdef TWIF_SLAVE_CTRLB - DEFINE(TWIF_SLAVE_CTRLB) -#else - MISSING(TWIF_SLAVE_CTRLB) -#endif - -#ifdef TWIF_SLAVE_DATA - DEFINE(TWIF_SLAVE_DATA) -#else - MISSING(TWIF_SLAVE_DATA) -#endif - -#ifdef TWIF_SLAVE_STATUS - DEFINE(TWIF_SLAVE_STATUS) -#else - MISSING(TWIF_SLAVE_STATUS) -#endif - -#ifdef TWIHSR - DEFINE(TWIHSR) -#else - MISSING(TWIHSR) -#endif - -#ifdef TWSA - DEFINE(TWSA) -#else - MISSING(TWSA) -#endif - -#ifdef TWSAM - DEFINE(TWSAM) -#else - MISSING(TWSAM) -#endif - -#ifdef TWSCRA - DEFINE(TWSCRA) -#else - MISSING(TWSCRA) -#endif - -#ifdef TWSCRB - DEFINE(TWSCRB) -#else - MISSING(TWSCRB) -#endif - -#ifdef TWSD - DEFINE(TWSD) -#else - MISSING(TWSD) -#endif - -#ifdef TWSR - DEFINE(TWSR) -#else - MISSING(TWSR) -#endif - -#ifdef TWSSRA - DEFINE(TWSSRA) -#else - MISSING(TWSSRA) -#endif - -#ifdef TXB - DEFINE(TXB) -#else - MISSING(TXB) -#endif - -#ifdef TX_CNTL - DEFINE(TX_CNTL) -#else - MISSING(TX_CNTL) -#endif - -#ifdef UBRR - DEFINE(UBRR) -#else - MISSING(UBRR) -#endif - -#ifdef UBRR0 - DEFINE(UBRR0) -#else - MISSING(UBRR0) -#endif - -#ifdef UBRR0H - DEFINE(UBRR0H) -#else - MISSING(UBRR0H) -#endif - -#ifdef UBRR0L - DEFINE(UBRR0L) -#else - MISSING(UBRR0L) -#endif - -#ifdef UBRR1 - DEFINE(UBRR1) -#else - MISSING(UBRR1) -#endif - -#ifdef UBRR1H - DEFINE(UBRR1H) -#else - MISSING(UBRR1H) -#endif - -#ifdef UBRR1L - DEFINE(UBRR1L) -#else - MISSING(UBRR1L) -#endif - -#ifdef UBRR2 - DEFINE(UBRR2) -#else - MISSING(UBRR2) -#endif - -#ifdef UBRR2H - DEFINE(UBRR2H) -#else - MISSING(UBRR2H) -#endif - -#ifdef UBRR2L - DEFINE(UBRR2L) -#else - MISSING(UBRR2L) -#endif - -#ifdef UBRR3 - DEFINE(UBRR3) -#else - MISSING(UBRR3) -#endif - -#ifdef UBRR3H - DEFINE(UBRR3H) -#else - MISSING(UBRR3H) -#endif - -#ifdef UBRR3L - DEFINE(UBRR3L) -#else - MISSING(UBRR3L) -#endif - -#ifdef UBRRH - DEFINE(UBRRH) -#else - MISSING(UBRRH) -#endif - -#ifdef UBRRHI - DEFINE(UBRRHI) -#else - MISSING(UBRRHI) -#endif - -#ifdef UBRRL - DEFINE(UBRRL) -#else - MISSING(UBRRL) -#endif - -#ifdef UBRRLO - DEFINE(UBRRLO) -#else - MISSING(UBRRLO) -#endif - -#ifdef UCR - DEFINE(UCR) -#else - MISSING(UCR) -#endif - -#ifdef UCRA - DEFINE(UCRA) -#else - MISSING(UCRA) -#endif - -#ifdef UCRB - DEFINE(UCRB) -#else - MISSING(UCRB) -#endif - -#ifdef UCSR0A - DEFINE(UCSR0A) -#else - MISSING(UCSR0A) -#endif - -#ifdef UCSR0B - DEFINE(UCSR0B) -#else - MISSING(UCSR0B) -#endif - -#ifdef UCSR0C - DEFINE(UCSR0C) -#else - MISSING(UCSR0C) -#endif - -#ifdef UCSR1A - DEFINE(UCSR1A) -#else - MISSING(UCSR1A) -#endif - -#ifdef UCSR1B - DEFINE(UCSR1B) -#else - MISSING(UCSR1B) -#endif - -#ifdef UCSR1C - DEFINE(UCSR1C) -#else - MISSING(UCSR1C) -#endif - -#ifdef UCSR1D - DEFINE(UCSR1D) -#else - MISSING(UCSR1D) -#endif - -#ifdef UCSR2A - DEFINE(UCSR2A) -#else - MISSING(UCSR2A) -#endif - -#ifdef UCSR2B - DEFINE(UCSR2B) -#else - MISSING(UCSR2B) -#endif - -#ifdef UCSR2C - DEFINE(UCSR2C) -#else - MISSING(UCSR2C) -#endif - -#ifdef UCSR3A - DEFINE(UCSR3A) -#else - MISSING(UCSR3A) -#endif - -#ifdef UCSR3B - DEFINE(UCSR3B) -#else - MISSING(UCSR3B) -#endif - -#ifdef UCSR3C - DEFINE(UCSR3C) -#else - MISSING(UCSR3C) -#endif - -#ifdef UCSRA - DEFINE(UCSRA) -#else - MISSING(UCSRA) -#endif - -#ifdef UCSRB - DEFINE(UCSRB) -#else - MISSING(UCSRB) -#endif - -#ifdef UCSRC - DEFINE(UCSRC) -#else - MISSING(UCSRC) -#endif - -#ifdef UDADDR - DEFINE(UDADDR) -#else - MISSING(UDADDR) -#endif - -#ifdef UDCON - DEFINE(UDCON) -#else - MISSING(UDCON) -#endif - -#ifdef UDFNUM - DEFINE(UDFNUM) -#else - MISSING(UDFNUM) -#endif - -#ifdef UDFNUMH - DEFINE(UDFNUMH) -#else - MISSING(UDFNUMH) -#endif - -#ifdef UDFNUML - DEFINE(UDFNUML) -#else - MISSING(UDFNUML) -#endif - -#ifdef UDIEN - DEFINE(UDIEN) -#else - MISSING(UDIEN) -#endif - -#ifdef UDINT - DEFINE(UDINT) -#else - MISSING(UDINT) -#endif - -#ifdef UDMFN - DEFINE(UDMFN) -#else - MISSING(UDMFN) -#endif - -#ifdef UDPADD - DEFINE(UDPADD) -#else - MISSING(UDPADD) -#endif - -#ifdef UDPADDH - DEFINE(UDPADDH) -#else - MISSING(UDPADDH) -#endif - -#ifdef UDPADDL - DEFINE(UDPADDL) -#else - MISSING(UDPADDL) -#endif - -#ifdef UDR - DEFINE(UDR) -#else - MISSING(UDR) -#endif - -#ifdef UDR0 - DEFINE(UDR0) -#else - MISSING(UDR0) -#endif - -#ifdef UDR1 - DEFINE(UDR1) -#else - MISSING(UDR1) -#endif - -#ifdef UDR2 - DEFINE(UDR2) -#else - MISSING(UDR2) -#endif - -#ifdef UDR3 - DEFINE(UDR3) -#else - MISSING(UDR3) -#endif - -#ifdef UDTST - DEFINE(UDTST) -#else - MISSING(UDTST) -#endif - -#ifdef UEBCHX - DEFINE(UEBCHX) -#else - MISSING(UEBCHX) -#endif - -#ifdef UEBCLX - DEFINE(UEBCLX) -#else - MISSING(UEBCLX) -#endif - -#ifdef UEBCX - DEFINE(UEBCX) -#else - MISSING(UEBCX) -#endif - -#ifdef UECFG0X - DEFINE(UECFG0X) -#else - MISSING(UECFG0X) -#endif - -#ifdef UECFG1X - DEFINE(UECFG1X) -#else - MISSING(UECFG1X) -#endif - -#ifdef UECONX - DEFINE(UECONX) -#else - MISSING(UECONX) -#endif - -#ifdef UEDATX - DEFINE(UEDATX) -#else - MISSING(UEDATX) -#endif - -#ifdef UEIENX - DEFINE(UEIENX) -#else - MISSING(UEIENX) -#endif - -#ifdef UEINT - DEFINE(UEINT) -#else - MISSING(UEINT) -#endif - -#ifdef UEINTX - DEFINE(UEINTX) -#else - MISSING(UEINTX) -#endif - -#ifdef UENUM - DEFINE(UENUM) -#else - MISSING(UENUM) -#endif - -#ifdef UERST - DEFINE(UERST) -#else - MISSING(UERST) -#endif - -#ifdef UESTA0X - DEFINE(UESTA0X) -#else - MISSING(UESTA0X) -#endif - -#ifdef UESTA1X - DEFINE(UESTA1X) -#else - MISSING(UESTA1X) -#endif - -#ifdef UHADDR - DEFINE(UHADDR) -#else - MISSING(UHADDR) -#endif - -#ifdef UHCON - DEFINE(UHCON) -#else - MISSING(UHCON) -#endif - -#ifdef UHCR - DEFINE(UHCR) -#else - MISSING(UHCR) -#endif - -#ifdef UHFLEN - DEFINE(UHFLEN) -#else - MISSING(UHFLEN) -#endif - -#ifdef UHFNUM - DEFINE(UHFNUM) -#else - MISSING(UHFNUM) -#endif - -#ifdef UHFNUMH - DEFINE(UHFNUMH) -#else - MISSING(UHFNUMH) -#endif - -#ifdef UHFNUML - DEFINE(UHFNUML) -#else - MISSING(UHFNUML) -#endif - -#ifdef UHIEN - DEFINE(UHIEN) -#else - MISSING(UHIEN) -#endif - -#ifdef UHINT - DEFINE(UHINT) -#else - MISSING(UHINT) -#endif - -#ifdef UHSR - DEFINE(UHSR) -#else - MISSING(UHSR) -#endif - -#ifdef UHWCON - DEFINE(UHWCON) -#else - MISSING(UHWCON) -#endif - -#ifdef UPBCHX - DEFINE(UPBCHX) -#else - MISSING(UPBCHX) -#endif - -#ifdef UPBCLX - DEFINE(UPBCLX) -#else - MISSING(UPBCLX) -#endif - -#ifdef UPBCX - DEFINE(UPBCX) -#else - MISSING(UPBCX) -#endif - -#ifdef UPBCXH - DEFINE(UPBCXH) -#else - MISSING(UPBCXH) -#endif - -#ifdef UPBCXL - DEFINE(UPBCXL) -#else - MISSING(UPBCXL) -#endif - -#ifdef UPCFG0X - DEFINE(UPCFG0X) -#else - MISSING(UPCFG0X) -#endif - -#ifdef UPCFG1X - DEFINE(UPCFG1X) -#else - MISSING(UPCFG1X) -#endif - -#ifdef UPCFG2X - DEFINE(UPCFG2X) -#else - MISSING(UPCFG2X) -#endif - -#ifdef UPCONX - DEFINE(UPCONX) -#else - MISSING(UPCONX) -#endif - -#ifdef UPCRX - DEFINE(UPCRX) -#else - MISSING(UPCRX) -#endif - -#ifdef UPDATX - DEFINE(UPDATX) -#else - MISSING(UPDATX) -#endif - -#ifdef UPERRX - DEFINE(UPERRX) -#else - MISSING(UPERRX) -#endif - -#ifdef UPIENX - DEFINE(UPIENX) -#else - MISSING(UPIENX) -#endif - -#ifdef UPINRQX - DEFINE(UPINRQX) -#else - MISSING(UPINRQX) -#endif - -#ifdef UPINT - DEFINE(UPINT) -#else - MISSING(UPINT) -#endif - -#ifdef UPINTX - DEFINE(UPINTX) -#else - MISSING(UPINTX) -#endif - -#ifdef UPNUM - DEFINE(UPNUM) -#else - MISSING(UPNUM) -#endif - -#ifdef UPOE - DEFINE(UPOE) -#else - MISSING(UPOE) -#endif - -#ifdef UPRST - DEFINE(UPRST) -#else - MISSING(UPRST) -#endif - -#ifdef UPSTAX - DEFINE(UPSTAX) -#else - MISSING(UPSTAX) -#endif - -#ifdef USARTC0_BAUDCTRLA - DEFINE(USARTC0_BAUDCTRLA) -#else - MISSING(USARTC0_BAUDCTRLA) -#endif - -#ifdef USARTC0_BAUDCTRLB - DEFINE(USARTC0_BAUDCTRLB) -#else - MISSING(USARTC0_BAUDCTRLB) -#endif - -#ifdef USARTC0_CTRLA - DEFINE(USARTC0_CTRLA) -#else - MISSING(USARTC0_CTRLA) -#endif - -#ifdef USARTC0_CTRLB - DEFINE(USARTC0_CTRLB) -#else - MISSING(USARTC0_CTRLB) -#endif - -#ifdef USARTC0_CTRLC - DEFINE(USARTC0_CTRLC) -#else - MISSING(USARTC0_CTRLC) -#endif - -#ifdef USARTC0_DATA - DEFINE(USARTC0_DATA) -#else - MISSING(USARTC0_DATA) -#endif - -#ifdef USARTC0_STATUS - DEFINE(USARTC0_STATUS) -#else - MISSING(USARTC0_STATUS) -#endif - -#ifdef USARTC1_BAUDCTRLA - DEFINE(USARTC1_BAUDCTRLA) -#else - MISSING(USARTC1_BAUDCTRLA) -#endif - -#ifdef USARTC1_BAUDCTRLB - DEFINE(USARTC1_BAUDCTRLB) -#else - MISSING(USARTC1_BAUDCTRLB) -#endif - -#ifdef USARTC1_CTRLA - DEFINE(USARTC1_CTRLA) -#else - MISSING(USARTC1_CTRLA) -#endif - -#ifdef USARTC1_CTRLB - DEFINE(USARTC1_CTRLB) -#else - MISSING(USARTC1_CTRLB) -#endif - -#ifdef USARTC1_CTRLC - DEFINE(USARTC1_CTRLC) -#else - MISSING(USARTC1_CTRLC) -#endif - -#ifdef USARTC1_DATA - DEFINE(USARTC1_DATA) -#else - MISSING(USARTC1_DATA) -#endif - -#ifdef USARTC1_STATUS - DEFINE(USARTC1_STATUS) -#else - MISSING(USARTC1_STATUS) -#endif - -#ifdef USARTD0_BAUDCTRLA - DEFINE(USARTD0_BAUDCTRLA) -#else - MISSING(USARTD0_BAUDCTRLA) -#endif - -#ifdef USARTD0_BAUDCTRLB - DEFINE(USARTD0_BAUDCTRLB) -#else - MISSING(USARTD0_BAUDCTRLB) -#endif - -#ifdef USARTD0_CTRLA - DEFINE(USARTD0_CTRLA) -#else - MISSING(USARTD0_CTRLA) -#endif - -#ifdef USARTD0_CTRLB - DEFINE(USARTD0_CTRLB) -#else - MISSING(USARTD0_CTRLB) -#endif - -#ifdef USARTD0_CTRLC - DEFINE(USARTD0_CTRLC) -#else - MISSING(USARTD0_CTRLC) -#endif - -#ifdef USARTD0_DATA - DEFINE(USARTD0_DATA) -#else - MISSING(USARTD0_DATA) -#endif - -#ifdef USARTD0_STATUS - DEFINE(USARTD0_STATUS) -#else - MISSING(USARTD0_STATUS) -#endif - -#ifdef USARTD1_BAUDCTRLA - DEFINE(USARTD1_BAUDCTRLA) -#else - MISSING(USARTD1_BAUDCTRLA) -#endif - -#ifdef USARTD1_BAUDCTRLB - DEFINE(USARTD1_BAUDCTRLB) -#else - MISSING(USARTD1_BAUDCTRLB) -#endif - -#ifdef USARTD1_CTRLA - DEFINE(USARTD1_CTRLA) -#else - MISSING(USARTD1_CTRLA) -#endif - -#ifdef USARTD1_CTRLB - DEFINE(USARTD1_CTRLB) -#else - MISSING(USARTD1_CTRLB) -#endif - -#ifdef USARTD1_CTRLC - DEFINE(USARTD1_CTRLC) -#else - MISSING(USARTD1_CTRLC) -#endif - -#ifdef USARTD1_DATA - DEFINE(USARTD1_DATA) -#else - MISSING(USARTD1_DATA) -#endif - -#ifdef USARTD1_STATUS - DEFINE(USARTD1_STATUS) -#else - MISSING(USARTD1_STATUS) -#endif - -#ifdef USARTE0_BAUDCTRLA - DEFINE(USARTE0_BAUDCTRLA) -#else - MISSING(USARTE0_BAUDCTRLA) -#endif - -#ifdef USARTE0_BAUDCTRLB - DEFINE(USARTE0_BAUDCTRLB) -#else - MISSING(USARTE0_BAUDCTRLB) -#endif - -#ifdef USARTE0_CTRLA - DEFINE(USARTE0_CTRLA) -#else - MISSING(USARTE0_CTRLA) -#endif - -#ifdef USARTE0_CTRLB - DEFINE(USARTE0_CTRLB) -#else - MISSING(USARTE0_CTRLB) -#endif - -#ifdef USARTE0_CTRLC - DEFINE(USARTE0_CTRLC) -#else - MISSING(USARTE0_CTRLC) -#endif - -#ifdef USARTE0_DATA - DEFINE(USARTE0_DATA) -#else - MISSING(USARTE0_DATA) -#endif - -#ifdef USARTE0_STATUS - DEFINE(USARTE0_STATUS) -#else - MISSING(USARTE0_STATUS) -#endif - -#ifdef USARTE1_BAUDCTRLA - DEFINE(USARTE1_BAUDCTRLA) -#else - MISSING(USARTE1_BAUDCTRLA) -#endif - -#ifdef USARTE1_BAUDCTRLB - DEFINE(USARTE1_BAUDCTRLB) -#else - MISSING(USARTE1_BAUDCTRLB) -#endif - -#ifdef USARTE1_CTRLA - DEFINE(USARTE1_CTRLA) -#else - MISSING(USARTE1_CTRLA) -#endif - -#ifdef USARTE1_CTRLB - DEFINE(USARTE1_CTRLB) -#else - MISSING(USARTE1_CTRLB) -#endif - -#ifdef USARTE1_CTRLC - DEFINE(USARTE1_CTRLC) -#else - MISSING(USARTE1_CTRLC) -#endif - -#ifdef USARTE1_DATA - DEFINE(USARTE1_DATA) -#else - MISSING(USARTE1_DATA) -#endif - -#ifdef USARTE1_STATUS - DEFINE(USARTE1_STATUS) -#else - MISSING(USARTE1_STATUS) -#endif - -#ifdef USARTF0_BAUDCTRLA - DEFINE(USARTF0_BAUDCTRLA) -#else - MISSING(USARTF0_BAUDCTRLA) -#endif - -#ifdef USARTF0_BAUDCTRLB - DEFINE(USARTF0_BAUDCTRLB) -#else - MISSING(USARTF0_BAUDCTRLB) -#endif - -#ifdef USARTF0_CTRLA - DEFINE(USARTF0_CTRLA) -#else - MISSING(USARTF0_CTRLA) -#endif - -#ifdef USARTF0_CTRLB - DEFINE(USARTF0_CTRLB) -#else - MISSING(USARTF0_CTRLB) -#endif - -#ifdef USARTF0_CTRLC - DEFINE(USARTF0_CTRLC) -#else - MISSING(USARTF0_CTRLC) -#endif - -#ifdef USARTF0_DATA - DEFINE(USARTF0_DATA) -#else - MISSING(USARTF0_DATA) -#endif - -#ifdef USARTF0_STATUS - DEFINE(USARTF0_STATUS) -#else - MISSING(USARTF0_STATUS) -#endif - -#ifdef USARTF1_BAUDCTRLA - DEFINE(USARTF1_BAUDCTRLA) -#else - MISSING(USARTF1_BAUDCTRLA) -#endif - -#ifdef USARTF1_BAUDCTRLB - DEFINE(USARTF1_BAUDCTRLB) -#else - MISSING(USARTF1_BAUDCTRLB) -#endif - -#ifdef USARTF1_CTRLA - DEFINE(USARTF1_CTRLA) -#else - MISSING(USARTF1_CTRLA) -#endif - -#ifdef USARTF1_CTRLB - DEFINE(USARTF1_CTRLB) -#else - MISSING(USARTF1_CTRLB) -#endif - -#ifdef USARTF1_CTRLC - DEFINE(USARTF1_CTRLC) -#else - MISSING(USARTF1_CTRLC) -#endif - -#ifdef USARTF1_DATA - DEFINE(USARTF1_DATA) -#else - MISSING(USARTF1_DATA) -#endif - -#ifdef USARTF1_STATUS - DEFINE(USARTF1_STATUS) -#else - MISSING(USARTF1_STATUS) -#endif - -#ifdef USBCON - DEFINE(USBCON) -#else - MISSING(USBCON) -#endif - -#ifdef USBCR - DEFINE(USBCR) -#else - MISSING(USBCR) -#endif - -#ifdef USBCSEX - DEFINE(USBCSEX) -#else - MISSING(USBCSEX) -#endif - -#ifdef USBDBCEX - DEFINE(USBDBCEX) -#else - MISSING(USBDBCEX) -#endif - -#ifdef USBDMAB - DEFINE(USBDMAB) -#else - MISSING(USBDMAB) -#endif - -#ifdef USBDMACS - DEFINE(USBDMACS) -#else - MISSING(USBDMACS) -#endif - -#ifdef USBDMAD - DEFINE(USBDMAD) -#else - MISSING(USBDMAD) -#endif - -#ifdef USBDMADH - DEFINE(USBDMADH) -#else - MISSING(USBDMADH) -#endif - -#ifdef USBDMADL - DEFINE(USBDMADL) -#else - MISSING(USBDMADL) -#endif - -#ifdef USBEI - DEFINE(USBEI) -#else - MISSING(USBEI) -#endif - -#ifdef USBEIM - DEFINE(USBEIM) -#else - MISSING(USBEIM) -#endif - -#ifdef USBENUM - DEFINE(USBENUM) -#else - MISSING(USBENUM) -#endif - -#ifdef USBFA - DEFINE(USBFA) -#else - MISSING(USBFA) -#endif - -#ifdef USBFCEX - DEFINE(USBFCEX) -#else - MISSING(USBFCEX) -#endif - -#ifdef USBFN - DEFINE(USBFN) -#else - MISSING(USBFN) -#endif - -#ifdef USBFNH - DEFINE(USBFNH) -#else - MISSING(USBFNH) -#endif - -#ifdef USBFNL - DEFINE(USBFNL) -#else - MISSING(USBFNL) -#endif - -#ifdef USBGS - DEFINE(USBGS) -#else - MISSING(USBGS) -#endif - -#ifdef USBINT - DEFINE(USBINT) -#else - MISSING(USBINT) -#endif - -#ifdef USBPI - DEFINE(USBPI) -#else - MISSING(USBPI) -#endif - -#ifdef USBPIM - DEFINE(USBPIM) -#else - MISSING(USBPIM) -#endif - -#ifdef USBRSTE - DEFINE(USBRSTE) -#else - MISSING(USBRSTE) -#endif - -#ifdef USBSTA - DEFINE(USBSTA) -#else - MISSING(USBSTA) -#endif - -#ifdef USB_ADDR - DEFINE(USB_ADDR) -#else - MISSING(USB_ADDR) -#endif - -#ifdef USB_CAL0 - DEFINE(USB_CAL0) -#else - MISSING(USB_CAL0) -#endif - -#ifdef USB_CAL1 - DEFINE(USB_CAL1) -#else - MISSING(USB_CAL1) -#endif - -#ifdef USB_CTRLA - DEFINE(USB_CTRLA) -#else - MISSING(USB_CTRLA) -#endif - -#ifdef USB_CTRLB - DEFINE(USB_CTRLB) -#else - MISSING(USB_CTRLB) -#endif - -#ifdef USB_EPPTR - DEFINE(USB_EPPTR) -#else - MISSING(USB_EPPTR) -#endif - -#ifdef USB_EP_TABLE_EP0IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP0IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP0IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP0IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP0IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP0IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_CNTH - DEFINE(USB_EP_TABLE_EP0IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP0IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP0IN_CNTL - DEFINE(USB_EP_TABLE_EP0IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP0IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_CTRL - DEFINE(USB_EP_TABLE_EP0IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP0IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP0IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP0IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP0IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP0IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP0IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_STATUS - DEFINE(USB_EP_TABLE_EP0IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP0IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP0OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP0OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_CNTH - DEFINE(USB_EP_TABLE_EP0OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP0OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_CNTL - DEFINE(USB_EP_TABLE_EP0OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP0OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_CTRL - DEFINE(USB_EP_TABLE_EP0OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP0OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP0OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP0OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_STATUS - DEFINE(USB_EP_TABLE_EP0OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP0OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP10IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP10IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP10IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP10IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP10IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP10IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_CNTH - DEFINE(USB_EP_TABLE_EP10IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP10IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP10IN_CNTL - DEFINE(USB_EP_TABLE_EP10IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP10IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_CTRL - DEFINE(USB_EP_TABLE_EP10IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP10IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP10IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP10IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP10IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP10IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP10IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_STATUS - DEFINE(USB_EP_TABLE_EP10IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP10IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP10OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP10OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_CNTH - DEFINE(USB_EP_TABLE_EP10OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP10OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_CNTL - DEFINE(USB_EP_TABLE_EP10OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP10OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_CTRL - DEFINE(USB_EP_TABLE_EP10OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP10OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP10OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP10OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_STATUS - DEFINE(USB_EP_TABLE_EP10OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP10OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP11IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP11IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP11IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP11IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP11IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP11IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_CNTH - DEFINE(USB_EP_TABLE_EP11IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP11IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP11IN_CNTL - DEFINE(USB_EP_TABLE_EP11IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP11IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_CTRL - DEFINE(USB_EP_TABLE_EP11IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP11IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP11IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP11IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP11IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP11IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP11IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_STATUS - DEFINE(USB_EP_TABLE_EP11IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP11IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP11OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP11OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_CNTH - DEFINE(USB_EP_TABLE_EP11OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP11OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_CNTL - DEFINE(USB_EP_TABLE_EP11OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP11OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_CTRL - DEFINE(USB_EP_TABLE_EP11OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP11OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP11OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP11OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_STATUS - DEFINE(USB_EP_TABLE_EP11OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP11OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP12IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP12IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP12IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP12IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP12IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP12IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_CNTH - DEFINE(USB_EP_TABLE_EP12IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP12IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP12IN_CNTL - DEFINE(USB_EP_TABLE_EP12IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP12IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_CTRL - DEFINE(USB_EP_TABLE_EP12IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP12IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP12IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP12IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP12IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP12IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP12IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_STATUS - DEFINE(USB_EP_TABLE_EP12IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP12IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP12OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP12OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_CNTH - DEFINE(USB_EP_TABLE_EP12OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP12OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_CNTL - DEFINE(USB_EP_TABLE_EP12OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP12OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_CTRL - DEFINE(USB_EP_TABLE_EP12OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP12OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP12OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP12OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_STATUS - DEFINE(USB_EP_TABLE_EP12OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP12OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP13IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP13IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP13IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP13IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP13IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP13IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_CNTH - DEFINE(USB_EP_TABLE_EP13IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP13IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP13IN_CNTL - DEFINE(USB_EP_TABLE_EP13IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP13IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_CTRL - DEFINE(USB_EP_TABLE_EP13IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP13IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP13IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP13IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP13IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP13IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP13IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_STATUS - DEFINE(USB_EP_TABLE_EP13IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP13IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP13OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP13OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_CNTH - DEFINE(USB_EP_TABLE_EP13OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP13OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_CNTL - DEFINE(USB_EP_TABLE_EP13OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP13OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_CTRL - DEFINE(USB_EP_TABLE_EP13OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP13OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP13OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP13OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_STATUS - DEFINE(USB_EP_TABLE_EP13OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP13OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP14IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP14IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP14IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP14IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP14IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP14IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_CNTH - DEFINE(USB_EP_TABLE_EP14IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP14IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP14IN_CNTL - DEFINE(USB_EP_TABLE_EP14IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP14IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_CTRL - DEFINE(USB_EP_TABLE_EP14IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP14IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP14IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP14IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP14IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP14IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP14IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_STATUS - DEFINE(USB_EP_TABLE_EP14IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP14IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP14OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP14OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_CNTH - DEFINE(USB_EP_TABLE_EP14OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP14OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_CNTL - DEFINE(USB_EP_TABLE_EP14OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP14OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_CTRL - DEFINE(USB_EP_TABLE_EP14OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP14OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP14OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP14OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_STATUS - DEFINE(USB_EP_TABLE_EP14OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP14OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP15IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP15IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP15IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP15IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP15IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP15IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_CNTH - DEFINE(USB_EP_TABLE_EP15IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP15IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP15IN_CNTL - DEFINE(USB_EP_TABLE_EP15IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP15IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_CTRL - DEFINE(USB_EP_TABLE_EP15IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP15IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP15IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP15IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP15IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP15IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP15IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_STATUS - DEFINE(USB_EP_TABLE_EP15IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP15IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP15OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP15OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_CNTH - DEFINE(USB_EP_TABLE_EP15OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP15OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_CNTL - DEFINE(USB_EP_TABLE_EP15OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP15OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_CTRL - DEFINE(USB_EP_TABLE_EP15OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP15OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP15OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP15OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_STATUS - DEFINE(USB_EP_TABLE_EP15OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP15OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP1IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP1IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP1IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP1IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP1IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP1IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_CNTH - DEFINE(USB_EP_TABLE_EP1IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP1IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP1IN_CNTL - DEFINE(USB_EP_TABLE_EP1IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP1IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_CTRL - DEFINE(USB_EP_TABLE_EP1IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP1IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP1IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP1IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP1IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP1IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP1IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_STATUS - DEFINE(USB_EP_TABLE_EP1IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP1IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP1OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP1OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_CNTH - DEFINE(USB_EP_TABLE_EP1OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP1OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_CNTL - DEFINE(USB_EP_TABLE_EP1OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP1OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_CTRL - DEFINE(USB_EP_TABLE_EP1OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP1OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP1OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP1OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_STATUS - DEFINE(USB_EP_TABLE_EP1OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP1OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP2IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP2IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP2IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP2IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP2IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP2IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_CNTH - DEFINE(USB_EP_TABLE_EP2IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP2IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP2IN_CNTL - DEFINE(USB_EP_TABLE_EP2IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP2IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_CTRL - DEFINE(USB_EP_TABLE_EP2IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP2IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP2IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP2IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP2IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP2IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP2IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_STATUS - DEFINE(USB_EP_TABLE_EP2IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP2IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP2OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP2OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_CNTH - DEFINE(USB_EP_TABLE_EP2OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP2OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_CNTL - DEFINE(USB_EP_TABLE_EP2OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP2OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_CTRL - DEFINE(USB_EP_TABLE_EP2OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP2OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP2OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP2OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_STATUS - DEFINE(USB_EP_TABLE_EP2OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP2OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP3IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP3IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP3IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP3IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP3IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP3IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_CNTH - DEFINE(USB_EP_TABLE_EP3IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP3IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP3IN_CNTL - DEFINE(USB_EP_TABLE_EP3IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP3IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_CTRL - DEFINE(USB_EP_TABLE_EP3IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP3IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP3IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP3IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP3IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP3IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP3IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_STATUS - DEFINE(USB_EP_TABLE_EP3IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP3IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP3OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP3OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_CNTH - DEFINE(USB_EP_TABLE_EP3OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP3OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_CNTL - DEFINE(USB_EP_TABLE_EP3OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP3OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_CTRL - DEFINE(USB_EP_TABLE_EP3OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP3OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP3OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP3OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_STATUS - DEFINE(USB_EP_TABLE_EP3OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP3OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP4IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP4IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP4IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP4IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP4IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP4IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_CNTH - DEFINE(USB_EP_TABLE_EP4IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP4IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP4IN_CNTL - DEFINE(USB_EP_TABLE_EP4IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP4IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_CTRL - DEFINE(USB_EP_TABLE_EP4IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP4IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP4IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP4IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP4IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP4IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP4IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_STATUS - DEFINE(USB_EP_TABLE_EP4IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP4IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP4OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP4OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_CNTH - DEFINE(USB_EP_TABLE_EP4OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP4OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_CNTL - DEFINE(USB_EP_TABLE_EP4OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP4OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_CTRL - DEFINE(USB_EP_TABLE_EP4OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP4OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP4OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP4OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_STATUS - DEFINE(USB_EP_TABLE_EP4OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP4OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP5IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP5IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP5IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP5IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP5IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP5IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_CNTH - DEFINE(USB_EP_TABLE_EP5IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP5IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP5IN_CNTL - DEFINE(USB_EP_TABLE_EP5IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP5IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_CTRL - DEFINE(USB_EP_TABLE_EP5IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP5IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP5IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP5IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP5IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP5IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP5IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_STATUS - DEFINE(USB_EP_TABLE_EP5IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP5IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP5OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP5OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_CNTH - DEFINE(USB_EP_TABLE_EP5OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP5OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_CNTL - DEFINE(USB_EP_TABLE_EP5OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP5OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_CTRL - DEFINE(USB_EP_TABLE_EP5OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP5OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP5OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP5OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_STATUS - DEFINE(USB_EP_TABLE_EP5OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP5OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP6IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP6IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP6IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP6IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP6IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP6IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_CNTH - DEFINE(USB_EP_TABLE_EP6IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP6IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP6IN_CNTL - DEFINE(USB_EP_TABLE_EP6IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP6IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_CTRL - DEFINE(USB_EP_TABLE_EP6IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP6IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP6IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP6IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP6IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP6IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP6IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_STATUS - DEFINE(USB_EP_TABLE_EP6IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP6IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP6OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP6OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_CNTH - DEFINE(USB_EP_TABLE_EP6OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP6OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_CNTL - DEFINE(USB_EP_TABLE_EP6OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP6OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_CTRL - DEFINE(USB_EP_TABLE_EP6OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP6OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP6OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP6OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_STATUS - DEFINE(USB_EP_TABLE_EP6OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP6OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP7IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP7IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP7IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP7IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP7IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP7IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_CNTH - DEFINE(USB_EP_TABLE_EP7IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP7IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP7IN_CNTL - DEFINE(USB_EP_TABLE_EP7IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP7IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_CTRL - DEFINE(USB_EP_TABLE_EP7IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP7IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP7IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP7IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP7IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP7IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP7IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_STATUS - DEFINE(USB_EP_TABLE_EP7IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP7IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP7OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP7OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_CNTH - DEFINE(USB_EP_TABLE_EP7OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP7OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_CNTL - DEFINE(USB_EP_TABLE_EP7OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP7OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_CTRL - DEFINE(USB_EP_TABLE_EP7OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP7OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP7OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP7OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_STATUS - DEFINE(USB_EP_TABLE_EP7OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP7OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP8IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP8IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP8IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP8IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP8IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP8IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_CNTH - DEFINE(USB_EP_TABLE_EP8IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP8IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP8IN_CNTL - DEFINE(USB_EP_TABLE_EP8IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP8IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_CTRL - DEFINE(USB_EP_TABLE_EP8IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP8IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP8IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP8IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP8IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP8IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP8IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_STATUS - DEFINE(USB_EP_TABLE_EP8IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP8IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP8OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP8OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_CNTH - DEFINE(USB_EP_TABLE_EP8OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP8OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_CNTL - DEFINE(USB_EP_TABLE_EP8OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP8OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_CTRL - DEFINE(USB_EP_TABLE_EP8OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP8OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP8OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP8OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_STATUS - DEFINE(USB_EP_TABLE_EP8OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP8OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP9IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP9IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP9IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP9IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP9IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP9IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_CNTH - DEFINE(USB_EP_TABLE_EP9IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP9IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP9IN_CNTL - DEFINE(USB_EP_TABLE_EP9IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP9IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_CTRL - DEFINE(USB_EP_TABLE_EP9IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP9IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP9IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP9IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP9IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP9IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP9IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_STATUS - DEFINE(USB_EP_TABLE_EP9IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP9IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP9OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP9OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_CNTH - DEFINE(USB_EP_TABLE_EP9OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP9OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_CNTL - DEFINE(USB_EP_TABLE_EP9OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP9OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_CTRL - DEFINE(USB_EP_TABLE_EP9OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP9OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP9OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP9OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_STATUS - DEFINE(USB_EP_TABLE_EP9OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP9OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_FRAMENUMH - DEFINE(USB_EP_TABLE_FRAMENUMH) -#else - MISSING(USB_EP_TABLE_FRAMENUMH) -#endif - -#ifdef USB_EP_TABLE_FRAMENUML - DEFINE(USB_EP_TABLE_FRAMENUML) -#else - MISSING(USB_EP_TABLE_FRAMENUML) -#endif - -#ifdef USB_FIFORP - DEFINE(USB_FIFORP) -#else - MISSING(USB_FIFORP) -#endif - -#ifdef USB_FIFOWP - DEFINE(USB_FIFOWP) -#else - MISSING(USB_FIFOWP) -#endif - -#ifdef USB_INTCTRLA - DEFINE(USB_INTCTRLA) -#else - MISSING(USB_INTCTRLA) -#endif - -#ifdef USB_INTCTRLB - DEFINE(USB_INTCTRLB) -#else - MISSING(USB_INTCTRLB) -#endif - -#ifdef USB_INTFLAGSACLR - DEFINE(USB_INTFLAGSACLR) -#else - MISSING(USB_INTFLAGSACLR) -#endif - -#ifdef USB_INTFLAGSASET - DEFINE(USB_INTFLAGSASET) -#else - MISSING(USB_INTFLAGSASET) -#endif - -#ifdef USB_INTFLAGSBCLR - DEFINE(USB_INTFLAGSBCLR) -#else - MISSING(USB_INTFLAGSBCLR) -#endif - -#ifdef USB_INTFLAGSBSET - DEFINE(USB_INTFLAGSBSET) -#else - MISSING(USB_INTFLAGSBSET) -#endif - -#ifdef USB_STATUS - DEFINE(USB_STATUS) -#else - MISSING(USB_STATUS) -#endif - -#ifdef USIBR - DEFINE(USIBR) -#else - MISSING(USIBR) -#endif - -#ifdef USICR - DEFINE(USICR) -#else - MISSING(USICR) -#endif - -#ifdef USIDR - DEFINE(USIDR) -#else - MISSING(USIDR) -#endif - -#ifdef USIPP - DEFINE(USIPP) -#else - MISSING(USIPP) -#endif - -#ifdef USISR - DEFINE(USISR) -#else - MISSING(USISR) -#endif - -#ifdef USPCR - DEFINE(USPCR) -#else - MISSING(USPCR) -#endif - -#ifdef USPDR - DEFINE(USPDR) -#else - MISSING(USPDR) -#endif - -#ifdef USPSR - DEFINE(USPSR) -#else - MISSING(USPSR) -#endif - -#ifdef USR - DEFINE(USR) -#else - MISSING(USR) -#endif - -#ifdef VADAC0 - DEFINE(VADAC0) -#else - MISSING(VADAC0) -#endif - -#ifdef VADAC1 - DEFINE(VADAC1) -#else - MISSING(VADAC1) -#endif - -#ifdef VADAC2 - DEFINE(VADAC2) -#else - MISSING(VADAC2) -#endif - -#ifdef VADAC3 - DEFINE(VADAC3) -#else - MISSING(VADAC3) -#endif - -#ifdef VADC - DEFINE(VADC) -#else - MISSING(VADC) -#endif - -#ifdef VADCH - DEFINE(VADCH) -#else - MISSING(VADCH) -#endif - -#ifdef VADCL - DEFINE(VADCL) -#else - MISSING(VADCL) -#endif - -#ifdef VADCSR - DEFINE(VADCSR) -#else - MISSING(VADCSR) -#endif - -#ifdef VADIC - DEFINE(VADIC) -#else - MISSING(VADIC) -#endif - -#ifdef VADICH - DEFINE(VADICH) -#else - MISSING(VADICH) -#endif - -#ifdef VADICL - DEFINE(VADICL) -#else - MISSING(VADICL) -#endif - -#ifdef VADMUX - DEFINE(VADMUX) -#else - MISSING(VADMUX) -#endif - -#ifdef VBAT_BACKUP0 - DEFINE(VBAT_BACKUP0) -#else - MISSING(VBAT_BACKUP0) -#endif - -#ifdef VBAT_BACKUP1 - DEFINE(VBAT_BACKUP1) -#else - MISSING(VBAT_BACKUP1) -#endif - -#ifdef VBAT_CTRL - DEFINE(VBAT_CTRL) -#else - MISSING(VBAT_CTRL) -#endif - -#ifdef VBAT_STATUS - DEFINE(VBAT_STATUS) -#else - MISSING(VBAT_STATUS) -#endif - -#ifdef VCOTUNE - DEFINE(VCOTUNE) -#else - MISSING(VCOTUNE) -#endif - -#ifdef VELACC1 - DEFINE(VELACC1) -#else - MISSING(VELACC1) -#endif - -#ifdef VELACC2 - DEFINE(VELACC2) -#else - MISSING(VELACC2) -#endif - -#ifdef VELACC3 - DEFINE(VELACC3) -#else - MISSING(VELACC3) -#endif - -#ifdef VELCVEL - DEFINE(VELCVEL) -#else - MISSING(VELCVEL) -#endif - -#ifdef VELDEC1 - DEFINE(VELDEC1) -#else - MISSING(VELDEC1) -#endif - -#ifdef VELDEC2 - DEFINE(VELDEC2) -#else - MISSING(VELDEC2) -#endif - -#ifdef VELDEC3 - DEFINE(VELDEC3) -#else - MISSING(VELDEC3) -#endif - -#ifdef VELHI1 - DEFINE(VELHI1) -#else - MISSING(VELHI1) -#endif - -#ifdef VELHI2 - DEFINE(VELHI2) -#else - MISSING(VELHI2) -#endif - -#ifdef VELHI3 - DEFINE(VELHI3) -#else - MISSING(VELHI3) -#endif - -#ifdef VELIFLG - DEFINE(VELIFLG) -#else - MISSING(VELIFLG) -#endif - -#ifdef VELIMSK - DEFINE(VELIMSK) -#else - MISSING(VELIMSK) -#endif - -#ifdef VELLOW1 - DEFINE(VELLOW1) -#else - MISSING(VELLOW1) -#endif - -#ifdef VELLOW2 - DEFINE(VELLOW2) -#else - MISSING(VELLOW2) -#endif - -#ifdef VELLOW3 - DEFINE(VELLOW3) -#else - MISSING(VELLOW3) -#endif - -#ifdef VELSTB - DEFINE(VELSTB) -#else - MISSING(VELSTB) -#endif - -#ifdef VELTVEL - DEFINE(VELTVEL) -#else - MISSING(VELTVEL) -#endif - -#ifdef VELVGCTL - DEFINE(VELVGCTL) -#else - MISSING(VELVGCTL) -#endif - -#ifdef VERSION_NUM - DEFINE(VERSION_NUM) -#else - MISSING(VERSION_NUM) -#endif - -#ifdef VLMCSR - DEFINE(VLMCSR) -#else - MISSING(VLMCSR) -#endif - -#ifdef VMCSR - DEFINE(VMCSR) -#else - MISSING(VMCSR) -#endif - -#ifdef VPORT0_DIR - DEFINE(VPORT0_DIR) -#else - MISSING(VPORT0_DIR) -#endif - -#ifdef VPORT0_IN - DEFINE(VPORT0_IN) -#else - MISSING(VPORT0_IN) -#endif - -#ifdef VPORT0_INTFLAGS - DEFINE(VPORT0_INTFLAGS) -#else - MISSING(VPORT0_INTFLAGS) -#endif - -#ifdef VPORT0_OUT - DEFINE(VPORT0_OUT) -#else - MISSING(VPORT0_OUT) -#endif - -#ifdef VPORT1_DIR - DEFINE(VPORT1_DIR) -#else - MISSING(VPORT1_DIR) -#endif - -#ifdef VPORT1_IN - DEFINE(VPORT1_IN) -#else - MISSING(VPORT1_IN) -#endif - -#ifdef VPORT1_INTFLAGS - DEFINE(VPORT1_INTFLAGS) -#else - MISSING(VPORT1_INTFLAGS) -#endif - -#ifdef VPORT1_OUT - DEFINE(VPORT1_OUT) -#else - MISSING(VPORT1_OUT) -#endif - -#ifdef VPORT2_DIR - DEFINE(VPORT2_DIR) -#else - MISSING(VPORT2_DIR) -#endif - -#ifdef VPORT2_IN - DEFINE(VPORT2_IN) -#else - MISSING(VPORT2_IN) -#endif - -#ifdef VPORT2_INTFLAGS - DEFINE(VPORT2_INTFLAGS) -#else - MISSING(VPORT2_INTFLAGS) -#endif - -#ifdef VPORT2_OUT - DEFINE(VPORT2_OUT) -#else - MISSING(VPORT2_OUT) -#endif - -#ifdef VPORT3_DIR - DEFINE(VPORT3_DIR) -#else - MISSING(VPORT3_DIR) -#endif - -#ifdef VPORT3_IN - DEFINE(VPORT3_IN) -#else - MISSING(VPORT3_IN) -#endif - -#ifdef VPORT3_INTFLAGS - DEFINE(VPORT3_INTFLAGS) -#else - MISSING(VPORT3_INTFLAGS) -#endif - -#ifdef VPORT3_OUT - DEFINE(VPORT3_OUT) -#else - MISSING(VPORT3_OUT) -#endif - -#ifdef VREG_CTRL - DEFINE(VREG_CTRL) -#else - MISSING(VREG_CTRL) -#endif - -#ifdef WDTCKD - DEFINE(WDTCKD) -#else - MISSING(WDTCKD) -#endif - -#ifdef WDTCLR - DEFINE(WDTCLR) -#else - MISSING(WDTCLR) -#endif - -#ifdef WDTCR - DEFINE(WDTCR) -#else - MISSING(WDTCR) -#endif - -#ifdef WDTCSR - DEFINE(WDTCSR) -#else - MISSING(WDTCSR) -#endif - -#ifdef WDT_CTRL - DEFINE(WDT_CTRL) -#else - MISSING(WDT_CTRL) -#endif - -#ifdef WDT_STATUS - DEFINE(WDT_STATUS) -#else - MISSING(WDT_STATUS) -#endif - -#ifdef WDT_WINCTRL - DEFINE(WDT_WINCTRL) -#else - MISSING(WDT_WINCTRL) -#endif - -#ifdef WUTCSR - DEFINE(WUTCSR) -#else - MISSING(WUTCSR) -#endif - -#ifdef XAH_CTRL_0 - DEFINE(XAH_CTRL_0) -#else - MISSING(XAH_CTRL_0) -#endif - -#ifdef XAH_CTRL_1 - DEFINE(XAH_CTRL_1) -#else - MISSING(XAH_CTRL_1) -#endif - -#ifdef XDIV - DEFINE(XDIV) -#else - MISSING(XDIV) -#endif - -#ifdef XMCRA - DEFINE(XMCRA) -#else - MISSING(XMCRA) -#endif - -#ifdef XMCRB - DEFINE(XMCRB) -#else - MISSING(XMCRB) -#endif - -#ifdef XOSC_CTRL - DEFINE(XOSC_CTRL) -#else - MISSING(XOSC_CTRL) -#endif \ No newline at end of file diff --git a/firmware/Nanpy/generated_mcu.h b/firmware/Nanpy/generated_mcu.h deleted file mode 100644 index dfce6ac..0000000 --- a/firmware/Nanpy/generated_mcu.h +++ /dev/null @@ -1,1287 +0,0 @@ - -// this file was generated by codegen.py - -// __AVR_LIBC_VERSION_STRING__ = "1.8.0" -// __AVR_LIBC_DATE_STRING__ = "20111228" - - -#ifdef __AVR_AT43USB320__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT43USB320__" -#endif - -#ifdef __AVR_AT43USB355__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT43USB355__" -#endif - -#ifdef __AVR_AT76C711__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT76C711__" -#endif - -#ifdef __AVR_AT86RF401__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT86RF401__" -#endif - -#ifdef __AVR_AT90C8534__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90C8534__" -#endif - -#ifdef __AVR_AT90CAN128__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90CAN128__" -#endif - -#ifdef __AVR_AT90CAN32__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90CAN32__" -#endif - -#ifdef __AVR_AT90CAN64__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90CAN64__" -#endif - -#ifdef __AVR_AT90PWM1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM1__" -#endif - -#ifdef __AVR_AT90PWM216__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM216__" -#endif - -#ifdef __AVR_AT90PWM2B__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM2B__" -#endif - -#ifdef __AVR_AT90PWM2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM2__" -#endif - -#ifdef __AVR_AT90PWM316__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM316__" -#endif - -#ifdef __AVR_AT90PWM3B__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM3B__" -#endif - -#ifdef __AVR_AT90PWM3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM3__" -#endif - -#ifdef __AVR_AT90PWM81__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM81__" -#endif - -#ifdef __AVR_AT90S1200__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S1200__" -#endif - -#ifdef __AVR_AT90S2313__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2313__" -#endif - -#ifdef __AVR_AT90S2323__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2323__" -#endif - -#ifdef __AVR_AT90S2333__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2333__" -#endif - -#ifdef __AVR_AT90S2343__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2343__" -#endif - -#ifdef __AVR_AT90S4414__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S4414__" -#endif - -#ifdef __AVR_AT90S4433__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S4433__" -#endif - -#ifdef __AVR_AT90S4434__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S4434__" -#endif - -#ifdef __AVR_AT90S8515__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S8515__" -#endif - -#ifdef __AVR_AT90S8535__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S8535__" -#endif - -#ifdef __AVR_AT90SCR100__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90SCR100__" -#endif - -#ifdef __AVR_AT90USB1286__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB1286__" -#endif - -#ifdef __AVR_AT90USB1287__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB1287__" -#endif - -#ifdef __AVR_AT90USB162__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB162__" -#endif - -#ifdef __AVR_AT90USB646__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB646__" -#endif - -#ifdef __AVR_AT90USB647__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB647__" -#endif - -#ifdef __AVR_AT90USB82__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB82__" -#endif - -#ifdef __AVR_AT94K__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT94K__" -#endif - -#ifdef __AVR_ATA6289__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATA6289__" -#endif - -#ifdef __AVR_ATmega103__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega103__" -#endif - -#ifdef __AVR_ATmega1280__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega1280__" -#endif - -#ifdef __AVR_ATmega1281__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega1281__" -#endif - -#ifdef __AVR_ATmega1284P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega1284P__" -#endif - -#ifdef __AVR_ATmega128RFA1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega128RFA1__" -#endif - -#ifdef __AVR_ATmega128__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega128__" -#endif - -#ifdef __AVR_ATmega161__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega161__" -#endif - -#ifdef __AVR_ATmega162__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega162__" -#endif - -#ifdef __AVR_ATmega163__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega163__" -#endif - -#ifdef __AVR_ATmega164A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega164A__" -#endif - -#ifdef __AVR_ATmega164P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega164P__" -#endif - -#ifdef __AVR_ATmega164__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega164__" -#endif - -#ifdef __AVR_ATmega165A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega165A__" -#endif - -#ifdef __AVR_ATmega165P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega165P__" -#endif - -#ifdef __AVR_ATmega165__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega165__" -#endif - -#ifdef __AVR_ATmega168A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega168A__" -#endif - -#ifdef __AVR_ATmega168P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega168P__" -#endif - -#ifdef __AVR_ATmega168__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega168__" -#endif - -#ifdef __AVR_ATmega169A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169A__" -#endif - -#ifdef __AVR_ATmega169PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169PA__" -#endif - -#ifdef __AVR_ATmega169P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169P__" -#endif - -#ifdef __AVR_ATmega169__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169__" -#endif - -#ifdef __AVR_ATmega16A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16A__" -#endif - -#ifdef __AVR_ATmega16HVA2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVA2__" -#endif - -#ifdef __AVR_ATmega16HVA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVA__" -#endif - -#ifdef __AVR_ATmega16HVBREVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVBREVB__" -#endif - -#ifdef __AVR_ATmega16HVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVB__" -#endif - -#ifdef __AVR_ATmega16M1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16M1__" -#endif - -#ifdef __AVR_ATmega16U2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16U2__" -#endif - -#ifdef __AVR_ATmega16U4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16U4__" -#endif - -#ifdef __AVR_ATmega16__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16__" -#endif - -#ifdef __AVR_ATmega2560__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega2560__" -#endif - -#ifdef __AVR_ATmega2561__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega2561__" -#endif - -#ifdef __AVR_ATmega323__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega323__" -#endif - -#ifdef __AVR_ATmega324A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega324A__" -#endif - -#ifdef __AVR_ATmega324PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega324PA__" -#endif - -#ifdef __AVR_ATmega324P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega324P__" -#endif - -#ifdef __AVR_ATmega3250A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3250A__" -#endif - -#ifdef __AVR_ATmega3250P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3250P__" -#endif - -#ifdef __AVR_ATmega3250__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3250__" -#endif - -#ifdef __AVR_ATmega325A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega325A__" -#endif - -#ifdef __AVR_ATmega325P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega325P__" -#endif - -#ifdef __AVR_ATmega325__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega325__" -#endif - -#ifdef __AVR_ATmega328P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega328P__" -#endif - -#ifdef __AVR_ATmega328__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega328__" -#endif - -#ifdef __AVR_ATmega3290A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3290A__" -#endif - -#ifdef __AVR_ATmega3290P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3290P__" -#endif - -#ifdef __AVR_ATmega3290__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3290__" -#endif - -#ifdef __AVR_ATmega329A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329A__" -#endif - -#ifdef __AVR_ATmega329PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329PA__" -#endif - -#ifdef __AVR_ATmega329P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329P__" -#endif - -#ifdef __AVR_ATmega329__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329__" -#endif - -#ifdef __AVR_ATmega32C1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32C1__" -#endif - -#ifdef __AVR_ATmega32HVBREVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32HVBREVB__" -#endif - -#ifdef __AVR_ATmega32HVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32HVB__" -#endif - -#ifdef __AVR_ATmega32M1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32M1__" -#endif - -#ifdef __AVR_ATmega32U2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32U2__" -#endif - -#ifdef __AVR_ATmega32U4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32U4__" -#endif - -#ifdef __AVR_ATmega32U6__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32U6__" -#endif - -#ifdef __AVR_ATmega32__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32__" -#endif - -#ifdef __AVR_ATmega406__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega406__" -#endif - -#ifdef __AVR_ATmega48A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega48A__" -#endif - -#ifdef __AVR_ATmega48P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega48P__" -#endif - -#ifdef __AVR_ATmega48__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega48__" -#endif - -#ifdef __AVR_ATmega640__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega640__" -#endif - -#ifdef __AVR_ATmega644A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644A__" -#endif - -#ifdef __AVR_ATmega644PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644PA__" -#endif - -#ifdef __AVR_ATmega644P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644P__" -#endif - -#ifdef __AVR_ATmega644__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644__" -#endif - -#ifdef __AVR_ATmega6450A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6450A__" -#endif - -#ifdef __AVR_ATmega6450P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6450P__" -#endif - -#ifdef __AVR_ATmega6450__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6450__" -#endif - -#ifdef __AVR_ATmega645A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega645A__" -#endif - -#ifdef __AVR_ATmega645P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega645P__" -#endif - -#ifdef __AVR_ATmega645__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega645__" -#endif - -#ifdef __AVR_ATmega6490A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6490A__" -#endif - -#ifdef __AVR_ATmega6490P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6490P__" -#endif - -#ifdef __AVR_ATmega6490__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6490__" -#endif - -#ifdef __AVR_ATmega649A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega649A__" -#endif - -#ifdef __AVR_ATmega649P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega649P__" -#endif - -#ifdef __AVR_ATmega649__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega649__" -#endif - -#ifdef __AVR_ATmega64C1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64C1__" -#endif - -#ifdef __AVR_ATmega64HVE__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64HVE__" -#endif - -#ifdef __AVR_ATmega64M1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64M1__" -#endif - -#ifdef __AVR_ATmega64__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64__" -#endif - -#ifdef __AVR_ATmega8515__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8515__" -#endif - -#ifdef __AVR_ATmega8535__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8535__" -#endif - -#ifdef __AVR_ATmega88A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88A__" -#endif - -#ifdef __AVR_ATmega88PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88PA__" -#endif - -#ifdef __AVR_ATmega88P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88P__" -#endif - -#ifdef __AVR_ATmega88__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88__" -#endif - -#ifdef __AVR_ATmega8HVA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8HVA__" -#endif - -#ifdef __AVR_ATmega8U2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8U2__" -#endif - -#ifdef __AVR_ATmega8__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8__" -#endif - -#ifdef __AVR_ATtiny10__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny10__" -#endif - -#ifdef __AVR_ATtiny11__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny11__" -#endif - -#ifdef __AVR_ATtiny12__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny12__" -#endif - -#ifdef __AVR_ATtiny13A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny13A__" -#endif - -#ifdef __AVR_ATtiny13__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny13__" -#endif - -#ifdef __AVR_ATtiny15__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny15__" -#endif - -#ifdef __AVR_ATtiny167__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny167__" -#endif - -#ifdef __AVR_ATtiny20__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny20__" -#endif - -#ifdef __AVR_ATtiny22__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny22__" -#endif - -#ifdef __AVR_ATtiny2313A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny2313A__" -#endif - -#ifdef __AVR_ATtiny2313__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny2313__" -#endif - -#ifdef __AVR_ATtiny24A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny24A__" -#endif - -#ifdef __AVR_ATtiny24__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny24__" -#endif - -#ifdef __AVR_ATtiny25__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny25__" -#endif - -#ifdef __AVR_ATtiny261A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny261A__" -#endif - -#ifdef __AVR_ATtiny261__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny261__" -#endif - -#ifdef __AVR_ATtiny26__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny26__" -#endif - -#ifdef __AVR_ATtiny28__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny28__" -#endif - -#ifdef __AVR_ATtiny40__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny40__" -#endif - -#ifdef __AVR_ATtiny4313__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny4313__" -#endif - -#ifdef __AVR_ATtiny43U__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny43U__" -#endif - -#ifdef __AVR_ATtiny44A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny44A__" -#endif - -#ifdef __AVR_ATtiny44__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny44__" -#endif - -#ifdef __AVR_ATtiny45__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny45__" -#endif - -#ifdef __AVR_ATtiny461A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny461A__" -#endif - -#ifdef __AVR_ATtiny461__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny461__" -#endif - -#ifdef __AVR_ATtiny48__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny48__" -#endif - -#ifdef __AVR_ATtiny4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny4__" -#endif - -#ifdef __AVR_ATtiny5__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny5__" -#endif - -#ifdef __AVR_ATtiny84A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny84A__" -#endif - -#ifdef __AVR_ATtiny84__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny84__" -#endif - -#ifdef __AVR_ATtiny85__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny85__" -#endif - -#ifdef __AVR_ATtiny861A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny861A__" -#endif - -#ifdef __AVR_ATtiny861__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny861__" -#endif - -#ifdef __AVR_ATtiny87__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny87__" -#endif - -#ifdef __AVR_ATtiny88__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny88__" -#endif - -#ifdef __AVR_ATtiny9__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny9__" -#endif - -#ifdef __AVR_ATxmega128A1U__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128A1U__" -#endif - -#ifdef __AVR_ATxmega128A1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128A1__" -#endif - -#ifdef __AVR_ATxmega128A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128A3__" -#endif - -#ifdef __AVR_ATxmega128D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128D3__" -#endif - -#ifdef __AVR_ATxmega16A4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega16A4__" -#endif - -#ifdef __AVR_ATxmega16D4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega16D4__" -#endif - -#ifdef __AVR_ATxmega192A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega192A3__" -#endif - -#ifdef __AVR_ATxmega192D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega192D3__" -#endif - -#ifdef __AVR_ATxmega256A3B__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega256A3B__" -#endif - -#ifdef __AVR_ATxmega256A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega256A3__" -#endif - -#ifdef __AVR_ATxmega256D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega256D3__" -#endif - -#ifdef __AVR_ATxmega32A4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega32A4__" -#endif - -#ifdef __AVR_ATxmega32D4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega32D4__" -#endif - -#ifdef __AVR_ATxmega64A1U__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64A1U__" -#endif - -#ifdef __AVR_ATxmega64A1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64A1__" -#endif - -#ifdef __AVR_ATxmega64A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64A3__" -#endif - -#ifdef __AVR_ATxmega64D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64D3__" -#endif \ No newline at end of file diff --git a/firmware/Nanpy/intdefs.h b/firmware/Nanpy/intdefs.h deleted file mode 100644 index 9ad0eee..0000000 --- a/firmware/Nanpy/intdefs.h +++ /dev/null @@ -1,18 +0,0 @@ - -// frequently used constants should be placed first -DEFINE(A0) -DEFINE(NUM_DIGITAL_PINS) -DEFINE(RAMEND) -DEFINE(XRAMEND) -DEFINE(E2END) -DEFINE(FLASHEND) -DEFINE(SPM_PAGESIZE) -DEFINE(E2PAGESIZE) -DEFINE(F_CPU) -DEFINE(ARDUINO) -DEFINE(SS) -DEFINE(MOSI) -DEFINE(MISO) -DEFINE(SCK) -DEFINE(__AVR_LIBC_DATE_) -DEFINE(__AVR_LIBC_VERSION__) diff --git a/firmware/Nanpy/timers.h b/firmware/Nanpy/timers.h deleted file mode 100644 index 6a8c3f5..0000000 --- a/firmware/Nanpy/timers.h +++ /dev/null @@ -1,501 +0,0 @@ - -#ifndef FreqCount_timers_h_ -#define FreqCount_timers_h_ - -#include -#include - -// Arduino Mega -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - // #define COUNTER_USE_TIMER1 // T1 is not connected - // #define COUNTER_USE_TIMER3 // T3 is not connected - // #define COUNTER_USE_TIMER4 // T4 is not connected - #define COUNTER_USE_TIMER5 // T5 is pin 47 - #define TIMER_USE_TIMER2 - -// Teensy 2.0 -#elif defined(__AVR_ATmega32U4__) - #define COUNTER_USE_TIMER1 // T1 is pin 11 (has LED connected) - #define TIMER_USE_TIMER4H - -// Teensy++ 1.0 & 2.0 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) - #define COUNTER_USE_TIMER1 // T1 is pin 6 (has LED connected) - //#define COUNTER_USE_TIMER3 // T3 is pin 13 - #define TIMER_USE_TIMER2 - -// Sanguino -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) - #define COUNTER_USE_TIMER1 // T1 is pin 1 - #define TIMER_USE_TIMER2 - -// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc -#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) - #define COUNTER_USE_TIMER1 // T1 is pin 5 - #define TIMER_USE_TIMER2 - -#else - #error "Unknown chip, please edit me with timer+counter definitions" - -#endif - - -/**********************************************/ -/* Counter Hardware Abstraction */ -/**********************************************/ - -#if defined(COUNTER_USE_TIMER1) // 16 bit Timer 1 - -static uint8_t saveTCCR1A, saveTCCR1B; - -static inline void counter_init(void) -{ - saveTCCR1A = TCCR1A; - saveTCCR1B = TCCR1B; - TCCR1B = 0; - TCCR1A = 0; - TCNT1 = 0; - TIFR1 = (1<= 16000000L - #define TIMER2_OCR2A_1MS_VAL 124 // div 125 - #define TIMER2_TCCR2B_1MS_VAL (1<> 3; - OCR2A = TIMER2_OCR2A_8MS_VAL; - startTCCR2B = TIMER2_TCCR2B_8MS_VAL; - } else if ((msec & 3) == 0) { - gate_len = msec >> 2; - OCR2A = TIMER2_OCR2A_4MS_VAL; - startTCCR2B = TIMER2_TCCR2B_4MS_VAL; - } else if ((msec & 1) == 0) { - gate_len = msec >> 1; - OCR2A = TIMER2_OCR2A_2MS_VAL; - startTCCR2B = TIMER2_TCCR2B_2MS_VAL; - } else { - gate_len = msec; - OCR2A = TIMER2_OCR2A_1MS_VAL; - startTCCR2B = TIMER2_TCCR2B_1MS_VAL; - } - TIFR2 = (1<: -2 326: 1f 92 push r1 -2 328: 0f 92 push r0 -1 32a: 0f b6 in r0, 0x3f ; 63 -2 32c: 0f 92 push r0 -1 32e: 11 24 eor r1, r1 -2 330: ef 92 push r14 -2 332: ff 92 push r15 -2 334: 0f 93 push r16 -2 336: 1f 93 push r17 -2 338: 2f 93 push r18 -2 33a: 3f 93 push r19 -2 33c: 4f 93 push r20 -2 33e: 5f 93 push r21 -2 340: 8f 93 push r24 -2 342: 9f 93 push r25 -2 344: af 93 push r26 -2 346: bf 93 push r27 -*/ -#define TIMER_LATENCY_CYCLES 34 - - - -#elif defined(TIMER_USE_TIMER4H) // 10 bit "high speed" Timer 4 - -#define TIMER4H_OCR4C_VAL 124 // always div 125 -#if F_CPU == 16000000L - #define TIMER4H_TCCR4B_1MS_VAL (1<> 3; - startTCCR4B = TIMER4H_TCCR4B_8MS_VAL | (1<> 2; - startTCCR4B = TIMER4H_TCCR4B_4MS_VAL | (1<> 1; - startTCCR4B = TIMER4H_TCCR4B_2MS_VAL | (1< Date: Fri, 21 Mar 2014 19:35:58 +0100 Subject: [PATCH 199/344] Removed makefile stuff, moved to firmware repo --- tests/makefile_stuff/Makefile | 1 - tests/makefile_stuff/arduino.mk | 448 ----------- .../CapacitiveSensor/CapacitiveSensor.cpp | 181 ----- .../CapacitiveSensor/CapacitiveSensor.h | 51 -- .../libraries/CapacitiveSensor/README.md | 4 - .../CapacitiveSensorSketch.pde | 39 - .../libraries/CapacitiveSensor/keywords.txt | 6 - tests/makefile_stuff/libraries/DHT/DHT.cpp | 161 ---- tests/makefile_stuff/libraries/DHT/DHT.h | 39 - tests/makefile_stuff/libraries/DHT/README.txt | 3 - .../DHT/examples/DHTtester/DHTtester.pde | 44 -- .../DallasTemperature/DallasTemperature.cpp | 738 ------------------ .../DallasTemperature/DallasTemperature.h | 242 ------ .../libraries/DallasTemperature/README.TXT | 53 -- .../libraries/DallasTemperature/change.txt | 85 -- .../examples/Alarm/Alarm.pde | 162 ---- .../examples/AlarmHandler/AlarmHandler.pde | 144 ---- .../examples/Multiple/Multiple.pde | 140 ---- .../examples/Simple/Simple.pde | 33 - .../examples/Single/Single.pde | 109 --- .../examples/Tester/Tester.pde | 124 --- .../WaitForConversion/WaitForConversion.pde | 66 -- .../WaitForConversion2/WaitForConversion2.pde | 80 -- .../libraries/DallasTemperature/keywords.txt | 54 -- .../libraries/OneWire/OneWire.cpp | 527 ------------- .../libraries/OneWire/OneWire.h | 192 ----- .../DS18x20_Temperature.pde | 109 --- .../examples/DS2408_Switch/DS2408_Switch.pde | 77 -- .../examples/DS250x_PROM/DS250x_PROM.pde | 90 --- .../libraries/OneWire/keywords.txt | 38 - tests/test_make.py | 15 - 31 files changed, 4055 deletions(-) delete mode 100644 tests/makefile_stuff/Makefile delete mode 100644 tests/makefile_stuff/arduino.mk delete mode 100644 tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.cpp delete mode 100644 tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.h delete mode 100644 tests/makefile_stuff/libraries/CapacitiveSensor/README.md delete mode 100644 tests/makefile_stuff/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde delete mode 100644 tests/makefile_stuff/libraries/CapacitiveSensor/keywords.txt delete mode 100644 tests/makefile_stuff/libraries/DHT/DHT.cpp delete mode 100644 tests/makefile_stuff/libraries/DHT/DHT.h delete mode 100644 tests/makefile_stuff/libraries/DHT/README.txt delete mode 100644 tests/makefile_stuff/libraries/DHT/examples/DHTtester/DHTtester.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.cpp delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.h delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/README.TXT delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/change.txt delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/Alarm/Alarm.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/Multiple/Multiple.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/Simple/Simple.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/Single/Single.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/Tester/Tester.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde delete mode 100644 tests/makefile_stuff/libraries/DallasTemperature/keywords.txt delete mode 100644 tests/makefile_stuff/libraries/OneWire/OneWire.cpp delete mode 100644 tests/makefile_stuff/libraries/OneWire/OneWire.h delete mode 100644 tests/makefile_stuff/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde delete mode 100644 tests/makefile_stuff/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde delete mode 100644 tests/makefile_stuff/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde delete mode 100644 tests/makefile_stuff/libraries/OneWire/keywords.txt delete mode 100644 tests/test_make.py diff --git a/tests/makefile_stuff/Makefile b/tests/makefile_stuff/Makefile deleted file mode 100644 index 29ebe54..0000000 --- a/tests/makefile_stuff/Makefile +++ /dev/null @@ -1 +0,0 @@ -include arduino.mk diff --git a/tests/makefile_stuff/arduino.mk b/tests/makefile_stuff/arduino.mk deleted file mode 100644 index b9acb8d..0000000 --- a/tests/makefile_stuff/arduino.mk +++ /dev/null @@ -1,448 +0,0 @@ -#_______________________________________________________________________________ -# -# edam's Arduino makefile -#_______________________________________________________________________________ -# version 0.5 -# -# Copyright (C) 2011, 2012, 2013 Tim Marston . -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -#_______________________________________________________________________________ -# -# -# This is a general purpose makefile for use with Arduino hardware and -# software. It works with the arduino-1.0 and later software releases. It -# should work GNU/Linux and OS X. To download the latest version of this -# makefile visit the following website where you can also find documentation on -# it's use. (The following text can only really be considered a reference.) -# -# http://ed.am/dev/make/arduino-mk -# -# This makefile can be used as a drop-in replacement for the Arduino IDE's -# build system. To use it, just copy arduino.mk in to your project directory. -# Or, you could save it somewhere (I keep mine at ~/src/arduino.mk) and create -# a symlink to it in your project directory, named "Makefile". For example: -# -# $ ln -s ~/src/arduino.mk Makefile -# -# The Arduino software (version 1.0 or later) is required. On GNU/Linux you -# can probably install the software from your package manager. If you are -# using Debian (or a derivative), try `apt-get install arduino`. Otherwise, -# you can download the Arduino software manually from http://arduino.cc/. It -# is suggested that you install it at ~/opt/arduino (or /Applications on OS X) -# if you are unsure. -# -# If you downloaded the Arduino software manually and unpacked it somewhere -# other than ~/opt/arduino (or /Applications), you will need to set up the -# ARDUINODIR environment variable to be the path where you unpacked it. (If -# unset, ARDUINODIR defaults to some sensible places). You could set this in -# your ~/.profile by adding something like this: -# -# export ARDUINODIR=~/somewhere/arduino-1.0 -# -# For each project, you will also need to set BOARD to the type of Arduino -# you're building for. Type `make boards` for a list of acceptable values. -# For example: -# -# $ export BOARD=uno -# $ make -# -# You may also need to set SERIALDEV if it is not detected correctly. -# -# The presence of a .ino (or .pde) file causes the arduino.mk to automatically -# determine values for SOURCES, TARGET and LIBRARIES. Any .c, .cc and .cpp -# files in the project directory (or any "util" or "utility" subdirectories) -# are automatically included in the build and are scanned for Arduino libraries -# that have been #included. Note, there can only be one .ino (or .pde) file in -# a project directory and if you want to be compatible with the Arduino IDE, it -# should be called the same as the directory name. -# -# Alternatively, if you want to manually specify build variables, create a -# Makefile that defines SOURCES and LIBRARIES and then includes arduino.mk. -# (There is no need to define TARGET). You can also specify the BOARD here, if -# the project has a specific one. Here is an example Makefile: -# -# SOURCES := main.cc other.cc -# LIBRARIES := EEPROM -# BOARD := pro5v -# include ~/src/arduino.mk -# -# Here is a complete list of configuration parameters: -# -# ARDUINODIR The path where the Arduino software is installed on your system. -# -# ARDUINOCONST The Arduino software version, as an integer, used to define the -# ARDUINO version constant. This defaults to 100 if undefined. -# -# AVRDUDECONF The avrdude.conf to use. If undefined, this defaults to a guess -# based on where avrdude is. If set empty, no avrdude.conf is -# passed to avrdude (so the system default is used). -# -# AVRDUDEFLAGS Specify any additional flags for avrdude. The usual flags, -# required to build the project, will be appended to this. -# -# AVRTOOLSPATH A space-separated list of directories that is searched in order -# when looking for the avr build tools. This defaults to PATH, -# followed by subdirectories in ARDUINODIR. -# -# BOARD Specify a target board type. Run `make boards` to see available -# board types. -# -# CPPFLAGS Specify any additional flags for the compiler. The usual flags, -# required to build the project, will be appended to this. -# -# LINKFLAGS Specify any additional flags for the linker. The usual flags, -# required to build the project, will be appended to this. -# -# LIBRARIES A list of Arduino libraries to build and include. This is set -# automatically if a .ino (or .pde) is found. -# -# LIBRARYPATH A space-separated list of directories that is searched in order -# when looking for Arduino libraries. This defaults to "libs", -# "libraries" (in the project directory), then your sketchbook -# "libraries" directory, then the Arduino libraries directory. -# -# SERIALDEV The POSIX device name of the serial device that is the Arduino. -# If unspecified, an attempt is made to guess the name of a -# connected Arduino's serial device, which may work in some cases. -# -# SOURCES A list of all source files of whatever language. The language -# type is determined by the file extension. This is set -# automatically if a .ino (or .pde) is found. -# -# TARGET The name of the target file. This is set automatically if a -# .ino (or .pde) is found, but it is not necessary to set it -# otherwise. -# -# This makefile also defines the following goals for use on the command line -# when you run make: -# -# all This is the default if no goal is specified. It builds the -# target. -# -# target Builds the target. -# -# upload Uploads the target (building it, as necessary) to an attached -# Arduino. -# -# clean Deletes files created during the build. -# -# boards Display a list of available board names, so that you can set the -# BOARD environment variable appropriately. -# -# monitor Start `screen` on the serial device. This is meant to be an -# equivalent to the Arduino serial monitor. -# -# size Displays size information about the built target. -# -# bootloader Burns the bootloader for your board to it. -# -# Builds the specified file, either an object file or the target, -# from those that that would be built for the project. -#_______________________________________________________________________________ -# - -# default arduino software directory, check software exists -ifndef ARDUINODIR -ARDUINODIR := $(firstword $(wildcard ~/opt/arduino /usr/share/arduino \ - /Applications/Arduino.app/Contents/Resources/Java \ - $(HOME)/Applications/Arduino.app/Contents/Resources/Java)) -endif -ifeq "$(wildcard $(ARDUINODIR)/hardware/arduino/boards.txt)" "" -$(error ARDUINODIR is not set correctly; arduino software not found) -endif - -# default arduino version -ARDUINOCONST ?= 100 - -# default path for avr tools -AVRTOOLSPATH ?= $(subst :, , $(PATH)) $(ARDUINODIR)/hardware/tools \ - $(ARDUINODIR)/hardware/tools/avr/bin - -# default path to find libraries -LIBRARYPATH ?= libraries libs $(SKETCHBOOKDIR)/libraries $(ARDUINODIR)/libraries - -# default serial device to a poor guess (something that might be an arduino) -SERIALDEVGUESS := 0 -ifndef SERIALDEV -SERIALDEV := $(firstword $(wildcard \ - /dev/ttyACM? /dev/ttyUSB? /dev/tty.usbserial* /dev/tty.usbmodem*)) -SERIALDEVGUESS := 1 -endif - -# no board? -ifndef BOARD -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -#$(error BOARD is unset. Type 'make boards' to see possible values) -BOARD := uno -endif -endif -endif - -# obtain board parameters from the arduino boards.txt file -BOARDSFILE := $(ARDUINODIR)/hardware/arduino/boards.txt -readboardsparam = $(shell sed -ne "s/$(BOARD).$(1)=\(.*\)/\1/p" $(BOARDSFILE)) -BOARD_BUILD_MCU := $(call readboardsparam,build.mcu) -BOARD_BUILD_FCPU := $(call readboardsparam,build.f_cpu) -BOARD_BUILD_VARIANT := $(call readboardsparam,build.variant) -BOARD_UPLOAD_SPEED := $(call readboardsparam,upload.speed) -BOARD_UPLOAD_PROTOCOL := $(call readboardsparam,upload.protocol) -BOARD_USB_VID := $(call readboardsparam,build.vid) -BOARD_USB_PID := $(call readboardsparam,build.pid) -BOARD_BOOTLOADER_UNLOCK := $(call readboardsparam,bootloader.unlock_bits) -BOARD_BOOTLOADER_LOCK := $(call readboardsparam,bootloader.lock_bits) -BOARD_BOOTLOADER_LFUSES := $(call readboardsparam,bootloader.low_fuses) -BOARD_BOOTLOADER_HFUSES := $(call readboardsparam,bootloader.high_fuses) -BOARD_BOOTLOADER_EFUSES := $(call readboardsparam,bootloader.extended_fuses) -BOARD_BOOTLOADER_PATH := $(call readboardsparam,bootloader.path) -BOARD_BOOTLOADER_FILE := $(call readboardsparam,bootloader.file) - -# obtain preferences from the IDE's preferences.txt -PREFERENCESFILE := $(firstword $(wildcard \ - $(HOME)/.arduino/preferences.txt $(HOME)/Library/Arduino/preferences.txt)) -ifneq "$(PREFERENCESFILE)" "" -readpreferencesparam = $(shell sed -ne "s/$(1)=\(.*\)/\1/p" $(PREFERENCESFILE)) -SKETCHBOOKDIR := $(call readpreferencesparam,sketchbook.path) -endif - -# invalid board? -ifeq "$(BOARD_BUILD_MCU)" "" -ifneq "$(MAKECMDGOALS)" "boards" -ifneq "$(MAKECMDGOALS)" "clean" -$(error BOARD is invalid. Type 'make boards' to see possible values) -endif -endif -endif - -# auto mode? -INOFILE := $(wildcard *.ino *.pde) -ifdef INOFILE -ifneq "$(words $(INOFILE))" "1" -$(error There is more than one .pde or .ino file in this directory!) -endif - -# automatically determine sources and targeet -TARGET := $(basename $(INOFILE)) -SOURCES := $(INOFILE) \ - $(wildcard *.c *.cc *.cpp *.C) \ - $(wildcard $(addprefix util/, *.c *.cc *.cpp *.C)) \ - $(wildcard $(addprefix utility/, *.c *.cc *.cpp *.C)) - -# automatically determine included libraries -LIBRARIES := $(filter $(notdir $(wildcard $(addsuffix /*, $(LIBRARYPATH)))), \ - $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(SOURCES))) - -endif - -# software -findsoftware = $(firstword $(wildcard $(addsuffix /$(1), $(AVRTOOLSPATH)))) -CC := $(call findsoftware,avr-gcc) -CXX := $(call findsoftware,avr-g++) -LD := $(call findsoftware,avr-ld) -AR := $(call findsoftware,avr-ar) -OBJCOPY := $(call findsoftware,avr-objcopy) -AVRDUDE := $(call findsoftware,avrdude) -AVRSIZE := $(call findsoftware,avr-size) - -# directories -ARDUINOCOREDIR := $(ARDUINODIR)/hardware/arduino/cores/arduino -LIBRARYDIRS := $(foreach lib, $(LIBRARIES), \ - $(firstword $(wildcard $(addsuffix /$(lib), $(LIBRARYPATH))))) -LIBRARYDIRS += $(addsuffix /utility, $(LIBRARYDIRS)) - -# files -TARGET := $(if $(TARGET),$(TARGET),a.out) -OBJECTS := $(addsuffix .o, $(basename $(SOURCES))) -DEPFILES := $(patsubst %, .dep/%.dep, $(SOURCES)) -ARDUINOLIB := .lib/arduino.a -ARDUINOLIBOBJS := $(foreach dir, $(ARDUINOCOREDIR) $(LIBRARYDIRS), \ - $(patsubst %, .lib/%.o, $(wildcard $(addprefix $(dir)/, *.c *.cpp)))) -BOOTLOADERHEX := $(addprefix \ - $(ARDUINODIR)/hardware/arduino/bootloaders/$(BOARD_BOOTLOADER_PATH)/, \ - $(BOARD_BOOTLOADER_FILE)) - -# avrdude confifuration -ifeq "$(AVRDUDECONF)" "" -ifeq "$(AVRDUDE)" "$(ARDUINODIR)/hardware/tools/avr/bin/avrdude" -AVRDUDECONF := $(ARDUINODIR)/hardware/tools/avr/etc/avrdude.conf -else -AVRDUDECONF := $(wildcard $(AVRDUDE).conf) -endif -endif - -# flags -CPPFLAGS += -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -CPPFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CPPFLAGS += -mmcu=$(BOARD_BUILD_MCU) -CPPFLAGS += -DF_CPU=$(BOARD_BUILD_FCPU) -DARDUINO=$(ARDUINOCONST) -CPPFLAGS += -DUSB_VID=$(BOARD_USB_VID) -DUSB_PID=$(BOARD_USB_PID) -CPPFLAGS += -I. -Iutil -Iutility -I $(ARDUINOCOREDIR) -CPPFLAGS += -I $(ARDUINODIR)/hardware/arduino/variants/$(BOARD_BUILD_VARIANT)/ -CPPFLAGS += $(addprefix -I , $(LIBRARYDIRS)) -CPPDEPFLAGS = -MMD -MP -MF .dep/$<.dep -CPPINOFLAGS := -x c++ -include $(ARDUINOCOREDIR)/Arduino.h -AVRDUDEFLAGS += $(addprefix -C , $(AVRDUDECONF)) -DV -AVRDUDEFLAGS += -p $(BOARD_BUILD_MCU) -P $(SERIALDEV) -AVRDUDEFLAGS += -c $(BOARD_UPLOAD_PROTOCOL) -b $(BOARD_UPLOAD_SPEED) -LINKFLAGS += -Os -Wl,--gc-sections -mmcu=$(BOARD_BUILD_MCU) - -# figure out which arg to use with stty (for OS X, GNU and busybox stty) -STTYFARG := $(shell stty --help 2>&1 | \ - grep -q 'illegal option' && echo -f || echo -F) - -# include dependencies -ifneq "$(MAKECMDGOALS)" "clean" --include $(DEPFILES) -endif - -# default rule -.DEFAULT_GOAL := all - -#_______________________________________________________________________________ -# RULES - -.PHONY: all target upload clean boards monitor size bootloader - -all: target - -target: $(TARGET).hex - -upload: target - @echo "\nUploading to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } -ifeq "$(BOARD_BOOTLOADER_PATH)" "caterina" - stty $(STTYFARG) $(SERIALDEV) speed 1200 - sleep 1 -else - stty $(STTYFARG) $(SERIALDEV) hupcl -endif - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(TARGET).hex:i - -clean: - rm -f $(OBJECTS) - rm -f $(TARGET).elf $(TARGET).hex $(ARDUINOLIB) *~ - rm -rf .lib .dep - -boards: - @echo "Available values for BOARD:" - @sed -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDSFILE) | \ - sed -Ee 's/([^.]+)\.name=(.*)/\1 \2/' \ - -e 's/(.{12}) *(.*)/\1 \2/' - -monitor: - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test -n `which screen` || { \ - echo "error: can't find GNU screen, you might need to install it." >&2 \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - screen $(SERIALDEV) - -size: $(TARGET).elf - echo && $(AVRSIZE) --format=avr --mcu=$(BOARD_BUILD_MCU) $(TARGET).elf - -bootloader: - @echo "Burning bootloader to board..." - @test -n "$(SERIALDEV)" || { \ - echo "error: SERIALDEV could not be determined automatically." >&2; \ - exit 1; } - @test 0 -eq $(SERIALDEVGUESS) || { \ - echo "*GUESSING* at serial device:" $(SERIALDEV); \ - echo; } - stty $(STTYFARG) $(SERIALDEV) hupcl - $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_UNLOCK):m - $(AVRDUDE) $(AVRDUDEFLAGS) -eU lfuse:w:$(BOARD_BOOTLOADER_LFUSES):m - $(AVRDUDE) $(AVRDUDEFLAGS) -U hfuse:w:$(BOARD_BOOTLOADER_HFUSES):m -ifneq "$(BOARD_BOOTLOADER_EFUSES)" "" - $(AVRDUDE) $(AVRDUDEFLAGS) -U efuse:w:$(BOARD_BOOTLOADER_EFUSES):m -endif -ifneq "$(BOOTLOADERHEX)" "" - $(AVRDUDE) $(AVRDUDEFLAGS) -U flash:w:$(BOOTLOADERHEX):i -endif - $(AVRDUDE) $(AVRDUDEFLAGS) -U lock:w:$(BOARD_BOOTLOADER_LOCK):m - -# building the target - -$(TARGET).hex: $(TARGET).elf - $(OBJCOPY) -O ihex -R .eeprom $< $@ - -.INTERMEDIATE: $(TARGET).elf - -$(TARGET).elf: $(ARDUINOLIB) $(OBJECTS) - $(CC) $(LINKFLAGS) $(OBJECTS) $(ARDUINOLIB) -lm -o $@ - -%.o: %.c - mkdir -p .dep/$(dir $<) - $(COMPILE.c) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cpp - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.cc - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.C - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $< - -%.o: %.ino - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -%.o: %.pde - mkdir -p .dep/$(dir $<) - $(COMPILE.cpp) $(CPPDEPFLAGS) -o $@ $(CPPINOFLAGS) $< - -# building the arduino library - -$(ARDUINOLIB): $(ARDUINOLIBOBJS) - $(AR) rcs $@ $? - -.lib/%.c.o: %.c - mkdir -p $(dir $@) - $(COMPILE.c) -o $@ $< - -.lib/%.cpp.o: %.cpp - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.cc.o: %.cc - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -.lib/%.C.o: %.C - mkdir -p $(dir $@) - $(COMPILE.cpp) -o $@ $< - -# Local Variables: -# mode: makefile -# tab-width: 4 -# End: \ No newline at end of file diff --git a/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.cpp b/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.cpp deleted file mode 100644 index 54e0d81..0000000 --- a/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - CapacitiveSense.h v.04 - Capacitive Sensing Library for 'duino / Wiring - Copyright (c) 2009 Paul Bagder All right reserved. - Version 04 by Paul Stoffregen - Arduino 1.0 compatibility, issue 146 fix - vim: set ts=4: - */ - -#if ARDUINO >= 100 -#include "Arduino.h" -#else -#include "WProgram.h" -#include "pins_arduino.h" -#include "WConstants.h" -#endif - -#include "CapacitiveSensor.h" - -// Constructor ///////////////////////////////////////////////////////////////// -// Function that handles the creation and setup of instances - -CapacitiveSensor::CapacitiveSensor(uint8_t sendPin, uint8_t receivePin) -{ - uint8_t sPort, rPort; - - // initialize this instance's variables - // Serial.begin(9600); // for debugging - error = 1; - loopTimingFactor = 310; // determined empirically - a hack - - CS_Timeout_Millis = (2000 * (float)loopTimingFactor * (float)F_CPU) / 16000000; - CS_AutocaL_Millis = 20000; - - // Serial.print("timwOut = "); - // Serial.println(CS_Timeout_Millis); - - // get pin mapping and port for send Pin - from PinMode function in core - -#ifdef NUM_DIGITAL_PINS - if (sendPin >= NUM_DIGITAL_PINS) error = -1; - if (receivePin >= NUM_DIGITAL_PINS) error = -1; -#endif - - sBit = digitalPinToBitMask(sendPin); // get send pin's ports and bitmask - sPort = digitalPinToPort(sendPin); - sReg = portModeRegister(sPort); - sOut = portOutputRegister(sPort); // get pointer to output register - - rBit = digitalPinToBitMask(receivePin); // get receive pin's ports and bitmask - rPort = digitalPinToPort(receivePin); - rReg = portModeRegister(rPort); - rIn = portInputRegister(rPort); - rOut = portOutputRegister(rPort); - - // get pin mapping and port for receive Pin - from digital pin functions in Wiring.c - noInterrupts(); - *sReg |= sBit; // set sendpin to OUTPUT - interrupts(); - leastTotal = 0x0FFFFFFFL; // input large value for autocalibrate begin - lastCal = millis(); // set millis for start -} - -// Public Methods ////////////////////////////////////////////////////////////// -// Functions available in Wiring sketches, this library, and other libraries - -long CapacitiveSensor::capacitiveSensor(uint8_t samples) -{ - total = 0; - if (samples == 0) return 0; - if (error < 0) return -1; // bad pin - - - for (uint8_t i = 0; i < samples; i++) { // loop for samples parameter - simple lowpass filter - if (SenseOneCycle() < 0) return -2; // variable over timeout -} - - // only calibrate if time is greater than CS_AutocaL_Millis and total is less than 10% of baseline - // this is an attempt to keep from calibrating when the sensor is seeing a "touched" signal - - if ( (millis() - lastCal > CS_AutocaL_Millis) && abs(total - leastTotal) < (int)(.10 * (float)leastTotal) ) { - - // Serial.println(); // debugging - // Serial.println("auto-calibrate"); - // Serial.println(); - // delay(2000); */ - - leastTotal = 0x0FFFFFFFL; // reset for "autocalibrate" - lastCal = millis(); - } - /*else{ // debugging - Serial.print(" total = "); - Serial.print(total); - - Serial.print(" leastTotal = "); - Serial.println(leastTotal); - - Serial.print("total - leastTotal = "); - x = total - leastTotal ; - Serial.print(x); - Serial.print(" .1 * leastTotal = "); - x = (int)(.1 * (float)leastTotal); - Serial.println(x); - } */ - - // routine to subtract baseline (non-sensed capacitance) from sensor return - if (total < leastTotal) leastTotal = total; // set floor value to subtract from sensed value - return(total - leastTotal); - -} - -long CapacitiveSensor::capacitiveSensorRaw(uint8_t samples) -{ - total = 0; - if (samples == 0) return 0; - if (error < 0) return -1; // bad pin - this appears not to work - - for (uint8_t i = 0; i < samples; i++) { // loop for samples parameter - simple lowpass filter - if (SenseOneCycle() < 0) return -2; // variable over timeout - } - - return total; -} - - -void CapacitiveSensor::reset_CS_AutoCal(void){ - leastTotal = 0x0FFFFFFFL; -} - -void CapacitiveSensor::set_CS_AutocaL_Millis(unsigned long autoCal_millis){ - CS_AutocaL_Millis = autoCal_millis; -} - -void CapacitiveSensor::set_CS_Timeout_Millis(unsigned long timeout_millis){ - CS_Timeout_Millis = (timeout_millis * (float)loopTimingFactor * (float)F_CPU) / 16000000; // floats to deal with large numbers -} - -// Private Methods ///////////////////////////////////////////////////////////// -// Functions only available to other functions in this library - -int CapacitiveSensor::SenseOneCycle(void) -{ - noInterrupts(); - *sOut &= ~sBit; // set Send Pin Register low - - *rReg &= ~rBit; // set receivePin to input - *rOut &= ~rBit; // set receivePin Register low to make sure pullups are off - - *rReg |= rBit; // set pin to OUTPUT - pin is now LOW AND OUTPUT - *rReg &= ~rBit; // set pin to INPUT - - *sOut |= sBit; // set send Pin High - interrupts(); - - while ( !(*rIn & rBit) && (total < CS_Timeout_Millis) ) { // while receive pin is LOW AND total is positive value - total++; - } - - if (total > CS_Timeout_Millis) { - return -2; // total variable over timeout - } - - // set receive pin HIGH briefly to charge up fully - because the while loop above will exit when pin is ~ 2.5V - noInterrupts(); - *rOut |= rBit; // set receive pin HIGH - turns on pullup - *rReg |= rBit; // set pin to OUTPUT - pin is now HIGH AND OUTPUT - *rReg &= ~rBit; // set pin to INPUT - *rOut &= ~rBit; // turn off pullup - - *sOut &= ~sBit; // set send Pin LOW - interrupts(); - - while ( (*rIn & rBit) && (total < CS_Timeout_Millis) ) { // while receive pin is HIGH AND total is less than timeout - total++; - } - // Serial.println(total); - - if (total >= CS_Timeout_Millis) { - return -2; // total variable over timeout - } else { - return 1; - } -} diff --git a/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.h b/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.h deleted file mode 100644 index 45424b1..0000000 --- a/tests/makefile_stuff/libraries/CapacitiveSensor/CapacitiveSensor.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - CapacitiveSense.h v.04 - Capacitive Sensing Library for 'duino / Wiring - Copyright (c) 2008 Paul Bagder All rights reserved. - Version 04 by Paul Stoffregen - Arduino 1.0 compatibility, issue 146 fix - vim: set ts=4: -*/ - -// ensure this library description is only included once -#ifndef CapacitiveSensor_h -#define CapacitiveSensor_h - -#if ARDUINO >= 100 -#include "Arduino.h" -#else -#include "WProgram.h" -#endif - -// library interface description -class CapacitiveSensor -{ - // user-accessible "public" interface - public: - // methods - CapacitiveSensor(uint8_t sendPin, uint8_t receivePin); - long capacitiveSensorRaw(uint8_t samples); - long capacitiveSensor(uint8_t samples); - void set_CS_Timeout_Millis(unsigned long timeout_millis); - void reset_CS_AutoCal(); - void set_CS_AutocaL_Millis(unsigned long autoCal_millis); - // library-accessible "private" interface - private: - // variables - int error; - unsigned long leastTotal; - unsigned int loopTimingFactor; - unsigned long CS_Timeout_Millis; - unsigned long CS_AutocaL_Millis; - unsigned long lastCal; - unsigned long total; - uint8_t sBit; // send pin's ports and bitmask - volatile uint8_t *sReg; - volatile uint8_t *sOut; - uint8_t rBit; // receive pin's ports and bitmask - volatile uint8_t *rReg; - volatile uint8_t *rIn; - volatile uint8_t *rOut; - // methods - int SenseOneCycle(void); -}; - -#endif diff --git a/tests/makefile_stuff/libraries/CapacitiveSensor/README.md b/tests/makefile_stuff/libraries/CapacitiveSensor/README.md deleted file mode 100644 index 0799c96..0000000 --- a/tests/makefile_stuff/libraries/CapacitiveSensor/README.md +++ /dev/null @@ -1,4 +0,0 @@ -CapacitiveSensor -================ - -CapacitiveSensor \ No newline at end of file diff --git a/tests/makefile_stuff/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde b/tests/makefile_stuff/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde deleted file mode 100644 index a036612..0000000 --- a/tests/makefile_stuff/libraries/CapacitiveSensor/examples/CapacitiveSensorSketch/CapacitiveSensorSketch.pde +++ /dev/null @@ -1,39 +0,0 @@ -#include - -/* - * CapitiveSense Library Demo Sketch - * Paul Badger 2008 - * Uses a high value resistor e.g. 10M between send pin and receive pin - * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values. - * Receive pin is the sensor pin - try different amounts of foil/metal on this pin - */ - - -CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired -CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil -CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil - -void setup() -{ - cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example - Serial.begin(9600); -} - -void loop() -{ - long start = millis(); - long total1 = cs_4_2.capacitiveSensor(30); - long total2 = cs_4_6.capacitiveSensor(30); - long total3 = cs_4_8.capacitiveSensor(30); - - Serial.print(millis() - start); // check on performance in milliseconds - Serial.print("\t"); // tab character for debug windown spacing - - Serial.print(total1); // print sensor output 1 - Serial.print("\t"); - Serial.print(total2); // print sensor output 2 - Serial.print("\t"); - Serial.println(total3); // print sensor output 3 - - delay(10); // arbitrary delay to limit data to serial port -} diff --git a/tests/makefile_stuff/libraries/CapacitiveSensor/keywords.txt b/tests/makefile_stuff/libraries/CapacitiveSensor/keywords.txt deleted file mode 100644 index 1933303..0000000 --- a/tests/makefile_stuff/libraries/CapacitiveSensor/keywords.txt +++ /dev/null @@ -1,6 +0,0 @@ -CapacitiveSensor KEYWORD1 -capacitiveSensorRaw KEYWORD2 -capacitiveSensor KEYWORD2 -set_CS_Timeout_Millis KEYWORD2 -reset_CS_AutoCal KEYWORD2 -set_CS_AutocaL_Millis KEYWORD2 diff --git a/tests/makefile_stuff/libraries/DHT/DHT.cpp b/tests/makefile_stuff/libraries/DHT/DHT.cpp deleted file mode 100644 index efa1d39..0000000 --- a/tests/makefile_stuff/libraries/DHT/DHT.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -#include "DHT.h" - -DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { - _pin = pin; - _type = type; - _count = count; - firstreading = true; -} - -void DHT::begin(void) { - // set up the pins! - pinMode(_pin, INPUT); - digitalWrite(_pin, HIGH); - _lastreadtime = 0; -} - -//boolean S == Scale. True == Farenheit; False == Celcius -float DHT::readTemperature(bool S) { - float f; - - if (read()) { - switch (_type) { - case DHT11: - f = data[2]; - if(S) - f = convertCtoF(f); - - return f; - case DHT22: - case DHT21: - f = data[2] & 0x7F; - f *= 256; - f += data[3]; - f /= 10; - if (data[2] & 0x80) - f *= -1; - if(S) - f = convertCtoF(f); - - return f; - } - } - Serial.print("Read fail"); - return NAN; -} - -float DHT::convertCtoF(float c) { - return c * 9 / 5 + 32; -} - -float DHT::readHumidity(void) { - float f; - if (read()) { - switch (_type) { - case DHT11: - f = data[0]; - return f; - case DHT22: - case DHT21: - f = data[0]; - f *= 256; - f += data[1]; - f /= 10; - return f; - } - } - Serial.print("Read fail"); - return NAN; -} - - -boolean DHT::read(void) { - uint8_t laststate = HIGH; - uint8_t counter = 0; - uint8_t j = 0, i; - unsigned long currenttime; - - // pull the pin high and wait 250 milliseconds - digitalWrite(_pin, HIGH); - delay(250); - - currenttime = millis(); - if (currenttime < _lastreadtime) { - // ie there was a rollover - _lastreadtime = 0; - } - if (!firstreading && ((currenttime - _lastreadtime) < 2000)) { - return true; // return last correct measurement - //delay(2000 - (currenttime - _lastreadtime)); - } - firstreading = false; - /* - Serial.print("Currtime: "); Serial.print(currenttime); - Serial.print(" Lasttime: "); Serial.print(_lastreadtime); - */ - _lastreadtime = millis(); - - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - // now pull it low for ~20 milliseconds - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); - delay(20); - cli(); - digitalWrite(_pin, HIGH); - delayMicroseconds(40); - pinMode(_pin, INPUT); - - // read in timings - for ( i=0; i< MAXTIMINGS; i++) { - counter = 0; - while (digitalRead(_pin) == laststate) { - counter++; - delayMicroseconds(1); - if (counter == 255) { - break; - } - } - laststate = digitalRead(_pin); - - if (counter == 255) break; - - // ignore first 3 transitions - if ((i >= 4) && (i%2 == 0)) { - // shove each bit into the storage bytes - data[j/8] <<= 1; - if (counter > _count) - data[j/8] |= 1; - j++; - } - - } - - sei(); - - /* - Serial.println(j, DEC); - Serial.print(data[0], HEX); Serial.print(", "); - Serial.print(data[1], HEX); Serial.print(", "); - Serial.print(data[2], HEX); Serial.print(", "); - Serial.print(data[3], HEX); Serial.print(", "); - Serial.print(data[4], HEX); Serial.print(" =? "); - Serial.println(data[0] + data[1] + data[2] + data[3], HEX); - */ - - // check we read 40 bits and that the checksum matches - if ((j >= 40) && - (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) { - return true; - } - - - return false; - -} diff --git a/tests/makefile_stuff/libraries/DHT/DHT.h b/tests/makefile_stuff/libraries/DHT/DHT.h deleted file mode 100644 index 1c78c87..0000000 --- a/tests/makefile_stuff/libraries/DHT/DHT.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DHT_H -#define DHT_H -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -// how many timing transitions we need to keep track of. 2 * number bits + extra -#define MAXTIMINGS 85 - -#define DHT11 11 -#define DHT22 22 -#define DHT21 21 -#define AM2301 21 - -class DHT { - private: - uint8_t data[6]; - uint8_t _pin, _type, _count; - boolean read(void); - unsigned long _lastreadtime; - boolean firstreading; - - public: - DHT(uint8_t pin, uint8_t type, uint8_t count=6); - void begin(void); - float readTemperature(bool S=false); - float convertCtoF(float); - float readHumidity(void); - -}; -#endif diff --git a/tests/makefile_stuff/libraries/DHT/README.txt b/tests/makefile_stuff/libraries/DHT/README.txt deleted file mode 100644 index 4dfcbab..0000000 --- a/tests/makefile_stuff/libraries/DHT/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -This is an Arduino library for the DHT series of low cost temperature/humidity sensors. - -To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT. Check that the DHT folder contains DHT.cpp and DHT.h. Place the DHT library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. \ No newline at end of file diff --git a/tests/makefile_stuff/libraries/DHT/examples/DHTtester/DHTtester.pde b/tests/makefile_stuff/libraries/DHT/examples/DHTtester/DHTtester.pde deleted file mode 100644 index 8f40790..0000000 --- a/tests/makefile_stuff/libraries/DHT/examples/DHTtester/DHTtester.pde +++ /dev/null @@ -1,44 +0,0 @@ -// Example testing sketch for various DHT humidity/temperature sensors -// Written by ladyada, public domain - -#include "DHT.h" - -#define DHTPIN 2 // what pin we're connected to - -// Uncomment whatever type you're using! -//#define DHTTYPE DHT11 // DHT 11 -#define DHTTYPE DHT22 // DHT 22 (AM2302) -//#define DHTTYPE DHT21 // DHT 21 (AM2301) - -// Connect pin 1 (on the left) of the sensor to +5V -// Connect pin 2 of the sensor to whatever your DHTPIN is -// Connect pin 4 (on the right) of the sensor to GROUND -// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor - -DHT dht(DHTPIN, DHTTYPE); - -void setup() { - Serial.begin(9600); - Serial.println("DHTxx test!"); - - dht.begin(); -} - -void loop() { - // Reading temperature or humidity takes about 250 milliseconds! - // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) - float h = dht.readHumidity(); - float t = dht.readTemperature(); - - // check if returns are valid, if they are NaN (not a number) then something went wrong! - if (isnan(t) || isnan(h)) { - Serial.println("Failed to read from DHT"); - } else { - Serial.print("Humidity: "); - Serial.print(h); - Serial.print(" %\t"); - Serial.print("Temperature: "); - Serial.print(t); - Serial.println(" *C"); - } -} diff --git a/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.cpp b/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.cpp deleted file mode 100644 index 1409701..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.cpp +++ /dev/null @@ -1,738 +0,0 @@ -// This library 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. - -// Version 3.7.2 modified on Dec 6, 2011 to support Arduino 1.0 -// See Includes... -// Modified by Jordan Hochenbaum - -#include "DallasTemperature.h" - -#if ARDUINO >= 100 - #include "Arduino.h" -#else -extern "C" { - #include "WConstants.h" -} -#endif - -DallasTemperature::DallasTemperature(OneWire* _oneWire) - #if REQUIRESALARMS - : _AlarmHandler(&defaultAlarmHandler) - #endif -{ - _wire = _oneWire; - devices = 0; - parasite = false; - bitResolution = 9; - waitForConversion = true; - checkForConversion = true; -} - -// initialise the bus -void DallasTemperature::begin(void) -{ - DeviceAddress deviceAddress; - - _wire->reset_search(); - devices = 0; // Reset the number of devices when we enumerate wire devices - - while (_wire->search(deviceAddress)) - { - if (validAddress(deviceAddress)) - { - if (!parasite && readPowerSupply(deviceAddress)) parasite = true; - - ScratchPad scratchPad; - - readScratchPad(deviceAddress, scratchPad); - - bitResolution = max(bitResolution, getResolution(deviceAddress)); - - devices++; - } - } -} - -// returns the number of devices found on the bus -uint8_t DallasTemperature::getDeviceCount(void) -{ - return devices; -} - -// returns true if address is valid -bool DallasTemperature::validAddress(uint8_t* deviceAddress) -{ - return (_wire->crc8(deviceAddress, 7) == deviceAddress[7]); -} - -// finds an address at a given index on the bus -// returns true if the device was found -bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index) -{ - uint8_t depth = 0; - - _wire->reset_search(); - - while (depth <= index && _wire->search(deviceAddress)) - { - if (depth == index && validAddress(deviceAddress)) return true; - depth++; - } - - return false; -} - -// attempt to determine if the device at the given address is connected to the bus -bool DallasTemperature::isConnected(uint8_t* deviceAddress) -{ - ScratchPad scratchPad; - return isConnected(deviceAddress, scratchPad); -} - -// attempt to determine if the device at the given address is connected to the bus -// also allows for updating the read scratchpad -bool DallasTemperature::isConnected(uint8_t* deviceAddress, uint8_t* scratchPad) -{ - readScratchPad(deviceAddress, scratchPad); - return (_wire->crc8(scratchPad, 8) == scratchPad[SCRATCHPAD_CRC]); -} - -// read device's scratch pad -void DallasTemperature::readScratchPad(uint8_t* deviceAddress, uint8_t* scratchPad) -{ - // send the command - _wire->reset(); - _wire->select(deviceAddress); - _wire->write(READSCRATCH); - - // TODO => collect all comments & use simple loop - // byte 0: temperature LSB - // byte 1: temperature MSB - // byte 2: high alarm temp - // byte 3: low alarm temp - // byte 4: DS18S20: store for crc - // DS18B20 & DS1822: configuration register - // byte 5: internal use & crc - // byte 6: DS18S20: COUNT_REMAIN - // DS18B20 & DS1822: store for crc - // byte 7: DS18S20: COUNT_PER_C - // DS18B20 & DS1822: store for crc - // byte 8: SCRATCHPAD_CRC - // - // for(int i=0; i<9; i++) - // { - // scratchPad[i] = _wire->read(); - // } - - - // read the response - - // byte 0: temperature LSB - scratchPad[TEMP_LSB] = _wire->read(); - - // byte 1: temperature MSB - scratchPad[TEMP_MSB] = _wire->read(); - - // byte 2: high alarm temp - scratchPad[HIGH_ALARM_TEMP] = _wire->read(); - - // byte 3: low alarm temp - scratchPad[LOW_ALARM_TEMP] = _wire->read(); - - // byte 4: - // DS18S20: store for crc - // DS18B20 & DS1822: configuration register - scratchPad[CONFIGURATION] = _wire->read(); - - // byte 5: - // internal use & crc - scratchPad[INTERNAL_BYTE] = _wire->read(); - - // byte 6: - // DS18S20: COUNT_REMAIN - // DS18B20 & DS1822: store for crc - scratchPad[COUNT_REMAIN] = _wire->read(); - - // byte 7: - // DS18S20: COUNT_PER_C - // DS18B20 & DS1822: store for crc - scratchPad[COUNT_PER_C] = _wire->read(); - - // byte 8: - // SCTRACHPAD_CRC - scratchPad[SCRATCHPAD_CRC] = _wire->read(); - - _wire->reset(); -} - -// writes device's scratch pad -void DallasTemperature::writeScratchPad(uint8_t* deviceAddress, const uint8_t* scratchPad) -{ - _wire->reset(); - _wire->select(deviceAddress); - _wire->write(WRITESCRATCH); - _wire->write(scratchPad[HIGH_ALARM_TEMP]); // high alarm temp - _wire->write(scratchPad[LOW_ALARM_TEMP]); // low alarm temp - // DS18S20 does not use the configuration register - if (deviceAddress[0] != DS18S20MODEL) _wire->write(scratchPad[CONFIGURATION]); // configuration - _wire->reset(); - // save the newly written values to eeprom - _wire->write(COPYSCRATCH, parasite); - if (parasite) delay(10); // 10ms delay - _wire->reset(); -} - -// reads the device's power requirements -bool DallasTemperature::readPowerSupply(uint8_t* deviceAddress) -{ - bool ret = false; - _wire->reset(); - _wire->select(deviceAddress); - _wire->write(READPOWERSUPPLY); - if (_wire->read_bit() == 0) ret = true; - _wire->reset(); - return ret; -} - - -// set resolution of all devices to 9, 10, 11, or 12 bits -// if new resolution is out of range, it is constrained. -void DallasTemperature::setResolution(uint8_t newResolution) -{ - bitResolution = constrain(newResolution, 9, 12); - DeviceAddress deviceAddress; - for (int i=0; ireset(); - _wire->skip(); - _wire->write(STARTCONVO, parasite); - - // ASYNC mode? - if (!waitForConversion) return; - blockTillConversionComplete(&bitResolution, 0); - - return; -} - -// sends command for one device to perform a temperature by address -// returns FALSE if device is disconnected -// returns TRUE otherwise -bool DallasTemperature::requestTemperaturesByAddress(uint8_t* deviceAddress) -{ - - _wire->reset(); - _wire->select(deviceAddress); - _wire->write(STARTCONVO, parasite); - - // check device - ScratchPad scratchPad; - if (!isConnected(deviceAddress, scratchPad)) return false; - - - // ASYNC mode? - if (!waitForConversion) return true; - uint8_t bitResolution = getResolution(deviceAddress); - blockTillConversionComplete(&bitResolution, deviceAddress); - - return true; -} - - -void DallasTemperature::blockTillConversionComplete(uint8_t* bitResolution, uint8_t* deviceAddress) -{ - if(deviceAddress != 0 && checkForConversion && !parasite) - { - // Continue to check if the IC has responded with a temperature - // NB: Could cause issues with multiple devices (one device may respond faster) - unsigned long start = millis(); - while(!isConversionAvailable(0) && ((millis() - start) < 750)); - } - - // Wait a fix number of cycles till conversion is complete (based on IC datasheet) - switch (*bitResolution) - { - case 9: - delay(94); - break; - case 10: - delay(188); - break; - case 11: - delay(375); - break; - case 12: - default: - delay(750); - break; - } - -} - -// sends command for one device to perform a temp conversion by index -bool DallasTemperature::requestTemperaturesByIndex(uint8_t deviceIndex) -{ - DeviceAddress deviceAddress; - getAddress(deviceAddress, deviceIndex); - return requestTemperaturesByAddress(deviceAddress); -} - -// Fetch temperature for device index -float DallasTemperature::getTempCByIndex(uint8_t deviceIndex) -{ - DeviceAddress deviceAddress; - getAddress(deviceAddress, deviceIndex); - return getTempC((uint8_t*)deviceAddress); -} - -// Fetch temperature for device index -float DallasTemperature::getTempFByIndex(uint8_t deviceIndex) -{ - return toFahrenheit(getTempCByIndex(deviceIndex)); -} - -// reads scratchpad and returns the temperature in degrees C -float DallasTemperature::calculateTemperature(uint8_t* deviceAddress, uint8_t* scratchPad) -{ - int16_t rawTemperature = (((int16_t)scratchPad[TEMP_MSB]) << 8) | scratchPad[TEMP_LSB]; - - switch (deviceAddress[0]) - { - case DS18B20MODEL: - case DS1822MODEL: - switch (scratchPad[CONFIGURATION]) - { - case TEMP_12_BIT: - return (float)rawTemperature * 0.0625; - break; - case TEMP_11_BIT: - return (float)(rawTemperature >> 1) * 0.125; - break; - case TEMP_10_BIT: - return (float)(rawTemperature >> 2) * 0.25; - break; - case TEMP_9_BIT: - return (float)(rawTemperature >> 3) * 0.5; - break; - } - break; - case DS18S20MODEL: - /* - - Resolutions greater than 9 bits can be calculated using the data from - the temperature, COUNT REMAIN and COUNT PER �C registers in the - scratchpad. Note that the COUNT PER �C register is hard-wired to 16 - (10h). After reading the scratchpad, the TEMP_READ value is obtained - by truncating the 0.5�C bit (bit 0) from the temperature data. The - extended resolution temperature can then be calculated using the - following equation: - - COUNT_PER_C - COUNT_REMAIN - TEMPERATURE = TEMP_READ - 0.25 + -------------------------- - COUNT_PER_C - */ - - // Good spot. Thanks Nic Johns for your contribution - return (float)(rawTemperature >> 1) - 0.25 +((float)(scratchPad[COUNT_PER_C] - scratchPad[COUNT_REMAIN]) / (float)scratchPad[COUNT_PER_C] ); - break; - } -} - -// returns temperature in degrees C or DEVICE_DISCONNECTED if the -// device's scratch pad cannot be read successfully. -// the numeric value of DEVICE_DISCONNECTED is defined in -// DallasTemperature.h. It is a large negative number outside the -// operating range of the device -float DallasTemperature::getTempC(uint8_t* deviceAddress) -{ - // TODO: Multiple devices (up to 64) on the same bus may take - // some time to negotiate a response - // What happens in case of collision? - - ScratchPad scratchPad; - if (isConnected(deviceAddress, scratchPad)) return calculateTemperature(deviceAddress, scratchPad); - return DEVICE_DISCONNECTED; -} - -// returns temperature in degrees F -// TODO: - when getTempC returns DEVICE_DISCONNECTED -// -127 gets converted to -196.6 F -float DallasTemperature::getTempF(uint8_t* deviceAddress) -{ - return toFahrenheit(getTempC(deviceAddress)); -} - -// returns true if the bus requires parasite power -bool DallasTemperature::isParasitePowerMode(void) -{ - return parasite; -} - -#if REQUIRESALARMS - -/* - -ALARMS: - -TH and TL Register Format - -BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 - S 2^6 2^5 2^4 2^3 2^2 2^1 2^0 - -Only bits 11 through 4 of the temperature register are used -in the TH and TL comparison since TH and TL are 8-bit -registers. If the measured temperature is lower than or equal -to TL or higher than or equal to TH, an alarm condition exists -and an alarm flag is set inside the DS18B20. This flag is -updated after every temperature measurement; therefore, if the -alarm condition goes away, the flag will be turned off after -the next temperature conversion. - -*/ - -// sets the high alarm temperature for a device in degrees celsius -// accepts a float, but the alarm resolution will ignore anything -// after a decimal point. valid range is -55C - 125C -void DallasTemperature::setHighAlarmTemp(uint8_t* deviceAddress, char celsius) -{ - // make sure the alarm temperature is within the device's range - if (celsius > 125) celsius = 125; - else if (celsius < -55) celsius = -55; - - ScratchPad scratchPad; - if (isConnected(deviceAddress, scratchPad)) - { - scratchPad[HIGH_ALARM_TEMP] = (uint8_t)celsius; - writeScratchPad(deviceAddress, scratchPad); - } -} - -// sets the low alarm temperature for a device in degreed celsius -// accepts a float, but the alarm resolution will ignore anything -// after a decimal point. valid range is -55C - 125C -void DallasTemperature::setLowAlarmTemp(uint8_t* deviceAddress, char celsius) -{ - // make sure the alarm temperature is within the device's range - if (celsius > 125) celsius = 125; - else if (celsius < -55) celsius = -55; - - ScratchPad scratchPad; - if (isConnected(deviceAddress, scratchPad)) - { - scratchPad[LOW_ALARM_TEMP] = (uint8_t)celsius; - writeScratchPad(deviceAddress, scratchPad); - } -} - -// returns a char with the current high alarm temperature or -// DEVICE_DISCONNECTED for an address -char DallasTemperature::getHighAlarmTemp(uint8_t* deviceAddress) -{ - ScratchPad scratchPad; - if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[HIGH_ALARM_TEMP]; - return DEVICE_DISCONNECTED; -} - -// returns a char with the current low alarm temperature or -// DEVICE_DISCONNECTED for an address -char DallasTemperature::getLowAlarmTemp(uint8_t* deviceAddress) -{ - ScratchPad scratchPad; - if (isConnected(deviceAddress, scratchPad)) return (char)scratchPad[LOW_ALARM_TEMP]; - return DEVICE_DISCONNECTED; -} - -// resets internal variables used for the alarm search -void DallasTemperature::resetAlarmSearch() -{ - alarmSearchJunction = -1; - alarmSearchExhausted = 0; - for(uint8_t i = 0; i < 7; i++) - alarmSearchAddress[i] = 0; -} - -// This is a modified version of the OneWire::search method. -// -// Also added the OneWire search fix documented here: -// http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295 -// -// Perform an alarm search. If this function returns a '1' then it has -// enumerated the next device and you may retrieve the ROM from the -// OneWire::address variable. If there are no devices, no further -// devices, or something horrible happens in the middle of the -// enumeration then a 0 is returned. If a new device is found then -// its address is copied to newAddr. Use -// DallasTemperature::resetAlarmSearch() to start over. -bool DallasTemperature::alarmSearch(uint8_t* newAddr) -{ - uint8_t i; - char lastJunction = -1; - uint8_t done = 1; - - if (alarmSearchExhausted) return false; - if (!_wire->reset()) return false; - - // send the alarm search command - _wire->write(0xEC, 0); - - for(i = 0; i < 64; i++) - { - uint8_t a = _wire->read_bit( ); - uint8_t nota = _wire->read_bit( ); - uint8_t ibyte = i / 8; - uint8_t ibit = 1 << (i & 7); - - // I don't think this should happen, this means nothing responded, but maybe if - // something vanishes during the search it will come up. - if (a && nota) return false; - - if (!a && !nota) - { - if (i == alarmSearchJunction) - { - // this is our time to decide differently, we went zero last time, go one. - a = 1; - alarmSearchJunction = lastJunction; - } - else if (i < alarmSearchJunction) - { - // take whatever we took last time, look in address - if (alarmSearchAddress[ibyte] & ibit) a = 1; - else - { - // Only 0s count as pending junctions, we've already exhasuted the 0 side of 1s - a = 0; - done = 0; - lastJunction = i; - } - } - else - { - // we are blazing new tree, take the 0 - a = 0; - alarmSearchJunction = i; - done = 0; - } - // OneWire search fix - // See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295 - } - - if (a) alarmSearchAddress[ibyte] |= ibit; - else alarmSearchAddress[ibyte] &= ~ibit; - - _wire->write_bit(a); - } - - if (done) alarmSearchExhausted = 1; - for (i = 0; i < 8; i++) newAddr[i] = alarmSearchAddress[i]; - return true; -} - -// returns true if device address has an alarm condition -// TODO: can this be done with only TEMP_MSB REGISTER (faster) -// if ((char) scratchPad[TEMP_MSB] <= (char) scratchPad[LOW_ALARM_TEMP]) return true; -// if ((char) scratchPad[TEMP_MSB] >= (char) scratchPad[HIGH_ALARM_TEMP]) return true; -bool DallasTemperature::hasAlarm(uint8_t* deviceAddress) -{ - ScratchPad scratchPad; - if (isConnected(deviceAddress, scratchPad)) - { - float temp = calculateTemperature(deviceAddress, scratchPad); - - // check low alarm - if ((char)temp <= (char)scratchPad[LOW_ALARM_TEMP]) return true; - - // check high alarm - if ((char)temp >= (char)scratchPad[HIGH_ALARM_TEMP]) return true; - } - - // no alarm - return false; -} - -// returns true if any device is reporting an alarm condition on the bus -bool DallasTemperature::hasAlarm(void) -{ - DeviceAddress deviceAddress; - resetAlarmSearch(); - return alarmSearch(deviceAddress); -} - -// runs the alarm handler for all devices returned by alarmSearch() -void DallasTemperature::processAlarms(void) -{ - resetAlarmSearch(); - DeviceAddress alarmAddr; - - while (alarmSearch(alarmAddr)) - { - if (validAddress(alarmAddr)) - _AlarmHandler(alarmAddr); - } -} - -// sets the alarm handler -void DallasTemperature::setAlarmHandler(AlarmHandler *handler) -{ - _AlarmHandler = handler; -} - -// The default alarm handler -void DallasTemperature::defaultAlarmHandler(uint8_t* deviceAddress) -{ -} - -#endif - -// Convert float celsius to fahrenheit -float DallasTemperature::toFahrenheit(float celsius) -{ - return (celsius * 1.8) + 32; -} - -// Convert float fahrenheit to celsius -float DallasTemperature::toCelsius(float fahrenheit) -{ - return (fahrenheit - 32) / 1.8; -} - -#if REQUIRESNEW - -// MnetCS - Allocates memory for DallasTemperature. Allows us to instance a new object -void* DallasTemperature::operator new(unsigned int size) // Implicit NSS obj size -{ - void * p; // void pointer - p = malloc(size); // Allocate memory - memset((DallasTemperature*)p,0,size); // Initalise memory - - //!!! CANT EXPLICITLY CALL CONSTRUCTOR - workaround by using an init() methodR - workaround by using an init() method - return (DallasTemperature*) p; // Cast blank region to NSS pointer -} - -// MnetCS 2009 - Unallocates the memory used by this instance -void DallasTemperature::operator delete(void* p) -{ - DallasTemperature* pNss = (DallasTemperature*) p; // Cast to NSS pointer - pNss->~DallasTemperature(); // Destruct the object - - free(p); // Free the memory -} - -#endif diff --git a/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.h b/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.h deleted file mode 100644 index ff8262f..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/DallasTemperature.h +++ /dev/null @@ -1,242 +0,0 @@ -#ifndef DallasTemperature_h -#define DallasTemperature_h - -#define DALLASTEMPLIBVERSION "3.7.2" - -// This library 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. - -// set to true to include code for new and delete operators -#ifndef REQUIRESNEW -#define REQUIRESNEW false -#endif - -// set to true to include code implementing alarm search functions -#ifndef REQUIRESALARMS -#define REQUIRESALARMS true -#endif - -#include -#include - -// Model IDs -#define DS18S20MODEL 0x10 -#define DS18B20MODEL 0x28 -#define DS1822MODEL 0x22 - -// OneWire commands -#define STARTCONVO 0x44 // Tells device to take a temperature reading and put it on the scratchpad -#define COPYSCRATCH 0x48 // Copy EEPROM -#define READSCRATCH 0xBE // Read EEPROM -#define WRITESCRATCH 0x4E // Write to EEPROM -#define RECALLSCRATCH 0xB8 // Reload from last known -#define READPOWERSUPPLY 0xB4 // Determine if device needs parasite power -#define ALARMSEARCH 0xEC // Query bus for devices with an alarm condition - -// Scratchpad locations -#define TEMP_LSB 0 -#define TEMP_MSB 1 -#define HIGH_ALARM_TEMP 2 -#define LOW_ALARM_TEMP 3 -#define CONFIGURATION 4 -#define INTERNAL_BYTE 5 -#define COUNT_REMAIN 6 -#define COUNT_PER_C 7 -#define SCRATCHPAD_CRC 8 - -// Device resolution -#define TEMP_9_BIT 0x1F // 9 bit -#define TEMP_10_BIT 0x3F // 10 bit -#define TEMP_11_BIT 0x5F // 11 bit -#define TEMP_12_BIT 0x7F // 12 bit - -// Error Codes -#define DEVICE_DISCONNECTED -127 - -typedef uint8_t DeviceAddress[8]; - -class DallasTemperature -{ - public: - - DallasTemperature(OneWire*); - - // initalise bus - void begin(void); - - // returns the number of devices found on the bus - uint8_t getDeviceCount(void); - - // Is a conversion complete on the wire? - bool isConversionComplete(void); - - // returns true if address is valid - bool validAddress(uint8_t*); - - // finds an address at a given index on the bus - bool getAddress(uint8_t*, const uint8_t); - - // attempt to determine if the device at the given address is connected to the bus - bool isConnected(uint8_t*); - - // attempt to determine if the device at the given address is connected to the bus - // also allows for updating the read scratchpad - bool isConnected(uint8_t*, uint8_t*); - - // read device's scratchpad - void readScratchPad(uint8_t*, uint8_t*); - - // write device's scratchpad - void writeScratchPad(uint8_t*, const uint8_t*); - - // read device's power requirements - bool readPowerSupply(uint8_t*); - - // get global resolution - uint8_t getResolution(); - - // set global resolution to 9, 10, 11, or 12 bits - void setResolution(uint8_t); - - // returns the device resolution, 9-12 - uint8_t getResolution(uint8_t*); - - // set resolution of a device to 9, 10, 11, or 12 bits - bool setResolution(uint8_t*, uint8_t); - - // sets/gets the waitForConversion flag - void setWaitForConversion(bool); - bool getWaitForConversion(void); - - // sets/gets the checkForConversion flag - void setCheckForConversion(bool); - bool getCheckForConversion(void); - - // sends command for all devices on the bus to perform a temperature conversion - void requestTemperatures(void); - - // sends command for one device to perform a temperature conversion by address - bool requestTemperaturesByAddress(uint8_t*); - - // sends command for one device to perform a temperature conversion by index - bool requestTemperaturesByIndex(uint8_t); - - // returns temperature in degrees C - float getTempC(uint8_t*); - - // returns temperature in degrees F - float getTempF(uint8_t*); - - // Get temperature for device index (slow) - float getTempCByIndex(uint8_t); - - // Get temperature for device index (slow) - float getTempFByIndex(uint8_t); - - // returns true if the bus requires parasite power - bool isParasitePowerMode(void); - - bool isConversionAvailable(uint8_t*); - - #if REQUIRESALARMS - - typedef void AlarmHandler(uint8_t*); - - // sets the high alarm temperature for a device - // accepts a char. valid range is -55C - 125C - void setHighAlarmTemp(uint8_t*, const char); - - // sets the low alarm temperature for a device - // accepts a char. valid range is -55C - 125C - void setLowAlarmTemp(uint8_t*, const char); - - // returns a signed char with the current high alarm temperature for a device - // in the range -55C - 125C - char getHighAlarmTemp(uint8_t*); - - // returns a signed char with the current low alarm temperature for a device - // in the range -55C - 125C - char getLowAlarmTemp(uint8_t*); - - // resets internal variables used for the alarm search - void resetAlarmSearch(void); - - // search the wire for devices with active alarms - bool alarmSearch(uint8_t*); - - // returns true if ia specific device has an alarm - bool hasAlarm(uint8_t*); - - // returns true if any device is reporting an alarm on the bus - bool hasAlarm(void); - - // runs the alarm handler for all devices returned by alarmSearch() - void processAlarms(void); - - // sets the alarm handler - void setAlarmHandler(AlarmHandler *); - - // The default alarm handler - static void defaultAlarmHandler(uint8_t*); - - #endif - - // convert from celcius to farenheit - static float toFahrenheit(const float); - - // convert from farenheit to celsius - static float toCelsius(const float); - - #if REQUIRESNEW - - // initalize memory area - void* operator new (unsigned int); - - // delete memory reference - void operator delete(void*); - - #endif - - private: - typedef uint8_t ScratchPad[9]; - - // parasite power on or off - bool parasite; - - // used to determine the delay amount needed to allow for the - // temperature conversion to take place - uint8_t bitResolution; - - // used to requestTemperature with or without delay - bool waitForConversion; - - // used to requestTemperature to dynamically check if a conversion is complete - bool checkForConversion; - - // count of devices on the bus - uint8_t devices; - - // Take a pointer to one wire instance - OneWire* _wire; - - // reads scratchpad and returns the temperature in degrees C - float calculateTemperature(uint8_t*, uint8_t*); - - void blockTillConversionComplete(uint8_t*,uint8_t*); - - #if REQUIRESALARMS - - // required for alarmSearch - uint8_t alarmSearchAddress[8]; - char alarmSearchJunction; - uint8_t alarmSearchExhausted; - - // the alarm handler function pointer - AlarmHandler *_AlarmHandler; - - #endif - -}; -#endif diff --git a/tests/makefile_stuff/libraries/DallasTemperature/README.TXT b/tests/makefile_stuff/libraries/DallasTemperature/README.TXT deleted file mode 100644 index 764bdd7..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/README.TXT +++ /dev/null @@ -1,53 +0,0 @@ -Arduino Library for Dallas Temperature ICs -========================================== - -Usage ------ - -This library supports the following devices: - DS18B20 - DS18S20 - Please note there appears to be an issue with this series. - DS1822 - -You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line -and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The -centre pin is the data line '1-wire'. - -We have included a "REQUIRESNEW" and "REQUIRESALARMS" definition. If you -want to slim down the code feel free to use either of these by including -#define REQUIRESNEW or #define REQUIRESALARMS a the top of DallasTemperature.h - -Credits -------- - -The OneWire code has been derived from -http://www.arduino.cc/playground/Learning/OneWire. -Miles Burton originally developed this library. -Tim Newsome added support for multiple sensors on -the same bus. -Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5) -Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0) - - -Website -------- - -You can find the latest version of the library at -http://milesburton.com/index.php?title=Dallas_Temperature_Control_Library - -License -------- - -This library 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 library 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 -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/tests/makefile_stuff/libraries/DallasTemperature/change.txt b/tests/makefile_stuff/libraries/DallasTemperature/change.txt deleted file mode 100644 index 42564ca..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/change.txt +++ /dev/null @@ -1,85 +0,0 @@ - -This file contains the change history of the Dallas Temperature Control Library. - -VERSION 3.7.2 BETA -=================== -DATE: 6 DEC 2011 - -- Jordan Hochenbaum [jhochenbaum@gmail.com] updated library for compatibility with Arduino 1.0. - -VERSION 3.7.0 BETA -=================== -DATE: 11 JAN 2011 - -- Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0) - The library is backwards compatible with version 3.6.0 - - MAJOR: async modus - ------------------ -- Added - private bool waitForConversion. -This boolean is default set to true in the Constructor to keep the library backwards compatible. If this flag is true calls to requestTemperatures(), requestTemperaturesByAddress() et al, will be blocking with the appropiate time specified (in datasheet) for the resolution used. If the flag is set to false, requestTemperatures() et al, will return immediately after the conversion command is send over the 1-wire interface. The programmer is responsible to wait long enough before reading the temperature values. This enables the application to do other things while waiting for a new reading, like calculations, update LCD, read/write other IO lines etc. See examples. - -- Added - void setWaitForConversion(bool); -To set the flag to true or false, depending on the modus needed. - -- Added - bool getWaitForConversion(void); -To get the current value of the flag. - -- Changed - void requestTemperatures(void); -Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready. - -- Changed - bool requestTemperaturesByAddress(uint8_t*); -Added a test (false == waitForConversion) to return immediately after the conversion command instead of waiting until the conversion is ready. - - - MINOR version number - -------------------- -- Added - #define DALLASTEMPLIBVERSION "3.7.0" -To indicate the version number in .h file - - - MINOR internal var bitResolution - ---------------------------- -- Changed - private int conversionDelay - is renamed to - private int bitResolution -As this variable holds the resolution. The delay for the conversion is derived from it. - -- Changed - uint8_t getResolution(uint8_t* deviceAddress); -If the device is not connected, it returns 0, otherwise it returns the resolution of the device. - -- Changed - bool setResolution(uint8_t* deviceAddress, uint8_t newResolution); -If the device is not connected, it returns FALSE (fail), otherwise it returns TRUE (succes). - -- Added - uint8_t getResolution(); -Returns bitResolution. - -- Added - void setResolution(uint8_t newResolution) -Sets the internal variable bitResolution, and all devices to this value - - - MINOR check connected state - ---------------------------- -- Changed - bool requestTemperaturesByIndex(deviceIndex) -Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise. - -- Changed - bool requestTemperaturesByAddress(deviceAddress) -Changed return type from void to bool. The function returns false if the device identified with [deviceAddress] is not found on the bus and true otherwise. -Added code to handle the DS18S20 which has a 9 bit resolution separately. -Changed code so the blocking delay matches the bitResolution set in the device with deviceAddress. - -- Changed - bool requestTemperaturesByIndex(uint8_t deviceIndex) -Changed return type from void to bool. The function returns false if the device identified with [deviceIndex] is not found on the bus and true otherwise. - - - -VERSION 3.6.0 -============== -DATE: 2010-10-10 - -- no detailed change history known except: - -- The OneWire code has been derived from -http://www.arduino.cc/playground/Learning/OneWire. -- Miles Burton originally developed this library. -- Tim Newsome added support for multiple sensors on -the same bus. -- Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5) diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/Alarm/Alarm.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Alarm/Alarm.pde deleted file mode 100644 index d9c6e6c..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/Alarm/Alarm.pde +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -// arrays to hold device addresses -DeviceAddress insideThermometer, outsideThermometer; - -void setup(void) -{ - // start serial port - Serial.begin(9600); - Serial.println("Dallas Temperature IC Control Library Demo"); - - // Start up the library - sensors.begin(); - - // locate devices on the bus - Serial.print("Found "); - Serial.print(sensors.getDeviceCount(), DEC); - Serial.println(" devices."); - - // search for devices on the bus and assign based on an index. - if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); - if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); - - // show the addresses we found on the bus - Serial.print("Device 0 Address: "); - printAddress(insideThermometer); - Serial.println(); - - Serial.print("Device 0 Alarms: "); - printAlarms(insideThermometer); - Serial.println(); - - Serial.print("Device 1 Address: "); - printAddress(outsideThermometer); - Serial.println(); - - Serial.print("Device 1 Alarms: "); - printAlarms(outsideThermometer); - Serial.println(); - - Serial.println("Setting alarm temps..."); - - // alarm when temp is higher than 30C - sensors.setHighAlarmTemp(insideThermometer, 30); - - // alarm when temp is lower than -10C - sensors.setLowAlarmTemp(insideThermometer, -10); - - // alarm when temp is higher than 31C - sensors.setHighAlarmTemp(outsideThermometer, 31); - - // alarn when temp is lower than 27C - sensors.setLowAlarmTemp(outsideThermometer, 27); - - Serial.print("New Device 0 Alarms: "); - printAlarms(insideThermometer); - Serial.println(); - - Serial.print("New Device 1 Alarms: "); - printAlarms(outsideThermometer); - Serial.println(); -} - -// function to print a device address -void printAddress(DeviceAddress deviceAddress) -{ - for (uint8_t i = 0; i < 8; i++) - { - if (deviceAddress[i] < 16) Serial.print("0"); - Serial.print(deviceAddress[i], HEX); - } -} - -// function to print the temperature for a device -void printTemperature(DeviceAddress deviceAddress) -{ - float tempC = sensors.getTempC(deviceAddress); - Serial.print("Temp C: "); - Serial.print(tempC); - Serial.print(" Temp F: "); - Serial.print(DallasTemperature::toFahrenheit(tempC)); -} - -void printAlarms(uint8_t deviceAddress[]) -{ - char temp; - temp = sensors.getHighAlarmTemp(deviceAddress); - Serial.print("High Alarm: "); - Serial.print(temp, DEC); - Serial.print("C/"); - Serial.print(DallasTemperature::toFahrenheit(temp)); - Serial.print("F | Low Alarm: "); - temp = sensors.getLowAlarmTemp(deviceAddress); - Serial.print(temp, DEC); - Serial.print("C/"); - Serial.print(DallasTemperature::toFahrenheit(temp)); - Serial.print("F"); -} - -// main function to print information about a device -void printData(DeviceAddress deviceAddress) -{ - Serial.print("Device Address: "); - printAddress(deviceAddress); - Serial.print(" "); - printTemperature(deviceAddress); - Serial.println(); -} - -void checkAlarm(DeviceAddress deviceAddress) -{ - if (sensors.hasAlarm(deviceAddress)) - { - Serial.print("ALARM: "); - printData(deviceAddress); - } -} - -void loop(void) -{ - // call sensors.requestTemperatures() to issue a global temperature - // request to all devices on the bus - Serial.print("Requesting temperatures..."); - sensors.requestTemperatures(); - Serial.println("DONE"); - - // Method 1: - // check each address individually for an alarm condition - checkAlarm(insideThermometer); - checkAlarm(outsideThermometer); -/* - // Alternate method: - // Search the bus and iterate through addresses of devices with alarms - - // space for the alarm device's address - DeviceAddress alarmAddr; - - Serial.println("Searching for alarms..."); - - // resetAlarmSearch() must be called before calling alarmSearch() - sensors.resetAlarmSearch(); - - // alarmSearch() returns 0 when there are no devices with alarms - while (sensors.alarmSearch(alarmAddr)) - { - Serial.print("ALARM: "); - printData(alarmAddr); - } -*/ - -} - diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde deleted file mode 100644 index 4b72962..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/AlarmHandler/AlarmHandler.pde +++ /dev/null @@ -1,144 +0,0 @@ -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -// arrays to hold device addresses -DeviceAddress insideThermometer, outsideThermometer; - -// function that will be called when an alarm condition exists during DallasTemperatures::processAlarms(); -void newAlarmHandler(uint8_t* deviceAddress) -{ - Serial.println("Alarm Handler Start"); - printAlarmInfo(deviceAddress); - printTemp(deviceAddress); - Serial.println(); - Serial.println("Alarm Handler Finish"); -} - -void printCurrentTemp(DeviceAddress deviceAddress) -{ - printAddress(deviceAddress); - printTemp(deviceAddress); - Serial.println(); -} - -void printAddress(DeviceAddress deviceAddress) -{ - Serial.print("Address: "); - for (uint8_t i = 0; i < 8; i++) - { - if (deviceAddress[i] < 16) Serial.print("0"); - Serial.print(deviceAddress[i], HEX); - } - Serial.print(" "); -} - -void printTemp(DeviceAddress deviceAddress) -{ - float tempC = sensors.getTempC(deviceAddress); - if (tempC != DEVICE_DISCONNECTED) - { - Serial.print("Current Temp C: "); - Serial.print(tempC); - } - else Serial.print("DEVICE DISCONNECTED"); - Serial.print(" "); -} - -void printAlarmInfo(DeviceAddress deviceAddress) -{ - char temp; - printAddress(deviceAddress); - temp = sensors.getHighAlarmTemp(deviceAddress); - Serial.print("High Alarm: "); - Serial.print(temp, DEC); - Serial.print("C"); - Serial.print(" Low Alarm: "); - temp = sensors.getLowAlarmTemp(deviceAddress); - Serial.print(temp, DEC); - Serial.print("C"); - Serial.print(" "); -} - -void setup(void) -{ - // start serial port - Serial.begin(9600); - Serial.println("Dallas Temperature IC Control Library Demo"); - - // Start up the library - sensors.begin(); - - // locate devices on the bus - Serial.print("Found "); - Serial.print(sensors.getDeviceCount(), DEC); - Serial.println(" devices."); - - // search for devices on the bus and assign based on an index - if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); - if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); - - Serial.print("Device insideThermometer "); - printAlarmInfo(insideThermometer); - Serial.println(); - - Serial.print("Device outsideThermometer "); - printAlarmInfo(outsideThermometer); - Serial.println(); - - // set alarm ranges - Serial.println("Setting alarm temps..."); - sensors.setHighAlarmTemp(insideThermometer, 26); - sensors.setLowAlarmTemp(insideThermometer, 22); - sensors.setHighAlarmTemp(outsideThermometer, 25); - sensors.setLowAlarmTemp(outsideThermometer, 21); - - Serial.print("New insideThermometer "); - printAlarmInfo(insideThermometer); - Serial.println(); - - Serial.print("New outsideThermometer "); - printAlarmInfo(outsideThermometer); - Serial.println(); - - // attach alarm handler - sensors.setAlarmHandler(&newAlarmHandler); - -} - -void loop(void) -{ - // ask the devices to measure the temperature - sensors.requestTemperatures(); - - // if an alarm condition exists as a result of the most recent - // requestTemperatures() request, it exists until the next time - // requestTemperatures() is called AND there isn't an alarm condition - // on the device - if (sensors.hasAlarm()) - { - Serial.println("Oh noes! There is at least one alarm on the bus."); - } - - // call alarm handler function defined by sensors.setAlarmHandler - // for each device reporting an alarm - sensors.processAlarms(); - - if (!sensors.hasAlarm()) - { - // just print out the current temperature - printCurrentTemp(insideThermometer); - printCurrentTemp(outsideThermometer); - } - - delay(1000); -} - diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/Multiple/Multiple.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Multiple/Multiple.pde deleted file mode 100644 index 37e7ba6..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/Multiple/Multiple.pde +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 -#define TEMPERATURE_PRECISION 9 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -// arrays to hold device addresses -DeviceAddress insideThermometer, outsideThermometer; - -void setup(void) -{ - // start serial port - Serial.begin(9600); - Serial.println("Dallas Temperature IC Control Library Demo"); - - // Start up the library - sensors.begin(); - - // locate devices on the bus - Serial.print("Locating devices..."); - Serial.print("Found "); - Serial.print(sensors.getDeviceCount(), DEC); - Serial.println(" devices."); - - // report parasite power requirements - Serial.print("Parasite power is: "); - if (sensors.isParasitePowerMode()) Serial.println("ON"); - else Serial.println("OFF"); - - // assign address manually. the addresses below will beed to be changed - // to valid device addresses on your bus. device address can be retrieved - // by using either oneWire.search(deviceAddress) or individually via - // sensors.getAddress(deviceAddress, index) - //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; - //outsideThermometer = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 }; - - // search for devices on the bus and assign based on an index. ideally, - // you would do this to initially discover addresses on the bus and then - // use those addresses and manually assign them (see above) once you know - // the devices on your bus (and assuming they don't change). - // - // method 1: by index - if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); - if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1"); - - // method 2: search() - // search() looks for the next device. Returns 1 if a new address has been - // returned. A zero might mean that the bus is shorted, there are no devices, - // or you have already retrieved all of them. It might be a good idea to - // check the CRC to make sure you didn't get garbage. The order is - // deterministic. You will always get the same devices in the same order - // - // Must be called before search() - //oneWire.reset_search(); - // assigns the first address found to insideThermometer - //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer"); - // assigns the seconds address found to outsideThermometer - //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer"); - - // show the addresses we found on the bus - Serial.print("Device 0 Address: "); - printAddress(insideThermometer); - Serial.println(); - - Serial.print("Device 1 Address: "); - printAddress(outsideThermometer); - Serial.println(); - - // set the resolution to 9 bit - sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION); - sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION); - - Serial.print("Device 0 Resolution: "); - Serial.print(sensors.getResolution(insideThermometer), DEC); - Serial.println(); - - Serial.print("Device 1 Resolution: "); - Serial.print(sensors.getResolution(outsideThermometer), DEC); - Serial.println(); -} - -// function to print a device address -void printAddress(DeviceAddress deviceAddress) -{ - for (uint8_t i = 0; i < 8; i++) - { - // zero pad the address if necessary - if (deviceAddress[i] < 16) Serial.print("0"); - Serial.print(deviceAddress[i], HEX); - } -} - -// function to print the temperature for a device -void printTemperature(DeviceAddress deviceAddress) -{ - float tempC = sensors.getTempC(deviceAddress); - Serial.print("Temp C: "); - Serial.print(tempC); - Serial.print(" Temp F: "); - Serial.print(DallasTemperature::toFahrenheit(tempC)); -} - -// function to print a device's resolution -void printResolution(DeviceAddress deviceAddress) -{ - Serial.print("Resolution: "); - Serial.print(sensors.getResolution(deviceAddress)); - Serial.println(); -} - -// main function to print information about a device -void printData(DeviceAddress deviceAddress) -{ - Serial.print("Device Address: "); - printAddress(deviceAddress); - Serial.print(" "); - printTemperature(deviceAddress); - Serial.println(); -} - -void loop(void) -{ - // call sensors.requestTemperatures() to issue a global temperature - // request to all devices on the bus - Serial.print("Requesting temperatures..."); - sensors.requestTemperatures(); - Serial.println("DONE"); - - // print the device information - printData(insideThermometer); - printData(outsideThermometer); -} - diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/Simple/Simple.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Simple/Simple.pde deleted file mode 100644 index 5b2954d..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/Simple/Simple.pde +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -void setup(void) -{ - // start serial port - Serial.begin(9600); - Serial.println("Dallas Temperature IC Control Library Demo"); - - // Start up the library - sensors.begin(); -} - -void loop(void) -{ - // call sensors.requestTemperatures() to issue a global temperature - // request to all devices on the bus - Serial.print("Requesting temperatures..."); - sensors.requestTemperatures(); // Send the command to get temperatures - Serial.println("DONE"); - - Serial.print("Temperature for the device 1 (index 0) is: "); - Serial.println(sensors.getTempCByIndex(0)); -} diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/Single/Single.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Single/Single.pde deleted file mode 100644 index 7336859..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/Single/Single.pde +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -// arrays to hold device address -DeviceAddress insideThermometer; - -void setup(void) -{ - // start serial port - Serial.begin(9600); - Serial.println("Dallas Temperature IC Control Library Demo"); - - // locate devices on the bus - Serial.print("Locating devices..."); - sensors.begin(); - Serial.print("Found "); - Serial.print(sensors.getDeviceCount(), DEC); - Serial.println(" devices."); - - // report parasite power requirements - Serial.print("Parasite power is: "); - if (sensors.isParasitePowerMode()) Serial.println("ON"); - else Serial.println("OFF"); - - // assign address manually. the addresses below will beed to be changed - // to valid device addresses on your bus. device address can be retrieved - // by using either oneWire.search(deviceAddress) or individually via - // sensors.getAddress(deviceAddress, index) - //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; - - // Method 1: - // search for devices on the bus and assign based on an index. ideally, - // you would do this to initially discover addresses on the bus and then - // use those addresses and manually assign them (see above) once you know - // the devices on your bus (and assuming they don't change). - if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); - - // method 2: search() - // search() looks for the next device. Returns 1 if a new address has been - // returned. A zero might mean that the bus is shorted, there are no devices, - // or you have already retrieved all of them. It might be a good idea to - // check the CRC to make sure you didn't get garbage. The order is - // deterministic. You will always get the same devices in the same order - // - // Must be called before search() - //oneWire.reset_search(); - // assigns the first address found to insideThermometer - //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer"); - - // show the addresses we found on the bus - Serial.print("Device 0 Address: "); - printAddress(insideThermometer); - Serial.println(); - - // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions) - sensors.setResolution(insideThermometer, 9); - - Serial.print("Device 0 Resolution: "); - Serial.print(sensors.getResolution(insideThermometer), DEC); - Serial.println(); -} - -// function to print the temperature for a device -void printTemperature(DeviceAddress deviceAddress) -{ - // method 1 - slower - //Serial.print("Temp C: "); - //Serial.print(sensors.getTempC(deviceAddress)); - //Serial.print(" Temp F: "); - //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit - - // method 2 - faster - float tempC = sensors.getTempC(deviceAddress); - Serial.print("Temp C: "); - Serial.print(tempC); - Serial.print(" Temp F: "); - Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit -} - -void loop(void) -{ - // call sensors.requestTemperatures() to issue a global temperature - // request to all devices on the bus - Serial.print("Requesting temperatures..."); - sensors.requestTemperatures(); // Send the command to get temperatures - Serial.println("DONE"); - - // It responds almost immediately. Let's print out the data - printTemperature(insideThermometer); // Use a simple function to print out the data -} - -// function to print a device address -void printAddress(DeviceAddress deviceAddress) -{ - for (uint8_t i = 0; i < 8; i++) - { - if (deviceAddress[i] < 16) Serial.print("0"); - Serial.print(deviceAddress[i], HEX); - } -} diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/Tester/Tester.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/Tester/Tester.pde deleted file mode 100644 index 33ca9ba..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/Tester/Tester.pde +++ /dev/null @@ -1,124 +0,0 @@ -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 -#define TEMPERATURE_PRECISION 9 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -int numberOfDevices; // Number of temperature devices found - -DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address - -void setup(void) -{ - // start serial port - Serial.begin(9600); - Serial.println("Dallas Temperature IC Control Library Demo"); - - // Start up the library - sensors.begin(); - - // Grab a count of devices on the wire - numberOfDevices = sensors.getDeviceCount(); - - // locate devices on the bus - Serial.print("Locating devices..."); - - Serial.print("Found "); - Serial.print(numberOfDevices, DEC); - Serial.println(" devices."); - - // report parasite power requirements - Serial.print("Parasite power is: "); - if (sensors.isParasitePowerMode()) Serial.println("ON"); - else Serial.println("OFF"); - - // Loop through each device, print out address - for(int i=0;i -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -void setup(void) -{ - // start serial port - Serial.begin(115200); - Serial.println("Dallas Temperature Control Library - Async Demo"); - Serial.println("\nDemo shows the difference in length of the call\n\n"); - - // Start up the library - sensors.begin(); -} - -void loop(void) -{ - // Request temperature conversion (traditional) - Serial.println("Before blocking requestForConversion"); - unsigned long start = millis(); - - sensors.requestTemperatures(); - - unsigned long stop = millis(); - Serial.println("After blocking requestForConversion"); - Serial.print("Time used: "); - Serial.println(stop - start); - - // get temperature - Serial.print("Temperature: "); - Serial.println(sensors.getTempCByIndex(0)); - Serial.println("\n"); - - // Request temperature conversion - non-blocking / async - Serial.println("Before NON-blocking/async requestForConversion"); - start = millis(); - sensors.setWaitForConversion(false); // makes it async - sensors.requestTemperatures(); - sensors.setWaitForConversion(true); - stop = millis(); - Serial.println("After NON-blocking/async requestForConversion"); - Serial.print("Time used: "); - Serial.println(stop - start); - - - // 9 bit resolution by default - // Note the programmer is responsible for the right delay - // we could do something usefull here instead of the delay - int resolution = 9; - delay(750/ (1 << (12-resolution))); - - // get temperature - Serial.print("Temperature: "); - Serial.println(sensors.getTempCByIndex(0)); - Serial.println("\n\n\n\n"); - - delay(5000); -} diff --git a/tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde b/tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde deleted file mode 100644 index 4322330..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde +++ /dev/null @@ -1,80 +0,0 @@ -// -// Sample of using Async reading of Dallas Temperature Sensors -// -#include -#include - -// Data wire is plugged into port 2 on the Arduino -#define ONE_WIRE_BUS 2 - -// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) -OneWire oneWire(ONE_WIRE_BUS); - -// Pass our oneWire reference to Dallas Temperature. -DallasTemperature sensors(&oneWire); - -DeviceAddress tempDeviceAddress; - -int resolution = 12; -unsigned long lastTempRequest = 0; -int delayInMillis = 0; -float temperature = 0.0; -int idle = 0; -// -// SETUP -// -void setup(void) -{ - Serial.begin(115200); - Serial.println("Dallas Temperature Control Library - Async Demo"); - Serial.print("Library Version: "); - Serial.println(DALLASTEMPLIBVERSION); - Serial.println("\n"); - - sensors.begin(); - sensors.getAddress(tempDeviceAddress, 0); - sensors.setResolution(tempDeviceAddress, resolution); - - sensors.setWaitForConversion(false); - sensors.requestTemperatures(); - delayInMillis = 750 / (1 << (12 - resolution)); - lastTempRequest = millis(); - - pinMode(13, OUTPUT); -} - -void loop(void) -{ - - if (millis() - lastTempRequest >= delayInMillis) // waited long enough?? - { - digitalWrite(13, LOW); - Serial.print(" Temperature: "); - temperature = sensors.getTempCByIndex(0); - Serial.println(temperature, resolution - 8); - Serial.print(" Resolution: "); - Serial.println(resolution); - Serial.print("Idle counter: "); - Serial.println(idle); - Serial.println(); - - idle = 0; - - // immediately after fetching the temperature we request a new sample - // in the async modus - // for the demo we let the resolution change to show differences - resolution++; - if (resolution > 12) resolution = 9; - - sensors.setResolution(tempDeviceAddress, resolution); - sensors.requestTemperatures(); - delayInMillis = 750 / (1 << (12 - resolution)); - lastTempRequest = millis(); - } - - digitalWrite(13, HIGH); - // we can do usefull things here - // for the demo we just count the idle time in millis - delay(1); - idle++; -} diff --git a/tests/makefile_stuff/libraries/DallasTemperature/keywords.txt b/tests/makefile_stuff/libraries/DallasTemperature/keywords.txt deleted file mode 100644 index 0212d44..0000000 --- a/tests/makefile_stuff/libraries/DallasTemperature/keywords.txt +++ /dev/null @@ -1,54 +0,0 @@ -####################################### -# Syntax Coloring Map For Ultrasound -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### -DallasTemperature KEYWORD1 -OneWire KEYWORD1 -AlarmHandler KEYWORD1 -DeviceAddress KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -setResolution KEYWORD2 -getResolution KEYWORD2 -getTempC KEYWORD2 -toFahrenheit KEYWORD2 -getTempF KEYWORD2 -getTempCByIndex KEYWORD2 -getTempFByIndex KEYWORD2 -setWaitForConversion KEYWORD2 -getWaitForConversion KEYWORD2 -requestTemperatures KEYWORD2 -requestTemperaturesByAddress KEYWORD2 -requestTemperaturesByIndex KEYWORD2 -isParasitePowerMode KEYWORD2 -begin KEYWORD2 -getDeviceCount KEYWORD2 -getAddress KEYWORD2 -validAddress KEYWORD2 -isConnected KEYWORD2 -readScratchPad KEYWORD2 -writeScratchPad KEYWORD2 -readPowerSupply KEYWORD2 -setHighAlarmTemp KEYWORD2 -setLowAlarmTemp KEYWORD2 -getHighAlarmTemp KEYWORD2 -getLowAlarmTemp KEYWORD2 -resetAlarmSearch KEYWORD2 -alarmSearch KEYWORD2 -hasAlarm KEYWORD2 -toCelsius KEYWORD2 -processAlarmss KEYWORD2 -setAlarmHandlers KEYWORD2 -defaultAlarmHandler KEYWORD2 -calculateTemperature KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### - diff --git a/tests/makefile_stuff/libraries/OneWire/OneWire.cpp b/tests/makefile_stuff/libraries/OneWire/OneWire.cpp deleted file mode 100644 index 5c3561a..0000000 --- a/tests/makefile_stuff/libraries/OneWire/OneWire.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/* -Copyright (c) 2007, Jim Studt (original old version - many contributors since) - -The latest version of this library may be found at: - http://www.pjrc.com/teensy/td_libs_OneWire.html - -Version 2.1: - Arduino 1.0 compatibility, Paul Stoffregen - Improve temperature example, Paul Stoffregen - DS250x_PROM example, Guillermo Lovato - PIC32 (chipKit) compatibility, Jason Dangel, dangel.jason AT gmail.com - Improvements from Glenn Trewitt: - - crc16() now works - - check_crc16() does all of calculation/checking work. - - Added read_bytes() and write_bytes(), to reduce tedious loops. - - Added ds2408 example. - Delete very old, out-of-date readme file (info is here) - -Version 2.0: Modifications by Paul Stoffregen, January 2010: -http://www.pjrc.com/teensy/td_libs_OneWire.html - Search fix from Robin James - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 - Use direct optimized I/O in all cases - Disable interrupts during timing critical sections - (this solves many random communication errors) - Disable interrupts during read-modify-write I/O - Reduce RAM consumption by eliminating unnecessary - variables and trimming many to 8 bits - Optimize both crc8 - table version moved to flash - -Modified to work with larger numbers of devices - avoids loop. -Tested in Arduino 11 alpha with 12 sensors. -26 Sept 2008 -- Robin James -http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238032295/27#27 - -Updated to work with arduino-0008 and to include skip() as of -2007/07/06. --RJL20 - -Modified to calculate the 8-bit CRC directly, avoiding the need for -the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010 --- Tom Pollard, Jan 23, 2008 - -Jim Studt's original library was modified by Josh Larios. - -Tom Pollard, pollard@alum.mit.edu, contributed around May 20, 2008 - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Much of the code was inspired by Derek Yerger's code, though I don't -think much of that remains. In any event that was.. - (copyleft) 2006 by Derek Yerger - Free to distribute freely. - -The CRC code was excerpted and inspired by the Dallas Semiconductor -sample code bearing this copyright. -//--------------------------------------------------------------------------- -// Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES -// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// -// Except as contained in this notice, the name of Dallas Semiconductor -// shall not be used except as stated in the Dallas Semiconductor -// Branding Policy. -//-------------------------------------------------------------------------- -*/ - -#include "OneWire.h" - - -OneWire::OneWire(uint8_t pin) -{ - pinMode(pin, INPUT); - bitmask = PIN_TO_BITMASK(pin); - baseReg = PIN_TO_BASEREG(pin); -#if ONEWIRE_SEARCH - reset_search(); -#endif -} - - -// Perform the onewire reset function. We will wait up to 250uS for -// the bus to come high, if it doesn't then it is broken or shorted -// and we return a 0; -// -// Returns 1 if a device asserted a presence pulse, 0 otherwise. -// -uint8_t OneWire::reset(void) -{ - IO_REG_TYPE mask = bitmask; - volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; - uint8_t r; - uint8_t retries = 125; - - noInterrupts(); - DIRECT_MODE_INPUT(reg, mask); - interrupts(); - // wait until the wire is high... just in case - do { - if (--retries == 0) return 0; - delayMicroseconds(2); - } while ( !DIRECT_READ(reg, mask)); - - noInterrupts(); - DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low - interrupts(); - delayMicroseconds(500); - noInterrupts(); - DIRECT_MODE_INPUT(reg, mask); // allow it to float - delayMicroseconds(80); - r = !DIRECT_READ(reg, mask); - interrupts(); - delayMicroseconds(420); - return r; -} - -// -// Write a bit. Port and bit is used to cut lookup time and provide -// more certain timing. -// -void OneWire::write_bit(uint8_t v) -{ - IO_REG_TYPE mask=bitmask; - volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; - - if (v & 1) { - noInterrupts(); - DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low - delayMicroseconds(10); - DIRECT_WRITE_HIGH(reg, mask); // drive output high - interrupts(); - delayMicroseconds(55); - } else { - noInterrupts(); - DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low - delayMicroseconds(65); - DIRECT_WRITE_HIGH(reg, mask); // drive output high - interrupts(); - delayMicroseconds(5); - } -} - -// -// Read a bit. Port and bit is used to cut lookup time and provide -// more certain timing. -// -uint8_t OneWire::read_bit(void) -{ - IO_REG_TYPE mask=bitmask; - volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; - uint8_t r; - - noInterrupts(); - DIRECT_MODE_OUTPUT(reg, mask); - DIRECT_WRITE_LOW(reg, mask); - delayMicroseconds(3); - DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise - delayMicroseconds(10); - r = DIRECT_READ(reg, mask); - interrupts(); - delayMicroseconds(53); - return r; -} - -// -// Write a byte. The writing code uses the active drivers to raise the -// pin high, if you need power after the write (e.g. DS18S20 in -// parasite power mode) then set 'power' to 1, otherwise the pin will -// go tri-state at the end of the write to avoid heating in a short or -// other mishap. -// -void OneWire::write(uint8_t v, uint8_t power /* = 0 */) { - uint8_t bitMask; - - for (bitMask = 0x01; bitMask; bitMask <<= 1) { - OneWire::write_bit( (bitMask & v)?1:0); - } - if ( !power) { - noInterrupts(); - DIRECT_MODE_INPUT(baseReg, bitmask); - DIRECT_WRITE_LOW(baseReg, bitmask); - interrupts(); - } -} - -void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) { - for (uint16_t i = 0 ; i < count ; i++) - write(buf[i]); - if (!power) { - noInterrupts(); - DIRECT_MODE_INPUT(baseReg, bitmask); - DIRECT_WRITE_LOW(baseReg, bitmask); - interrupts(); - } -} - -// -// Read a byte -// -uint8_t OneWire::read() { - uint8_t bitMask; - uint8_t r = 0; - - for (bitMask = 0x01; bitMask; bitMask <<= 1) { - if ( OneWire::read_bit()) r |= bitMask; - } - return r; -} - -void OneWire::read_bytes(uint8_t *buf, uint16_t count) { - for (uint16_t i = 0 ; i < count ; i++) - buf[i] = read(); -} - -// -// Do a ROM select -// -void OneWire::select( uint8_t rom[8]) -{ - int i; - - write(0x55); // Choose ROM - - for( i = 0; i < 8; i++) write(rom[i]); -} - -// -// Do a ROM skip -// -void OneWire::skip() -{ - write(0xCC); // Skip ROM -} - -void OneWire::depower() -{ - noInterrupts(); - DIRECT_MODE_INPUT(baseReg, bitmask); - interrupts(); -} - -#if ONEWIRE_SEARCH - -// -// You need to use this function to start a search again from the beginning. -// You do not need to do it for the first search, though you could. -// -void OneWire::reset_search() - { - // reset the search state - LastDiscrepancy = 0; - LastDeviceFlag = FALSE; - LastFamilyDiscrepancy = 0; - for(int i = 7; ; i--) - { - ROM_NO[i] = 0; - if ( i == 0) break; - } - } - -// -// Perform a search. If this function returns a '1' then it has -// enumerated the next device and you may retrieve the ROM from the -// OneWire::address variable. If there are no devices, no further -// devices, or something horrible happens in the middle of the -// enumeration then a 0 is returned. If a new device is found then -// its address is copied to newAddr. Use OneWire::reset_search() to -// start over. -// -// --- Replaced by the one from the Dallas Semiconductor web site --- -//-------------------------------------------------------------------------- -// Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing -// search state. -// Return TRUE : device found, ROM number in ROM_NO buffer -// FALSE : device not found, end of search -// -uint8_t OneWire::search(uint8_t *newAddr) -{ - uint8_t id_bit_number; - uint8_t last_zero, rom_byte_number, search_result; - uint8_t id_bit, cmp_id_bit; - - unsigned char rom_byte_mask, search_direction; - - // initialize for search - id_bit_number = 1; - last_zero = 0; - rom_byte_number = 0; - rom_byte_mask = 1; - search_result = 0; - - // if the last call was not the last one - if (!LastDeviceFlag) - { - // 1-Wire reset - if (!reset()) - { - // reset the search - LastDiscrepancy = 0; - LastDeviceFlag = FALSE; - LastFamilyDiscrepancy = 0; - return FALSE; - } - - // issue the search command - write(0xF0); - - // loop to do the search - do - { - // read a bit and its complement - id_bit = read_bit(); - cmp_id_bit = read_bit(); - - // check for no devices on 1-wire - if ((id_bit == 1) && (cmp_id_bit == 1)) - break; - else - { - // all devices coupled have 0 or 1 - if (id_bit != cmp_id_bit) - search_direction = id_bit; // bit write value for search - else - { - // if this discrepancy if before the Last Discrepancy - // on a previous next then pick the same as last time - if (id_bit_number < LastDiscrepancy) - search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0); - else - // if equal to last pick 1, if not then pick 0 - search_direction = (id_bit_number == LastDiscrepancy); - - // if 0 was picked then record its position in LastZero - if (search_direction == 0) - { - last_zero = id_bit_number; - - // check for Last discrepancy in family - if (last_zero < 9) - LastFamilyDiscrepancy = last_zero; - } - } - - // set or clear the bit in the ROM byte rom_byte_number - // with mask rom_byte_mask - if (search_direction == 1) - ROM_NO[rom_byte_number] |= rom_byte_mask; - else - ROM_NO[rom_byte_number] &= ~rom_byte_mask; - - // serial number search direction write bit - write_bit(search_direction); - - // increment the byte counter id_bit_number - // and shift the mask rom_byte_mask - id_bit_number++; - rom_byte_mask <<= 1; - - // if the mask is 0 then go to new SerialNum byte rom_byte_number and reset mask - if (rom_byte_mask == 0) - { - rom_byte_number++; - rom_byte_mask = 1; - } - } - } - while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 - - // if the search was successful then - if (!(id_bit_number < 65)) - { - // search successful so set LastDiscrepancy,LastDeviceFlag,search_result - LastDiscrepancy = last_zero; - - // check for last device - if (LastDiscrepancy == 0) - LastDeviceFlag = TRUE; - - search_result = TRUE; - } - } - - // if no device found then reset counters so next 'search' will be like a first - if (!search_result || !ROM_NO[0]) - { - LastDiscrepancy = 0; - LastDeviceFlag = FALSE; - LastFamilyDiscrepancy = 0; - search_result = FALSE; - } - for (int i = 0; i < 8; i++) newAddr[i] = ROM_NO[i]; - return search_result; - } - -#endif - -#if ONEWIRE_CRC -// The 1-Wire CRC scheme is described in Maxim Application Note 27: -// "Understanding and Using Cyclic Redundancy Checks with Maxim iButton Products" -// - -#if ONEWIRE_CRC8_TABLE -// This table comes from Dallas sample code where it is freely reusable, -// though Copyright (C) 2000 Dallas Semiconductor Corporation -static const uint8_t PROGMEM dscrc_table[] = { - 0, 94,188,226, 97, 63,221,131,194,156,126, 32,163,253, 31, 65, - 157,195, 33,127,252,162, 64, 30, 95, 1,227,189, 62, 96,130,220, - 35,125,159,193, 66, 28,254,160,225,191, 93, 3,128,222, 60, 98, - 190,224, 2, 92,223,129, 99, 61,124, 34,192,158, 29, 67,161,255, - 70, 24,250,164, 39,121,155,197,132,218, 56,102,229,187, 89, 7, - 219,133,103, 57,186,228, 6, 88, 25, 71,165,251,120, 38,196,154, - 101, 59,217,135, 4, 90,184,230,167,249, 27, 69,198,152,122, 36, - 248,166, 68, 26,153,199, 37,123, 58,100,134,216, 91, 5,231,185, - 140,210, 48,110,237,179, 81, 15, 78, 16,242,172, 47,113,147,205, - 17, 79,173,243,112, 46,204,146,211,141,111, 49,178,236, 14, 80, - 175,241, 19, 77,206,144,114, 44,109, 51,209,143, 12, 82,176,238, - 50,108,142,208, 83, 13,239,177,240,174, 76, 18,145,207, 45,115, - 202,148,118, 40,171,245, 23, 73, 8, 86,180,234,105, 55,213,139, - 87, 9,235,181, 54,104,138,212,149,203, 41,119,244,170, 72, 22, - 233,183, 85, 11,136,214, 52,106, 43,117,151,201, 74, 20,246,168, - 116, 42,200,150, 21, 75,169,247,182,232, 10, 84,215,137,107, 53}; - -// -// Compute a Dallas Semiconductor 8 bit CRC. These show up in the ROM -// and the registers. (note: this might better be done without to -// table, it would probably be smaller and certainly fast enough -// compared to all those delayMicrosecond() calls. But I got -// confused, so I use this table from the examples.) -// -uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) -{ - uint8_t crc = 0; - - while (len--) { - crc = pgm_read_byte(dscrc_table + (crc ^ *addr++)); - } - return crc; -} -#else -// -// Compute a Dallas Semiconductor 8 bit CRC directly. -// this is much slower, but much smaller, than the lookup table. -// -uint8_t OneWire::crc8( uint8_t *addr, uint8_t len) -{ - uint8_t crc = 0; - - while (len--) { - uint8_t inbyte = *addr++; - for (uint8_t i = 8; i; i--) { - uint8_t mix = (crc ^ inbyte) & 0x01; - crc >>= 1; - if (mix) crc ^= 0x8C; - inbyte >>= 1; - } - } - return crc; -} -#endif - -#if ONEWIRE_CRC16 -bool OneWire::check_crc16(uint8_t* input, uint16_t len, uint8_t* inverted_crc) -{ - uint16_t crc = ~crc16(input, len); - return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1]; -} - -uint16_t OneWire::crc16(uint8_t* input, uint16_t len) -{ - static const uint8_t oddparity[16] = - { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; - uint16_t crc = 0; // Starting seed is zero. - - for (uint16_t i = 0 ; i < len ; i++) { - // Even though we're just copying a byte from the input, - // we'll be doing 16-bit computation with it. - uint16_t cdata = input[i]; - cdata = (cdata ^ (crc & 0xff)) & 0xff; - crc >>= 8; - - if (oddparity[cdata & 0x0F] ^ oddparity[cdata >> 4]) - crc ^= 0xC001; - - cdata <<= 6; - crc ^= cdata; - cdata <<= 1; - crc ^= cdata; - } - return crc; -} -#endif - -#endif diff --git a/tests/makefile_stuff/libraries/OneWire/OneWire.h b/tests/makefile_stuff/libraries/OneWire/OneWire.h deleted file mode 100644 index 2737b27..0000000 --- a/tests/makefile_stuff/libraries/OneWire/OneWire.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef OneWire_h -#define OneWire_h - -#include - -#if ARDUINO >= 100 -#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc -#else -#include "WProgram.h" // for delayMicroseconds -#include "pins_arduino.h" // for digitalPinToBitMask, etc -#endif - -// You can exclude certain features from OneWire. In theory, this -// might save some space. In practice, the compiler automatically -// removes unused code (technically, the linker, using -fdata-sections -// and -ffunction-sections when compiling, and Wl,--gc-sections -// when linking), so most of these will not result in any code size -// reduction. Well, unless you try to use the missing features -// and redesign your program to not need them! ONEWIRE_CRC8_TABLE -// is the exception, because it selects a fast but large algorithm -// or a small but slow algorithm. - -// you can exclude onewire_search by defining that to 0 -#ifndef ONEWIRE_SEARCH -#define ONEWIRE_SEARCH 1 -#endif - -// You can exclude CRC checks altogether by defining this to 0 -#ifndef ONEWIRE_CRC -#define ONEWIRE_CRC 1 -#endif - -// Select the table-lookup method of computing the 8-bit CRC -// by setting this to 1. The lookup table enlarges code size by -// about 250 bytes. It does NOT consume RAM (but did in very -// old versions of OneWire). If you disable this, a slower -// but very compact algorithm is used. -#ifndef ONEWIRE_CRC8_TABLE -#define ONEWIRE_CRC8_TABLE 1 -#endif - -// You can allow 16-bit CRC checks by defining this to 1 -// (Note that ONEWIRE_CRC must also be 1.) -#ifndef ONEWIRE_CRC16 -#define ONEWIRE_CRC16 1 -#endif - -#define FALSE 0 -#define TRUE 1 - -// Platform specific I/O definitions - -#if defined(__AVR__) -#define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define IO_REG_TYPE uint8_t -#define IO_REG_ASM asm("r30") -#define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) ((*(base+1)) &= ~(mask)) -#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) |= (mask)) -#define DIRECT_WRITE_LOW(base, mask) ((*(base+2)) &= ~(mask)) -#define DIRECT_WRITE_HIGH(base, mask) ((*(base+2)) |= (mask)) - -#elif defined(__PIC32MX__) -#include // is this necessary? -#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define IO_REG_TYPE uint32_t -#define IO_REG_ASM -#define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 -#define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 -#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 -#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 -#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28 - -#else -#error "Please define I/O register types here" -#endif - - -class OneWire -{ - private: - IO_REG_TYPE bitmask; - volatile IO_REG_TYPE *baseReg; - -#if ONEWIRE_SEARCH - // global search state - unsigned char ROM_NO[8]; - uint8_t LastDiscrepancy; - uint8_t LastFamilyDiscrepancy; - uint8_t LastDeviceFlag; -#endif - - public: - OneWire( uint8_t pin); - - // Perform a 1-Wire reset cycle. Returns 1 if a device responds - // with a presence pulse. Returns 0 if there is no device or the - // bus is shorted or otherwise held low for more than 250uS - uint8_t reset(void); - - // Issue a 1-Wire rom select command, you do the reset first. - void select( uint8_t rom[8]); - - // Issue a 1-Wire rom skip command, to address all on bus. - void skip(void); - - // Write a byte. If 'power' is one then the wire is held high at - // the end for parasitically powered devices. You are responsible - // for eventually depowering it by calling depower() or doing - // another read or write. - void write(uint8_t v, uint8_t power = 0); - - void write_bytes(const uint8_t *buf, uint16_t count, bool power = 0); - - // Read a byte. - uint8_t read(void); - - void read_bytes(uint8_t *buf, uint16_t count); - - // Write a bit. The bus is always left powered at the end, see - // note in write() about that. - void write_bit(uint8_t v); - - // Read a bit. - uint8_t read_bit(void); - - // Stop forcing power onto the bus. You only need to do this if - // you used the 'power' flag to write() or used a write_bit() call - // and aren't about to do another read or write. You would rather - // not leave this powered if you don't have to, just in case - // someone shorts your bus. - void depower(void); - -#if ONEWIRE_SEARCH - // Clear the search state so that if will start from the beginning again. - void reset_search(); - - // Look for the next device. Returns 1 if a new address has been - // returned. A zero might mean that the bus is shorted, there are - // no devices, or you have already retrieved all of them. It - // might be a good idea to check the CRC to make sure you didn't - // get garbage. The order is deterministic. You will always get - // the same devices in the same order. - uint8_t search(uint8_t *newAddr); -#endif - -#if ONEWIRE_CRC - // Compute a Dallas Semiconductor 8 bit CRC, these are used in the - // ROM and scratchpad registers. - static uint8_t crc8( uint8_t *addr, uint8_t len); - -#if ONEWIRE_CRC16 - // Compute the 1-Wire CRC16 and compare it against the received CRC. - // Example usage (reading a DS2408): - // // Put everything in a buffer so we can compute the CRC easily. - // uint8_t buf[13]; - // buf[0] = 0xF0; // Read PIO Registers - // buf[1] = 0x88; // LSB address - // buf[2] = 0x00; // MSB address - // WriteBytes(net, buf, 3); // Write 3 cmd bytes - // ReadBytes(net, buf+3, 10); // Read 6 data bytes, 2 0xFF, 2 CRC16 - // if (!CheckCRC16(buf, 11, &buf[11])) { - // // Handle error. - // } - // - // @param input - Array of bytes to checksum. - // @param len - How many bytes to use. - // @param inverted_crc - The two CRC16 bytes in the received data. - // This should just point into the received data, - // *not* at a 16-bit integer. - // @return True, iff the CRC matches. - static bool check_crc16(uint8_t* input, uint16_t len, uint8_t* inverted_crc); - - // Compute a Dallas Semiconductor 16 bit CRC. This is required to check - // the integrity of data received from many 1-Wire devices. Note that the - // CRC computed here is *not* what you'll get from the 1-Wire network, - // for two reasons: - // 1) The CRC is transmitted bitwise inverted. - // 2) Depending on the endian-ness of your processor, the binary - // representation of the two-byte return value may have a different - // byte order than the two bytes you get from 1-Wire. - // @param input - Array of bytes to checksum. - // @param len - How many bytes to use. - // @return The CRC16, as defined by Dallas Semiconductor. - static uint16_t crc16(uint8_t* input, uint16_t len); -#endif -#endif -}; - -#endif diff --git a/tests/makefile_stuff/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde b/tests/makefile_stuff/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde deleted file mode 100644 index 1d632ca..0000000 --- a/tests/makefile_stuff/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde +++ /dev/null @@ -1,109 +0,0 @@ -#include - -// OneWire DS18S20, DS18B20, DS1822 Temperature Example -// -// http://www.pjrc.com/teensy/td_libs_OneWire.html -// -// The DallasTemperature library can do all this work for you! -// http://milesburton.com/Dallas_Temperature_Control_Library - -OneWire ds(10); // on pin 10 - -void setup(void) { - Serial.begin(9600); -} - -void loop(void) { - byte i; - byte present = 0; - byte type_s; - byte data[12]; - byte addr[8]; - float celsius, fahrenheit; - - if ( !ds.search(addr)) { - Serial.println("No more addresses."); - Serial.println(); - ds.reset_search(); - delay(250); - return; - } - - Serial.print("ROM ="); - for( i = 0; i < 8; i++) { - Serial.write(' '); - Serial.print(addr[i], HEX); - } - - if (OneWire::crc8(addr, 7) != addr[7]) { - Serial.println("CRC is not valid!"); - return; - } - Serial.println(); - - // the first ROM byte indicates which chip - switch (addr[0]) { - case 0x10: - Serial.println(" Chip = DS18S20"); // or old DS1820 - type_s = 1; - break; - case 0x28: - Serial.println(" Chip = DS18B20"); - type_s = 0; - break; - case 0x22: - Serial.println(" Chip = DS1822"); - type_s = 0; - break; - default: - Serial.println("Device is not a DS18x20 family device."); - return; - } - - ds.reset(); - ds.select(addr); - ds.write(0x44,1); // start conversion, with parasite power on at the end - - delay(1000); // maybe 750ms is enough, maybe not - // we might do a ds.depower() here, but the reset will take care of it. - - present = ds.reset(); - ds.select(addr); - ds.write(0xBE); // Read Scratchpad - - Serial.print(" Data = "); - Serial.print(present,HEX); - Serial.print(" "); - for ( i = 0; i < 9; i++) { // we need 9 bytes - data[i] = ds.read(); - Serial.print(data[i], HEX); - Serial.print(" "); - } - Serial.print(" CRC="); - Serial.print(OneWire::crc8(data, 8), HEX); - Serial.println(); - - // convert the data to actual temperature - - unsigned int raw = (data[1] << 8) | data[0]; - if (type_s) { - raw = raw << 3; // 9 bit resolution default - if (data[7] == 0x10) { - // count remain gives full 12 bit resolution - raw = (raw & 0xFFF0) + 12 - data[6]; - } - } else { - byte cfg = (data[4] & 0x60); - if (cfg == 0x00) raw = raw << 3; // 9 bit resolution, 93.75 ms - else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms - else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms - // default is 12 bit resolution, 750 ms conversion time - } - celsius = (float)raw / 16.0; - fahrenheit = celsius * 1.8 + 32.0; - Serial.print(" Temperature = "); - Serial.print(celsius); - Serial.print(" Celsius, "); - Serial.print(fahrenheit); - Serial.println(" Fahrenheit"); -} diff --git a/tests/makefile_stuff/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde b/tests/makefile_stuff/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde deleted file mode 100644 index d171f9b..0000000 --- a/tests/makefile_stuff/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde +++ /dev/null @@ -1,77 +0,0 @@ -#include - -/* - * DS2408 8-Channel Addressable Switch - * - * Writte by Glenn Trewitt, glenn at trewitt dot org - * - * Some notes about the DS2408: - * - Unlike most input/output ports, the DS2408 doesn't have mode bits to - * set whether the pins are input or output. If you issue a read command, - * they're inputs. If you write to them, they're outputs. - * - For reading from a switch, you should use 10K pull-up resisters. - */ - -void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0) { - for (uint8_t i = 0; i < count; i++) { - Serial.print(addr[i]>>4, HEX); - Serial.print(addr[i]&0x0f, HEX); - } - if (newline) - Serial.println(); -} - -void ReadAndReport(OneWire* net, uint8_t* addr) { - Serial.print(" Reading DS2408 "); - PrintBytes(addr, 8); - Serial.println(); - - uint8_t buf[13]; // Put everything in the buffer so we can compute CRC easily. - buf[0] = 0xF0; // Read PIO Registers - buf[1] = 0x88; // LSB address - buf[2] = 0x00; // MSB address - net->write_bytes(buf, 3); - net->read_bytes(buf+3, 10); // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16 - net->reset(); - - if (!OneWire::check_crc16(buf, 11, &buf[11])) { - Serial.print("CRC failure in DS2408 at "); - PrintBytes(addr, 8, true); - return; - } - Serial.print(" DS2408 data = "); - // First 3 bytes contain command, register address. - Serial.println(buf[3], BIN); -} - -OneWire net(10); // on pin 10 - -void setup(void) { - Serial.begin(9600); -} - -void loop(void) { - byte i; - byte present = 0; - byte addr[8]; - - if (!net.search(addr)) { - Serial.print("No more addresses.\n"); - net.reset_search(); - delay(1000); - return; - } - - if (OneWire::crc8(addr, 7) != addr[7]) { - Serial.print("CRC is not valid!\n"); - return; - } - - if (addr[0] != 0x29) { - PrintBytes(addr, 8); - Serial.print(" is not a DS2408.\n"); - return; - } - - ReadAndReport(&net, addr); -} diff --git a/tests/makefile_stuff/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde b/tests/makefile_stuff/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde deleted file mode 100644 index baa51c8..0000000 --- a/tests/makefile_stuff/libraries/OneWire/examples/DS250x_PROM/DS250x_PROM.pde +++ /dev/null @@ -1,90 +0,0 @@ -/* -DS250x add-only programmable memory reader w/SKIP ROM. - - The DS250x is a 512/1024bit add-only PROM(you can add data but cannot change the old one) that's used mainly for device identification purposes - like serial number, mfgr data, unique identifiers, etc. It uses the Maxim 1-wire bus. - - This sketch will use the SKIP ROM function that skips the 1-Wire search phase since we only have one device connected in the bus on digital pin 6. - If more than one device is connected to the bus, it will fail. - Sketch will not verify if device connected is from the DS250x family since the skip rom function effectively skips the family-id byte readout. - thus it is possible to run this sketch with any Maxim OneWire device in which case the command CRC will most likely fail. - Sketch will only read the first page of memory(32bits) starting from the lower address(0000h), if more than 1 device is present, then use the sketch with search functions. - Remember to put a 4.7K pullup resistor between pin 6 and +Vcc - - To change the range or ammount of data to read, simply change the data array size, LSB/MSB addresses and for loop iterations - - This example code is in the public domain and is provided AS-IS. - - Built with Arduino 0022 and PJRC OneWire 2.0 library http://www.pjrc.com/teensy/td_libs_OneWire.html - - created by Guillermo Lovato - march/2011 - - */ - -#include -OneWire ds(6); // OneWire bus on digital pin 6 -void setup() { - Serial.begin (9600); -} - -void loop() { - byte i; // This is for the for loops - boolean present; // device present var - byte data[32]; // container for the data from device - byte leemem[3] = { // array with the commands to initiate a read, DS250x devices expect 3 bytes to start a read: command,LSB&MSB adresses - 0xF0 , 0x00 , 0x00 }; // 0xF0 is the Read Data command, followed by 00h 00h as starting address(the beginning, 0000h) - byte ccrc; // Variable to store the command CRC - byte ccrc_calc; - - present = ds.reset(); // OneWire bus reset, always needed to start operation on the bus, returns a 1/TRUE if there's a device present. - ds.skip(); // Skip ROM search - - if (present == TRUE){ // We only try to read the data if there's a device present - Serial.println("DS250x device present"); - ds.write(leemem[0],1); // Read data command, leave ghost power on - ds.write(leemem[1],1); // LSB starting address, leave ghost power on - ds.write(leemem[2],1); // MSB starting address, leave ghost power on - - ccrc = ds.read(); // DS250x generates a CRC for the command we sent, we assign a read slot and store it's value - ccrc_calc = OneWire::crc8(leemem, 3); // We calculate the CRC of the commands we sent using the library function and store it - - if ( ccrc_calc != ccrc) { // Then we compare it to the value the ds250x calculated, if it fails, we print debug messages and abort - Serial.println("Invalid command CRC!"); - Serial.print("Calculated CRC:"); - Serial.println(ccrc_calc,HEX); // HEX makes it easier to observe and compare - Serial.print("DS250x readback CRC:"); - Serial.println(ccrc,HEX); - return; // Since CRC failed, we abort the rest of the loop and start over - } - Serial.println("Data is: "); // For the printout of the data - for ( i = 0; i < 32; i++) { // Now it's time to read the PROM data itself, each page is 32 bytes so we need 32 read commands - data[i] = ds.read(); // we store each read byte to a different position in the data array - Serial.print(data[i]); // printout in ASCII - Serial.print(" "); // blank space - } - Serial.println(); - delay(5000); // Delay so we don't saturate the serial output - } - else { // Nothing is connected in the bus - Serial.println("Nothing connected"); - delay(3000); - } -} - - - - - - - - - - - - - - - - - diff --git a/tests/makefile_stuff/libraries/OneWire/keywords.txt b/tests/makefile_stuff/libraries/OneWire/keywords.txt deleted file mode 100644 index bee5d90..0000000 --- a/tests/makefile_stuff/libraries/OneWire/keywords.txt +++ /dev/null @@ -1,38 +0,0 @@ -####################################### -# Syntax Coloring Map For OneWire -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -OneWire KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -reset KEYWORD2 -write_bit KEYWORD2 -read_bit KEYWORD2 -write KEYWORD2 -write_bytes KEYWORD2 -read KEYWORD2 -read_bytes KEYWORD2 -select KEYWORD2 -skip KEYWORD2 -depower KEYWORD2 -reset_search KEYWORD2 -search KEYWORD2 -crc8 KEYWORD2 -crc16 KEYWORD2 -check_crc16 KEYWORD2 - -####################################### -# Instances (KEYWORD2) -####################################### - - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/tests/test_make.py b/tests/test_make.py deleted file mode 100644 index 2f8a37a..0000000 --- a/tests/test_make.py +++ /dev/null @@ -1,15 +0,0 @@ -from easyprocess import EasyProcess -from nose.tools import eq_ -from util import tmpdir -import os -import shutil - - -FIRMWARE = os.path.dirname(__file__) + '/../firmware/Nanpy' - - -def test_make(): - dest = tmpdir() + '/Nanpy' - shutil.copytree(FIRMWARE, dest) - p = EasyProcess('make size BOARD=uno', cwd=dest).call() - eq_(p.return_code, 0) From a612cb2ec33fad05a3caffd224bdb6c5f73ca716 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 22 Mar 2014 22:19:28 +0100 Subject: [PATCH 200/344] Codegen package removed --- codegen/README.md | 47 ---------------- codegen/__init__.py | 130 -------------------------------------------- 2 files changed, 177 deletions(-) delete mode 100644 codegen/README.md delete mode 100644 codegen/__init__.py diff --git a/codegen/README.md b/codegen/README.md deleted file mode 100644 index 3c841c8..0000000 --- a/codegen/README.md +++ /dev/null @@ -1,47 +0,0 @@ -Code generation -================ - -C code is generated for AVR type and registers. -All information is parsed from AVR Libc header files. - -dependencies: - - - path.py - - AVR Libc (http://www.nongnu.org/avr-libc/) - - sudo apt-get install python-pip avr-libc - sudo pip install path.py - -running from project directory: - - python codegen/__init__.py - -generated files: - - - firmware/Nanpy/generated_mcu.h - - firmware/Nanpy/generated_avr_registers.h - - -generated_mcu.h ------------------ - -This is a list of all known AVR types, "MCU" is defined to the type name. -Example: - - #ifdef __AVR_ATmega328P__ - # ifdef MCU - # error "MCU is already defined" - # endif - # define MCU "__AVR_ATmega328P__" - #endif - -generated_avr_registers.h ---------------------------- -This is a list of all known register names. -Example: - - #ifdef DDRB - DEFINE(DDRB) - #else - MISSING(DDRB) - #endif diff --git a/codegen/__init__.py b/codegen/__init__.py deleted file mode 100644 index aebc6db..0000000 --- a/codegen/__init__.py +++ /dev/null @@ -1,130 +0,0 @@ -from path import path - - -def read_define(fname, name): - for line in path(fname).lines(): - ls = line.split(name) - if len(ls) > 1: - if ls[0].strip().strip('#') == 'define': - return ls[1].strip() - - -class Codegen(object): - - def __init__(self, root): - self.root = root - - def header(self, avrlibc=True): - s = ''' -// this file was generated by codegen.py -''' - if avrlibc: - s += ''' -// __AVR_LIBC_VERSION_STRING__ = {version} -// __AVR_LIBC_DATE_STRING__ = {date} - \n'''.format( - version=self.version(), - date=self.date(), - ) - - return (s) - - def version(self): - return ( - read_define(self.root / 'version.h', '__AVR_LIBC_VERSION_STRING__') - ) - - def date(self): - return read_define(self.root / 'version.h', '__AVR_LIBC_DATE_STRING__') - - def write_header(self, hfile, text, avrlibc=True): - print 'writing to %s' % hfile - hfile.write_text(self.header(avrlibc) + text) - - def regs(self, target): - print '== generating code for registers ==' - valid = set() - defs = set() - print 'reading %s directory' % self.root - for h in path(self.root).walkfiles('*.h'): - for x in h.lines(): - x = x.replace('#', '').strip() - ls = x.split() + [''] * 4 - if 'define' == ls[0]: - if '_struct' not in ls[1]: - if '_SFR_IO8' in ls[2] or '_SFR_MEM8' in ls[2]: - valid.add(ls[1]) - if '_SFR_IO16' in ls[2] or '_SFR_MEM16' in ls[2]: - valid.add(ls[1]) - - ok = True - if '(' in ls[2]: - ok = False - if ls[1] != ls[1].upper(): - ok = False - if ls[1].startswith('_'): - ok = False - for s in ['(', '_vect', '_H', 'eeprom']: - if s in ls[1]: - ok = False - if ok: - defs.add(ls[1]) - exlude_regs = ['SPDR0'] - valid = filter(lambda x: x not in exlude_regs, valid) - valid = sorted(valid) - TEMPLATE = ''' -#ifdef {0} - DEFINE({0}) -#else - MISSING({0}) -#endif''' - cpp = '\n'.join([TEMPLATE.format(x) for x in valid]) - - self.write_header(target, cpp) - - def mcu(self, target): - print '== generating code for MCUs ==' - valid = set() - print 'reading %s directory' % self.root - for h in self.root.walkfiles('*.h'): - for x in h.lines(): - x = x.replace('#', '').strip() - x = x.replace('!', '').strip() - ls = x.split() + [''] * 4 - if ls[0] in ['elif', 'if']: - for t in ls: - if 'defined' in t or 'defined' in x: - if '__AVR_AT' in t: - t = t.replace('defined', '') - t = t.replace('(', '') - t = t.replace(')', '') - t = t.strip() - valid.add(t) - - valid = sorted(valid) - TEMPLATE = ''' -#ifdef {0} -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "{0}" -#endif''' - cpp = '\n'.join([TEMPLATE.format(x) for x in valid]) - self.write_header(target, cpp) - - -def main(): - firmware_path = path(__file__).abspath().parent.parent / 'firmware' - nanpy_path = path(__file__).abspath().parent.parent / 'nanpy' - avr_include_path = path('/usr/lib/avr/include/avr/') - - x = Codegen(avr_include_path) - - x.regs(firmware_path / 'Nanpy' / 'generated_avr_registers.h') - - x.mcu(firmware_path / 'Nanpy' / 'generated_mcu.h') - - print 'done' - -if __name__ == '__main__': - main() From 4d549052937483ddf39d57fa00c3f8ee90d0c174 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 28 Mar 2014 18:21:34 +0100 Subject: [PATCH 201/344] Wire and I2C support --- nanpy/arduinotree.py | 7 ++ nanpy/examples/i2c_scanner.py | 22 +++++++ nanpy/examples/i2c_send.py | 22 +++++++ nanpy/i2c.py | 110 ++++++++++++++++++++++++++++++++ nanpy/wire.py | 116 ++++++++++++++++++++++++++++++++++ 5 files changed, 277 insertions(+) create mode 100755 nanpy/examples/i2c_scanner.py create mode 100755 nanpy/examples/i2c_send.py create mode 100644 nanpy/i2c.py create mode 100644 nanpy/wire.py diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index b8ea09a..111ed59 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -12,6 +12,7 @@ from nanpy.serialmanager import SerialManager, serial_manager from nanpy.vcc import Vcc from nanpy.watchdog import Watchdog +from nanpy.wire import Wire import time @@ -117,3 +118,9 @@ def soft_reset(self): # TODO: after restart the first read is not correct (why?) # This command helps cleaning the read buffer self.connection.flush_input() + + @property + @memoized + def wire(self): + """Access to Wire.""" + return Wire(self.connection) diff --git a/nanpy/examples/i2c_scanner.py b/nanpy/examples/i2c_scanner.py new file mode 100755 index 0000000..6d85b69 --- /dev/null +++ b/nanpy/examples/i2c_scanner.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +# Description: + +from nanpy.arduinotree import ArduinoTree +from nanpy.i2c import I2C_Master +from nanpy.serialmanager import SerialManager +import logging +log = logging.getLogger(__name__) + + +def main(): + connection = SerialManager(sleep_after_connect=2) + connection.connect() + print connection.device + a = ArduinoTree(connection=connection) + master = I2C_Master(a.wire) + print ['0x%02x' % x for x in master.scan()] + + +if __name__ == '__main__': + main() diff --git a/nanpy/examples/i2c_send.py b/nanpy/examples/i2c_send.py new file mode 100755 index 0000000..55841d6 --- /dev/null +++ b/nanpy/examples/i2c_send.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +# Description: + +from nanpy.arduinotree import ArduinoTree +from nanpy.i2c import I2C_Master +from nanpy.serialmanager import SerialManager +import logging +log = logging.getLogger(__name__) + + +def main(): + connection = SerialManager(sleep_after_connect=2) + connection.connect() + print connection.device + a = ArduinoTree(connection=connection) + master = I2C_Master(a.wire) + master.send(0x27, [0b00001000]) + + +if __name__ == '__main__': + main() diff --git a/nanpy/i2c.py b/nanpy/i2c.py new file mode 100644 index 0000000..8fad5fd --- /dev/null +++ b/nanpy/i2c.py @@ -0,0 +1,110 @@ +import logging +log = logging.getLogger(__name__) + + +class I2C_CommunicationError(Exception): + error_texts = { + # 0: 'success', + 1: 'data too long to fit in transmit buffer', + 2: 'received NACK on transmit of address', + 3: 'received NACK on transmit of data', + 4: 'other error', + } + + def __init__(self, error_code): + self.error_code = error_code + Exception.__init__(self, self.error_texts[error_code]) + + +class I2C_Base(object): + + '' + bus_initialised = False + address = None + + def _begin(self): + if not self.bus_initialised: + self.wire.begin(self.address) + self.bus_initialised = True + + +class I2C_Master(I2C_Base): + + """High level interface for I2C Master.""" + + def __init__(self, wire): + self.wire = wire + + def request(self, address, quantity): + """Used by the master to request bytes from a slave device. + + :param address: the 7-bit address of the device to request bytes from + :param quantity: the number of bytes to request + :param stop: boolean. true will send a stop message after the request, releasing the bus. false will continually send a restart after the request, keeping the connection active. + :returns: byte : the number of bytes returned from the slave device + + http://arduino.cc/en/Reference/WireRequestFrom + + """ + self._begin() + n = self.wire.requestFrom(address, quantity, stop=True) + if n < quantity: + log.info('slave sent less bytes than requested') + ls = n * [None] + for i in range(n): + ls[i] = self.wire.read() + return ls + + def send(self, address, data): + """""" + self._begin() + self.wire.beginTransmission(address) + for b in data: + self.wire.write(b) + error_code = self.wire.endTransmission() + if error_code != 0: + raise I2C_CommunicationError(error_code) + + def scan(self): + """The i2c_scanner uses the return value of the Write.endTransmisstion + to see if a device did acknowledge to the address. + + original source: http://playground.arduino.cc/Main/I2cScanner#.Uxs4Wdt4iJM + + """ + self._begin() + ls = [] + for address in range(128): + try: + self.send(address, []) + ls.append(address) + except I2C_CommunicationError: + pass + + return ls + + +class I2C_Slave(I2C_Base): + + """High level interface for I2C Slave.""" + + def __init__(self, wire, address): + ''' + :param address: slave address + ''' + self.wire = wire + self.address = address + + def receive(self): + self._begin() + n = self.wire.available() + ls = n * [None] + for i in range(n): + ls[i] = self.wire.read() + return ls + + def send(self, data): + """""" + self._begin() + for b in data: + self.wire.write(b) diff --git a/nanpy/wire.py b/nanpy/wire.py new file mode 100644 index 0000000..76d49cc --- /dev/null +++ b/nanpy/wire.py @@ -0,0 +1,116 @@ +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware + + +@check4firmware +class Wire(FirmwareClass): + + """access to Wire library + http://arduino.cc/en/reference/wire + """ + firmware_id = 'Wire' + + @arduinomethod + def begin(self, address=None): + """Initiate the Wire library and join the I2C bus as a master or slave. + This should normally be called only once. + + :param address: the 7-bit slave address (optional); if not specified, + join the bus as a master. + :returns: None + + http://arduino.cc/en/Reference/WireBegin + + """ + + @returns(int) + @arduinomethod + def requestFrom(self, address, quantity, stop=True): + """Used by the master to request bytes from a slave device. The bytes + may then be retrieved with the available() and read() functions. + + :param address: the 7-bit address of the device to request bytes from + :param quantity: the number of bytes to request + :param stop: boolean. true will send a stop message after the request, + releasing the bus. false will continually send a restart after the request, + keeping the connection active. + :returns: byte : the number of bytes returned from the slave device + + http://arduino.cc/en/Reference/WireRequestFrom + + """ + + @arduinomethod + def beginTransmission(self, address): + """Begin a transmission to the I2C slave device with the given address. + Subsequently, queue bytes for transmission with the write() function + and transmit them by calling endTransmission(). + + :param address: the 7-bit address of the device to transmit to + :returns: None + + http://arduino.cc/en/Reference/WireBeginTransmission + + """ + + @returns(int) + @arduinomethod + def endTransmission(self, stop=True): + """Ends a transmission to a slave device that was begun by + beginTransmission() and transmits the bytes that were queued by + write(). + + :param stop: boolean. true will send a stop message, + releasing the bus after transmission. false will send a restart, + keeping the connection active. + :returns: byte, which indicates the status of the transmission: + 0:success + 1:data too long to fit in transmit buffer + 2:received NACK on transmit of address + 3:received NACK on transmit of data + 4:other error + + http://arduino.cc/en/Reference/WireEndTransmission + + """ + + @returns(int) + @arduinomethod + def write(self, value): + """Writes data from a slave device in response to a request from a + master, or queues bytes for transmission from a master to slave device. + + (in-between calls to beginTransmission() and endTransmission()). + + :param value: a value to send as a single byte + :returns: byte: write() will return the number of bytes written + + http://arduino.cc/en/Reference/WireWrite + + """ + + @returns(int) + @arduinomethod + def available(self, pin, value): + """Returns the number of bytes available for retrieval with read(). + This should be called on a master device after a call to requestFrom() + or on a slave inside the onReceive() handler. + + :returns: The number of bytes available for reading. + + http://arduino.cc/en/Reference/WireAvailable + + """ + + @returns(int) + @arduinomethod + def read(self, pin, value): + """Reads a byte that was transmitted from a slave device to a master + after a call to requestFrom() or was transmitted from a master to a + slave. + + :returns: The next byte received + + http://arduino.cc/en/Reference/WireRead + + """ From 5240bf94a8548d5849d1f29a9d2ba167f1c850a1 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 28 Mar 2014 18:23:45 +0100 Subject: [PATCH 202/344] LCD I2C interface support --- nanpy/examples/lcd_hello.py | 27 +++++++++++++++++++++++++++ nanpy/lcd_i2c.py | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 nanpy/examples/lcd_hello.py create mode 100644 nanpy/lcd_i2c.py diff --git a/nanpy/examples/lcd_hello.py b/nanpy/examples/lcd_hello.py new file mode 100755 index 0000000..9ab2982 --- /dev/null +++ b/nanpy/examples/lcd_hello.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +from nanpy import SerialManager +from nanpy.lcd import Lcd +from nanpy.lcd_i2c import Lcd_I2C + +I2C = True + + +def hello(): + connection = SerialManager(sleep_after_connect=2) + + cols, rows = 16, 2 + + if I2C: + pins = [0x27, 2, 1, 0, 4, 5, 6, 7, 3, 0] # "ebay" version + lcd = Lcd_I2C(pins, [cols, rows], connection=connection) + lcd.setBacklight(0) + else: + pins = [7, 8, 9, 10, 11, 12] + lcd = Lcd(pins, [cols, rows], connection=connection) + + lcd.setCursor(0, 0) + lcd.printString('hello') + +if __name__ == '__main__': + hello() diff --git a/nanpy/lcd_i2c.py b/nanpy/lcd_i2c.py new file mode 100644 index 0000000..c0c2139 --- /dev/null +++ b/nanpy/lcd_i2c.py @@ -0,0 +1,25 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import arduinoobjectmethod + + +class Lcd_I2C(ArduinoObject): + + def __init__(self, pins, begin, connection=None): + ''' + :param pins: [lcd_Addr, enable, Rw, Rs, d4, d5, d6, d7, backlighPin, pol] + :param begin: [cols, rows] + ''' + ArduinoObject.__init__(self, connection=connection) + self.id = self.call('new', pins, begin) + + @arduinoobjectmethod + def printString(self, value, col=None, row=None): + pass + + @arduinoobjectmethod + def setCursor(self, col, row): + pass + + @arduinoobjectmethod + def setBacklight(self, value): + pass From ed0c1d842ea6ef5c9f93f732d3946a95bfafc211 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 2 Apr 2014 20:53:38 +0200 Subject: [PATCH 203/344] new: firmware_info --- nanpy/arduinotree.py | 17 ++++----- nanpy/examples/checkspeed.py | 3 -- nanpy/fwinfo.py | 67 ++++++++++++++++++++++++++++++++++++ tests/test_fwinfo.py | 41 ++++++++++++++++++++++ tests/test_serial/test.py | 5 --- 5 files changed, 115 insertions(+), 18 deletions(-) create mode 100644 nanpy/fwinfo.py create mode 100644 tests/test_fwinfo.py diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index 111ed59..46c83ef 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -6,6 +6,7 @@ from nanpy.counter import Counter from nanpy.define import DefineFeature from nanpy.eepromobj import EepromLib +from nanpy.fwinfo import firmware_info from nanpy.memo import memoized from nanpy.ram import RAM from nanpy.register import RegisterFeature @@ -95,16 +96,6 @@ def vcc(self): """Access to VCC.""" return Vcc(self.register) - @property - def avr_name(self): - """The name of the AVR. - - Example: ATmega328P - - """ - s = self.define.get('MCU') - return s.strip('_').split('_')[-1] - def soft_reset(self): """Resets the AVR, the registers will be reset to their known, default settings. @@ -124,3 +115,9 @@ def soft_reset(self): def wire(self): """Access to Wire.""" return Wire(self.connection) + + @property + @memoized + def firmware_info(self): + """""" + return firmware_info(self.define.as_dict) diff --git a/nanpy/examples/checkspeed.py b/nanpy/examples/checkspeed.py index 20e3e58..0fe6121 100644 --- a/nanpy/examples/checkspeed.py +++ b/nanpy/examples/checkspeed.py @@ -29,9 +29,6 @@ def checkspeed(n): print ('n=%s' % n) print('') - a.avr_name # init cache - measure(a, n, 'avr_name') - measure(a, n, 'api.digitalRead(0)') measure(a, n, 'api.digitalWrite(0,0)') measure(a, n, 'api.analogRead(0)') diff --git a/nanpy/fwinfo.py b/nanpy/fwinfo.py new file mode 100644 index 0000000..09bcc6f --- /dev/null +++ b/nanpy/fwinfo.py @@ -0,0 +1,67 @@ +import datetime + + +def avr_name(MCU): + """The name of the AVR. + + Example: __AVR_ATmega328P__ -> ATmega328P + + """ + return MCU.strip('_').split('_')[-1] + + +def arduino_version(ARDUINO): + """ + Example: 105 -> 1.0.5 + + """ + return '.'.join(str(ARDUINO)) + + +def compile_datetime(DATE, TIME): + ''' + Example: Mar 28 2014, 17:40:12 + -> datetime.datetime(2008, 3, 28, 17, 40, 12) + ''' + dt = datetime.datetime.strptime( + DATE + ' ' + TIME, + '%b %d %Y %H:%M:%S') + return dt + + +def libc_version(AVR_LIBC_VERSION): + """ + Example: 10604 -> 1.6.4 + + """ + s = str(AVR_LIBC_VERSION) + ls = [s[0], s[1:3], s[3:5]] + ls = map(int, ls) + ls = map(str, ls) + return '.'.join(ls) + + +def libc_date(AVR_LIBC_DATE): + """ + Example: 20081106 -> 2008.11.06 + + """ + s = str(AVR_LIBC_DATE) + ls = [s[0:4], s[4:6], s[6:8]] + ls = map(int, ls) + d = datetime.date(*ls) + return d + + +def firmware_info(define_dict): + d = dict() + d['avr_name'] = avr_name(define_dict['MCU']) + d['arduino_version'] = arduino_version(define_dict['ARDUINO']) + d['compile_datetime'] = compile_datetime(define_dict['__DATE__'], + define_dict['__TIME__'], + ) + d['gcc_version'] = define_dict['__VERSION__'] + d['libc_version'] = libc_version(define_dict['__AVR_LIBC_VERSION__']) + d['libc_date'] = libc_date(define_dict['__AVR_LIBC_DATE_']) + + return d diff --git a/tests/test_fwinfo.py b/tests/test_fwinfo.py new file mode 100644 index 0000000..32fe94f --- /dev/null +++ b/tests/test_fwinfo.py @@ -0,0 +1,41 @@ +from nanpy.fwinfo import libc_version, arduino_version, avr_name, libc_date, \ + compile_datetime, firmware_info +from nose.tools import eq_ +import datetime + + +def test(): + eq_(libc_version(10604), '1.6.4') + eq_(libc_version('10604'), '1.6.4') + eq_(libc_version(11111), '1.11.11') + + eq_(libc_date(20081106), datetime.date(2008, 11, 6)) + eq_(libc_date('20081106'), datetime.date(2008, 11, 6)) + + eq_(arduino_version(105), '1.0.5') + eq_(arduino_version('105'), '1.0.5') + + eq_(avr_name('__AVR_ATmega328P__'), 'ATmega328P') + + eq_(compile_datetime('Mar 28 2008', '17:40:12'), + datetime.datetime(2008, 3, 28, 17, 40, 12)) + + eq_(firmware_info(dict( + MCU='__AVR_ATmega328P__', + ARDUINO='105', + __DATE__='Mar 28 2014', + __TIME__='17:40:12', + __VERSION__='4.3.2', + __AVR_LIBC_DATE_='20081106', + __AVR_LIBC_VERSION__='10604', + + )), + {'gcc_version': '4.3.2', + 'libc_version': '1.6.4', + 'libc_date': datetime.date(2008, 11, 6), + 'arduino_version': '1.0.5', + 'avr_name': 'ATmega328P', + 'compile_datetime': + datetime.datetime(2014, 3, 28, 17, 40, 12), + } + ) diff --git a/tests/test_serial/test.py b/tests/test_serial/test.py index 9e27cd2..dc2328a 100644 --- a/tests/test_serial/test.py +++ b/tests/test_serial/test.py @@ -11,11 +11,6 @@ def setup(): common.setup() -def test_avr_name(): - a = ArduinoTree() - eq_(a.avr_name, config['avr_name']) - - def test_vcc(): a = ArduinoTree() ok_vcc(a.vcc.read()) From b02300d9858270e5e703c5f1906b12badfc96a9a Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 2 Apr 2014 20:55:22 +0200 Subject: [PATCH 204/344] SerialManager: open(), close(), timeout parameter --- nanpy/examples/checkspeed.py | 2 +- nanpy/examples/i2c_scanner.py | 2 +- nanpy/examples/i2c_send.py | 2 +- nanpy/serialmanager.py | 24 ++++++++++++++++++------ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/nanpy/examples/checkspeed.py b/nanpy/examples/checkspeed.py index 0fe6121..d06258b 100644 --- a/nanpy/examples/checkspeed.py +++ b/nanpy/examples/checkspeed.py @@ -22,7 +22,7 @@ def measure(a, n, f, root='a'): def checkspeed(n): connection = SerialManager() - connection.connect() + connection.open() a = ArduinoTree(connection=connection) print ('performance test for ArduinoTree()') diff --git a/nanpy/examples/i2c_scanner.py b/nanpy/examples/i2c_scanner.py index 6d85b69..9a54afd 100755 --- a/nanpy/examples/i2c_scanner.py +++ b/nanpy/examples/i2c_scanner.py @@ -11,7 +11,7 @@ def main(): connection = SerialManager(sleep_after_connect=2) - connection.connect() + connection.open() print connection.device a = ArduinoTree(connection=connection) master = I2C_Master(a.wire) diff --git a/nanpy/examples/i2c_send.py b/nanpy/examples/i2c_send.py index 55841d6..5180d22 100755 --- a/nanpy/examples/i2c_send.py +++ b/nanpy/examples/i2c_send.py @@ -11,7 +11,7 @@ def main(): connection = SerialManager(sleep_after_connect=2) - connection.connect() + connection.open() print connection.device a = ArduinoTree(connection=connection) master = I2C_Master(a.wire) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 05a16f7..f75a726 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -49,12 +49,17 @@ def readline(self): class SerialManager(object): _serial = None - def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE, sleep_after_connect=2): + def __init__(self, device=None, + baudrate=DEFAULT_BAUDRATE, + sleep_after_connect=2, + timeout=1): self.device = device self.baudrate = baudrate self.sleep_after_connect = sleep_after_connect + self.timeout = timeout - def connect(self, device=None): + def open(self, device=None): + '''open connection''' if device: self.device = device @@ -65,14 +70,16 @@ def connect(self, device=None): self.device = ports[0] log.debug('opening port:%s [%s baud]' % (self.device, self.baudrate)) assert self.device - self._serial = serial.Serial(self.device, self.baudrate, timeout=1) + self._serial = serial.Serial(self.device, + self.baudrate, + timeout=self.timeout) if self.sleep_after_connect: time.sleep(self.sleep_after_connect) self._serial.flushInput() def write(self, value): if not self._serial: - self.connect() + self.open() log.debug('sending:%s' % repr(value)) if PY3: self._serial.write(bytes(value, 'latin-1')) @@ -81,7 +88,7 @@ def write(self, value): def readline(self): if not self._serial: - self.connect() + self.open() s = self._serial.readline() log.debug('received:%s' % repr(s)) s = s.decode() @@ -92,9 +99,14 @@ def readline(self): def flush_input(self): '''Flush input buffer, discarding all it's contents.''' if not self._serial: - self.connect() + self.open() self._serial.flushInput() + def close(self): + '''close connection''' + if self._serial: + self._serial.close() + self._serial = None serial_manager = SerialManager() From e01bc99d6335f02b545dbb12b1dd96fdcd78a3df Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Thu, 10 Apr 2014 16:01:29 +0100 Subject: [PATCH 205/344] Add PyPi badge to README. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 515c11e..96310fa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ Nanpy ===== + +[![PyPI version](https://badge.fury.io/py/nanpy.svg)](http://badge.fury.io/py/nanpy) + Use your Arduino board with Python. Description From 46fa0b7a42edd4e03d45115e129ff61887b5988a Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 22 Apr 2014 01:10:42 +0200 Subject: [PATCH 206/344] Version 0.9 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a28be48..3d2c7a5 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.8", + version="0.9", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From 52c8f2e8ce686fea6aae025104fab6f5df21814e Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 8 Jun 2014 02:22:11 +0200 Subject: [PATCH 207/344] Added getResolution and setResolution for DallasTemperature --- nanpy/dallastemperature.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 9db8bed..b5f7125 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -8,6 +8,15 @@ def __init__(self, pin): self.pin = pin self.id = self.call('new', pin) + @arduinoobjectmethod + def setResolution(self, bits): + pass + + @returns(int) + @arduinoobjectmethod + def getResolution(self, bits): + pass + @returns(int) @arduinoobjectmethod def getDeviceCount(self): @@ -18,7 +27,7 @@ def getAddress(self, index): if val == "1": return val return val.split(' ') - + @arduinoobjectmethod def requestTemperatures(self, address = None): From f3cc1c9813c2b47781e6115de5962619d3161df3 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 8 Jun 2014 02:25:22 +0200 Subject: [PATCH 208/344] Ignore venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7576ade..4ff8229 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ nanpy.egg-info/ cfg.h setup_makefile.sh firmware +venv #Python *.pyc From 0d158596edec70edfabedd16efd12d0de0c61531 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 8 Jun 2014 03:17:28 +0200 Subject: [PATCH 209/344] Added setResolution to DallasTemperature sample, request the address before cycle --- nanpy/examples/dallastemperature.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nanpy/examples/dallastemperature.py b/nanpy/examples/dallastemperature.py index 8977aaf..ec187d9 100755 --- a/nanpy/examples/dallastemperature.py +++ b/nanpy/examples/dallastemperature.py @@ -8,10 +8,11 @@ sensors = DallasTemperature(5) +print("There are %d devices connected on pin %d" % (sensors.getDeviceCount(), sensors.pin)) +addr = sensors.getAddress(0) +sensors.setResolution(9) while True: - print("There are %d devices connected on pin %d" % (sensors.getDeviceCount(), sensors.pin)) sensors.requestTemperatures(0) - addr = sensors.getAddress(0) temp = sensors.getTempC(addr) print("The temperature, in Celsius degrees is %0.2f" % temp) print("Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp)) From 1d6fc1d987bc3d90946a40ba77e898fad8d9618f Mon Sep 17 00:00:00 2001 From: Richard Giles Date: Fri, 1 Aug 2014 14:46:37 +0800 Subject: [PATCH 210/344] fixed getAddress method (was missing @arduinoobjectmethod) --- nanpy/dallastemperature.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index b5f7125..8489389 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -22,6 +22,7 @@ def getResolution(self, bits): def getDeviceCount(self): pass + @arduinoobjectmethod def getAddress(self, index): val = self.call('getAddress') if val == "1": From 82c69f55b9c1e3a83cd8441d74114c5bf84d9339 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 9 Aug 2014 14:30:47 +0200 Subject: [PATCH 211/344] Added Richard Giles to CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8290d0f..cfc6569 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -11,3 +11,4 @@ Contributors - Fernando Molina (Twitter @F_M_A) - Laurent Désarmes (https://github.com/llaurent) - Anthony Goodhew (tony.goodhew@ntlworld.com) +- Richard Giles (https://github.com/wrik) From efa85eb2118b9faf64615f5f94acb71f9a54fc14 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 9 Aug 2014 14:35:37 +0200 Subject: [PATCH 212/344] Version 0.9.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3d2c7a5..eec4bb8 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.9", + version="0.9.1", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From 6b00cbe26adc413187d0f392bffcad218fcca7d2 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 24 Aug 2014 09:33:40 +0200 Subject: [PATCH 213/344] fix Wire.read --- nanpy/wire.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/wire.py b/nanpy/wire.py index 76d49cc..0b1cc61 100644 --- a/nanpy/wire.py +++ b/nanpy/wire.py @@ -104,7 +104,7 @@ def available(self, pin, value): @returns(int) @arduinomethod - def read(self, pin, value): + def read(self): """Reads a byte that was transmitted from a slave device to a master after a call to requestFrom() or was transmitted from a master to a slave. From 77184b4178503d9252453aab83175934762e0575 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 24 Aug 2014 09:38:36 +0200 Subject: [PATCH 214/344] support for bmp180 presssure sensor --- nanpy/bmp180.py | 117 +++++++++++++++++++++++++++++++++++++ nanpy/examples/pressure.py | 24 ++++++++ 2 files changed, 141 insertions(+) create mode 100755 nanpy/bmp180.py create mode 100755 nanpy/examples/pressure.py diff --git a/nanpy/bmp180.py b/nanpy/bmp180.py new file mode 100755 index 0000000..f7356fd --- /dev/null +++ b/nanpy/bmp180.py @@ -0,0 +1,117 @@ +from __future__ import division + +import logging +from nanpy.i2c import I2C_Master +from nanpy.memo import memoized +import time + + +log = logging.getLogger(__name__) + + +def to_s16(n): + return (n + 2 ** 15) % 2 ** 16 - 2 ** 15 + + +class Bmp180(object): + """Control of BMP180 Digital pressure sensor (I2C) + + calculation is based on Bosch datasheet.""" + + def __init__(self, wire, address=0x77, oss=3): + self.i2c = I2C_Master(wire) + self.address = address + self.oss = oss + + def read_bytes(self, address, count): + self.i2c.send(self.address, [address]) + x = self.i2c.request(self.address, count) + return x + + def write_byte(self, address, data): + self.i2c.send(self.address, [address, data]) + + @property + @memoized + def eeprom(self): + return self.read_bytes(0xaa, 22) + + def read_temperature_raw(self): + self.write_byte(0xf4, 0x2e) + time.sleep(0.005) + + MSB, LSB = self.read_bytes(0xf6, 2) + + UT = (MSB << 8) + LSB + return UT + + def read_pressure_raw(self): + self.write_byte(0xf4, 0x34 + (self.oss << 6)) + time.sleep(0.005) + MSB, LSB, XLSB = self.read_bytes(0xf6, 3) + + UP = ((MSB << 16) + (LSB << 8) + XLSB) >> (8 - self.oss) + return UP + + @classmethod + def calculate(cls, pressure_raw, temperature_raw, oss, eeprom): + ''' + return: Pascal, Celsius + ''' + UT = temperature_raw + UP = pressure_raw + + def ushort(i): + return (eeprom[2 * i] << 8) + eeprom[2 * i + 1] + + def short(i): + return to_s16(ushort(i)) + + AC1 = short(0) + AC2 = short(1) + AC3 = short(2) + AC4 = ushort(3) + AC5 = ushort(4) + AC6 = ushort(5) + B1 = short(6) + B2 = short(7) +# MB = short(8) + MC = short(9) + MD = short(10) + + X1 = ((UT - AC6) * AC5) >> 15 + X2 = (MC << 11) // (X1 + MD) + B5 = X1 + X2 + T = (B5 + 8) >> 4 + + B6 = B5 - 4000 + X1 = (B2 * ((B6 * B6) >> 12)) >> 11 + X2 = (AC2 * B6) >> 11 + X3 = X1 + X2 + B3 = (((AC1 * 4 + X3) << oss) + 2) // 4 + X1 = (AC3 * B6) >> 13 + X2 = (B1 * ((B6 * B6) >> 12)) >> 16 + X3 = ((X1 + X2) + 2) // 4 + B4 = (AC4 * (X3 + 32768)) >> 15 + B7 = (UP - B3) * (50000 >> oss) + p = (B7 * 2) // B4 if B7 < 0x80000000 else (B7 // B4) * 2 + X1 = (p >> 8) * (p >> 8) + X1 = (X1 * 3038) >> 16 + X2 = (-7357 * p) >> 16 + p += (X1 + X2 + 3791) >> 4 + + return p, T / 10 + + def read(self): + ''' + return: Pascal, Celsius + ''' + temperature_raw = self.read_temperature_raw() + pressure_raw = self.read_pressure_raw() + + return self.calculate( + pressure_raw, + temperature_raw, + self.oss, + self.eeprom, + ) diff --git a/nanpy/examples/pressure.py b/nanpy/examples/pressure.py new file mode 100755 index 0000000..413dc04 --- /dev/null +++ b/nanpy/examples/pressure.py @@ -0,0 +1,24 @@ +"""Pressure sensor demo. + +Connect the BMP180 to the I2C bus. + +""" +from __future__ import division + +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager + +from nanpy.bmp180 import Bmp180 + + +def main(): + connection = SerialManager(sleep_after_connect=2) + connection.open() + a = ArduinoTree(connection=connection) + bmp = Bmp180(a.wire) + p, t = bmp.read() + print 'pressure: %s kPa' % (p / 1000) + print 'temperature: %s C' % t + +if __name__ == '__main__': + main() From 27e3ef9588eaa48d60fc0410897e9862c4458000 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 1 Sep 2014 13:43:37 +0200 Subject: [PATCH 215/344] Added Graeme Pyle to contributors --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index cfc6569..259f8ba 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,3 +12,4 @@ Contributors - Laurent Désarmes (https://github.com/llaurent) - Anthony Goodhew (tony.goodhew@ntlworld.com) - Richard Giles (https://github.com/wrik) +- Graeme Pyle (https://github.com/graemian) From 2638326e578f5b0bd0df7f24af6fb31124d30bdc Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 21 Sep 2014 03:08:23 +0200 Subject: [PATCH 216/344] Added Justin Youngblood to CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 259f8ba..af42d70 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -13,3 +13,4 @@ Contributors - Anthony Goodhew (tony.goodhew@ntlworld.com) - Richard Giles (https://github.com/wrik) - Graeme Pyle (https://github.com/graemian) +- Justin Youngblood (darksotm@gmail.com) From 0abb921e0e2413cc291a54fdcea3e0d3443a8595 Mon Sep 17 00:00:00 2001 From: Justin Youngblood Date: Wed, 24 Sep 2014 19:22:01 -0700 Subject: [PATCH 217/344] Update dallastemperature.py --- nanpy/dallastemperature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 8489389..d60fe44 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -3,8 +3,8 @@ class DallasTemperature(ArduinoObject): - def __init__(self, pin): - ArduinoObject.__init__(self) + def __init__(self, pin, connection=None): + ArduinoObject.__init__(self, connection=connection) self.pin = pin self.id = self.call('new', pin) From 47ce98960cdfcd4c25109845047ad7fc6db2084b Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 30 Sep 2014 20:32:56 +0200 Subject: [PATCH 218/344] Set serial default timeout to None --- nanpy/serialmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index f75a726..0550612 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -52,7 +52,7 @@ class SerialManager(object): def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE, sleep_after_connect=2, - timeout=1): + timeout=None): self.device = device self.baudrate = baudrate self.sleep_after_connect = sleep_after_connect From 6ecc00cb33c21a45598085f82cb38b3db2178e07 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 30 Sep 2014 20:39:21 +0200 Subject: [PATCH 219/344] Added missing connection parameter to all ArduinoObjects --- nanpy/capacitivesensor.py | 4 ++-- nanpy/dht.py | 4 ++-- nanpy/onewire.py | 6 +++--- nanpy/servo.py | 4 ++-- nanpy/stepper.py | 4 ++-- nanpy/tone.py | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nanpy/capacitivesensor.py b/nanpy/capacitivesensor.py index 95fabe5..fc51d26 100644 --- a/nanpy/capacitivesensor.py +++ b/nanpy/capacitivesensor.py @@ -3,8 +3,8 @@ class CapacitiveSensor(ArduinoObject): - def __init__(self, pin1, pin2): - ArduinoObject.__init__(self) + def __init__(self, pin1, pin2, connection=None): + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pin1, pin2) @returns(int) diff --git a/nanpy/dht.py b/nanpy/dht.py index a82a08d..3ccb6ef 100644 --- a/nanpy/dht.py +++ b/nanpy/dht.py @@ -8,8 +8,8 @@ class DHT(ArduinoObject): DHT21 = 21 AM2301 = 21 - def __init__(self, pin, _type, count = 6): - ArduinoObject.__init__(self) + def __init__(self, pin, _type, count = 6, connection=None): + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pin, _type, count) @returns(int) diff --git a/nanpy/onewire.py b/nanpy/onewire.py index d3f1013..c1a4a85 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -2,9 +2,9 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class OneWire(ArduinoObject): - - def __init__(self, pin): - ArduinoObject.__init__(self) + + def __init__(self, pin, connection=None): + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pin) def search(self): diff --git a/nanpy/servo.py b/nanpy/servo.py index 1443e41..b847bb9 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -3,8 +3,8 @@ class Servo(ArduinoObject): - def __init__(self, pin): - ArduinoObject.__init__(self) + def __init__(self, pin, connection=None): + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pin) @arduinoobjectmethod diff --git a/nanpy/stepper.py b/nanpy/stepper.py index b674526..714c8bf 100644 --- a/nanpy/stepper.py +++ b/nanpy/stepper.py @@ -3,8 +3,8 @@ class Stepper(ArduinoObject): - def __init__(self, revsteps, pin1, pin2, speed=None): - ArduinoObject.__init__(self) + def __init__(self, revsteps, pin1, pin2, speed=None, connection=None): + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', revsteps, pin1, pin2) if speed: self.setSpeed(speed) diff --git a/nanpy/tone.py b/nanpy/tone.py index c887641..2bc3a19 100644 --- a/nanpy/tone.py +++ b/nanpy/tone.py @@ -93,8 +93,8 @@ class Tone(ArduinoObject): NOTE_D8 = 4699 NOTE_DS8 = 4978 - def __init__(self, pin): - ArduinoObject.__init__(self) + def __init__(self, pin, connection=None): + ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pin) @arduinoobjectmethod From 4ba2be6a30c38c8609db1d64abebacfd24f815da Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Thu, 2 Oct 2014 09:55:27 +0200 Subject: [PATCH 220/344] Version 0.9.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index eec4bb8..be231ac 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name="nanpy", - version="0.9.1", + version="0.9.2", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From fd1b55674f037076ed0e53267ac6e6df8a89b51b Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 18 Oct 2014 14:18:24 +0200 Subject: [PATCH 221/344] Minfixes on README --- README.md | 101 +++++++++++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 96310fa..168939d 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,72 @@ -Nanpy -===== +# Nanpy [![PyPI version](https://badge.fury.io/py/nanpy.svg)](http://badge.fury.io/py/nanpy) -Use your Arduino board with Python. +--- -Description ------------ -The main purpose of Nanpy is making programmers' life easier, giving them something to create prototypes faster and use Arduino in a simpler way, thanks to a simple and powerful language like Python. Also Nanpy can run on RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use it for communicating with Arduino :) +## Overview -Let's start with a classic example, turn on a led placed in the 13th pin.. +Nanpy is a library that use your Arduino as a slave, controlled by a master device where you run your scripts, such as a PC, a Raspberry Pi etc. +The main purpose of Nanpy is making programmers' life easier, providing them a powerful library to create prototypes faster and make Arduino programming a game for kids. - connection = SerialManager() - a = ArduinoApi(connection=connection) - a.pinMode(13, a.OUTPUT) - a.digitalWrite(13, a.HIGH) + a = ArduinoApi() + a.pinMode(13, a.OUTPUT) + a.digitalWrite(13, a.HIGH) -There are a lot of projects able to do that. Nanpy can do more! +I know, there are a lot of projects able to do that, but hey, Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. -We started supporting OneWire, Lcd, Stepper and Servo library and they're still incomplete. -Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print something! +We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many more... +Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and show your first "Hello world"! - connection = SerialManager() - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2], connection=connection) - lcd.printString("Hello World!") + from nanpy import Lcd + + lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + lcd.printString('Hello World!') really straightforward now, isn't it? :) -Multithreading --------------- -What happens if you call methods in an async context? Nothing bad, all works! every call is mutually exclusive.. For example, suppose that two threads need to write on the same Lcd and in different positions at the same time... well, just call printString on the Lcd object specifying the position (row and column) +### Serial communication - #Thread_1 - ... - lcd.printString("Hello First Row!", 0, 0) - ... - - #Thread_2 - .... - lcd.printString("Hello Second Row!", 0, 1) - ... +Nanpy autodetects the serial port for you, anyway you can manually specify another serial port: -How to build and install ------------------------- -You need to build the firmware for your Arduino first, just clone the firmware repository at https://github.com/nanpy/firmware and follow the README to configure and build it. + from nanpy import SerialManager + connection = SerialManager(device='/dev/ttyACM1') -To install Nanpy Python library just type (as root): +and use it with your objects - python setup.py install + a = ArduinoApi(connection=connection) + a.pinMode(13, a.OUTPUT) + a.digitalWrite(13, a.HIGH) -How to use ----------- -### Serial communication +You can specify how many SerialManager objects you want and control more than one Arduino board within the same script. + +--- + +## How to build and install + +First of all, you need to build the firmware and upload it on your Arduino, to do that clone the [nanpy-firmware repository on Github](https://github.com/nanpy/firmware) or [download it from PyPi](https://pypi.python.org/pypi/nanpy). + + git clone git@github.com:nanpy/nanpy-firmware.git + cd nanpy-firmware + ./configure.sh + +You can now edit Nanpy/cfg.h generated file to configure your Nanpy firmware, selecting the features you want to include and the baud rate. +To build and install Nanpy firmware, copy Nanpy directory under your "sketchbook" directory, start your Arduino IDE, open Sketchbook -> Nanpy and click on "Upload". + +To install Nanpy Python library on your master device just type: -Nanpy autodetects the serial port for you, anyway you can specify another serial port manually: + pip install nanpy - from nanpy import SerialManager - connection = SerialManager(device='/dev/ttyACM1') +--- -### Import modules +## How to contribute -Import all the modules you need :) +Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at - from nanpy import Arduino - from nanpy import (OneWire, Lcd) - ... +Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, [please donate using Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J) -How to contribute ------------------ -Nanpy needs a lot of work to be a great tool. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at +--- -Donate ------- -Do you want to support us with a coffee? We need it to code all night long! if you like this project and you want to support it with some cents, please donate :) https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J +## License -License -------- -This software is released under MIT License. Copyright (c) 2012-2013 Andrea Stagi +This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi \ No newline at end of file From 42f415ebf0053dd91e8ed2420f31a73f80d08144 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 18 Oct 2014 14:10:41 +0200 Subject: [PATCH 222/344] First import for docs --- .gitignore | 3 ++ docs/css/extra.css | 21 +++++++++++ docs/img/nanpy_logo_min.png | Bin 0 -> 427 bytes docs/index.md | 72 ++++++++++++++++++++++++++++++++++++ mkdocs.yml | 3 ++ 5 files changed, 99 insertions(+) create mode 100644 docs/css/extra.css create mode 100644 docs/img/nanpy_logo_min.png create mode 100644 docs/index.md create mode 100644 mkdocs.yml diff --git a/.gitignore b/.gitignore index 4ff8229..16f62a8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ venv #hidden files .* !.gitignore + +#Docs +site/ diff --git a/docs/css/extra.css b/docs/css/extra.css new file mode 100644 index 0000000..968e58d --- /dev/null +++ b/docs/css/extra.css @@ -0,0 +1,21 @@ +div.col-md-9 h1:first-of-type { + text-align: center; + font-size: 60px; + font-weight: 300; +} +div.col-md-9 p:first-of-type { + text-align: center; +} +.navbar { + background-image: none; + background-color: #31a8ae; +} +.navbar-brand:before { + content: ''; + display: inline-block; + width: 18px; + height: 18px; + margin-right: 5px; + vertical-align: middle; + background: url(../img/nanpy_logo_min.png) center center no-repeat; +} \ No newline at end of file diff --git a/docs/img/nanpy_logo_min.png b/docs/img/nanpy_logo_min.png new file mode 100644 index 0000000000000000000000000000000000000000..8c5f76e4da07af98d7c458fd04e447d1a2fe3d6b GIT binary patch literal 427 zcmV;c0aX5pP)72sTutX1nDxvTdTu>kdiohwLrlki?5hy~=zzLj|GfxC(;c#bG>-7bVe=BnhtT4h0~~NOXg>my9mY3*Uth zIkR&ZU7XdnRrS|$W|k_lpz$9h)`9#JQPk`5Ih`__OlFG`sQG#mYN8XHnKcs*u%#>8 z0QSCl>`=#IUmcT`GUiqpk-kQ>c-v-n?EC(S-b$LL^9^9MT1{| Nanpy and click on "Upload". + +To install Nanpy Python library on your master device just type: + + pip install nanpy + +--- + +## How to contribute + +Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at + +Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, [please donate using Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J) + +--- + +## License + +This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..7eaab3c --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,3 @@ +site_name: Nanpy + +repo_url: https://github.com/nanpy/ \ No newline at end of file From 72c7224e0d1bfb081e894fdc6418048fa8c77cdc Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 16 Nov 2014 15:37:19 +0100 Subject: [PATCH 223/344] Adds How to extend Nanpy section to docs --- docs/index.md | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/docs/index.md b/docs/index.md index eebb078..9bb0448 100644 --- a/docs/index.md +++ b/docs/index.md @@ -67,6 +67,121 @@ Do you want to support us with a coffee? We need a lot of caffeine to code all n --- +## How to extend Nanpy + +First of all create some boilerplate code starting with Python. Suppose you want initially support two methods of the Centpiede library + + void portWrite(int port, int value); + int portRead(int port); + +You can create your centipede.py module and put it in nanpy/ + + from nanpy.arduinoboard import ArduinoObject + from nanpy.arduinoboard import (arduinoobjectmethod, returns) + + class Centipede(ArduinoObject): + + def __init__(self, your_parameters connection=None): + ArduinoObject.__init__(self, connection=connection) + self.id = self.call('new', your_parameters) + + @arduinoobjectmethod + def portWrite(self, port, value): + pass + + @returns(int) + @arduinoobjectmethod + def portRead(self, port): + pass + +After that you can include this module in the __init__.py to make it available in Nanpy (nanpy/__init__.py https://github.com/nanpy/nanpy/blob/master/nanpy/__init__.py) + + from nanpy.centipede import Centipede + +You're done with Python :) Let's see how to add the firmware part (https://github.com/nanpy/nanpy-firmware) + +First of all modify sample.cfg adding + + #define USE_Centipede 1 + +or do it directly on your cfg.h file :) + +You need to create CentipedeClass.h and CentipedeClass.cpp + +In CentipedeClass.h you need + + #ifndef CENTIPEDE_CLASS + #define CENTIPEDE_CLASS + + #include "BaseClass.h" + #include "MethodDescriptor.h" + + class Centipede; + + namespace nanpy { + class CentipedeClass: public ObjectsManager { + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + }; + } + + #endif + +And in Centipede.cpp + + #include "cfg.h" + + #if USE_Centipede + + #include + #include //!!!Your real Centipede Library!!!! + #include "CentipedeClass.h" + #include + + const char* nanpy::CentipedeClass::get_firmware_id() + { + return "Centipede"; + } + + void nanpy::CentipedeClass::elaborate( MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + Centipede* cent; + cent = new Centipede (m->getInt(0), m->getInt(1), m->getInt(2)); + cent->begin(); + v.insert(cent); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "portWrite") == 0) { + m->returns(v[m->getObjectId()]->portWrite(m->getInt(0), m->getInt(1))); + } + + if (strcmp(m->getName(), "portRead") == 0) { + m->returns(v[m->getObjectId()]->portRead(m->getInt(0))); + } + }; + + #endif + +Finally you need to register your class in the main loop! Open Nanpy.ino file and add + + //... + + #if USE_Centipede + #include + #endif + + #include "CentipedeClass.h" + + //... + + REGISTER_CLASS_CONDITIONAL(CentipedeClass, USE_Centipede); + +--- + ## License This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi From 32beeb2300deb5c1220fe88b76cb3653188eebe2 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Tue, 23 Dec 2014 08:40:49 +0100 Subject: [PATCH 224/344] Restore serial timeout --- nanpy/serialmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 0550612..49c48a3 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -52,7 +52,7 @@ class SerialManager(object): def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE, sleep_after_connect=2, - timeout=None): + timeout=20): self.device = device self.baudrate = baudrate self.sleep_after_connect = sleep_after_connect From 458d7bf190629e02d14c20c679d687f9befbf2ba Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 22 Jan 2015 16:07:15 +0100 Subject: [PATCH 225/344] adding classifiers --- setup.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/setup.py b/setup.py index be231ac..f9278d2 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,22 @@ from setuptools import setup, find_packages +classifiers = [ +# Get more strings from +# http://pypi.python.org/pypi?%3Aaction=list_classifiers +"License :: OSI Approved :: MIT License", +"Natural Language :: English", +"Operating System :: OS Independent", +"Programming Language :: Python", +"Programming Language :: Python :: 2", +"Programming Language :: Python :: 2.6", +"Programming Language :: Python :: 2.7", +"Programming Language :: Python :: 3", +"Programming Language :: Python :: 3.1", +"Programming Language :: Python :: 3.2", +"Programming Language :: Python :: 3.3", +] + setup(name="nanpy", version="0.9.2", description="Use your Arduino board with Python", @@ -14,4 +30,5 @@ install_requires=[ "pyserial", ], + classifiers=classifiers, zip_safe = True) From 244f721a87d0296b8367d0b7edbb2bcfe33ded4e Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 22 Jan 2015 16:07:35 +0100 Subject: [PATCH 226/344] more badges --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 168939d..094333a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Nanpy -[![PyPI version](https://badge.fury.io/py/nanpy.svg)](http://badge.fury.io/py/nanpy) +[![Latest Version](https://pypip.in/version/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) +[![Supported Python versions](https://pypip.in/py_versions/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) +[![License](https://pypip.in/license/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) +[![Downloads](https://pypip.in/download/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) --- From 38cca95f2c62adb4c1f2643350a0296bf5d75823 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 31 Jan 2015 12:21:26 +0100 Subject: [PATCH 227/344] Python side delay for Tone --- nanpy/tone.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nanpy/tone.py b/nanpy/tone.py index 2bc3a19..8d9f8fd 100644 --- a/nanpy/tone.py +++ b/nanpy/tone.py @@ -1,3 +1,4 @@ +from nanpy import Arduino from nanpy.arduinoboard import ArduinoObject from nanpy.arduinoboard import arduinoobjectmethod @@ -98,8 +99,10 @@ def __init__(self, pin, connection=None): self.id = self.call('new', pin) @arduinoobjectmethod - def play(self, note, duration): - pass + def play(self, note, duration=0): + if duration != 0: + Arduino.delay(duration) + self.stop() @arduinoobjectmethod def stop(self): From 0a474263f2526c3d883af04b8112bce904f29bb3 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 31 Jan 2015 12:23:21 +0100 Subject: [PATCH 228/344] Set timeout to 7 seconds --- nanpy/serialmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 49c48a3..f519641 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -52,7 +52,7 @@ class SerialManager(object): def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE, sleep_after_connect=2, - timeout=20): + timeout=7): self.device = device self.baudrate = baudrate self.sleep_after_connect = sleep_after_connect From f1b9d37d14407540a00dc50da5fdbc63e9a0c0a9 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 4 Feb 2015 15:30:12 +0100 Subject: [PATCH 229/344] move test files --- tests/{ => test_offline}/test.py | 0 tests/{ => test_offline}/test_fwinfo.py | 0 tests/{ => test_offline}/test_memo.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => test_offline}/test.py (100%) rename tests/{ => test_offline}/test_fwinfo.py (100%) rename tests/{ => test_offline}/test_memo.py (100%) diff --git a/tests/test.py b/tests/test_offline/test.py similarity index 100% rename from tests/test.py rename to tests/test_offline/test.py diff --git a/tests/test_fwinfo.py b/tests/test_offline/test_fwinfo.py similarity index 100% rename from tests/test_fwinfo.py rename to tests/test_offline/test_fwinfo.py diff --git a/tests/test_memo.py b/tests/test_offline/test_memo.py similarity index 100% rename from tests/test_memo.py rename to tests/test_offline/test_memo.py From 8fdc8a17dc71a97d9914eab3efdb26a90226f103 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 4 Feb 2015 15:30:47 +0100 Subject: [PATCH 230/344] fix tox --- tox.ini | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index c9f0669..7de6280 100644 --- a/tox.ini +++ b/tox.ini @@ -6,10 +6,11 @@ envlist = py26,py27,py31,py32,py33 deps= nose pyserial - easyprocess -setenv= - PYTHONPATH= -changedir=tests + +changedir=tests/test_offline + +# if you have an Arduino connected +#changedir=tests commands=nosetests -v From ccf0ed4f24e2ba414eaed89f391120a8dbab0dcb Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 4 Feb 2015 15:31:29 +0100 Subject: [PATCH 231/344] drop support for py31, add for py34 --- setup.py | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f9278d2..ac3da7e 100644 --- a/setup.py +++ b/setup.py @@ -13,9 +13,9 @@ "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", -"Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", +"Programming Language :: Python :: 3.4", ] setup(name="nanpy", diff --git a/tox.ini b/tox.ini index 7de6280..a67cb3d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -envlist = py26,py27,py31,py32,py33 +envlist = py26,py27,py32,py33,py34 [testenv] deps= From 8e88d8d8e2b86a28cd4906912c3786cfe59d828a Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 4 Feb 2015 15:34:13 +0100 Subject: [PATCH 232/344] add travis and coverall support ( #40 ) --- .coveragerc | 5 +++++ .gitignore | 3 +++ .travis.yml | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 .coveragerc create mode 100644 .travis.yml diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..4dbfced --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[report] +omit = + */python?.?/* + */site-packages/nose/* + diff --git a/.gitignore b/.gitignore index 16f62a8..0fe6650 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ venv #hidden files .* !.gitignore +!.gitattributes +!.travis* +!.coveragerc #Docs site/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..674b197 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + +install: + - pip install . + - pip install coveralls coverage + - pip install pyserial + +script: + - cd tests/test_offline && nosetests -v --with-coverage --cover-package=nanpy . + +after_success: + - coveralls From 5e0ee70eb683665241a65e600491a0898eb76bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Thu, 5 Feb 2015 00:51:03 +0100 Subject: [PATCH 233/344] Add travis and coveralls badges --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 094333a..2dbd9e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Nanpy [![Latest Version](https://pypip.in/version/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) +[![Travis](http://img.shields.io/travis/nanpy/nanpy.svg)] (https://travis-ci.org/nanpy/nanpy) +[![Coveralls](http://img.shields.io/coveralls/nanpy/nanpy/master.svg)] (https://coveralls.io/r/nanpy/nanpy) [![Supported Python versions](https://pypip.in/py_versions/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![License](https://pypip.in/license/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![Downloads](https://pypip.in/download/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) @@ -72,4 +74,4 @@ Do you want to support us with a coffee? We need a lot of caffeine to code all n ## License -This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi \ No newline at end of file +This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi From c46079f937d7e07cc0a930cc7ae278036f50a47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Thu, 5 Feb 2015 01:01:10 +0100 Subject: [PATCH 234/344] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2dbd9e1..e1fbc42 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![License](https://pypip.in/license/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![Downloads](https://pypip.in/download/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) ---- +Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy ## Overview From 72d96b082c492b33476d321823f9ef2db6274e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Thu, 5 Feb 2015 01:07:07 +0100 Subject: [PATCH 235/344] Update README.md --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index e1fbc42..c21e639 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Nanpy -[![Latest Version](https://pypip.in/version/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![Travis](http://img.shields.io/travis/nanpy/nanpy.svg)] (https://travis-ci.org/nanpy/nanpy) [![Coveralls](http://img.shields.io/coveralls/nanpy/nanpy/master.svg)] (https://coveralls.io/r/nanpy/nanpy) +[![Latest Version](https://pypip.in/version/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![Supported Python versions](https://pypip.in/py_versions/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![License](https://pypip.in/license/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![Downloads](https://pypip.in/download/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) @@ -45,8 +45,6 @@ and use it with your objects You can specify how many SerialManager objects you want and control more than one Arduino board within the same script. ---- - ## How to build and install First of all, you need to build the firmware and upload it on your Arduino, to do that clone the [nanpy-firmware repository on Github](https://github.com/nanpy/firmware) or [download it from PyPi](https://pypi.python.org/pypi/nanpy). @@ -62,16 +60,12 @@ To install Nanpy Python library on your master device just type: pip install nanpy ---- - ## How to contribute Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, [please donate using Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J) ---- - ## License This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi From 05e89188211b814d0db3d26173c0834529f8d4bc Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 5 Feb 2015 09:35:23 +0100 Subject: [PATCH 236/344] fix coveralls (#40) --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 674b197..74a5854 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,11 @@ python: - "3.4" install: - - pip install . - pip install coveralls coverage - pip install pyserial script: - - cd tests/test_offline && nosetests -v --with-coverage --cover-package=nanpy . + - python setup.py nosetests -w tests/test_offline --with-coverage --cover-package=nanpy after_success: - coveralls From 63e0c99875fb6cac7eec68f021b9f81a10f22c14 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 12 Feb 2015 16:08:36 +0100 Subject: [PATCH 237/344] support more MCU in vcc.py --- nanpy/arduinotree.py | 2 +- nanpy/vcc.py | 33 ++++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index 46c83ef..4928ca4 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -94,7 +94,7 @@ def core(self): @memoized def vcc(self): """Access to VCC.""" - return Vcc(self.register) + return Vcc(self.register, MCU=self.define.get('MCU')) def soft_reset(self): """Resets the AVR, the registers will be reset to their known, default diff --git a/nanpy/vcc.py b/nanpy/vcc.py index 2f01a3f..1f969f5 100644 --- a/nanpy/vcc.py +++ b/nanpy/vcc.py @@ -1,13 +1,22 @@ import time +MUX0=1 << 0 +MUX1=1 << 1 +MUX2=1 << 2 +MUX3=1 << 3 +MUX4=1 << 4 +MUX5=1 << 5 +REFS0=1 << 6 +REFS1=1 << 7 class Vcc(object): - - def __init__(self, register): + bandgap_voltage = 1.1 # Volt + def __init__(self, register, MCU=None): self.register = register + self.MCU = MCU def read(self): - """VCC in Volt. This works on Arduinos with a 328 or 168 only. + """VCC in Volt. Bandgap voltage precision: +-10% Source: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter @@ -26,8 +35,18 @@ def read(self): """ reg = self.register.proxy - # 0b01001110 = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1) - reg.ADMUX = 0x4E + + + if self.MCU in ['__AVR_ATmega32U4__' , '__AVR_ATmega1280__' , '__AVR_ATmega2560__']: + cfg = REFS0 | MUX4 | MUX3 | MUX2 | MUX1 + elif self.MCU in ['__AVR_ATtiny24__' , '__AVR_ATtiny44__' , '__AVR_ATtiny84__']: + cfg = MUX5 | MUX0 + elif self.MCU in ['__AVR_ATtiny25__' , '__AVR_ATtiny45__' , '__AVR_ATtiny85__']: + cfg = MUX3 | MUX2 + else: + cfg = REFS0 | MUX3 | MUX2 | MUX1 + + reg.ADMUX = cfg # Wait for Vref to settle time.sleep(0.002) # Convert @@ -35,6 +54,6 @@ def read(self): while reg.ADCSRA & 0x40: # bit_is_set(ADCSRA, ADSC) time.sleep(0.001) result = reg.ADCL | (reg.ADCH << 8) - bandgap_voltage = 1.1 # Volt - result = (bandgap_voltage * 1023) / result + + result = (self.bandgap_voltage * 1024) / result return result From 39154aecae8e0f36065816bb6ed159a18c1ee2ef Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 16 Feb 2015 14:13:31 +0100 Subject: [PATCH 238/344] add landscape badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c21e639..5764707 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![Supported Python versions](https://pypip.in/py_versions/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![License](https://pypip.in/license/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) [![Downloads](https://pypip.in/download/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) +[![Code Health](https://landscape.io/github/nanpy/nanpy/master/landscape.svg?style=flat)](https://landscape.io/github/nanpy/nanpy/master) Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy From 232f6c096bccc693e3de9f71225d3e95e01ce3da Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 16 Feb 2015 14:26:03 +0100 Subject: [PATCH 239/344] fix warnings --- nanpy/arduinotree.py | 2 +- nanpy/classinfo.py | 2 +- nanpy/define.py | 2 +- nanpy/examples/checkspeed.py | 2 +- nanpy/examples/dump.py | 3 +-- nanpy/examples/mytemperaturelib.py | 1 - nanpy/memo.py | 7 +++---- nanpy/pwm.py | 3 +-- nanpy/serialmanager.py | 12 +++++++----- 9 files changed, 16 insertions(+), 18 deletions(-) diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index 4928ca4..e2f3413 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -10,7 +10,7 @@ from nanpy.memo import memoized from nanpy.ram import RAM from nanpy.register import RegisterFeature -from nanpy.serialmanager import SerialManager, serial_manager +from nanpy.serialmanager import serial_manager from nanpy.vcc import Vcc from nanpy.watchdog import Watchdog from nanpy.wire import Wire diff --git a/nanpy/classinfo.py b/nanpy/classinfo.py index 6d29810..e5f1033 100644 --- a/nanpy/classinfo.py +++ b/nanpy/classinfo.py @@ -61,7 +61,7 @@ def __init__(self, connection): self.firmware_id_list = sorted(ls) for cls in check4firmware.names.values(): - self.firmware_class_status[cls.__name__] = False + self.firmware_class_status[cls.__name__] = False for x in self.firmware_id_list: cls = check4firmware.names.get(x) diff --git a/nanpy/define.py b/nanpy/define.py index d7bdfe8..9ac3f11 100644 --- a/nanpy/define.py +++ b/nanpy/define.py @@ -82,4 +82,4 @@ def get(self, name): n = self._arr.name(i) if n == name: return self._arr.value(i) - raise ValueError('% was not found!' % name) + raise ValueError('%s was not found!' % name) diff --git a/nanpy/examples/checkspeed.py b/nanpy/examples/checkspeed.py index d06258b..539246b 100644 --- a/nanpy/examples/checkspeed.py +++ b/nanpy/examples/checkspeed.py @@ -6,7 +6,7 @@ def measure(a, n, f, root='a'): start = time.time() - for x in range(n): + for _ in range(n): cmd = root + '.' + f try: locals()[root] = a diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py index 84fced8..d014704 100644 --- a/nanpy/examples/dump.py +++ b/nanpy/examples/dump.py @@ -4,7 +4,6 @@ from nanpy.serialmanager import SerialManager from pprint import pprint import inspect -from nanpy.serialmanager import SerialManager FORMAT = '%-20s = %20s' @@ -17,7 +16,7 @@ def dump(obj, selected_names=None): for attr in ls: if not attr.startswith('__'): if not inspect.ismethod(getattr(obj, attr)): - print(FORMAT % (attr, getattr(obj, attr))) + print(FORMAT % (attr, getattr(obj, attr))) def dump_dict(d): diff --git a/nanpy/examples/mytemperaturelib.py b/nanpy/examples/mytemperaturelib.py index 5d55dea..c61ce68 100755 --- a/nanpy/examples/mytemperaturelib.py +++ b/nanpy/examples/mytemperaturelib.py @@ -5,7 +5,6 @@ # Dependencies: None from nanpy import (Arduino, OneWire) -import time class FakeDallasTemperature(): diff --git a/nanpy/memo.py b/nanpy/memo.py index d9c9c65..86087e1 100644 --- a/nanpy/memo.py +++ b/nanpy/memo.py @@ -1,14 +1,13 @@ import functools -''' -http://wiki.python.org/moin/PythonDecoratorLibrary -''' - class memoized(object): """Decorator that caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated. + + http://wiki.python.org/moin/PythonDecoratorLibrary + """ def __init__(self, func): self.func = func diff --git a/nanpy/pwm.py b/nanpy/pwm.py index 685e9f1..c949a89 100644 --- a/nanpy/pwm.py +++ b/nanpy/pwm.py @@ -8,8 +8,7 @@ class PwmError(Exception): pass -class BiDict(): - +class BiDict(object): def __init__(self, dic): self.norm = dic self.inv = dict([(v, k) for k, v in dic.items()]) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index f519641..945d4fc 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -1,4 +1,3 @@ -from nanpy.memo import memoized import fnmatch import logging import serial @@ -16,12 +15,15 @@ class SerialManagerError(Exception): pass -def _auto_detect_serial_unix(preferred_list=['*']): +def _auto_detect_serial_unix(preferred_list=None): import glob glist = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') glist += ['/dev/ttyS0', '/dev/ttyS1'] ret = [] + if preferred_list is None: + preferred_list = ['*'] + for d in glist: for preferred in preferred_list: if fnmatch.fnmatch(d, preferred): @@ -68,7 +70,7 @@ def open(self, device=None): if not len(ports): raise SerialManagerError("No port was set, and no port was found!") self.device = ports[0] - log.debug('opening port:%s [%s baud]' % (self.device, self.baudrate)) + log.debug('opening port:%s [%s baud]', self.device, self.baudrate) assert self.device self._serial = serial.Serial(self.device, self.baudrate, @@ -80,7 +82,7 @@ def open(self, device=None): def write(self, value): if not self._serial: self.open() - log.debug('sending:%s' % repr(value)) + log.debug('sending:%s', repr(value)) if PY3: self._serial.write(bytes(value, 'latin-1')) else: @@ -90,7 +92,7 @@ def readline(self): if not self._serial: self.open() s = self._serial.readline() - log.debug('received:%s' % repr(s)) + log.debug('received:%s', repr(s)) s = s.decode() if not len(s): raise SerialManagerError('Serial timeout!') From 2cb0e6dba03e66f3cafd1212d20f4d4cce9f4edc Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 14 Feb 2015 13:42:19 +0100 Subject: [PATCH 240/344] Remove mytemperaturelib sample --- nanpy/examples/mytemperaturelib.py | 86 ------------------------------ 1 file changed, 86 deletions(-) delete mode 100755 nanpy/examples/mytemperaturelib.py diff --git a/nanpy/examples/mytemperaturelib.py b/nanpy/examples/mytemperaturelib.py deleted file mode 100755 index c61ce68..0000000 --- a/nanpy/examples/mytemperaturelib.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: a fake DallasTemperature library written in Python -# Dependencies: None - -from nanpy import (Arduino, OneWire) - -class FakeDallasTemperature(): - - def __init__(self, pin): - self.__ds = OneWire(pin) - self.__data = 0 - - def __fetchAddress(self): - ds_address = self.__ds.search() - - if ds_address == "1": - return False - - self.__ds.reset() - self.__ds.select(ds_address) - self.__ds.write(0x44, 1) - Arduino.delay(700) - present = self.__ds.reset() - self.__ds.select(ds_address) - self.__ds.write(0xBE) - return True - - def __fetchData(self): - - data = [] - - for i in range(9): - val = self.__ds.read() - data.append(val) - - raw = (data[1] << 8) | data[0] - - type = 1 - - if type == 0: - - raw = raw << 3; - if data[7] == 0x10: - raw = (raw & 0xFFF0) + 12 - data[6] - - else: - cfg = (data[4] & 0x60) - - if cfg == 0x00: - raw = raw << 3 - elif cfg == 0x20: - raw = raw << 2 - elif cfg == 0x40: - raw = raw << 1 - else: - pass - - self.__data = raw - - def getCelsius(self): - if self.__fetchAddress(): - self.__fetchData() - return self.__data / 16.0 - - def getFahrenheit(self): - if self.__fetchAddress(): - self.__fetchData() - return self.getCelsius() * 1.8 + 32.0 - - -from nanpy import Lcd - -if __name__ == "__main__": - - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) - lcd.printString("Loc. London") - - temp_int = FakeDallasTemperature(6) - temp_ext = FakeDallasTemperature(5) - - while(1): - lcd.setCursor(0, 1) - lcd.printString("Ex.%0.0f\xDFC In.%0.0f\xDFC" % (temp_int.getCelsius(), temp_ext.getCelsius())) - From a4addf4fd28409650338044c0ad73d601a3b3ba1 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 14 Feb 2015 13:42:27 +0100 Subject: [PATCH 241/344] Add servo sample --- nanpy/examples/servo.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 nanpy/examples/servo.py diff --git a/nanpy/examples/servo.py b/nanpy/examples/servo.py new file mode 100644 index 0000000..54c9f3e --- /dev/null +++ b/nanpy/examples/servo.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: move a servo motor +# Dependencies: None + +from nanpy import Servo +import time + +servo = Servo(7) +for move in [0, 90, 180, 90, 0]: + servo.write(move) + time.sleep(1) From 7a379d8d3119f19f9ccc41b9b9f3091f8e7b16c9 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 14 Feb 2015 13:47:38 +0100 Subject: [PATCH 242/344] Functions toCelsius and toFahrenheit are now class methods --- nanpy/dallastemperature.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index d60fe44..cd6b625 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -45,14 +45,10 @@ def getTempF(self, address): pass @classmethod - @returns(float) - @arduinoclassmethod def toCelsius(cls, value): - pass + return (value - 32) * 5/9 @classmethod - @returns(float) - @arduinoclassmethod def toFahrenheit(cls, value): - pass + return (value * 9/5) + 32 From 10946da4ee69f17c08ca28abbaa7f7f417dd743c Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 14 Feb 2015 18:07:38 +0100 Subject: [PATCH 243/344] New DallasTemperature example --- nanpy/examples/dallastemperature.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/nanpy/examples/dallastemperature.py b/nanpy/examples/dallastemperature.py index ec187d9..eeac564 100755 --- a/nanpy/examples/dallastemperature.py +++ b/nanpy/examples/dallastemperature.py @@ -7,13 +7,20 @@ from nanpy import DallasTemperature sensors = DallasTemperature(5) +n_sensors = sensors.getDeviceCount() -print("There are %d devices connected on pin %d" % (sensors.getDeviceCount(), sensors.pin)) -addr = sensors.getAddress(0) -sensors.setResolution(9) -while True: - sensors.requestTemperatures(0) - temp = sensors.getTempC(addr) - print("The temperature, in Celsius degrees is %0.2f" % temp) - print("Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp)) +print("There are %d devices connected on pin %d" % (n_sensors, sensors.pin)) +addresses = [] + +for i in range(n_sensors): + addresses.append(sensors.getAddress(i)) +sensors.setResolution(12) + +while True: + sensors.requestTemperatures() + for i in range(n_sensors): + temp = sensors.getTempC(i) + print("Device %d (%s) temperature, in Celsius degrees is %0.2f" % (i, addresses[i], temp)) + print("Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp)) + print("\n") From 65f15ff5eebefe0bfd82ca38593f6ca3929bae40 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 15 Feb 2015 11:44:41 +0100 Subject: [PATCH 244/344] Fix print call in nanpy/examples --- nanpy/examples/i2c_scanner.py | 4 ++-- nanpy/examples/i2c_send.py | 2 +- nanpy/examples/pressure.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nanpy/examples/i2c_scanner.py b/nanpy/examples/i2c_scanner.py index 9a54afd..3d2f236 100755 --- a/nanpy/examples/i2c_scanner.py +++ b/nanpy/examples/i2c_scanner.py @@ -12,10 +12,10 @@ def main(): connection = SerialManager(sleep_after_connect=2) connection.open() - print connection.device + print (connection.device) a = ArduinoTree(connection=connection) master = I2C_Master(a.wire) - print ['0x%02x' % x for x in master.scan()] + print (['0x%02x' % x for x in master.scan()]) if __name__ == '__main__': diff --git a/nanpy/examples/i2c_send.py b/nanpy/examples/i2c_send.py index 5180d22..296c7e6 100755 --- a/nanpy/examples/i2c_send.py +++ b/nanpy/examples/i2c_send.py @@ -12,7 +12,7 @@ def main(): connection = SerialManager(sleep_after_connect=2) connection.open() - print connection.device + print (connection.device) a = ArduinoTree(connection=connection) master = I2C_Master(a.wire) master.send(0x27, [0b00001000]) diff --git a/nanpy/examples/pressure.py b/nanpy/examples/pressure.py index 413dc04..d710b20 100755 --- a/nanpy/examples/pressure.py +++ b/nanpy/examples/pressure.py @@ -17,8 +17,8 @@ def main(): a = ArduinoTree(connection=connection) bmp = Bmp180(a.wire) p, t = bmp.read() - print 'pressure: %s kPa' % (p / 1000) - print 'temperature: %s C' % t + print ('pressure: %s kPa' % (p / 1000)) + print ('temperature: %s C' % t) if __name__ == '__main__': main() From 6760a52dc33b8d0f47240a047e604caf64a16f21 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 16 Feb 2015 08:39:44 +0100 Subject: [PATCH 245/344] Update year --- LICENSE | 2 +- README.md | 2 +- docs/index.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 40bed8b..254d448 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012-2013 Andrea Stagi +Copyright (c) 2012-2015 Andrea Stagi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5764707..7bfaa61 100644 --- a/README.md +++ b/README.md @@ -69,4 +69,4 @@ Do you want to support us with a coffee? We need a lot of caffeine to code all n ## License -This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi +This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi diff --git a/docs/index.md b/docs/index.md index 9bb0448..1af322f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -184,4 +184,4 @@ Finally you need to register your class in the main loop! Open Nanpy.ino file an ## License -This software is released under MIT License. Copyright (c) 2012-2014 Andrea Stagi +This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi From 30d7dc583fcf1e0a70e1a1c82db792241805d533 Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 16 Feb 2015 16:25:19 +0100 Subject: [PATCH 246/344] /dev/ttyACM* has highest prio --- nanpy/serialmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 945d4fc..6de3c95 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -17,7 +17,7 @@ class SerialManagerError(Exception): def _auto_detect_serial_unix(preferred_list=None): import glob - glist = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glist = glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') glist += ['/dev/ttyS0', '/dev/ttyS1'] ret = [] From c5a9327b130d1223769d09ba157b8933eb302e1c Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Feb 2015 16:03:04 +0100 Subject: [PATCH 247/344] avoid mutex deadlock --- nanpy/arduinoboard.py | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 7e1f9d2..7d6ac69 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -24,27 +24,29 @@ def _call(namespace, id, args, connection): nel = 0 mutex.acquire() - _write(namespace, connection) - _write(id, connection) - - for arg in args: - if type(arg) == type(list()): - for el in arg: - if el != None: - toprint.append(el) + try: + _write(namespace, connection) + _write(id, connection) + + for arg in args: + if type(arg) == type(list()): + for el in arg: + if el != None: + toprint.append(el) + nel += 1 + else: + if arg != None: + toprint.append(arg) nel += 1 - else: - if arg != None: - toprint.append(arg) - nel += 1 - - _write(nel - 1, connection) - - for elprint in toprint: - _write(elprint, connection) - - ret = return_value(connection) - mutex.release() + + _write(nel - 1, connection) + + for elprint in toprint: + _write(elprint, connection) + + ret = return_value(connection) + finally: + mutex.release() return ret @@ -147,8 +149,8 @@ def __init__(self, connection=None): def call(self, *args): return _call(self.namespace, self.id, args, self.connection) - def __del__(self): - return _call(self.namespace, self.id, ["remove"], self.connection) +# def __del__(self): +# return _call(self.namespace, self.id, ["remove"], self.connection) class FirmwareClass(object): From e02c9a87e9d059fafc4f0195d6a39bfd5f8e760a Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Feb 2015 16:03:27 +0100 Subject: [PATCH 248/344] mock connection --- nanpy/mock/__init__.py | 0 nanpy/mock/mockconnection.py | 77 +++++++++++++++++++ nanpy/mock/mockeeprom.py | 17 ++++ nanpy/mock/mockinfo.py | 18 +++++ nanpy/mock/mockobject.py | 12 +++ nanpy/mock/mockram.py | 20 +++++ nanpy/mock/mockservo.py | 33 ++++++++ nanpy/mock/mockstepper.py | 29 +++++++ .../test_mockconnection/test_eeprom.py | 16 ++++ .../test_mockconnection/test_ram.py | 18 +++++ .../test_mockconnection/test_servo.py | 32 ++++++++ .../test_mockconnection/test_stepper.py | 12 +++ 12 files changed, 284 insertions(+) create mode 100644 nanpy/mock/__init__.py create mode 100644 nanpy/mock/mockconnection.py create mode 100644 nanpy/mock/mockeeprom.py create mode 100644 nanpy/mock/mockinfo.py create mode 100644 nanpy/mock/mockobject.py create mode 100644 nanpy/mock/mockram.py create mode 100644 nanpy/mock/mockservo.py create mode 100644 nanpy/mock/mockstepper.py create mode 100644 tests/test_offline/test_mockconnection/test_eeprom.py create mode 100644 tests/test_offline/test_mockconnection/test_ram.py create mode 100644 tests/test_offline/test_mockconnection/test_servo.py create mode 100644 tests/test_offline/test_mockconnection/test_stepper.py diff --git a/nanpy/mock/__init__.py b/nanpy/mock/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nanpy/mock/mockconnection.py b/nanpy/mock/mockconnection.py new file mode 100644 index 0000000..a0af841 --- /dev/null +++ b/nanpy/mock/mockconnection.py @@ -0,0 +1,77 @@ +import logging + +from nanpy.mock.mockeeprom import MockEEPROM +from nanpy.mock.mockinfo import MockInfo +from nanpy.mock.mockram import MockRAM +from nanpy.mock.mockservo import MockServo +from nanpy.mock.mockstepper import MockStepper + + +log = logging.getLogger(__name__) + + +ALL_CLASSES = [ + MockInfo, + MockRAM, + MockEEPROM, + MockServo, + MockStepper, + ] + + +class MockConnection(object): + state = 0 + obj_id = 0 + param_count = 0 + + def __init__(self): + self.objects = dict([(c.firmware_id, c()) for c in ALL_CLASSES]) + self.objects['Info'].class_names = [x.firmware_id for x in ALL_CLASSES] + + def elaborate(self,): + for n, x in self.objects.items(): + if n == self.class_name: + self.return_value = x.elaborate(self.obj_id, self.func_name, self.params) + return + assert 0 + + def write(self, value): + log.debug('sending:%s', repr(value)) + assert value.endswith('\x00') + + value = value[0:-1] + + assert value == value.strip() + + if self.state == 0: + self.class_name = value + self.state += 1 + elif self.state == 1: + self.obj_id = int(value) + self.state += 1 + elif self.state == 2: + self.param_count = int(value) + self.state += 1 + elif self.state == 3: + self.func_name = value + self.params = [] + self.state += 1 + if self.param_count == 0: + self.elaborate() + self.state = 0 + elif self.state == 4: + self.params.append(value) + self.param_count -= 1 + if self.param_count == 0: + self.elaborate() + self.state = 0 + + assert self.state<=4 + assert self.param_count<=10 + assert self.param_count>=0 + + def readline(self): + s = '%s\r\n' % self.return_value + log.debug('received:%s', repr(s)) + return s + diff --git a/nanpy/mock/mockeeprom.py b/nanpy/mock/mockeeprom.py new file mode 100644 index 0000000..6aaab30 --- /dev/null +++ b/nanpy/mock/mockeeprom.py @@ -0,0 +1,17 @@ +import logging + +log = logging.getLogger(__name__) + +class MockEEPROM(object): + firmware_id = "EEPROM" + + def __init__(self): + self.memory = [0, 1, 2, 3, 4, 5, 255, 255] + + def elaborate(self, obj_id, name, params): + if name == "size": + return len(self.memory) + elif name == "read": + return self.memory[int(params[0])] + elif name == "write": + self.memory[int(params[0])] = int(params[1]) diff --git a/nanpy/mock/mockinfo.py b/nanpy/mock/mockinfo.py new file mode 100644 index 0000000..8f3a9f4 --- /dev/null +++ b/nanpy/mock/mockinfo.py @@ -0,0 +1,18 @@ +import logging + +log = logging.getLogger(__name__) + + +class MockInfo(object): + firmware_id = "Info" + + def __init__(self, class_names=None): + self.class_names = class_names + + + def elaborate(self, obj_id, name, params): + if name == "count": + return len(self.class_names) + elif name == "name": + return self.class_names[int(params[0])] + diff --git a/nanpy/mock/mockobject.py b/nanpy/mock/mockobject.py new file mode 100644 index 0000000..f8c825c --- /dev/null +++ b/nanpy/mock/mockobject.py @@ -0,0 +1,12 @@ +class MockObject(object): + def __init__(self): + self.objects = [] + + def elaborate(self, obj_id, name, params): + if name == "new": + x = self.factory(params) + self.objects.append(x) + return len(self.objects) - 1 + if name == "remove": + del self.objects[int(params[0])] + return 0 diff --git a/nanpy/mock/mockram.py b/nanpy/mock/mockram.py new file mode 100644 index 0000000..7a24fa3 --- /dev/null +++ b/nanpy/mock/mockram.py @@ -0,0 +1,20 @@ +import logging + +log = logging.getLogger(__name__) + +class MockRAM(object): + firmware_id = "RAM" + + def __init__(self): + self.memory = [0, 1, 2, 3, 4, 5, 255, 255] + self.free = 3 + + def elaborate(self, obj_id, name, params): + if name == "size": + return len(self.memory) + elif name == "read": + return self.memory[int(params[0])] + elif name == "write": + self.memory[int(params[0])] = int(params[1]) + elif name == "free": + return self.free diff --git a/nanpy/mock/mockservo.py b/nanpy/mock/mockservo.py new file mode 100644 index 0000000..39868b8 --- /dev/null +++ b/nanpy/mock/mockservo.py @@ -0,0 +1,33 @@ +import logging + +from nanpy.mock.mockobject import MockObject + + +log = logging.getLogger(__name__) + +class MockServo(MockObject): + firmware_id = "Servo" + + def factory(self, params): + d = dict( + pin=int(params[0]), + angle=0, + ) + return d + + def elaborate(self, obj_id, name, params): + if name == "read": + return self.objects[obj_id]['angle'] + elif name == "write": + self.objects[obj_id]['angle'] = int(params[0]) + return 0 + elif name == "writeMicroseconds": + raise NotImplementedError + elif name == "readMicroseconds": + raise NotImplementedError + elif name == "detach": + self.objects[obj_id]['pin'] = None + return 0 + elif name == "attached": + return self.objects[obj_id]['pin'] is not None + return MockObject.elaborate(self, obj_id, name, params) diff --git a/nanpy/mock/mockstepper.py b/nanpy/mock/mockstepper.py new file mode 100644 index 0000000..1c06d53 --- /dev/null +++ b/nanpy/mock/mockstepper.py @@ -0,0 +1,29 @@ +import logging + +from nanpy.mock.mockobject import MockObject + + +log = logging.getLogger(__name__) + + +class MockStepper(MockObject): + firmware_id = "Stepper" + + def factory(self, params): + d = dict( + revsteps=int(params[0]), + pin1=int(params[1]), + pin2=int(params[2]), + speed=0, + ) + return d + + def elaborate(self, obj_id, name, params): + if name == "setSpeed": + self.objects[obj_id]['speed'] = int(params[0]) + return 0 + elif name == "step": + assert self.objects[obj_id] + return 0 + return MockObject.elaborate(self, obj_id, name, params) + diff --git a/tests/test_offline/test_mockconnection/test_eeprom.py b/tests/test_offline/test_mockconnection/test_eeprom.py new file mode 100644 index 0000000..fb8b981 --- /dev/null +++ b/tests/test_offline/test_mockconnection/test_eeprom.py @@ -0,0 +1,16 @@ +from nose.tools import eq_, ok_ + +from nanpy.mock.mockconnection import MockConnection +from nanpy.eepromobj import EepromLib + + +def test(): + mock = MockConnection() + x = EepromLib(connection=mock) + + mock.objects['EEPROM'].memory = [1, 2, 3] + eq_(x.size, 3) + eq_(x.read(0), 1) + eq_(x.read(1), 2) + eq_(x.read(2), 3) + diff --git a/tests/test_offline/test_mockconnection/test_ram.py b/tests/test_offline/test_mockconnection/test_ram.py new file mode 100644 index 0000000..e1ee0fa --- /dev/null +++ b/tests/test_offline/test_mockconnection/test_ram.py @@ -0,0 +1,18 @@ +from nanpy.ram import RAM +from nose.tools import eq_, ok_ + +from nanpy.mock.mockconnection import MockConnection + + +def test(): + mock = MockConnection() + x = RAM(connection=mock) + + mock.objects['RAM'].memory = [1, 2, 3] + mock.objects['RAM'].free = 2 + eq_(x.size, 3) + eq_(x.free(), 2) + eq_(x.read(0), 1) + eq_(x.read(1), 2) + eq_(x.read(2), 3) + diff --git a/tests/test_offline/test_mockconnection/test_servo.py b/tests/test_offline/test_mockconnection/test_servo.py new file mode 100644 index 0000000..fa096db --- /dev/null +++ b/tests/test_offline/test_mockconnection/test_servo.py @@ -0,0 +1,32 @@ +from nanpy.servo import Servo +from nose.tools import eq_, ok_ + +from nanpy.mock.mockconnection import MockConnection + + +def test(): + mock = MockConnection() + x = Servo(pin=3, connection=mock) + + ok_(x.attached()) + x.write(42) + eq_(x.read(), 42) + + +def test_more(): + mock = MockConnection() + + def objs(): + return mock.objects['Servo'].objects + + eq_(len(objs()), 0) + + x1 = Servo(pin=5, connection=mock) + + eq_(len(objs()), 1) + + x2 = Servo(pin=6, connection=mock) + + eq_(len(objs()), 2) + + \ No newline at end of file diff --git a/tests/test_offline/test_mockconnection/test_stepper.py b/tests/test_offline/test_mockconnection/test_stepper.py new file mode 100644 index 0000000..c816cc2 --- /dev/null +++ b/tests/test_offline/test_mockconnection/test_stepper.py @@ -0,0 +1,12 @@ +from nanpy.stepper import Stepper +from nose.tools import eq_, ok_ + +from nanpy.mock.mockconnection import MockConnection + + +def test(): + mock = MockConnection() + x = Stepper(revsteps=100, pin1=3, pin2=4, connection=mock) + x.step(3) + x.setSpeed(3) + From ae48536d52e97c6992eae8a9fec255752785599f Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 17 Feb 2015 17:56:03 +0100 Subject: [PATCH 249/344] remove classmethod based classes (arduino.py and eeprom.py) #47 --- nanpy/__init__.py | 2 -- nanpy/arduino.py | 51 ----------------------------------- nanpy/arduinoboard.py | 48 ++++++++++++++++----------------- nanpy/dallastemperature.py | 2 +- nanpy/eeprom.py | 22 --------------- nanpy/tone.py | 5 ++-- tests/test_serial/test_old.py | 17 ------------ 7 files changed, 28 insertions(+), 119 deletions(-) delete mode 100644 nanpy/arduino.py delete mode 100644 nanpy/eeprom.py delete mode 100644 tests/test_serial/test_old.py diff --git a/nanpy/__init__.py b/nanpy/__init__.py index ac7d4a0..9b426ff 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -13,8 +13,6 @@ from nanpy.serialmanager import SerialManager from nanpy.serialmanager import serial_manager -from nanpy.arduino import Arduino -from nanpy.eeprom import EEPROM from nanpy.lcd import Lcd from nanpy.onewire import OneWire from nanpy.stepper import Stepper diff --git a/nanpy/arduino.py b/nanpy/arduino.py deleted file mode 100644 index 41e89f6..0000000 --- a/nanpy/arduino.py +++ /dev/null @@ -1,51 +0,0 @@ -from nanpy.arduinoboard import arduinoclassmethod, returns, FirmwareClass -import time - - -class Arduino(FirmwareClass): - firmware_id = 'A' - - LOW, HIGH = 0, 1 - INPUT, OUTPUT = 0, 1 - - @classmethod - @arduinoclassmethod('dw') - def digitalWrite(cls, pin, value): - pass - - @classmethod - @returns(int) - @arduinoclassmethod('r') - def digitalRead(cls, pin): - pass - - @classmethod - @arduinoclassmethod('aw') - def analogWrite(cls, pin, value): - pass - - @classmethod - @returns(int) - @arduinoclassmethod('a') - def analogRead(cls, pin): - pass - - @classmethod - @arduinoclassmethod('pm') - def pinMode(cls, pin, mode): - pass - - @classmethod - def delay(cls, value): - time.sleep(float(value)/1000) - - @classmethod - @returns(int) - @arduinoclassmethod('m') - def millis(cls): - pass - - @classmethod - def map(cls, x, in_min, in_max, out_min, out_max): - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min - diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 7d6ac69..14e85e7 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -88,30 +88,30 @@ def class_get_firmware_id(cls): return cls.__name__ -def arduinoclassmethod(param): - is_func = hasattr(param, '__call__') - if is_func: - funct = param - - def wrapper(cls, *args, **kwargs): - cls_name = class_get_firmware_id(cls) - call_pars = [funct.__name__] - call_pars.extend(args) - funct(cls, *args, **kwargs) - return _call(cls_name, 0, call_pars, connection=None) - return wrapper - else: - name = param - - def wrapper2(funct): - def wrapper(cls, *args, **kwargs): - cls_name = class_get_firmware_id(cls) - call_pars = [name] - call_pars.extend(args) - funct(cls, *args, **kwargs) - return _call(cls_name, 0, call_pars, connection=None) - return wrapper - return wrapper2 +# def arduinoclassmethod(param): +# is_func = hasattr(param, '__call__') +# if is_func: +# funct = param +# +# def wrapper(cls, *args, **kwargs): +# cls_name = class_get_firmware_id(cls) +# call_pars = [funct.__name__] +# call_pars.extend(args) +# funct(cls, *args, **kwargs) +# return _call(cls_name, 0, call_pars, connection=None) +# return wrapper +# else: +# name = param +# +# def wrapper2(funct): +# def wrapper(cls, *args, **kwargs): +# cls_name = class_get_firmware_id(cls) +# call_pars = [name] +# call_pars.extend(args) +# funct(cls, *args, **kwargs) +# return _call(cls_name, 0, call_pars, connection=None) +# return wrapper +# return wrapper2 def _wrapper3(name): diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index cd6b625..7ae04b6 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -1,5 +1,5 @@ from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, arduinoclassmethod, returns) +from nanpy.arduinoboard import (arduinoobjectmethod, returns) class DallasTemperature(ArduinoObject): diff --git a/nanpy/eeprom.py b/nanpy/eeprom.py deleted file mode 100644 index 1db53bd..0000000 --- a/nanpy/eeprom.py +++ /dev/null @@ -1,22 +0,0 @@ -from nanpy.arduinoboard import (arduinoclassmethod, returns) -from nanpy.memo import memoized - -class EEPROM(object): - - @classmethod - @arduinoclassmethod - def write(cls, address, value): - pass - - @classmethod - @returns(int) - @arduinoclassmethod - def read(cls, address): - pass - - @classmethod - @memoized - @returns(int) - @arduinoclassmethod - def size(cls): - pass diff --git a/nanpy/tone.py b/nanpy/tone.py index 8d9f8fd..76f2227 100644 --- a/nanpy/tone.py +++ b/nanpy/tone.py @@ -1,6 +1,7 @@ -from nanpy import Arduino from nanpy.arduinoboard import ArduinoObject from nanpy.arduinoboard import arduinoobjectmethod +import time + class Tone(ArduinoObject): @@ -101,7 +102,7 @@ def __init__(self, pin, connection=None): @arduinoobjectmethod def play(self, note, duration=0): if duration != 0: - Arduino.delay(duration) + time.sleep(duration/1000.0) self.stop() @arduinoobjectmethod diff --git a/tests/test_serial/test_old.py b/tests/test_serial/test_old.py deleted file mode 100644 index 076c596..0000000 --- a/tests/test_serial/test_old.py +++ /dev/null @@ -1,17 +0,0 @@ -from nanpy.arduino import Arduino -from nose.tools import eq_, ok_ -from tests.util import ok_an -import common - - -def setup(): - common.setup() - - -def test(): - ok_(Arduino.millis() > 1) - - ok_an(Arduino.analogRead(0)) - - Arduino.pinMode(13, 1) - Arduino.pinMode(13, 0) From 87e506a4b792a39b300927d02dbb3cbd59b01262 Mon Sep 17 00:00:00 2001 From: Pierrick BRUN Date: Wed, 18 Feb 2015 18:27:52 +0100 Subject: [PATCH 250/344] Add reStructuredText README --- README.rst | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..d79247b --- /dev/null +++ b/README.rst @@ -0,0 +1,110 @@ +Nanpy +===== + + +Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy + +Overview +-------- + +| Nanpy is a library that use your Arduino as a slave, controlled by a + master device where you run your scripts, such as a PC, a Raspberry Pi + etc. +| The main purpose of Nanpy is making programmers' life easier, + providing them a powerful library to create prototypes faster and make + Arduino programming a game for kids. + +:: + + a = ArduinoApi() + a.pinMode(13, a.OUTPUT) + a.digitalWrite(13, a.HIGH) + +| I know, there are a lot of projects able to do that, but hey, Nanpy + can do more! +| Nanpy is easily extensible and can theoretically use every library, + allowing you to create how many objects you want. +| We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many + more... +| Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 + and show your first "Hello world"! + +:: + + from nanpy import Lcd + + lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) + lcd.printString('Hello World!') + +really straightforward now, isn't it? :) + +Serial communication +~~~~~~~~~~~~~~~~~~~~ + +Nanpy autodetects the serial port for you, anyway you can manually +specify another serial port: + +:: + + from nanpy import SerialManager + connection = SerialManager(device='/dev/ttyACM1') + +and use it with your objects + +:: + + a = ArduinoApi(connection=connection) + a.pinMode(13, a.OUTPUT) + a.digitalWrite(13, a.HIGH) + +You can specify how many SerialManager objects you want and control more +than one Arduino board within the same script. + +How to build and install +------------------------ + +First of all, you need to build the firmware and upload it on your +Arduino, to do that clone the `nanpy-firmware repository on +Github `__ or `download it from +PyPi `__. + +:: + + git clone git@github.com:nanpy/nanpy-firmware.git + cd nanpy-firmware + ./configure.sh + +| You can now edit Nanpy/cfg.h generated file to configure your Nanpy + firmware, selecting the features you want to include and the baud + rate. +| To build and install Nanpy firmware, copy Nanpy directory under your + "sketchbook" directory, start your Arduino IDE, open Sketchbook -> + Nanpy and click on "Upload". + +To install Nanpy Python library on your master device just type: + +:: + + pip install nanpy + +How to contribute +----------------- + +Nanpy still needs a lot of work. You can contribute with patches +(bugfixing, improvements, adding support for a new library not included +in Nanpy yet, writing examples and so on), writing documentation, +reporting bugs, creating packages or simply spreading Nanpy through the +web if you like it :) If you have any doubt or problem, please contact +me at stagi.andrea@gmail.com + +Do you want to support us with a coffee? We need a lot of caffeine to +code all night long! if you like this project and you want to support +us, `please donate using +Paypal `__ + +License +------- + +This software is released under MIT License. Copyright (c) 2012-2015 +Andrea Stagi stagi.andrea@gmail.com + From 5f574cb67a99b5d53d01b69f3d027c69c94eb2c0 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Thu, 19 Feb 2015 20:07:17 +0100 Subject: [PATCH 251/344] EepromLib is now EEPROM --- nanpy/__init__.py | 2 +- nanpy/arduinotree.py | 4 ++-- nanpy/{eepromobj.py => eeprom.py} | 2 +- nanpy/examples/eepromread.py | 4 ++-- tests/test_offline/test_mockconnection/test_eeprom.py | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) rename nanpy/{eepromobj.py => eeprom.py} (93%) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 9b426ff..a00077e 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -22,4 +22,4 @@ from nanpy.capacitivesensor import CapacitiveSensor from nanpy.dht import DHT from nanpy.arduinoapi import ArduinoApi -from nanpy.eepromobj import EepromLib +from nanpy.eeprom import EEPROM diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index e2f3413..2f74ebc 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -5,7 +5,7 @@ from nanpy.classinfo import ClassInfo from nanpy.counter import Counter from nanpy.define import DefineFeature -from nanpy.eepromobj import EepromLib +from nanpy.eeprom import EEPROM from nanpy.fwinfo import firmware_info from nanpy.memo import memoized from nanpy.ram import RAM @@ -70,7 +70,7 @@ def watchdog(self): @memoized def eeprom(self): """Access to EEPROM.""" - return EepromLib(self.connection) + return EEPROM(self.connection) @property @memoized diff --git a/nanpy/eepromobj.py b/nanpy/eeprom.py similarity index 93% rename from nanpy/eepromobj.py rename to nanpy/eeprom.py index 1b72b9c..c239039 100644 --- a/nanpy/eepromobj.py +++ b/nanpy/eeprom.py @@ -4,7 +4,7 @@ @check4firmware -class EepromLib(FirmwareClass): +class EEPROM(FirmwareClass): firmware_id = 'EEPROM' @arduinomethod diff --git a/nanpy/examples/eepromread.py b/nanpy/examples/eepromread.py index 76404e4..85dc3a8 100755 --- a/nanpy/examples/eepromread.py +++ b/nanpy/examples/eepromread.py @@ -4,11 +4,11 @@ # Description: read from EEPROM # Dependencies: None -from nanpy import (EepromLib, SerialManager) +from nanpy import (EEPROM, SerialManager) import sys connection = SerialManager() -e = EepromLib(connection=connection) +e = EEPROM(connection=connection) def display(a_list): diff --git a/tests/test_offline/test_mockconnection/test_eeprom.py b/tests/test_offline/test_mockconnection/test_eeprom.py index fb8b981..f4f442a 100644 --- a/tests/test_offline/test_mockconnection/test_eeprom.py +++ b/tests/test_offline/test_mockconnection/test_eeprom.py @@ -1,16 +1,16 @@ from nose.tools import eq_, ok_ from nanpy.mock.mockconnection import MockConnection -from nanpy.eepromobj import EepromLib +from nanpy.eeprom import EEPROM def test(): mock = MockConnection() - x = EepromLib(connection=mock) - + x = EEPROM(connection=mock) + mock.objects['EEPROM'].memory = [1, 2, 3] eq_(x.size, 3) eq_(x.read(0), 1) eq_(x.read(1), 2) eq_(x.read(2), 3) - + From f6ed82355a1c6c765017710408740aec65d4818e Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 21 Feb 2015 14:33:12 +0100 Subject: [PATCH 252/344] Version 0.9.3 --- nanpy/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index a00077e..7a679ff 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -5,7 +5,7 @@ """ Nanpy library """ -__version__ = '1.0' +__version__ = '0.9.3' __author__ = 'Andrea Stagi' __license__ = 'MIT' diff --git a/setup.py b/setup.py index ac3da7e..700ecb0 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ ] setup(name="nanpy", - version="0.9.2", + version="0.9.3", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From b3020ec9741c24e302d34e4e9b712cac588bc96f Mon Sep 17 00:00:00 2001 From: Pi3R1k Date: Sun, 22 Feb 2015 16:37:15 +0100 Subject: [PATCH 253/344] Add Badges to README.rst --- README.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.rst b/README.rst index d79247b..47d6058 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,13 @@ Nanpy ===== +| [|Travis|\ ] (https://travis-ci.org/nanpy/nanpy) +| [|Coveralls|\ ] (https://coveralls.io/r/nanpy/nanpy) +| |Latest Version| +| |Supported Python versions| +| |License| +| |Downloads| +| |Code Health| Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy @@ -108,3 +115,15 @@ License This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi stagi.andrea@gmail.com +.. |Travis| image:: http://img.shields.io/travis/nanpy/nanpy.svg +.. |Coveralls| image:: http://img.shields.io/coveralls/nanpy/nanpy/master.svg +.. |Latest Version| image:: https://pypip.in/version/nanpy/badge.svg + :target: https://pypi.python.org/pypi/nanpy/ +.. |Supported Python versions| image:: https://pypip.in/py_versions/nanpy/badge.svg + :target: https://pypi.python.org/pypi/nanpy/ +.. |License| image:: https://pypip.in/license/nanpy/badge.svg + :target: https://pypi.python.org/pypi/nanpy/ +.. |Downloads| image:: https://pypip.in/download/nanpy/badge.svg + :target: https://pypi.python.org/pypi/nanpy/ +.. |Code Health| image:: https://landscape.io/github/nanpy/nanpy/master/landscape.svg?style=flat + :target: https://landscape.io/github/nanpy/nanpy/master From 078e8f144ea9696240dc419f26f19d29e39b6a9d Mon Sep 17 00:00:00 2001 From: Pi3R1k Date: Sun, 22 Feb 2015 16:55:09 +0100 Subject: [PATCH 254/344] Correct Badges View --- README.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 47d6058..60cc7a3 100644 --- a/README.rst +++ b/README.rst @@ -1,13 +1,7 @@ -Nanpy + Nanpy ===== -| [|Travis|\ ] (https://travis-ci.org/nanpy/nanpy) -| [|Coveralls|\ ] (https://coveralls.io/r/nanpy/nanpy) -| |Latest Version| -| |Supported Python versions| -| |License| -| |Downloads| -| |Code Health| +|Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy @@ -116,7 +110,9 @@ This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi stagi.andrea@gmail.com .. |Travis| image:: http://img.shields.io/travis/nanpy/nanpy.svg + :target: https://travis-ci.org/nanpy/nanpy/ .. |Coveralls| image:: http://img.shields.io/coveralls/nanpy/nanpy/master.svg + :target: https://coveralls.io/r/nanpy/nanpy/ .. |Latest Version| image:: https://pypip.in/version/nanpy/badge.svg :target: https://pypi.python.org/pypi/nanpy/ .. |Supported Python versions| image:: https://pypip.in/py_versions/nanpy/badge.svg From a0c57d3f5e2269b4384af3d6d54f6c7d59d84fc3 Mon Sep 17 00:00:00 2001 From: Pi3R1k Date: Sun, 22 Feb 2015 16:56:10 +0100 Subject: [PATCH 255/344] Correct Title --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 60cc7a3..307e8a8 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ - Nanpy +Nanpy: ===== |Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| From 59e147345b33169d68a4b6c3ed5a862dc988ffdb Mon Sep 17 00:00:00 2001 From: Pi3R1k Date: Sun, 22 Feb 2015 16:56:50 +0100 Subject: [PATCH 256/344] Correct Title --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 307e8a8..eb88d06 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Nanpy: +Nanpy ===== |Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| From 5bbd4c81ce24a380a41e8769fd57f0716f18d5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Tue, 24 Feb 2015 08:06:33 +0100 Subject: [PATCH 257/344] Goodbye README.md --- README.md | 72 ------------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 7bfaa61..0000000 --- a/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# Nanpy - -[![Travis](http://img.shields.io/travis/nanpy/nanpy.svg)] (https://travis-ci.org/nanpy/nanpy) -[![Coveralls](http://img.shields.io/coveralls/nanpy/nanpy/master.svg)] (https://coveralls.io/r/nanpy/nanpy) -[![Latest Version](https://pypip.in/version/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) -[![Supported Python versions](https://pypip.in/py_versions/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) -[![License](https://pypip.in/license/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) -[![Downloads](https://pypip.in/download/nanpy/badge.svg)](https://pypi.python.org/pypi/nanpy/) -[![Code Health](https://landscape.io/github/nanpy/nanpy/master/landscape.svg?style=flat)](https://landscape.io/github/nanpy/nanpy/master) - -Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy - -## Overview - -Nanpy is a library that use your Arduino as a slave, controlled by a master device where you run your scripts, such as a PC, a Raspberry Pi etc. -The main purpose of Nanpy is making programmers' life easier, providing them a powerful library to create prototypes faster and make Arduino programming a game for kids. - - a = ArduinoApi() - a.pinMode(13, a.OUTPUT) - a.digitalWrite(13, a.HIGH) - -I know, there are a lot of projects able to do that, but hey, Nanpy can do more! -Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. -We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many more... -Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and show your first "Hello world"! - - from nanpy import Lcd - - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) - lcd.printString('Hello World!') - -really straightforward now, isn't it? :) - -### Serial communication - -Nanpy autodetects the serial port for you, anyway you can manually specify another serial port: - - from nanpy import SerialManager - connection = SerialManager(device='/dev/ttyACM1') - -and use it with your objects - - a = ArduinoApi(connection=connection) - a.pinMode(13, a.OUTPUT) - a.digitalWrite(13, a.HIGH) - -You can specify how many SerialManager objects you want and control more than one Arduino board within the same script. - -## How to build and install - -First of all, you need to build the firmware and upload it on your Arduino, to do that clone the [nanpy-firmware repository on Github](https://github.com/nanpy/firmware) or [download it from PyPi](https://pypi.python.org/pypi/nanpy). - - git clone git@github.com:nanpy/nanpy-firmware.git - cd nanpy-firmware - ./configure.sh - -You can now edit Nanpy/cfg.h generated file to configure your Nanpy firmware, selecting the features you want to include and the baud rate. -To build and install Nanpy firmware, copy Nanpy directory under your "sketchbook" directory, start your Arduino IDE, open Sketchbook -> Nanpy and click on "Upload". - -To install Nanpy Python library on your master device just type: - - pip install nanpy - -## How to contribute - -Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at - -Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, [please donate using Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J) - -## License - -This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi From 715df3510ac6b48ca7c75e87e7de803086b91970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Thu, 26 Feb 2015 09:21:21 +0100 Subject: [PATCH 258/344] Add Pierrick Brun to CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index af42d70..6ab68d6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -14,3 +14,4 @@ Contributors - Richard Giles (https://github.com/wrik) - Graeme Pyle (https://github.com/graemian) - Justin Youngblood (darksotm@gmail.com) +- Pierrick Brun (https://github.com/Pi3R1k) From ac931c54c7fc9dcb88b853af39d1199a258619f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Sat, 28 Feb 2015 13:43:51 +0100 Subject: [PATCH 259/344] Use PyPI pins flat style --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index eb88d06..87d273d 100644 --- a/README.rst +++ b/README.rst @@ -113,13 +113,13 @@ Andrea Stagi stagi.andrea@gmail.com :target: https://travis-ci.org/nanpy/nanpy/ .. |Coveralls| image:: http://img.shields.io/coveralls/nanpy/nanpy/master.svg :target: https://coveralls.io/r/nanpy/nanpy/ -.. |Latest Version| image:: https://pypip.in/version/nanpy/badge.svg +.. |Latest Version| image:: https://pypip.in/version/nanpy/badge.svg?style=flat :target: https://pypi.python.org/pypi/nanpy/ -.. |Supported Python versions| image:: https://pypip.in/py_versions/nanpy/badge.svg +.. |Supported Python versions| image:: https://pypip.in/py_versions/nanpy/badge.svg?style=flat :target: https://pypi.python.org/pypi/nanpy/ -.. |License| image:: https://pypip.in/license/nanpy/badge.svg +.. |License| image:: https://pypip.in/license/nanpy/badge.svg?style=flat :target: https://pypi.python.org/pypi/nanpy/ -.. |Downloads| image:: https://pypip.in/download/nanpy/badge.svg +.. |Downloads| image:: https://pypip.in/download/nanpy/badge.svg?style=flat :target: https://pypi.python.org/pypi/nanpy/ .. |Code Health| image:: https://landscape.io/github/nanpy/nanpy/master/landscape.svg?style=flat :target: https://landscape.io/github/nanpy/nanpy/master From a272ed9b20a362fda86cb2cfb1a069bd0a58a6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Sun, 26 Apr 2015 18:37:52 +0200 Subject: [PATCH 260/344] Add rtscts parameter to SerialManager Enabling rtscts fixes problems on Raspberry Pi --- nanpy/serialmanager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py index 6de3c95..a4b7fdb 100644 --- a/nanpy/serialmanager.py +++ b/nanpy/serialmanager.py @@ -54,11 +54,13 @@ class SerialManager(object): def __init__(self, device=None, baudrate=DEFAULT_BAUDRATE, sleep_after_connect=2, - timeout=7): + timeout=7, + rtscts=False): self.device = device self.baudrate = baudrate self.sleep_after_connect = sleep_after_connect self.timeout = timeout + self.rtscts = rtscts def open(self, device=None): '''open connection''' @@ -74,7 +76,8 @@ def open(self, device=None): assert self.device self._serial = serial.Serial(self.device, self.baudrate, - timeout=self.timeout) + timeout=self.timeout, + rtscts=self.rtscts) if self.sleep_after_connect: time.sleep(self.sleep_after_connect) self._serial.flushInput() From 43cbf9842af471e896b116b214dc25dfb056b617 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 27 Apr 2015 23:48:02 +0200 Subject: [PATCH 261/344] Style fixes on dht --- nanpy/dht.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/dht.py b/nanpy/dht.py index 3ccb6ef..f0b8302 100644 --- a/nanpy/dht.py +++ b/nanpy/dht.py @@ -8,7 +8,7 @@ class DHT(ArduinoObject): DHT21 = 21 AM2301 = 21 - def __init__(self, pin, _type, count = 6, connection=None): + def __init__(self, pin, _type, count=6, connection=None): ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', pin, _type, count) @@ -24,5 +24,5 @@ def readHumidity(self): @returns(float) @arduinoobjectmethod - def readTemperature(self, value = False): + def readTemperature(self, value=False): pass From 5259436c779a7dc27337cb317d9301735b358ac3 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Mon, 27 Apr 2015 23:48:13 +0200 Subject: [PATCH 262/344] New DHT example --- nanpy/examples/dht.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nanpy/examples/dht.py b/nanpy/examples/dht.py index 363a371..ff524bf 100755 --- a/nanpy/examples/dht.py +++ b/nanpy/examples/dht.py @@ -6,10 +6,15 @@ # http://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor # DHT sensor connected to digital pin 10 -dht = DHT(10,DHT.DHT22) +dhts = [ + DHT(6, DHT.DHT11), + DHT(7, DHT.DHT11), + DHT(8, DHT.DHT11) +] -print("temperature is %f degrees Celcius" % dht.readTemperature()) -print("temperature is %f degrees Celcius" % dht.readTemperature(False)) -print("temperature is %f degrees Fahrenheit" % dht.readTemperature(True)) -print("humidity is %f %%" % dht.readHumidity()) +for i, dht in enumerate(dhts): + print("DHT %d" % i) + print("Temperature is %.2f degrees Celcius" % dht.readTemperature(False)) + print("Temperature is %.2f degrees Fahrenheit" % dht.readTemperature(True)) + print("Humidity is %.2f %%" % dht.readHumidity()) From 92eb4a3c7317eb324188907282e5542cda6eb1f0 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 2 May 2015 12:42:54 +0200 Subject: [PATCH 263/344] Version 0.9.4 --- nanpy/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 7a679ff..68fa26c 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -5,7 +5,7 @@ """ Nanpy library """ -__version__ = '0.9.3' +__version__ = '0.9.4' __author__ = 'Andrea Stagi' __license__ = 'MIT' diff --git a/setup.py b/setup.py index 700ecb0..ca7ad96 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ ] setup(name="nanpy", - version="0.9.3", + version="0.9.4", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From 0f843b7b979b583f8de9ceedac467dd3903eb518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Fri, 8 May 2015 08:21:54 +0200 Subject: [PATCH 264/344] Update README.rst --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 87d273d..3e9d0cc 100644 --- a/README.rst +++ b/README.rst @@ -113,13 +113,13 @@ Andrea Stagi stagi.andrea@gmail.com :target: https://travis-ci.org/nanpy/nanpy/ .. |Coveralls| image:: http://img.shields.io/coveralls/nanpy/nanpy/master.svg :target: https://coveralls.io/r/nanpy/nanpy/ -.. |Latest Version| image:: https://pypip.in/version/nanpy/badge.svg?style=flat +.. |Latest Version| image:: https://img.shields.io/pypi/v/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |Supported Python versions| image:: https://pypip.in/py_versions/nanpy/badge.svg?style=flat +.. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%202.8%2C%203.3%2C%203.4-blue.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |License| image:: https://pypip.in/license/nanpy/badge.svg?style=flat +.. |License| image:: https://img.shields.io/pypi/l/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |Downloads| image:: https://pypip.in/download/nanpy/badge.svg?style=flat +.. |Downloads| image:: https://img.shields.io/pypi/dm/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ .. |Code Health| image:: https://landscape.io/github/nanpy/nanpy/master/landscape.svg?style=flat :target: https://landscape.io/github/nanpy/nanpy/master From 80ac39564b473f406f7cdd557e1c76267cb74ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Fri, 8 May 2015 08:29:08 +0200 Subject: [PATCH 265/344] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3e9d0cc..4e3cbcf 100644 --- a/README.rst +++ b/README.rst @@ -117,7 +117,7 @@ Andrea Stagi stagi.andrea@gmail.com :target: https://pypi.python.org/pypi/nanpy/ .. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%202.8%2C%203.3%2C%203.4-blue.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |License| image:: https://img.shields.io/pypi/l/nanpy.svg +.. |License| image:: https://img.shields.io/github/license/nanpy/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ .. |Downloads| image:: https://img.shields.io/pypi/dm/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ From 807f498d09f96c03b5e4fe50bd444edae1203b0b Mon Sep 17 00:00:00 2001 From: LunarLanding Date: Mon, 18 May 2015 12:13:56 +0100 Subject: [PATCH 266/344] Make link actually work Otherwise got this error: Cloning into 'nanpy-firmware'... Permission denied (publickey). fatal: Could not read from remote repository. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4e3cbcf..f25fb1e 100644 --- a/README.rst +++ b/README.rst @@ -71,7 +71,7 @@ PyPi `__. :: - git clone git@github.com:nanpy/nanpy-firmware.git + git clone https://github.com/nanpy/nanpy-firmware.git cd nanpy-firmware ./configure.sh From 6c1bd1bcc0d81a739a5f2af97e9a6f1424509fde Mon Sep 17 00:00:00 2001 From: LunarLanding Date: Mon, 18 May 2015 12:26:49 +0100 Subject: [PATCH 267/344] add necessary import --- README.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 4e3cbcf..9d79578 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,6 @@ Overview Arduino programming a game for kids. :: - a = ArduinoApi() a.pinMode(13, a.OUTPUT) a.digitalWrite(13, a.HIGH) @@ -53,7 +52,7 @@ specify another serial port: and use it with your objects :: - + from nanpy import ArduinoApi a = ArduinoApi(connection=connection) a.pinMode(13, a.OUTPUT) a.digitalWrite(13, a.HIGH) From 9cee56042ca6f3613561195645e550d8a77977c0 Mon Sep 17 00:00:00 2001 From: balzreber Date: Sun, 30 Aug 2015 08:04:13 +0200 Subject: [PATCH 268/344] Added Support for the Adafruit TLC5947 24-Channel PWM Driver --- nanpy/TLC5947.py | 16 ++++++++++++++++ nanpy/__init__.py | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 nanpy/TLC5947.py diff --git a/nanpy/TLC5947.py b/nanpy/TLC5947.py new file mode 100644 index 0000000..0466a80 --- /dev/null +++ b/nanpy/TLC5947.py @@ -0,0 +1,16 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import (arduinoobjectmethod, returns) + +class TLC5947(ArduinoObject): + + def __init__(self, boardTotal, clock, data, latch, connection=None): + ArduinoObject.__init__(self, connection=connection) + self.id = self.call('new', boardTotal, clock, data, latch) + + @arduinoobjectmethod + def setLED(self, led, r, g, b): + pass + + @arduinoobjectmethod + def write(self): + pass \ No newline at end of file diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 68fa26c..9c0b0b1 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -23,3 +23,5 @@ from nanpy.dht import DHT from nanpy.arduinoapi import ArduinoApi from nanpy.eeprom import EEPROM + +from nanpy.TLC5947 import TLC5947 \ No newline at end of file From b2c5a2c9be7ebb31a1dc01ed110836050f97299a Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sun, 6 Sep 2015 11:22:34 +0200 Subject: [PATCH 269/344] Bump version to 0.9.5 --- nanpy/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index 9c0b0b1..dae11e5 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -5,7 +5,7 @@ """ Nanpy library """ -__version__ = '0.9.4' +__version__ = '0.9.5' __author__ = 'Andrea Stagi' __license__ = 'MIT' diff --git a/setup.py b/setup.py index ca7ad96..422d0ad 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ ] setup(name="nanpy", - version="0.9.4", + version="0.9.5", description="Use your Arduino board with Python", license="MIT", author="Andrea Stagi", From ee052f6b0142979108118c936eeca3d3072e7113 Mon Sep 17 00:00:00 2001 From: balzreber Date: Sun, 6 Sep 2015 18:58:09 +0200 Subject: [PATCH 270/344] Added Support for the Adafruit TLC5947 24-Channel PWM Driver --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 6ab68d6..524719c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -15,3 +15,4 @@ Contributors - Graeme Pyle (https://github.com/graemian) - Justin Youngblood (darksotm@gmail.com) - Pierrick Brun (https://github.com/Pi3R1k) +- Balz Reber (https://github.com/balzreber) \ No newline at end of file From 41500772412e1a6da769ec08f5ff82d4c89183f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Fri, 11 Sep 2015 08:13:15 +0200 Subject: [PATCH 271/344] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a7a8cb3..2b8ba7b 100644 --- a/README.rst +++ b/README.rst @@ -114,7 +114,7 @@ Andrea Stagi stagi.andrea@gmail.com :target: https://coveralls.io/r/nanpy/nanpy/ .. |Latest Version| image:: https://img.shields.io/pypi/v/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%202.8%2C%203.3%2C%203.4-blue.svg +.. |Supported Python versions| image:: https://img.shields.io/badge/python-2.6%2C%202.7%2C%203.3%2C%203.4-blue.svg :target: https://pypi.python.org/pypi/nanpy/ .. |License| image:: https://img.shields.io/github/license/nanpy/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ From 983128382a1a3f90fc06591c77d08e0195e2f980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Wed, 28 Oct 2015 13:52:52 +0100 Subject: [PATCH 272/344] Remove Python 3.2 from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 74a5854..ee8ef5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python python: - "2.6" - "2.7" - - "3.2" - "3.3" - "3.4" From 09a706449de6074d1063912b591d2a200f4b5470 Mon Sep 17 00:00:00 2001 From: Michal Opler Date: Thu, 28 Jan 2016 15:23:20 +0100 Subject: [PATCH 273/344] Add LCD autoscroll --- nanpy/lcd.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 4e99ca0..9f5c445 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -18,3 +18,11 @@ def printString(self, value, col = None, row = None): @arduinoobjectmethod def setCursor(self, col, row): pass + + @arduinoobjectmethod + def autoscroll(self): + pass + + @arduinoobjectmethod + def noAutoscroll(self): + pass From 50ef9514367b4242f0f8ab873d9e46c44fc4f1c4 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 30 Jan 2016 11:50:56 +0100 Subject: [PATCH 274/344] Add clear method for lcd --- nanpy/lcd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 9f5c445..3c8498f 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -26,3 +26,7 @@ def autoscroll(self): @arduinoobjectmethod def noAutoscroll(self): pass + + @arduinoobjectmethod + def clear(self): + pass From 4e293daad5af96ee16d93058dda45bae733be9ad Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 30 Jan 2016 11:51:24 +0100 Subject: [PATCH 275/344] Add example for lcd autoscroll --- nanpy/examples/lcd_autoscroll.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 nanpy/examples/lcd_autoscroll.py diff --git a/nanpy/examples/lcd_autoscroll.py b/nanpy/examples/lcd_autoscroll.py new file mode 100644 index 0000000..f24fa6e --- /dev/null +++ b/nanpy/examples/lcd_autoscroll.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import time + +from nanpy import SerialManager +from nanpy.lcd import Lcd + + +if __name__ == '__main__': + + connection = SerialManager(sleep_after_connect=2) + + cols, rows = 16, 2 + + pins = [7, 8, 9, 10, 11, 12] + lcd = Lcd(pins, [cols, rows], connection=connection) + + while True: + + lcd.setCursor(0, 0); + + for char in range(10): + lcd.printString(char) + time.sleep(0.5) + + lcd.setCursor(16, 1) + lcd.autoscroll() + + for char in range(10): + lcd.printString(char) + time.sleep(0.5) + + lcd.noAutoscroll() + lcd.clear() \ No newline at end of file From 95911fe278acebc5aa66ea7543e48709c99d7583 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 29 Jan 2016 19:54:33 +0100 Subject: [PATCH 276/344] Update copyright --- LICENSE | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 254d448..f887ad0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012-2015 Andrea Stagi +Copyright (c) 2012-2016 Andrea Stagi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index 2b8ba7b..931d9ac 100644 --- a/README.rst +++ b/README.rst @@ -105,7 +105,7 @@ Paypal Date: Fri, 29 Jan 2016 20:01:05 +0100 Subject: [PATCH 277/344] Drop support to Python 2.6 --- .travis.yml | 6 +++--- README.rst | 2 +- setup.py | 3 +-- tox.ini | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee8ef5a..48c1df4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,16 @@ language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" + - "3.5" install: - pip install coveralls coverage - pip install pyserial -script: +script: - python setup.py nosetests -w tests/test_offline --with-coverage --cover-package=nanpy - + after_success: - coveralls diff --git a/README.rst b/README.rst index 931d9ac..4c54732 100644 --- a/README.rst +++ b/README.rst @@ -114,7 +114,7 @@ Andrea Stagi stagi.andrea@gmail.com :target: https://coveralls.io/r/nanpy/nanpy/ .. |Latest Version| image:: https://img.shields.io/pypi/v/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |Supported Python versions| image:: https://img.shields.io/badge/python-2.6%2C%202.7%2C%203.3%2C%203.4-blue.svg +.. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%203.3%2C%203.4%2C%203.5-blue.svg :target: https://pypi.python.org/pypi/nanpy/ .. |License| image:: https://img.shields.io/github/license/nanpy/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ diff --git a/setup.py b/setup.py index 422d0ad..a4498e9 100644 --- a/setup.py +++ b/setup.py @@ -10,12 +10,11 @@ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", -"Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", -"Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", +"Programming Language :: Python :: 3.5", ] setup(name="nanpy", diff --git a/tox.ini b/tox.ini index a67cb3d..e4f2075 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -envlist = py26,py27,py32,py33,py34 +envlist = py27,py33,py34,py35 [testenv] deps= @@ -12,5 +12,5 @@ changedir=tests/test_offline # if you have an Arduino connected #changedir=tests -commands=nosetests -v +commands=nosetests -v From 6a08ffdc295b8e26eb3a204d96b665da2c57f453 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 30 Jan 2016 01:56:02 +0100 Subject: [PATCH 278/344] Add requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9a1ffa9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyserial==3.0.1 From 7ae55057bcc3904c66c8cdf698bbaed74592113c Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 30 Jan 2016 01:59:28 +0100 Subject: [PATCH 279/344] Add auto long description detection --- setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a4498e9..ab58147 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,12 @@ #!/usr/bin/env python from setuptools import setup, find_packages +import os, sys + + +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + classifiers = [ # Get more strings from @@ -20,12 +26,13 @@ setup(name="nanpy", version="0.9.5", description="Use your Arduino board with Python", + long_description=read('README.rst'), license="MIT", author="Andrea Stagi", author_email="stagi.andrea@gmail.com", url="http://github.com/nanpy/nanpy", packages = find_packages(), - keywords= "arduino library prototype", + keywords= "arduino library prototype serial communication rpc", install_requires=[ "pyserial", ], From 9da4c5fdb56d8ca56e2135a40bd03d948a1062d4 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 30 Jan 2016 02:00:57 +0100 Subject: [PATCH 280/344] Add Michal Opler to CONTRIBUTORS --- CONTRIBUTORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 524719c..435e663 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -15,4 +15,5 @@ Contributors - Graeme Pyle (https://github.com/graemian) - Justin Youngblood (darksotm@gmail.com) - Pierrick Brun (https://github.com/Pi3R1k) -- Balz Reber (https://github.com/balzreber) \ No newline at end of file +- Balz Reber (https://github.com/balzreber) +- Michal Opler (https://github.com/joppi) \ No newline at end of file From 388e511be60a59b3aa865fae27429d9cf305ac0f Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 30 Jan 2016 11:59:02 +0100 Subject: [PATCH 281/344] Remove useless badges from README --- README.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 4c54732..d912c04 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Nanpy ===== -|Travis| |Coveralls| |Latest Version| |Supported Python versions| |License| |Downloads| |Code Health| +|Travis| |Coveralls| |Latest Version| |Supported Python versions| |Downloads| Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy @@ -116,9 +116,5 @@ Andrea Stagi stagi.andrea@gmail.com :target: https://pypi.python.org/pypi/nanpy/ .. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%203.3%2C%203.4%2C%203.5-blue.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |License| image:: https://img.shields.io/github/license/nanpy/nanpy.svg - :target: https://pypi.python.org/pypi/nanpy/ .. |Downloads| image:: https://img.shields.io/pypi/dm/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ -.. |Code Health| image:: https://landscape.io/github/nanpy/nanpy/master/landscape.svg?style=flat - :target: https://landscape.io/github/nanpy/nanpy/master From 01adc9b2de58b76452c505ef363ce7c70643b2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Sun, 31 Jan 2016 16:26:48 +0100 Subject: [PATCH 282/344] Update README.rst --- README.rst | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index d912c04..b8186aa 100644 --- a/README.rst +++ b/README.rst @@ -8,26 +8,23 @@ Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy Overview -------- -| Nanpy is a library that use your Arduino as a slave, controlled by a - master device where you run your scripts, such as a PC, a Raspberry Pi - etc. -| The main purpose of Nanpy is making programmers' life easier, - providing them a powerful library to create prototypes faster and make - Arduino programming a game for kids. +Nanpy is a library that use your Arduino as a slave, controlled by a master device where you run your scripts, such as a PC, a Raspberry Pi etc. + +The main purpose of Nanpy is making programmers' life easier, providing them a powerful library to create prototypes faster and make Arduino programming a game for kids. :: + a = ArduinoApi() a.pinMode(13, a.OUTPUT) a.digitalWrite(13, a.HIGH) -| I know, there are a lot of projects able to do that, but hey, Nanpy - can do more! -| Nanpy is easily extensible and can theoretically use every library, - allowing you to create how many objects you want. -| We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many - more... -| Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 - and show your first "Hello world"! +I know, there are a lot of projects able to do that, but hey, Nanpy can do more! + +Nanpy is easily extensible and can theoretically use every library, +allowing you to create how many objects you want. We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many +more... + +Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and show your first "Hello world"! :: @@ -52,6 +49,7 @@ specify another serial port: and use it with your objects :: + from nanpy import ArduinoApi a = ArduinoApi(connection=connection) a.pinMode(13, a.OUTPUT) From 07cf70852f135f8ea5e212b46bb14902ba49eb35 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 6 Feb 2016 14:18:21 +0100 Subject: [PATCH 283/344] Add INPUT_PULLUP support --- nanpy/arduinoapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/arduinoapi.py b/nanpy/arduinoapi.py index 5dbe53d..df1a040 100644 --- a/nanpy/arduinoapi.py +++ b/nanpy/arduinoapi.py @@ -9,7 +9,7 @@ class ArduinoApi(FirmwareClass): firmware_id = 'A' LOW, HIGH = 0, 1 - INPUT, OUTPUT = 0, 1 + INPUT, OUTPUT, INPUT_PULLUP = 0, 1, 2 LSBFIRST, MSBFIRST = 0, 1 @arduinomethod('dw') From 8a668efbc266802a4f4e23c936d3589b230d9528 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Sat, 6 Feb 2016 14:21:00 +0100 Subject: [PATCH 284/344] Add blink example on two different boards --- nanpy/examples/blink_2boards.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 nanpy/examples/blink_2boards.py diff --git a/nanpy/examples/blink_2boards.py b/nanpy/examples/blink_2boards.py new file mode 100644 index 0000000..3c8855e --- /dev/null +++ b/nanpy/examples/blink_2boards.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Author: Andrea Stagi +# Description: keeps your led blinking on 2 boards +# Dependencies: None + +from nanpy import (ArduinoApi, SerialManager) +from time import sleep + + +device_1 = '/dev/tty.usbmodem1411' +device_2 = '/dev/tty.usbmodem1431' + +connection_1 = SerialManager(device=device_1) +connection_2 = SerialManager(device=device_2) + +a1 = ArduinoApi(connection=connection_1) +a1.pinMode(13, a1.OUTPUT) + +a2 = ArduinoApi(connection=connection_2) +a2.pinMode(13, a2.OUTPUT) + +for i in range(10000): + a1.digitalWrite(13, (i + 1) % 2) + sleep(1) + a2.digitalWrite(13, (i + 1) % 2) + sleep(1) + From aeca430286e57b824cf6f7929391e15022640d49 Mon Sep 17 00:00:00 2001 From: hegartybr Date: Tue, 16 Feb 2016 13:16:00 -0500 Subject: [PATCH 285/344] Updating stepper.py to allow for 4 pin motors. Awkward argument order in order to preserve backward compatibility. Requires changes to the firmware, as well. --- nanpy/stepper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nanpy/stepper.py b/nanpy/stepper.py index 714c8bf..55cdd24 100644 --- a/nanpy/stepper.py +++ b/nanpy/stepper.py @@ -3,9 +3,12 @@ class Stepper(ArduinoObject): - def __init__(self, revsteps, pin1, pin2, speed=None, connection=None): + def __init__(self, revsteps, pin1, pin2, speed=None, connection=None, pin3=None, pin4=None): ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', revsteps, pin1, pin2) + if pin3 is not None and pin4 is not None: + self.id = self.call('new', revsteps, pin1, pin2, pin3, pin4) + else: + self.id = self.call('new', revsteps, pin1, pin2) if speed: self.setSpeed(speed) From a49a1988c43f5f1f97ed77a8a43cdf917133193f Mon Sep 17 00:00:00 2001 From: Michal Opler Date: Tue, 23 Feb 2016 19:57:01 +0100 Subject: [PATCH 286/344] Add LCD createChar API This resolves nanpy/nanpy#63. --- nanpy/lcd.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nanpy/lcd.py b/nanpy/lcd.py index 3c8498f..f3d463f 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -30,3 +30,11 @@ def noAutoscroll(self): @arduinoobjectmethod def clear(self): pass + + @arduinoobjectmethod + def createChar(self, num, data): + pass + + @arduinoobjectmethod + def write(self, data): + pass From 8f71a4824b6db1a4e7d9d25335e6d4af595d79cf Mon Sep 17 00:00:00 2001 From: Michal Opler Date: Tue, 23 Feb 2016 19:59:15 +0100 Subject: [PATCH 287/344] Add example for LCD createChar --- nanpy/examples/lcd_createchar.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 nanpy/examples/lcd_createchar.py diff --git a/nanpy/examples/lcd_createchar.py b/nanpy/examples/lcd_createchar.py new file mode 100644 index 0000000..31488d2 --- /dev/null +++ b/nanpy/examples/lcd_createchar.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +from nanpy.lcd import Lcd + + +if __name__ == '__main__': + + pins = [7, 8, 9, 10, 11, 12] + cols, rows = 16, 2 + lcd = Lcd(pins, [cols, rows]) + + smiley= [ + 0b00000, + 0b10001, + 0b00000, + 0b00000, + 0b10001, + 0b01110, + 0b00000, + 0b00000] + + lcd.createChar(0,smiley) + lcd.setCursor(0,0) + lcd.write(0) From dc54d28f1af7b915aa639d81fa6ff85e77f81c25 Mon Sep 17 00:00:00 2001 From: Michal Opler Date: Tue, 23 Feb 2016 20:06:33 +0100 Subject: [PATCH 288/344] Code style fix --- nanpy/examples/lcd_createchar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nanpy/examples/lcd_createchar.py b/nanpy/examples/lcd_createchar.py index 31488d2..81bd4ff 100644 --- a/nanpy/examples/lcd_createchar.py +++ b/nanpy/examples/lcd_createchar.py @@ -9,7 +9,7 @@ cols, rows = 16, 2 lcd = Lcd(pins, [cols, rows]) - smiley= [ + smiley = [ 0b00000, 0b10001, 0b00000, @@ -17,7 +17,8 @@ 0b10001, 0b01110, 0b00000, - 0b00000] + 0b00000 + ] lcd.createChar(0,smiley) lcd.setCursor(0,0) From 6072e84739da29e83d649b2ec5b06a3cd5257380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Sat, 27 Feb 2016 12:36:34 +0100 Subject: [PATCH 289/344] Update README.rst --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index b8186aa..1e1e63a 100644 --- a/README.rst +++ b/README.rst @@ -14,6 +14,8 @@ The main purpose of Nanpy is making programmers' life easier, providing them a p :: + from nanpy import ArduinoApi + a = ArduinoApi() a.pinMode(13, a.OUTPUT) a.digitalWrite(13, a.HIGH) From 5e7aa2542c702c040fee6269b6974970bb628848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Sat, 27 Feb 2016 13:47:02 +0100 Subject: [PATCH 290/344] Add Stefan Krastanov to contributors --- CONTRIBUTORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 435e663..82bde08 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -16,4 +16,5 @@ Contributors - Justin Youngblood (darksotm@gmail.com) - Pierrick Brun (https://github.com/Pi3R1k) - Balz Reber (https://github.com/balzreber) -- Michal Opler (https://github.com/joppi) \ No newline at end of file +- Michal Opler (https://github.com/joppi) +- Stefan Krastanov (https://github.com/Krastanov) From fb0d728d5033545dacc47ef83e6982fca686c2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Wed, 2 Mar 2016 11:34:35 +0100 Subject: [PATCH 291/344] Update README.rst --- README.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 1e1e63a..4a997ba 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Nanpy ===== -|Travis| |Coveralls| |Latest Version| |Supported Python versions| |Downloads| +|Travis| |Latest Version| |Supported Python versions| |Downloads| Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy @@ -110,8 +110,6 @@ Andrea Stagi stagi.andrea@gmail.com .. |Travis| image:: http://img.shields.io/travis/nanpy/nanpy.svg :target: https://travis-ci.org/nanpy/nanpy/ -.. |Coveralls| image:: http://img.shields.io/coveralls/nanpy/nanpy/master.svg - :target: https://coveralls.io/r/nanpy/nanpy/ .. |Latest Version| image:: https://img.shields.io/pypi/v/nanpy.svg :target: https://pypi.python.org/pypi/nanpy/ .. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%203.3%2C%203.4%2C%203.5-blue.svg From 01bc64be22640f28574aba6db2c1f89158bb0b92 Mon Sep 17 00:00:00 2001 From: Andrea Stagi Date: Fri, 4 Mar 2016 08:21:20 +0100 Subject: [PATCH 292/344] Bump version to 0.9.6 --- nanpy/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/__init__.py b/nanpy/__init__.py index dae11e5..a7d29a0 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -5,7 +5,7 @@ """ Nanpy library """ -__version__ = '0.9.5' +__version__ = '0.9.6' __author__ = 'Andrea Stagi' __license__ = 'MIT' diff --git a/setup.py b/setup.py index ab58147..fda965c 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def read(fname): ] setup(name="nanpy", - version="0.9.5", + version="0.9.6", description="Use your Arduino board with Python", long_description=read('README.rst'), license="MIT", From 44197cbae30af4686f4a1b687c54a7415776ff50 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 20 Mar 2016 17:52:04 +0100 Subject: [PATCH 293/344] i2c: fix doc, improve example --- nanpy/examples/i2c_send.py | 7 ++++--- nanpy/i2c.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nanpy/examples/i2c_send.py b/nanpy/examples/i2c_send.py index 296c7e6..e17cb82 100755 --- a/nanpy/examples/i2c_send.py +++ b/nanpy/examples/i2c_send.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Description: +# Description: sending a byte to PCF8574 from nanpy.arduinotree import ArduinoTree from nanpy.i2c import I2C_Master @@ -8,14 +8,15 @@ import logging log = logging.getLogger(__name__) - +I2C_ADDRESS = 0x27 + def main(): connection = SerialManager(sleep_after_connect=2) connection.open() print (connection.device) a = ArduinoTree(connection=connection) master = I2C_Master(a.wire) - master.send(0x27, [0b00001000]) + master.send(I2C_ADDRESS, [0b00001000]) if __name__ == '__main__': diff --git a/nanpy/i2c.py b/nanpy/i2c.py index 8fad5fd..dd1eaa8 100644 --- a/nanpy/i2c.py +++ b/nanpy/i2c.py @@ -41,7 +41,7 @@ def request(self, address, quantity): :param address: the 7-bit address of the device to request bytes from :param quantity: the number of bytes to request :param stop: boolean. true will send a stop message after the request, releasing the bus. false will continually send a restart after the request, keeping the connection active. - :returns: byte : the number of bytes returned from the slave device + :returns: list : the list of bytes returned from the slave device http://arduino.cc/en/Reference/WireRequestFrom From 5d8429eed783c12582c060caf3bf20294d9e7d60 Mon Sep 17 00:00:00 2001 From: ponty Date: Sun, 20 Mar 2016 17:57:31 +0100 Subject: [PATCH 294/344] PCF8574: implementation --- nanpy/PCF8574.py | 43 +++++++++++++++++++++++++++++++++ nanpy/examples/PCF8574.py | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 nanpy/PCF8574.py create mode 100644 nanpy/examples/PCF8574.py diff --git a/nanpy/PCF8574.py b/nanpy/PCF8574.py new file mode 100644 index 0000000..e65c227 --- /dev/null +++ b/nanpy/PCF8574.py @@ -0,0 +1,43 @@ +import logging +from nanpy.i2c import I2C_Master + + +log = logging.getLogger(__name__) + + +class PCF8574_Error(Exception): + pass + + +class PCF8574(object): + + def __init__(self, wire, address): + self._address = address + self.master = I2C_Master(wire) + + def read8(self): + ls = self.master.request(self._address, 1) + + # HACK: without beginTransmission all second read is empty + self.master.wire.beginTransmission(self._address) + error_code = self.master.wire.endTransmission() + + if len(ls) >= 1: + return ls[0] + else: + raise PCF8574_Error('no data received from PCF8574') + + def write8(self, value): + self.master.send(self._address, [value]) + + def readPin(self, pin): + d = self.read8() + return (d & (1 << pin)) > 0 + + def writePin(self, pin, value): + d = self.read8() + if value: + d |= (1 << pin) + else: + d &= ~(1 << pin) + self.write8(d) diff --git a/nanpy/examples/PCF8574.py b/nanpy/examples/PCF8574.py new file mode 100644 index 0000000..d59d1fc --- /dev/null +++ b/nanpy/examples/PCF8574.py @@ -0,0 +1,50 @@ +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager +from nanpy.PCF8574 import PCF8574 + + +I2C_ADDRESS = 0x27 + + +def main(): + print ('PCF8574 demo') + print ('address: 0x%X' % I2C_ADDRESS) + connection = SerialManager(sleep_after_connect=2) + connection.open() + a = ArduinoTree(connection=connection) + pcf = PCF8574(a.wire, I2C_ADDRESS) + + def write(d): + print ('write: %s' % bin(d)) + pcf.write8(d) + + def read(): + d = pcf.read8() + print ('read: %s' % bin(d)) + + read() + + d = pcf.readPin(0) + print ('read pin 0: %s' % d) + print ('write pin 0: %s' % 1) + pcf.writePin(0, 1) + d = pcf.readPin(0) + print ('read pin 0: %s' % d) + + read() + + write(0b11111111) + read() + + write(0b10101010) + read() + + write(0b01010101) + read() + + write(0b00000000) + read() + + +if __name__ == '__main__': + main() From 45a307eedc95d17ff347023ba595b9e2c52911c8 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 11 Feb 2016 16:12:27 +0100 Subject: [PATCH 295/344] add example for power supply --- nanpy/examples/power.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 nanpy/examples/power.py diff --git a/nanpy/examples/power.py b/nanpy/examples/power.py new file mode 100755 index 0000000..9920e78 --- /dev/null +++ b/nanpy/examples/power.py @@ -0,0 +1,15 @@ +"""power read demo.""" + +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager + + +def power_demo(): + connection = SerialManager() + a = ArduinoTree(connection=connection) + Vcc = a.vcc.read() + msg = 'Power supply= %0.2f V' % Vcc + print(msg) + +if __name__ == '__main__': + power_demo() From 00cfc6296fadd0ea706963882d1383f9cf63236e Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 14 Apr 2016 15:23:42 +0200 Subject: [PATCH 296/344] X9C1xxx support added --- nanpy/DigiPotX9Cxxx.py | 77 +++++++++++++++++++++++++++++++++++++++ nanpy/examples/digipot.py | 39 ++++++++++++++++++++ nanpy/util.py | 9 +++++ 3 files changed, 125 insertions(+) create mode 100644 nanpy/DigiPotX9Cxxx.py create mode 100644 nanpy/examples/digipot.py create mode 100644 nanpy/util.py diff --git a/nanpy/DigiPotX9Cxxx.py b/nanpy/DigiPotX9Cxxx.py new file mode 100644 index 0000000..c18026d --- /dev/null +++ b/nanpy/DigiPotX9Cxxx.py @@ -0,0 +1,77 @@ +# based on https:#sites.google.com/site/tfagerscode/home/digipotx9cxxx +from nanpy.util import constrain + + +DIGIPOT_MAX_AMOUNT = 99 +DIGIPOT_UNKNOWN = 255 + +LOW, HIGH = 0, 1 +INPUT, OUTPUT = 0, 1 + + + +class DigiPot(): + + def __init__(self, arduinoApi, incPin, udPin, csPin): + self._arduinoApi = arduinoApi + self._incPin = incPin + self._udPin = udPin + self._csPin = csPin + self._currentValue = DIGIPOT_UNKNOWN + + self._incPin.write_mode(OUTPUT) + self._udPin.write_mode(OUTPUT) + self._csPin.write_mode(OUTPUT) + self._csPin.write_digital_value(HIGH) + + def reset(self): + # change down maximum number of times to ensure the value is 0 + self.decrease(DIGIPOT_MAX_AMOUNT) + self._currentValue = 0 + + def set(self, value): + value = constrain(value, 0, DIGIPOT_MAX_AMOUNT) + if (self._currentValue == DIGIPOT_UNKNOWN): + self.reset() + if (self._currentValue > value): + self.change(-1, self._currentValue - value) + elif (self._currentValue < value): + self.change(1, value - self._currentValue) + + def get(self): + return self._currentValue + + def increase(self, amount): + amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) + self.change(1, amount) + + def decrease(self, amount): + amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) + self.change(-1, amount) + + def change(self, direction, amount): + if direction==1: + ud=HIGH + elif direction==-1: + ud=LOW + else: + raise ValueError('invalid direction: %s', direction) + + amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) + if amount==0: + return + + self._udPin.write_digital_value(ud) + self._incPin.write_digital_value(HIGH) + self._csPin.write_digital_value(LOW) + + for _ in range(amount): + self._incPin.write_digital_value(LOW) +# delayMicroseconds(2) + self._incPin.write_digital_value(HIGH) +# delayMicroseconds(2) + if (self._currentValue != DIGIPOT_UNKNOWN): + self._currentValue += direction + self._currentValue = constrain( self._currentValue, 0, DIGIPOT_MAX_AMOUNT) + + self._csPin.write_digital_value(HIGH) diff --git a/nanpy/examples/digipot.py b/nanpy/examples/digipot.py new file mode 100644 index 0000000..e61794f --- /dev/null +++ b/nanpy/examples/digipot.py @@ -0,0 +1,39 @@ +# +# DigiPot.pde - Example sketch for Arduino library for managing digital potentiometers X9C1xxx (xxx = 102,103,104,503). +# By Timo Fager, Jul 29, 2011. +# Released to public domain. +# +# For this example, connect your X9C103P (or the like) as follows: +# 1 - INC - Arduino pin 2 +# 2 - U/D - Arduino pin 3 +# 3 - VH - 5V +# 4 - VSS - GND +# 5 - VW - Output: 150 Ohm resistor -> LED -> GND +# 6 - VL - GND +# 7 - CS - Arduino pin 4 +# 8 - VCC - 5V +# + +from nanpy import SerialManager +from nanpy.arduinotree import ArduinoTree +from time import sleep + +from nanpy.DigiPotX9Cxxx import DigiPot + + +connection = SerialManager() +a = ArduinoTree(connection=connection) +incPin = a.pin.get(2) +udPin = a.pin.get(3) +csPin = a.pin.get(4) + +pot = DigiPot(incPin, udPin, csPin) + +for i in range(100): + pot.set(i) + print('set pot to %s' % i) + sleep(0.2) +for i in reversed(range(100)): + pot.set(i) + print('set pot to %s' % i) + sleep(0.2) diff --git a/nanpy/util.py b/nanpy/util.py new file mode 100644 index 0000000..9cc4379 --- /dev/null +++ b/nanpy/util.py @@ -0,0 +1,9 @@ + + +def constrain(value, xmin, xmax): + if value < xmin: + return xmin + if value > xmax: + return xmax + return value + From 6354ebdb2dfa0916bda57c0229d81afba7ba5ad0 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 14 Apr 2016 19:05:01 +0200 Subject: [PATCH 297/344] support new version format (example:10608 -> 1.6.8) --- nanpy/fwinfo.py | 9 +++++++-- tests/test_offline/test_fwinfo.py | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nanpy/fwinfo.py b/nanpy/fwinfo.py index 09bcc6f..3e50213 100644 --- a/nanpy/fwinfo.py +++ b/nanpy/fwinfo.py @@ -13,9 +13,14 @@ def avr_name(MCU): def arduino_version(ARDUINO): """ Example: 105 -> 1.0.5 - + 10608 -> 1.6.8 """ - return '.'.join(str(ARDUINO)) + s = str(ARDUINO) + if len(s) == 5: + return '%s.%s.%s' % (s[0], int(s[1:3]), int(s[3:5])) + else: + return '.'.join(s) + def compile_datetime(DATE, TIME): diff --git a/tests/test_offline/test_fwinfo.py b/tests/test_offline/test_fwinfo.py index 32fe94f..e7fc1b9 100644 --- a/tests/test_offline/test_fwinfo.py +++ b/tests/test_offline/test_fwinfo.py @@ -14,6 +14,9 @@ def test(): eq_(arduino_version(105), '1.0.5') eq_(arduino_version('105'), '1.0.5') + eq_(arduino_version(10608), '1.6.8') + eq_(arduino_version('10608'), '1.6.8') + eq_(arduino_version('52417'), '5.24.17') eq_(avr_name('__AVR_ATmega328P__'), 'ATmega328P') From 41b14cd6bd26c10e501460f3b35002614be32491 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 14 Apr 2016 19:07:04 +0200 Subject: [PATCH 298/344] parse month always as English name --- nanpy/fwinfo.py | 41 ++++++++++++++++++++++++++++--- tests/test_offline/test_fwinfo.py | 2 ++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/nanpy/fwinfo.py b/nanpy/fwinfo.py index 3e50213..c4ed2cc 100644 --- a/nanpy/fwinfo.py +++ b/nanpy/fwinfo.py @@ -22,15 +22,50 @@ def arduino_version(ARDUINO): return '.'.join(s) +def parse_month(s): + '''gcc month + Jan -> 1 + ... + ''' + if s == 'Jan': + return 1 + if s == 'Feb': + return 2 + if s == 'Mar': + return 3 + if s == 'Apr': + return 4 + if s == 'May': + return 5 + if s == 'Jun': + return 6 + if s == 'Jul': + return 7 + if s == 'Aug': + return 8 + if s == 'Sep': + return 9 + if s == 'Oct': + return 10 + if s == 'Nov': + return 11 + if s == 'Dec': + return 12 + raise ValueError('invalid month: %s' % s) + def compile_datetime(DATE, TIME): ''' Example: Mar 28 2014, 17:40:12 -> datetime.datetime(2008, 3, 28, 17, 40, 12) ''' - dt = datetime.datetime.strptime( - DATE + ' ' + TIME, - '%b %d %Y %H:%M:%S') + dls = DATE.strip().split() + d = datetime.date(int(dls[2]), parse_month(dls[0]), int(dls[1])) + t = datetime.datetime.strptime(TIME, '%H:%M:%S') + dt = datetime.datetime.combine(d, t.time()) +# dt = datetime.datetime.strptime( +# DATE + ' ' + TIME, +# '%b %d %Y %H:%M:%S') return dt diff --git a/tests/test_offline/test_fwinfo.py b/tests/test_offline/test_fwinfo.py index e7fc1b9..b205760 100644 --- a/tests/test_offline/test_fwinfo.py +++ b/tests/test_offline/test_fwinfo.py @@ -22,6 +22,8 @@ def test(): eq_(compile_datetime('Mar 28 2008', '17:40:12'), datetime.datetime(2008, 3, 28, 17, 40, 12)) + eq_(compile_datetime('Apr 10 2016', '15:54:18'), + datetime.datetime(2016, 4, 10, 15, 54, 18)) eq_(firmware_info(dict( MCU='__AVR_ATmega328P__', From 70029663be1508df21a61d8d269d4755f82bdb31 Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 18 Apr 2016 18:58:36 +0200 Subject: [PATCH 299/344] fix digipot --- nanpy/DigiPotX9Cxxx.py | 54 ++++++++++++++++++++------------------- nanpy/examples/digipot.py | 19 +++++++------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/nanpy/DigiPotX9Cxxx.py b/nanpy/DigiPotX9Cxxx.py index c18026d..5ad101c 100644 --- a/nanpy/DigiPotX9Cxxx.py +++ b/nanpy/DigiPotX9Cxxx.py @@ -3,26 +3,30 @@ DIGIPOT_MAX_AMOUNT = 99 -DIGIPOT_UNKNOWN = 255 LOW, HIGH = 0, 1 INPUT, OUTPUT = 0, 1 - class DigiPot(): + _udLastValue = None + _currentValue = None + range = (0, DIGIPOT_MAX_AMOUNT) - def __init__(self, arduinoApi, incPin, udPin, csPin): - self._arduinoApi = arduinoApi + def __init__(self, incPin, udPin, csPin): self._incPin = incPin self._udPin = udPin self._csPin = csPin - self._currentValue = DIGIPOT_UNKNOWN self._incPin.write_mode(OUTPUT) + self._incPin.write_digital_value(HIGH) + self._udPin.write_mode(OUTPUT) + self._csPin.write_mode(OUTPUT) - self._csPin.write_digital_value(HIGH) + self._csPin.write_digital_value(LOW) + + self.set(0) def reset(self): # change down maximum number of times to ensure the value is 0 @@ -31,11 +35,11 @@ def reset(self): def set(self, value): value = constrain(value, 0, DIGIPOT_MAX_AMOUNT) - if (self._currentValue == DIGIPOT_UNKNOWN): + if self._currentValue is None: self.reset() - if (self._currentValue > value): + if self._currentValue > value: self.change(-1, self._currentValue - value) - elif (self._currentValue < value): + elif self._currentValue < value: self.change(1, value - self._currentValue) def get(self): @@ -49,29 +53,27 @@ def decrease(self, amount): amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) self.change(-1, amount) - def change(self, direction, amount): - if direction==1: - ud=HIGH - elif direction==-1: - ud=LOW + def change(self, direction, amount): + if direction == 1: + ud = HIGH + elif direction == -1: + ud = LOW else: raise ValueError('invalid direction: %s', direction) - + amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) - if amount==0: + if amount == 0: return - - self._udPin.write_digital_value(ud) - self._incPin.write_digital_value(HIGH) - self._csPin.write_digital_value(LOW) + + if self._udLastValue != ud: + self._udPin.write_digital_value(ud) for _ in range(amount): self._incPin.write_digital_value(LOW) -# delayMicroseconds(2) self._incPin.write_digital_value(HIGH) -# delayMicroseconds(2) - if (self._currentValue != DIGIPOT_UNKNOWN): + if self._currentValue is not None: self._currentValue += direction - self._currentValue = constrain( self._currentValue, 0, DIGIPOT_MAX_AMOUNT) - - self._csPin.write_digital_value(HIGH) + self._currentValue = constrain( + self._currentValue, + 0, + DIGIPOT_MAX_AMOUNT) diff --git a/nanpy/examples/digipot.py b/nanpy/examples/digipot.py index e61794f..cbe27cf 100644 --- a/nanpy/examples/digipot.py +++ b/nanpy/examples/digipot.py @@ -8,7 +8,7 @@ # 2 - U/D - Arduino pin 3 # 3 - VH - 5V # 4 - VSS - GND -# 5 - VW - Output: 150 Ohm resistor -> LED -> GND +# 5 - VW - Output: A0 and 150 Ohm resistor -> LED -> GND # 6 - VL - GND # 7 - CS - Arduino pin 4 # 8 - VCC - 5V @@ -27,13 +27,14 @@ udPin = a.pin.get(3) csPin = a.pin.get(4) -pot = DigiPot(incPin, udPin, csPin) +anPin = a.pin.get('A0') -for i in range(100): - pot.set(i) - print('set pot to %s' % i) - sleep(0.2) -for i in reversed(range(100)): +pot = DigiPot(incPin, udPin, csPin) + +for i in range(100) + list(reversed(range(100))): pot.set(i) - print('set pot to %s' % i) - sleep(0.2) + an = anPin.read_analog_value() + print('set pot to %s, read analog: %s' % (i, an)) + sleep(0.1) + + From c13cb00147f7b5d764ffa20863dea77015776ab4 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 4 May 2016 11:20:28 +0200 Subject: [PATCH 300/344] doc: Supported hardware (#68) --- README.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.rst b/README.rst index 4a997ba..c64821c 100644 --- a/README.rst +++ b/README.rst @@ -102,6 +102,21 @@ code all night long! if you like this project and you want to support us, `please donate using Paypal `__ +Supported hardware +------------------ + +board: + - ATmega boards (ATtiny has not enough RAM) + +external hardware: + - BMP180 Digital pressure sensor + - AD9850 Direct Digital Synthesizer + - TLC5947 LED Driver + - DHT11, DHT22, DHT21, AM2301 humidity sensors + - HD44780 LCD controller + - PCF8574 8-Bit I/O Expander for I2C + - X9C1xxx (xxx = 102,103,104,503) digital potentiometers + License ------- From 9661d75d349ead8fb01c9ee43c1bd8ad1a8b7ab9 Mon Sep 17 00:00:00 2001 From: ponty Date: Wed, 4 May 2016 11:23:50 +0200 Subject: [PATCH 301/344] support esp8266 --- README.rst | 1 + nanpy/arduinotree.py | 40 ++++++++++-- nanpy/classinfo.py | 4 +- nanpy/define.py | 5 +- nanpy/esp.py | 109 ++++++++++++++++++++++++++++++++ nanpy/examples/blink_esp8266.py | 19 ++++++ nanpy/examples/dump.py | 83 +++++++++++++++++------- nanpy/sockconnection.py | 53 ++++++++++++++++ 8 files changed, 282 insertions(+), 32 deletions(-) create mode 100644 nanpy/esp.py create mode 100755 nanpy/examples/blink_esp8266.py create mode 100644 nanpy/sockconnection.py diff --git a/README.rst b/README.rst index c64821c..550d0e6 100644 --- a/README.rst +++ b/README.rst @@ -107,6 +107,7 @@ Supported hardware board: - ATmega boards (ATtiny has not enough RAM) + - ESP8266 (communication over serial or WiFi connection) external hardware: - BMP180 Digital pressure sensor diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py index 2f74ebc..6e89db7 100644 --- a/nanpy/arduinotree.py +++ b/nanpy/arduinotree.py @@ -1,8 +1,9 @@ from __future__ import division + from nanpy.arduinoapi import ArduinoApi from nanpy.arduinocore import ArduinoCore from nanpy.arduinopin import PinFeature -from nanpy.classinfo import ClassInfo +from nanpy.classinfo import ClassInfo, FirmwareMissingFeatureError from nanpy.counter import Counter from nanpy.define import DefineFeature from nanpy.eeprom import EEPROM @@ -16,6 +17,8 @@ from nanpy.wire import Wire import time +from nanpy.esp import Esp + class ArduinoTree(object): @@ -46,6 +49,14 @@ def api(self): @memoized def pin(self): """Object-oriented representation of an Arduino pin""" +# if not self.register: +# return None +# if not self.define: +# return None +# if not self.core: +# return None +# if not self.ram: +# return None return PinFeature(self.define, self.register, self.core, self.ram, self.api) @property @@ -58,7 +69,10 @@ def define(self): @memoized def register(self): """Direct access to AVR registers.""" - return RegisterFeature(self.connection) + try: + return RegisterFeature(self.connection) + except FirmwareMissingFeatureError: + return None @property @memoized @@ -76,7 +90,10 @@ def eeprom(self): @memoized def ram(self): """Access to RAM.""" - return RAM(self.connection) + try: + return RAM(self.connection) + except FirmwareMissingFeatureError: + return None @property @memoized @@ -88,12 +105,19 @@ def counter(self): @memoized def core(self): """Access to Arduino functions which are not part of the public API.""" - return ArduinoCore(self.connection) + try: + return ArduinoCore(self.connection) + except FirmwareMissingFeatureError: + return None @property @memoized def vcc(self): """Access to VCC.""" + if not self.register: + return None + if not self.define: + return None return Vcc(self.register, MCU=self.define.get('MCU')) def soft_reset(self): @@ -121,3 +145,11 @@ def wire(self): def firmware_info(self): """""" return firmware_info(self.define.as_dict) + + @property + @memoized + def esp(self): + try: + return Esp(self.connection) + except FirmwareMissingFeatureError: + return None diff --git a/nanpy/classinfo.py b/nanpy/classinfo.py index e5f1033..7433fe4 100644 --- a/nanpy/classinfo.py +++ b/nanpy/classinfo.py @@ -2,7 +2,7 @@ from nanpy.memo import memoized -class FirmwareError(Exception): +class FirmwareMissingFeatureError(Exception): pass @@ -21,7 +21,7 @@ def getinstance(connection): if not hasattr(connection, 'classinfo'): connection.classinfo = ClassInfo(connection) if cls_name not in connection.classinfo.firmware_id_list: - raise FirmwareError( + raise FirmwareMissingFeatureError( '''%s ['%s'] is missing from firmware!''' % (cls, cls_name)) return cls(connection) diff --git a/nanpy/define.py b/nanpy/define.py index 9ac3f11..062b598 100644 --- a/nanpy/define.py +++ b/nanpy/define.py @@ -67,7 +67,7 @@ def names(self): def count(self): return len(self.as_dict) - def get(self, name): + def get(self, name, defaultValue=None): """get a constant. Examples: @@ -82,4 +82,5 @@ def get(self, name): n = self._arr.name(i) if n == name: return self._arr.value(i) - raise ValueError('%s was not found!' % name) + return defaultValue +# raise ValueError('%s was not found!' % name) diff --git a/nanpy/esp.py b/nanpy/esp.py new file mode 100644 index 0000000..7dd6df4 --- /dev/null +++ b/nanpy/esp.py @@ -0,0 +1,109 @@ +from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass +from nanpy.classinfo import check4firmware +from nanpy.memo import memoized + + +@check4firmware +class Esp(FirmwareClass): + firmware_id = 'Esp' + + @arduinomethod + def wdtEnable(self): + pass + + @arduinomethod + def wdtDisable(self): + pass + + @arduinomethod + def wdtFeed(self): + pass + + @arduinomethod + def reset(self): + pass + + @arduinomethod + def restart(self): + pass + + @returns(int) + @arduinomethod + def getVcc(self): + pass + + @arduinomethod + def getFreeHeap(self): + pass + + @arduinomethod + def getChipId(self): + pass + + @arduinomethod + def getSdkVersion(self): + pass + + @arduinomethod + def getBootVersion(self): + pass + + @arduinomethod + def getBootMode(self): + pass + + @arduinomethod + def getCpuFreqMHz(self): + pass + + @arduinomethod + def getFlashChipId(self): + pass + + @arduinomethod + def getFlashChipRealSize(self): + pass + + @arduinomethod + def getFlashChipSize(self): + pass + + @arduinomethod + def getFlashChipSpeed(self): + pass + + @arduinomethod + def getFlashChipMode(self): + pass + + @arduinomethod + def getFlashChipSizeByChipId(self): + pass + + @arduinomethod + def getResetReason(self): + pass + + @arduinomethod + def getResetInfo(self): + pass + + @arduinomethod + def getSketchSize(self): + pass + + @arduinomethod + def getFreeSketchSpace(self): + pass + + @arduinomethod + def flashEraseSector(self): + pass + + @arduinomethod + def flashWrite(self): + pass + + @arduinomethod + def flashRead(self): + pass diff --git a/nanpy/examples/blink_esp8266.py b/nanpy/examples/blink_esp8266.py new file mode 100755 index 0000000..76eae01 --- /dev/null +++ b/nanpy/examples/blink_esp8266.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +from nanpy import ArduinoApi +from time import sleep +from nanpy.sockconnection import SocketManager +# import logging +# logging.basicConfig(level=logging.DEBUG) + +PIN=2 + +connection = SocketManager() +a = ArduinoApi(connection=connection) + +a.pinMode(PIN, a.OUTPUT) + +for i in range(10000): + a.digitalWrite(PIN, (i + 1) % 2) + sleep(0.2) + diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py index d014704..e50a50c 100644 --- a/nanpy/examples/dump.py +++ b/nanpy/examples/dump.py @@ -1,9 +1,12 @@ """Dump all possible values from the AVR.""" +import inspect from nanpy.arduinotree import ArduinoTree from nanpy.serialmanager import SerialManager from pprint import pprint -import inspect +from nanpy.classinfo import FirmwareMissingFeatureError +# import logging +# logging.basicConfig(level=logging.DEBUG) FORMAT = '%-20s = %20s' @@ -24,13 +27,19 @@ def dump_dict(d): defvalue = d[defname] print(FORMAT % (defname, defvalue)) +def myprint(template, name, func): + try: + print(template % (name, func())) + except FirmwareMissingFeatureError: + pass def dumpall(): connection = SerialManager() a = ArduinoTree(connection=connection) - print((FORMAT + ' V') % ('read_vcc', a.vcc.read())) - print((FORMAT + ' sec') % ('millis', a.api.millis() / 1000.0)) + if a.vcc: + myprint(FORMAT + ' V', 'read_vcc', lambda : a.vcc.read()) + myprint(FORMAT + ' sec', 'uptime', lambda : a.api.millis() / 1000.0) print('') print('================================') @@ -41,14 +50,43 @@ def dumpall(): print('unknown ids:') pprint(a.connection.classinfo.unknown_firmware_ids) + print('') + print('================================') + print('defines:') + print('================================') + dump_dict(a.define.as_dict) + + if a.esp: + print('') + print('================================') + print('ESP:') + print('================================') + myprint(FORMAT , 'getVcc', lambda :a.esp.getVcc()) + myprint(FORMAT , 'getFreeHeap', lambda :a.esp.getFreeHeap()) + myprint(FORMAT , 'getChipId', lambda :a.esp.getChipId()) + myprint(FORMAT , 'getSdkVersion', lambda :a.esp.getSdkVersion()) + myprint(FORMAT , 'getBootVersion', lambda :a.esp.getBootVersion()) + myprint(FORMAT , 'getBootMode', lambda :a.esp.getBootMode()) + myprint(FORMAT , 'getCpuFreqMHz', lambda :a.esp.getCpuFreqMHz()) + myprint(FORMAT , 'getFlashChipId', lambda :a.esp.getFlashChipId()) + myprint(FORMAT , 'getFlashChipRealSize', lambda :a.esp.getFlashChipRealSize()) + myprint(FORMAT , 'getFlashChipSize', lambda :a.esp.getFlashChipSize()) + myprint(FORMAT , 'getFlashChipSpeed', lambda :a.esp.getFlashChipSpeed()) + myprint(FORMAT , 'getFlashChipMode', lambda :a.esp.getFlashChipMode()) + myprint(FORMAT , 'getFlashChipSizeByChipId', lambda :a.esp.getFlashChipSizeByChipId()) + myprint(FORMAT , 'getResetReason', lambda :a.esp.getResetReason()) + myprint(FORMAT , 'getResetInfo', lambda :a.esp.getResetInfo()) + myprint(FORMAT , 'getSketchSize', lambda :a.esp.getSketchSize()) + myprint(FORMAT , 'getFreeSketchSpace', lambda :a.esp.getFreeSketchSpace()) + print('') print('================================') print('pins:') print('================================') - print(FORMAT % ('total_pin_count', a.pin.count)) - print(FORMAT % ('digital_names', a.pin.names_digital)) - print(FORMAT % ('analog_names', a.pin.names_analog)) + myprint(FORMAT , 'total_pin_count', lambda :a.pin.count) + myprint(FORMAT , 'digital_names', lambda :a.pin.names_digital) + myprint(FORMAT , 'analog_names', lambda :a.pin.names_analog) for pin_number in range(a.pin.count): print('---------- pin_number=%s ---------------' % pin_number) @@ -65,25 +103,22 @@ def dumpall(): wgm '''.split()) - print('') - print('================================') - print('defines:') - print('================================') - dump_dict(a.define.as_dict) - - print('') - print('================================') - print('registers:') - print('================================') - for x in a.register.names: - r = a.register.get(x) - if r.size == 2: - v = '0x%04X' % (r.value) - else: - v = ' 0x%02X' % (r.value) - - print('%-20s = %s @0x%2X (size:%s)' % (r.name, v, r.address, r.size)) + if a.register: + print('') + print('================================') + print('registers:') + print('================================') + for x in a.register.names: + r = a.register.get(x) + if r.size == 2: + v = '0x%04X' % (r.value) + else: + v = ' 0x%02X' % (r.value) + + print('%-20s = %s @0x%2X (size:%s)' % (r.name, v, r.address, r.size)) + + if __name__ == '__main__': dumpall() diff --git a/nanpy/sockconnection.py b/nanpy/sockconnection.py new file mode 100644 index 0000000..650d1ba --- /dev/null +++ b/nanpy/sockconnection.py @@ -0,0 +1,53 @@ +import logging +import socket + +log = logging.getLogger(__name__) + + +class SocketManagerError(Exception): + pass + + +class SocketManager(object): + _socket = None + + def __init__(self, host='nanpy.local', port=5678): + self.host = host + self.port = port + + def open(self): + log.debug('opening:%s:%s', self.host, self.port) + self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self._socket.connect((self.host, self.port)) + + def close(self): + log.debug('closing:%s:%s', self.host, self.port) + if self._socket: + self._socket.close() + self._socket = None + + def write(self, value): + if not self._socket: + self.open() + log.debug('sending:%s', repr(value)) + self._socket.sendall(value) + + def readline(self): + if not self._socket: + self.open() + s = '' + while 1: + c = self._socket.recv(1) + if c == '\r': + continue + if c == '\n': + break + if c == '': + break + s += c + + log.debug('received:%s', repr(s)) + s = s.decode() + if not len(s): + raise SocketManagerError('timeout!') + return s From 7a95026b5c02f067fdfbcefda42f3b8bd63bf6b7 Mon Sep 17 00:00:00 2001 From: Trey Garrison Date: Fri, 9 Sep 2016 16:15:29 -0500 Subject: [PATCH 302/344] MCP41xxx addition --- nanpy/MCP41xxx.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 nanpy/MCP41xxx.py diff --git a/nanpy/MCP41xxx.py b/nanpy/MCP41xxx.py new file mode 100644 index 0000000..69b29d0 --- /dev/null +++ b/nanpy/MCP41xxx.py @@ -0,0 +1,14 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import (arduinoobjectmethod, returns) + +class MCP41xxx(ArduinoObject): + + def __init__(self, dac, connection=None): + ArduinoObject.__init__(self, connection=connection) + self.id = self.call('new', dac) + + + @arduinoobjectmethod + def analogWrite(self, gate, value): + pass + From 7b2b52a2d28a831ad0a59cc74528f0447b72cc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=94ndrea=20Stagi?= Date: Fri, 23 Sep 2016 17:58:42 +0200 Subject: [PATCH 303/344] Update CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 82bde08..b288d42 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -18,3 +18,4 @@ Contributors - Balz Reber (https://github.com/balzreber) - Michal Opler (https://github.com/joppi) - Stefan Krastanov (https://github.com/Krastanov) +- egarris2 (https://github.com/egarris2) From d1e7cd1cbc582516cd4345b21567018f01b045bb Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 6 Oct 2016 08:47:12 +0200 Subject: [PATCH 304/344] soft reset demo: comment --- nanpy/examples/reset.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/nanpy/examples/reset.py b/nanpy/examples/reset.py index 9d30873..f4546c3 100755 --- a/nanpy/examples/reset.py +++ b/nanpy/examples/reset.py @@ -1,4 +1,23 @@ -"""soft reset demo.""" +"""soft reset demo. + +https://github.com/nanpy/nanpy/issues/72 + +watchdog doesn't work with some bootloaders. +Soft_reset() is based on watchdog. + +More information: +http://arduino.stackexchange.com/questions/2922/watchdog-timer-stuck-in-restart-loop-green-led-flashing +"The OP is using an Adriuni Pro Mini clone. +The included bootloader on the Arduino Pro Mini +does not support system restarts by the WDT. +Essentially, on a device with a bootloader +that does not support WDT restarts, +the board will restart but the timer / reset will not causing +the board to continuously reset on reboot. +There are alternative bootloaders for arduino boards +that may resolve this issue." + +""" from nanpy.arduinotree import ArduinoTree from nanpy.serialmanager import SerialManager From 4838e400197c5b76ad1e518202892a3a186280ee Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 28 Nov 2016 09:55:02 +0100 Subject: [PATCH 305/344] README: Bug reports --- README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.rst b/README.rst index 550d0e6..27106dd 100644 --- a/README.rst +++ b/README.rst @@ -102,6 +102,16 @@ code all night long! if you like this project and you want to support us, `please donate using Paypal `__ +Bug reports +----------- + +- try to test the function without Nanpy, using only Arduino. If the problem remains then it is not a Nanpy bug. +- enable logging: `import logging;logging.basicConfig(level=logging.DEBUG)` +- attach the log messages +- attach your program. The program should be as small as possible which demonstrates the bug. +- check cfg.h. All needed functions are enabled? +- attach your cfg.h + Supported hardware ------------------ From 0cf1eea3adfe60a095802c6d5740e5381a1c2739 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 16 Dec 2016 15:39:24 +0100 Subject: [PATCH 306/344] README --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 27106dd..ad33ac5 100644 --- a/README.rst +++ b/README.rst @@ -105,6 +105,7 @@ Paypal Date: Wed, 8 Feb 2017 13:29:35 -0500 Subject: [PATCH 307/344] Experimental PulseIn Uses the function parameters "pin" and "value" --- nanpy/arduinoapi.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nanpy/arduinoapi.py b/nanpy/arduinoapi.py index df1a040..339a767 100644 --- a/nanpy/arduinoapi.py +++ b/nanpy/arduinoapi.py @@ -39,6 +39,11 @@ def pinMode(self, pin, mode): def millis(self): pass + @returns(int) + @arduinomethod('pi') + def shiftOut(self, pin, value): + pass + @returns(int) @arduinomethod('s') def shiftOut(self, dataPin, clockPin, bitOrder, value): From 88259e51e2d719d695defe8bbccb0734d7d63b03 Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Thu, 9 Feb 2017 15:52:37 -0500 Subject: [PATCH 308/344] Fixed function naming error --- nanpy/arduinoapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/arduinoapi.py b/nanpy/arduinoapi.py index 339a767..930d7d4 100644 --- a/nanpy/arduinoapi.py +++ b/nanpy/arduinoapi.py @@ -41,7 +41,7 @@ def millis(self): @returns(int) @arduinomethod('pi') - def shiftOut(self, pin, value): + def pulseIn(self, pin, value): pass @returns(int) From 2f3b2b96633107495948d90167d552967963fab2 Mon Sep 17 00:00:00 2001 From: ponty Date: Sat, 18 Feb 2017 19:05:56 +0100 Subject: [PATCH 309/344] DHT: make DHT example simple again --- nanpy/examples/dht.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/nanpy/examples/dht.py b/nanpy/examples/dht.py index ff524bf..411b27f 100755 --- a/nanpy/examples/dht.py +++ b/nanpy/examples/dht.py @@ -6,15 +6,9 @@ # http://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor # DHT sensor connected to digital pin 10 -dhts = [ - DHT(6, DHT.DHT11), - DHT(7, DHT.DHT11), - DHT(8, DHT.DHT11) -] +dht = DHT(10, DHT.DHT22) -for i, dht in enumerate(dhts): - print("DHT %d" % i) - print("Temperature is %.2f degrees Celcius" % dht.readTemperature(False)) - print("Temperature is %.2f degrees Fahrenheit" % dht.readTemperature(True)) - print("Humidity is %.2f %%" % dht.readHumidity()) +print("Temperature is %.2f degrees Celcius" % dht.readTemperature(False)) +print("Temperature is %.2f degrees Fahrenheit" % dht.readTemperature(True)) +print("Humidity is %.2f %%" % dht.readHumidity()) From 6387a28348e82b3c15985bff6469dfdd2ddabdf3 Mon Sep 17 00:00:00 2001 From: ponty Date: Sat, 18 Feb 2017 19:56:19 +0100 Subject: [PATCH 310/344] dallas: parameter can be address_or_index --- nanpy/dallastemperature.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 7ae04b6..7b3a04f 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -31,17 +31,17 @@ def getAddress(self, index): @arduinoobjectmethod - def requestTemperatures(self, address = None): + def requestTemperatures(self, address_or_index = None): pass @returns(float) @arduinoobjectmethod - def getTempC(self, address): + def getTempC(self, address_or_index): pass @returns(float) @arduinoobjectmethod - def getTempF(self, address): + def getTempF(self, address_or_index): pass @classmethod From 2012283ada5c7010c05ed6014471411e2889e1b7 Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Fri, 3 Mar 2017 10:38:40 -0500 Subject: [PATCH 311/344] Added ultrasonic module to nanpy --- nanpy/__init__.py | 5 ++++- nanpy/ultrasonic.py | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 nanpy/ultrasonic.py diff --git a/nanpy/__init__.py b/nanpy/__init__.py index a7d29a0..a046450 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -24,4 +24,7 @@ from nanpy.arduinoapi import ArduinoApi from nanpy.eeprom import EEPROM -from nanpy.TLC5947 import TLC5947 \ No newline at end of file +from nanpy.TLC5947 import TLC5947 + +# GW-Robotics Modules +from nanpy.ultrasonic import Ultrasonic diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py new file mode 100644 index 0000000..6197ba0 --- /dev/null +++ b/nanpy/ultrasonic.py @@ -0,0 +1,19 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import (arduinoobjectmethod, returns) + +class Ultrasonic(ArduinoOject): + + def __init__(self, echo, trig, connecion=None): + ArduinoObject.__init__(self, connection=connection) + self.id = self.call('new', echo, trig) + + @returns(float) + @arduinoobjectmethod + def get_distance(self): + pass + + @returns(float) + @arduinoobjectmethod + def reading_in_range(self, low, high): + pass + From 3c0bafbc2d5664a1c92b64bc255497fca7fa4550 Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Fri, 3 Mar 2017 12:47:51 -0500 Subject: [PATCH 312/344] Added useInches as ultrasonic parameter --- nanpy/ultrasonic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index 6197ba0..bc9a77b 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -3,9 +3,9 @@ class Ultrasonic(ArduinoOject): - def __init__(self, echo, trig, connecion=None): + def __init__(self, echo, trig, useInches, connecion=None): ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', echo, trig) + self.id = self.call('new', echo, trig, useInches) @returns(float) @arduinoobjectmethod From b6334b44a5487628a4582d4a6d26aeba6e54a841 Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Sat, 4 Mar 2017 01:22:45 -0500 Subject: [PATCH 313/344] Fixed spelling error --- nanpy/ultrasonic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index bc9a77b..ce267dd 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -1,7 +1,7 @@ from nanpy.arduinoboard import ArduinoObject from nanpy.arduinoboard import (arduinoobjectmethod, returns) -class Ultrasonic(ArduinoOject): +class Ultrasonic(ArduinoObject): def __init__(self, echo, trig, useInches, connecion=None): ArduinoObject.__init__(self, connection=connection) From 99ede2fa454ec1afe07e58fd55b5ac9cc4a35f63 Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Sat, 4 Mar 2017 01:29:21 -0500 Subject: [PATCH 314/344] Fixed typo --- nanpy/ultrasonic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index ce267dd..85bfc39 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -3,7 +3,7 @@ class Ultrasonic(ArduinoObject): - def __init__(self, echo, trig, useInches, connecion=None): + def __init__(self, echo, trig, useInches, connection=None): ArduinoObject.__init__(self, connection=connection) self.id = self.call('new', echo, trig, useInches) From b9460d54cdad7c389c72c8b2574659ed16a2dd08 Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Sat, 4 Mar 2017 01:58:14 -0500 Subject: [PATCH 315/344] Fixed type error --- nanpy/ultrasonic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index 85bfc39..83766f2 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -12,7 +12,7 @@ def __init__(self, echo, trig, useInches, connection=None): def get_distance(self): pass - @returns(float) + @returns(bool) @arduinoobjectmethod def reading_in_range(self, low, high): pass From 421ad646dcbbf0545b3650d73b0d58cd86ff4bf8 Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Sat, 4 Mar 2017 02:31:33 -0500 Subject: [PATCH 316/344] Fixed naming mismatch --- nanpy/ultrasonic.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index 83766f2..b493348 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -12,8 +12,6 @@ def __init__(self, echo, trig, useInches, connection=None): def get_distance(self): pass - @returns(bool) - @arduinoobjectmethod def reading_in_range(self, low, high): pass From b235fc753a9d4969d253c5adccd09758a9e1d7bc Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Sat, 4 Mar 2017 02:38:34 -0500 Subject: [PATCH 317/344] Fixed no return type --- nanpy/ultrasonic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index b493348..83766f2 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -12,6 +12,8 @@ def __init__(self, echo, trig, useInches, connection=None): def get_distance(self): pass + @returns(bool) + @arduinoobjectmethod def reading_in_range(self, low, high): pass From 0cd7c833558e7dabc990aa8ad0e1b1d79ab8dcc8 Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Sat, 4 Mar 2017 02:51:03 -0500 Subject: [PATCH 318/344] Moved reading_in_range to just python --- nanpy/ultrasonic.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index 83766f2..592dc95 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -12,8 +12,6 @@ def __init__(self, echo, trig, useInches, connection=None): def get_distance(self): pass - @returns(bool) - @arduinoobjectmethod def reading_in_range(self, low, high): - pass + return get_distance() in frange(low, high) From bb320dcea882df62a361ca5ba4b41c3546b56e9c Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Sat, 4 Mar 2017 02:57:18 -0500 Subject: [PATCH 319/344] Fixes? --- nanpy/ultrasonic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index 592dc95..d3a8d19 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -13,5 +13,5 @@ def get_distance(self): pass def reading_in_range(self, low, high): - return get_distance() in frange(low, high) + return self.get_distance() in frange(low, high) From b467a73970ddfab5f0555e25ea3e6ce6a0044879 Mon Sep 17 00:00:00 2001 From: omn0mn0m Date: Sat, 4 Mar 2017 02:59:18 -0500 Subject: [PATCH 320/344] Uh... --- nanpy/ultrasonic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index d3a8d19..ec71f66 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -13,5 +13,5 @@ def get_distance(self): pass def reading_in_range(self, low, high): - return self.get_distance() in frange(low, high) + return low <= self.get_distance() <= high From 50a374983ff1a5e8687fc368248a569d83b6f00e Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Wed, 8 Mar 2017 16:29:36 -0500 Subject: [PATCH 321/344] Wrote experimental colour sensor code --- nanpy/__init__.py | 1 + nanpy/colorsensor.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 nanpy/colorsensor.py diff --git a/nanpy/__init__.py b/nanpy/__init__.py index a046450..35969ab 100644 --- a/nanpy/__init__.py +++ b/nanpy/__init__.py @@ -28,3 +28,4 @@ # GW-Robotics Modules from nanpy.ultrasonic import Ultrasonic +from nanpy.colorsensor import ColorSensor diff --git a/nanpy/colorsensor.py b/nanpy/colorsensor.py new file mode 100644 index 0000000..832e3a3 --- /dev/null +++ b/nanpy/colorsensor.py @@ -0,0 +1,13 @@ +from nanpy.arduinoboard import ArduinoObject +from nanpy.arduinoboard import (arduinoobjectmethod, returns) + +class ColorSensor(ArduinoObject): + + def __init__(self, s0, s1, s2, s3, sensorInput, connection=None): + ArduinoObject.__init__(self, connection=connection) + self.id = self.call('new', s0, s1, s2, s3, sensorInput) + + @returns(int) + @arduinoobjectmethod + def get_color(self, color): + pass From e81cdd7942a0870f83b8d6a0f7d4f5a92ab7d978 Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Wed, 22 Mar 2017 17:30:12 -0400 Subject: [PATCH 322/344] Added missing detach function Already implemented in hardware --- nanpy/servo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nanpy/servo.py b/nanpy/servo.py index b847bb9..f6f4a85 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -28,3 +28,7 @@ def readMicroseconds(self, value): @arduinoobjectmethod def attached(self): pass + + @arduinoobjectmethod + def detach(self): + pass From 7c00195137b92a885024f877c77e33663fba7b26 Mon Sep 17 00:00:00 2001 From: ponty Date: Sat, 1 Apr 2017 09:25:50 +0200 Subject: [PATCH 323/344] demo: improve and fix counterdemo --- nanpy/examples/counterdemo.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/nanpy/examples/counterdemo.py b/nanpy/examples/counterdemo.py index 5c6850f..dfafcd4 100644 --- a/nanpy/examples/counterdemo.py +++ b/nanpy/examples/counterdemo.py @@ -1,25 +1,36 @@ +"""This demo sets a PWM frequency on pin 5, then measures it using a counter. + +For measuring external frequency the PWM should be disabled. + +""" + from nanpy.arduinotree import ArduinoTree -import time from nanpy.serialmanager import SerialManager +import time +EXTERNAL_FREQUENCY = False GATE_TIME = 0.7 # sec -F = 9765 # Hz + +INPUT, OUTPUT = 0, 1 def counterdemo(): connection = SerialManager() a = ArduinoTree(connection=connection) p = a.pin.get(5) - a.soft_reset() - print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) - p.write_mode(1) - p.pwm.write_value(128) - p.pwm.frequency = F - print ('frequency set: %s' % p.pwm.frequency) + + if not EXTERNAL_FREQUENCY: + p.write_mode(OUTPUT) + p.pwm.write_value(128) + p.pwm.frequency = p.pwm.frequencies_available[-2] + print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) + print ('frequency set: %s' % p.pwm.frequency) + t1 = time.time() fread = a.counter.read_frequency(GATE_TIME) t2 = time.time() + print ('frequency read: %s' % fread) print ('gate time: %s sec' % (GATE_TIME)) print ('time elapsed: %s sec' % (t2 - t1)) From 701cb709f3dbdfeb8d4e5c9f262e86626d5777d3 Mon Sep 17 00:00:00 2001 From: ponty Date: Sat, 1 Apr 2017 09:54:00 +0200 Subject: [PATCH 324/344] demo: pwm_demo --- nanpy/examples/pwm_demo.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 nanpy/examples/pwm_demo.py diff --git a/nanpy/examples/pwm_demo.py b/nanpy/examples/pwm_demo.py new file mode 100644 index 0000000..020dddf --- /dev/null +++ b/nanpy/examples/pwm_demo.py @@ -0,0 +1,29 @@ +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager + +PIN = 5 + +# 0-255 +VALUE = 128 +DUTY_CYCLE = VALUE / 256.0 + +INPUT, OUTPUT = 0, 1 + + +def pwm_demo(): + connection = SerialManager() + a = ArduinoTree(connection=connection) + p = a.pin.get(PIN) + print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) + p.write_mode(OUTPUT) + p.pwm.write_value(VALUE) + + # set frequency here + p.pwm.frequency = 61 + + print ('PWM frequency: %s' % p.pwm.frequency) + print ('PWM duty cycle: %s %% ' % (DUTY_CYCLE * 100)) + + +if __name__ == '__main__': + pwm_demo() From a51418fa38304a2eb84c44b1effc47f60498f810 Mon Sep 17 00:00:00 2001 From: ponty Date: Sat, 1 Apr 2017 09:54:23 +0200 Subject: [PATCH 325/344] readme --- README.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.rst b/README.rst index ad33ac5..5db0cc6 100644 --- a/README.rst +++ b/README.rst @@ -112,6 +112,7 @@ Bug reports - attach your program. The program should be as small as possible which demonstrates the bug. - check cfg.h. All needed functions are enabled? - attach your cfg.h +- describe your hardware Supported hardware ------------------ @@ -129,6 +130,17 @@ external hardware: - PCF8574 8-Bit I/O Expander for I2C - X9C1xxx (xxx = 102,103,104,503) digital potentiometers +internal hardware: + - counter, frequency measurement + - PWM + - ADC + - I2C + - read, write RAM + - read, write EEPROM + - read, write all registers + - tone() + + License ------- From 42d362cbdbdda644a5322917833ad7d4594b8152 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 14 Apr 2017 14:29:42 +0200 Subject: [PATCH 326/344] pwm: check if register class available --- nanpy/pwm.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nanpy/pwm.py b/nanpy/pwm.py index c949a89..703bdd9 100644 --- a/nanpy/pwm.py +++ b/nanpy/pwm.py @@ -125,6 +125,8 @@ def divisors_available(self): def read_divisor(self): """read current divisor.""" + if self.register is None: + return self._check() d = divisor_mapping[self.nr] return d.norm[self.read_timer_mode()] @@ -153,6 +155,8 @@ def timer_register_name_b(self): return self._timer_register_name(variant='B') def read_timer_mode(self): + if self.register is None: + return reg_name = self.timer_register_name_b return self.register.get(reg_name).read_value() & timer_mask @@ -171,6 +175,8 @@ def base_divisor(self): return base_divisor[self.nr] def calculate_frequency(self, divisor): + if self.register is None: + return return 1.0 * self.F_CPU / self.base_divisor / divisor @property @@ -201,6 +207,8 @@ def write_frequency(self, value): def read_wgm(self): """read waveform generation mode.""" + if self.register is None: + return self._check() rega = self.timer_register_name_a regb = self.timer_register_name_b From 84a6154f8c51696770abe3be3ad27dbf9306e453 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 14 Apr 2017 14:30:05 +0200 Subject: [PATCH 327/344] ClassInfo: firmware_name_list --- nanpy/classinfo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nanpy/classinfo.py b/nanpy/classinfo.py index 7433fe4..b6fe75e 100644 --- a/nanpy/classinfo.py +++ b/nanpy/classinfo.py @@ -53,7 +53,8 @@ class ClassInfo(object): def __init__(self, connection): self.firmware_class_status = dict() self.unknown_firmware_ids = [] - + self.firmware_name_list = [] + self._arr = ClassInfoArray(connection=connection) ls = [self._arr.name(i) for i in range(self._arr.count)] @@ -66,6 +67,8 @@ def __init__(self, connection): for x in self.firmware_id_list: cls = check4firmware.names.get(x) if cls: + self.firmware_name_list.append(str(cls.__name__)) self.firmware_class_status[cls.__name__] = True else: + self.firmware_name_list.append(str(x)) self.unknown_firmware_ids.append(x) From 13498ea7a1adfc59d2b741263d9a2c5964133105 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 14 Apr 2017 14:30:43 +0200 Subject: [PATCH 328/344] example: print classes in dump.py --- nanpy/examples/dump.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py index e50a50c..d4a833e 100644 --- a/nanpy/examples/dump.py +++ b/nanpy/examples/dump.py @@ -45,10 +45,7 @@ def dumpall(): print('================================') print('firmware classes:') print('================================') - print('status:') - pprint(a.connection.classinfo.firmware_class_status) - print('unknown ids:') - pprint(a.connection.classinfo.unknown_firmware_ids) + pprint(a.connection.classinfo.firmware_name_list) print('') print('================================') From cb6141edafe81ab194bda43caa231b9e75b86bb0 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 14 Apr 2017 15:55:44 +0200 Subject: [PATCH 329/344] readme: add HC-SR04 (ultrasonic sensor) #87 --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5db0cc6..2b18b3a 100644 --- a/README.rst +++ b/README.rst @@ -25,7 +25,7 @@ I know, there are a lot of projects able to do that, but hey, Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many more... - + Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and show your first "Hello world"! :: @@ -118,7 +118,7 @@ Supported hardware ------------------ board: - - ATmega boards (ATtiny has not enough RAM) + - ATmega boards (ATtiny has not enough RAM) - ESP8266 (communication over serial or WiFi connection) external hardware: @@ -129,6 +129,7 @@ external hardware: - HD44780 LCD controller - PCF8574 8-Bit I/O Expander for I2C - X9C1xxx (xxx = 102,103,104,503) digital potentiometers + - HC-SR04 (ultrasonic sensor) internal hardware: - counter, frequency measurement From 70a77de2b2cf28f81c5162f9c24a38d906d44414 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 14 Apr 2017 16:25:28 +0200 Subject: [PATCH 330/344] readme: pwm is hardcoded (#73) --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2b18b3a..5a0cb68 100644 --- a/README.rst +++ b/README.rst @@ -133,7 +133,7 @@ external hardware: internal hardware: - counter, frequency measurement - - PWM + - PWM (advanced PWM functions are hardcoded for Uno compatible boards) - ADC - I2C - read, write RAM From 818adfb1b73ad9f7cd8868a4809e04e35ef20e77 Mon Sep 17 00:00:00 2001 From: ponty Date: Fri, 14 Apr 2017 19:25:06 +0200 Subject: [PATCH 331/344] log: message to help adding missing class to cfg.h --- nanpy/MCP41xxx.py | 1 + nanpy/TLC5947.py | 1 + nanpy/arduinoboard.py | 1 + nanpy/arduinocore.py | 1 + nanpy/capacitivesensor.py | 1 + nanpy/classinfo.py | 8 ++++++-- nanpy/colorsensor.py | 1 + nanpy/counter.py | 1 + nanpy/dallastemperature.py | 1 + nanpy/define.py | 1 + nanpy/dht.py | 1 + nanpy/eeprom.py | 1 + nanpy/lcd.py | 1 + nanpy/lcd_i2c.py | 1 + nanpy/onewire.py | 1 + nanpy/ram.py | 1 + nanpy/register.py | 1 + nanpy/servo.py | 1 + nanpy/stepper.py | 1 + nanpy/tone.py | 1 + nanpy/ultrasonic.py | 1 + nanpy/watchdog.py | 2 ++ nanpy/wire.py | 1 + 23 files changed, 29 insertions(+), 2 deletions(-) diff --git a/nanpy/MCP41xxx.py b/nanpy/MCP41xxx.py index 69b29d0..9f1ffc8 100644 --- a/nanpy/MCP41xxx.py +++ b/nanpy/MCP41xxx.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class MCP41xxx(ArduinoObject): + cfg_h_name = 'USE_MCP41xxx' def __init__(self, dac, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/TLC5947.py b/nanpy/TLC5947.py index 0466a80..2d1ee92 100644 --- a/nanpy/TLC5947.py +++ b/nanpy/TLC5947.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class TLC5947(ArduinoObject): + cfg_h_name = 'USE_TLC5947' def __init__(self, boardTotal, clock, data, latch, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py index 14e85e7..203d1b7 100644 --- a/nanpy/arduinoboard.py +++ b/nanpy/arduinoboard.py @@ -156,6 +156,7 @@ def call(self, *args): class FirmwareClass(object): connection = None firmware_id = None + cfg_h_name = 'missing implementation!' @classmethod def get_firmware_id(cls): diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py index eebcfea..46d8023 100644 --- a/nanpy/arduinocore.py +++ b/nanpy/arduinocore.py @@ -8,6 +8,7 @@ class ArduinoCore(FirmwareClass): """Access to Arduino functions which are not part of the public API.""" + cfg_h_name = 'USE_ArduinoCore' firmware_id = 'Core' @memoized diff --git a/nanpy/capacitivesensor.py b/nanpy/capacitivesensor.py index fc51d26..713e2de 100644 --- a/nanpy/capacitivesensor.py +++ b/nanpy/capacitivesensor.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class CapacitiveSensor(ArduinoObject): + cfg_h_name = 'USE_CapacitiveSensor' def __init__(self, pin1, pin2, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/classinfo.py b/nanpy/classinfo.py index b6fe75e..1b0b774 100644 --- a/nanpy/classinfo.py +++ b/nanpy/classinfo.py @@ -22,8 +22,11 @@ def getinstance(connection): connection.classinfo = ClassInfo(connection) if cls_name not in connection.classinfo.firmware_id_list: raise FirmwareMissingFeatureError( - '''%s ['%s'] is missing from firmware!''' % - (cls, cls_name)) + '''%s ['%s'] is missing from firmware! +Please enable it in your cfg.h: +#define %s 1 + ''' % + (cls, cls_name, cls.cfg_h_name)) return cls(connection) # getinstance.__name__ = cls.__name__ return getinstance @@ -31,6 +34,7 @@ def getinstance(connection): @check4firmware class ClassInfoArray(FirmwareClass): + cfg_h_name = 'USE_Info' firmware_id = 'Info' @property diff --git a/nanpy/colorsensor.py b/nanpy/colorsensor.py index 832e3a3..f5a0762 100644 --- a/nanpy/colorsensor.py +++ b/nanpy/colorsensor.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class ColorSensor(ArduinoObject): + cfg_h_name = 'USE_ColorSensor' def __init__(self, s0, s1, s2, s3, sensorInput, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/counter.py b/nanpy/counter.py index 1747748..3352867 100644 --- a/nanpy/counter.py +++ b/nanpy/counter.py @@ -6,6 +6,7 @@ @check4firmware class CounterLib(FirmwareClass): + cfg_h_name = 'USE_Counter' firmware_id = 'Counter' @arduinomethod diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py index 7b3a04f..080e156 100644 --- a/nanpy/dallastemperature.py +++ b/nanpy/dallastemperature.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class DallasTemperature(ArduinoObject): + cfg_h_name = 'USE_DallasTemperature' def __init__(self, pin, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/define.py b/nanpy/define.py index 062b598..f4c1bed 100644 --- a/nanpy/define.py +++ b/nanpy/define.py @@ -12,6 +12,7 @@ def auto_convert(x): @check4firmware class DefineArray(FirmwareClass): + cfg_h_name = 'USE_Define' firmware_id = 'D' @property diff --git a/nanpy/dht.py b/nanpy/dht.py index f0b8302..17cd5cb 100644 --- a/nanpy/dht.py +++ b/nanpy/dht.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class DHT(ArduinoObject): + cfg_h_name = 'USE_DHT' DHT11 = 11 DHT22 = 22 diff --git a/nanpy/eeprom.py b/nanpy/eeprom.py index c239039..902dbbb 100644 --- a/nanpy/eeprom.py +++ b/nanpy/eeprom.py @@ -5,6 +5,7 @@ @check4firmware class EEPROM(FirmwareClass): + cfg_h_name = 'USE_EEPROM' firmware_id = 'EEPROM' @arduinomethod diff --git a/nanpy/lcd.py b/nanpy/lcd.py index f3d463f..49b6b37 100644 --- a/nanpy/lcd.py +++ b/nanpy/lcd.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import arduinoobjectmethod class Lcd(ArduinoObject): + cfg_h_name = 'USE_LiquidCrystal' def __init__(self, pins, begin, connection=None): ''' diff --git a/nanpy/lcd_i2c.py b/nanpy/lcd_i2c.py index c0c2139..e0b2b7f 100644 --- a/nanpy/lcd_i2c.py +++ b/nanpy/lcd_i2c.py @@ -3,6 +3,7 @@ class Lcd_I2C(ArduinoObject): + cfg_h_name = 'USE_LiquidCrystal_I2C' def __init__(self, pins, begin, connection=None): ''' diff --git a/nanpy/onewire.py b/nanpy/onewire.py index c1a4a85..0377ed2 100644 --- a/nanpy/onewire.py +++ b/nanpy/onewire.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class OneWire(ArduinoObject): + cfg_h_name = 'USE_OneWire' def __init__(self, pin, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/ram.py b/nanpy/ram.py index 3b0ecfc..bd2a3b1 100644 --- a/nanpy/ram.py +++ b/nanpy/ram.py @@ -5,6 +5,7 @@ @check4firmware class RAM(FirmwareClass): + cfg_h_name = 'USE_RAM' firmware_id = 'RAM' @arduinomethod diff --git a/nanpy/register.py b/nanpy/register.py index 6efd239..49eda01 100644 --- a/nanpy/register.py +++ b/nanpy/register.py @@ -5,6 +5,7 @@ @check4firmware class RegisterArray(FirmwareClass): + cfg_h_name = 'USE_Register' firmware_id = 'R' @memoized diff --git a/nanpy/servo.py b/nanpy/servo.py index f6f4a85..1a1fe53 100644 --- a/nanpy/servo.py +++ b/nanpy/servo.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class Servo(ArduinoObject): + cfg_h_name = 'USE_Servo' def __init__(self, pin, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/stepper.py b/nanpy/stepper.py index 55cdd24..b38d19e 100644 --- a/nanpy/stepper.py +++ b/nanpy/stepper.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import arduinoobjectmethod class Stepper(ArduinoObject): + cfg_h_name = 'USE_Stepper' def __init__(self, revsteps, pin1, pin2, speed=None, connection=None, pin3=None, pin4=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/tone.py b/nanpy/tone.py index 76f2227..0837ed6 100644 --- a/nanpy/tone.py +++ b/nanpy/tone.py @@ -4,6 +4,7 @@ class Tone(ArduinoObject): + cfg_h_name = 'USE_Tone' NOTE_B0 = 31 NOTE_C1 = 33 diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py index ec71f66..a00ae4d 100644 --- a/nanpy/ultrasonic.py +++ b/nanpy/ultrasonic.py @@ -2,6 +2,7 @@ from nanpy.arduinoboard import (arduinoobjectmethod, returns) class Ultrasonic(ArduinoObject): + cfg_h_name = 'USE_Ultrasonic' def __init__(self, echo, trig, useInches, connection=None): ArduinoObject.__init__(self, connection=connection) diff --git a/nanpy/watchdog.py b/nanpy/watchdog.py index 6427f42..a0648c5 100644 --- a/nanpy/watchdog.py +++ b/nanpy/watchdog.py @@ -10,6 +10,8 @@ class Watchdog(FirmwareClass): Details: http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html """ + cfg_h_name = 'USE_Watchdog' + WDTO_15MS = 0 WDTO_30MS = 1 WDTO_60MS = 2 diff --git a/nanpy/wire.py b/nanpy/wire.py index 0b1cc61..5781e88 100644 --- a/nanpy/wire.py +++ b/nanpy/wire.py @@ -9,6 +9,7 @@ class Wire(FirmwareClass): http://arduino.cc/en/reference/wire """ firmware_id = 'Wire' + cfg_h_name = 'USE_Wire' @arduinomethod def begin(self, address=None): From 28673ba310468709845da722bc406673fde3b031 Mon Sep 17 00:00:00 2001 From: ponty Date: Tue, 18 Apr 2017 16:23:27 +0200 Subject: [PATCH 332/344] comments --- nanpy/arduinocore.py | 10 ++++++---- nanpy/arduinopin.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py index 46d8023..464b7b7 100644 --- a/nanpy/arduinocore.py +++ b/nanpy/arduinocore.py @@ -6,7 +6,9 @@ @check4firmware class ArduinoCore(FirmwareClass): - """Access to Arduino functions which are not part of the public API.""" + """Access to Arduino functions which are not part of the public API. + AVR only. SAM has different interface. + """ cfg_h_name = 'USE_ArduinoCore' firmware_id = 'Core' @@ -41,7 +43,7 @@ def analogInPinToBit(self, pin): def portOutputRegister(self, port): """nonpublic Arduino function. - @return: RAM address + @return: address """ @@ -51,7 +53,7 @@ def portOutputRegister(self, port): def portInputRegister(self, port): """nonpublic Arduino function. - @return: RAM address + @return: address """ @@ -61,6 +63,6 @@ def portInputRegister(self, port): def portModeRegister(self, port): """nonpublic Arduino function. - @return: RAM address + @return: address """ diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py index 55b9ad2..960bf63 100644 --- a/nanpy/arduinopin.py +++ b/nanpy/arduinopin.py @@ -91,6 +91,7 @@ def is_analog(self): @property def avr_port(self): '''AVR port name (example: "B") + AVR only. ''' x = self.core.digitalPinToPort(self.pin_number) return chr(ord('A') + x - 1) @@ -98,6 +99,7 @@ def avr_port(self): @property def avr_bit(self): '''AVR bit name (example: "2") + AVR only. ''' bitmask = self.core.digitalPinToBitMask(self.pin_number) i = 0 From a0f4ce2299aa8fad187f12489d31f8116f0aa570 Mon Sep 17 00:00:00 2001 From: ponty Date: Mon, 22 May 2017 21:11:18 +0200 Subject: [PATCH 333/344] readme: install from github (#91) --- README.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.rst b/README.rst index 5a0cb68..56c995c 100644 --- a/README.rst +++ b/README.rst @@ -87,6 +87,15 @@ To install Nanpy Python library on your master device just type: pip install nanpy +To uninstall:: + + pip uninstall nanpy + +To install the latest version from Github:: + + pip install https://github.com/nanpy/nanpy/archive/master.zip + + How to contribute ----------------- From ec672be0148c7b067cbeab9fec6763b93a7fcc17 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 25 May 2017 17:56:48 +0200 Subject: [PATCH 334/344] new: firmware_check.py --- nanpy/examples/firmware_check.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 nanpy/examples/firmware_check.py diff --git a/nanpy/examples/firmware_check.py b/nanpy/examples/firmware_check.py new file mode 100644 index 0000000..a7f7e2f --- /dev/null +++ b/nanpy/examples/firmware_check.py @@ -0,0 +1,19 @@ +from nanpy.arduinotree import ArduinoTree +from nanpy.serialmanager import SerialManager + + +def fw_check(): + connection = SerialManager() + a = ArduinoTree(connection=connection) + + print('Firmware classes enabled in cfg.h:') + print(' ' + '\n '.join(a.connection.classinfo.firmware_name_list)) + + d = a.define.as_dict + print( + '\nYour firmware was built on:\n %s %s' % + (d.get('__DATE__'), d.get('__TIME__'))) + + +if __name__ == '__main__': + fw_check() From c19fb8673880e8648cc87a47bafdeeebcd56b155 Mon Sep 17 00:00:00 2001 From: ponty Date: Thu, 25 May 2017 18:05:05 +0200 Subject: [PATCH 335/344] new: ISSUE_TEMPLATE.py --- ISSUE_TEMPLATE.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 3 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 ISSUE_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..89128e1 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,47 @@ + + +Make sure these boxes are checked before submitting your issue - thank you! + +- [ ] Try `examples/blink.py` +- [ ] Try to test the function without Nanpy, using only Arduino code. +- [ ] Check cfg.h. All needed functions are enabled? +- [ ] Run `examples/firmware_check.py` to check cfg.h again. All needed functions are listed? +- [ ] Your program should be as small as possible which demonstrates the bug. +- [ ] Enable logging in program: `import logging;logging.basicConfig(level=logging.DEBUG)` + + +### Your Python code + + +```python +import logging +logging.basicConfig(level=logging.DEBUG) + +from nanpy import ... +``` + +### Your log messages + +``` +DEBUG:nanpy.serialmanager:opening port:/dev/ttyACM0 [115200 baud] +... +``` + +### Your cfg.h + +```c +#define USE_Info 1 +... +``` +### Output of examples/firmware_check.py + +``` +Firmware classes enabled in cfg.h: + ... +``` + +### Your hardware + +- Arduino board: ` ` +- Additional hardware: ` ` + diff --git a/README.rst b/README.rst index 56c995c..f2cc304 100644 --- a/README.rst +++ b/README.rst @@ -115,11 +115,12 @@ Bug reports ----------- - try the blink.py example -- try to test the function without Nanpy, using only Arduino. If the problem remains then it is not a Nanpy bug. +- try to test the function without Nanpy, using only Arduino code. If the problem remains then it is not a Nanpy bug. - enable logging: `import logging;logging.basicConfig(level=logging.DEBUG)` - attach the log messages - attach your program. The program should be as small as possible which demonstrates the bug. - check cfg.h. All needed functions are enabled? +- Run `examples/firmware_check.py` to check cfg.h again. All needed functions are listed? - attach your cfg.h - describe your hardware From 7fa648ad915e7201ca81c3d73f040a745de4594d Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Mon, 7 Oct 2019 18:12:34 -0500 Subject: [PATCH 336/344] fixed socket connection and added py3 support --- nanpy/sockconnection.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nanpy/sockconnection.py b/nanpy/sockconnection.py index 650d1ba..885ae5f 100644 --- a/nanpy/sockconnection.py +++ b/nanpy/sockconnection.py @@ -30,19 +30,20 @@ def write(self, value): if not self._socket: self.open() log.debug('sending:%s', repr(value)) - self._socket.sendall(value) + self._socket.sendall(bytes(value, 'latin-1')) def readline(self): if not self._socket: self.open() - s = '' + s = b'' while 1: c = self._socket.recv(1) - if c == '\r': + log.debug('recv: %s', repr(c.decode())) + if c.decode() == '\r': continue - if c == '\n': + if c.decode() == '\n': break - if c == '': + if c.decode() == '': break s += c From 148ffb9c3736f46e2b217e9cb68afcabf3ce2646 Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Sat, 19 Oct 2019 12:36:15 -0500 Subject: [PATCH 337/344] Added timeout to socket connection Added timeout to prevent haning on socket and allow for reconnections. --- nanpy/sockconnection.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nanpy/sockconnection.py b/nanpy/sockconnection.py index 885ae5f..c255717 100644 --- a/nanpy/sockconnection.py +++ b/nanpy/sockconnection.py @@ -18,7 +18,11 @@ def __init__(self, host='nanpy.local', port=5678): def open(self): log.debug('opening:%s:%s', self.host, self.port) self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self._socket.connect((self.host, self.port)) + self._socket.settimeout(120) + try: + self._socket.connect((self.host, self.port)) + except OSError: + raise SocketManagerError('Host not found!') def close(self): log.debug('closing:%s:%s', self.host, self.port) @@ -37,6 +41,7 @@ def readline(self): self.open() s = b'' while 1: + self._socket.settimeout(120) c = self._socket.recv(1) log.debug('recv: %s', repr(c.decode())) if c.decode() == '\r': From 755609c96be2647a546d30ef878c244c77370c2a Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Mon, 21 Oct 2019 11:30:06 -0500 Subject: [PATCH 338/344] Added timeout catch to socket manager --- nanpy/sockconnection.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/nanpy/sockconnection.py b/nanpy/sockconnection.py index c255717..8307818 100644 --- a/nanpy/sockconnection.py +++ b/nanpy/sockconnection.py @@ -41,16 +41,19 @@ def readline(self): self.open() s = b'' while 1: - self._socket.settimeout(120) - c = self._socket.recv(1) - log.debug('recv: %s', repr(c.decode())) - if c.decode() == '\r': - continue - if c.decode() == '\n': - break - if c.decode() == '': - break - s += c + try: + self._socket.settimeout(120) + c = self._socket.recv(1) + log.debug('recv: %s', repr(c.decode())) + if c.decode() == '\r': + continue + if c.decode() == '\n': + break + if c.decode() == '': + break + s += c + except socket.timeout: + raise SocketManagerError('Socket Timeout!') log.debug('received:%s', repr(s)) s = s.decode() From b5d2a76344a0425203193228d0c15ae3169e5dc8 Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Thu, 13 Aug 2020 10:50:48 -0500 Subject: [PATCH 339/344] Initial commit --- .gitattributes | 2 + ArduinoClass.cpp | 54 + ArduinoClass.h | 17 + ArduinoCoreClass.cpp | 42 + ArduinoCoreClass.h | 14 + BaseClass.cpp | 6 + BaseClass.h | 71 + CapacitiveSensorClass.cpp | 31 + CapacitiveSensorClass.h | 19 + ColorSensorClass.cpp | 23 + ColorSensorClass.h | 19 + ColorSensorWrapper.cpp | 40 + ColorSensorWrapper.h | 12 + ComChannel.cpp | 233 + ComChannel.h | 28 + CounterClass.cpp | 35 + CounterClass.h | 14 + DHTClass.cpp | 39 + DHTClass.h | 19 + DallasTemperatureClass.cpp | 99 + DallasTemperatureClass.h | 19 + DefineClass.cpp | 130 + DefineClass.h | 14 + EEPROMClass.cpp | 28 + EEPROMClass.h | 17 + EspClass.cpp | 237 + EspClass.h | 18 + FreqCount.cpp | 115 + FreqCount.h | 13 + InfoClass.cpp | 26 + InfoClass.h | 14 + LiquidCrystalClass.cpp | 71 + LiquidCrystalClass.h | 20 + LiquidCrystalClass_I2C.cpp | 57 + LiquidCrystalClass_I2C.h | 20 + MCP41xxxClass.cpp | 32 + MCP41xxxClass.h | 17 + MethodDescriptor.cpp | 127 + MethodDescriptor.h | 44 + Nanpy-MudPi.ino | 131 + OneWireClass.cpp | 76 + OneWireClass.h | 19 + RAMClass.cpp | 43 + RAMClass.h | 17 + RegisterClass.cpp | 112 + RegisterClass.h | 13 + ServoClass.cpp | 52 + ServoClass.h | 19 + SlimArray.h | 92 + StepperClass.cpp | 40 + StepperClass.h | 19 + TLC5947Class.cpp | 36 + TLC5947Class.h | 17 + ToneClass.cpp | 32 + ToneClass.h | 110 + ToneWrapper.cpp | 20 + ToneWrapper.h | 20 + UltrasonicClass.cpp | 22 + UltrasonicClass.h | 19 + UltrasonicWrapper.cpp | 48 + UltrasonicWrapper.h | 12 + WatchdogClass.cpp | 48 + WatchdogClass.h | 16 + WireClass.cpp | 60 + WireClass.h | 19 + cfg.h | 86 + cfg_all.h | 5 + cfg_check.h | 44 + cfg_defaults.h | 105 + consts.h | 3 + freeram.c | 65 + freeram.h | 14 + generated_avr_registers.h | 13764 +++++++++++++++++++++++++++++++++++ generated_intdefs.h | 69 + generated_mcu.h | 1287 ++++ intdefs.h | 11 + timers.h | 501 ++ 77 files changed, 18902 insertions(+) create mode 100644 .gitattributes create mode 100644 ArduinoClass.cpp create mode 100644 ArduinoClass.h create mode 100644 ArduinoCoreClass.cpp create mode 100644 ArduinoCoreClass.h create mode 100644 BaseClass.cpp create mode 100644 BaseClass.h create mode 100644 CapacitiveSensorClass.cpp create mode 100644 CapacitiveSensorClass.h create mode 100644 ColorSensorClass.cpp create mode 100644 ColorSensorClass.h create mode 100644 ColorSensorWrapper.cpp create mode 100644 ColorSensorWrapper.h create mode 100644 ComChannel.cpp create mode 100644 ComChannel.h create mode 100644 CounterClass.cpp create mode 100644 CounterClass.h create mode 100644 DHTClass.cpp create mode 100644 DHTClass.h create mode 100644 DallasTemperatureClass.cpp create mode 100644 DallasTemperatureClass.h create mode 100644 DefineClass.cpp create mode 100644 DefineClass.h create mode 100644 EEPROMClass.cpp create mode 100644 EEPROMClass.h create mode 100644 EspClass.cpp create mode 100644 EspClass.h create mode 100644 FreqCount.cpp create mode 100644 FreqCount.h create mode 100644 InfoClass.cpp create mode 100644 InfoClass.h create mode 100644 LiquidCrystalClass.cpp create mode 100644 LiquidCrystalClass.h create mode 100644 LiquidCrystalClass_I2C.cpp create mode 100644 LiquidCrystalClass_I2C.h create mode 100644 MCP41xxxClass.cpp create mode 100644 MCP41xxxClass.h create mode 100644 MethodDescriptor.cpp create mode 100644 MethodDescriptor.h create mode 100644 Nanpy-MudPi.ino create mode 100644 OneWireClass.cpp create mode 100644 OneWireClass.h create mode 100644 RAMClass.cpp create mode 100644 RAMClass.h create mode 100644 RegisterClass.cpp create mode 100644 RegisterClass.h create mode 100644 ServoClass.cpp create mode 100644 ServoClass.h create mode 100644 SlimArray.h create mode 100644 StepperClass.cpp create mode 100644 StepperClass.h create mode 100644 TLC5947Class.cpp create mode 100644 TLC5947Class.h create mode 100644 ToneClass.cpp create mode 100644 ToneClass.h create mode 100644 ToneWrapper.cpp create mode 100644 ToneWrapper.h create mode 100644 UltrasonicClass.cpp create mode 100644 UltrasonicClass.h create mode 100644 UltrasonicWrapper.cpp create mode 100644 UltrasonicWrapper.h create mode 100644 WatchdogClass.cpp create mode 100644 WatchdogClass.h create mode 100644 WireClass.cpp create mode 100644 WireClass.h create mode 100644 cfg.h create mode 100644 cfg_all.h create mode 100644 cfg_check.h create mode 100644 cfg_defaults.h create mode 100644 consts.h create mode 100644 freeram.c create mode 100644 freeram.h create mode 100644 generated_avr_registers.h create mode 100644 generated_intdefs.h create mode 100644 generated_mcu.h create mode 100644 intdefs.h create mode 100644 timers.h diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/ArduinoClass.cpp b/ArduinoClass.cpp new file mode 100644 index 0000000..46ff927 --- /dev/null +++ b/ArduinoClass.cpp @@ -0,0 +1,54 @@ +#include +#include "ArduinoClass.h" +#include + + +const char* nanpy::ArduinoClass::get_firmware_id() +{ + return "A"; +} + +void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "dw") == 0) { // digitalWrite + digitalWrite(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "r") == 0) { // digitalRead + m->returns(digitalRead(m->getInt(0))); + } +#ifndef ESP32 + if (strcmp(m->getName(), "aw") == 0) { // analogWrite + analogWrite(m->getInt(0), m->getInt(1)); + m->returns(0); + } +#endif + + if (strcmp(m->getName(), "a") == 0) { // analogRead + m->returns(analogRead(m->getInt(0))); + } + + if (strcmp(m->getName(), "pm") == 0) { // pinMode + pinMode(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "delay") == 0) { + m->returns(0); + } + + if (strcmp(m->getName(), "m") == 0) { // millis + m->returns(millis()); + } + + if (strcmp(m->getName(), "pi") == 0) { // pulseIn + pulseIn(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "s") == 0) { // shiftOut + // shiftOut(dataPin, clockPin, bitOrder, value) + shiftOut(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); + m->returns(0); + } +}; diff --git a/ArduinoClass.h b/ArduinoClass.h new file mode 100644 index 0000000..c3ca79a --- /dev/null +++ b/ArduinoClass.h @@ -0,0 +1,17 @@ +#ifndef ARDUINO_CLASS +#define ARDUINO_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class ArduinoClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; + +#endif diff --git a/ArduinoCoreClass.cpp b/ArduinoCoreClass.cpp new file mode 100644 index 0000000..287f49a --- /dev/null +++ b/ArduinoCoreClass.cpp @@ -0,0 +1,42 @@ +#include "cfg_all.h" + +#if USE_ArduinoCore + +#include +#include "ArduinoCoreClass.h" +#include + +#define RETURN_PIN_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x(m->getInt(0))); } +#define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns((uint32_t)x(m->getInt(0))); } + +const char* nanpy::ArduinoCoreClass::get_firmware_id() +{ + return "Core"; +} + +void nanpy::ArduinoCoreClass::elaborate(nanpy::MethodDescriptor* m) +{ + RETURN_PIN_FUNC(digitalPinToBitMask); + RETURN_PIN_FUNC(digitalPinToPort); + RETURN_PIN_FUNC(digitalPinToTimer); + + if (strcmp(m->getName(), "analogInPinToBit") == 0) + { +#ifdef analogInPinToBit + m->returns(analogInPinToBit(m->getInt(0))); +#else + m->returns(-1); +#endif + } +// RETURN_PIN_FUNC(analogInPinToBit); + +// if (strcmp(m->getName(), "portModeRegister") == 0) +// { +// m->returns((uint32_t)portModeRegister(m->getInt(0))); +// } + RETURN_PORT_FUNC(portModeRegister); + RETURN_PORT_FUNC(portOutputRegister); + RETURN_PORT_FUNC(portInputRegister); +} + +#endif diff --git a/ArduinoCoreClass.h b/ArduinoCoreClass.h new file mode 100644 index 0000000..25af72f --- /dev/null +++ b/ArduinoCoreClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class ArduinoCoreClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; diff --git a/BaseClass.cpp b/BaseClass.cpp new file mode 100644 index 0000000..333413f --- /dev/null +++ b/BaseClass.cpp @@ -0,0 +1,6 @@ + +#include "BaseClass.h" + +using namespace nanpy; + +SlimArray Register::classes; diff --git a/BaseClass.h b/BaseClass.h new file mode 100644 index 0000000..1ae6765 --- /dev/null +++ b/BaseClass.h @@ -0,0 +1,71 @@ +#ifndef BASE_CLASS +#define BASE_CLASS + +#include "cfg_all.h" +#include "SlimArray.h" +#include "MethodDescriptor.h" + +namespace nanpy { + + class BaseClass { + + public: + virtual void elaborate( nanpy::MethodDescriptor* m ) = 0; + virtual const char* get_firmware_id() = 0; + + }; + + template class ObjectsManager : public BaseClass { + + protected: + nanpy::SlimArray v; + + public: + ObjectsManager() {} + void elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "remove") == 0) { + delete(v[m->getObjectId()]); + v.remove(m->getObjectId()); + COMM_SERIAL.println("0"); + } + } + + }; + + + class Register { + static nanpy::SlimArray classes; + + public: + + template static void registerClass() { + nanpy::BaseClass* obj = (nanpy::BaseClass*)new T(); + classes.insert(obj); + } + + static nanpy::SlimArray * get_classes() { + return &classes; + } + + static void elaborate(nanpy::MethodDescriptor* m) { + for(int i = 0 ; i < classes.getSize() ; i++) + { + if (strcmp(m->getClass(), classes[i]->get_firmware_id()) == 0) + { + classes[i]->elaborate(m); + } + } + + if(m != NULL) { + delete(m); + m = NULL; + } + } + + }; +} + +#define REGISTER_CLASS_CONDITIONAL(cls, condition) if(condition) Register::registerClass(); +#define REGISTER_CLASS(cls) REGISTER_CLASS_CONDITIONAL(cls, 1); + +#endif diff --git a/CapacitiveSensorClass.cpp b/CapacitiveSensorClass.cpp new file mode 100644 index 0000000..44292ed --- /dev/null +++ b/CapacitiveSensorClass.cpp @@ -0,0 +1,31 @@ +#include "cfg_all.h" + +#if USE_CapacitiveSensor + +#include +#include +#include "CapacitiveSensorClass.h" + +const char* nanpy::CapacitiveSensorClass::get_firmware_id() +{ + return "CapacitiveSensor"; +} + +void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + v.insert(new CapacitiveSensor(m->getInt(0), m->getInt(1))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "capacitiveSensor") == 0) { + m->returns(v[m->getObjectId()]->capacitiveSensor(m->getInt(0))); + } + + if (strcmp(m->getName(), "capacitiveSensorRaw") == 0) { + m->returns(v[m->getObjectId()]->capacitiveSensorRaw(m->getInt(0))); + } +}; + +#endif diff --git a/CapacitiveSensorClass.h b/CapacitiveSensorClass.h new file mode 100644 index 0000000..92ab2df --- /dev/null +++ b/CapacitiveSensorClass.h @@ -0,0 +1,19 @@ +#ifndef CAPACITIVE_SENSOR_CLASS +#define CAPACITIVE_SENSOR_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class CapacitiveSensor; + +namespace nanpy { + class CapacitiveSensorClass : public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/ColorSensorClass.cpp b/ColorSensorClass.cpp new file mode 100644 index 0000000..d4f2ef7 --- /dev/null +++ b/ColorSensorClass.cpp @@ -0,0 +1,23 @@ +#include "cfg_all.h" + +#include +#include "ColorSensorClass.h" +#include + +const char* nanpy::ColorSensorClass::get_firmware_id() { + return "ColorSensor"; +} + +void nanpy::ColorSensorClass::elaborate( MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + v.insert(new ColorSensorWrapper(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3), m->getInt(4))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "get_color") == 0) { + char* p = m->getString(0); + m->returns(v[m->getObjectId()]->getColor(*p)); + } +} diff --git a/ColorSensorClass.h b/ColorSensorClass.h new file mode 100644 index 0000000..63e8c48 --- /dev/null +++ b/ColorSensorClass.h @@ -0,0 +1,19 @@ +#ifndef COLORSENSOR_CLASS +#define COLORSENSOR_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" +#include "ColorSensorWrapper.h" + +class ColorSensor; + +namespace nanpy { + class ColorSensorClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + }; +} + +#endif diff --git a/ColorSensorWrapper.cpp b/ColorSensorWrapper.cpp new file mode 100644 index 0000000..3d96e23 --- /dev/null +++ b/ColorSensorWrapper.cpp @@ -0,0 +1,40 @@ +#include "cfg_all.h" + +#if USE_ColorSensor + +#include "ColorSensorWrapper.h" +#include + +nanpy::ColorSensorWrapper::ColorSensorWrapper(int s0Pin, int s1Pin, int s2Pin, int s3Pin, int sensorOutPin) { + s0 = s0Pin; + s1 = s1Pin; + s2 = s2Pin; + s3 = s3Pin; + sensorOut = sensorOutPin; + + pinMode(s0, OUTPUT); + pinMode(s1, OUTPUT); + pinMode(s2, OUTPUT); + pinMode(s3, OUTPUT); + pinMode(sensorOut, INPUT); + + digitalWrite(s0, HIGH); + digitalWrite(s1, LOW); +} + +int nanpy::ColorSensorWrapper::getColor(char color) { + if (color == 'r') { + digitalWrite(s2, HIGH); + digitalWrite(s3, LOW); + } else if (color == 'g') { + digitalWrite(s2, HIGH); + digitalWrite(s3, HIGH); + } else if (color == 'b') { + digitalWrite(s2, LOW); + digitalWrite(s3, HIGH); + } + + return pulseIn(sensorOut, LOW); +} + +#endif diff --git a/ColorSensorWrapper.h b/ColorSensorWrapper.h new file mode 100644 index 0000000..2212d04 --- /dev/null +++ b/ColorSensorWrapper.h @@ -0,0 +1,12 @@ +namespace nanpy { + + class ColorSensorWrapper { + + private: + int s0, s1, s2, s3, sensorOut; + + public: + ColorSensorWrapper(int s0, int s1, int s2, int s3, int sensorOut); + int getColor(char color); + }; +} diff --git a/ComChannel.cpp b/ComChannel.cpp new file mode 100644 index 0000000..174c0bc --- /dev/null +++ b/ComChannel.cpp @@ -0,0 +1,233 @@ +#include "ComChannel.h" +#include + +#if USE_WIFI_CONNECTION + +#ifdef ESP8266 +#include +#include +#else +#ifdef ESP32 +#include +#include +#endif +#endif + +#define DNS_NAME "mudpi" +#define SERVER_PORT 5678 +#define SerialDebug Serial +#define TIMEOUT 50 + +WiFiServer server(SERVER_PORT); +WiFiClient client; + +unsigned long currentTime = millis(); +unsigned long previousTime = 0; +const long timeoutTime = 10000; + +void nanpy::ComChannel::connect() +{ + SerialDebug.begin(115200); + SerialDebug.println(""); + WiFi.disconnect(); //Flush WiFi + delay(2000); + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + SerialDebug.print("\nConnecting to "); + SerialDebug.println(WIFI_SSID); + uint8_t i = 0; + while (WiFi.status() != WL_CONNECTED && i++ < TIMEOUT) + { + delay(1000); + Serial.print("."); + } + if(i > TIMEOUT) + { + SerialDebug.println(""); + SerialDebug.print("Could not connect to "); + SerialDebug.println(WIFI_SSID); + while(1) + { + delay(500); + } + } + + SerialDebug.println(""); + + if (MDNS.begin(DNS_NAME)) + { + SerialDebug.println("MDNS responder started"); + SerialDebug.print("ping "); + SerialDebug.print(DNS_NAME); + SerialDebug.println(".local"); + } + + SerialDebug.println(""); + + //start UART and the server + server.begin(); + server.setNoDelay(true); + + SerialDebug.print("ping "); + SerialDebug.println(WiFi.localIP()); + + SerialDebug.print("port:"); + SerialDebug.println(SERVER_PORT); +} + +bool nanpy::ComChannel::available() +{ + currentTime = millis(); + if (previousTime == 0) { + previousTime = currentTime; + } + if(client) { + previousTime = currentTime; + // read data from the connected client + if (client.connected() && currentTime - previousTime <= timeoutTime) { + previousTime = currentTime; + return (client.available() > 0); + } + else { + client.stop(); + Serial.println("Client Disconnected."); + } + } + else + { + // try to connect to a new client + client = server.available(); + if (client.connected()) { + SerialDebug.println("Client connected"); + } + } + return false; +} + +char nanpy::ComChannel::read_buffer[MAX_READ_BUFFER_SIZE] = {0}; + +void readLineFromSerial(char* extbuff) { + if(client) { + if(client.connected()) { + int i=0; + char ch = '0'; + char* buff = nanpy::ComChannel::read_buffer; + do { + ch = client.read(); + if(ch < 255 && ch >= 0) { + buff[i++] = ch; + } + if (i == MAX_READ_BUFFER_SIZE - 1) { + buff[i] = '\0'; + break; + } + } while(ch != '\0'); + strcpy(extbuff, buff); + } + } +}; + +void nanpy::ComChannel::readLine(char* extbuff) { + readLineFromSerial(extbuff); +} + +void nanpy::ComChannel::println(String& val) { + client.println(val); +} + +void nanpy::ComChannel::println(const char* val) { + client.println(val); +} + +void nanpy::ComChannel::println(int val) { + client.println(val); +} + +void nanpy::ComChannel::println(unsigned int val) { + client.println(val); +} + +void nanpy::ComChannel::println(float val) { + client.println(val); +} + +void nanpy::ComChannel::println(double val) { + client.println(val); +} + +void nanpy::ComChannel::println(long val) { + client.println(val); +} + +void nanpy::ComChannel::println(unsigned long val) { + client.println(val); +} + + +#else +char nanpy::ComChannel::read_buffer[MAX_READ_BUFFER_SIZE] = {0}; + +void readLineFromSerial(char* extbuff) { + int i=0; + char ch = '0'; + char* buff = nanpy::ComChannel::read_buffer; + do { + ch = COMM_SERIAL.read(); + if(ch < 255 && ch >= 0) { + buff[i++] = ch; + } + if (i == MAX_READ_BUFFER_SIZE - 1) { + buff[i] = '\0'; + break; + } + } while(ch != '\0'); + strcpy(extbuff, buff); +}; + +bool nanpy::ComChannel::available() { + if (COMM_SERIAL.available() > 0) + return true; + else + return false; +} + +void nanpy::ComChannel::connect() { + COMM_SERIAL.begin(BAUDRATE); +} + +void nanpy::ComChannel::println(String& val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(const char* val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(int val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(unsigned int val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(float val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(double val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(long val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::println(unsigned long val) { + COMM_SERIAL.println(val); +} + +void nanpy::ComChannel::readLine(char* extbuff) { + readLineFromSerial(extbuff); +} + +#endif diff --git a/ComChannel.h b/ComChannel.h new file mode 100644 index 0000000..f6cc480 --- /dev/null +++ b/ComChannel.h @@ -0,0 +1,28 @@ +#ifndef COM_CHANNEL +#define COM_CHANNEL + +#include "cfg_all.h" +#include "consts.h" + +#include + +namespace nanpy { + class ComChannel { + + public: + static char read_buffer[MAX_READ_BUFFER_SIZE]; + static bool available(); + static void connect(); + static void println(String& val); + static void println(const char* val); + static void println(int val); + static void println(unsigned int val); + static void println(float val); + static void println(double val); + static void println(long val); + static void println(unsigned long val); + static void readLine(char* extbuff); + }; +} + +#endif diff --git a/CounterClass.cpp b/CounterClass.cpp new file mode 100644 index 0000000..73911e4 --- /dev/null +++ b/CounterClass.cpp @@ -0,0 +1,35 @@ +#include "cfg_all.h" + +#if USE_Counter + +#include "CounterClass.h" +#include "FreqCount.h" + +const char* nanpy::CounterClass::get_firmware_id() +{ + return "Counter"; +} + +void nanpy::CounterClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getName(), "begin") == 0) + { + FreqCount.begin(m->getInt(0)); + m->returns(0); + } + if (strcmp(m->getName(), "available") == 0) + { + m->returns(FreqCount.available()); + } + if (strcmp(m->getName(), "read") == 0) + { + m->returns(FreqCount.read()); + } + if (strcmp(m->getName(), "end") == 0) + { + FreqCount.end(); + m->returns(0); + } +} + +#endif diff --git a/CounterClass.h b/CounterClass.h new file mode 100644 index 0000000..8a145c0 --- /dev/null +++ b/CounterClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class CounterClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; diff --git a/DHTClass.cpp b/DHTClass.cpp new file mode 100644 index 0000000..6416895 --- /dev/null +++ b/DHTClass.cpp @@ -0,0 +1,39 @@ +#include "cfg_all.h" + +#if USE_DHT + +#include +#include +#include "DHTClass.h" +#include + +const char* nanpy::DHTClass::get_firmware_id() +{ + return "DHT"; +} + +void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + DHT* dht; + if (m->getNArgs() == 3) { + dht = new DHT (m->getInt(0), m->getInt(1), m->getInt(2)); + } else { + dht = new DHT (m->getInt(0), m->getInt(1)); + } + dht->begin(); + v.insert(dht); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "readHumidity") == 0) { + m->returns(v[m->getObjectId()]->readHumidity()); + } + + if (strcmp(m->getName(), "readTemperature") == 0) { + m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); + } +}; + +#endif diff --git a/DHTClass.h b/DHTClass.h new file mode 100644 index 0000000..b14cd8f --- /dev/null +++ b/DHTClass.h @@ -0,0 +1,19 @@ +#ifndef DHT_CLASS +#define DHT_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class DHT; + +namespace nanpy { + class DHTClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/DallasTemperatureClass.cpp b/DallasTemperatureClass.cpp new file mode 100644 index 0000000..bbc088b --- /dev/null +++ b/DallasTemperatureClass.cpp @@ -0,0 +1,99 @@ +#include "cfg_all.h" + +#if USE_DallasTemperature + +#include +#include +#include +#include "DallasTemperatureClass.h" +#include + +const char* nanpy::DallasTemperatureClass::get_firmware_id() +{ + return "DallasTemperature"; +} + +void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + int prm = 0; + OneWire* wr = new OneWire(m->getInt(0)); + DallasTemperature* dt = new DallasTemperature(&(*wr)); + v.insert(dt); + dt->begin(); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "setResolution") == 0) { + v[m->getObjectId()]->setResolution(m->getInt(0)); + m->returns(0); + } + + if (strcmp(m->getName(), "getResolution") == 0) { + m->returns(v[m->getObjectId()]->getResolution()); + } + + if (strcmp(m->getName(), "requestTemperatures") == 0) { + if (m->getNArgs() == 1) { + m->returns(v[m->getObjectId()]->requestTemperaturesByIndex(m->getInt(0))); + } else if (m->getNArgs() > 1) { + byte addr[8]; + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = m->getByte(i); + } + m->returns(v[m->getObjectId()]->requestTemperaturesByAddress(addr)); + } else { + v[m->getObjectId()]->requestTemperatures(); + m->returns(0); + } + } + + if (strcmp(m->getName(), "getTempC") == 0) { + if(m->getNArgs() == 1) { + m->returns(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); + } else { + byte addr[8]; + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = m->getByte(i); + } + m->returns(v[m->getObjectId()]->getTempC(addr)); + } + } + + if (strcmp(m->getName(), "getTempF") == 0) { + if(m->getNArgs() == 1) { + m->returns(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); + } else { + byte addr[8]; + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = m->getByte(i); + } + m->returns(v[m->getObjectId()]->getTempF(addr)); + } + } + + if (strcmp(m->getName(), "getAddress") == 0) { + byte addr[8]; + String addr_hex = String(); + if(!v[m->getObjectId()]->getAddress(addr, m->getInt(0))) { + m->returns(1); + return; + } + + char stmp[3]; + for( int cc = 0; cc < 8; cc++ ) + { + sprintf(stmp, "%02X", addr[cc]); + addr_hex.concat( stmp ); + if (cc < 7) + addr_hex.concat( "." ); + } + m->returns(addr_hex); + } + + if (strcmp(m->getName(), "getDeviceCount") == 0) { + m->returns(v[m->getObjectId()]->getDeviceCount()); + } +}; +#endif diff --git a/DallasTemperatureClass.h b/DallasTemperatureClass.h new file mode 100644 index 0000000..30639c5 --- /dev/null +++ b/DallasTemperatureClass.h @@ -0,0 +1,19 @@ +#ifndef DALLAS_TEMP_CLASS +#define DALLAS_TEMP_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class DallasTemperature; + +namespace nanpy { + class DallasTemperatureClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/DefineClass.cpp b/DefineClass.cpp new file mode 100644 index 0000000..d50ef2a --- /dev/null +++ b/DefineClass.cpp @@ -0,0 +1,130 @@ +#include "cfg_all.h" + +#if USE_Define + +#include +#include "DefineClass.h" +#include + +#include "generated_mcu.h" +#ifndef MCU +// unknown MCU +# define MCU "" +#endif + +#ifdef ARDUINO_ARCH_AVR +# define USE_PGM +#endif + +#ifdef USE_PGM +# define MY_PROGMEM PROGMEM +#else +# define MY_PROGMEM +#endif + + +// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html + +// example: +// char string_A0[] PROGMEM = "A0"; +#define DEFINE(x) const char string_##x[] MY_PROGMEM = #x; +#include "generated_intdefs.h" +#include "intdefs.h" +#undef DEFINE + +const char * const name_table[] MY_PROGMEM = +{ +// example: +// string_A0, +#define DEFINE(x) string_##x, +#include "generated_intdefs.h" +#include "intdefs.h" +#undef DEFINE +}; + +const int32_t value_table[] MY_PROGMEM = +{ +// example: +// A0, +#define DEFINE(x) x, +#include "generated_intdefs.h" +#include "intdefs.h" +#undef DEFINE +}; + + +#define COUNT_INT_DEFS sizeof(name_table)/sizeof(name_table[0]) + +#define COUNT_STR_DEFS 4 +// __TIME__, __DATE__, __VERSION__, MCU + +const char* nanpy::DefineClass::get_firmware_id() +{ + return "D"; +} + +void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getName(), "c") == 0) // count + { + m->returns(COUNT_INT_DEFS + COUNT_STR_DEFS); + } + if (strcmp(m->getName(), "n") == 0) // name + { + int index = m->getInt(0); + switch (index) + { + case COUNT_INT_DEFS + 0: + m->returns("__TIME__"); + break; + case COUNT_INT_DEFS + 1: + m->returns("__DATE__"); + break; + case COUNT_INT_DEFS + 2: + m->returns("__VERSION__"); + break; + case COUNT_INT_DEFS + 3: + m->returns("MCU"); + break; + + default: + char buffer[LONGEST_STRING_IN_INTDEFS_H+1]; +#ifdef USE_PGM + strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); +#else + strcpy(buffer, name_table[index]); +#endif + m->returns(buffer); + } + } + if (strcmp(m->getName(), "v") == 0) // value + { + int index = m->getInt(0); + switch (index) + { + case COUNT_INT_DEFS + 0: + m->returns(__TIME__); + break; + case COUNT_INT_DEFS + 1: + m->returns(__DATE__); + break; + case COUNT_INT_DEFS + 2: + m->returns(__VERSION__); + break; + case COUNT_INT_DEFS + 3: + m->returns(MCU); + break; + + default: +#ifdef USE_PGM + int32_t value = pgm_read_dword(&(value_table[index])); +#else + int32_t value = value_table[index]; +#endif + m->returns(value); + } + } + +} + +#endif diff --git a/DefineClass.h b/DefineClass.h new file mode 100644 index 0000000..bc4433e --- /dev/null +++ b/DefineClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class DefineClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; diff --git a/EEPROMClass.cpp b/EEPROMClass.cpp new file mode 100644 index 0000000..a5d127f --- /dev/null +++ b/EEPROMClass.cpp @@ -0,0 +1,28 @@ +#include "cfg_all.h" + +#if USE_EEPROM + +#include +#include "EEPROMClass.h" +#include + +const char* nanpy::EEPROMClass::get_firmware_id() +{ + return "EEPROM"; +} + +void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "write") == 0) { + EEPROM.write(m->getInt(0), m->getInt(1)); + m->returns(0); + } + if (strcmp(m->getName(), "read") == 0) { + m->returns(EEPROM.read(m->getInt(0))); + } + + if (strcmp(m->getName(), "size") == 0) { + m->returns(E2END+1); + } +}; + +#endif diff --git a/EEPROMClass.h b/EEPROMClass.h new file mode 100644 index 0000000..06cae2e --- /dev/null +++ b/EEPROMClass.h @@ -0,0 +1,17 @@ +#ifndef EEPROM_CLASS +#define EEPROM_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class EEPROMClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/EspClass.cpp b/EspClass.cpp new file mode 100644 index 0000000..92a7ef8 --- /dev/null +++ b/EspClass.cpp @@ -0,0 +1,237 @@ +//#include "cfg_all.h" + +#ifdef ESP8266 + +#include "EspClass.h" +#include + +const char* nanpy::EspClass::get_firmware_id() +{ + return "Esp"; +} + +//https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Esp.cpp +void nanpy::EspClass::elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "wdtEnable") == 0) { + ESP.wdtEnable(100); + m->returns(0); + } + if (strcmp(m->getName(), "wdtDisable") == 0) { + ESP.wdtDisable(); + m->returns(0); + } + + if (strcmp(m->getName(), "wdtFeed") == 0) { + ESP.wdtFeed(); + m->returns(0); + } +// if (strcmp(m->getName(), "deepSleep") == 0) { +// ESP.deepSleep(); +// m->returns(0); +// } + if (strcmp(m->getName(), "reset") == 0) { + ESP.reset(); + m->returns(0); + } + if (strcmp(m->getName(), "restart") == 0) { + ESP.restart(); + m->returns(0); + } + if (strcmp(m->getName(), "getVcc") == 0) { + m->returns(ESP.getVcc()); + } + if (strcmp(m->getName(), "getFreeHeap") == 0) { + m->returns(ESP.getFreeHeap()); + } + if (strcmp(m->getName(), "getChipId") == 0) { + m->returns(ESP.getChipId()); + } + if (strcmp(m->getName(), "getSdkVersion") == 0) { + m->returns(ESP.getSdkVersion()); + } + if (strcmp(m->getName(), "getBootVersion") == 0) { + m->returns(ESP.getBootVersion()); + } + if (strcmp(m->getName(), "getBootMode") == 0) { + m->returns(ESP.getBootMode()); + } + if (strcmp(m->getName(), "getCpuFreqMHz") == 0) { + m->returns(ESP.getCpuFreqMHz()); + } + if (strcmp(m->getName(), "getFlashChipId") == 0) { + m->returns(ESP.getFlashChipId()); + } + if (strcmp(m->getName(), "getFlashChipRealSize") == 0) { + m->returns(ESP.getFlashChipRealSize()); + } + + if (strcmp(m->getName(), "getFlashChipSize") == 0) { + m->returns(ESP.getFlashChipSize()); + } + if (strcmp(m->getName(), "getFlashChipSpeed") == 0) { + m->returns(ESP.getFlashChipSpeed()); + } + if (strcmp(m->getName(), "getFlashChipMode") == 0) { + m->returns(ESP.getFlashChipMode()); + } +// if (strcmp(m->getName(), "magicFlashChipSize") == 0) { +// m->returns(ESP.magicFlashChipSize()); +// } +// if (strcmp(m->getName(), "magicFlashChipSpeed") == 0) { +// m->returns(ESP.magicFlashChipSpeed()); +// } +// if (strcmp(m->getName(), "magicFlashChipMode") == 0) { +// m->returns(ESP.magicFlashChipMode()); +// } + if (strcmp(m->getName(), "getFlashChipSizeByChipId") == 0) { + m->returns(ESP.getFlashChipSizeByChipId()); + } +// if (strcmp(m->getName(), "checkFlashConfig") == 0) { +// m->returns(ESP.checkFlashConfig()); +// } + if (strcmp(m->getName(), "getResetReason") == 0) { + String s = ESP.getResetReason(); + m->returns(s); + } + if (strcmp(m->getName(), "getResetInfo") == 0) { + String s = ESP.getResetInfo(); + m->returns(s); + } + if (strcmp(m->getName(), "getSketchSize") == 0) { + m->returns(ESP.getSketchSize()); + } + if (strcmp(m->getName(), "getFreeSketchSpace") == 0) { + m->returns(ESP.getFreeSketchSpace()); + } + if (strcmp(m->getName(), "flashEraseSector") == 0) { + m->returns(ESP.flashEraseSector(m->getInt(0))); + } + if (strcmp(m->getName(), "flashWrite") == 0) { + uint32_t data = m->getInt(1); + m->returns(ESP.flashWrite(m->getInt(0), &data, 1)); + } + if (strcmp(m->getName(), "flashRead") == 0) { + uint32_t data; + ESP.flashRead(m->getInt(0), &data, 1); + m->returns(data); + } +}; + +#else +#ifdef ESP32 +#include "EspClass.h" +#include + +const char* nanpy::EspClass::get_firmware_id() +{ + return "Esp"; +} +//https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Esp.cpp +void nanpy::EspClass::elaborate( nanpy::MethodDescriptor* m ) { +// if (strcmp(m->getName(), "wdtEnable") == 0) { +// ESP.wdtEnable(100); +// m->returns(0); +// } +// if (strcmp(m->getName(), "wdtDisable") == 0) { +// ESP.wdtDisable(); +// m->returns(0); +// } +// +// if (strcmp(m->getName(), "wdtFeed") == 0) { +// ESP.wdtFeed(); +// m->returns(0); +// } +// if (strcmp(m->getName(), "deepSleep") == 0) { +// ESP.deepSleep(); +// m->returns(0); +// } + if (strcmp(m->getName(), "reset") == 0) { + ESP.restart(); + m->returns(0); + } + if (strcmp(m->getName(), "restart") == 0) { + ESP.restart(); + m->returns(0); + } +// if (strcmp(m->getName(), "getVcc") == 0) { +//// m->returns(ESP.getVcc()); +// } + if (strcmp(m->getName(), "getFreeHeap") == 0) { + m->returns(ESP.getFreeHeap()); + } + if (strcmp(m->getName(), "getChipId") == 0) { + m->returns(ESP.getChipRevision()); + } + if (strcmp(m->getName(), "getSdkVersion") == 0) { + m->returns(ESP.getSdkVersion()); + } +// if (strcmp(m->getName(), "getBootVersion") == 0) { +//// m->returns(ESP.getBootVersion()); +// } +// if (strcmp(m->getName(), "getBootMode") == 0) { +//// m->returns(ESP.getFlashChipMode()); +// } + if (strcmp(m->getName(), "getCpuFreqMHz") == 0) { + m->returns("80MHZ"); + } +// if (strcmp(m->getName(), "getFlashChipId") == 0) { +// m->returns(ESP.getFlashChipId()); +// } +// if (strcmp(m->getName(), "getFlashChipRealSize") == 0) { +// m->returns(ESP.getFlashChipRealSize()); +// } + + if (strcmp(m->getName(), "getFlashChipSize") == 0) { + m->returns(ESP.getFlashChipSize()); + } + if (strcmp(m->getName(), "getFlashChipSpeed") == 0) { + m->returns(ESP.getFlashChipSpeed()); + } + if (strcmp(m->getName(), "getFlashChipMode") == 0) { + m->returns(ESP.getFlashChipMode()); + } +// if (strcmp(m->getName(), "magicFlashChipSize") == 0) { +// m->returns(ESP.magicFlashChipSize()); +// } +// if (strcmp(m->getName(), "magicFlashChipSpeed") == 0) { +// m->returns(ESP.magicFlashChipSpeed()); +// } +// if (strcmp(m->getName(), "magicFlashChipMode") == 0) { +// m->returns(ESP.magicFlashChipMode()); +// } +// if (strcmp(m->getName(), "getFlashChipSizeByChipId") == 0) { +// m->returns(ESP.getFlashChipSizeByChipId()); +// } +// if (strcmp(m->getName(), "checkFlashConfig") == 0) { +// m->returns(ESP.checkFlashConfig()); +// } +// if (strcmp(m->getName(), "getResetReason") == 0) { +// String s = ESP.getResetReason(); +// m->returns(s); +// } +// if (strcmp(m->getName(), "getResetInfo") == 0) { +// String s = ESP.getResetInfo(); +// m->returns(s); +// } + if (strcmp(m->getName(), "getSketchSize") == 0) { + m->returns(ESP.getSketchSize()); + } + if (strcmp(m->getName(), "getFreeSketchSpace") == 0) { + m->returns(ESP.getFreeSketchSpace()); + } + if (strcmp(m->getName(), "flashEraseSector") == 0) { + m->returns(ESP.flashEraseSector(m->getInt(0))); + } + if (strcmp(m->getName(), "flashWrite") == 0) { + uint32_t data = m->getInt(1); + m->returns(ESP.flashWrite(m->getInt(0), &data, 1)); + } + if (strcmp(m->getName(), "flashRead") == 0) { + uint32_t data; + ESP.flashRead(m->getInt(0), &data, 1); + m->returns(data); + } +}; + +#endif +#endif diff --git a/EspClass.h b/EspClass.h new file mode 100644 index 0000000..4a94786 --- /dev/null +++ b/EspClass.h @@ -0,0 +1,18 @@ +#pragma once + +//#ifdef ESP8266 + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class EspClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; + +//#endif diff --git a/FreqCount.cpp b/FreqCount.cpp new file mode 100644 index 0000000..6cba70d --- /dev/null +++ b/FreqCount.cpp @@ -0,0 +1,115 @@ + +/* FreqCount Library, for measuring frequencies + * http://www.pjrc.com/teensy/td_libs_FreqCount.html + * Copyright (c) 2011 PJRC.COM, LLC - Paul Stoffregen + * + * Version 1.0 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// FreqCount Library was so modified that it can be included in Nanpy + +#include "cfg_all.h" +#if USE_Counter + +#include "FreqCount.h" +#include "timers.h" + +static uint16_t count_msw; +static uint32_t count_prev; +static volatile uint32_t count_output; +static volatile uint8_t count_ready; +static uint16_t gate_length; +static uint16_t gate_index; + + +void FreqCountClass::begin(uint16_t msec) +{ + if (msec < 10) return; + gate_index = 0; + count_msw = 0; + count_prev = 0; + count_ready = 0; + counter_init(); + gate_length = timer_init(msec); + uint8_t status = SREG; + cli(); + timer_start(); + timer_isr_latency_delay(); + counter_start(); + SREG = status; +} + +uint8_t FreqCountClass::available(void) +{ + return count_ready; +} + +uint32_t FreqCountClass::read(void) +{ + uint32_t count; + uint8_t status; + + status = SREG; + cli(); + count = count_output; + count_ready = 0; + SREG = status; + return count; +} + +void FreqCountClass::end(void) +{ + timer_shutdown(); + counter_shutdown(); +} + + +ISR(TIMER_ISR_VECTOR) +{ + uint16_t count_lsw; + uint32_t count; + uint16_t index, length; + + count_lsw = counter_read(); + if (counter_overflow()) { + counter_overflow_reset(); + count_msw++; + } + index = gate_index + 1; + length = gate_length; + if (index >= length) { + gate_index = 0; + count = ((uint32_t)count_msw << 16) + count_lsw; + count_output = count - count_prev; + count_prev = count; + count_ready = 1; + restore_other_interrupts(); + } else { + if (index == length - 1) disable_other_interrupts(); + gate_index = index; + } +} + + +FreqCountClass FreqCount; + + +#endif diff --git a/FreqCount.h b/FreqCount.h new file mode 100644 index 0000000..8db9663 --- /dev/null +++ b/FreqCount.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +class FreqCountClass { +public: + static void begin(uint16_t msec); + static uint8_t available(void); + static uint32_t read(void); + static void end(void); +}; + +extern FreqCountClass FreqCount; diff --git a/InfoClass.cpp b/InfoClass.cpp new file mode 100644 index 0000000..249b53e --- /dev/null +++ b/InfoClass.cpp @@ -0,0 +1,26 @@ +#include "cfg_all.h" + +#if USE_Info + +#include "InfoClass.h" +#include + +const char* nanpy::InfoClass::get_firmware_id() +{ + return "Info"; +} + +void nanpy::InfoClass::elaborate(nanpy::MethodDescriptor* m) +{ + nanpy::SlimArray * classes = Register::get_classes(); + if (strcmp(m->getName(), "count") == 0) + { + m->returns(classes->getSize()); + } + if (strcmp(m->getName(), "name") == 0) + { + int index = m->getInt(0); + m->returns(classes->get(index)->get_firmware_id()); + } +} +#endif diff --git a/InfoClass.h b/InfoClass.h new file mode 100644 index 0000000..3f31212 --- /dev/null +++ b/InfoClass.h @@ -0,0 +1,14 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class InfoClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; diff --git a/LiquidCrystalClass.cpp b/LiquidCrystalClass.cpp new file mode 100644 index 0000000..2169680 --- /dev/null +++ b/LiquidCrystalClass.cpp @@ -0,0 +1,71 @@ +#include "cfg_all.h" + +#if USE_LiquidCrystal + +#include +#include +#include "LiquidCrystalClass.h" +#include +#include + +const char* nanpy::LiquidCrystalClass::get_firmware_id() +{ + return "Lcd"; +} + +void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + int prm = 0; + v.insert(new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), + m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); + v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "printString") == 0) { + if(m->getNArgs() == 3) { + v[m->getObjectId()]->setCursor(m->getInt(1), m->getInt(2)); + v[m->getObjectId()]->print(m->getString(0)); + } + else + v[m->getObjectId()]->print(m->getString(0)); + m->returns(0); + } + + if (strcmp(m->getName(), "setCursor") == 0) { + v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "autoscroll") == 0) { + v[m->getObjectId()]->autoscroll(); + m->returns(0); + } + + if (strcmp(m->getName(), "noAutoscroll") == 0) { + v[m->getObjectId()]->noAutoscroll(); + m->returns(0); + } + + if (strcmp(m->getName(), "clear") == 0) { + v[m->getObjectId()]->clear(); + m->returns(0); + } + + if (strcmp(m->getName(), "createChar") == 0) { + byte chr[8]; + for(int i = 0; i < 8; i++) { + chr[i] = m->getByte(i+1); + } + v[m->getObjectId()]->createChar(m->getByte(0), chr); + m->returns(0); + } + + if (strcmp(m->getName(), "write") == 0) { + v[m->getObjectId()]->write(m->getByte(0)); + m->returns(0); + } +}; +#endif diff --git a/LiquidCrystalClass.h b/LiquidCrystalClass.h new file mode 100644 index 0000000..4811ced --- /dev/null +++ b/LiquidCrystalClass.h @@ -0,0 +1,20 @@ +#ifndef LIQUID_CRYSTAL_CLASS +#define LIQUID_CRYSTAL_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class LiquidCrystal; + +namespace nanpy { + class LiquidCrystalClass : public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + + +#endif diff --git a/LiquidCrystalClass_I2C.cpp b/LiquidCrystalClass_I2C.cpp new file mode 100644 index 0000000..4c785cd --- /dev/null +++ b/LiquidCrystalClass_I2C.cpp @@ -0,0 +1,57 @@ +#include "cfg_all.h" + +#if USE_LiquidCrystal_I2C + +#include +#include +#include "LiquidCrystalClass_I2C.h" +#include +#include + +const char* nanpy::LiquidCrystalClass_I2C::get_firmware_id() +{ + return "Lcd_I2C"; +} + +void nanpy::LiquidCrystalClass_I2C::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + int prm = 0; + // lcd_Addr, En, Rw, Rs, d4, d5, d6, d7 + v.insert(new LiquidCrystal_I2C ( + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + m->getInt(prm++), + (t_backlighPol)m->getInt(prm++))); + v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "printString") == 0) { + if(m->getNArgs() == 3) { + v[m->getObjectId()]->setCursor(m->getInt(1), m->getInt(2)); + v[m->getObjectId()]->print(m->getString(0)); + } + else + v[m->getObjectId()]->print(m->getString(0)); + m->returns(0); + } + + if (strcmp(m->getName(), "setCursor") == 0) { + v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "setBacklight") == 0) { + v[m->getObjectId()]->setBacklight(m->getInt(0)); + m->returns(0); + } +}; +#endif diff --git a/LiquidCrystalClass_I2C.h b/LiquidCrystalClass_I2C.h new file mode 100644 index 0000000..e6ccb04 --- /dev/null +++ b/LiquidCrystalClass_I2C.h @@ -0,0 +1,20 @@ +#ifndef LIQUID_CRYSTAL_CLASS_I2C +#define LIQUID_CRYSTAL_CLASS_I2C + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class LiquidCrystal_I2C; + +namespace nanpy { + class LiquidCrystalClass_I2C : public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + + +#endif diff --git a/MCP41xxxClass.cpp b/MCP41xxxClass.cpp new file mode 100644 index 0000000..2c3e7a1 --- /dev/null +++ b/MCP41xxxClass.cpp @@ -0,0 +1,32 @@ +#include "cfg.h" + +#if USE_MCP41xxx + +#include +#include +#include "MCP41xxxClass.h" +#include "SPI.h" +#include + +const char* nanpy::MCP41xxxClass::get_firmware_id(){ + return "MCP41xxx"; +} + +void nanpy::MCP41xxxClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + MCP41xxx* pot; + pot = new MCP41xxx (m->getInt(0)); + pot->begin(); + v.insert(pot); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "analogWrite") == 0) { + v[m->getObjectId()]->analogWrite(m->getInt(0), m->getInt(1)); + m->returns(0); + } +} + +#endif diff --git a/MCP41xxxClass.h b/MCP41xxxClass.h new file mode 100644 index 0000000..323fbac --- /dev/null +++ b/MCP41xxxClass.h @@ -0,0 +1,17 @@ +#ifndef MCP41XXX_CLASS +#define MCP41XXX_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class MCP41xxx; + +namespace nanpy{ + class MCP41xxxClass: public ObjectsManager{ + public: + void elaborate( nanpy::MethodDescriptor* m); + const char* get_firmware_id(); + }; +} + +#endif diff --git a/MethodDescriptor.cpp b/MethodDescriptor.cpp new file mode 100644 index 0000000..a2850de --- /dev/null +++ b/MethodDescriptor.cpp @@ -0,0 +1,127 @@ +#include "MethodDescriptor.h" +#include +#include +#include "ComChannel.h" +#include "consts.h" + +char** nanpy::MethodDescriptor::stack_pool = 0; +int nanpy::MethodDescriptor::stack_pool_size = 3; + +nanpy::MethodDescriptor::MethodDescriptor() { + + char buff[MAX_READ_BUFFER_SIZE]; + + ComChannel::readLine(this->classname); + + ComChannel::readLine(buff); + this->objid = atoi(buff); + + ComChannel::readLine(buff); + this->n_args = atoi(buff); + + ComChannel::readLine(this->name); + + if (this->n_args > nanpy::MethodDescriptor::stack_pool_size) { + if(nanpy::MethodDescriptor::stack_pool != 0) { + for(int n = 0; n < nanpy::MethodDescriptor::stack_pool_size; n++) { + delete(nanpy::MethodDescriptor::stack_pool[n]); + } + delete(nanpy::MethodDescriptor::stack_pool); + } + nanpy::MethodDescriptor::stack_pool = 0; + nanpy::MethodDescriptor::stack_pool_size = this->n_args; + } + + if (nanpy::MethodDescriptor::stack_pool == 0) { + nanpy::MethodDescriptor::stack_pool = (char**)malloc(sizeof(char*) * nanpy::MethodDescriptor::stack_pool_size); + for(int i = 0; i < nanpy::MethodDescriptor::stack_pool_size; i++) { + nanpy::MethodDescriptor::stack_pool[i] = (char*)malloc(sizeof(char) * MAX_READ_BUFFER_SIZE); + } + } + + this->stack = nanpy::MethodDescriptor::stack_pool; + + for(int n = 0; n < this->n_args; n++) { + ComChannel::readLine(this->stack[n]); + } +}; + +int nanpy::MethodDescriptor::getNArgs() { + return this->n_args; +}; + +bool nanpy::MethodDescriptor::getBool(int n) { + return strcmp(this->stack[n], "True") == 0 ? true : false; +}; + +int nanpy::MethodDescriptor::getInt(int n) { + return atoi(this->stack[n]); +}; + +byte nanpy::MethodDescriptor::getByte(int n) { + return byte(getInt(n)); +}; + +float nanpy::MethodDescriptor::getFloat(int n) { + return atof(this->stack[n]); +}; + +double nanpy::MethodDescriptor::getDouble(int n) { + return atof(this->stack[n]); +}; + +char* nanpy::MethodDescriptor::getString(int n) { + return this->stack[n]; +}; + +char* nanpy::MethodDescriptor::getClass() { + return this->classname; +}; + +int nanpy::MethodDescriptor::getObjectId() { + return this->objid; +}; + +char* nanpy::MethodDescriptor::getName() { + return this->name; +}; + +void nanpy::MethodDescriptor::returns(String& val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(const char* val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(char val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(unsigned char val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(int val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(unsigned int val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(float val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(double val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(long val) { + ComChannel::println(val); +} + +void nanpy::MethodDescriptor::returns(unsigned long val) { + ComChannel::println(val); +} diff --git a/MethodDescriptor.h b/MethodDescriptor.h new file mode 100644 index 0000000..8d1ac3b --- /dev/null +++ b/MethodDescriptor.h @@ -0,0 +1,44 @@ +#ifndef METHOD_DESCRIPTOR +#define METHOD_DESCRIPTOR + +#include +#include + +namespace nanpy { + class MethodDescriptor { + + private: + char name[50]; + int objid; + char classname[50]; + int n_args; + char **stack; + static char **stack_pool; + static int stack_pool_size; + + public: + MethodDescriptor(); + int getNArgs(); + char* getClass(); + int getObjectId(); + bool getBool(int n); + int getInt(int n); + byte getByte(int n); + float getFloat(int n); + double getDouble(int n); + char* getString(int n); + char* getName(); + void returns(String& val); + void returns(const char* val); + void returns(char val); + void returns(unsigned char val); + void returns(int val); + void returns(unsigned int val); + void returns(float val); + void returns(double val); + void returns(long val); + void returns(unsigned long val); + + }; +} +#endif diff --git a/Nanpy-MudPi.ino b/Nanpy-MudPi.ino new file mode 100644 index 0000000..065a182 --- /dev/null +++ b/Nanpy-MudPi.ino @@ -0,0 +1,131 @@ +#include "cfg_all.h" + +// external libraries should be put inside #if ... #endif +// internal headers not. + +#if USE_MCP41xxx +#include +#endif + +#if USE_EEPROM +#include +#endif + +#if USE_Servo +#include +#endif + +#if USE_LiquidCrystal +#include +#endif + +#if USE_LiquidCrystal_I2C +#include +#endif + +#if USE_Stepper +#include +#endif + +#if USE_OneWire +#include +#endif + +#if USE_DallasTemperature +#include +#endif + +#if USE_CapacitiveSensor +#include +#endif + +#if USE_DHT +#include +#endif + +#if USE_Wire +#include +#endif + +#if USE_TLC5947 +#include +#endif + + +#include "MCP41xxxClass.h" +#include "BaseClass.h" +#include "ArduinoClass.h" +#include "OneWireClass.h" +#include "StepperClass.h" +#include "ServoClass.h" +#include "DallasTemperatureClass.h" +#include "LiquidCrystalClass.h" +#include "LiquidCrystalClass_I2C.h" +#include "CapacitiveSensorClass.h" +#include "ToneClass.h" +#include "MethodDescriptor.h" +#include "ComChannel.h" +#include "EEPROMClass.h" +#include "RAMClass.h" +#include "DHTClass.h" + +#include "DefineClass.h" +#include "ArduinoCoreClass.h" +#include "WatchdogClass.h" +#include "RegisterClass.h" +#include "CounterClass.h" +#include "InfoClass.h" +#include "WireClass.h" + +#include "TLC5947Class.h" +#include "EspClass.h" +#include "UltrasonicClass.h" +#include "ColorSensorClass.h" + +using namespace nanpy; + +MethodDescriptor *m = NULL; + +void setup() { + disable_watchdog_at_startup(); + + REGISTER_CLASS(ArduinoClass); // 0.8 k +// + REGISTER_CLASS_CONDITIONAL(MCP41xxxClass, USE_MCP41xxx); + REGISTER_CLASS_CONDITIONAL(nanpy::EEPROMClass, USE_EEPROM); // 0.3 k + REGISTER_CLASS_CONDITIONAL(nanpy::RAMClass, USE_RAM); // + REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass, USE_LiquidCrystal); // 2.3 k + REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass_I2C, USE_LiquidCrystal_I2C); + REGISTER_CLASS_CONDITIONAL(OneWireClass, USE_OneWire); // 1.7 k + REGISTER_CLASS_CONDITIONAL(DallasTemperatureClass, USE_DallasTemperature); // 6.1 k + REGISTER_CLASS_CONDITIONAL(StepperClass, USE_Stepper); // 0.8 k + REGISTER_CLASS_CONDITIONAL(ServoClass, USE_Servo); // 2.5 k + REGISTER_CLASS_CONDITIONAL(ToneClass, USE_Tone); // 2.2 k + REGISTER_CLASS_CONDITIONAL(CapacitiveSensorClass, USE_CapacitiveSensor); // 2.2 k + REGISTER_CLASS_CONDITIONAL(DefineClass, USE_Define); // 0.6 k + REGISTER_CLASS_CONDITIONAL(ArduinoCoreClass, USE_ArduinoCore); // + REGISTER_CLASS_CONDITIONAL(WatchdogClass, USE_Watchdog); // 0.2 k + REGISTER_CLASS_CONDITIONAL(RegisterClass, USE_Register); // 1.5 k + + REGISTER_CLASS_CONDITIONAL(CounterClass, USE_Counter); + REGISTER_CLASS_CONDITIONAL(InfoClass, USE_Info); + REGISTER_CLASS_CONDITIONAL(DHTClass, USE_DHT); + REGISTER_CLASS_CONDITIONAL(WireClass, USE_Wire); + + REGISTER_CLASS_CONDITIONAL(TLC5947Class, USE_TLC5947); + + REGISTER_CLASS_CONDITIONAL(nanpy::EspClass, USE_ESP); + + // GW Classes + REGISTER_CLASS_CONDITIONAL(UltrasonicClass, USE_Ultrasonic); + REGISTER_CLASS_CONDITIONAL(ColorSensorClass, USE_ColorSensor); + + ComChannel::connect(); +} + +void loop() { + if(ComChannel::available()) { + m = new MethodDescriptor(); + Register::elaborate(m); + } +} diff --git a/OneWireClass.cpp b/OneWireClass.cpp new file mode 100644 index 0000000..e4fb1b4 --- /dev/null +++ b/OneWireClass.cpp @@ -0,0 +1,76 @@ +#include "cfg_all.h" + +#if USE_OneWire + +#include +#include "OneWireClass.h" +#include + +const char* nanpy::OneWireClass::get_firmware_id() +{ + return "OneWire"; +} + +void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + v.insert(new OneWire(m->getInt(0))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "search") == 0) { + byte addr[8]; + int res = v[m->getObjectId()]->search(addr); + + if(!res) { + v[m->getObjectId()]->reset_search(); + delay(250); + m->returns(1); + } + + else { + String addr_hex = String(); + for( int cc = 0; cc < 7; cc++ ) + addr_hex += String(addr[cc]) + " "; + addr_hex += String(addr[7]); + m->returns(addr_hex); + } + } + + if (strcmp(m->getName(), "reset_search") == 0) { + v[m->getObjectId()]->reset_search(); + m->returns(0); + } + + if (strcmp(m->getName(), "reset") == 0) { + m->returns(v[m->getObjectId()]->reset()); + } + + if (strcmp(m->getName(), "select") == 0) { + byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); + + for(int i = 0 ; i < m->getNArgs() ; i++) { + addr[i] = m->getByte(i); + } + + v[m->getObjectId()]->select(addr); + + delete(addr); + m->returns(0); + } + + if (strcmp(m->getName(), "write") == 0) { + if(m->getNArgs() == 1) + v[m->getObjectId()]->write(m->getInt(0)); + else + v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "read") == 0) { + m->returns(v[m->getObjectId()]->read()); + } +}; + +#endif diff --git a/OneWireClass.h b/OneWireClass.h new file mode 100644 index 0000000..52e4842 --- /dev/null +++ b/OneWireClass.h @@ -0,0 +1,19 @@ +#ifndef ONE_WIRE_CLASS +#define ONE_WIRE_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class OneWire; + +namespace nanpy { + class OneWireClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/RAMClass.cpp b/RAMClass.cpp new file mode 100644 index 0000000..ce9e6cc --- /dev/null +++ b/RAMClass.cpp @@ -0,0 +1,43 @@ +#include "cfg_all.h" + +#if USE_RAM + +#include "RAMClass.h" +#include +#include "freeram.h" + + +const char* nanpy::RAMClass::get_firmware_id() +{ + return "RAM"; +} + +void nanpy::RAMClass::elaborate( nanpy::MethodDescriptor* m ) { + if (strcmp(m->getName(), "write") == 0) { + uint8_t* p = (uint8_t*)(m->getInt(0)); + *p = m->getInt(1); + m->returns(0); + } + if (strcmp(m->getName(), "read") == 0) { + uint8_t* p = (uint8_t*)(m->getInt(0)); + m->returns(*p); + } + + if (strcmp(m->getName(), "size") == 0) { +#ifdef RAMEND + m->returns(RAMEND+1); +#else + m->returns(0); +#endif + } + + if (strcmp(m->getName(), "free") == 0) { +#ifdef __AVR__ + m->returns(free_ram2()); +#else + m->returns(0); +#endif + } +}; + +#endif diff --git a/RAMClass.h b/RAMClass.h new file mode 100644 index 0000000..bd234a2 --- /dev/null +++ b/RAMClass.h @@ -0,0 +1,17 @@ +#ifndef RAM_CLASS +#define RAM_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class RAMClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/RegisterClass.cpp b/RegisterClass.cpp new file mode 100644 index 0000000..4223c58 --- /dev/null +++ b/RegisterClass.cpp @@ -0,0 +1,112 @@ +#include "cfg_all.h" + +#if USE_Register + +#include +#include "RegisterClass.h" +#include + +// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html + +#define MISSING(x) + +// example: +// char string_OCR2A[] PROGMEM = "OCR2A"; +#define DEFINE(x) const char string_##x[] PROGMEM = #x; +#include "generated_avr_registers.h" +#undef DEFINE + +const char * const name_table[] PROGMEM = +{ +// example: +// string_OCR2A, +#define DEFINE(x) string_##x, +#include "generated_avr_registers.h" +#undef DEFINE +}; + +#define DEFINE(x) (uint16_t)(&x), +const uint16_t reg_list[] PROGMEM = +{ +#include "generated_avr_registers.h" +}; +#undef DEFINE + +#define DEFINE(x) sizeof(x), +const uint16_t sizeof_list[] PROGMEM = +{ +#include "generated_avr_registers.h" +}; +#undef DEFINE + +const int REG_COUNT = sizeof(sizeof_list) / sizeof(sizeof_list[0]); + +#define LONGEST_REGISTER_NAME 21 + +const char* nanpy::RegisterClass::get_firmware_id() +{ + return "R"; +} + +void nanpy::RegisterClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getName(), "c") == 0) // count + { + m->returns(REG_COUNT); + } + else if (strcmp(m->getName(), "n") == 0) // name + { + word regindex = m->getInt(0); + char buffer[LONGEST_REGISTER_NAME]; + strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[regindex]))); + m->returns(buffer); + } + else + { + word regindex = m->getInt(0); + word regvalue = m->getInt(1); + + word regaddr = pgm_read_word(®_list[regindex]); + byte regsize = pgm_read_byte(&sizeof_list[regindex]); + + volatile byte* preg8 = (volatile byte*) regaddr; + volatile word* preg16 = (volatile word*) regaddr; + + if (strcmp(m->getName(), "r") == 0) // read + { + switch (regsize) + { + case 1: + m->returns(*preg8); + break; + case 2: + m->returns(*preg16); + break; + } + } + else if (strcmp(m->getName(), "w") == 0) // write + { + switch (regsize) + { + case 1: + *preg8 = (byte) regvalue; + break; + case 2: + *preg16 = regvalue; + break; + } + m->returns(0); + } + else if (strcmp(m->getName(), "a") == 0) // address + { + m->returns(regaddr); + } + else if (strcmp(m->getName(), "s") == 0) // size + { + m->returns(regsize); + } + + } +} + +#endif diff --git a/RegisterClass.h b/RegisterClass.h new file mode 100644 index 0000000..d151798 --- /dev/null +++ b/RegisterClass.h @@ -0,0 +1,13 @@ +#pragma once +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class RegisterClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; diff --git a/ServoClass.cpp b/ServoClass.cpp new file mode 100644 index 0000000..01425c9 --- /dev/null +++ b/ServoClass.cpp @@ -0,0 +1,52 @@ +#include "cfg_all.h" + +#if USE_Servo + +#include +#include +#include "ServoClass.h" +#include + +const char* nanpy::ServoClass::get_firmware_id() +{ + return "Servo"; +} + +void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + v.insert(new Servo()); + v[v.getLastIndex()]->attach(m->getInt(0)); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "write") == 0) { + v[m->getObjectId()]->write(m->getInt(0)); + m->returns(0); + } + + if (strcmp(m->getName(), "read") == 0) { + m->returns(v[m->getObjectId()]->read()); + } + + if (strcmp(m->getName(), "writeMicroseconds") == 0) { + v[m->getObjectId()]->writeMicroseconds(m->getInt(0)); + m->returns(0); + } + + if (strcmp(m->getName(), "readMicroseconds") == 0) { + m->returns(v[m->getObjectId()]->readMicroseconds()); + } + + if (strcmp(m->getName(), "detach") == 0) { + v[m->getObjectId()]->detach(); + m->returns(0); + } + + if (strcmp(m->getName(), "attached") == 0) { + m->returns(v[m->getObjectId()]->attached()); + } +} + +#endif diff --git a/ServoClass.h b/ServoClass.h new file mode 100644 index 0000000..e35fad2 --- /dev/null +++ b/ServoClass.h @@ -0,0 +1,19 @@ +#ifndef SERVO_CLASS +#define SERVO_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class Servo; + +namespace nanpy { + class ServoClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/SlimArray.h b/SlimArray.h new file mode 100644 index 0000000..30cb23f --- /dev/null +++ b/SlimArray.h @@ -0,0 +1,92 @@ +#ifndef SLIM_ARRAY +#define SLIM_ARRAY + +#include + +namespace nanpy { + template class SlimArray { + + private: + + int size; + int cur_size; + T *v; + + public: + + SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { + for(int i = 0; i < size; i++) + v[i] = 0; + cur_size = 0; + } + + SlimArray(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { + size = s; + for(int i = 0; i < size; i++) + v[i] = x[i]; + } + + void insert(T el) { + this->insert(cur_size, el); + } + + void remove(int pos) { + if(pos > size - 1) + return; + + T* newv = (T*)malloc(sizeof(T) * (size - 1)); + + int j = 0; + + for(int i = 0; i < size; i++) { + if(i != pos) { + newv[j] = v[i]; + j++; + } + } + + free(v); + v = newv; + cur_size--; + size--; + } + + void insert(int pos, T el) { + if(pos > size - 1) { + T* newv = (T*)malloc(sizeof(T) * (pos + 1)); + newv[pos] = el; + for(int i = 0; i < size; i++) + newv[i] = v[i]; + free(v); + size = pos + 1; + v = newv; + } else { + v[pos] = el; + } + cur_size++; + } + + T get(int pos) { + return v[pos]; + } + + T& operator[] ( int pos ) { + return v[pos]; + } + + int getSize() { + return this->size; + } + + int getLastIndex() { + return (this->cur_size - 1); + } + + ~SlimArray() { + free(v); + } + + }; +} + +#endif diff --git a/StepperClass.cpp b/StepperClass.cpp new file mode 100644 index 0000000..2174c3c --- /dev/null +++ b/StepperClass.cpp @@ -0,0 +1,40 @@ +#include "cfg_all.h" + +#if USE_Stepper + +#include +#include +#include "StepperClass.h" +#include + +const char* nanpy::StepperClass::get_firmware_id() +{ + return "Stepper"; +} + +void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + int prm = 0; + if (m->getNArgs() == 3) { + v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); + } else { + v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); + } + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "setSpeed") == 0) { + v[m->getObjectId()]->setSpeed(m->getInt(0)); + m->returns(0); + } + + if (strcmp(m->getName(), "step") == 0) { + v[m->getObjectId()]->step(m->getInt(0)); + m->returns(0); + } +} + + +#endif diff --git a/StepperClass.h b/StepperClass.h new file mode 100644 index 0000000..7311f17 --- /dev/null +++ b/StepperClass.h @@ -0,0 +1,19 @@ +#ifndef STEPPER_CLASS +#define STEPPER_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class Stepper; + +namespace nanpy { + class StepperClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/TLC5947Class.cpp b/TLC5947Class.cpp new file mode 100644 index 0000000..f419cca --- /dev/null +++ b/TLC5947Class.cpp @@ -0,0 +1,36 @@ +#include "cfg.h" + +#if USE_TLC5947 + +#include +#include +#include "TLC5947Class.h" +#include + +const char* nanpy::TLC5947Class::get_firmware_id() { + return "TLC5947"; +} + +void nanpy::TLC5947Class::elaborate( MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if(strcmp(m->getName(), "new") == 0) { + Adafruit_TLC5947* tlc = new Adafruit_TLC5947(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); + tlc->begin(); + v.insert(tlc); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "setLED") == 0) { + v[m->getObjectId()]->setLED(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); + m->returns(0); + } + + if (strcmp(m->getName(), "write") == 0) { + v[m->getObjectId()]->write(); + m->returns(0); + } + +} + +#endif diff --git a/TLC5947Class.h b/TLC5947Class.h new file mode 100644 index 0000000..b30864a --- /dev/null +++ b/TLC5947Class.h @@ -0,0 +1,17 @@ +#ifndef TLC5947_CLASS +#define TLC5947_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class Adafruit_TLC5947; + +namespace nanpy { + class TLC5947Class: public ObjectsManager { + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + }; +} + +#endif diff --git a/ToneClass.cpp b/ToneClass.cpp new file mode 100644 index 0000000..0508804 --- /dev/null +++ b/ToneClass.cpp @@ -0,0 +1,32 @@ +#include "cfg_all.h" + +#if USE_Tone + +#include +#include "ToneClass.h" +#include + +const char* nanpy::ToneClass::get_firmware_id() +{ + return "Tone"; +} + +void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(),"new") == 0) { + v.insert(new ToneWrapper (m->getInt(0))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "play") == 0) { + v[m->getObjectId()]->play(m->getInt(0), m->getInt(1)); + m->returns(0); + } + + if (strcmp(m->getName(), "stop") == 0) { + v[m->getObjectId()]->stop(); + m->returns(0); + } +}; +#endif diff --git a/ToneClass.h b/ToneClass.h new file mode 100644 index 0000000..75bcefa --- /dev/null +++ b/ToneClass.h @@ -0,0 +1,110 @@ +#ifndef TONE_CLASS +#define TONE_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 + +#include "ToneWrapper.h" + +namespace nanpy { + + class ToneClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/ToneWrapper.cpp b/ToneWrapper.cpp new file mode 100644 index 0000000..2042d21 --- /dev/null +++ b/ToneWrapper.cpp @@ -0,0 +1,20 @@ +#include "cfg_all.h" + +#if USE_Tone + +#include "ToneWrapper.h" +#include + +void nanpy::ToneWrapper::play(int note, int duration) { + #if defined(__AVR__) + tone(pin, note); + #endif +} + +void nanpy::ToneWrapper::stop(void) { + #if defined(__AVR__) + noTone(pin); + #endif +} + +#endif diff --git a/ToneWrapper.h b/ToneWrapper.h new file mode 100644 index 0000000..bd64b18 --- /dev/null +++ b/ToneWrapper.h @@ -0,0 +1,20 @@ +#ifndef TONE_WRAPPER_H +#define TONE_WRAPPER_H + +namespace nanpy { +class ToneWrapper { + + private: + + int pin; + + public: + + ToneWrapper(int pin) : pin(pin) {} + void play(int note, int duration); + void stop(void); + +}; +} + +#endif diff --git a/UltrasonicClass.cpp b/UltrasonicClass.cpp new file mode 100644 index 0000000..2e977c3 --- /dev/null +++ b/UltrasonicClass.cpp @@ -0,0 +1,22 @@ +#include "cfg_all.h" + +#include +#include "UltrasonicClass.h" +#include + +const char* nanpy::UltrasonicClass::get_firmware_id() { + return "Ultrasonic"; +} + +void nanpy::UltrasonicClass::elaborate( MethodDescriptor* m ) { + ObjectsManager::elaborate(m); + + if (strcmp(m->getName(), "new") == 0) { + v.insert(new UltrasonicWrapper(m->getInt(0), m->getInt(1), m->getBool(2))); + m->returns(v.getLastIndex()); + } + + if (strcmp(m->getName(), "get_distance") == 0) { + m->returns(v[m->getObjectId()]->getDistance()); + } +} diff --git a/UltrasonicClass.h b/UltrasonicClass.h new file mode 100644 index 0000000..5ded5f0 --- /dev/null +++ b/UltrasonicClass.h @@ -0,0 +1,19 @@ +#ifndef ULTRASONIC_CLASS +#define ULTRASONIC_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" +#include "UltrasonicWrapper.h" + +class Ultrasonic; + +namespace nanpy { + class UltrasonicClass: public ObjectsManager { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + }; +} + +#endif diff --git a/UltrasonicWrapper.cpp b/UltrasonicWrapper.cpp new file mode 100644 index 0000000..ee5f266 --- /dev/null +++ b/UltrasonicWrapper.cpp @@ -0,0 +1,48 @@ +#include "cfg_all.h" + +#if USE_Ultrasonic + +#include "UltrasonicWrapper.h" +#include + +nanpy::UltrasonicWrapper::UltrasonicWrapper(int echoPin, int trigPin, bool useInches) { + echo = echoPin; + trig = trigPin; + + if (useInches) { + conversionFactor = 74; + } else { + conversionFactor = 29; + } + + pinMode(echo, INPUT); + pinMode(trig, OUTPUT); + } + +float nanpy::UltrasonicWrapper::getDistance() { + // Code goes here for getDistance() + int duration; + float distance; + + digitalWrite(trig, LOW); + delayMicroseconds(2); + digitalWrite(trig, HIGH); + delayMicroseconds(10); + digitalWrite(trig, LOW); + + // Get the echo pulse that will last the time between the ultrasound signal has been emited and its echo has been received. + duration = pulseIn(echo, HIGH); + // Sound speed throw the air is 343m/s at 20ºC. Given that pulseIn returns microseconds and the pulse has travelled + // twice the distance between the sensor and the blocking object, we have: + // distance (in meters) = duration (in microseconds) x 343 / 1000000 (microseconds per second) / 2 + // We are working with distances ranging from 10 to 200 cm so meters are too big for us. We need to work with cm. + // Sound speed will be 34300 cm/s andif we invert that 34300 / 1000000 => 1000000 / 34300 = 29,15... + // we can express the same formula as: + // distance (in centimeters) = duration (in microseconds) / 29 / 2 that is much simpler and faster to compute. + + distance = duration / conversionFactor / 2; + + return distance; +} + +#endif diff --git a/UltrasonicWrapper.h b/UltrasonicWrapper.h new file mode 100644 index 0000000..20f0d84 --- /dev/null +++ b/UltrasonicWrapper.h @@ -0,0 +1,12 @@ +namespace nanpy { + + class UltrasonicWrapper { + + private: + int echo, trig, conversionFactor; + + public: + UltrasonicWrapper(int echoPin, int trigPin, bool useInches); + float getDistance(); + }; +} diff --git a/WatchdogClass.cpp b/WatchdogClass.cpp new file mode 100644 index 0000000..884ee65 --- /dev/null +++ b/WatchdogClass.cpp @@ -0,0 +1,48 @@ +#include "cfg_all.h" + +#if USE_Watchdog + +#include +#include "WatchdogClass.h" +#include +#include + +const char* nanpy::WatchdogClass::get_firmware_id() +{ + return "Watchdog"; +} + +void nanpy::WatchdogClass::elaborate(nanpy::MethodDescriptor* m) +{ + if (strcmp(m->getName(), "reset") == 0) + { + wdt_reset(); + m->returns(0); + } + if (strcmp(m->getName(), "enable") == 0) + { + wdt_enable(m->getInt(0)); + m->returns(0); + } + if (strcmp(m->getName(), "disable") == 0) + { + wdt_disable(); + m->returns(0); + } +} + +#endif + +void disable_watchdog_at_startup() +{ + // disable watchdog at startup + // http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html + // "the watchdog timer remains active even after a system reset (except a power-on condition), + // using the fastest prescaler value (approximately 15 ms). + // It is therefore required to turn off the watchdog early during program startup,.." + // "..clearing the watchdog reset flag before disabling the watchdog is required, according to the datasheet." +#ifdef MCUSR + MCUSR = 0; + wdt_disable(); +#endif +} diff --git a/WatchdogClass.h b/WatchdogClass.h new file mode 100644 index 0000000..8383785 --- /dev/null +++ b/WatchdogClass.h @@ -0,0 +1,16 @@ +#pragma once + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +namespace nanpy { + class WatchdogClass : public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +}; + +void disable_watchdog_at_startup(); diff --git a/WireClass.cpp b/WireClass.cpp new file mode 100644 index 0000000..bc9d536 --- /dev/null +++ b/WireClass.cpp @@ -0,0 +1,60 @@ +#include "cfg_all.h" + +#if USE_Wire + +#include +#include +#include "WireClass.h" +#include + +const char* nanpy::WireClass::get_firmware_id() +{ + return "Wire"; +} + +void nanpy::WireClass::elaborate( MethodDescriptor* m ) { + + if (strcmp(m->getName(), "begin") == 0) { + if (m->getNArgs()) + { + // slave + Wire.begin(m->getInt(0)); + } + else + { + // master + Wire.begin(); + } + m->returns(0); + } + if (strcmp(m->getName(), "requestFrom") == 0) { + byte x = Wire.requestFrom(m->getInt(0), m->getInt(1), m->getInt(2)); + m->returns(x); + } + if (strcmp(m->getName(), "beginTransmission") == 0) { + Wire.beginTransmission(m->getInt(0)); + m->returns(0); + } + if (strcmp(m->getName(), "endTransmission") == 0) { + byte x = Wire.endTransmission(m->getInt(0)); + m->returns(x); + } + if (strcmp(m->getName(), "write") == 0) { + // string and array writes are not implemented + byte x = Wire.write(m->getInt(0)); + m->returns(x); + } + if (strcmp(m->getName(), "available") == 0) { + int x = Wire.available(); + m->returns(x); + } + if (strcmp(m->getName(), "read") == 0) { + byte x = Wire.read(); + m->returns(x); + } + + // onReceive and onRequest are not implemented + +}; + +#endif diff --git a/WireClass.h b/WireClass.h new file mode 100644 index 0000000..bd69378 --- /dev/null +++ b/WireClass.h @@ -0,0 +1,19 @@ +#ifndef Wire_CLASS +#define Wire_CLASS + +#include "BaseClass.h" +#include "MethodDescriptor.h" + +class Wire; + +namespace nanpy { + class WireClass: public BaseClass { + + public: + void elaborate( nanpy::MethodDescriptor* m ); + const char* get_firmware_id(); + + }; +} + +#endif diff --git a/cfg.h b/cfg.h new file mode 100644 index 0000000..c84dcb2 --- /dev/null +++ b/cfg.h @@ -0,0 +1,86 @@ +#pragma once + + +// only for ESP8266 +#define USE_WIFI_CONNECTION 1 + +// for WIFI connection +#define WIFI_SSID "Infected Network Detected" +#define WIFI_PASSWORD "DeaDlyDavisson" + + +// for serial connection +#define BAUDRATE 115200 +#define COMM_SERIAL Serial + +// info about existence of other features +#define USE_Info 1 + +// definitions: MCU type, frequency, Arduino version, +// EEPROM size, RAM size, pin count, build time,.. +#define USE_Define 1 + +// low level mapping of pins and ports +#define USE_ArduinoCore 1 + +// read, write RAM +#define USE_RAM 1 + +// read, write EEPROM +#define USE_EEPROM 1 + +// read, write AVR registers +#define USE_Register 0 + +// watchdog and reset +#define USE_Watchdog 0 + +#define USE_Tone 0 + +#define USE_LiquidCrystal 0 + +// I2C +#define USE_Wire 0 + +#define USE_Servo 0 + +#define USE_Stepper 0 + +// frequency counter, USE_Tone should be off! +#define USE_Counter 0 + +// GW Robotics Classes +#define USE_Ultrasonic 0 +#define USE_ColorSensor 0 + +/////////////////////////////////////////////////////////////////////// +// external libraries should be installed for the following features: +/////////////////////////////////////////////////////////////////////// + +// install with Library Manager: "OneWire" +// https://github.com/PaulStoffregen/OneWire +#define USE_OneWire 0 + +// install with Library Manager: "DallasTemperature" +// https://github.com/milesburton/Arduino-Temperature-Control-Library +#define USE_DallasTemperature 0 + + +// install with Library Manager: "CapacitiveSensor" +// https://github.com/PaulStoffregen/CapacitiveSensor +#define USE_CapacitiveSensor 0 + +// install with Library Manager: "DHT sensor library","Adafruit Unified Sensor" +// https://github.com/adafruit/DHT-sensor-library +#define USE_DHT 1 + +// https://bitbucket.org/fmalpartida/new-liquidcrystal +#define USE_LiquidCrystal_I2C 0 + +// install with Library Manager: "Adafruit TLC5947" +// https://github.com/adafruit/Adafruit_TLC5947 +#define USE_TLC5947 0 + +// install with Library Manager: "MCP41XXX" +// https://github.com/ArduinoMax/MCP41xxx +#define USE_MCP41xxx 0 diff --git a/cfg_all.h b/cfg_all.h new file mode 100644 index 0000000..bcd533c --- /dev/null +++ b/cfg_all.h @@ -0,0 +1,5 @@ +#pragma once + +#include "cfg.h" +#include "cfg_defaults.h" +#include "cfg_check.h" diff --git a/cfg_check.h b/cfg_check.h new file mode 100644 index 0000000..dfb8930 --- /dev/null +++ b/cfg_check.h @@ -0,0 +1,44 @@ +#pragma once + +// check configuration for compatibility + +#ifndef ARDUINO_ARCH_AVR +// disable AVR only features +#define USE_ArduinoCore 0 +//#define USE_RAM 0 +#define USE_EEPROM 0 +#define USE_Register 0 +#define USE_Watchdog 0 +#define USE_Counter 0 +#define USE_DHT 1 +#define USE_LiquidCrystal_I2C 0 +#define USE_LiquidCrystal 0 +#endif + +// check configuration for problems + +#ifdef ARDUINO_ARCH_AVR +#if USE_Tone +# if USE_Counter +# error "USE_Tone conflicts with USE_Counter!" +# endif +#endif +#endif + +#ifdef ESP8266 +# define USE_ESP 1 +#else +#ifdef ESP32 +# define USE_ESP_32 1 +# define USE_ESP 1 +# define USE_DHT 1 +#else +# define USE_ESP 0 +#endif +#endif + +#ifndef ESP8266 +#ifndef ESP32 +# define USE_WIFI_CONNECTION 0 +#endif +#endif diff --git a/cfg_defaults.h b/cfg_defaults.h new file mode 100644 index 0000000..3e835f0 --- /dev/null +++ b/cfg_defaults.h @@ -0,0 +1,105 @@ +#pragma once + +// default configuration + +// All these settings can be overwritten in cfg.h + +#ifndef COMM_SERIAL +# define COMM_SERIAL Serial +#endif + +#ifndef USE_WIFI_CONNECTION +# define USE_WIFI_CONNECTION 0 +#endif + +#ifndef BAUDRATE +# define BAUDRATE 115200 +#endif + +#ifndef USE_Servo +# define USE_Servo 0 +#endif + +#ifndef USE_Tone +# define USE_Tone 0 +#endif + +#ifndef USE_LiquidCrystal +# define USE_LiquidCrystal 0 +#endif + +#ifndef USE_Stepper +# define USE_Stepper 0 +#endif + +#ifndef USE_EEPROM +# define USE_EEPROM 0 +#endif + +#ifndef USE_RAM +# define USE_RAM 0 +#endif + +#ifndef USE_Define +# define USE_Define 0 +#endif + +#ifndef USE_ArduinoCore +# define USE_ArduinoCore 0 +#endif + +#ifndef USE_Watchdog +# define USE_Watchdog 0 +#endif + +#ifndef USE_Register +# define USE_Register 0 +#endif + +#ifndef USE_Info +# define USE_Info 0 +#endif + +#ifndef USE_Counter +# define USE_Counter 0 +#endif + +#ifndef USE_Wire +# define USE_Wire 0 +#endif + +#ifndef USE_OneWire +# define USE_OneWire 0 +#endif + +#ifndef USE_DallasTemperature +# define USE_DallasTemperature 0 +#endif + +#ifndef USE_CapacitiveSensor +# define USE_CapacitiveSensor 0 +#endif + +#ifndef USE_DHT +# define USE_DHT 1 +#endif + +#ifndef USE_LiquidCrystal_I2C +# define USE_LiquidCrystal_I2C 0 +#endif + +#ifndef USE_TLC5947 +# define USE_TLC5947 0 +#endif + +#ifndef USE_MCP41xxx +# define USE_MCP41xxx 0 +#endif + +#ifndef USE_Ultrasonic +# define USE_Ultrasonic 0 +#endif + +#ifndef USE_ColorSensor +# define USE_ColorSensor 0 +#endif diff --git a/consts.h b/consts.h new file mode 100644 index 0000000..3cd1b46 --- /dev/null +++ b/consts.h @@ -0,0 +1,3 @@ +#pragma once + +#define MAX_READ_BUFFER_SIZE 50 diff --git a/freeram.c b/freeram.c new file mode 100644 index 0000000..9056f39 --- /dev/null +++ b/freeram.c @@ -0,0 +1,65 @@ +#if defined(__AVR__) +#include +#include + + +extern unsigned int __bss_end; +extern unsigned int __heap_start; +extern void *__brkval; +extern unsigned int __data_start; + +/// return available RAM +int free_ram1() +{ + /// copy from http://arduino.cc/playground/Code/AvailableMemory + int free_memory; + + if ((int) __brkval == 0) + free_memory = ((int) &free_memory) - ((int) &__bss_end); + else + free_memory = ((int) &free_memory) - ((int) __brkval); + + return free_memory; +} + +/// return available RAM +/*! This function places the current value of the heap and stack pointers in the + * variables. You can call it from any place in your code and save the data for + * outputting or displaying later. This allows you to check at different parts of + * your program flow. + * The stack pointer starts at the top of RAM and grows downwards. The heap pointer + * starts just above the static variables etc. and grows upwards. SP should always + * be larger than HP or you'll be in big trouble! The smaller the gap, the more + * careful you need to be. Julian Gall 6-Feb-2009. + */ +int free_ram2() +{ + /// copy from http://arduino.cc/playground/Code/AvailableMemory + uint8_t * heapptr, *stackptr; + + stackptr = (uint8_t *) malloc(4); // use stackptr temporarily + heapptr = stackptr; // save value of heap pointer + free(stackptr); // free up the memory again (sets stackptr to 0) + stackptr = (uint8_t *) (SP); // save value of stack pointer + return (int) (stackptr - heapptr); +} + +/// return available RAM + +/// this function will return the number of bytes currently free in RAM +/// written by David A. Mellis +/// based on code by Rob Faludi http://www.faludi.com +int free_ram3() +{ + /// copy from http://arduino.cc/playground/Code/AvailableMemory + int size = (int) RAMEND - (int) &__data_start; + uint8_t *buf; + + while ((buf = (uint8_t *) malloc(--size)) == NULL) + ; + + free(buf); + + return size; +} +#endif diff --git a/freeram.h b/freeram.h new file mode 100644 index 0000000..f1dba7a --- /dev/null +++ b/freeram.h @@ -0,0 +1,14 @@ +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +int free_ram1(); +int free_ram2(); +int free_ram3(); + +#ifdef __cplusplus +} +#endif diff --git a/generated_avr_registers.h b/generated_avr_registers.h new file mode 100644 index 0000000..dce2e9b --- /dev/null +++ b/generated_avr_registers.h @@ -0,0 +1,13764 @@ + +// this file was generated by codegen.py + +// __AVR_LIBC_VERSION_STRING__ = "1.8.0" +// __AVR_LIBC_DATE_STRING__ = "20111228" + + +#ifdef AC0CON + DEFINE(AC0CON) +#else + MISSING(AC0CON) +#endif + +#ifdef AC1CON + DEFINE(AC1CON) +#else + MISSING(AC1CON) +#endif + +#ifdef AC1ECON + DEFINE(AC1ECON) +#else + MISSING(AC1ECON) +#endif + +#ifdef AC2CON + DEFINE(AC2CON) +#else + MISSING(AC2CON) +#endif + +#ifdef AC2ECON + DEFINE(AC2ECON) +#else + MISSING(AC2ECON) +#endif + +#ifdef AC3CON + DEFINE(AC3CON) +#else + MISSING(AC3CON) +#endif + +#ifdef AC3ECON + DEFINE(AC3ECON) +#else + MISSING(AC3ECON) +#endif + +#ifdef ACA_AC0CTRL + DEFINE(ACA_AC0CTRL) +#else + MISSING(ACA_AC0CTRL) +#endif + +#ifdef ACA_AC0MUXCTRL + DEFINE(ACA_AC0MUXCTRL) +#else + MISSING(ACA_AC0MUXCTRL) +#endif + +#ifdef ACA_AC1CTRL + DEFINE(ACA_AC1CTRL) +#else + MISSING(ACA_AC1CTRL) +#endif + +#ifdef ACA_AC1MUXCTRL + DEFINE(ACA_AC1MUXCTRL) +#else + MISSING(ACA_AC1MUXCTRL) +#endif + +#ifdef ACA_CTRLA + DEFINE(ACA_CTRLA) +#else + MISSING(ACA_CTRLA) +#endif + +#ifdef ACA_CTRLB + DEFINE(ACA_CTRLB) +#else + MISSING(ACA_CTRLB) +#endif + +#ifdef ACA_STATUS + DEFINE(ACA_STATUS) +#else + MISSING(ACA_STATUS) +#endif + +#ifdef ACA_WINCTRL + DEFINE(ACA_WINCTRL) +#else + MISSING(ACA_WINCTRL) +#endif + +#ifdef ACB_AC0CTRL + DEFINE(ACB_AC0CTRL) +#else + MISSING(ACB_AC0CTRL) +#endif + +#ifdef ACB_AC0MUXCTRL + DEFINE(ACB_AC0MUXCTRL) +#else + MISSING(ACB_AC0MUXCTRL) +#endif + +#ifdef ACB_AC1CTRL + DEFINE(ACB_AC1CTRL) +#else + MISSING(ACB_AC1CTRL) +#endif + +#ifdef ACB_AC1MUXCTRL + DEFINE(ACB_AC1MUXCTRL) +#else + MISSING(ACB_AC1MUXCTRL) +#endif + +#ifdef ACB_CTRLA + DEFINE(ACB_CTRLA) +#else + MISSING(ACB_CTRLA) +#endif + +#ifdef ACB_CTRLB + DEFINE(ACB_CTRLB) +#else + MISSING(ACB_CTRLB) +#endif + +#ifdef ACB_STATUS + DEFINE(ACB_STATUS) +#else + MISSING(ACB_STATUS) +#endif + +#ifdef ACB_WINCTRL + DEFINE(ACB_WINCTRL) +#else + MISSING(ACB_WINCTRL) +#endif + +#ifdef ACSR + DEFINE(ACSR) +#else + MISSING(ACSR) +#endif + +#ifdef ACSRA + DEFINE(ACSRA) +#else + MISSING(ACSRA) +#endif + +#ifdef ACSRB + DEFINE(ACSRB) +#else + MISSING(ACSRB) +#endif + +#ifdef ADC + DEFINE(ADC) +#else + MISSING(ADC) +#endif + +#ifdef ADCA_CAL + DEFINE(ADCA_CAL) +#else + MISSING(ADCA_CAL) +#endif + +#ifdef ADCA_CH0RES + DEFINE(ADCA_CH0RES) +#else + MISSING(ADCA_CH0RES) +#endif + +#ifdef ADCA_CH0_CTRL + DEFINE(ADCA_CH0_CTRL) +#else + MISSING(ADCA_CH0_CTRL) +#endif + +#ifdef ADCA_CH0_INTCTRL + DEFINE(ADCA_CH0_INTCTRL) +#else + MISSING(ADCA_CH0_INTCTRL) +#endif + +#ifdef ADCA_CH0_INTFLAGS + DEFINE(ADCA_CH0_INTFLAGS) +#else + MISSING(ADCA_CH0_INTFLAGS) +#endif + +#ifdef ADCA_CH0_MUXCTRL + DEFINE(ADCA_CH0_MUXCTRL) +#else + MISSING(ADCA_CH0_MUXCTRL) +#endif + +#ifdef ADCA_CH0_RES + DEFINE(ADCA_CH0_RES) +#else + MISSING(ADCA_CH0_RES) +#endif + +#ifdef ADCA_CH1RES + DEFINE(ADCA_CH1RES) +#else + MISSING(ADCA_CH1RES) +#endif + +#ifdef ADCA_CH1_CTRL + DEFINE(ADCA_CH1_CTRL) +#else + MISSING(ADCA_CH1_CTRL) +#endif + +#ifdef ADCA_CH1_INTCTRL + DEFINE(ADCA_CH1_INTCTRL) +#else + MISSING(ADCA_CH1_INTCTRL) +#endif + +#ifdef ADCA_CH1_INTFLAGS + DEFINE(ADCA_CH1_INTFLAGS) +#else + MISSING(ADCA_CH1_INTFLAGS) +#endif + +#ifdef ADCA_CH1_MUXCTRL + DEFINE(ADCA_CH1_MUXCTRL) +#else + MISSING(ADCA_CH1_MUXCTRL) +#endif + +#ifdef ADCA_CH1_RES + DEFINE(ADCA_CH1_RES) +#else + MISSING(ADCA_CH1_RES) +#endif + +#ifdef ADCA_CH2RES + DEFINE(ADCA_CH2RES) +#else + MISSING(ADCA_CH2RES) +#endif + +#ifdef ADCA_CH2_CTRL + DEFINE(ADCA_CH2_CTRL) +#else + MISSING(ADCA_CH2_CTRL) +#endif + +#ifdef ADCA_CH2_INTCTRL + DEFINE(ADCA_CH2_INTCTRL) +#else + MISSING(ADCA_CH2_INTCTRL) +#endif + +#ifdef ADCA_CH2_INTFLAGS + DEFINE(ADCA_CH2_INTFLAGS) +#else + MISSING(ADCA_CH2_INTFLAGS) +#endif + +#ifdef ADCA_CH2_MUXCTRL + DEFINE(ADCA_CH2_MUXCTRL) +#else + MISSING(ADCA_CH2_MUXCTRL) +#endif + +#ifdef ADCA_CH2_RES + DEFINE(ADCA_CH2_RES) +#else + MISSING(ADCA_CH2_RES) +#endif + +#ifdef ADCA_CH3RES + DEFINE(ADCA_CH3RES) +#else + MISSING(ADCA_CH3RES) +#endif + +#ifdef ADCA_CH3_CTRL + DEFINE(ADCA_CH3_CTRL) +#else + MISSING(ADCA_CH3_CTRL) +#endif + +#ifdef ADCA_CH3_INTCTRL + DEFINE(ADCA_CH3_INTCTRL) +#else + MISSING(ADCA_CH3_INTCTRL) +#endif + +#ifdef ADCA_CH3_INTFLAGS + DEFINE(ADCA_CH3_INTFLAGS) +#else + MISSING(ADCA_CH3_INTFLAGS) +#endif + +#ifdef ADCA_CH3_MUXCTRL + DEFINE(ADCA_CH3_MUXCTRL) +#else + MISSING(ADCA_CH3_MUXCTRL) +#endif + +#ifdef ADCA_CH3_RES + DEFINE(ADCA_CH3_RES) +#else + MISSING(ADCA_CH3_RES) +#endif + +#ifdef ADCA_CMP + DEFINE(ADCA_CMP) +#else + MISSING(ADCA_CMP) +#endif + +#ifdef ADCA_CTRLA + DEFINE(ADCA_CTRLA) +#else + MISSING(ADCA_CTRLA) +#endif + +#ifdef ADCA_CTRLB + DEFINE(ADCA_CTRLB) +#else + MISSING(ADCA_CTRLB) +#endif + +#ifdef ADCA_EVCTRL + DEFINE(ADCA_EVCTRL) +#else + MISSING(ADCA_EVCTRL) +#endif + +#ifdef ADCA_INTFLAGS + DEFINE(ADCA_INTFLAGS) +#else + MISSING(ADCA_INTFLAGS) +#endif + +#ifdef ADCA_PRESCALER + DEFINE(ADCA_PRESCALER) +#else + MISSING(ADCA_PRESCALER) +#endif + +#ifdef ADCA_REFCTRL + DEFINE(ADCA_REFCTRL) +#else + MISSING(ADCA_REFCTRL) +#endif + +#ifdef ADCA_TEMP + DEFINE(ADCA_TEMP) +#else + MISSING(ADCA_TEMP) +#endif + +#ifdef ADCB_CAL + DEFINE(ADCB_CAL) +#else + MISSING(ADCB_CAL) +#endif + +#ifdef ADCB_CH0RES + DEFINE(ADCB_CH0RES) +#else + MISSING(ADCB_CH0RES) +#endif + +#ifdef ADCB_CH0_CTRL + DEFINE(ADCB_CH0_CTRL) +#else + MISSING(ADCB_CH0_CTRL) +#endif + +#ifdef ADCB_CH0_INTCTRL + DEFINE(ADCB_CH0_INTCTRL) +#else + MISSING(ADCB_CH0_INTCTRL) +#endif + +#ifdef ADCB_CH0_INTFLAGS + DEFINE(ADCB_CH0_INTFLAGS) +#else + MISSING(ADCB_CH0_INTFLAGS) +#endif + +#ifdef ADCB_CH0_MUXCTRL + DEFINE(ADCB_CH0_MUXCTRL) +#else + MISSING(ADCB_CH0_MUXCTRL) +#endif + +#ifdef ADCB_CH0_RES + DEFINE(ADCB_CH0_RES) +#else + MISSING(ADCB_CH0_RES) +#endif + +#ifdef ADCB_CH1RES + DEFINE(ADCB_CH1RES) +#else + MISSING(ADCB_CH1RES) +#endif + +#ifdef ADCB_CH1_CTRL + DEFINE(ADCB_CH1_CTRL) +#else + MISSING(ADCB_CH1_CTRL) +#endif + +#ifdef ADCB_CH1_INTCTRL + DEFINE(ADCB_CH1_INTCTRL) +#else + MISSING(ADCB_CH1_INTCTRL) +#endif + +#ifdef ADCB_CH1_INTFLAGS + DEFINE(ADCB_CH1_INTFLAGS) +#else + MISSING(ADCB_CH1_INTFLAGS) +#endif + +#ifdef ADCB_CH1_MUXCTRL + DEFINE(ADCB_CH1_MUXCTRL) +#else + MISSING(ADCB_CH1_MUXCTRL) +#endif + +#ifdef ADCB_CH1_RES + DEFINE(ADCB_CH1_RES) +#else + MISSING(ADCB_CH1_RES) +#endif + +#ifdef ADCB_CH2RES + DEFINE(ADCB_CH2RES) +#else + MISSING(ADCB_CH2RES) +#endif + +#ifdef ADCB_CH2_CTRL + DEFINE(ADCB_CH2_CTRL) +#else + MISSING(ADCB_CH2_CTRL) +#endif + +#ifdef ADCB_CH2_INTCTRL + DEFINE(ADCB_CH2_INTCTRL) +#else + MISSING(ADCB_CH2_INTCTRL) +#endif + +#ifdef ADCB_CH2_INTFLAGS + DEFINE(ADCB_CH2_INTFLAGS) +#else + MISSING(ADCB_CH2_INTFLAGS) +#endif + +#ifdef ADCB_CH2_MUXCTRL + DEFINE(ADCB_CH2_MUXCTRL) +#else + MISSING(ADCB_CH2_MUXCTRL) +#endif + +#ifdef ADCB_CH2_RES + DEFINE(ADCB_CH2_RES) +#else + MISSING(ADCB_CH2_RES) +#endif + +#ifdef ADCB_CH3RES + DEFINE(ADCB_CH3RES) +#else + MISSING(ADCB_CH3RES) +#endif + +#ifdef ADCB_CH3_CTRL + DEFINE(ADCB_CH3_CTRL) +#else + MISSING(ADCB_CH3_CTRL) +#endif + +#ifdef ADCB_CH3_INTCTRL + DEFINE(ADCB_CH3_INTCTRL) +#else + MISSING(ADCB_CH3_INTCTRL) +#endif + +#ifdef ADCB_CH3_INTFLAGS + DEFINE(ADCB_CH3_INTFLAGS) +#else + MISSING(ADCB_CH3_INTFLAGS) +#endif + +#ifdef ADCB_CH3_MUXCTRL + DEFINE(ADCB_CH3_MUXCTRL) +#else + MISSING(ADCB_CH3_MUXCTRL) +#endif + +#ifdef ADCB_CH3_RES + DEFINE(ADCB_CH3_RES) +#else + MISSING(ADCB_CH3_RES) +#endif + +#ifdef ADCB_CMP + DEFINE(ADCB_CMP) +#else + MISSING(ADCB_CMP) +#endif + +#ifdef ADCB_CTRLA + DEFINE(ADCB_CTRLA) +#else + MISSING(ADCB_CTRLA) +#endif + +#ifdef ADCB_CTRLB + DEFINE(ADCB_CTRLB) +#else + MISSING(ADCB_CTRLB) +#endif + +#ifdef ADCB_EVCTRL + DEFINE(ADCB_EVCTRL) +#else + MISSING(ADCB_EVCTRL) +#endif + +#ifdef ADCB_INTFLAGS + DEFINE(ADCB_INTFLAGS) +#else + MISSING(ADCB_INTFLAGS) +#endif + +#ifdef ADCB_PRESCALER + DEFINE(ADCB_PRESCALER) +#else + MISSING(ADCB_PRESCALER) +#endif + +#ifdef ADCB_REFCTRL + DEFINE(ADCB_REFCTRL) +#else + MISSING(ADCB_REFCTRL) +#endif + +#ifdef ADCB_TEMP + DEFINE(ADCB_TEMP) +#else + MISSING(ADCB_TEMP) +#endif + +#ifdef ADCH + DEFINE(ADCH) +#else + MISSING(ADCH) +#endif + +#ifdef ADCL + DEFINE(ADCL) +#else + MISSING(ADCL) +#endif + +#ifdef ADCRA + DEFINE(ADCRA) +#else + MISSING(ADCRA) +#endif + +#ifdef ADCRB + DEFINE(ADCRB) +#else + MISSING(ADCRB) +#endif + +#ifdef ADCRC + DEFINE(ADCRC) +#else + MISSING(ADCRC) +#endif + +#ifdef ADCRD + DEFINE(ADCRD) +#else + MISSING(ADCRD) +#endif + +#ifdef ADCRE + DEFINE(ADCRE) +#else + MISSING(ADCRE) +#endif + +#ifdef ADCSR + DEFINE(ADCSR) +#else + MISSING(ADCSR) +#endif + +#ifdef ADCSRA + DEFINE(ADCSRA) +#else + MISSING(ADCSRA) +#endif + +#ifdef ADCSRB + DEFINE(ADCSRB) +#else + MISSING(ADCSRB) +#endif + +#ifdef ADCSRC + DEFINE(ADCSRC) +#else + MISSING(ADCSRC) +#endif + +#ifdef ADCW + DEFINE(ADCW) +#else + MISSING(ADCW) +#endif + +#ifdef ADCWH + DEFINE(ADCWH) +#else + MISSING(ADCWH) +#endif + +#ifdef ADCWL + DEFINE(ADCWL) +#else + MISSING(ADCWL) +#endif + +#ifdef ADIFR + DEFINE(ADIFR) +#else + MISSING(ADIFR) +#endif + +#ifdef ADIMR + DEFINE(ADIMR) +#else + MISSING(ADIMR) +#endif + +#ifdef ADMUX + DEFINE(ADMUX) +#else + MISSING(ADMUX) +#endif + +#ifdef ADRSLT + DEFINE(ADRSLT) +#else + MISSING(ADRSLT) +#endif + +#ifdef ADRSLTH + DEFINE(ADRSLTH) +#else + MISSING(ADRSLTH) +#endif + +#ifdef ADRSLTHI + DEFINE(ADRSLTHI) +#else + MISSING(ADRSLTHI) +#endif + +#ifdef ADRSLTL + DEFINE(ADRSLTL) +#else + MISSING(ADRSLTL) +#endif + +#ifdef ADRSLTLO + DEFINE(ADRSLTLO) +#else + MISSING(ADRSLTLO) +#endif + +#ifdef ADSCSRA + DEFINE(ADSCSRA) +#else + MISSING(ADSCSRA) +#endif + +#ifdef ADSCSRB + DEFINE(ADSCSRB) +#else + MISSING(ADSCSRB) +#endif + +#ifdef AESACR + DEFINE(AESACR) +#else + MISSING(AESACR) +#endif + +#ifdef AESADDR + DEFINE(AESADDR) +#else + MISSING(AESADDR) +#endif + +#ifdef AESCR + DEFINE(AESCR) +#else + MISSING(AESCR) +#endif + +#ifdef AESDR + DEFINE(AESDR) +#else + MISSING(AESDR) +#endif + +#ifdef AES_CTRL + DEFINE(AES_CTRL) +#else + MISSING(AES_CTRL) +#endif + +#ifdef AES_INTCTRL + DEFINE(AES_INTCTRL) +#else + MISSING(AES_INTCTRL) +#endif + +#ifdef AES_KEY + DEFINE(AES_KEY) +#else + MISSING(AES_KEY) +#endif + +#ifdef AES_STATE + DEFINE(AES_STATE) +#else + MISSING(AES_STATE) +#endif + +#ifdef AES_STATUS + DEFINE(AES_STATUS) +#else + MISSING(AES_STATUS) +#endif + +#ifdef AGPDDR + DEFINE(AGPDDR) +#else + MISSING(AGPDDR) +#endif + +#ifdef AGPPIN + DEFINE(AGPPIN) +#else + MISSING(AGPPIN) +#endif + +#ifdef AGPPORT + DEFINE(AGPPORT) +#else + MISSING(AGPPORT) +#endif + +#ifdef AMISCR + DEFINE(AMISCR) +#else + MISSING(AMISCR) +#endif + +#ifdef AMP0CSR + DEFINE(AMP0CSR) +#else + MISSING(AMP0CSR) +#endif + +#ifdef AMP1CSR + DEFINE(AMP1CSR) +#else + MISSING(AMP1CSR) +#endif + +#ifdef AMP2CSR + DEFINE(AMP2CSR) +#else + MISSING(AMP2CSR) +#endif + +#ifdef AMUXCTL + DEFINE(AMUXCTL) +#else + MISSING(AMUXCTL) +#endif + +#ifdef ANT_DIV + DEFINE(ANT_DIV) +#else + MISSING(ANT_DIV) +#endif + +#ifdef ASSR + DEFINE(ASSR) +#else + MISSING(ASSR) +#endif + +#ifdef AVR_CONFIG + DEFINE(AVR_CONFIG) +#else + MISSING(AVR_CONFIG) +#endif + +#ifdef AWEXC_CTRL + DEFINE(AWEXC_CTRL) +#else + MISSING(AWEXC_CTRL) +#endif + +#ifdef AWEXC_DTBOTH + DEFINE(AWEXC_DTBOTH) +#else + MISSING(AWEXC_DTBOTH) +#endif + +#ifdef AWEXC_DTBOTHBUF + DEFINE(AWEXC_DTBOTHBUF) +#else + MISSING(AWEXC_DTBOTHBUF) +#endif + +#ifdef AWEXC_DTHS + DEFINE(AWEXC_DTHS) +#else + MISSING(AWEXC_DTHS) +#endif + +#ifdef AWEXC_DTHSBUF + DEFINE(AWEXC_DTHSBUF) +#else + MISSING(AWEXC_DTHSBUF) +#endif + +#ifdef AWEXC_DTLS + DEFINE(AWEXC_DTLS) +#else + MISSING(AWEXC_DTLS) +#endif + +#ifdef AWEXC_DTLSBUF + DEFINE(AWEXC_DTLSBUF) +#else + MISSING(AWEXC_DTLSBUF) +#endif + +#ifdef AWEXC_FDCTRL + DEFINE(AWEXC_FDCTRL) +#else + MISSING(AWEXC_FDCTRL) +#endif + +#ifdef AWEXC_FDEMASK + DEFINE(AWEXC_FDEMASK) +#else + MISSING(AWEXC_FDEMASK) +#endif + +#ifdef AWEXC_OUTOVEN + DEFINE(AWEXC_OUTOVEN) +#else + MISSING(AWEXC_OUTOVEN) +#endif + +#ifdef AWEXC_STATUS + DEFINE(AWEXC_STATUS) +#else + MISSING(AWEXC_STATUS) +#endif + +#ifdef AWEXE_CTRL + DEFINE(AWEXE_CTRL) +#else + MISSING(AWEXE_CTRL) +#endif + +#ifdef AWEXE_DTBOTH + DEFINE(AWEXE_DTBOTH) +#else + MISSING(AWEXE_DTBOTH) +#endif + +#ifdef AWEXE_DTBOTHBUF + DEFINE(AWEXE_DTBOTHBUF) +#else + MISSING(AWEXE_DTBOTHBUF) +#endif + +#ifdef AWEXE_DTHS + DEFINE(AWEXE_DTHS) +#else + MISSING(AWEXE_DTHS) +#endif + +#ifdef AWEXE_DTHSBUF + DEFINE(AWEXE_DTHSBUF) +#else + MISSING(AWEXE_DTHSBUF) +#endif + +#ifdef AWEXE_DTLS + DEFINE(AWEXE_DTLS) +#else + MISSING(AWEXE_DTLS) +#endif + +#ifdef AWEXE_DTLSBUF + DEFINE(AWEXE_DTLSBUF) +#else + MISSING(AWEXE_DTLSBUF) +#endif + +#ifdef AWEXE_FDCTRL + DEFINE(AWEXE_FDCTRL) +#else + MISSING(AWEXE_FDCTRL) +#endif + +#ifdef AWEXE_FDEMASK + DEFINE(AWEXE_FDEMASK) +#else + MISSING(AWEXE_FDEMASK) +#endif + +#ifdef AWEXE_OUTOVEN + DEFINE(AWEXE_OUTOVEN) +#else + MISSING(AWEXE_OUTOVEN) +#endif + +#ifdef AWEXE_STATUS + DEFINE(AWEXE_STATUS) +#else + MISSING(AWEXE_STATUS) +#endif + +#ifdef BATMON + DEFINE(BATMON) +#else + MISSING(BATMON) +#endif + +#ifdef BGCAL + DEFINE(BGCAL) +#else + MISSING(BGCAL) +#endif + +#ifdef BGCCR + DEFINE(BGCCR) +#else + MISSING(BGCCR) +#endif + +#ifdef BGCR + DEFINE(BGCR) +#else + MISSING(BGCR) +#endif + +#ifdef BGCRA + DEFINE(BGCRA) +#else + MISSING(BGCRA) +#endif + +#ifdef BGCRB + DEFINE(BGCRB) +#else + MISSING(BGCRB) +#endif + +#ifdef BGCRR + DEFINE(BGCRR) +#else + MISSING(BGCRR) +#endif + +#ifdef BGCSR + DEFINE(BGCSR) +#else + MISSING(BGCSR) +#endif + +#ifdef BGCSRA + DEFINE(BGCSRA) +#else + MISSING(BGCSRA) +#endif + +#ifdef BGLR + DEFINE(BGLR) +#else + MISSING(BGLR) +#endif + +#ifdef BGPDDR + DEFINE(BGPDDR) +#else + MISSING(BGPDDR) +#endif + +#ifdef BGPPIN + DEFINE(BGPPIN) +#else + MISSING(BGPPIN) +#endif + +#ifdef BGPPORT + DEFINE(BGPPORT) +#else + MISSING(BGPPORT) +#endif + +#ifdef BL_CONFIG + DEFINE(BL_CONFIG) +#else + MISSING(BL_CONFIG) +#endif + +#ifdef BODCR + DEFINE(BODCR) +#else + MISSING(BODCR) +#endif + +#ifdef BPCHCD + DEFINE(BPCHCD) +#else + MISSING(BPCHCD) +#endif + +#ifdef BPCOCD + DEFINE(BPCOCD) +#else + MISSING(BPCOCD) +#endif + +#ifdef BPCR + DEFINE(BPCR) +#else + MISSING(BPCR) +#endif + +#ifdef BPDHCD + DEFINE(BPDHCD) +#else + MISSING(BPDHCD) +#endif + +#ifdef BPDOCD + DEFINE(BPDOCD) +#else + MISSING(BPDOCD) +#endif + +#ifdef BPDUV + DEFINE(BPDUV) +#else + MISSING(BPDUV) +#endif + +#ifdef BPHCTR + DEFINE(BPHCTR) +#else + MISSING(BPHCTR) +#endif + +#ifdef BPIFR + DEFINE(BPIFR) +#else + MISSING(BPIFR) +#endif + +#ifdef BPIMSK + DEFINE(BPIMSK) +#else + MISSING(BPIMSK) +#endif + +#ifdef BPIR + DEFINE(BPIR) +#else + MISSING(BPIR) +#endif + +#ifdef BPOCD + DEFINE(BPOCD) +#else + MISSING(BPOCD) +#endif + +#ifdef BPOCTR + DEFINE(BPOCTR) +#else + MISSING(BPOCTR) +#endif + +#ifdef BPPLR + DEFINE(BPPLR) +#else + MISSING(BPPLR) +#endif + +#ifdef BPSCD + DEFINE(BPSCD) +#else + MISSING(BPSCD) +#endif + +#ifdef BPSCTR + DEFINE(BPSCTR) +#else + MISSING(BPSCTR) +#endif + +#ifdef BTCNT + DEFINE(BTCNT) +#else + MISSING(BTCNT) +#endif + +#ifdef BTCR + DEFINE(BTCR) +#else + MISSING(BTCR) +#endif + +#ifdef B_DET + DEFINE(B_DET) +#else + MISSING(B_DET) +#endif + +#ifdef CADAC0 + DEFINE(CADAC0) +#else + MISSING(CADAC0) +#endif + +#ifdef CADAC1 + DEFINE(CADAC1) +#else + MISSING(CADAC1) +#endif + +#ifdef CADAC2 + DEFINE(CADAC2) +#else + MISSING(CADAC2) +#endif + +#ifdef CADAC3 + DEFINE(CADAC3) +#else + MISSING(CADAC3) +#endif + +#ifdef CADCSRA + DEFINE(CADCSRA) +#else + MISSING(CADCSRA) +#endif + +#ifdef CADCSRB + DEFINE(CADCSRB) +#else + MISSING(CADCSRB) +#endif + +#ifdef CADCSRC + DEFINE(CADCSRC) +#else + MISSING(CADCSRC) +#endif + +#ifdef CADIC + DEFINE(CADIC) +#else + MISSING(CADIC) +#endif + +#ifdef CADICH + DEFINE(CADICH) +#else + MISSING(CADICH) +#endif + +#ifdef CADICL + DEFINE(CADICL) +#else + MISSING(CADICL) +#endif + +#ifdef CADRC + DEFINE(CADRC) +#else + MISSING(CADRC) +#endif + +#ifdef CADRCC + DEFINE(CADRCC) +#else + MISSING(CADRCC) +#endif + +#ifdef CADRCL + DEFINE(CADRCL) +#else + MISSING(CADRCL) +#endif + +#ifdef CADRCLH + DEFINE(CADRCLH) +#else + MISSING(CADRCLH) +#endif + +#ifdef CADRCLL + DEFINE(CADRCLL) +#else + MISSING(CADRCLL) +#endif + +#ifdef CADRDC + DEFINE(CADRDC) +#else + MISSING(CADRDC) +#endif + +#ifdef CANBT1 + DEFINE(CANBT1) +#else + MISSING(CANBT1) +#endif + +#ifdef CANBT2 + DEFINE(CANBT2) +#else + MISSING(CANBT2) +#endif + +#ifdef CANBT3 + DEFINE(CANBT3) +#else + MISSING(CANBT3) +#endif + +#ifdef CANCDMOB + DEFINE(CANCDMOB) +#else + MISSING(CANCDMOB) +#endif + +#ifdef CANEN + DEFINE(CANEN) +#else + MISSING(CANEN) +#endif + +#ifdef CANEN1 + DEFINE(CANEN1) +#else + MISSING(CANEN1) +#endif + +#ifdef CANEN2 + DEFINE(CANEN2) +#else + MISSING(CANEN2) +#endif + +#ifdef CANGCON + DEFINE(CANGCON) +#else + MISSING(CANGCON) +#endif + +#ifdef CANGIE + DEFINE(CANGIE) +#else + MISSING(CANGIE) +#endif + +#ifdef CANGIT + DEFINE(CANGIT) +#else + MISSING(CANGIT) +#endif + +#ifdef CANGSTA + DEFINE(CANGSTA) +#else + MISSING(CANGSTA) +#endif + +#ifdef CANHPMOB + DEFINE(CANHPMOB) +#else + MISSING(CANHPMOB) +#endif + +#ifdef CANIDM1 + DEFINE(CANIDM1) +#else + MISSING(CANIDM1) +#endif + +#ifdef CANIDM2 + DEFINE(CANIDM2) +#else + MISSING(CANIDM2) +#endif + +#ifdef CANIDM3 + DEFINE(CANIDM3) +#else + MISSING(CANIDM3) +#endif + +#ifdef CANIDM4 + DEFINE(CANIDM4) +#else + MISSING(CANIDM4) +#endif + +#ifdef CANIDT1 + DEFINE(CANIDT1) +#else + MISSING(CANIDT1) +#endif + +#ifdef CANIDT2 + DEFINE(CANIDT2) +#else + MISSING(CANIDT2) +#endif + +#ifdef CANIDT3 + DEFINE(CANIDT3) +#else + MISSING(CANIDT3) +#endif + +#ifdef CANIDT4 + DEFINE(CANIDT4) +#else + MISSING(CANIDT4) +#endif + +#ifdef CANIE + DEFINE(CANIE) +#else + MISSING(CANIE) +#endif + +#ifdef CANIE1 + DEFINE(CANIE1) +#else + MISSING(CANIE1) +#endif + +#ifdef CANIE2 + DEFINE(CANIE2) +#else + MISSING(CANIE2) +#endif + +#ifdef CANMSG + DEFINE(CANMSG) +#else + MISSING(CANMSG) +#endif + +#ifdef CANPAGE + DEFINE(CANPAGE) +#else + MISSING(CANPAGE) +#endif + +#ifdef CANREC + DEFINE(CANREC) +#else + MISSING(CANREC) +#endif + +#ifdef CANSIT + DEFINE(CANSIT) +#else + MISSING(CANSIT) +#endif + +#ifdef CANSIT1 + DEFINE(CANSIT1) +#else + MISSING(CANSIT1) +#endif + +#ifdef CANSIT2 + DEFINE(CANSIT2) +#else + MISSING(CANSIT2) +#endif + +#ifdef CANSTM + DEFINE(CANSTM) +#else + MISSING(CANSTM) +#endif + +#ifdef CANSTMH + DEFINE(CANSTMH) +#else + MISSING(CANSTMH) +#endif + +#ifdef CANSTML + DEFINE(CANSTML) +#else + MISSING(CANSTML) +#endif + +#ifdef CANSTMOB + DEFINE(CANSTMOB) +#else + MISSING(CANSTMOB) +#endif + +#ifdef CANTCON + DEFINE(CANTCON) +#else + MISSING(CANTCON) +#endif + +#ifdef CANTEC + DEFINE(CANTEC) +#else + MISSING(CANTEC) +#endif + +#ifdef CANTIM + DEFINE(CANTIM) +#else + MISSING(CANTIM) +#endif + +#ifdef CANTIMH + DEFINE(CANTIMH) +#else + MISSING(CANTIMH) +#endif + +#ifdef CANTIML + DEFINE(CANTIML) +#else + MISSING(CANTIML) +#endif + +#ifdef CANTTC + DEFINE(CANTTC) +#else + MISSING(CANTTC) +#endif + +#ifdef CANTTCH + DEFINE(CANTTCH) +#else + MISSING(CANTTCH) +#endif + +#ifdef CANTTCL + DEFINE(CANTTCL) +#else + MISSING(CANTTCL) +#endif + +#ifdef CBCR + DEFINE(CBCR) +#else + MISSING(CBCR) +#endif + +#ifdef CBPTR + DEFINE(CBPTR) +#else + MISSING(CBPTR) +#endif + +#ifdef CBTR1 + DEFINE(CBTR1) +#else + MISSING(CBTR1) +#endif + +#ifdef CBTR2 + DEFINE(CBTR2) +#else + MISSING(CBTR2) +#endif + +#ifdef CBTR3 + DEFINE(CBTR3) +#else + MISSING(CBTR3) +#endif + +#ifdef CCA_THRES + DEFINE(CCA_THRES) +#else + MISSING(CCA_THRES) +#endif + +#ifdef CCFLG + DEFINE(CCFLG) +#else + MISSING(CCFLG) +#endif + +#ifdef CCISR + DEFINE(CCISR) +#else + MISSING(CCISR) +#endif + +#ifdef CCP + DEFINE(CCP) +#else + MISSING(CCP) +#endif + +#ifdef CCSR + DEFINE(CCSR) +#else + MISSING(CCSR) +#endif + +#ifdef CDIVCAN + DEFINE(CDIVCAN) +#else + MISSING(CDIVCAN) +#endif + +#ifdef CEFR + DEFINE(CEFR) +#else + MISSING(CEFR) +#endif + +#ifdef CGPDDR + DEFINE(CGPDDR) +#else + MISSING(CGPDDR) +#endif + +#ifdef CGPPIN + DEFINE(CGPPIN) +#else + MISSING(CGPPIN) +#endif + +#ifdef CGPPORT + DEFINE(CGPPORT) +#else + MISSING(CGPPORT) +#endif + +#ifdef CHGDCSR + DEFINE(CHGDCSR) +#else + MISSING(CHGDCSR) +#endif + +#ifdef CIDAH0 + DEFINE(CIDAH0) +#else + MISSING(CIDAH0) +#endif + +#ifdef CIDAH1 + DEFINE(CIDAH1) +#else + MISSING(CIDAH1) +#endif + +#ifdef CIER + DEFINE(CIER) +#else + MISSING(CIER) +#endif + +#ifdef CKSEL0 + DEFINE(CKSEL0) +#else + MISSING(CKSEL0) +#endif + +#ifdef CKSEL1 + DEFINE(CKSEL1) +#else + MISSING(CKSEL1) +#endif + +#ifdef CKSTA + DEFINE(CKSTA) +#else + MISSING(CKSTA) +#endif + +#ifdef CLKCSR + DEFINE(CLKCSR) +#else + MISSING(CLKCSR) +#endif + +#ifdef CLKMSR + DEFINE(CLKMSR) +#else + MISSING(CLKMSR) +#endif + +#ifdef CLKPR + DEFINE(CLKPR) +#else + MISSING(CLKPR) +#endif + +#ifdef CLKPSR + DEFINE(CLKPSR) +#else + MISSING(CLKPSR) +#endif + +#ifdef CLKSEL0 + DEFINE(CLKSEL0) +#else + MISSING(CLKSEL0) +#endif + +#ifdef CLKSEL1 + DEFINE(CLKSEL1) +#else + MISSING(CLKSEL1) +#endif + +#ifdef CLKSELR + DEFINE(CLKSELR) +#else + MISSING(CLKSELR) +#endif + +#ifdef CLKSTA + DEFINE(CLKSTA) +#else + MISSING(CLKSTA) +#endif + +#ifdef CLK_CNTR + DEFINE(CLK_CNTR) +#else + MISSING(CLK_CNTR) +#endif + +#ifdef CLK_CTRL + DEFINE(CLK_CTRL) +#else + MISSING(CLK_CTRL) +#endif + +#ifdef CLK_LOCK + DEFINE(CLK_LOCK) +#else + MISSING(CLK_LOCK) +#endif + +#ifdef CLK_PSCTRL + DEFINE(CLK_PSCTRL) +#else + MISSING(CLK_PSCTRL) +#endif + +#ifdef CLK_RTCCTRL + DEFINE(CLK_RTCCTRL) +#else + MISSING(CLK_RTCCTRL) +#endif + +#ifdef CLK_USBCTRL + DEFINE(CLK_USBCTRL) +#else + MISSING(CLK_USBCTRL) +#endif + +#ifdef CMCR + DEFINE(CMCR) +#else + MISSING(CMCR) +#endif + +#ifdef CMIMR + DEFINE(CMIMR) +#else + MISSING(CMIMR) +#endif + +#ifdef CMSR + DEFINE(CMSR) +#else + MISSING(CMSR) +#endif + +#ifdef COSDAC + DEFINE(COSDAC) +#else + MISSING(COSDAC) +#endif + +#ifdef COSDACH + DEFINE(COSDACH) +#else + MISSING(COSDACH) +#endif + +#ifdef COSDACL + DEFINE(COSDACL) +#else + MISSING(COSDACL) +#endif + +#ifdef CPU_CCP + DEFINE(CPU_CCP) +#else + MISSING(CPU_CCP) +#endif + +#ifdef CPU_EIND + DEFINE(CPU_EIND) +#else + MISSING(CPU_EIND) +#endif + +#ifdef CPU_RAMPD + DEFINE(CPU_RAMPD) +#else + MISSING(CPU_RAMPD) +#endif + +#ifdef CPU_RAMPX + DEFINE(CPU_RAMPX) +#else + MISSING(CPU_RAMPX) +#endif + +#ifdef CPU_RAMPY + DEFINE(CPU_RAMPY) +#else + MISSING(CPU_RAMPY) +#endif + +#ifdef CPU_RAMPZ + DEFINE(CPU_RAMPZ) +#else + MISSING(CPU_RAMPZ) +#endif + +#ifdef CPU_SPH + DEFINE(CPU_SPH) +#else + MISSING(CPU_SPH) +#endif + +#ifdef CPU_SPL + DEFINE(CPU_SPL) +#else + MISSING(CPU_SPL) +#endif + +#ifdef CPU_SREG + DEFINE(CPU_SREG) +#else + MISSING(CPU_SREG) +#endif + +#ifdef CRAFEN + DEFINE(CRAFEN) +#else + MISSING(CRAFEN) +#endif + +#ifdef CRC_CHECKSUM0 + DEFINE(CRC_CHECKSUM0) +#else + MISSING(CRC_CHECKSUM0) +#endif + +#ifdef CRC_CHECKSUM1 + DEFINE(CRC_CHECKSUM1) +#else + MISSING(CRC_CHECKSUM1) +#endif + +#ifdef CRC_CHECKSUM2 + DEFINE(CRC_CHECKSUM2) +#else + MISSING(CRC_CHECKSUM2) +#endif + +#ifdef CRC_CHECKSUM3 + DEFINE(CRC_CHECKSUM3) +#else + MISSING(CRC_CHECKSUM3) +#endif + +#ifdef CRC_CTRL + DEFINE(CRC_CTRL) +#else + MISSING(CRC_CTRL) +#endif + +#ifdef CRC_DATAIN + DEFINE(CRC_DATAIN) +#else + MISSING(CRC_DATAIN) +#endif + +#ifdef CRC_STATUS + DEFINE(CRC_STATUS) +#else + MISSING(CRC_STATUS) +#endif + +#ifdef CRXERR + DEFINE(CRXERR) +#else + MISSING(CRXERR) +#endif + +#ifdef CSMA_BE + DEFINE(CSMA_BE) +#else + MISSING(CSMA_BE) +#endif + +#ifdef CSMA_SEED_0 + DEFINE(CSMA_SEED_0) +#else + MISSING(CSMA_SEED_0) +#endif + +#ifdef CSMA_SEED_1 + DEFINE(CSMA_SEED_1) +#else + MISSING(CSMA_SEED_1) +#endif + +#ifdef CTARR + DEFINE(CTARR) +#else + MISSING(CTARR) +#endif + +#ifdef CTXERR + DEFINE(CTXERR) +#else + MISSING(CTXERR) +#endif + +#ifdef CURIRED + DEFINE(CURIRED) +#else + MISSING(CURIRED) +#endif + +#ifdef CURIRUN + DEFINE(CURIRUN) +#else + MISSING(CURIRUN) +#endif + +#ifdef CURRDLY + DEFINE(CURRDLY) +#else + MISSING(CURRDLY) +#endif + +#ifdef CVER + DEFINE(CVER) +#else + MISSING(CVER) +#endif + +#ifdef DAC + DEFINE(DAC) +#else + MISSING(DAC) +#endif + +#ifdef DACA_CH0DATA + DEFINE(DACA_CH0DATA) +#else + MISSING(DACA_CH0DATA) +#endif + +#ifdef DACA_CH0GAINCAL + DEFINE(DACA_CH0GAINCAL) +#else + MISSING(DACA_CH0GAINCAL) +#endif + +#ifdef DACA_CH0OFFSETCAL + DEFINE(DACA_CH0OFFSETCAL) +#else + MISSING(DACA_CH0OFFSETCAL) +#endif + +#ifdef DACA_CH1DATA + DEFINE(DACA_CH1DATA) +#else + MISSING(DACA_CH1DATA) +#endif + +#ifdef DACA_CH1GAINCAL + DEFINE(DACA_CH1GAINCAL) +#else + MISSING(DACA_CH1GAINCAL) +#endif + +#ifdef DACA_CH1OFFSETCAL + DEFINE(DACA_CH1OFFSETCAL) +#else + MISSING(DACA_CH1OFFSETCAL) +#endif + +#ifdef DACA_CTRLA + DEFINE(DACA_CTRLA) +#else + MISSING(DACA_CTRLA) +#endif + +#ifdef DACA_CTRLB + DEFINE(DACA_CTRLB) +#else + MISSING(DACA_CTRLB) +#endif + +#ifdef DACA_CTRLC + DEFINE(DACA_CTRLC) +#else + MISSING(DACA_CTRLC) +#endif + +#ifdef DACA_EVCTRL + DEFINE(DACA_EVCTRL) +#else + MISSING(DACA_EVCTRL) +#endif + +#ifdef DACA_GAINCAL + DEFINE(DACA_GAINCAL) +#else + MISSING(DACA_GAINCAL) +#endif + +#ifdef DACA_OFFSETCAL + DEFINE(DACA_OFFSETCAL) +#else + MISSING(DACA_OFFSETCAL) +#endif + +#ifdef DACA_STATUS + DEFINE(DACA_STATUS) +#else + MISSING(DACA_STATUS) +#endif + +#ifdef DACA_TIMCTRL + DEFINE(DACA_TIMCTRL) +#else + MISSING(DACA_TIMCTRL) +#endif + +#ifdef DACB_CH0DATA + DEFINE(DACB_CH0DATA) +#else + MISSING(DACB_CH0DATA) +#endif + +#ifdef DACB_CH0GAINCAL + DEFINE(DACB_CH0GAINCAL) +#else + MISSING(DACB_CH0GAINCAL) +#endif + +#ifdef DACB_CH0OFFSETCAL + DEFINE(DACB_CH0OFFSETCAL) +#else + MISSING(DACB_CH0OFFSETCAL) +#endif + +#ifdef DACB_CH1DATA + DEFINE(DACB_CH1DATA) +#else + MISSING(DACB_CH1DATA) +#endif + +#ifdef DACB_CH1GAINCAL + DEFINE(DACB_CH1GAINCAL) +#else + MISSING(DACB_CH1GAINCAL) +#endif + +#ifdef DACB_CH1OFFSETCAL + DEFINE(DACB_CH1OFFSETCAL) +#else + MISSING(DACB_CH1OFFSETCAL) +#endif + +#ifdef DACB_CTRLA + DEFINE(DACB_CTRLA) +#else + MISSING(DACB_CTRLA) +#endif + +#ifdef DACB_CTRLB + DEFINE(DACB_CTRLB) +#else + MISSING(DACB_CTRLB) +#endif + +#ifdef DACB_CTRLC + DEFINE(DACB_CTRLC) +#else + MISSING(DACB_CTRLC) +#endif + +#ifdef DACB_EVCTRL + DEFINE(DACB_EVCTRL) +#else + MISSING(DACB_EVCTRL) +#endif + +#ifdef DACB_GAINCAL + DEFINE(DACB_GAINCAL) +#else + MISSING(DACB_GAINCAL) +#endif + +#ifdef DACB_OFFSETCAL + DEFINE(DACB_OFFSETCAL) +#else + MISSING(DACB_OFFSETCAL) +#endif + +#ifdef DACB_STATUS + DEFINE(DACB_STATUS) +#else + MISSING(DACB_STATUS) +#endif + +#ifdef DACB_TIMCTRL + DEFINE(DACB_TIMCTRL) +#else + MISSING(DACB_TIMCTRL) +#endif + +#ifdef DACCTRL + DEFINE(DACCTRL) +#else + MISSING(DACCTRL) +#endif + +#ifdef DACH + DEFINE(DACH) +#else + MISSING(DACH) +#endif + +#ifdef DACL + DEFINE(DACL) +#else + MISSING(DACL) +#endif + +#ifdef DACON + DEFINE(DACON) +#else + MISSING(DACON) +#endif + +#ifdef DACVAL + DEFINE(DACVAL) +#else + MISSING(DACVAL) +#endif + +#ifdef DACVALH + DEFINE(DACVALH) +#else + MISSING(DACVALH) +#endif + +#ifdef DACVALHI + DEFINE(DACVALHI) +#else + MISSING(DACVALHI) +#endif + +#ifdef DACVALL + DEFINE(DACVALL) +#else + MISSING(DACVALL) +#endif + +#ifdef DACVALLO + DEFINE(DACVALLO) +#else + MISSING(DACVALLO) +#endif + +#ifdef DCCR + DEFINE(DCCR) +#else + MISSING(DCCR) +#endif + +#ifdef DDRA + DEFINE(DDRA) +#else + MISSING(DDRA) +#endif + +#ifdef DDRB + DEFINE(DDRB) +#else + MISSING(DDRB) +#endif + +#ifdef DDRC + DEFINE(DDRC) +#else + MISSING(DDRC) +#endif + +#ifdef DDRD + DEFINE(DDRD) +#else + MISSING(DDRD) +#endif + +#ifdef DDRE + DEFINE(DDRE) +#else + MISSING(DDRE) +#endif + +#ifdef DDRF + DEFINE(DDRF) +#else + MISSING(DDRF) +#endif + +#ifdef DDRG + DEFINE(DDRG) +#else + MISSING(DDRG) +#endif + +#ifdef DDRH + DEFINE(DDRH) +#else + MISSING(DDRH) +#endif + +#ifdef DDRJ + DEFINE(DDRJ) +#else + MISSING(DDRJ) +#endif + +#ifdef DDRK + DEFINE(DDRK) +#else + MISSING(DDRK) +#endif + +#ifdef DDRL + DEFINE(DDRL) +#else + MISSING(DDRL) +#endif + +#ifdef DEEAR + DEFINE(DEEAR) +#else + MISSING(DEEAR) +#endif + +#ifdef DEEARL + DEFINE(DEEARL) +#else + MISSING(DEEARL) +#endif + +#ifdef DEECR + DEFINE(DEECR) +#else + MISSING(DEECR) +#endif + +#ifdef DEEDR + DEFINE(DEEDR) +#else + MISSING(DEEDR) +#endif + +#ifdef DFLLRC2M_CALA + DEFINE(DFLLRC2M_CALA) +#else + MISSING(DFLLRC2M_CALA) +#endif + +#ifdef DFLLRC2M_CALB + DEFINE(DFLLRC2M_CALB) +#else + MISSING(DFLLRC2M_CALB) +#endif + +#ifdef DFLLRC2M_COMP0 + DEFINE(DFLLRC2M_COMP0) +#else + MISSING(DFLLRC2M_COMP0) +#endif + +#ifdef DFLLRC2M_COMP1 + DEFINE(DFLLRC2M_COMP1) +#else + MISSING(DFLLRC2M_COMP1) +#endif + +#ifdef DFLLRC2M_COMP2 + DEFINE(DFLLRC2M_COMP2) +#else + MISSING(DFLLRC2M_COMP2) +#endif + +#ifdef DFLLRC2M_CTRL + DEFINE(DFLLRC2M_CTRL) +#else + MISSING(DFLLRC2M_CTRL) +#endif + +#ifdef DFLLRC32M_CALA + DEFINE(DFLLRC32M_CALA) +#else + MISSING(DFLLRC32M_CALA) +#endif + +#ifdef DFLLRC32M_CALB + DEFINE(DFLLRC32M_CALB) +#else + MISSING(DFLLRC32M_CALB) +#endif + +#ifdef DFLLRC32M_COMP0 + DEFINE(DFLLRC32M_COMP0) +#else + MISSING(DFLLRC32M_COMP0) +#endif + +#ifdef DFLLRC32M_COMP1 + DEFINE(DFLLRC32M_COMP1) +#else + MISSING(DFLLRC32M_COMP1) +#endif + +#ifdef DFLLRC32M_COMP2 + DEFINE(DFLLRC32M_COMP2) +#else + MISSING(DFLLRC32M_COMP2) +#endif + +#ifdef DFLLRC32M_CTRL + DEFINE(DFLLRC32M_CTRL) +#else + MISSING(DFLLRC32M_CTRL) +#endif + +#ifdef DIDR + DEFINE(DIDR) +#else + MISSING(DIDR) +#endif + +#ifdef DIDR0 + DEFINE(DIDR0) +#else + MISSING(DIDR0) +#endif + +#ifdef DIDR1 + DEFINE(DIDR1) +#else + MISSING(DIDR1) +#endif + +#ifdef DIDR2 + DEFINE(DIDR2) +#else + MISSING(DIDR2) +#endif + +#ifdef DMA_CH0_ADDRCTRL + DEFINE(DMA_CH0_ADDRCTRL) +#else + MISSING(DMA_CH0_ADDRCTRL) +#endif + +#ifdef DMA_CH0_CTRLA + DEFINE(DMA_CH0_CTRLA) +#else + MISSING(DMA_CH0_CTRLA) +#endif + +#ifdef DMA_CH0_CTRLB + DEFINE(DMA_CH0_CTRLB) +#else + MISSING(DMA_CH0_CTRLB) +#endif + +#ifdef DMA_CH0_DESTADDR0 + DEFINE(DMA_CH0_DESTADDR0) +#else + MISSING(DMA_CH0_DESTADDR0) +#endif + +#ifdef DMA_CH0_DESTADDR1 + DEFINE(DMA_CH0_DESTADDR1) +#else + MISSING(DMA_CH0_DESTADDR1) +#endif + +#ifdef DMA_CH0_DESTADDR2 + DEFINE(DMA_CH0_DESTADDR2) +#else + MISSING(DMA_CH0_DESTADDR2) +#endif + +#ifdef DMA_CH0_REPCNT + DEFINE(DMA_CH0_REPCNT) +#else + MISSING(DMA_CH0_REPCNT) +#endif + +#ifdef DMA_CH0_SRCADDR0 + DEFINE(DMA_CH0_SRCADDR0) +#else + MISSING(DMA_CH0_SRCADDR0) +#endif + +#ifdef DMA_CH0_SRCADDR1 + DEFINE(DMA_CH0_SRCADDR1) +#else + MISSING(DMA_CH0_SRCADDR1) +#endif + +#ifdef DMA_CH0_SRCADDR2 + DEFINE(DMA_CH0_SRCADDR2) +#else + MISSING(DMA_CH0_SRCADDR2) +#endif + +#ifdef DMA_CH0_TRFCNT + DEFINE(DMA_CH0_TRFCNT) +#else + MISSING(DMA_CH0_TRFCNT) +#endif + +#ifdef DMA_CH0_TRIGSRC + DEFINE(DMA_CH0_TRIGSRC) +#else + MISSING(DMA_CH0_TRIGSRC) +#endif + +#ifdef DMA_CH1_ADDRCTRL + DEFINE(DMA_CH1_ADDRCTRL) +#else + MISSING(DMA_CH1_ADDRCTRL) +#endif + +#ifdef DMA_CH1_CTRLA + DEFINE(DMA_CH1_CTRLA) +#else + MISSING(DMA_CH1_CTRLA) +#endif + +#ifdef DMA_CH1_CTRLB + DEFINE(DMA_CH1_CTRLB) +#else + MISSING(DMA_CH1_CTRLB) +#endif + +#ifdef DMA_CH1_DESTADDR0 + DEFINE(DMA_CH1_DESTADDR0) +#else + MISSING(DMA_CH1_DESTADDR0) +#endif + +#ifdef DMA_CH1_DESTADDR1 + DEFINE(DMA_CH1_DESTADDR1) +#else + MISSING(DMA_CH1_DESTADDR1) +#endif + +#ifdef DMA_CH1_DESTADDR2 + DEFINE(DMA_CH1_DESTADDR2) +#else + MISSING(DMA_CH1_DESTADDR2) +#endif + +#ifdef DMA_CH1_REPCNT + DEFINE(DMA_CH1_REPCNT) +#else + MISSING(DMA_CH1_REPCNT) +#endif + +#ifdef DMA_CH1_SRCADDR0 + DEFINE(DMA_CH1_SRCADDR0) +#else + MISSING(DMA_CH1_SRCADDR0) +#endif + +#ifdef DMA_CH1_SRCADDR1 + DEFINE(DMA_CH1_SRCADDR1) +#else + MISSING(DMA_CH1_SRCADDR1) +#endif + +#ifdef DMA_CH1_SRCADDR2 + DEFINE(DMA_CH1_SRCADDR2) +#else + MISSING(DMA_CH1_SRCADDR2) +#endif + +#ifdef DMA_CH1_TRFCNT + DEFINE(DMA_CH1_TRFCNT) +#else + MISSING(DMA_CH1_TRFCNT) +#endif + +#ifdef DMA_CH1_TRIGSRC + DEFINE(DMA_CH1_TRIGSRC) +#else + MISSING(DMA_CH1_TRIGSRC) +#endif + +#ifdef DMA_CH2_ADDRCTRL + DEFINE(DMA_CH2_ADDRCTRL) +#else + MISSING(DMA_CH2_ADDRCTRL) +#endif + +#ifdef DMA_CH2_CTRLA + DEFINE(DMA_CH2_CTRLA) +#else + MISSING(DMA_CH2_CTRLA) +#endif + +#ifdef DMA_CH2_CTRLB + DEFINE(DMA_CH2_CTRLB) +#else + MISSING(DMA_CH2_CTRLB) +#endif + +#ifdef DMA_CH2_DESTADDR0 + DEFINE(DMA_CH2_DESTADDR0) +#else + MISSING(DMA_CH2_DESTADDR0) +#endif + +#ifdef DMA_CH2_DESTADDR1 + DEFINE(DMA_CH2_DESTADDR1) +#else + MISSING(DMA_CH2_DESTADDR1) +#endif + +#ifdef DMA_CH2_DESTADDR2 + DEFINE(DMA_CH2_DESTADDR2) +#else + MISSING(DMA_CH2_DESTADDR2) +#endif + +#ifdef DMA_CH2_REPCNT + DEFINE(DMA_CH2_REPCNT) +#else + MISSING(DMA_CH2_REPCNT) +#endif + +#ifdef DMA_CH2_SRCADDR0 + DEFINE(DMA_CH2_SRCADDR0) +#else + MISSING(DMA_CH2_SRCADDR0) +#endif + +#ifdef DMA_CH2_SRCADDR1 + DEFINE(DMA_CH2_SRCADDR1) +#else + MISSING(DMA_CH2_SRCADDR1) +#endif + +#ifdef DMA_CH2_SRCADDR2 + DEFINE(DMA_CH2_SRCADDR2) +#else + MISSING(DMA_CH2_SRCADDR2) +#endif + +#ifdef DMA_CH2_TRFCNT + DEFINE(DMA_CH2_TRFCNT) +#else + MISSING(DMA_CH2_TRFCNT) +#endif + +#ifdef DMA_CH2_TRIGSRC + DEFINE(DMA_CH2_TRIGSRC) +#else + MISSING(DMA_CH2_TRIGSRC) +#endif + +#ifdef DMA_CH3_ADDRCTRL + DEFINE(DMA_CH3_ADDRCTRL) +#else + MISSING(DMA_CH3_ADDRCTRL) +#endif + +#ifdef DMA_CH3_CTRLA + DEFINE(DMA_CH3_CTRLA) +#else + MISSING(DMA_CH3_CTRLA) +#endif + +#ifdef DMA_CH3_CTRLB + DEFINE(DMA_CH3_CTRLB) +#else + MISSING(DMA_CH3_CTRLB) +#endif + +#ifdef DMA_CH3_DESTADDR0 + DEFINE(DMA_CH3_DESTADDR0) +#else + MISSING(DMA_CH3_DESTADDR0) +#endif + +#ifdef DMA_CH3_DESTADDR1 + DEFINE(DMA_CH3_DESTADDR1) +#else + MISSING(DMA_CH3_DESTADDR1) +#endif + +#ifdef DMA_CH3_DESTADDR2 + DEFINE(DMA_CH3_DESTADDR2) +#else + MISSING(DMA_CH3_DESTADDR2) +#endif + +#ifdef DMA_CH3_REPCNT + DEFINE(DMA_CH3_REPCNT) +#else + MISSING(DMA_CH3_REPCNT) +#endif + +#ifdef DMA_CH3_SRCADDR0 + DEFINE(DMA_CH3_SRCADDR0) +#else + MISSING(DMA_CH3_SRCADDR0) +#endif + +#ifdef DMA_CH3_SRCADDR1 + DEFINE(DMA_CH3_SRCADDR1) +#else + MISSING(DMA_CH3_SRCADDR1) +#endif + +#ifdef DMA_CH3_SRCADDR2 + DEFINE(DMA_CH3_SRCADDR2) +#else + MISSING(DMA_CH3_SRCADDR2) +#endif + +#ifdef DMA_CH3_TRFCNT + DEFINE(DMA_CH3_TRFCNT) +#else + MISSING(DMA_CH3_TRFCNT) +#endif + +#ifdef DMA_CH3_TRIGSRC + DEFINE(DMA_CH3_TRIGSRC) +#else + MISSING(DMA_CH3_TRIGSRC) +#endif + +#ifdef DMA_CTRL + DEFINE(DMA_CTRL) +#else + MISSING(DMA_CTRL) +#endif + +#ifdef DMA_INTFLAGS + DEFINE(DMA_INTFLAGS) +#else + MISSING(DMA_INTFLAGS) +#endif + +#ifdef DMA_STATUS + DEFINE(DMA_STATUS) +#else + MISSING(DMA_STATUS) +#endif + +#ifdef DMA_TEMP + DEFINE(DMA_TEMP) +#else + MISSING(DMA_TEMP) +#endif + +#ifdef DPDS0 + DEFINE(DPDS0) +#else + MISSING(DPDS0) +#endif + +#ifdef DPDS1 + DEFINE(DPDS1) +#else + MISSING(DPDS1) +#endif + +#ifdef DRTRAM0 + DEFINE(DRTRAM0) +#else + MISSING(DRTRAM0) +#endif + +#ifdef DRTRAM1 + DEFINE(DRTRAM1) +#else + MISSING(DRTRAM1) +#endif + +#ifdef DRTRAM2 + DEFINE(DRTRAM2) +#else + MISSING(DRTRAM2) +#endif + +#ifdef DRTRAM3 + DEFINE(DRTRAM3) +#else + MISSING(DRTRAM3) +#endif + +#ifdef DT1 + DEFINE(DT1) +#else + MISSING(DT1) +#endif + +#ifdef DT1A + DEFINE(DT1A) +#else + MISSING(DT1A) +#endif + +#ifdef DT1B + DEFINE(DT1B) +#else + MISSING(DT1B) +#endif + +#ifdef DT4 + DEFINE(DT4) +#else + MISSING(DT4) +#endif + +#ifdef DTPS1 + DEFINE(DTPS1) +#else + MISSING(DTPS1) +#endif + +#ifdef DWDR + DEFINE(DWDR) +#else + MISSING(DWDR) +#endif + +#ifdef EBI_CS0_BASEADDR + DEFINE(EBI_CS0_BASEADDR) +#else + MISSING(EBI_CS0_BASEADDR) +#endif + +#ifdef EBI_CS0_CTRLA + DEFINE(EBI_CS0_CTRLA) +#else + MISSING(EBI_CS0_CTRLA) +#endif + +#ifdef EBI_CS0_CTRLB + DEFINE(EBI_CS0_CTRLB) +#else + MISSING(EBI_CS0_CTRLB) +#endif + +#ifdef EBI_CS1_BASEADDR + DEFINE(EBI_CS1_BASEADDR) +#else + MISSING(EBI_CS1_BASEADDR) +#endif + +#ifdef EBI_CS1_CTRLA + DEFINE(EBI_CS1_CTRLA) +#else + MISSING(EBI_CS1_CTRLA) +#endif + +#ifdef EBI_CS1_CTRLB + DEFINE(EBI_CS1_CTRLB) +#else + MISSING(EBI_CS1_CTRLB) +#endif + +#ifdef EBI_CS2_BASEADDR + DEFINE(EBI_CS2_BASEADDR) +#else + MISSING(EBI_CS2_BASEADDR) +#endif + +#ifdef EBI_CS2_CTRLA + DEFINE(EBI_CS2_CTRLA) +#else + MISSING(EBI_CS2_CTRLA) +#endif + +#ifdef EBI_CS2_CTRLB + DEFINE(EBI_CS2_CTRLB) +#else + MISSING(EBI_CS2_CTRLB) +#endif + +#ifdef EBI_CS3_BASEADDR + DEFINE(EBI_CS3_BASEADDR) +#else + MISSING(EBI_CS3_BASEADDR) +#endif + +#ifdef EBI_CS3_CTRLA + DEFINE(EBI_CS3_CTRLA) +#else + MISSING(EBI_CS3_CTRLA) +#endif + +#ifdef EBI_CS3_CTRLB + DEFINE(EBI_CS3_CTRLB) +#else + MISSING(EBI_CS3_CTRLB) +#endif + +#ifdef EBI_CTRL + DEFINE(EBI_CTRL) +#else + MISSING(EBI_CTRL) +#endif + +#ifdef EBI_INITDLY + DEFINE(EBI_INITDLY) +#else + MISSING(EBI_INITDLY) +#endif + +#ifdef EBI_REFRESH + DEFINE(EBI_REFRESH) +#else + MISSING(EBI_REFRESH) +#endif + +#ifdef EBI_SDRAMCTRLA + DEFINE(EBI_SDRAMCTRLA) +#else + MISSING(EBI_SDRAMCTRLA) +#endif + +#ifdef EBI_SDRAMCTRLB + DEFINE(EBI_SDRAMCTRLB) +#else + MISSING(EBI_SDRAMCTRLB) +#endif + +#ifdef EBI_SDRAMCTRLC + DEFINE(EBI_SDRAMCTRLC) +#else + MISSING(EBI_SDRAMCTRLC) +#endif + +#ifdef EEAR + DEFINE(EEAR) +#else + MISSING(EEAR) +#endif + +#ifdef EEARH + DEFINE(EEARH) +#else + MISSING(EEARH) +#endif + +#ifdef EEARL + DEFINE(EEARL) +#else + MISSING(EEARL) +#endif + +#ifdef EECR + DEFINE(EECR) +#else + MISSING(EECR) +#endif + +#ifdef EEDR + DEFINE(EEDR) +#else + MISSING(EEDR) +#endif + +#ifdef EICR + DEFINE(EICR) +#else + MISSING(EICR) +#endif + +#ifdef EICRA + DEFINE(EICRA) +#else + MISSING(EICRA) +#endif + +#ifdef EICRB + DEFINE(EICRB) +#else + MISSING(EICRB) +#endif + +#ifdef EIFR + DEFINE(EIFR) +#else + MISSING(EIFR) +#endif + +#ifdef EIMF + DEFINE(EIMF) +#else + MISSING(EIMF) +#endif + +#ifdef EIMSK + DEFINE(EIMSK) +#else + MISSING(EIMSK) +#endif + +#ifdef EIND + DEFINE(EIND) +#else + MISSING(EIND) +#endif + +#ifdef EIRR + DEFINE(EIRR) +#else + MISSING(EIRR) +#endif + +#ifdef EMCUCR + DEFINE(EMCUCR) +#else + MISSING(EMCUCR) +#endif + +#ifdef ETIFR + DEFINE(ETIFR) +#else + MISSING(ETIFR) +#endif + +#ifdef ETIMSK + DEFINE(ETIMSK) +#else + MISSING(ETIMSK) +#endif + +#ifdef EUCSRA + DEFINE(EUCSRA) +#else + MISSING(EUCSRA) +#endif + +#ifdef EUCSRB + DEFINE(EUCSRB) +#else + MISSING(EUCSRB) +#endif + +#ifdef EUCSRC + DEFINE(EUCSRC) +#else + MISSING(EUCSRC) +#endif + +#ifdef EUDR + DEFINE(EUDR) +#else + MISSING(EUDR) +#endif + +#ifdef EVSYS_CH0CTRL + DEFINE(EVSYS_CH0CTRL) +#else + MISSING(EVSYS_CH0CTRL) +#endif + +#ifdef EVSYS_CH0MUX + DEFINE(EVSYS_CH0MUX) +#else + MISSING(EVSYS_CH0MUX) +#endif + +#ifdef EVSYS_CH1CTRL + DEFINE(EVSYS_CH1CTRL) +#else + MISSING(EVSYS_CH1CTRL) +#endif + +#ifdef EVSYS_CH1MUX + DEFINE(EVSYS_CH1MUX) +#else + MISSING(EVSYS_CH1MUX) +#endif + +#ifdef EVSYS_CH2CTRL + DEFINE(EVSYS_CH2CTRL) +#else + MISSING(EVSYS_CH2CTRL) +#endif + +#ifdef EVSYS_CH2MUX + DEFINE(EVSYS_CH2MUX) +#else + MISSING(EVSYS_CH2MUX) +#endif + +#ifdef EVSYS_CH3CTRL + DEFINE(EVSYS_CH3CTRL) +#else + MISSING(EVSYS_CH3CTRL) +#endif + +#ifdef EVSYS_CH3MUX + DEFINE(EVSYS_CH3MUX) +#else + MISSING(EVSYS_CH3MUX) +#endif + +#ifdef EVSYS_CH4CTRL + DEFINE(EVSYS_CH4CTRL) +#else + MISSING(EVSYS_CH4CTRL) +#endif + +#ifdef EVSYS_CH4MUX + DEFINE(EVSYS_CH4MUX) +#else + MISSING(EVSYS_CH4MUX) +#endif + +#ifdef EVSYS_CH5CTRL + DEFINE(EVSYS_CH5CTRL) +#else + MISSING(EVSYS_CH5CTRL) +#endif + +#ifdef EVSYS_CH5MUX + DEFINE(EVSYS_CH5MUX) +#else + MISSING(EVSYS_CH5MUX) +#endif + +#ifdef EVSYS_CH6CTRL + DEFINE(EVSYS_CH6CTRL) +#else + MISSING(EVSYS_CH6CTRL) +#endif + +#ifdef EVSYS_CH6MUX + DEFINE(EVSYS_CH6MUX) +#else + MISSING(EVSYS_CH6MUX) +#endif + +#ifdef EVSYS_CH7CTRL + DEFINE(EVSYS_CH7CTRL) +#else + MISSING(EVSYS_CH7CTRL) +#endif + +#ifdef EVSYS_CH7MUX + DEFINE(EVSYS_CH7MUX) +#else + MISSING(EVSYS_CH7MUX) +#endif + +#ifdef EVSYS_DATA + DEFINE(EVSYS_DATA) +#else + MISSING(EVSYS_DATA) +#endif + +#ifdef EVSYS_STROBE + DEFINE(EVSYS_STROBE) +#else + MISSING(EVSYS_STROBE) +#endif + +#ifdef EXOCR1A + DEFINE(EXOCR1A) +#else + MISSING(EXOCR1A) +#endif + +#ifdef EXOCR1AH + DEFINE(EXOCR1AH) +#else + MISSING(EXOCR1AH) +#endif + +#ifdef EXOCR1AL + DEFINE(EXOCR1AL) +#else + MISSING(EXOCR1AL) +#endif + +#ifdef EXOCR1B + DEFINE(EXOCR1B) +#else + MISSING(EXOCR1B) +#endif + +#ifdef EXOCR1BH + DEFINE(EXOCR1BH) +#else + MISSING(EXOCR1BH) +#endif + +#ifdef EXOCR1BL + DEFINE(EXOCR1BL) +#else + MISSING(EXOCR1BL) +#endif + +#ifdef EXTCCR0 + DEFINE(EXTCCR0) +#else + MISSING(EXTCCR0) +#endif + +#ifdef EXTCCR1A + DEFINE(EXTCCR1A) +#else + MISSING(EXTCCR1A) +#endif + +#ifdef EXTCCR1B + DEFINE(EXTCCR1B) +#else + MISSING(EXTCCR1B) +#endif + +#ifdef EXTCNT + DEFINE(EXTCNT) +#else + MISSING(EXTCNT) +#endif + +#ifdef EXTCNT1 + DEFINE(EXTCNT1) +#else + MISSING(EXTCNT1) +#endif + +#ifdef EXTCNT1H + DEFINE(EXTCNT1H) +#else + MISSING(EXTCNT1H) +#endif + +#ifdef EXTCNT1L + DEFINE(EXTCNT1L) +#else + MISSING(EXTCNT1L) +#endif + +#ifdef EXTIFR + DEFINE(EXTIFR) +#else + MISSING(EXTIFR) +#endif + +#ifdef EXTIMSK + DEFINE(EXTIMSK) +#else + MISSING(EXTIMSK) +#endif + +#ifdef FCSR + DEFINE(FCSR) +#else + MISSING(FCSR) +#endif + +#ifdef FISCR + DEFINE(FISCR) +#else + MISSING(FISCR) +#endif + +#ifdef FISUA + DEFINE(FISUA) +#else + MISSING(FISUA) +#endif + +#ifdef FISUB + DEFINE(FISUB) +#else + MISSING(FISUB) +#endif + +#ifdef FISUC + DEFINE(FISUC) +#else + MISSING(FISUC) +#endif + +#ifdef FISUD + DEFINE(FISUD) +#else + MISSING(FISUD) +#endif + +#ifdef FOSCCAL + DEFINE(FOSCCAL) +#else + MISSING(FOSCCAL) +#endif + +#ifdef FPGAD + DEFINE(FPGAD) +#else + MISSING(FPGAD) +#endif + +#ifdef FPGAX + DEFINE(FPGAX) +#else + MISSING(FPGAX) +#endif + +#ifdef FPGAY + DEFINE(FPGAY) +#else + MISSING(FPGAY) +#endif + +#ifdef FPGAZ + DEFINE(FPGAZ) +#else + MISSING(FPGAZ) +#endif + +#ifdef FRCCAL + DEFINE(FRCCAL) +#else + MISSING(FRCCAL) +#endif + +#ifdef FTN_CTRL + DEFINE(FTN_CTRL) +#else + MISSING(FTN_CTRL) +#endif + +#ifdef GAINDAC + DEFINE(GAINDAC) +#else + MISSING(GAINDAC) +#endif + +#ifdef GICR + DEFINE(GICR) +#else + MISSING(GICR) +#endif + +#ifdef GIFR + DEFINE(GIFR) +#else + MISSING(GIFR) +#endif + +#ifdef GIMSK + DEFINE(GIMSK) +#else + MISSING(GIMSK) +#endif + +#ifdef GIPR + DEFINE(GIPR) +#else + MISSING(GIPR) +#endif + +#ifdef GPIO0 + DEFINE(GPIO0) +#else + MISSING(GPIO0) +#endif + +#ifdef GPIO1 + DEFINE(GPIO1) +#else + MISSING(GPIO1) +#endif + +#ifdef GPIO2 + DEFINE(GPIO2) +#else + MISSING(GPIO2) +#endif + +#ifdef GPIO3 + DEFINE(GPIO3) +#else + MISSING(GPIO3) +#endif + +#ifdef GPIO4 + DEFINE(GPIO4) +#else + MISSING(GPIO4) +#endif + +#ifdef GPIO5 + DEFINE(GPIO5) +#else + MISSING(GPIO5) +#endif + +#ifdef GPIO6 + DEFINE(GPIO6) +#else + MISSING(GPIO6) +#endif + +#ifdef GPIO7 + DEFINE(GPIO7) +#else + MISSING(GPIO7) +#endif + +#ifdef GPIO8 + DEFINE(GPIO8) +#else + MISSING(GPIO8) +#endif + +#ifdef GPIO9 + DEFINE(GPIO9) +#else + MISSING(GPIO9) +#endif + +#ifdef GPIOA + DEFINE(GPIOA) +#else + MISSING(GPIOA) +#endif + +#ifdef GPIOB + DEFINE(GPIOB) +#else + MISSING(GPIOB) +#endif + +#ifdef GPIOC + DEFINE(GPIOC) +#else + MISSING(GPIOC) +#endif + +#ifdef GPIOD + DEFINE(GPIOD) +#else + MISSING(GPIOD) +#endif + +#ifdef GPIOE + DEFINE(GPIOE) +#else + MISSING(GPIOE) +#endif + +#ifdef GPIOF + DEFINE(GPIOF) +#else + MISSING(GPIOF) +#endif + +#ifdef GPIOR0 + DEFINE(GPIOR0) +#else + MISSING(GPIOR0) +#endif + +#ifdef GPIOR1 + DEFINE(GPIOR1) +#else + MISSING(GPIOR1) +#endif + +#ifdef GPIOR2 + DEFINE(GPIOR2) +#else + MISSING(GPIOR2) +#endif + +#ifdef GPIOR3 + DEFINE(GPIOR3) +#else + MISSING(GPIOR3) +#endif + +#ifdef GPIOR4 + DEFINE(GPIOR4) +#else + MISSING(GPIOR4) +#endif + +#ifdef GPIOR5 + DEFINE(GPIOR5) +#else + MISSING(GPIOR5) +#endif + +#ifdef GPIOR6 + DEFINE(GPIOR6) +#else + MISSING(GPIOR6) +#endif + +#ifdef GPIOR7 + DEFINE(GPIOR7) +#else + MISSING(GPIOR7) +#endif + +#ifdef GPIOR8 + DEFINE(GPIOR8) +#else + MISSING(GPIOR8) +#endif + +#ifdef GPIOR9 + DEFINE(GPIOR9) +#else + MISSING(GPIOR9) +#endif + +#ifdef GPIORA + DEFINE(GPIORA) +#else + MISSING(GPIORA) +#endif + +#ifdef GPIORB + DEFINE(GPIORB) +#else + MISSING(GPIORB) +#endif + +#ifdef GPIORC + DEFINE(GPIORC) +#else + MISSING(GPIORC) +#endif + +#ifdef GPIORD + DEFINE(GPIORD) +#else + MISSING(GPIORD) +#endif + +#ifdef GPIORE + DEFINE(GPIORE) +#else + MISSING(GPIORE) +#endif + +#ifdef GPIORF + DEFINE(GPIORF) +#else + MISSING(GPIORF) +#endif + +#ifdef GPIO_GPIO0 + DEFINE(GPIO_GPIO0) +#else + MISSING(GPIO_GPIO0) +#endif + +#ifdef GPIO_GPIO1 + DEFINE(GPIO_GPIO1) +#else + MISSING(GPIO_GPIO1) +#endif + +#ifdef GPIO_GPIO2 + DEFINE(GPIO_GPIO2) +#else + MISSING(GPIO_GPIO2) +#endif + +#ifdef GPIO_GPIO3 + DEFINE(GPIO_GPIO3) +#else + MISSING(GPIO_GPIO3) +#endif + +#ifdef GPIO_GPIO4 + DEFINE(GPIO_GPIO4) +#else + MISSING(GPIO_GPIO4) +#endif + +#ifdef GPIO_GPIO5 + DEFINE(GPIO_GPIO5) +#else + MISSING(GPIO_GPIO5) +#endif + +#ifdef GPIO_GPIO6 + DEFINE(GPIO_GPIO6) +#else + MISSING(GPIO_GPIO6) +#endif + +#ifdef GPIO_GPIO7 + DEFINE(GPIO_GPIO7) +#else + MISSING(GPIO_GPIO7) +#endif + +#ifdef GPIO_GPIO8 + DEFINE(GPIO_GPIO8) +#else + MISSING(GPIO_GPIO8) +#endif + +#ifdef GPIO_GPIO9 + DEFINE(GPIO_GPIO9) +#else + MISSING(GPIO_GPIO9) +#endif + +#ifdef GPIO_GPIOA + DEFINE(GPIO_GPIOA) +#else + MISSING(GPIO_GPIOA) +#endif + +#ifdef GPIO_GPIOB + DEFINE(GPIO_GPIOB) +#else + MISSING(GPIO_GPIOB) +#endif + +#ifdef GPIO_GPIOC + DEFINE(GPIO_GPIOC) +#else + MISSING(GPIO_GPIOC) +#endif + +#ifdef GPIO_GPIOD + DEFINE(GPIO_GPIOD) +#else + MISSING(GPIO_GPIOD) +#endif + +#ifdef GPIO_GPIOE + DEFINE(GPIO_GPIOE) +#else + MISSING(GPIO_GPIOE) +#endif + +#ifdef GPIO_GPIOF + DEFINE(GPIO_GPIOF) +#else + MISSING(GPIO_GPIOF) +#endif + +#ifdef GPIO_GPIOR0 + DEFINE(GPIO_GPIOR0) +#else + MISSING(GPIO_GPIOR0) +#endif + +#ifdef GPIO_GPIOR1 + DEFINE(GPIO_GPIOR1) +#else + MISSING(GPIO_GPIOR1) +#endif + +#ifdef GPIO_GPIOR2 + DEFINE(GPIO_GPIOR2) +#else + MISSING(GPIO_GPIOR2) +#endif + +#ifdef GPIO_GPIOR3 + DEFINE(GPIO_GPIOR3) +#else + MISSING(GPIO_GPIOR3) +#endif + +#ifdef GPIO_GPIOR4 + DEFINE(GPIO_GPIOR4) +#else + MISSING(GPIO_GPIOR4) +#endif + +#ifdef GPIO_GPIOR5 + DEFINE(GPIO_GPIOR5) +#else + MISSING(GPIO_GPIOR5) +#endif + +#ifdef GPIO_GPIOR6 + DEFINE(GPIO_GPIOR6) +#else + MISSING(GPIO_GPIOR6) +#endif + +#ifdef GPIO_GPIOR7 + DEFINE(GPIO_GPIOR7) +#else + MISSING(GPIO_GPIOR7) +#endif + +#ifdef GPIO_GPIOR8 + DEFINE(GPIO_GPIOR8) +#else + MISSING(GPIO_GPIOR8) +#endif + +#ifdef GPIO_GPIOR9 + DEFINE(GPIO_GPIOR9) +#else + MISSING(GPIO_GPIOR9) +#endif + +#ifdef GPIO_GPIORA + DEFINE(GPIO_GPIORA) +#else + MISSING(GPIO_GPIORA) +#endif + +#ifdef GPIO_GPIORB + DEFINE(GPIO_GPIORB) +#else + MISSING(GPIO_GPIORB) +#endif + +#ifdef GPIO_GPIORC + DEFINE(GPIO_GPIORC) +#else + MISSING(GPIO_GPIORC) +#endif + +#ifdef GPIO_GPIORD + DEFINE(GPIO_GPIORD) +#else + MISSING(GPIO_GPIORD) +#endif + +#ifdef GPIO_GPIORE + DEFINE(GPIO_GPIORE) +#else + MISSING(GPIO_GPIORE) +#endif + +#ifdef GPIO_GPIORF + DEFINE(GPIO_GPIORF) +#else + MISSING(GPIO_GPIORF) +#endif + +#ifdef GTCCR + DEFINE(GTCCR) +#else + MISSING(GTCCR) +#endif + +#ifdef HIRESC_CTRLA + DEFINE(HIRESC_CTRLA) +#else + MISSING(HIRESC_CTRLA) +#endif + +#ifdef HIRESD_CTRLA + DEFINE(HIRESD_CTRLA) +#else + MISSING(HIRESD_CTRLA) +#endif + +#ifdef HIRESE_CTRLA + DEFINE(HIRESE_CTRLA) +#else + MISSING(HIRESE_CTRLA) +#endif + +#ifdef HIRESF_CTRLA + DEFINE(HIRESF_CTRLA) +#else + MISSING(HIRESF_CTRLA) +#endif + +#ifdef HSSPICFG + DEFINE(HSSPICFG) +#else + MISSING(HSSPICFG) +#endif + +#ifdef HSSPICNT + DEFINE(HSSPICNT) +#else + MISSING(HSSPICNT) +#endif + +#ifdef HSSPICR + DEFINE(HSSPICR) +#else + MISSING(HSSPICR) +#endif + +#ifdef HSSPIDMAB + DEFINE(HSSPIDMAB) +#else + MISSING(HSSPIDMAB) +#endif + +#ifdef HSSPIDMACS + DEFINE(HSSPIDMACS) +#else + MISSING(HSSPIDMACS) +#endif + +#ifdef HSSPIDMAD + DEFINE(HSSPIDMAD) +#else + MISSING(HSSPIDMAD) +#endif + +#ifdef HSSPIDMADH + DEFINE(HSSPIDMADH) +#else + MISSING(HSSPIDMADH) +#endif + +#ifdef HSSPIDMADL + DEFINE(HSSPIDMADL) +#else + MISSING(HSSPIDMADL) +#endif + +#ifdef HSSPIGTR + DEFINE(HSSPIGTR) +#else + MISSING(HSSPIGTR) +#endif + +#ifdef HSSPIIER + DEFINE(HSSPIIER) +#else + MISSING(HSSPIIER) +#endif + +#ifdef HSSPIIR + DEFINE(HSSPIIR) +#else + MISSING(HSSPIIR) +#endif + +#ifdef HSSPIRDR + DEFINE(HSSPIRDR) +#else + MISSING(HSSPIRDR) +#endif + +#ifdef HSSPISR + DEFINE(HSSPISR) +#else + MISSING(HSSPISR) +#endif + +#ifdef HSSPITDR + DEFINE(HSSPITDR) +#else + MISSING(HSSPITDR) +#endif + +#ifdef HSSPITO + DEFINE(HSSPITO) +#else + MISSING(HSSPITO) +#endif + +#ifdef HSSPITOH + DEFINE(HSSPITOH) +#else + MISSING(HSSPITOH) +#endif + +#ifdef HSSPITOL + DEFINE(HSSPITOL) +#else + MISSING(HSSPITOL) +#endif + +#ifdef ICR + DEFINE(ICR) +#else + MISSING(ICR) +#endif + +#ifdef ICR0 + DEFINE(ICR0) +#else + MISSING(ICR0) +#endif + +#ifdef ICR0H + DEFINE(ICR0H) +#else + MISSING(ICR0H) +#endif + +#ifdef ICR0L + DEFINE(ICR0L) +#else + MISSING(ICR0L) +#endif + +#ifdef ICR1 + DEFINE(ICR1) +#else + MISSING(ICR1) +#endif + +#ifdef ICR1H + DEFINE(ICR1H) +#else + MISSING(ICR1H) +#endif + +#ifdef ICR1L + DEFINE(ICR1L) +#else + MISSING(ICR1L) +#endif + +#ifdef ICR3 + DEFINE(ICR3) +#else + MISSING(ICR3) +#endif + +#ifdef ICR3H + DEFINE(ICR3H) +#else + MISSING(ICR3H) +#endif + +#ifdef ICR3L + DEFINE(ICR3L) +#else + MISSING(ICR3L) +#endif + +#ifdef ICR4 + DEFINE(ICR4) +#else + MISSING(ICR4) +#endif + +#ifdef ICR4H + DEFINE(ICR4H) +#else + MISSING(ICR4H) +#endif + +#ifdef ICR4L + DEFINE(ICR4L) +#else + MISSING(ICR4L) +#endif + +#ifdef ICR5 + DEFINE(ICR5) +#else + MISSING(ICR5) +#endif + +#ifdef ICR5H + DEFINE(ICR5H) +#else + MISSING(ICR5H) +#endif + +#ifdef ICR5L + DEFINE(ICR5L) +#else + MISSING(ICR5L) +#endif + +#ifdef IDXCTRL + DEFINE(IDXCTRL) +#else + MISSING(IDXCTRL) +#endif + +#ifdef IDXIFLG + DEFINE(IDXIFLG) +#else + MISSING(IDXIFLG) +#endif + +#ifdef IDXIMSK + DEFINE(IDXIMSK) +#else + MISSING(IDXIMSK) +#endif + +#ifdef IDXMSDT + DEFINE(IDXMSDT) +#else + MISSING(IDXMSDT) +#endif + +#ifdef IDXSTRB + DEFINE(IDXSTRB) +#else + MISSING(IDXSTRB) +#endif + +#ifdef IEEE_ADDR_0 + DEFINE(IEEE_ADDR_0) +#else + MISSING(IEEE_ADDR_0) +#endif + +#ifdef IEEE_ADDR_1 + DEFINE(IEEE_ADDR_1) +#else + MISSING(IEEE_ADDR_1) +#endif + +#ifdef IEEE_ADDR_2 + DEFINE(IEEE_ADDR_2) +#else + MISSING(IEEE_ADDR_2) +#endif + +#ifdef IEEE_ADDR_3 + DEFINE(IEEE_ADDR_3) +#else + MISSING(IEEE_ADDR_3) +#endif + +#ifdef IEEE_ADDR_4 + DEFINE(IEEE_ADDR_4) +#else + MISSING(IEEE_ADDR_4) +#endif + +#ifdef IEEE_ADDR_5 + DEFINE(IEEE_ADDR_5) +#else + MISSING(IEEE_ADDR_5) +#endif + +#ifdef IEEE_ADDR_6 + DEFINE(IEEE_ADDR_6) +#else + MISSING(IEEE_ADDR_6) +#endif + +#ifdef IEEE_ADDR_7 + DEFINE(IEEE_ADDR_7) +#else + MISSING(IEEE_ADDR_7) +#endif + +#ifdef IFR + DEFINE(IFR) +#else + MISSING(IFR) +#endif + +#ifdef INOCR1A + DEFINE(INOCR1A) +#else + MISSING(INOCR1A) +#endif + +#ifdef INOCR1AH + DEFINE(INOCR1AH) +#else + MISSING(INOCR1AH) +#endif + +#ifdef INOCR1AL + DEFINE(INOCR1AL) +#else + MISSING(INOCR1AL) +#endif + +#ifdef INOCR1B + DEFINE(INOCR1B) +#else + MISSING(INOCR1B) +#endif + +#ifdef INOCR1BH + DEFINE(INOCR1BH) +#else + MISSING(INOCR1BH) +#endif + +#ifdef INOCR1BL + DEFINE(INOCR1BL) +#else + MISSING(INOCR1BL) +#endif + +#ifdef INTCCR0 + DEFINE(INTCCR0) +#else + MISSING(INTCCR0) +#endif + +#ifdef INTCCR1A + DEFINE(INTCCR1A) +#else + MISSING(INTCCR1A) +#endif + +#ifdef INTCCR1B + DEFINE(INTCCR1B) +#else + MISSING(INTCCR1B) +#endif + +#ifdef INTCNT + DEFINE(INTCNT) +#else + MISSING(INTCNT) +#endif + +#ifdef INTCNT1 + DEFINE(INTCNT1) +#else + MISSING(INTCNT1) +#endif + +#ifdef INTCNT1H + DEFINE(INTCNT1H) +#else + MISSING(INTCNT1H) +#endif + +#ifdef INTCNT1L + DEFINE(INTCNT1L) +#else + MISSING(INTCNT1L) +#endif + +#ifdef INTIFR + DEFINE(INTIFR) +#else + MISSING(INTIFR) +#endif + +#ifdef INTIMSK + DEFINE(INTIMSK) +#else + MISSING(INTIMSK) +#endif + +#ifdef IOF + DEFINE(IOF) +#else + MISSING(IOF) +#endif + +#ifdef IO_DATIN + DEFINE(IO_DATIN) +#else + MISSING(IO_DATIN) +#endif + +#ifdef IO_DATOUT + DEFINE(IO_DATOUT) +#else + MISSING(IO_DATOUT) +#endif + +#ifdef IO_ENAB + DEFINE(IO_ENAB) +#else + MISSING(IO_ENAB) +#endif + +#ifdef IPA + DEFINE(IPA) +#else + MISSING(IPA) +#endif + +#ifdef IPAH + DEFINE(IPAH) +#else + MISSING(IPAH) +#endif + +#ifdef IPAL + DEFINE(IPAL) +#else + MISSING(IPAL) +#endif + +#ifdef IPCR + DEFINE(IPCR) +#else + MISSING(IPCR) +#endif + +#ifdef IPD + DEFINE(IPD) +#else + MISSING(IPD) +#endif + +#ifdef IPDH + DEFINE(IPDH) +#else + MISSING(IPDH) +#endif + +#ifdef IPDL + DEFINE(IPDL) +#else + MISSING(IPDL) +#endif + +#ifdef IRCOM_CTRL + DEFINE(IRCOM_CTRL) +#else + MISSING(IRCOM_CTRL) +#endif + +#ifdef IRCOM_RXPLCTRL + DEFINE(IRCOM_RXPLCTRL) +#else + MISSING(IRCOM_RXPLCTRL) +#endif + +#ifdef IRCOM_TXPLCTRL + DEFINE(IRCOM_TXPLCTRL) +#else + MISSING(IRCOM_TXPLCTRL) +#endif + +#ifdef IRDAMOD + DEFINE(IRDAMOD) +#else + MISSING(IRDAMOD) +#endif + +#ifdef IRQ_MASK + DEFINE(IRQ_MASK) +#else + MISSING(IRQ_MASK) +#endif + +#ifdef IRQ_STATUS + DEFINE(IRQ_STATUS) +#else + MISSING(IRQ_STATUS) +#endif + +#ifdef KBER + DEFINE(KBER) +#else + MISSING(KBER) +#endif + +#ifdef KBFR + DEFINE(KBFR) +#else + MISSING(KBFR) +#endif + +#ifdef KBLSR + DEFINE(KBLSR) +#else + MISSING(KBLSR) +#endif + +#ifdef LCDCCR + DEFINE(LCDCCR) +#else + MISSING(LCDCCR) +#endif + +#ifdef LCDCRA + DEFINE(LCDCRA) +#else + MISSING(LCDCRA) +#endif + +#ifdef LCDCRB + DEFINE(LCDCRB) +#else + MISSING(LCDCRB) +#endif + +#ifdef LCDDR0 + DEFINE(LCDDR0) +#else + MISSING(LCDDR0) +#endif + +#ifdef LCDDR00 + DEFINE(LCDDR00) +#else + MISSING(LCDDR00) +#endif + +#ifdef LCDDR01 + DEFINE(LCDDR01) +#else + MISSING(LCDDR01) +#endif + +#ifdef LCDDR02 + DEFINE(LCDDR02) +#else + MISSING(LCDDR02) +#endif + +#ifdef LCDDR03 + DEFINE(LCDDR03) +#else + MISSING(LCDDR03) +#endif + +#ifdef LCDDR04 + DEFINE(LCDDR04) +#else + MISSING(LCDDR04) +#endif + +#ifdef LCDDR05 + DEFINE(LCDDR05) +#else + MISSING(LCDDR05) +#endif + +#ifdef LCDDR06 + DEFINE(LCDDR06) +#else + MISSING(LCDDR06) +#endif + +#ifdef LCDDR07 + DEFINE(LCDDR07) +#else + MISSING(LCDDR07) +#endif + +#ifdef LCDDR08 + DEFINE(LCDDR08) +#else + MISSING(LCDDR08) +#endif + +#ifdef LCDDR09 + DEFINE(LCDDR09) +#else + MISSING(LCDDR09) +#endif + +#ifdef LCDDR1 + DEFINE(LCDDR1) +#else + MISSING(LCDDR1) +#endif + +#ifdef LCDDR10 + DEFINE(LCDDR10) +#else + MISSING(LCDDR10) +#endif + +#ifdef LCDDR11 + DEFINE(LCDDR11) +#else + MISSING(LCDDR11) +#endif + +#ifdef LCDDR12 + DEFINE(LCDDR12) +#else + MISSING(LCDDR12) +#endif + +#ifdef LCDDR13 + DEFINE(LCDDR13) +#else + MISSING(LCDDR13) +#endif + +#ifdef LCDDR14 + DEFINE(LCDDR14) +#else + MISSING(LCDDR14) +#endif + +#ifdef LCDDR15 + DEFINE(LCDDR15) +#else + MISSING(LCDDR15) +#endif + +#ifdef LCDDR16 + DEFINE(LCDDR16) +#else + MISSING(LCDDR16) +#endif + +#ifdef LCDDR17 + DEFINE(LCDDR17) +#else + MISSING(LCDDR17) +#endif + +#ifdef LCDDR18 + DEFINE(LCDDR18) +#else + MISSING(LCDDR18) +#endif + +#ifdef LCDDR19 + DEFINE(LCDDR19) +#else + MISSING(LCDDR19) +#endif + +#ifdef LCDDR2 + DEFINE(LCDDR2) +#else + MISSING(LCDDR2) +#endif + +#ifdef LCDDR3 + DEFINE(LCDDR3) +#else + MISSING(LCDDR3) +#endif + +#ifdef LCDDR4 + DEFINE(LCDDR4) +#else + MISSING(LCDDR4) +#endif + +#ifdef LCDDR5 + DEFINE(LCDDR5) +#else + MISSING(LCDDR5) +#endif + +#ifdef LCDDR6 + DEFINE(LCDDR6) +#else + MISSING(LCDDR6) +#endif + +#ifdef LCDDR7 + DEFINE(LCDDR7) +#else + MISSING(LCDDR7) +#endif + +#ifdef LCDDR8 + DEFINE(LCDDR8) +#else + MISSING(LCDDR8) +#endif + +#ifdef LCDDR9 + DEFINE(LCDDR9) +#else + MISSING(LCDDR9) +#endif + +#ifdef LCDFRR + DEFINE(LCDFRR) +#else + MISSING(LCDFRR) +#endif + +#ifdef LEDCR + DEFINE(LEDCR) +#else + MISSING(LEDCR) +#endif + +#ifdef LFCAL + DEFINE(LFCAL) +#else + MISSING(LFCAL) +#endif + +#ifdef LFCALH + DEFINE(LFCALH) +#else + MISSING(LFCALH) +#endif + +#ifdef LFCALL + DEFINE(LFCALL) +#else + MISSING(LFCALL) +#endif + +#ifdef LFCDR + DEFINE(LFCDR) +#else + MISSING(LFCDR) +#endif + +#ifdef LFFR + DEFINE(LFFR) +#else + MISSING(LFFR) +#endif + +#ifdef LFHCR + DEFINE(LFHCR) +#else + MISSING(LFHCR) +#endif + +#ifdef LFIDC + DEFINE(LFIDC) +#else + MISSING(LFIDC) +#endif + +#ifdef LFIDCH + DEFINE(LFIDCH) +#else + MISSING(LFIDCH) +#endif + +#ifdef LFIDCL + DEFINE(LFIDCL) +#else + MISSING(LFIDCL) +#endif + +#ifdef LFIMR + DEFINE(LFIMR) +#else + MISSING(LFIMR) +#endif + +#ifdef LFRB + DEFINE(LFRB) +#else + MISSING(LFRB) +#endif + +#ifdef LFRCR + DEFINE(LFRCR) +#else + MISSING(LFRCR) +#endif + +#ifdef LFRR + DEFINE(LFRR) +#else + MISSING(LFRR) +#endif + +#ifdef LFSR0 + DEFINE(LFSR0) +#else + MISSING(LFSR0) +#endif + +#ifdef LFSR1 + DEFINE(LFSR1) +#else + MISSING(LFSR1) +#endif + +#ifdef LFSR2 + DEFINE(LFSR2) +#else + MISSING(LFSR2) +#endif + +#ifdef LFSR3 + DEFINE(LFSR3) +#else + MISSING(LFSR3) +#endif + +#ifdef LINBRR + DEFINE(LINBRR) +#else + MISSING(LINBRR) +#endif + +#ifdef LINBRRH + DEFINE(LINBRRH) +#else + MISSING(LINBRRH) +#endif + +#ifdef LINBRRL + DEFINE(LINBRRL) +#else + MISSING(LINBRRL) +#endif + +#ifdef LINBTR + DEFINE(LINBTR) +#else + MISSING(LINBTR) +#endif + +#ifdef LINCR + DEFINE(LINCR) +#else + MISSING(LINCR) +#endif + +#ifdef LINDAT + DEFINE(LINDAT) +#else + MISSING(LINDAT) +#endif + +#ifdef LINDLR + DEFINE(LINDLR) +#else + MISSING(LINDLR) +#endif + +#ifdef LINENIR + DEFINE(LINENIR) +#else + MISSING(LINENIR) +#endif + +#ifdef LINERR + DEFINE(LINERR) +#else + MISSING(LINERR) +#endif + +#ifdef LINIDR + DEFINE(LINIDR) +#else + MISSING(LINIDR) +#endif + +#ifdef LINSEL + DEFINE(LINSEL) +#else + MISSING(LINSEL) +#endif + +#ifdef LINSIR + DEFINE(LINSIR) +#else + MISSING(LINSIR) +#endif + +#ifdef LLCR + DEFINE(LLCR) +#else + MISSING(LLCR) +#endif + +#ifdef LLDRH + DEFINE(LLDRH) +#else + MISSING(LLDRH) +#endif + +#ifdef LLDRL + DEFINE(LLDRL) +#else + MISSING(LLDRL) +#endif + +#ifdef LOCKDET1 + DEFINE(LOCKDET1) +#else + MISSING(LOCKDET1) +#endif + +#ifdef LOCKDET2 + DEFINE(LOCKDET2) +#else + MISSING(LOCKDET2) +#endif + +#ifdef MAN_ID_0 + DEFINE(MAN_ID_0) +#else + MISSING(MAN_ID_0) +#endif + +#ifdef MAN_ID_1 + DEFINE(MAN_ID_1) +#else + MISSING(MAN_ID_1) +#endif + +#ifdef MCSR + DEFINE(MCSR) +#else + MISSING(MCSR) +#endif + +#ifdef MCUCR + DEFINE(MCUCR) +#else + MISSING(MCUCR) +#endif + +#ifdef MCUCS + DEFINE(MCUCS) +#else + MISSING(MCUCS) +#endif + +#ifdef MCUCSR + DEFINE(MCUCSR) +#else + MISSING(MCUCSR) +#endif + +#ifdef MCUR + DEFINE(MCUR) +#else + MISSING(MCUR) +#endif + +#ifdef MCUSR + DEFINE(MCUSR) +#else + MISSING(MCUSR) +#endif + +#ifdef MCU_ANAINIT + DEFINE(MCU_ANAINIT) +#else + MISSING(MCU_ANAINIT) +#endif + +#ifdef MCU_AWEXLOCK + DEFINE(MCU_AWEXLOCK) +#else + MISSING(MCU_AWEXLOCK) +#endif + +#ifdef MCU_DEVID0 + DEFINE(MCU_DEVID0) +#else + MISSING(MCU_DEVID0) +#endif + +#ifdef MCU_DEVID1 + DEFINE(MCU_DEVID1) +#else + MISSING(MCU_DEVID1) +#endif + +#ifdef MCU_DEVID2 + DEFINE(MCU_DEVID2) +#else + MISSING(MCU_DEVID2) +#endif + +#ifdef MCU_EVSYSLOCK + DEFINE(MCU_EVSYSLOCK) +#else + MISSING(MCU_EVSYSLOCK) +#endif + +#ifdef MCU_JTAGUID + DEFINE(MCU_JTAGUID) +#else + MISSING(MCU_JTAGUID) +#endif + +#ifdef MCU_MCUCR + DEFINE(MCU_MCUCR) +#else + MISSING(MCU_MCUCR) +#endif + +#ifdef MCU_REVID + DEFINE(MCU_REVID) +#else + MISSING(MCU_REVID) +#endif + +#ifdef MODCR + DEFINE(MODCR) +#else + MISSING(MODCR) +#endif + +#ifdef MONDR + DEFINE(MONDR) +#else + MISSING(MONDR) +#endif + +#ifdef MSELR + DEFINE(MSELR) +#else + MISSING(MSELR) +#endif + +#ifdef MSMCR + DEFINE(MSMCR) +#else + MISSING(MSMCR) +#endif + +#ifdef MSPCR + DEFINE(MSPCR) +#else + MISSING(MSPCR) +#endif + +#ifdef MSPDR + DEFINE(MSPDR) +#else + MISSING(MSPDR) +#endif + +#ifdef MSPSR + DEFINE(MSPSR) +#else + MISSING(MSPSR) +#endif + +#ifdef MSVCAL + DEFINE(MSVCAL) +#else + MISSING(MSVCAL) +#endif + +#ifdef MUBRR + DEFINE(MUBRR) +#else + MISSING(MUBRR) +#endif + +#ifdef MUBRRH + DEFINE(MUBRRH) +#else + MISSING(MUBRRH) +#endif + +#ifdef MUBRRL + DEFINE(MUBRRL) +#else + MISSING(MUBRRL) +#endif + +#ifdef NEMCR + DEFINE(NEMCR) +#else + MISSING(NEMCR) +#endif + +#ifdef NVMCMD + DEFINE(NVMCMD) +#else + MISSING(NVMCMD) +#endif + +#ifdef NVMCSR + DEFINE(NVMCSR) +#else + MISSING(NVMCSR) +#endif + +#ifdef NVM_ADDR0 + DEFINE(NVM_ADDR0) +#else + MISSING(NVM_ADDR0) +#endif + +#ifdef NVM_ADDR1 + DEFINE(NVM_ADDR1) +#else + MISSING(NVM_ADDR1) +#endif + +#ifdef NVM_ADDR2 + DEFINE(NVM_ADDR2) +#else + MISSING(NVM_ADDR2) +#endif + +#ifdef NVM_CMD + DEFINE(NVM_CMD) +#else + MISSING(NVM_CMD) +#endif + +#ifdef NVM_CTRLA + DEFINE(NVM_CTRLA) +#else + MISSING(NVM_CTRLA) +#endif + +#ifdef NVM_CTRLB + DEFINE(NVM_CTRLB) +#else + MISSING(NVM_CTRLB) +#endif + +#ifdef NVM_DATA0 + DEFINE(NVM_DATA0) +#else + MISSING(NVM_DATA0) +#endif + +#ifdef NVM_DATA1 + DEFINE(NVM_DATA1) +#else + MISSING(NVM_DATA1) +#endif + +#ifdef NVM_DATA2 + DEFINE(NVM_DATA2) +#else + MISSING(NVM_DATA2) +#endif + +#ifdef NVM_INTCTRL + DEFINE(NVM_INTCTRL) +#else + MISSING(NVM_INTCTRL) +#endif + +#ifdef NVM_LOCKBITS + DEFINE(NVM_LOCKBITS) +#else + MISSING(NVM_LOCKBITS) +#endif + +#ifdef NVM_STATUS + DEFINE(NVM_STATUS) +#else + MISSING(NVM_STATUS) +#endif + +#ifdef OCDR + DEFINE(OCDR) +#else + MISSING(OCDR) +#endif + +#ifdef OCD_OCDR0 + DEFINE(OCD_OCDR0) +#else + MISSING(OCD_OCDR0) +#endif + +#ifdef OCD_OCDR1 + DEFINE(OCD_OCDR1) +#else + MISSING(OCD_OCDR1) +#endif + +#ifdef OCR0 + DEFINE(OCR0) +#else + MISSING(OCR0) +#endif + +#ifdef OCR0A + DEFINE(OCR0A) +#else + MISSING(OCR0A) +#endif + +#ifdef OCR0AH + DEFINE(OCR0AH) +#else + MISSING(OCR0AH) +#endif + +#ifdef OCR0AL + DEFINE(OCR0AL) +#else + MISSING(OCR0AL) +#endif + +#ifdef OCR0B + DEFINE(OCR0B) +#else + MISSING(OCR0B) +#endif + +#ifdef OCR0BH + DEFINE(OCR0BH) +#else + MISSING(OCR0BH) +#endif + +#ifdef OCR0BL + DEFINE(OCR0BL) +#else + MISSING(OCR0BL) +#endif + +#ifdef OCR0RA + DEFINE(OCR0RA) +#else + MISSING(OCR0RA) +#endif + +#ifdef OCR0RAH + DEFINE(OCR0RAH) +#else + MISSING(OCR0RAH) +#endif + +#ifdef OCR0RAL + DEFINE(OCR0RAL) +#else + MISSING(OCR0RAL) +#endif + +#ifdef OCR0RB + DEFINE(OCR0RB) +#else + MISSING(OCR0RB) +#endif + +#ifdef OCR0RBH + DEFINE(OCR0RBH) +#else + MISSING(OCR0RBH) +#endif + +#ifdef OCR0RBL + DEFINE(OCR0RBL) +#else + MISSING(OCR0RBL) +#endif + +#ifdef OCR0SA + DEFINE(OCR0SA) +#else + MISSING(OCR0SA) +#endif + +#ifdef OCR0SAH + DEFINE(OCR0SAH) +#else + MISSING(OCR0SAH) +#endif + +#ifdef OCR0SAL + DEFINE(OCR0SAL) +#else + MISSING(OCR0SAL) +#endif + +#ifdef OCR0SB + DEFINE(OCR0SB) +#else + MISSING(OCR0SB) +#endif + +#ifdef OCR0SBH + DEFINE(OCR0SBH) +#else + MISSING(OCR0SBH) +#endif + +#ifdef OCR0SBL + DEFINE(OCR0SBL) +#else + MISSING(OCR0SBL) +#endif + +#ifdef OCR1 + DEFINE(OCR1) +#else + MISSING(OCR1) +#endif + +#ifdef OCR1A + DEFINE(OCR1A) +#else + MISSING(OCR1A) +#endif + +#ifdef OCR1AH + DEFINE(OCR1AH) +#else + MISSING(OCR1AH) +#endif + +#ifdef OCR1AL + DEFINE(OCR1AL) +#else + MISSING(OCR1AL) +#endif + +#ifdef OCR1B + DEFINE(OCR1B) +#else + MISSING(OCR1B) +#endif + +#ifdef OCR1BH + DEFINE(OCR1BH) +#else + MISSING(OCR1BH) +#endif + +#ifdef OCR1BL + DEFINE(OCR1BL) +#else + MISSING(OCR1BL) +#endif + +#ifdef OCR1C + DEFINE(OCR1C) +#else + MISSING(OCR1C) +#endif + +#ifdef OCR1CH + DEFINE(OCR1CH) +#else + MISSING(OCR1CH) +#endif + +#ifdef OCR1CL + DEFINE(OCR1CL) +#else + MISSING(OCR1CL) +#endif + +#ifdef OCR1D + DEFINE(OCR1D) +#else + MISSING(OCR1D) +#endif + +#ifdef OCR1H + DEFINE(OCR1H) +#else + MISSING(OCR1H) +#endif + +#ifdef OCR1L + DEFINE(OCR1L) +#else + MISSING(OCR1L) +#endif + +#ifdef OCR1RA + DEFINE(OCR1RA) +#else + MISSING(OCR1RA) +#endif + +#ifdef OCR1RAH + DEFINE(OCR1RAH) +#else + MISSING(OCR1RAH) +#endif + +#ifdef OCR1RAL + DEFINE(OCR1RAL) +#else + MISSING(OCR1RAL) +#endif + +#ifdef OCR1RB + DEFINE(OCR1RB) +#else + MISSING(OCR1RB) +#endif + +#ifdef OCR1RBH + DEFINE(OCR1RBH) +#else + MISSING(OCR1RBH) +#endif + +#ifdef OCR1RBL + DEFINE(OCR1RBL) +#else + MISSING(OCR1RBL) +#endif + +#ifdef OCR1SA + DEFINE(OCR1SA) +#else + MISSING(OCR1SA) +#endif + +#ifdef OCR1SAH + DEFINE(OCR1SAH) +#else + MISSING(OCR1SAH) +#endif + +#ifdef OCR1SAL + DEFINE(OCR1SAL) +#else + MISSING(OCR1SAL) +#endif + +#ifdef OCR1SB + DEFINE(OCR1SB) +#else + MISSING(OCR1SB) +#endif + +#ifdef OCR1SBH + DEFINE(OCR1SBH) +#else + MISSING(OCR1SBH) +#endif + +#ifdef OCR1SBL + DEFINE(OCR1SBL) +#else + MISSING(OCR1SBL) +#endif + +#ifdef OCR2 + DEFINE(OCR2) +#else + MISSING(OCR2) +#endif + +#ifdef OCR2A + DEFINE(OCR2A) +#else + MISSING(OCR2A) +#endif + +#ifdef OCR2B + DEFINE(OCR2B) +#else + MISSING(OCR2B) +#endif + +#ifdef OCR2RA + DEFINE(OCR2RA) +#else + MISSING(OCR2RA) +#endif + +#ifdef OCR2RAH + DEFINE(OCR2RAH) +#else + MISSING(OCR2RAH) +#endif + +#ifdef OCR2RAL + DEFINE(OCR2RAL) +#else + MISSING(OCR2RAL) +#endif + +#ifdef OCR2RB + DEFINE(OCR2RB) +#else + MISSING(OCR2RB) +#endif + +#ifdef OCR2RBH + DEFINE(OCR2RBH) +#else + MISSING(OCR2RBH) +#endif + +#ifdef OCR2RBL + DEFINE(OCR2RBL) +#else + MISSING(OCR2RBL) +#endif + +#ifdef OCR2SA + DEFINE(OCR2SA) +#else + MISSING(OCR2SA) +#endif + +#ifdef OCR2SAH + DEFINE(OCR2SAH) +#else + MISSING(OCR2SAH) +#endif + +#ifdef OCR2SAL + DEFINE(OCR2SAL) +#else + MISSING(OCR2SAL) +#endif + +#ifdef OCR2SB + DEFINE(OCR2SB) +#else + MISSING(OCR2SB) +#endif + +#ifdef OCR2SBH + DEFINE(OCR2SBH) +#else + MISSING(OCR2SBH) +#endif + +#ifdef OCR2SBL + DEFINE(OCR2SBL) +#else + MISSING(OCR2SBL) +#endif + +#ifdef OCR3A + DEFINE(OCR3A) +#else + MISSING(OCR3A) +#endif + +#ifdef OCR3AH + DEFINE(OCR3AH) +#else + MISSING(OCR3AH) +#endif + +#ifdef OCR3AL + DEFINE(OCR3AL) +#else + MISSING(OCR3AL) +#endif + +#ifdef OCR3B + DEFINE(OCR3B) +#else + MISSING(OCR3B) +#endif + +#ifdef OCR3BH + DEFINE(OCR3BH) +#else + MISSING(OCR3BH) +#endif + +#ifdef OCR3BL + DEFINE(OCR3BL) +#else + MISSING(OCR3BL) +#endif + +#ifdef OCR3C + DEFINE(OCR3C) +#else + MISSING(OCR3C) +#endif + +#ifdef OCR3CH + DEFINE(OCR3CH) +#else + MISSING(OCR3CH) +#endif + +#ifdef OCR3CL + DEFINE(OCR3CL) +#else + MISSING(OCR3CL) +#endif + +#ifdef OCR4A + DEFINE(OCR4A) +#else + MISSING(OCR4A) +#endif + +#ifdef OCR4AH + DEFINE(OCR4AH) +#else + MISSING(OCR4AH) +#endif + +#ifdef OCR4AL + DEFINE(OCR4AL) +#else + MISSING(OCR4AL) +#endif + +#ifdef OCR4B + DEFINE(OCR4B) +#else + MISSING(OCR4B) +#endif + +#ifdef OCR4BH + DEFINE(OCR4BH) +#else + MISSING(OCR4BH) +#endif + +#ifdef OCR4BL + DEFINE(OCR4BL) +#else + MISSING(OCR4BL) +#endif + +#ifdef OCR4C + DEFINE(OCR4C) +#else + MISSING(OCR4C) +#endif + +#ifdef OCR4CH + DEFINE(OCR4CH) +#else + MISSING(OCR4CH) +#endif + +#ifdef OCR4CL + DEFINE(OCR4CL) +#else + MISSING(OCR4CL) +#endif + +#ifdef OCR4D + DEFINE(OCR4D) +#else + MISSING(OCR4D) +#endif + +#ifdef OCR5A + DEFINE(OCR5A) +#else + MISSING(OCR5A) +#endif + +#ifdef OCR5AH + DEFINE(OCR5AH) +#else + MISSING(OCR5AH) +#endif + +#ifdef OCR5AL + DEFINE(OCR5AL) +#else + MISSING(OCR5AL) +#endif + +#ifdef OCR5B + DEFINE(OCR5B) +#else + MISSING(OCR5B) +#endif + +#ifdef OCR5BH + DEFINE(OCR5BH) +#else + MISSING(OCR5BH) +#endif + +#ifdef OCR5BL + DEFINE(OCR5BL) +#else + MISSING(OCR5BL) +#endif + +#ifdef OCR5C + DEFINE(OCR5C) +#else + MISSING(OCR5C) +#endif + +#ifdef OCR5CH + DEFINE(OCR5CH) +#else + MISSING(OCR5CH) +#endif + +#ifdef OCR5CL + DEFINE(OCR5CL) +#else + MISSING(OCR5CL) +#endif + +#ifdef OCRA1 + DEFINE(OCRA1) +#else + MISSING(OCRA1) +#endif + +#ifdef OCRA1H + DEFINE(OCRA1H) +#else + MISSING(OCRA1H) +#endif + +#ifdef OCRA1L + DEFINE(OCRA1L) +#else + MISSING(OCRA1L) +#endif + +#ifdef OCRB1 + DEFINE(OCRB1) +#else + MISSING(OCRB1) +#endif + +#ifdef OCRB1H + DEFINE(OCRB1H) +#else + MISSING(OCRB1H) +#endif + +#ifdef OCRB1L + DEFINE(OCRB1L) +#else + MISSING(OCRB1L) +#endif + +#ifdef OSCCAL + DEFINE(OSCCAL) +#else + MISSING(OSCCAL) +#endif + +#ifdef OSC_CTRL + DEFINE(OSC_CTRL) +#else + MISSING(OSC_CTRL) +#endif + +#ifdef OSC_DFLLCTRL + DEFINE(OSC_DFLLCTRL) +#else + MISSING(OSC_DFLLCTRL) +#endif + +#ifdef OSC_PLLCTRL + DEFINE(OSC_PLLCTRL) +#else + MISSING(OSC_PLLCTRL) +#endif + +#ifdef OSC_RC32KCAL + DEFINE(OSC_RC32KCAL) +#else + MISSING(OSC_RC32KCAL) +#endif + +#ifdef OSC_STATUS + DEFINE(OSC_STATUS) +#else + MISSING(OSC_STATUS) +#endif + +#ifdef OSC_XOSCCTRL + DEFINE(OSC_XOSCCTRL) +#else + MISSING(OSC_XOSCCTRL) +#endif + +#ifdef OSC_XOSCFAIL + DEFINE(OSC_XOSCFAIL) +#else + MISSING(OSC_XOSCFAIL) +#endif + +#ifdef OSICSR + DEFINE(OSICSR) +#else + MISSING(OSICSR) +#endif + +#ifdef OTGCON + DEFINE(OTGCON) +#else + MISSING(OTGCON) +#endif + +#ifdef OTGIEN + DEFINE(OTGIEN) +#else + MISSING(OTGIEN) +#endif + +#ifdef OTGINT + DEFINE(OTGINT) +#else + MISSING(OTGINT) +#endif + +#ifdef OTGTCON + DEFINE(OTGTCON) +#else + MISSING(OTGTCON) +#endif + +#ifdef PACR + DEFINE(PACR) +#else + MISSING(PACR) +#endif + +#ifdef PAN_ID_0 + DEFINE(PAN_ID_0) +#else + MISSING(PAN_ID_0) +#endif + +#ifdef PAN_ID_1 + DEFINE(PAN_ID_1) +#else + MISSING(PAN_ID_1) +#endif + +#ifdef PART_NUM + DEFINE(PART_NUM) +#else + MISSING(PART_NUM) +#endif + +#ifdef PASDLY2 + DEFINE(PASDLY2) +#else + MISSING(PASDLY2) +#endif + +#ifdef PBOV + DEFINE(PBOV) +#else + MISSING(PBOV) +#endif + +#ifdef PCICR + DEFINE(PCICR) +#else + MISSING(PCICR) +#endif + +#ifdef PCIFR + DEFINE(PCIFR) +#else + MISSING(PCIFR) +#endif + +#ifdef PCMSK + DEFINE(PCMSK) +#else + MISSING(PCMSK) +#endif + +#ifdef PCMSK0 + DEFINE(PCMSK0) +#else + MISSING(PCMSK0) +#endif + +#ifdef PCMSK1 + DEFINE(PCMSK1) +#else + MISSING(PCMSK1) +#endif + +#ifdef PCMSK2 + DEFINE(PCMSK2) +#else + MISSING(PCMSK2) +#endif + +#ifdef PCMSK3 + DEFINE(PCMSK3) +#else + MISSING(PCMSK3) +#endif + +#ifdef PCNF + DEFINE(PCNF) +#else + MISSING(PCNF) +#endif + +#ifdef PCNF0 + DEFINE(PCNF0) +#else + MISSING(PCNF0) +#endif + +#ifdef PCNF1 + DEFINE(PCNF1) +#else + MISSING(PCNF1) +#endif + +#ifdef PCNF2 + DEFINE(PCNF2) +#else + MISSING(PCNF2) +#endif + +#ifdef PCNFE2 + DEFINE(PCNFE2) +#else + MISSING(PCNFE2) +#endif + +#ifdef PCTL + DEFINE(PCTL) +#else + MISSING(PCTL) +#endif + +#ifdef PCTL0 + DEFINE(PCTL0) +#else + MISSING(PCTL0) +#endif + +#ifdef PCTL1 + DEFINE(PCTL1) +#else + MISSING(PCTL1) +#endif + +#ifdef PCTL2 + DEFINE(PCTL2) +#else + MISSING(PCTL2) +#endif + +#ifdef PERIPHEN + DEFINE(PERIPHEN) +#else + MISSING(PERIPHEN) +#endif + +#ifdef PFRC0A + DEFINE(PFRC0A) +#else + MISSING(PFRC0A) +#endif + +#ifdef PFRC0B + DEFINE(PFRC0B) +#else + MISSING(PFRC0B) +#endif + +#ifdef PFRC1A + DEFINE(PFRC1A) +#else + MISSING(PFRC1A) +#endif + +#ifdef PFRC1B + DEFINE(PFRC1B) +#else + MISSING(PFRC1B) +#endif + +#ifdef PFRC2A + DEFINE(PFRC2A) +#else + MISSING(PFRC2A) +#endif + +#ifdef PFRC2B + DEFINE(PFRC2B) +#else + MISSING(PFRC2B) +#endif + +#ifdef PHY_CC_CCA + DEFINE(PHY_CC_CCA) +#else + MISSING(PHY_CC_CCA) +#endif + +#ifdef PHY_ED_LEVEL + DEFINE(PHY_ED_LEVEL) +#else + MISSING(PHY_ED_LEVEL) +#endif + +#ifdef PHY_RSSI + DEFINE(PHY_RSSI) +#else + MISSING(PHY_RSSI) +#endif + +#ifdef PHY_TX_PWR + DEFINE(PHY_TX_PWR) +#else + MISSING(PHY_TX_PWR) +#endif + +#ifdef PICR0 + DEFINE(PICR0) +#else + MISSING(PICR0) +#endif + +#ifdef PICR0H + DEFINE(PICR0H) +#else + MISSING(PICR0H) +#endif + +#ifdef PICR0L + DEFINE(PICR0L) +#else + MISSING(PICR0L) +#endif + +#ifdef PICR1 + DEFINE(PICR1) +#else + MISSING(PICR1) +#endif + +#ifdef PICR1H + DEFINE(PICR1H) +#else + MISSING(PICR1H) +#endif + +#ifdef PICR1L + DEFINE(PICR1L) +#else + MISSING(PICR1L) +#endif + +#ifdef PICR2 + DEFINE(PICR2) +#else + MISSING(PICR2) +#endif + +#ifdef PICR2H + DEFINE(PICR2H) +#else + MISSING(PICR2H) +#endif + +#ifdef PICR2L + DEFINE(PICR2L) +#else + MISSING(PICR2L) +#endif + +#ifdef PIFR + DEFINE(PIFR) +#else + MISSING(PIFR) +#endif + +#ifdef PIFR0 + DEFINE(PIFR0) +#else + MISSING(PIFR0) +#endif + +#ifdef PIFR1 + DEFINE(PIFR1) +#else + MISSING(PIFR1) +#endif + +#ifdef PIFR2 + DEFINE(PIFR2) +#else + MISSING(PIFR2) +#endif + +#ifdef PIM + DEFINE(PIM) +#else + MISSING(PIM) +#endif + +#ifdef PIM0 + DEFINE(PIM0) +#else + MISSING(PIM0) +#endif + +#ifdef PIM1 + DEFINE(PIM1) +#else + MISSING(PIM1) +#endif + +#ifdef PIM2 + DEFINE(PIM2) +#else + MISSING(PIM2) +#endif + +#ifdef PINA + DEFINE(PINA) +#else + MISSING(PINA) +#endif + +#ifdef PINB + DEFINE(PINB) +#else + MISSING(PINB) +#endif + +#ifdef PINC + DEFINE(PINC) +#else + MISSING(PINC) +#endif + +#ifdef PIND + DEFINE(PIND) +#else + MISSING(PIND) +#endif + +#ifdef PINE + DEFINE(PINE) +#else + MISSING(PINE) +#endif + +#ifdef PINF + DEFINE(PINF) +#else + MISSING(PINF) +#endif + +#ifdef PING + DEFINE(PING) +#else + MISSING(PING) +#endif + +#ifdef PINH + DEFINE(PINH) +#else + MISSING(PINH) +#endif + +#ifdef PINJ + DEFINE(PINJ) +#else + MISSING(PINJ) +#endif + +#ifdef PINK + DEFINE(PINK) +#else + MISSING(PINK) +#endif + +#ifdef PINL + DEFINE(PINL) +#else + MISSING(PINL) +#endif + +#ifdef PLLCR + DEFINE(PLLCR) +#else + MISSING(PLLCR) +#endif + +#ifdef PLLCSR + DEFINE(PLLCSR) +#else + MISSING(PLLCSR) +#endif + +#ifdef PLLFRQ + DEFINE(PLLFRQ) +#else + MISSING(PLLFRQ) +#endif + +#ifdef PLL_CF + DEFINE(PLL_CF) +#else + MISSING(PLL_CF) +#endif + +#ifdef PLL_DCU + DEFINE(PLL_DCU) +#else + MISSING(PLL_DCU) +#endif + +#ifdef PMIC0 + DEFINE(PMIC0) +#else + MISSING(PMIC0) +#endif + +#ifdef PMIC1 + DEFINE(PMIC1) +#else + MISSING(PMIC1) +#endif + +#ifdef PMIC2 + DEFINE(PMIC2) +#else + MISSING(PMIC2) +#endif + +#ifdef PMIC_CTRL + DEFINE(PMIC_CTRL) +#else + MISSING(PMIC_CTRL) +#endif + +#ifdef PMIC_INTPRI + DEFINE(PMIC_INTPRI) +#else + MISSING(PMIC_INTPRI) +#endif + +#ifdef PMIC_STATUS + DEFINE(PMIC_STATUS) +#else + MISSING(PMIC_STATUS) +#endif + +#ifdef POC + DEFINE(POC) +#else + MISSING(POC) +#endif + +#ifdef POCR0RA + DEFINE(POCR0RA) +#else + MISSING(POCR0RA) +#endif + +#ifdef POCR0RAH + DEFINE(POCR0RAH) +#else + MISSING(POCR0RAH) +#endif + +#ifdef POCR0RAL + DEFINE(POCR0RAL) +#else + MISSING(POCR0RAL) +#endif + +#ifdef POCR0SA + DEFINE(POCR0SA) +#else + MISSING(POCR0SA) +#endif + +#ifdef POCR0SAH + DEFINE(POCR0SAH) +#else + MISSING(POCR0SAH) +#endif + +#ifdef POCR0SAL + DEFINE(POCR0SAL) +#else + MISSING(POCR0SAL) +#endif + +#ifdef POCR0SB + DEFINE(POCR0SB) +#else + MISSING(POCR0SB) +#endif + +#ifdef POCR0SBH + DEFINE(POCR0SBH) +#else + MISSING(POCR0SBH) +#endif + +#ifdef POCR0SBL + DEFINE(POCR0SBL) +#else + MISSING(POCR0SBL) +#endif + +#ifdef POCR1RA + DEFINE(POCR1RA) +#else + MISSING(POCR1RA) +#endif + +#ifdef POCR1RAH + DEFINE(POCR1RAH) +#else + MISSING(POCR1RAH) +#endif + +#ifdef POCR1RAL + DEFINE(POCR1RAL) +#else + MISSING(POCR1RAL) +#endif + +#ifdef POCR1SA + DEFINE(POCR1SA) +#else + MISSING(POCR1SA) +#endif + +#ifdef POCR1SAH + DEFINE(POCR1SAH) +#else + MISSING(POCR1SAH) +#endif + +#ifdef POCR1SAL + DEFINE(POCR1SAL) +#else + MISSING(POCR1SAL) +#endif + +#ifdef POCR1SB + DEFINE(POCR1SB) +#else + MISSING(POCR1SB) +#endif + +#ifdef POCR1SBH + DEFINE(POCR1SBH) +#else + MISSING(POCR1SBH) +#endif + +#ifdef POCR1SBL + DEFINE(POCR1SBL) +#else + MISSING(POCR1SBL) +#endif + +#ifdef POCR2RA + DEFINE(POCR2RA) +#else + MISSING(POCR2RA) +#endif + +#ifdef POCR2RAH + DEFINE(POCR2RAH) +#else + MISSING(POCR2RAH) +#endif + +#ifdef POCR2RAL + DEFINE(POCR2RAL) +#else + MISSING(POCR2RAL) +#endif + +#ifdef POCR2SA + DEFINE(POCR2SA) +#else + MISSING(POCR2SA) +#endif + +#ifdef POCR2SAH + DEFINE(POCR2SAH) +#else + MISSING(POCR2SAH) +#endif + +#ifdef POCR2SAL + DEFINE(POCR2SAL) +#else + MISSING(POCR2SAL) +#endif + +#ifdef POCR2SB + DEFINE(POCR2SB) +#else + MISSING(POCR2SB) +#endif + +#ifdef POCR2SBH + DEFINE(POCR2SBH) +#else + MISSING(POCR2SBH) +#endif + +#ifdef POCR2SBL + DEFINE(POCR2SBL) +#else + MISSING(POCR2SBL) +#endif + +#ifdef POCR_RB + DEFINE(POCR_RB) +#else + MISSING(POCR_RB) +#endif + +#ifdef POCR_RBH + DEFINE(POCR_RBH) +#else + MISSING(POCR_RBH) +#endif + +#ifdef POCR_RBL + DEFINE(POCR_RBL) +#else + MISSING(POCR_RBL) +#endif + +#ifdef POCRxRB + DEFINE(POCRxRB) +#else + MISSING(POCRxRB) +#endif + +#ifdef POCRxRBH + DEFINE(POCRxRBH) +#else + MISSING(POCRxRBH) +#endif + +#ifdef POCRxRBL + DEFINE(POCRxRBL) +#else + MISSING(POCRxRBL) +#endif + +#ifdef POM2 + DEFINE(POM2) +#else + MISSING(POM2) +#endif + +#ifdef PORTA + DEFINE(PORTA) +#else + MISSING(PORTA) +#endif + +#ifdef PORTA_DIR + DEFINE(PORTA_DIR) +#else + MISSING(PORTA_DIR) +#endif + +#ifdef PORTA_DIRCLR + DEFINE(PORTA_DIRCLR) +#else + MISSING(PORTA_DIRCLR) +#endif + +#ifdef PORTA_DIRSET + DEFINE(PORTA_DIRSET) +#else + MISSING(PORTA_DIRSET) +#endif + +#ifdef PORTA_DIRTGL + DEFINE(PORTA_DIRTGL) +#else + MISSING(PORTA_DIRTGL) +#endif + +#ifdef PORTA_IN + DEFINE(PORTA_IN) +#else + MISSING(PORTA_IN) +#endif + +#ifdef PORTA_INT0MASK + DEFINE(PORTA_INT0MASK) +#else + MISSING(PORTA_INT0MASK) +#endif + +#ifdef PORTA_INT1MASK + DEFINE(PORTA_INT1MASK) +#else + MISSING(PORTA_INT1MASK) +#endif + +#ifdef PORTA_INTCTRL + DEFINE(PORTA_INTCTRL) +#else + MISSING(PORTA_INTCTRL) +#endif + +#ifdef PORTA_INTFLAGS + DEFINE(PORTA_INTFLAGS) +#else + MISSING(PORTA_INTFLAGS) +#endif + +#ifdef PORTA_OUT + DEFINE(PORTA_OUT) +#else + MISSING(PORTA_OUT) +#endif + +#ifdef PORTA_OUTCLR + DEFINE(PORTA_OUTCLR) +#else + MISSING(PORTA_OUTCLR) +#endif + +#ifdef PORTA_OUTSET + DEFINE(PORTA_OUTSET) +#else + MISSING(PORTA_OUTSET) +#endif + +#ifdef PORTA_OUTTGL + DEFINE(PORTA_OUTTGL) +#else + MISSING(PORTA_OUTTGL) +#endif + +#ifdef PORTA_PIN0CTRL + DEFINE(PORTA_PIN0CTRL) +#else + MISSING(PORTA_PIN0CTRL) +#endif + +#ifdef PORTA_PIN1CTRL + DEFINE(PORTA_PIN1CTRL) +#else + MISSING(PORTA_PIN1CTRL) +#endif + +#ifdef PORTA_PIN2CTRL + DEFINE(PORTA_PIN2CTRL) +#else + MISSING(PORTA_PIN2CTRL) +#endif + +#ifdef PORTA_PIN3CTRL + DEFINE(PORTA_PIN3CTRL) +#else + MISSING(PORTA_PIN3CTRL) +#endif + +#ifdef PORTA_PIN4CTRL + DEFINE(PORTA_PIN4CTRL) +#else + MISSING(PORTA_PIN4CTRL) +#endif + +#ifdef PORTA_PIN5CTRL + DEFINE(PORTA_PIN5CTRL) +#else + MISSING(PORTA_PIN5CTRL) +#endif + +#ifdef PORTA_PIN6CTRL + DEFINE(PORTA_PIN6CTRL) +#else + MISSING(PORTA_PIN6CTRL) +#endif + +#ifdef PORTA_PIN7CTRL + DEFINE(PORTA_PIN7CTRL) +#else + MISSING(PORTA_PIN7CTRL) +#endif + +#ifdef PORTB + DEFINE(PORTB) +#else + MISSING(PORTB) +#endif + +#ifdef PORTB_DIR + DEFINE(PORTB_DIR) +#else + MISSING(PORTB_DIR) +#endif + +#ifdef PORTB_DIRCLR + DEFINE(PORTB_DIRCLR) +#else + MISSING(PORTB_DIRCLR) +#endif + +#ifdef PORTB_DIRSET + DEFINE(PORTB_DIRSET) +#else + MISSING(PORTB_DIRSET) +#endif + +#ifdef PORTB_DIRTGL + DEFINE(PORTB_DIRTGL) +#else + MISSING(PORTB_DIRTGL) +#endif + +#ifdef PORTB_IN + DEFINE(PORTB_IN) +#else + MISSING(PORTB_IN) +#endif + +#ifdef PORTB_INT0MASK + DEFINE(PORTB_INT0MASK) +#else + MISSING(PORTB_INT0MASK) +#endif + +#ifdef PORTB_INT1MASK + DEFINE(PORTB_INT1MASK) +#else + MISSING(PORTB_INT1MASK) +#endif + +#ifdef PORTB_INTCTRL + DEFINE(PORTB_INTCTRL) +#else + MISSING(PORTB_INTCTRL) +#endif + +#ifdef PORTB_INTFLAGS + DEFINE(PORTB_INTFLAGS) +#else + MISSING(PORTB_INTFLAGS) +#endif + +#ifdef PORTB_OUT + DEFINE(PORTB_OUT) +#else + MISSING(PORTB_OUT) +#endif + +#ifdef PORTB_OUTCLR + DEFINE(PORTB_OUTCLR) +#else + MISSING(PORTB_OUTCLR) +#endif + +#ifdef PORTB_OUTSET + DEFINE(PORTB_OUTSET) +#else + MISSING(PORTB_OUTSET) +#endif + +#ifdef PORTB_OUTTGL + DEFINE(PORTB_OUTTGL) +#else + MISSING(PORTB_OUTTGL) +#endif + +#ifdef PORTB_PIN0CTRL + DEFINE(PORTB_PIN0CTRL) +#else + MISSING(PORTB_PIN0CTRL) +#endif + +#ifdef PORTB_PIN1CTRL + DEFINE(PORTB_PIN1CTRL) +#else + MISSING(PORTB_PIN1CTRL) +#endif + +#ifdef PORTB_PIN2CTRL + DEFINE(PORTB_PIN2CTRL) +#else + MISSING(PORTB_PIN2CTRL) +#endif + +#ifdef PORTB_PIN3CTRL + DEFINE(PORTB_PIN3CTRL) +#else + MISSING(PORTB_PIN3CTRL) +#endif + +#ifdef PORTB_PIN4CTRL + DEFINE(PORTB_PIN4CTRL) +#else + MISSING(PORTB_PIN4CTRL) +#endif + +#ifdef PORTB_PIN5CTRL + DEFINE(PORTB_PIN5CTRL) +#else + MISSING(PORTB_PIN5CTRL) +#endif + +#ifdef PORTB_PIN6CTRL + DEFINE(PORTB_PIN6CTRL) +#else + MISSING(PORTB_PIN6CTRL) +#endif + +#ifdef PORTB_PIN7CTRL + DEFINE(PORTB_PIN7CTRL) +#else + MISSING(PORTB_PIN7CTRL) +#endif + +#ifdef PORTC + DEFINE(PORTC) +#else + MISSING(PORTC) +#endif + +#ifdef PORTCFG_CLKEVOUT + DEFINE(PORTCFG_CLKEVOUT) +#else + MISSING(PORTCFG_CLKEVOUT) +#endif + +#ifdef PORTCFG_MPCMASK + DEFINE(PORTCFG_MPCMASK) +#else + MISSING(PORTCFG_MPCMASK) +#endif + +#ifdef PORTCFG_VPCTRLA + DEFINE(PORTCFG_VPCTRLA) +#else + MISSING(PORTCFG_VPCTRLA) +#endif + +#ifdef PORTCFG_VPCTRLB + DEFINE(PORTCFG_VPCTRLB) +#else + MISSING(PORTCFG_VPCTRLB) +#endif + +#ifdef PORTCR + DEFINE(PORTCR) +#else + MISSING(PORTCR) +#endif + +#ifdef PORTC_DIR + DEFINE(PORTC_DIR) +#else + MISSING(PORTC_DIR) +#endif + +#ifdef PORTC_DIRCLR + DEFINE(PORTC_DIRCLR) +#else + MISSING(PORTC_DIRCLR) +#endif + +#ifdef PORTC_DIRSET + DEFINE(PORTC_DIRSET) +#else + MISSING(PORTC_DIRSET) +#endif + +#ifdef PORTC_DIRTGL + DEFINE(PORTC_DIRTGL) +#else + MISSING(PORTC_DIRTGL) +#endif + +#ifdef PORTC_IN + DEFINE(PORTC_IN) +#else + MISSING(PORTC_IN) +#endif + +#ifdef PORTC_INT0MASK + DEFINE(PORTC_INT0MASK) +#else + MISSING(PORTC_INT0MASK) +#endif + +#ifdef PORTC_INT1MASK + DEFINE(PORTC_INT1MASK) +#else + MISSING(PORTC_INT1MASK) +#endif + +#ifdef PORTC_INTCTRL + DEFINE(PORTC_INTCTRL) +#else + MISSING(PORTC_INTCTRL) +#endif + +#ifdef PORTC_INTFLAGS + DEFINE(PORTC_INTFLAGS) +#else + MISSING(PORTC_INTFLAGS) +#endif + +#ifdef PORTC_OUT + DEFINE(PORTC_OUT) +#else + MISSING(PORTC_OUT) +#endif + +#ifdef PORTC_OUTCLR + DEFINE(PORTC_OUTCLR) +#else + MISSING(PORTC_OUTCLR) +#endif + +#ifdef PORTC_OUTSET + DEFINE(PORTC_OUTSET) +#else + MISSING(PORTC_OUTSET) +#endif + +#ifdef PORTC_OUTTGL + DEFINE(PORTC_OUTTGL) +#else + MISSING(PORTC_OUTTGL) +#endif + +#ifdef PORTC_PIN0CTRL + DEFINE(PORTC_PIN0CTRL) +#else + MISSING(PORTC_PIN0CTRL) +#endif + +#ifdef PORTC_PIN1CTRL + DEFINE(PORTC_PIN1CTRL) +#else + MISSING(PORTC_PIN1CTRL) +#endif + +#ifdef PORTC_PIN2CTRL + DEFINE(PORTC_PIN2CTRL) +#else + MISSING(PORTC_PIN2CTRL) +#endif + +#ifdef PORTC_PIN3CTRL + DEFINE(PORTC_PIN3CTRL) +#else + MISSING(PORTC_PIN3CTRL) +#endif + +#ifdef PORTC_PIN4CTRL + DEFINE(PORTC_PIN4CTRL) +#else + MISSING(PORTC_PIN4CTRL) +#endif + +#ifdef PORTC_PIN5CTRL + DEFINE(PORTC_PIN5CTRL) +#else + MISSING(PORTC_PIN5CTRL) +#endif + +#ifdef PORTC_PIN6CTRL + DEFINE(PORTC_PIN6CTRL) +#else + MISSING(PORTC_PIN6CTRL) +#endif + +#ifdef PORTC_PIN7CTRL + DEFINE(PORTC_PIN7CTRL) +#else + MISSING(PORTC_PIN7CTRL) +#endif + +#ifdef PORTD + DEFINE(PORTD) +#else + MISSING(PORTD) +#endif + +#ifdef PORTD_DIR + DEFINE(PORTD_DIR) +#else + MISSING(PORTD_DIR) +#endif + +#ifdef PORTD_DIRCLR + DEFINE(PORTD_DIRCLR) +#else + MISSING(PORTD_DIRCLR) +#endif + +#ifdef PORTD_DIRSET + DEFINE(PORTD_DIRSET) +#else + MISSING(PORTD_DIRSET) +#endif + +#ifdef PORTD_DIRTGL + DEFINE(PORTD_DIRTGL) +#else + MISSING(PORTD_DIRTGL) +#endif + +#ifdef PORTD_IN + DEFINE(PORTD_IN) +#else + MISSING(PORTD_IN) +#endif + +#ifdef PORTD_INT0MASK + DEFINE(PORTD_INT0MASK) +#else + MISSING(PORTD_INT0MASK) +#endif + +#ifdef PORTD_INT1MASK + DEFINE(PORTD_INT1MASK) +#else + MISSING(PORTD_INT1MASK) +#endif + +#ifdef PORTD_INTCTRL + DEFINE(PORTD_INTCTRL) +#else + MISSING(PORTD_INTCTRL) +#endif + +#ifdef PORTD_INTFLAGS + DEFINE(PORTD_INTFLAGS) +#else + MISSING(PORTD_INTFLAGS) +#endif + +#ifdef PORTD_OUT + DEFINE(PORTD_OUT) +#else + MISSING(PORTD_OUT) +#endif + +#ifdef PORTD_OUTCLR + DEFINE(PORTD_OUTCLR) +#else + MISSING(PORTD_OUTCLR) +#endif + +#ifdef PORTD_OUTSET + DEFINE(PORTD_OUTSET) +#else + MISSING(PORTD_OUTSET) +#endif + +#ifdef PORTD_OUTTGL + DEFINE(PORTD_OUTTGL) +#else + MISSING(PORTD_OUTTGL) +#endif + +#ifdef PORTD_PIN0CTRL + DEFINE(PORTD_PIN0CTRL) +#else + MISSING(PORTD_PIN0CTRL) +#endif + +#ifdef PORTD_PIN1CTRL + DEFINE(PORTD_PIN1CTRL) +#else + MISSING(PORTD_PIN1CTRL) +#endif + +#ifdef PORTD_PIN2CTRL + DEFINE(PORTD_PIN2CTRL) +#else + MISSING(PORTD_PIN2CTRL) +#endif + +#ifdef PORTD_PIN3CTRL + DEFINE(PORTD_PIN3CTRL) +#else + MISSING(PORTD_PIN3CTRL) +#endif + +#ifdef PORTD_PIN4CTRL + DEFINE(PORTD_PIN4CTRL) +#else + MISSING(PORTD_PIN4CTRL) +#endif + +#ifdef PORTD_PIN5CTRL + DEFINE(PORTD_PIN5CTRL) +#else + MISSING(PORTD_PIN5CTRL) +#endif + +#ifdef PORTD_PIN6CTRL + DEFINE(PORTD_PIN6CTRL) +#else + MISSING(PORTD_PIN6CTRL) +#endif + +#ifdef PORTD_PIN7CTRL + DEFINE(PORTD_PIN7CTRL) +#else + MISSING(PORTD_PIN7CTRL) +#endif + +#ifdef PORTE + DEFINE(PORTE) +#else + MISSING(PORTE) +#endif + +#ifdef PORTE_DIR + DEFINE(PORTE_DIR) +#else + MISSING(PORTE_DIR) +#endif + +#ifdef PORTE_DIRCLR + DEFINE(PORTE_DIRCLR) +#else + MISSING(PORTE_DIRCLR) +#endif + +#ifdef PORTE_DIRSET + DEFINE(PORTE_DIRSET) +#else + MISSING(PORTE_DIRSET) +#endif + +#ifdef PORTE_DIRTGL + DEFINE(PORTE_DIRTGL) +#else + MISSING(PORTE_DIRTGL) +#endif + +#ifdef PORTE_IN + DEFINE(PORTE_IN) +#else + MISSING(PORTE_IN) +#endif + +#ifdef PORTE_INT0MASK + DEFINE(PORTE_INT0MASK) +#else + MISSING(PORTE_INT0MASK) +#endif + +#ifdef PORTE_INT1MASK + DEFINE(PORTE_INT1MASK) +#else + MISSING(PORTE_INT1MASK) +#endif + +#ifdef PORTE_INTCTRL + DEFINE(PORTE_INTCTRL) +#else + MISSING(PORTE_INTCTRL) +#endif + +#ifdef PORTE_INTFLAGS + DEFINE(PORTE_INTFLAGS) +#else + MISSING(PORTE_INTFLAGS) +#endif + +#ifdef PORTE_OUT + DEFINE(PORTE_OUT) +#else + MISSING(PORTE_OUT) +#endif + +#ifdef PORTE_OUTCLR + DEFINE(PORTE_OUTCLR) +#else + MISSING(PORTE_OUTCLR) +#endif + +#ifdef PORTE_OUTSET + DEFINE(PORTE_OUTSET) +#else + MISSING(PORTE_OUTSET) +#endif + +#ifdef PORTE_OUTTGL + DEFINE(PORTE_OUTTGL) +#else + MISSING(PORTE_OUTTGL) +#endif + +#ifdef PORTE_PIN0CTRL + DEFINE(PORTE_PIN0CTRL) +#else + MISSING(PORTE_PIN0CTRL) +#endif + +#ifdef PORTE_PIN1CTRL + DEFINE(PORTE_PIN1CTRL) +#else + MISSING(PORTE_PIN1CTRL) +#endif + +#ifdef PORTE_PIN2CTRL + DEFINE(PORTE_PIN2CTRL) +#else + MISSING(PORTE_PIN2CTRL) +#endif + +#ifdef PORTE_PIN3CTRL + DEFINE(PORTE_PIN3CTRL) +#else + MISSING(PORTE_PIN3CTRL) +#endif + +#ifdef PORTE_PIN4CTRL + DEFINE(PORTE_PIN4CTRL) +#else + MISSING(PORTE_PIN4CTRL) +#endif + +#ifdef PORTE_PIN5CTRL + DEFINE(PORTE_PIN5CTRL) +#else + MISSING(PORTE_PIN5CTRL) +#endif + +#ifdef PORTE_PIN6CTRL + DEFINE(PORTE_PIN6CTRL) +#else + MISSING(PORTE_PIN6CTRL) +#endif + +#ifdef PORTE_PIN7CTRL + DEFINE(PORTE_PIN7CTRL) +#else + MISSING(PORTE_PIN7CTRL) +#endif + +#ifdef PORTF + DEFINE(PORTF) +#else + MISSING(PORTF) +#endif + +#ifdef PORTF_DIR + DEFINE(PORTF_DIR) +#else + MISSING(PORTF_DIR) +#endif + +#ifdef PORTF_DIRCLR + DEFINE(PORTF_DIRCLR) +#else + MISSING(PORTF_DIRCLR) +#endif + +#ifdef PORTF_DIRSET + DEFINE(PORTF_DIRSET) +#else + MISSING(PORTF_DIRSET) +#endif + +#ifdef PORTF_DIRTGL + DEFINE(PORTF_DIRTGL) +#else + MISSING(PORTF_DIRTGL) +#endif + +#ifdef PORTF_IN + DEFINE(PORTF_IN) +#else + MISSING(PORTF_IN) +#endif + +#ifdef PORTF_INT0MASK + DEFINE(PORTF_INT0MASK) +#else + MISSING(PORTF_INT0MASK) +#endif + +#ifdef PORTF_INT1MASK + DEFINE(PORTF_INT1MASK) +#else + MISSING(PORTF_INT1MASK) +#endif + +#ifdef PORTF_INTCTRL + DEFINE(PORTF_INTCTRL) +#else + MISSING(PORTF_INTCTRL) +#endif + +#ifdef PORTF_INTFLAGS + DEFINE(PORTF_INTFLAGS) +#else + MISSING(PORTF_INTFLAGS) +#endif + +#ifdef PORTF_OUT + DEFINE(PORTF_OUT) +#else + MISSING(PORTF_OUT) +#endif + +#ifdef PORTF_OUTCLR + DEFINE(PORTF_OUTCLR) +#else + MISSING(PORTF_OUTCLR) +#endif + +#ifdef PORTF_OUTSET + DEFINE(PORTF_OUTSET) +#else + MISSING(PORTF_OUTSET) +#endif + +#ifdef PORTF_OUTTGL + DEFINE(PORTF_OUTTGL) +#else + MISSING(PORTF_OUTTGL) +#endif + +#ifdef PORTF_PIN0CTRL + DEFINE(PORTF_PIN0CTRL) +#else + MISSING(PORTF_PIN0CTRL) +#endif + +#ifdef PORTF_PIN1CTRL + DEFINE(PORTF_PIN1CTRL) +#else + MISSING(PORTF_PIN1CTRL) +#endif + +#ifdef PORTF_PIN2CTRL + DEFINE(PORTF_PIN2CTRL) +#else + MISSING(PORTF_PIN2CTRL) +#endif + +#ifdef PORTF_PIN3CTRL + DEFINE(PORTF_PIN3CTRL) +#else + MISSING(PORTF_PIN3CTRL) +#endif + +#ifdef PORTF_PIN4CTRL + DEFINE(PORTF_PIN4CTRL) +#else + MISSING(PORTF_PIN4CTRL) +#endif + +#ifdef PORTF_PIN5CTRL + DEFINE(PORTF_PIN5CTRL) +#else + MISSING(PORTF_PIN5CTRL) +#endif + +#ifdef PORTF_PIN6CTRL + DEFINE(PORTF_PIN6CTRL) +#else + MISSING(PORTF_PIN6CTRL) +#endif + +#ifdef PORTF_PIN7CTRL + DEFINE(PORTF_PIN7CTRL) +#else + MISSING(PORTF_PIN7CTRL) +#endif + +#ifdef PORTG + DEFINE(PORTG) +#else + MISSING(PORTG) +#endif + +#ifdef PORTH + DEFINE(PORTH) +#else + MISSING(PORTH) +#endif + +#ifdef PORTH_DIR + DEFINE(PORTH_DIR) +#else + MISSING(PORTH_DIR) +#endif + +#ifdef PORTH_DIRCLR + DEFINE(PORTH_DIRCLR) +#else + MISSING(PORTH_DIRCLR) +#endif + +#ifdef PORTH_DIRSET + DEFINE(PORTH_DIRSET) +#else + MISSING(PORTH_DIRSET) +#endif + +#ifdef PORTH_DIRTGL + DEFINE(PORTH_DIRTGL) +#else + MISSING(PORTH_DIRTGL) +#endif + +#ifdef PORTH_IN + DEFINE(PORTH_IN) +#else + MISSING(PORTH_IN) +#endif + +#ifdef PORTH_INT0MASK + DEFINE(PORTH_INT0MASK) +#else + MISSING(PORTH_INT0MASK) +#endif + +#ifdef PORTH_INT1MASK + DEFINE(PORTH_INT1MASK) +#else + MISSING(PORTH_INT1MASK) +#endif + +#ifdef PORTH_INTCTRL + DEFINE(PORTH_INTCTRL) +#else + MISSING(PORTH_INTCTRL) +#endif + +#ifdef PORTH_INTFLAGS + DEFINE(PORTH_INTFLAGS) +#else + MISSING(PORTH_INTFLAGS) +#endif + +#ifdef PORTH_OUT + DEFINE(PORTH_OUT) +#else + MISSING(PORTH_OUT) +#endif + +#ifdef PORTH_OUTCLR + DEFINE(PORTH_OUTCLR) +#else + MISSING(PORTH_OUTCLR) +#endif + +#ifdef PORTH_OUTSET + DEFINE(PORTH_OUTSET) +#else + MISSING(PORTH_OUTSET) +#endif + +#ifdef PORTH_OUTTGL + DEFINE(PORTH_OUTTGL) +#else + MISSING(PORTH_OUTTGL) +#endif + +#ifdef PORTH_PIN0CTRL + DEFINE(PORTH_PIN0CTRL) +#else + MISSING(PORTH_PIN0CTRL) +#endif + +#ifdef PORTH_PIN1CTRL + DEFINE(PORTH_PIN1CTRL) +#else + MISSING(PORTH_PIN1CTRL) +#endif + +#ifdef PORTH_PIN2CTRL + DEFINE(PORTH_PIN2CTRL) +#else + MISSING(PORTH_PIN2CTRL) +#endif + +#ifdef PORTH_PIN3CTRL + DEFINE(PORTH_PIN3CTRL) +#else + MISSING(PORTH_PIN3CTRL) +#endif + +#ifdef PORTH_PIN4CTRL + DEFINE(PORTH_PIN4CTRL) +#else + MISSING(PORTH_PIN4CTRL) +#endif + +#ifdef PORTH_PIN5CTRL + DEFINE(PORTH_PIN5CTRL) +#else + MISSING(PORTH_PIN5CTRL) +#endif + +#ifdef PORTH_PIN6CTRL + DEFINE(PORTH_PIN6CTRL) +#else + MISSING(PORTH_PIN6CTRL) +#endif + +#ifdef PORTH_PIN7CTRL + DEFINE(PORTH_PIN7CTRL) +#else + MISSING(PORTH_PIN7CTRL) +#endif + +#ifdef PORTJ + DEFINE(PORTJ) +#else + MISSING(PORTJ) +#endif + +#ifdef PORTJ_DIR + DEFINE(PORTJ_DIR) +#else + MISSING(PORTJ_DIR) +#endif + +#ifdef PORTJ_DIRCLR + DEFINE(PORTJ_DIRCLR) +#else + MISSING(PORTJ_DIRCLR) +#endif + +#ifdef PORTJ_DIRSET + DEFINE(PORTJ_DIRSET) +#else + MISSING(PORTJ_DIRSET) +#endif + +#ifdef PORTJ_DIRTGL + DEFINE(PORTJ_DIRTGL) +#else + MISSING(PORTJ_DIRTGL) +#endif + +#ifdef PORTJ_IN + DEFINE(PORTJ_IN) +#else + MISSING(PORTJ_IN) +#endif + +#ifdef PORTJ_INT0MASK + DEFINE(PORTJ_INT0MASK) +#else + MISSING(PORTJ_INT0MASK) +#endif + +#ifdef PORTJ_INT1MASK + DEFINE(PORTJ_INT1MASK) +#else + MISSING(PORTJ_INT1MASK) +#endif + +#ifdef PORTJ_INTCTRL + DEFINE(PORTJ_INTCTRL) +#else + MISSING(PORTJ_INTCTRL) +#endif + +#ifdef PORTJ_INTFLAGS + DEFINE(PORTJ_INTFLAGS) +#else + MISSING(PORTJ_INTFLAGS) +#endif + +#ifdef PORTJ_OUT + DEFINE(PORTJ_OUT) +#else + MISSING(PORTJ_OUT) +#endif + +#ifdef PORTJ_OUTCLR + DEFINE(PORTJ_OUTCLR) +#else + MISSING(PORTJ_OUTCLR) +#endif + +#ifdef PORTJ_OUTSET + DEFINE(PORTJ_OUTSET) +#else + MISSING(PORTJ_OUTSET) +#endif + +#ifdef PORTJ_OUTTGL + DEFINE(PORTJ_OUTTGL) +#else + MISSING(PORTJ_OUTTGL) +#endif + +#ifdef PORTJ_PIN0CTRL + DEFINE(PORTJ_PIN0CTRL) +#else + MISSING(PORTJ_PIN0CTRL) +#endif + +#ifdef PORTJ_PIN1CTRL + DEFINE(PORTJ_PIN1CTRL) +#else + MISSING(PORTJ_PIN1CTRL) +#endif + +#ifdef PORTJ_PIN2CTRL + DEFINE(PORTJ_PIN2CTRL) +#else + MISSING(PORTJ_PIN2CTRL) +#endif + +#ifdef PORTJ_PIN3CTRL + DEFINE(PORTJ_PIN3CTRL) +#else + MISSING(PORTJ_PIN3CTRL) +#endif + +#ifdef PORTJ_PIN4CTRL + DEFINE(PORTJ_PIN4CTRL) +#else + MISSING(PORTJ_PIN4CTRL) +#endif + +#ifdef PORTJ_PIN5CTRL + DEFINE(PORTJ_PIN5CTRL) +#else + MISSING(PORTJ_PIN5CTRL) +#endif + +#ifdef PORTJ_PIN6CTRL + DEFINE(PORTJ_PIN6CTRL) +#else + MISSING(PORTJ_PIN6CTRL) +#endif + +#ifdef PORTJ_PIN7CTRL + DEFINE(PORTJ_PIN7CTRL) +#else + MISSING(PORTJ_PIN7CTRL) +#endif + +#ifdef PORTK + DEFINE(PORTK) +#else + MISSING(PORTK) +#endif + +#ifdef PORTK_DIR + DEFINE(PORTK_DIR) +#else + MISSING(PORTK_DIR) +#endif + +#ifdef PORTK_DIRCLR + DEFINE(PORTK_DIRCLR) +#else + MISSING(PORTK_DIRCLR) +#endif + +#ifdef PORTK_DIRSET + DEFINE(PORTK_DIRSET) +#else + MISSING(PORTK_DIRSET) +#endif + +#ifdef PORTK_DIRTGL + DEFINE(PORTK_DIRTGL) +#else + MISSING(PORTK_DIRTGL) +#endif + +#ifdef PORTK_IN + DEFINE(PORTK_IN) +#else + MISSING(PORTK_IN) +#endif + +#ifdef PORTK_INT0MASK + DEFINE(PORTK_INT0MASK) +#else + MISSING(PORTK_INT0MASK) +#endif + +#ifdef PORTK_INT1MASK + DEFINE(PORTK_INT1MASK) +#else + MISSING(PORTK_INT1MASK) +#endif + +#ifdef PORTK_INTCTRL + DEFINE(PORTK_INTCTRL) +#else + MISSING(PORTK_INTCTRL) +#endif + +#ifdef PORTK_INTFLAGS + DEFINE(PORTK_INTFLAGS) +#else + MISSING(PORTK_INTFLAGS) +#endif + +#ifdef PORTK_OUT + DEFINE(PORTK_OUT) +#else + MISSING(PORTK_OUT) +#endif + +#ifdef PORTK_OUTCLR + DEFINE(PORTK_OUTCLR) +#else + MISSING(PORTK_OUTCLR) +#endif + +#ifdef PORTK_OUTSET + DEFINE(PORTK_OUTSET) +#else + MISSING(PORTK_OUTSET) +#endif + +#ifdef PORTK_OUTTGL + DEFINE(PORTK_OUTTGL) +#else + MISSING(PORTK_OUTTGL) +#endif + +#ifdef PORTK_PIN0CTRL + DEFINE(PORTK_PIN0CTRL) +#else + MISSING(PORTK_PIN0CTRL) +#endif + +#ifdef PORTK_PIN1CTRL + DEFINE(PORTK_PIN1CTRL) +#else + MISSING(PORTK_PIN1CTRL) +#endif + +#ifdef PORTK_PIN2CTRL + DEFINE(PORTK_PIN2CTRL) +#else + MISSING(PORTK_PIN2CTRL) +#endif + +#ifdef PORTK_PIN3CTRL + DEFINE(PORTK_PIN3CTRL) +#else + MISSING(PORTK_PIN3CTRL) +#endif + +#ifdef PORTK_PIN4CTRL + DEFINE(PORTK_PIN4CTRL) +#else + MISSING(PORTK_PIN4CTRL) +#endif + +#ifdef PORTK_PIN5CTRL + DEFINE(PORTK_PIN5CTRL) +#else + MISSING(PORTK_PIN5CTRL) +#endif + +#ifdef PORTK_PIN6CTRL + DEFINE(PORTK_PIN6CTRL) +#else + MISSING(PORTK_PIN6CTRL) +#endif + +#ifdef PORTK_PIN7CTRL + DEFINE(PORTK_PIN7CTRL) +#else + MISSING(PORTK_PIN7CTRL) +#endif + +#ifdef PORTL + DEFINE(PORTL) +#else + MISSING(PORTL) +#endif + +#ifdef PORTQ_DIR + DEFINE(PORTQ_DIR) +#else + MISSING(PORTQ_DIR) +#endif + +#ifdef PORTQ_DIRCLR + DEFINE(PORTQ_DIRCLR) +#else + MISSING(PORTQ_DIRCLR) +#endif + +#ifdef PORTQ_DIRSET + DEFINE(PORTQ_DIRSET) +#else + MISSING(PORTQ_DIRSET) +#endif + +#ifdef PORTQ_DIRTGL + DEFINE(PORTQ_DIRTGL) +#else + MISSING(PORTQ_DIRTGL) +#endif + +#ifdef PORTQ_IN + DEFINE(PORTQ_IN) +#else + MISSING(PORTQ_IN) +#endif + +#ifdef PORTQ_INT0MASK + DEFINE(PORTQ_INT0MASK) +#else + MISSING(PORTQ_INT0MASK) +#endif + +#ifdef PORTQ_INT1MASK + DEFINE(PORTQ_INT1MASK) +#else + MISSING(PORTQ_INT1MASK) +#endif + +#ifdef PORTQ_INTCTRL + DEFINE(PORTQ_INTCTRL) +#else + MISSING(PORTQ_INTCTRL) +#endif + +#ifdef PORTQ_INTFLAGS + DEFINE(PORTQ_INTFLAGS) +#else + MISSING(PORTQ_INTFLAGS) +#endif + +#ifdef PORTQ_OUT + DEFINE(PORTQ_OUT) +#else + MISSING(PORTQ_OUT) +#endif + +#ifdef PORTQ_OUTCLR + DEFINE(PORTQ_OUTCLR) +#else + MISSING(PORTQ_OUTCLR) +#endif + +#ifdef PORTQ_OUTSET + DEFINE(PORTQ_OUTSET) +#else + MISSING(PORTQ_OUTSET) +#endif + +#ifdef PORTQ_OUTTGL + DEFINE(PORTQ_OUTTGL) +#else + MISSING(PORTQ_OUTTGL) +#endif + +#ifdef PORTQ_PIN0CTRL + DEFINE(PORTQ_PIN0CTRL) +#else + MISSING(PORTQ_PIN0CTRL) +#endif + +#ifdef PORTQ_PIN1CTRL + DEFINE(PORTQ_PIN1CTRL) +#else + MISSING(PORTQ_PIN1CTRL) +#endif + +#ifdef PORTQ_PIN2CTRL + DEFINE(PORTQ_PIN2CTRL) +#else + MISSING(PORTQ_PIN2CTRL) +#endif + +#ifdef PORTQ_PIN3CTRL + DEFINE(PORTQ_PIN3CTRL) +#else + MISSING(PORTQ_PIN3CTRL) +#endif + +#ifdef PORTQ_PIN4CTRL + DEFINE(PORTQ_PIN4CTRL) +#else + MISSING(PORTQ_PIN4CTRL) +#endif + +#ifdef PORTQ_PIN5CTRL + DEFINE(PORTQ_PIN5CTRL) +#else + MISSING(PORTQ_PIN5CTRL) +#endif + +#ifdef PORTQ_PIN6CTRL + DEFINE(PORTQ_PIN6CTRL) +#else + MISSING(PORTQ_PIN6CTRL) +#endif + +#ifdef PORTQ_PIN7CTRL + DEFINE(PORTQ_PIN7CTRL) +#else + MISSING(PORTQ_PIN7CTRL) +#endif + +#ifdef PORTR_DIR + DEFINE(PORTR_DIR) +#else + MISSING(PORTR_DIR) +#endif + +#ifdef PORTR_DIRCLR + DEFINE(PORTR_DIRCLR) +#else + MISSING(PORTR_DIRCLR) +#endif + +#ifdef PORTR_DIRSET + DEFINE(PORTR_DIRSET) +#else + MISSING(PORTR_DIRSET) +#endif + +#ifdef PORTR_DIRTGL + DEFINE(PORTR_DIRTGL) +#else + MISSING(PORTR_DIRTGL) +#endif + +#ifdef PORTR_IN + DEFINE(PORTR_IN) +#else + MISSING(PORTR_IN) +#endif + +#ifdef PORTR_INT0MASK + DEFINE(PORTR_INT0MASK) +#else + MISSING(PORTR_INT0MASK) +#endif + +#ifdef PORTR_INT1MASK + DEFINE(PORTR_INT1MASK) +#else + MISSING(PORTR_INT1MASK) +#endif + +#ifdef PORTR_INTCTRL + DEFINE(PORTR_INTCTRL) +#else + MISSING(PORTR_INTCTRL) +#endif + +#ifdef PORTR_INTFLAGS + DEFINE(PORTR_INTFLAGS) +#else + MISSING(PORTR_INTFLAGS) +#endif + +#ifdef PORTR_OUT + DEFINE(PORTR_OUT) +#else + MISSING(PORTR_OUT) +#endif + +#ifdef PORTR_OUTCLR + DEFINE(PORTR_OUTCLR) +#else + MISSING(PORTR_OUTCLR) +#endif + +#ifdef PORTR_OUTSET + DEFINE(PORTR_OUTSET) +#else + MISSING(PORTR_OUTSET) +#endif + +#ifdef PORTR_OUTTGL + DEFINE(PORTR_OUTTGL) +#else + MISSING(PORTR_OUTTGL) +#endif + +#ifdef PORTR_PIN0CTRL + DEFINE(PORTR_PIN0CTRL) +#else + MISSING(PORTR_PIN0CTRL) +#endif + +#ifdef PORTR_PIN1CTRL + DEFINE(PORTR_PIN1CTRL) +#else + MISSING(PORTR_PIN1CTRL) +#endif + +#ifdef PORTR_PIN2CTRL + DEFINE(PORTR_PIN2CTRL) +#else + MISSING(PORTR_PIN2CTRL) +#endif + +#ifdef PORTR_PIN3CTRL + DEFINE(PORTR_PIN3CTRL) +#else + MISSING(PORTR_PIN3CTRL) +#endif + +#ifdef PORTR_PIN4CTRL + DEFINE(PORTR_PIN4CTRL) +#else + MISSING(PORTR_PIN4CTRL) +#endif + +#ifdef PORTR_PIN5CTRL + DEFINE(PORTR_PIN5CTRL) +#else + MISSING(PORTR_PIN5CTRL) +#endif + +#ifdef PORTR_PIN6CTRL + DEFINE(PORTR_PIN6CTRL) +#else + MISSING(PORTR_PIN6CTRL) +#endif + +#ifdef PORTR_PIN7CTRL + DEFINE(PORTR_PIN7CTRL) +#else + MISSING(PORTR_PIN7CTRL) +#endif + +#ifdef PRELD + DEFINE(PRELD) +#else + MISSING(PRELD) +#endif + +#ifdef PRR + DEFINE(PRR) +#else + MISSING(PRR) +#endif + +#ifdef PRR0 + DEFINE(PRR0) +#else + MISSING(PRR0) +#endif + +#ifdef PRR1 + DEFINE(PRR1) +#else + MISSING(PRR1) +#endif + +#ifdef PRR2 + DEFINE(PRR2) +#else + MISSING(PRR2) +#endif + +#ifdef PR_PRGEN + DEFINE(PR_PRGEN) +#else + MISSING(PR_PRGEN) +#endif + +#ifdef PR_PRPA + DEFINE(PR_PRPA) +#else + MISSING(PR_PRPA) +#endif + +#ifdef PR_PRPB + DEFINE(PR_PRPB) +#else + MISSING(PR_PRPB) +#endif + +#ifdef PR_PRPC + DEFINE(PR_PRPC) +#else + MISSING(PR_PRPC) +#endif + +#ifdef PR_PRPD + DEFINE(PR_PRPD) +#else + MISSING(PR_PRPD) +#endif + +#ifdef PR_PRPE + DEFINE(PR_PRPE) +#else + MISSING(PR_PRPE) +#endif + +#ifdef PR_PRPF + DEFINE(PR_PRPF) +#else + MISSING(PR_PRPF) +#endif + +#ifdef PS2CON + DEFINE(PS2CON) +#else + MISSING(PS2CON) +#endif + +#ifdef PSOC0 + DEFINE(PSOC0) +#else + MISSING(PSOC0) +#endif + +#ifdef PSOC1 + DEFINE(PSOC1) +#else + MISSING(PSOC1) +#endif + +#ifdef PSOC2 + DEFINE(PSOC2) +#else + MISSING(PSOC2) +#endif + +#ifdef PSYNC + DEFINE(PSYNC) +#else + MISSING(PSYNC) +#endif + +#ifdef PUEA + DEFINE(PUEA) +#else + MISSING(PUEA) +#endif + +#ifdef PUEB + DEFINE(PUEB) +#else + MISSING(PUEB) +#endif + +#ifdef PUEC + DEFINE(PUEC) +#else + MISSING(PUEC) +#endif + +#ifdef PWMCTL + DEFINE(PWMCTL) +#else + MISSING(PWMCTL) +#endif + +#ifdef PWMMSK + DEFINE(PWMMSK) +#else + MISSING(PWMMSK) +#endif + +#ifdef PWMPER + DEFINE(PWMPER) +#else + MISSING(PWMPER) +#endif + +#ifdef PWMSFRQ + DEFINE(PWMSFRQ) +#else + MISSING(PWMSFRQ) +#endif + +#ifdef PWR_ATTEN + DEFINE(PWR_ATTEN) +#else + MISSING(PWR_ATTEN) +#endif + +#ifdef QTCSR + DEFINE(QTCSR) +#else + MISSING(QTCSR) +#endif + +#ifdef RAMAR + DEFINE(RAMAR) +#else + MISSING(RAMAR) +#endif + +#ifdef RAMDR + DEFINE(RAMDR) +#else + MISSING(RAMDR) +#endif + +#ifdef RAMPD + DEFINE(RAMPD) +#else + MISSING(RAMPD) +#endif + +#ifdef RAMPX + DEFINE(RAMPX) +#else + MISSING(RAMPX) +#endif + +#ifdef RAMPY + DEFINE(RAMPY) +#else + MISSING(RAMPY) +#endif + +#ifdef RAMPZ + DEFINE(RAMPZ) +#else + MISSING(RAMPZ) +#endif + +#ifdef RCCTRL + DEFINE(RCCTRL) +#else + MISSING(RCCTRL) +#endif + +#ifdef RDWDR + DEFINE(RDWDR) +#else + MISSING(RDWDR) +#endif + +#ifdef REGCR + DEFINE(REGCR) +#else + MISSING(REGCR) +#endif + +#ifdef RNGCR + DEFINE(RNGCR) +#else + MISSING(RNGCR) +#endif + +#ifdef ROCR + DEFINE(ROCR) +#else + MISSING(ROCR) +#endif + +#ifdef RSTFLR + DEFINE(RSTFLR) +#else + MISSING(RSTFLR) +#endif + +#ifdef RST_CTRL + DEFINE(RST_CTRL) +#else + MISSING(RST_CTRL) +#endif + +#ifdef RST_STATUS + DEFINE(RST_STATUS) +#else + MISSING(RST_STATUS) +#endif + +#ifdef RTC32_CTRL + DEFINE(RTC32_CTRL) +#else + MISSING(RTC32_CTRL) +#endif + +#ifdef RTC32_INTCTRL + DEFINE(RTC32_INTCTRL) +#else + MISSING(RTC32_INTCTRL) +#endif + +#ifdef RTC32_INTFLAGS + DEFINE(RTC32_INTFLAGS) +#else + MISSING(RTC32_INTFLAGS) +#endif + +#ifdef RTC32_SYNCCTRL + DEFINE(RTC32_SYNCCTRL) +#else + MISSING(RTC32_SYNCCTRL) +#endif + +#ifdef RTC_CNT + DEFINE(RTC_CNT) +#else + MISSING(RTC_CNT) +#endif + +#ifdef RTC_COMP + DEFINE(RTC_COMP) +#else + MISSING(RTC_COMP) +#endif + +#ifdef RTC_CTRL + DEFINE(RTC_CTRL) +#else + MISSING(RTC_CTRL) +#endif + +#ifdef RTC_INTCTRL + DEFINE(RTC_INTCTRL) +#else + MISSING(RTC_INTCTRL) +#endif + +#ifdef RTC_INTFLAGS + DEFINE(RTC_INTFLAGS) +#else + MISSING(RTC_INTFLAGS) +#endif + +#ifdef RTC_PER + DEFINE(RTC_PER) +#else + MISSING(RTC_PER) +#endif + +#ifdef RTC_STATUS + DEFINE(RTC_STATUS) +#else + MISSING(RTC_STATUS) +#endif + +#ifdef RTC_TEMP + DEFINE(RTC_TEMP) +#else + MISSING(RTC_TEMP) +#endif + +#ifdef RXB + DEFINE(RXB) +#else + MISSING(RXB) +#endif + +#ifdef RX_CTRL + DEFINE(RX_CTRL) +#else + MISSING(RX_CTRL) +#endif + +#ifdef RX_SYN + DEFINE(RX_SYN) +#else + MISSING(RX_SYN) +#endif + +#ifdef SCBTSRHH + DEFINE(SCBTSRHH) +#else + MISSING(SCBTSRHH) +#endif + +#ifdef SCBTSRHL + DEFINE(SCBTSRHL) +#else + MISSING(SCBTSRHL) +#endif + +#ifdef SCBTSRLH + DEFINE(SCBTSRLH) +#else + MISSING(SCBTSRLH) +#endif + +#ifdef SCBTSRLL + DEFINE(SCBTSRLL) +#else + MISSING(SCBTSRLL) +#endif + +#ifdef SCCNTHH + DEFINE(SCCNTHH) +#else + MISSING(SCCNTHH) +#endif + +#ifdef SCCNTHL + DEFINE(SCCNTHL) +#else + MISSING(SCCNTHL) +#endif + +#ifdef SCCNTLH + DEFINE(SCCNTLH) +#else + MISSING(SCCNTLH) +#endif + +#ifdef SCCNTLL + DEFINE(SCCNTLL) +#else + MISSING(SCCNTLL) +#endif + +#ifdef SCCON + DEFINE(SCCON) +#else + MISSING(SCCON) +#endif + +#ifdef SCCR + DEFINE(SCCR) +#else + MISSING(SCCR) +#endif + +#ifdef SCCR0 + DEFINE(SCCR0) +#else + MISSING(SCCR0) +#endif + +#ifdef SCCR1 + DEFINE(SCCR1) +#else + MISSING(SCCR1) +#endif + +#ifdef SCETU + DEFINE(SCETU) +#else + MISSING(SCETU) +#endif + +#ifdef SCETUH + DEFINE(SCETUH) +#else + MISSING(SCETUH) +#endif + +#ifdef SCETUL + DEFINE(SCETUL) +#else + MISSING(SCETUL) +#endif + +#ifdef SCGT + DEFINE(SCGT) +#else + MISSING(SCGT) +#endif + +#ifdef SCGTH + DEFINE(SCGTH) +#else + MISSING(SCGTH) +#endif + +#ifdef SCGTL + DEFINE(SCGTL) +#else + MISSING(SCGTL) +#endif + +#ifdef SCIBUF + DEFINE(SCIBUF) +#else + MISSING(SCIBUF) +#endif + +#ifdef SCICLK + DEFINE(SCICLK) +#else + MISSING(SCICLK) +#endif + +#ifdef SCICR + DEFINE(SCICR) +#else + MISSING(SCICR) +#endif + +#ifdef SCIER + DEFINE(SCIER) +#else + MISSING(SCIER) +#endif + +#ifdef SCIIR + DEFINE(SCIIR) +#else + MISSING(SCIIR) +#endif + +#ifdef SCIO + DEFINE(SCIO) +#else + MISSING(SCIO) +#endif + +#ifdef SCIRQM + DEFINE(SCIRQM) +#else + MISSING(SCIRQM) +#endif + +#ifdef SCIRQS + DEFINE(SCIRQS) +#else + MISSING(SCIRQS) +#endif + +#ifdef SCISR + DEFINE(SCISR) +#else + MISSING(SCISR) +#endif + +#ifdef SCOCR1HH + DEFINE(SCOCR1HH) +#else + MISSING(SCOCR1HH) +#endif + +#ifdef SCOCR1HL + DEFINE(SCOCR1HL) +#else + MISSING(SCOCR1HL) +#endif + +#ifdef SCOCR1LH + DEFINE(SCOCR1LH) +#else + MISSING(SCOCR1LH) +#endif + +#ifdef SCOCR1LL + DEFINE(SCOCR1LL) +#else + MISSING(SCOCR1LL) +#endif + +#ifdef SCOCR2HH + DEFINE(SCOCR2HH) +#else + MISSING(SCOCR2HH) +#endif + +#ifdef SCOCR2HL + DEFINE(SCOCR2HL) +#else + MISSING(SCOCR2HL) +#endif + +#ifdef SCOCR2LH + DEFINE(SCOCR2LH) +#else + MISSING(SCOCR2LH) +#endif + +#ifdef SCOCR2LL + DEFINE(SCOCR2LL) +#else + MISSING(SCOCR2LL) +#endif + +#ifdef SCOCR3HH + DEFINE(SCOCR3HH) +#else + MISSING(SCOCR3HH) +#endif + +#ifdef SCOCR3HL + DEFINE(SCOCR3HL) +#else + MISSING(SCOCR3HL) +#endif + +#ifdef SCOCR3LH + DEFINE(SCOCR3LH) +#else + MISSING(SCOCR3LH) +#endif + +#ifdef SCOCR3LL + DEFINE(SCOCR3LL) +#else + MISSING(SCOCR3LL) +#endif + +#ifdef SCR + DEFINE(SCR) +#else + MISSING(SCR) +#endif + +#ifdef SCSR + DEFINE(SCSR) +#else + MISSING(SCSR) +#endif + +#ifdef SCSW + DEFINE(SCSW) +#else + MISSING(SCSW) +#endif + +#ifdef SCTSRHH + DEFINE(SCTSRHH) +#else + MISSING(SCTSRHH) +#endif + +#ifdef SCTSRHL + DEFINE(SCTSRHL) +#else + MISSING(SCTSRHL) +#endif + +#ifdef SCTSRLH + DEFINE(SCTSRLH) +#else + MISSING(SCTSRLH) +#endif + +#ifdef SCTSRLL + DEFINE(SCTSRLL) +#else + MISSING(SCTSRLL) +#endif + +#ifdef SCWT0 + DEFINE(SCWT0) +#else + MISSING(SCWT0) +#endif + +#ifdef SCWT1 + DEFINE(SCWT1) +#else + MISSING(SCWT1) +#endif + +#ifdef SCWT2 + DEFINE(SCWT2) +#else + MISSING(SCWT2) +#endif + +#ifdef SCWT3 + DEFINE(SCWT3) +#else + MISSING(SCWT3) +#endif + +#ifdef SFD_VALUE + DEFINE(SFD_VALUE) +#else + MISSING(SFD_VALUE) +#endif + +#ifdef SFIOR + DEFINE(SFIOR) +#else + MISSING(SFIOR) +#endif + +#ifdef SFTCR + DEFINE(SFTCR) +#else + MISSING(SFTCR) +#endif + +#ifdef SHORT_ADDR_0 + DEFINE(SHORT_ADDR_0) +#else + MISSING(SHORT_ADDR_0) +#endif + +#ifdef SHORT_ADDR_1 + DEFINE(SHORT_ADDR_1) +#else + MISSING(SHORT_ADDR_1) +#endif + +#ifdef SIMSK + DEFINE(SIMSK) +#else + MISSING(SIMSK) +#endif + +#ifdef SINDAC + DEFINE(SINDAC) +#else + MISSING(SINDAC) +#endif + +#ifdef SINDACH + DEFINE(SINDACH) +#else + MISSING(SINDACH) +#endif + +#ifdef SINDACL + DEFINE(SINDACL) +#else + MISSING(SINDACL) +#endif + +#ifdef SLEEP_CTRL + DEFINE(SLEEP_CTRL) +#else + MISSING(SLEEP_CTRL) +#endif + +#ifdef SMCR + DEFINE(SMCR) +#else + MISSING(SMCR) +#endif + +#ifdef SMONCR + DEFINE(SMONCR) +#else + MISSING(SMONCR) +#endif + +#ifdef SOSCCALA + DEFINE(SOSCCALA) +#else + MISSING(SOSCCALA) +#endif + +#ifdef SOSCCALB + DEFINE(SOSCCALB) +#else + MISSING(SOSCCALB) +#endif + +#ifdef SP + DEFINE(SP) +#else + MISSING(SP) +#endif + +#ifdef SPCR + DEFINE(SPCR) +#else + MISSING(SPCR) +#endif + +#ifdef SPCR0 + DEFINE(SPCR0) +#else + MISSING(SPCR0) +#endif + +#ifdef SPDR + DEFINE(SPDR) +#else + MISSING(SPDR) +#endif + +#ifdef SPH + DEFINE(SPH) +#else + MISSING(SPH) +#endif + +#ifdef SPIC_CTRL + DEFINE(SPIC_CTRL) +#else + MISSING(SPIC_CTRL) +#endif + +#ifdef SPIC_DATA + DEFINE(SPIC_DATA) +#else + MISSING(SPIC_DATA) +#endif + +#ifdef SPIC_INTCTRL + DEFINE(SPIC_INTCTRL) +#else + MISSING(SPIC_INTCTRL) +#endif + +#ifdef SPIC_STATUS + DEFINE(SPIC_STATUS) +#else + MISSING(SPIC_STATUS) +#endif + +#ifdef SPID_CTRL + DEFINE(SPID_CTRL) +#else + MISSING(SPID_CTRL) +#endif + +#ifdef SPID_DATA + DEFINE(SPID_DATA) +#else + MISSING(SPID_DATA) +#endif + +#ifdef SPID_INTCTRL + DEFINE(SPID_INTCTRL) +#else + MISSING(SPID_INTCTRL) +#endif + +#ifdef SPID_STATUS + DEFINE(SPID_STATUS) +#else + MISSING(SPID_STATUS) +#endif + +#ifdef SPIE_CTRL + DEFINE(SPIE_CTRL) +#else + MISSING(SPIE_CTRL) +#endif + +#ifdef SPIE_DATA + DEFINE(SPIE_DATA) +#else + MISSING(SPIE_DATA) +#endif + +#ifdef SPIE_INTCTRL + DEFINE(SPIE_INTCTRL) +#else + MISSING(SPIE_INTCTRL) +#endif + +#ifdef SPIE_STATUS + DEFINE(SPIE_STATUS) +#else + MISSING(SPIE_STATUS) +#endif + +#ifdef SPIF_CTRL + DEFINE(SPIF_CTRL) +#else + MISSING(SPIF_CTRL) +#endif + +#ifdef SPIF_DATA + DEFINE(SPIF_DATA) +#else + MISSING(SPIF_DATA) +#endif + +#ifdef SPIF_INTCTRL + DEFINE(SPIF_INTCTRL) +#else + MISSING(SPIF_INTCTRL) +#endif + +#ifdef SPIF_STATUS + DEFINE(SPIF_STATUS) +#else + MISSING(SPIF_STATUS) +#endif + +#ifdef SPL + DEFINE(SPL) +#else + MISSING(SPL) +#endif + +#ifdef SPMCR + DEFINE(SPMCR) +#else + MISSING(SPMCR) +#endif + +#ifdef SPMCSR + DEFINE(SPMCSR) +#else + MISSING(SPMCSR) +#endif + +#ifdef SPSR + DEFINE(SPSR) +#else + MISSING(SPSR) +#endif + +#ifdef SPSR0 + DEFINE(SPSR0) +#else + MISSING(SPSR0) +#endif + +#ifdef SPWMCTL + DEFINE(SPWMCTL) +#else + MISSING(SPWMCTL) +#endif + +#ifdef SRCCAL + DEFINE(SRCCAL) +#else + MISSING(SRCCAL) +#endif + +#ifdef SREG + DEFINE(SREG) +#else + MISSING(SREG) +#endif + +#ifdef SSFR + DEFINE(SSFR) +#else + MISSING(SSFR) +#endif + +#ifdef STAT + DEFINE(STAT) +#else + MISSING(STAT) +#endif + +#ifdef SVCR + DEFINE(SVCR) +#else + MISSING(SVCR) +#endif + +#ifdef T0CR + DEFINE(T0CR) +#else + MISSING(T0CR) +#endif + +#ifdef T10IFR + DEFINE(T10IFR) +#else + MISSING(T10IFR) +#endif + +#ifdef T1CR + DEFINE(T1CR) +#else + MISSING(T1CR) +#endif + +#ifdef T2COR + DEFINE(T2COR) +#else + MISSING(T2COR) +#endif + +#ifdef T2CORH + DEFINE(T2CORH) +#else + MISSING(T2CORH) +#endif + +#ifdef T2CORL + DEFINE(T2CORL) +#else + MISSING(T2CORL) +#endif + +#ifdef T2CRA + DEFINE(T2CRA) +#else + MISSING(T2CRA) +#endif + +#ifdef T2CRB + DEFINE(T2CRB) +#else + MISSING(T2CRB) +#endif + +#ifdef T2ICR + DEFINE(T2ICR) +#else + MISSING(T2ICR) +#endif + +#ifdef T2ICRH + DEFINE(T2ICRH) +#else + MISSING(T2ICRH) +#endif + +#ifdef T2ICRL + DEFINE(T2ICRL) +#else + MISSING(T2ICRL) +#endif + +#ifdef T2IFR + DEFINE(T2IFR) +#else + MISSING(T2IFR) +#endif + +#ifdef T2IMR + DEFINE(T2IMR) +#else + MISSING(T2IMR) +#endif + +#ifdef T2MDR + DEFINE(T2MDR) +#else + MISSING(T2MDR) +#endif + +#ifdef T2MRA + DEFINE(T2MRA) +#else + MISSING(T2MRA) +#endif + +#ifdef T2MRB + DEFINE(T2MRB) +#else + MISSING(T2MRB) +#endif + +#ifdef T3CORA + DEFINE(T3CORA) +#else + MISSING(T3CORA) +#endif + +#ifdef T3CORAH + DEFINE(T3CORAH) +#else + MISSING(T3CORAH) +#endif + +#ifdef T3CORAL + DEFINE(T3CORAL) +#else + MISSING(T3CORAL) +#endif + +#ifdef T3CORB + DEFINE(T3CORB) +#else + MISSING(T3CORB) +#endif + +#ifdef T3CORBH + DEFINE(T3CORBH) +#else + MISSING(T3CORBH) +#endif + +#ifdef T3CORBL + DEFINE(T3CORBL) +#else + MISSING(T3CORBL) +#endif + +#ifdef T3CRA + DEFINE(T3CRA) +#else + MISSING(T3CRA) +#endif + +#ifdef T3CRB + DEFINE(T3CRB) +#else + MISSING(T3CRB) +#endif + +#ifdef T3ICR + DEFINE(T3ICR) +#else + MISSING(T3ICR) +#endif + +#ifdef T3ICRH + DEFINE(T3ICRH) +#else + MISSING(T3ICRH) +#endif + +#ifdef T3ICRL + DEFINE(T3ICRL) +#else + MISSING(T3ICRL) +#endif + +#ifdef T3IFR + DEFINE(T3IFR) +#else + MISSING(T3IFR) +#endif + +#ifdef T3IMR + DEFINE(T3IMR) +#else + MISSING(T3IMR) +#endif + +#ifdef T3MRA + DEFINE(T3MRA) +#else + MISSING(T3MRA) +#endif + +#ifdef T3MRB + DEFINE(T3MRB) +#else + MISSING(T3MRB) +#endif + +#ifdef TC1H + DEFINE(TC1H) +#else + MISSING(TC1H) +#endif + +#ifdef TC4H + DEFINE(TC4H) +#else + MISSING(TC4H) +#endif + +#ifdef TCC0_CCA + DEFINE(TCC0_CCA) +#else + MISSING(TCC0_CCA) +#endif + +#ifdef TCC0_CCABUF + DEFINE(TCC0_CCABUF) +#else + MISSING(TCC0_CCABUF) +#endif + +#ifdef TCC0_CCB + DEFINE(TCC0_CCB) +#else + MISSING(TCC0_CCB) +#endif + +#ifdef TCC0_CCBBUF + DEFINE(TCC0_CCBBUF) +#else + MISSING(TCC0_CCBBUF) +#endif + +#ifdef TCC0_CCC + DEFINE(TCC0_CCC) +#else + MISSING(TCC0_CCC) +#endif + +#ifdef TCC0_CCCBUF + DEFINE(TCC0_CCCBUF) +#else + MISSING(TCC0_CCCBUF) +#endif + +#ifdef TCC0_CCD + DEFINE(TCC0_CCD) +#else + MISSING(TCC0_CCD) +#endif + +#ifdef TCC0_CCDBUF + DEFINE(TCC0_CCDBUF) +#else + MISSING(TCC0_CCDBUF) +#endif + +#ifdef TCC0_CNT + DEFINE(TCC0_CNT) +#else + MISSING(TCC0_CNT) +#endif + +#ifdef TCC0_CTRLA + DEFINE(TCC0_CTRLA) +#else + MISSING(TCC0_CTRLA) +#endif + +#ifdef TCC0_CTRLB + DEFINE(TCC0_CTRLB) +#else + MISSING(TCC0_CTRLB) +#endif + +#ifdef TCC0_CTRLC + DEFINE(TCC0_CTRLC) +#else + MISSING(TCC0_CTRLC) +#endif + +#ifdef TCC0_CTRLD + DEFINE(TCC0_CTRLD) +#else + MISSING(TCC0_CTRLD) +#endif + +#ifdef TCC0_CTRLE + DEFINE(TCC0_CTRLE) +#else + MISSING(TCC0_CTRLE) +#endif + +#ifdef TCC0_CTRLFCLR + DEFINE(TCC0_CTRLFCLR) +#else + MISSING(TCC0_CTRLFCLR) +#endif + +#ifdef TCC0_CTRLFSET + DEFINE(TCC0_CTRLFSET) +#else + MISSING(TCC0_CTRLFSET) +#endif + +#ifdef TCC0_CTRLGCLR + DEFINE(TCC0_CTRLGCLR) +#else + MISSING(TCC0_CTRLGCLR) +#endif + +#ifdef TCC0_CTRLGSET + DEFINE(TCC0_CTRLGSET) +#else + MISSING(TCC0_CTRLGSET) +#endif + +#ifdef TCC0_INTCTRLA + DEFINE(TCC0_INTCTRLA) +#else + MISSING(TCC0_INTCTRLA) +#endif + +#ifdef TCC0_INTCTRLB + DEFINE(TCC0_INTCTRLB) +#else + MISSING(TCC0_INTCTRLB) +#endif + +#ifdef TCC0_INTFLAGS + DEFINE(TCC0_INTFLAGS) +#else + MISSING(TCC0_INTFLAGS) +#endif + +#ifdef TCC0_PER + DEFINE(TCC0_PER) +#else + MISSING(TCC0_PER) +#endif + +#ifdef TCC0_PERBUF + DEFINE(TCC0_PERBUF) +#else + MISSING(TCC0_PERBUF) +#endif + +#ifdef TCC0_TEMP + DEFINE(TCC0_TEMP) +#else + MISSING(TCC0_TEMP) +#endif + +#ifdef TCC1_CCA + DEFINE(TCC1_CCA) +#else + MISSING(TCC1_CCA) +#endif + +#ifdef TCC1_CCABUF + DEFINE(TCC1_CCABUF) +#else + MISSING(TCC1_CCABUF) +#endif + +#ifdef TCC1_CCB + DEFINE(TCC1_CCB) +#else + MISSING(TCC1_CCB) +#endif + +#ifdef TCC1_CCBBUF + DEFINE(TCC1_CCBBUF) +#else + MISSING(TCC1_CCBBUF) +#endif + +#ifdef TCC1_CNT + DEFINE(TCC1_CNT) +#else + MISSING(TCC1_CNT) +#endif + +#ifdef TCC1_CTRLA + DEFINE(TCC1_CTRLA) +#else + MISSING(TCC1_CTRLA) +#endif + +#ifdef TCC1_CTRLB + DEFINE(TCC1_CTRLB) +#else + MISSING(TCC1_CTRLB) +#endif + +#ifdef TCC1_CTRLC + DEFINE(TCC1_CTRLC) +#else + MISSING(TCC1_CTRLC) +#endif + +#ifdef TCC1_CTRLD + DEFINE(TCC1_CTRLD) +#else + MISSING(TCC1_CTRLD) +#endif + +#ifdef TCC1_CTRLE + DEFINE(TCC1_CTRLE) +#else + MISSING(TCC1_CTRLE) +#endif + +#ifdef TCC1_CTRLFCLR + DEFINE(TCC1_CTRLFCLR) +#else + MISSING(TCC1_CTRLFCLR) +#endif + +#ifdef TCC1_CTRLFSET + DEFINE(TCC1_CTRLFSET) +#else + MISSING(TCC1_CTRLFSET) +#endif + +#ifdef TCC1_CTRLGCLR + DEFINE(TCC1_CTRLGCLR) +#else + MISSING(TCC1_CTRLGCLR) +#endif + +#ifdef TCC1_CTRLGSET + DEFINE(TCC1_CTRLGSET) +#else + MISSING(TCC1_CTRLGSET) +#endif + +#ifdef TCC1_INTCTRLA + DEFINE(TCC1_INTCTRLA) +#else + MISSING(TCC1_INTCTRLA) +#endif + +#ifdef TCC1_INTCTRLB + DEFINE(TCC1_INTCTRLB) +#else + MISSING(TCC1_INTCTRLB) +#endif + +#ifdef TCC1_INTFLAGS + DEFINE(TCC1_INTFLAGS) +#else + MISSING(TCC1_INTFLAGS) +#endif + +#ifdef TCC1_PER + DEFINE(TCC1_PER) +#else + MISSING(TCC1_PER) +#endif + +#ifdef TCC1_PERBUF + DEFINE(TCC1_PERBUF) +#else + MISSING(TCC1_PERBUF) +#endif + +#ifdef TCC1_TEMP + DEFINE(TCC1_TEMP) +#else + MISSING(TCC1_TEMP) +#endif + +#ifdef TCCR0 + DEFINE(TCCR0) +#else + MISSING(TCCR0) +#endif + +#ifdef TCCR0A + DEFINE(TCCR0A) +#else + MISSING(TCCR0A) +#endif + +#ifdef TCCR0B + DEFINE(TCCR0B) +#else + MISSING(TCCR0B) +#endif + +#ifdef TCCR0C + DEFINE(TCCR0C) +#else + MISSING(TCCR0C) +#endif + +#ifdef TCCR1 + DEFINE(TCCR1) +#else + MISSING(TCCR1) +#endif + +#ifdef TCCR1A + DEFINE(TCCR1A) +#else + MISSING(TCCR1A) +#endif + +#ifdef TCCR1B + DEFINE(TCCR1B) +#else + MISSING(TCCR1B) +#endif + +#ifdef TCCR1C + DEFINE(TCCR1C) +#else + MISSING(TCCR1C) +#endif + +#ifdef TCCR1D + DEFINE(TCCR1D) +#else + MISSING(TCCR1D) +#endif + +#ifdef TCCR1E + DEFINE(TCCR1E) +#else + MISSING(TCCR1E) +#endif + +#ifdef TCCR2 + DEFINE(TCCR2) +#else + MISSING(TCCR2) +#endif + +#ifdef TCCR2A + DEFINE(TCCR2A) +#else + MISSING(TCCR2A) +#endif + +#ifdef TCCR2B + DEFINE(TCCR2B) +#else + MISSING(TCCR2B) +#endif + +#ifdef TCCR3A + DEFINE(TCCR3A) +#else + MISSING(TCCR3A) +#endif + +#ifdef TCCR3B + DEFINE(TCCR3B) +#else + MISSING(TCCR3B) +#endif + +#ifdef TCCR3C + DEFINE(TCCR3C) +#else + MISSING(TCCR3C) +#endif + +#ifdef TCCR4A + DEFINE(TCCR4A) +#else + MISSING(TCCR4A) +#endif + +#ifdef TCCR4B + DEFINE(TCCR4B) +#else + MISSING(TCCR4B) +#endif + +#ifdef TCCR4C + DEFINE(TCCR4C) +#else + MISSING(TCCR4C) +#endif + +#ifdef TCCR4D + DEFINE(TCCR4D) +#else + MISSING(TCCR4D) +#endif + +#ifdef TCCR4E + DEFINE(TCCR4E) +#else + MISSING(TCCR4E) +#endif + +#ifdef TCCR5A + DEFINE(TCCR5A) +#else + MISSING(TCCR5A) +#endif + +#ifdef TCCR5B + DEFINE(TCCR5B) +#else + MISSING(TCCR5B) +#endif + +#ifdef TCCR5C + DEFINE(TCCR5C) +#else + MISSING(TCCR5C) +#endif + +#ifdef TCD0_CCA + DEFINE(TCD0_CCA) +#else + MISSING(TCD0_CCA) +#endif + +#ifdef TCD0_CCABUF + DEFINE(TCD0_CCABUF) +#else + MISSING(TCD0_CCABUF) +#endif + +#ifdef TCD0_CCB + DEFINE(TCD0_CCB) +#else + MISSING(TCD0_CCB) +#endif + +#ifdef TCD0_CCBBUF + DEFINE(TCD0_CCBBUF) +#else + MISSING(TCD0_CCBBUF) +#endif + +#ifdef TCD0_CCC + DEFINE(TCD0_CCC) +#else + MISSING(TCD0_CCC) +#endif + +#ifdef TCD0_CCCBUF + DEFINE(TCD0_CCCBUF) +#else + MISSING(TCD0_CCCBUF) +#endif + +#ifdef TCD0_CCD + DEFINE(TCD0_CCD) +#else + MISSING(TCD0_CCD) +#endif + +#ifdef TCD0_CCDBUF + DEFINE(TCD0_CCDBUF) +#else + MISSING(TCD0_CCDBUF) +#endif + +#ifdef TCD0_CNT + DEFINE(TCD0_CNT) +#else + MISSING(TCD0_CNT) +#endif + +#ifdef TCD0_CTRLA + DEFINE(TCD0_CTRLA) +#else + MISSING(TCD0_CTRLA) +#endif + +#ifdef TCD0_CTRLB + DEFINE(TCD0_CTRLB) +#else + MISSING(TCD0_CTRLB) +#endif + +#ifdef TCD0_CTRLC + DEFINE(TCD0_CTRLC) +#else + MISSING(TCD0_CTRLC) +#endif + +#ifdef TCD0_CTRLD + DEFINE(TCD0_CTRLD) +#else + MISSING(TCD0_CTRLD) +#endif + +#ifdef TCD0_CTRLE + DEFINE(TCD0_CTRLE) +#else + MISSING(TCD0_CTRLE) +#endif + +#ifdef TCD0_CTRLFCLR + DEFINE(TCD0_CTRLFCLR) +#else + MISSING(TCD0_CTRLFCLR) +#endif + +#ifdef TCD0_CTRLFSET + DEFINE(TCD0_CTRLFSET) +#else + MISSING(TCD0_CTRLFSET) +#endif + +#ifdef TCD0_CTRLGCLR + DEFINE(TCD0_CTRLGCLR) +#else + MISSING(TCD0_CTRLGCLR) +#endif + +#ifdef TCD0_CTRLGSET + DEFINE(TCD0_CTRLGSET) +#else + MISSING(TCD0_CTRLGSET) +#endif + +#ifdef TCD0_INTCTRLA + DEFINE(TCD0_INTCTRLA) +#else + MISSING(TCD0_INTCTRLA) +#endif + +#ifdef TCD0_INTCTRLB + DEFINE(TCD0_INTCTRLB) +#else + MISSING(TCD0_INTCTRLB) +#endif + +#ifdef TCD0_INTFLAGS + DEFINE(TCD0_INTFLAGS) +#else + MISSING(TCD0_INTFLAGS) +#endif + +#ifdef TCD0_PER + DEFINE(TCD0_PER) +#else + MISSING(TCD0_PER) +#endif + +#ifdef TCD0_PERBUF + DEFINE(TCD0_PERBUF) +#else + MISSING(TCD0_PERBUF) +#endif + +#ifdef TCD0_TEMP + DEFINE(TCD0_TEMP) +#else + MISSING(TCD0_TEMP) +#endif + +#ifdef TCD1_CCA + DEFINE(TCD1_CCA) +#else + MISSING(TCD1_CCA) +#endif + +#ifdef TCD1_CCABUF + DEFINE(TCD1_CCABUF) +#else + MISSING(TCD1_CCABUF) +#endif + +#ifdef TCD1_CCB + DEFINE(TCD1_CCB) +#else + MISSING(TCD1_CCB) +#endif + +#ifdef TCD1_CCBBUF + DEFINE(TCD1_CCBBUF) +#else + MISSING(TCD1_CCBBUF) +#endif + +#ifdef TCD1_CNT + DEFINE(TCD1_CNT) +#else + MISSING(TCD1_CNT) +#endif + +#ifdef TCD1_CTRLA + DEFINE(TCD1_CTRLA) +#else + MISSING(TCD1_CTRLA) +#endif + +#ifdef TCD1_CTRLB + DEFINE(TCD1_CTRLB) +#else + MISSING(TCD1_CTRLB) +#endif + +#ifdef TCD1_CTRLC + DEFINE(TCD1_CTRLC) +#else + MISSING(TCD1_CTRLC) +#endif + +#ifdef TCD1_CTRLD + DEFINE(TCD1_CTRLD) +#else + MISSING(TCD1_CTRLD) +#endif + +#ifdef TCD1_CTRLE + DEFINE(TCD1_CTRLE) +#else + MISSING(TCD1_CTRLE) +#endif + +#ifdef TCD1_CTRLFCLR + DEFINE(TCD1_CTRLFCLR) +#else + MISSING(TCD1_CTRLFCLR) +#endif + +#ifdef TCD1_CTRLFSET + DEFINE(TCD1_CTRLFSET) +#else + MISSING(TCD1_CTRLFSET) +#endif + +#ifdef TCD1_CTRLGCLR + DEFINE(TCD1_CTRLGCLR) +#else + MISSING(TCD1_CTRLGCLR) +#endif + +#ifdef TCD1_CTRLGSET + DEFINE(TCD1_CTRLGSET) +#else + MISSING(TCD1_CTRLGSET) +#endif + +#ifdef TCD1_INTCTRLA + DEFINE(TCD1_INTCTRLA) +#else + MISSING(TCD1_INTCTRLA) +#endif + +#ifdef TCD1_INTCTRLB + DEFINE(TCD1_INTCTRLB) +#else + MISSING(TCD1_INTCTRLB) +#endif + +#ifdef TCD1_INTFLAGS + DEFINE(TCD1_INTFLAGS) +#else + MISSING(TCD1_INTFLAGS) +#endif + +#ifdef TCD1_PER + DEFINE(TCD1_PER) +#else + MISSING(TCD1_PER) +#endif + +#ifdef TCD1_PERBUF + DEFINE(TCD1_PERBUF) +#else + MISSING(TCD1_PERBUF) +#endif + +#ifdef TCD1_TEMP + DEFINE(TCD1_TEMP) +#else + MISSING(TCD1_TEMP) +#endif + +#ifdef TCE0_CCA + DEFINE(TCE0_CCA) +#else + MISSING(TCE0_CCA) +#endif + +#ifdef TCE0_CCABUF + DEFINE(TCE0_CCABUF) +#else + MISSING(TCE0_CCABUF) +#endif + +#ifdef TCE0_CCB + DEFINE(TCE0_CCB) +#else + MISSING(TCE0_CCB) +#endif + +#ifdef TCE0_CCBBUF + DEFINE(TCE0_CCBBUF) +#else + MISSING(TCE0_CCBBUF) +#endif + +#ifdef TCE0_CCC + DEFINE(TCE0_CCC) +#else + MISSING(TCE0_CCC) +#endif + +#ifdef TCE0_CCCBUF + DEFINE(TCE0_CCCBUF) +#else + MISSING(TCE0_CCCBUF) +#endif + +#ifdef TCE0_CCD + DEFINE(TCE0_CCD) +#else + MISSING(TCE0_CCD) +#endif + +#ifdef TCE0_CCDBUF + DEFINE(TCE0_CCDBUF) +#else + MISSING(TCE0_CCDBUF) +#endif + +#ifdef TCE0_CNT + DEFINE(TCE0_CNT) +#else + MISSING(TCE0_CNT) +#endif + +#ifdef TCE0_CTRLA + DEFINE(TCE0_CTRLA) +#else + MISSING(TCE0_CTRLA) +#endif + +#ifdef TCE0_CTRLB + DEFINE(TCE0_CTRLB) +#else + MISSING(TCE0_CTRLB) +#endif + +#ifdef TCE0_CTRLC + DEFINE(TCE0_CTRLC) +#else + MISSING(TCE0_CTRLC) +#endif + +#ifdef TCE0_CTRLD + DEFINE(TCE0_CTRLD) +#else + MISSING(TCE0_CTRLD) +#endif + +#ifdef TCE0_CTRLE + DEFINE(TCE0_CTRLE) +#else + MISSING(TCE0_CTRLE) +#endif + +#ifdef TCE0_CTRLFCLR + DEFINE(TCE0_CTRLFCLR) +#else + MISSING(TCE0_CTRLFCLR) +#endif + +#ifdef TCE0_CTRLFSET + DEFINE(TCE0_CTRLFSET) +#else + MISSING(TCE0_CTRLFSET) +#endif + +#ifdef TCE0_CTRLGCLR + DEFINE(TCE0_CTRLGCLR) +#else + MISSING(TCE0_CTRLGCLR) +#endif + +#ifdef TCE0_CTRLGSET + DEFINE(TCE0_CTRLGSET) +#else + MISSING(TCE0_CTRLGSET) +#endif + +#ifdef TCE0_INTCTRLA + DEFINE(TCE0_INTCTRLA) +#else + MISSING(TCE0_INTCTRLA) +#endif + +#ifdef TCE0_INTCTRLB + DEFINE(TCE0_INTCTRLB) +#else + MISSING(TCE0_INTCTRLB) +#endif + +#ifdef TCE0_INTFLAGS + DEFINE(TCE0_INTFLAGS) +#else + MISSING(TCE0_INTFLAGS) +#endif + +#ifdef TCE0_PER + DEFINE(TCE0_PER) +#else + MISSING(TCE0_PER) +#endif + +#ifdef TCE0_PERBUF + DEFINE(TCE0_PERBUF) +#else + MISSING(TCE0_PERBUF) +#endif + +#ifdef TCE0_TEMP + DEFINE(TCE0_TEMP) +#else + MISSING(TCE0_TEMP) +#endif + +#ifdef TCE1_CCA + DEFINE(TCE1_CCA) +#else + MISSING(TCE1_CCA) +#endif + +#ifdef TCE1_CCABUF + DEFINE(TCE1_CCABUF) +#else + MISSING(TCE1_CCABUF) +#endif + +#ifdef TCE1_CCB + DEFINE(TCE1_CCB) +#else + MISSING(TCE1_CCB) +#endif + +#ifdef TCE1_CCBBUF + DEFINE(TCE1_CCBBUF) +#else + MISSING(TCE1_CCBBUF) +#endif + +#ifdef TCE1_CNT + DEFINE(TCE1_CNT) +#else + MISSING(TCE1_CNT) +#endif + +#ifdef TCE1_CTRLA + DEFINE(TCE1_CTRLA) +#else + MISSING(TCE1_CTRLA) +#endif + +#ifdef TCE1_CTRLB + DEFINE(TCE1_CTRLB) +#else + MISSING(TCE1_CTRLB) +#endif + +#ifdef TCE1_CTRLC + DEFINE(TCE1_CTRLC) +#else + MISSING(TCE1_CTRLC) +#endif + +#ifdef TCE1_CTRLD + DEFINE(TCE1_CTRLD) +#else + MISSING(TCE1_CTRLD) +#endif + +#ifdef TCE1_CTRLE + DEFINE(TCE1_CTRLE) +#else + MISSING(TCE1_CTRLE) +#endif + +#ifdef TCE1_CTRLFCLR + DEFINE(TCE1_CTRLFCLR) +#else + MISSING(TCE1_CTRLFCLR) +#endif + +#ifdef TCE1_CTRLFSET + DEFINE(TCE1_CTRLFSET) +#else + MISSING(TCE1_CTRLFSET) +#endif + +#ifdef TCE1_CTRLGCLR + DEFINE(TCE1_CTRLGCLR) +#else + MISSING(TCE1_CTRLGCLR) +#endif + +#ifdef TCE1_CTRLGSET + DEFINE(TCE1_CTRLGSET) +#else + MISSING(TCE1_CTRLGSET) +#endif + +#ifdef TCE1_INTCTRLA + DEFINE(TCE1_INTCTRLA) +#else + MISSING(TCE1_INTCTRLA) +#endif + +#ifdef TCE1_INTCTRLB + DEFINE(TCE1_INTCTRLB) +#else + MISSING(TCE1_INTCTRLB) +#endif + +#ifdef TCE1_INTFLAGS + DEFINE(TCE1_INTFLAGS) +#else + MISSING(TCE1_INTFLAGS) +#endif + +#ifdef TCE1_PER + DEFINE(TCE1_PER) +#else + MISSING(TCE1_PER) +#endif + +#ifdef TCE1_PERBUF + DEFINE(TCE1_PERBUF) +#else + MISSING(TCE1_PERBUF) +#endif + +#ifdef TCE1_TEMP + DEFINE(TCE1_TEMP) +#else + MISSING(TCE1_TEMP) +#endif + +#ifdef TCF0_CCA + DEFINE(TCF0_CCA) +#else + MISSING(TCF0_CCA) +#endif + +#ifdef TCF0_CCABUF + DEFINE(TCF0_CCABUF) +#else + MISSING(TCF0_CCABUF) +#endif + +#ifdef TCF0_CCB + DEFINE(TCF0_CCB) +#else + MISSING(TCF0_CCB) +#endif + +#ifdef TCF0_CCBBUF + DEFINE(TCF0_CCBBUF) +#else + MISSING(TCF0_CCBBUF) +#endif + +#ifdef TCF0_CCC + DEFINE(TCF0_CCC) +#else + MISSING(TCF0_CCC) +#endif + +#ifdef TCF0_CCCBUF + DEFINE(TCF0_CCCBUF) +#else + MISSING(TCF0_CCCBUF) +#endif + +#ifdef TCF0_CCD + DEFINE(TCF0_CCD) +#else + MISSING(TCF0_CCD) +#endif + +#ifdef TCF0_CCDBUF + DEFINE(TCF0_CCDBUF) +#else + MISSING(TCF0_CCDBUF) +#endif + +#ifdef TCF0_CNT + DEFINE(TCF0_CNT) +#else + MISSING(TCF0_CNT) +#endif + +#ifdef TCF0_CTRLA + DEFINE(TCF0_CTRLA) +#else + MISSING(TCF0_CTRLA) +#endif + +#ifdef TCF0_CTRLB + DEFINE(TCF0_CTRLB) +#else + MISSING(TCF0_CTRLB) +#endif + +#ifdef TCF0_CTRLC + DEFINE(TCF0_CTRLC) +#else + MISSING(TCF0_CTRLC) +#endif + +#ifdef TCF0_CTRLD + DEFINE(TCF0_CTRLD) +#else + MISSING(TCF0_CTRLD) +#endif + +#ifdef TCF0_CTRLE + DEFINE(TCF0_CTRLE) +#else + MISSING(TCF0_CTRLE) +#endif + +#ifdef TCF0_CTRLFCLR + DEFINE(TCF0_CTRLFCLR) +#else + MISSING(TCF0_CTRLFCLR) +#endif + +#ifdef TCF0_CTRLFSET + DEFINE(TCF0_CTRLFSET) +#else + MISSING(TCF0_CTRLFSET) +#endif + +#ifdef TCF0_CTRLGCLR + DEFINE(TCF0_CTRLGCLR) +#else + MISSING(TCF0_CTRLGCLR) +#endif + +#ifdef TCF0_CTRLGSET + DEFINE(TCF0_CTRLGSET) +#else + MISSING(TCF0_CTRLGSET) +#endif + +#ifdef TCF0_INTCTRLA + DEFINE(TCF0_INTCTRLA) +#else + MISSING(TCF0_INTCTRLA) +#endif + +#ifdef TCF0_INTCTRLB + DEFINE(TCF0_INTCTRLB) +#else + MISSING(TCF0_INTCTRLB) +#endif + +#ifdef TCF0_INTFLAGS + DEFINE(TCF0_INTFLAGS) +#else + MISSING(TCF0_INTFLAGS) +#endif + +#ifdef TCF0_PER + DEFINE(TCF0_PER) +#else + MISSING(TCF0_PER) +#endif + +#ifdef TCF0_PERBUF + DEFINE(TCF0_PERBUF) +#else + MISSING(TCF0_PERBUF) +#endif + +#ifdef TCF0_TEMP + DEFINE(TCF0_TEMP) +#else + MISSING(TCF0_TEMP) +#endif + +#ifdef TCF1_CCA + DEFINE(TCF1_CCA) +#else + MISSING(TCF1_CCA) +#endif + +#ifdef TCF1_CCABUF + DEFINE(TCF1_CCABUF) +#else + MISSING(TCF1_CCABUF) +#endif + +#ifdef TCF1_CCB + DEFINE(TCF1_CCB) +#else + MISSING(TCF1_CCB) +#endif + +#ifdef TCF1_CCBBUF + DEFINE(TCF1_CCBBUF) +#else + MISSING(TCF1_CCBBUF) +#endif + +#ifdef TCF1_CNT + DEFINE(TCF1_CNT) +#else + MISSING(TCF1_CNT) +#endif + +#ifdef TCF1_CTRLA + DEFINE(TCF1_CTRLA) +#else + MISSING(TCF1_CTRLA) +#endif + +#ifdef TCF1_CTRLB + DEFINE(TCF1_CTRLB) +#else + MISSING(TCF1_CTRLB) +#endif + +#ifdef TCF1_CTRLC + DEFINE(TCF1_CTRLC) +#else + MISSING(TCF1_CTRLC) +#endif + +#ifdef TCF1_CTRLD + DEFINE(TCF1_CTRLD) +#else + MISSING(TCF1_CTRLD) +#endif + +#ifdef TCF1_CTRLE + DEFINE(TCF1_CTRLE) +#else + MISSING(TCF1_CTRLE) +#endif + +#ifdef TCF1_CTRLFCLR + DEFINE(TCF1_CTRLFCLR) +#else + MISSING(TCF1_CTRLFCLR) +#endif + +#ifdef TCF1_CTRLFSET + DEFINE(TCF1_CTRLFSET) +#else + MISSING(TCF1_CTRLFSET) +#endif + +#ifdef TCF1_CTRLGCLR + DEFINE(TCF1_CTRLGCLR) +#else + MISSING(TCF1_CTRLGCLR) +#endif + +#ifdef TCF1_CTRLGSET + DEFINE(TCF1_CTRLGSET) +#else + MISSING(TCF1_CTRLGSET) +#endif + +#ifdef TCF1_INTCTRLA + DEFINE(TCF1_INTCTRLA) +#else + MISSING(TCF1_INTCTRLA) +#endif + +#ifdef TCF1_INTCTRLB + DEFINE(TCF1_INTCTRLB) +#else + MISSING(TCF1_INTCTRLB) +#endif + +#ifdef TCF1_INTFLAGS + DEFINE(TCF1_INTFLAGS) +#else + MISSING(TCF1_INTFLAGS) +#endif + +#ifdef TCF1_PER + DEFINE(TCF1_PER) +#else + MISSING(TCF1_PER) +#endif + +#ifdef TCF1_PERBUF + DEFINE(TCF1_PERBUF) +#else + MISSING(TCF1_PERBUF) +#endif + +#ifdef TCF1_TEMP + DEFINE(TCF1_TEMP) +#else + MISSING(TCF1_TEMP) +#endif + +#ifdef TCNT0 + DEFINE(TCNT0) +#else + MISSING(TCNT0) +#endif + +#ifdef TCNT0H + DEFINE(TCNT0H) +#else + MISSING(TCNT0H) +#endif + +#ifdef TCNT0L + DEFINE(TCNT0L) +#else + MISSING(TCNT0L) +#endif + +#ifdef TCNT1 + DEFINE(TCNT1) +#else + MISSING(TCNT1) +#endif + +#ifdef TCNT1H + DEFINE(TCNT1H) +#else + MISSING(TCNT1H) +#endif + +#ifdef TCNT1L + DEFINE(TCNT1L) +#else + MISSING(TCNT1L) +#endif + +#ifdef TCNT2 + DEFINE(TCNT2) +#else + MISSING(TCNT2) +#endif + +#ifdef TCNT3 + DEFINE(TCNT3) +#else + MISSING(TCNT3) +#endif + +#ifdef TCNT3H + DEFINE(TCNT3H) +#else + MISSING(TCNT3H) +#endif + +#ifdef TCNT3L + DEFINE(TCNT3L) +#else + MISSING(TCNT3L) +#endif + +#ifdef TCNT4 + DEFINE(TCNT4) +#else + MISSING(TCNT4) +#endif + +#ifdef TCNT4H + DEFINE(TCNT4H) +#else + MISSING(TCNT4H) +#endif + +#ifdef TCNT4L + DEFINE(TCNT4L) +#else + MISSING(TCNT4L) +#endif + +#ifdef TCNT5 + DEFINE(TCNT5) +#else + MISSING(TCNT5) +#endif + +#ifdef TCNT5H + DEFINE(TCNT5H) +#else + MISSING(TCNT5H) +#endif + +#ifdef TCNT5L + DEFINE(TCNT5L) +#else + MISSING(TCNT5L) +#endif + +#ifdef TIFR + DEFINE(TIFR) +#else + MISSING(TIFR) +#endif + +#ifdef TIFR0 + DEFINE(TIFR0) +#else + MISSING(TIFR0) +#endif + +#ifdef TIFR1 + DEFINE(TIFR1) +#else + MISSING(TIFR1) +#endif + +#ifdef TIFR2 + DEFINE(TIFR2) +#else + MISSING(TIFR2) +#endif + +#ifdef TIFR3 + DEFINE(TIFR3) +#else + MISSING(TIFR3) +#endif + +#ifdef TIFR4 + DEFINE(TIFR4) +#else + MISSING(TIFR4) +#endif + +#ifdef TIFR5 + DEFINE(TIFR5) +#else + MISSING(TIFR5) +#endif + +#ifdef TIMSK + DEFINE(TIMSK) +#else + MISSING(TIMSK) +#endif + +#ifdef TIMSK0 + DEFINE(TIMSK0) +#else + MISSING(TIMSK0) +#endif + +#ifdef TIMSK1 + DEFINE(TIMSK1) +#else + MISSING(TIMSK1) +#endif + +#ifdef TIMSK2 + DEFINE(TIMSK2) +#else + MISSING(TIMSK2) +#endif + +#ifdef TIMSK3 + DEFINE(TIMSK3) +#else + MISSING(TIMSK3) +#endif + +#ifdef TIMSK4 + DEFINE(TIMSK4) +#else + MISSING(TIMSK4) +#endif + +#ifdef TIMSK5 + DEFINE(TIMSK5) +#else + MISSING(TIMSK5) +#endif + +#ifdef TRXFBEND + DEFINE(TRXFBEND) +#else + MISSING(TRXFBEND) +#endif + +#ifdef TRXFBST + DEFINE(TRXFBST) +#else + MISSING(TRXFBST) +#endif + +#ifdef TRXPR + DEFINE(TRXPR) +#else + MISSING(TRXPR) +#endif + +#ifdef TRX_CTRL_0 + DEFINE(TRX_CTRL_0) +#else + MISSING(TRX_CTRL_0) +#endif + +#ifdef TRX_CTRL_1 + DEFINE(TRX_CTRL_1) +#else + MISSING(TRX_CTRL_1) +#endif + +#ifdef TRX_CTRL_2 + DEFINE(TRX_CTRL_2) +#else + MISSING(TRX_CTRL_2) +#endif + +#ifdef TRX_STATE + DEFINE(TRX_STATE) +#else + MISSING(TRX_STATE) +#endif + +#ifdef TRX_STATUS + DEFINE(TRX_STATUS) +#else + MISSING(TRX_STATUS) +#endif + +#ifdef TSCR + DEFINE(TSCR) +#else + MISSING(TSCR) +#endif + +#ifdef TST_CTRL_DIGI + DEFINE(TST_CTRL_DIGI) +#else + MISSING(TST_CTRL_DIGI) +#endif + +#ifdef TST_RX_LENGTH + DEFINE(TST_RX_LENGTH) +#else + MISSING(TST_RX_LENGTH) +#endif + +#ifdef TWAMR + DEFINE(TWAMR) +#else + MISSING(TWAMR) +#endif + +#ifdef TWAR + DEFINE(TWAR) +#else + MISSING(TWAR) +#endif + +#ifdef TWBCSR + DEFINE(TWBCSR) +#else + MISSING(TWBCSR) +#endif + +#ifdef TWBR + DEFINE(TWBR) +#else + MISSING(TWBR) +#endif + +#ifdef TWCR + DEFINE(TWCR) +#else + MISSING(TWCR) +#endif + +#ifdef TWDR + DEFINE(TWDR) +#else + MISSING(TWDR) +#endif + +#ifdef TWHSR + DEFINE(TWHSR) +#else + MISSING(TWHSR) +#endif + +#ifdef TWIC_CTRL + DEFINE(TWIC_CTRL) +#else + MISSING(TWIC_CTRL) +#endif + +#ifdef TWIC_MASTER_ADDR + DEFINE(TWIC_MASTER_ADDR) +#else + MISSING(TWIC_MASTER_ADDR) +#endif + +#ifdef TWIC_MASTER_BAUD + DEFINE(TWIC_MASTER_BAUD) +#else + MISSING(TWIC_MASTER_BAUD) +#endif + +#ifdef TWIC_MASTER_CTRLA + DEFINE(TWIC_MASTER_CTRLA) +#else + MISSING(TWIC_MASTER_CTRLA) +#endif + +#ifdef TWIC_MASTER_CTRLB + DEFINE(TWIC_MASTER_CTRLB) +#else + MISSING(TWIC_MASTER_CTRLB) +#endif + +#ifdef TWIC_MASTER_CTRLC + DEFINE(TWIC_MASTER_CTRLC) +#else + MISSING(TWIC_MASTER_CTRLC) +#endif + +#ifdef TWIC_MASTER_DATA + DEFINE(TWIC_MASTER_DATA) +#else + MISSING(TWIC_MASTER_DATA) +#endif + +#ifdef TWIC_MASTER_STATUS + DEFINE(TWIC_MASTER_STATUS) +#else + MISSING(TWIC_MASTER_STATUS) +#endif + +#ifdef TWIC_SLAVE_ADDR + DEFINE(TWIC_SLAVE_ADDR) +#else + MISSING(TWIC_SLAVE_ADDR) +#endif + +#ifdef TWIC_SLAVE_ADDRMASK + DEFINE(TWIC_SLAVE_ADDRMASK) +#else + MISSING(TWIC_SLAVE_ADDRMASK) +#endif + +#ifdef TWIC_SLAVE_CTRLA + DEFINE(TWIC_SLAVE_CTRLA) +#else + MISSING(TWIC_SLAVE_CTRLA) +#endif + +#ifdef TWIC_SLAVE_CTRLB + DEFINE(TWIC_SLAVE_CTRLB) +#else + MISSING(TWIC_SLAVE_CTRLB) +#endif + +#ifdef TWIC_SLAVE_DATA + DEFINE(TWIC_SLAVE_DATA) +#else + MISSING(TWIC_SLAVE_DATA) +#endif + +#ifdef TWIC_SLAVE_STATUS + DEFINE(TWIC_SLAVE_STATUS) +#else + MISSING(TWIC_SLAVE_STATUS) +#endif + +#ifdef TWID_CTRL + DEFINE(TWID_CTRL) +#else + MISSING(TWID_CTRL) +#endif + +#ifdef TWID_MASTER_ADDR + DEFINE(TWID_MASTER_ADDR) +#else + MISSING(TWID_MASTER_ADDR) +#endif + +#ifdef TWID_MASTER_BAUD + DEFINE(TWID_MASTER_BAUD) +#else + MISSING(TWID_MASTER_BAUD) +#endif + +#ifdef TWID_MASTER_CTRLA + DEFINE(TWID_MASTER_CTRLA) +#else + MISSING(TWID_MASTER_CTRLA) +#endif + +#ifdef TWID_MASTER_CTRLB + DEFINE(TWID_MASTER_CTRLB) +#else + MISSING(TWID_MASTER_CTRLB) +#endif + +#ifdef TWID_MASTER_CTRLC + DEFINE(TWID_MASTER_CTRLC) +#else + MISSING(TWID_MASTER_CTRLC) +#endif + +#ifdef TWID_MASTER_DATA + DEFINE(TWID_MASTER_DATA) +#else + MISSING(TWID_MASTER_DATA) +#endif + +#ifdef TWID_MASTER_STATUS + DEFINE(TWID_MASTER_STATUS) +#else + MISSING(TWID_MASTER_STATUS) +#endif + +#ifdef TWID_SLAVE_ADDR + DEFINE(TWID_SLAVE_ADDR) +#else + MISSING(TWID_SLAVE_ADDR) +#endif + +#ifdef TWID_SLAVE_ADDRMASK + DEFINE(TWID_SLAVE_ADDRMASK) +#else + MISSING(TWID_SLAVE_ADDRMASK) +#endif + +#ifdef TWID_SLAVE_CTRLA + DEFINE(TWID_SLAVE_CTRLA) +#else + MISSING(TWID_SLAVE_CTRLA) +#endif + +#ifdef TWID_SLAVE_CTRLB + DEFINE(TWID_SLAVE_CTRLB) +#else + MISSING(TWID_SLAVE_CTRLB) +#endif + +#ifdef TWID_SLAVE_DATA + DEFINE(TWID_SLAVE_DATA) +#else + MISSING(TWID_SLAVE_DATA) +#endif + +#ifdef TWID_SLAVE_STATUS + DEFINE(TWID_SLAVE_STATUS) +#else + MISSING(TWID_SLAVE_STATUS) +#endif + +#ifdef TWIE_CTRL + DEFINE(TWIE_CTRL) +#else + MISSING(TWIE_CTRL) +#endif + +#ifdef TWIE_MASTER_ADDR + DEFINE(TWIE_MASTER_ADDR) +#else + MISSING(TWIE_MASTER_ADDR) +#endif + +#ifdef TWIE_MASTER_BAUD + DEFINE(TWIE_MASTER_BAUD) +#else + MISSING(TWIE_MASTER_BAUD) +#endif + +#ifdef TWIE_MASTER_CTRLA + DEFINE(TWIE_MASTER_CTRLA) +#else + MISSING(TWIE_MASTER_CTRLA) +#endif + +#ifdef TWIE_MASTER_CTRLB + DEFINE(TWIE_MASTER_CTRLB) +#else + MISSING(TWIE_MASTER_CTRLB) +#endif + +#ifdef TWIE_MASTER_CTRLC + DEFINE(TWIE_MASTER_CTRLC) +#else + MISSING(TWIE_MASTER_CTRLC) +#endif + +#ifdef TWIE_MASTER_DATA + DEFINE(TWIE_MASTER_DATA) +#else + MISSING(TWIE_MASTER_DATA) +#endif + +#ifdef TWIE_MASTER_STATUS + DEFINE(TWIE_MASTER_STATUS) +#else + MISSING(TWIE_MASTER_STATUS) +#endif + +#ifdef TWIE_SLAVE_ADDR + DEFINE(TWIE_SLAVE_ADDR) +#else + MISSING(TWIE_SLAVE_ADDR) +#endif + +#ifdef TWIE_SLAVE_ADDRMASK + DEFINE(TWIE_SLAVE_ADDRMASK) +#else + MISSING(TWIE_SLAVE_ADDRMASK) +#endif + +#ifdef TWIE_SLAVE_CTRLA + DEFINE(TWIE_SLAVE_CTRLA) +#else + MISSING(TWIE_SLAVE_CTRLA) +#endif + +#ifdef TWIE_SLAVE_CTRLB + DEFINE(TWIE_SLAVE_CTRLB) +#else + MISSING(TWIE_SLAVE_CTRLB) +#endif + +#ifdef TWIE_SLAVE_DATA + DEFINE(TWIE_SLAVE_DATA) +#else + MISSING(TWIE_SLAVE_DATA) +#endif + +#ifdef TWIE_SLAVE_STATUS + DEFINE(TWIE_SLAVE_STATUS) +#else + MISSING(TWIE_SLAVE_STATUS) +#endif + +#ifdef TWIF_CTRL + DEFINE(TWIF_CTRL) +#else + MISSING(TWIF_CTRL) +#endif + +#ifdef TWIF_MASTER_ADDR + DEFINE(TWIF_MASTER_ADDR) +#else + MISSING(TWIF_MASTER_ADDR) +#endif + +#ifdef TWIF_MASTER_BAUD + DEFINE(TWIF_MASTER_BAUD) +#else + MISSING(TWIF_MASTER_BAUD) +#endif + +#ifdef TWIF_MASTER_CTRLA + DEFINE(TWIF_MASTER_CTRLA) +#else + MISSING(TWIF_MASTER_CTRLA) +#endif + +#ifdef TWIF_MASTER_CTRLB + DEFINE(TWIF_MASTER_CTRLB) +#else + MISSING(TWIF_MASTER_CTRLB) +#endif + +#ifdef TWIF_MASTER_CTRLC + DEFINE(TWIF_MASTER_CTRLC) +#else + MISSING(TWIF_MASTER_CTRLC) +#endif + +#ifdef TWIF_MASTER_DATA + DEFINE(TWIF_MASTER_DATA) +#else + MISSING(TWIF_MASTER_DATA) +#endif + +#ifdef TWIF_MASTER_STATUS + DEFINE(TWIF_MASTER_STATUS) +#else + MISSING(TWIF_MASTER_STATUS) +#endif + +#ifdef TWIF_SLAVE_ADDR + DEFINE(TWIF_SLAVE_ADDR) +#else + MISSING(TWIF_SLAVE_ADDR) +#endif + +#ifdef TWIF_SLAVE_ADDRMASK + DEFINE(TWIF_SLAVE_ADDRMASK) +#else + MISSING(TWIF_SLAVE_ADDRMASK) +#endif + +#ifdef TWIF_SLAVE_CTRLA + DEFINE(TWIF_SLAVE_CTRLA) +#else + MISSING(TWIF_SLAVE_CTRLA) +#endif + +#ifdef TWIF_SLAVE_CTRLB + DEFINE(TWIF_SLAVE_CTRLB) +#else + MISSING(TWIF_SLAVE_CTRLB) +#endif + +#ifdef TWIF_SLAVE_DATA + DEFINE(TWIF_SLAVE_DATA) +#else + MISSING(TWIF_SLAVE_DATA) +#endif + +#ifdef TWIF_SLAVE_STATUS + DEFINE(TWIF_SLAVE_STATUS) +#else + MISSING(TWIF_SLAVE_STATUS) +#endif + +#ifdef TWIHSR + DEFINE(TWIHSR) +#else + MISSING(TWIHSR) +#endif + +#ifdef TWSA + DEFINE(TWSA) +#else + MISSING(TWSA) +#endif + +#ifdef TWSAM + DEFINE(TWSAM) +#else + MISSING(TWSAM) +#endif + +#ifdef TWSCRA + DEFINE(TWSCRA) +#else + MISSING(TWSCRA) +#endif + +#ifdef TWSCRB + DEFINE(TWSCRB) +#else + MISSING(TWSCRB) +#endif + +#ifdef TWSD + DEFINE(TWSD) +#else + MISSING(TWSD) +#endif + +#ifdef TWSR + DEFINE(TWSR) +#else + MISSING(TWSR) +#endif + +#ifdef TWSSRA + DEFINE(TWSSRA) +#else + MISSING(TWSSRA) +#endif + +#ifdef TXB + DEFINE(TXB) +#else + MISSING(TXB) +#endif + +#ifdef TX_CNTL + DEFINE(TX_CNTL) +#else + MISSING(TX_CNTL) +#endif + +#ifdef UBRR + DEFINE(UBRR) +#else + MISSING(UBRR) +#endif + +#ifdef UBRR0 + DEFINE(UBRR0) +#else + MISSING(UBRR0) +#endif + +#ifdef UBRR0H + DEFINE(UBRR0H) +#else + MISSING(UBRR0H) +#endif + +#ifdef UBRR0L + DEFINE(UBRR0L) +#else + MISSING(UBRR0L) +#endif + +#ifdef UBRR1 + DEFINE(UBRR1) +#else + MISSING(UBRR1) +#endif + +#ifdef UBRR1H + DEFINE(UBRR1H) +#else + MISSING(UBRR1H) +#endif + +#ifdef UBRR1L + DEFINE(UBRR1L) +#else + MISSING(UBRR1L) +#endif + +#ifdef UBRR2 + DEFINE(UBRR2) +#else + MISSING(UBRR2) +#endif + +#ifdef UBRR2H + DEFINE(UBRR2H) +#else + MISSING(UBRR2H) +#endif + +#ifdef UBRR2L + DEFINE(UBRR2L) +#else + MISSING(UBRR2L) +#endif + +#ifdef UBRR3 + DEFINE(UBRR3) +#else + MISSING(UBRR3) +#endif + +#ifdef UBRR3H + DEFINE(UBRR3H) +#else + MISSING(UBRR3H) +#endif + +#ifdef UBRR3L + DEFINE(UBRR3L) +#else + MISSING(UBRR3L) +#endif + +#ifdef UBRRH + DEFINE(UBRRH) +#else + MISSING(UBRRH) +#endif + +#ifdef UBRRHI + DEFINE(UBRRHI) +#else + MISSING(UBRRHI) +#endif + +#ifdef UBRRL + DEFINE(UBRRL) +#else + MISSING(UBRRL) +#endif + +#ifdef UBRRLO + DEFINE(UBRRLO) +#else + MISSING(UBRRLO) +#endif + +#ifdef UCR + DEFINE(UCR) +#else + MISSING(UCR) +#endif + +#ifdef UCRA + DEFINE(UCRA) +#else + MISSING(UCRA) +#endif + +#ifdef UCRB + DEFINE(UCRB) +#else + MISSING(UCRB) +#endif + +#ifdef UCSR0A + DEFINE(UCSR0A) +#else + MISSING(UCSR0A) +#endif + +#ifdef UCSR0B + DEFINE(UCSR0B) +#else + MISSING(UCSR0B) +#endif + +#ifdef UCSR0C + DEFINE(UCSR0C) +#else + MISSING(UCSR0C) +#endif + +#ifdef UCSR1A + DEFINE(UCSR1A) +#else + MISSING(UCSR1A) +#endif + +#ifdef UCSR1B + DEFINE(UCSR1B) +#else + MISSING(UCSR1B) +#endif + +#ifdef UCSR1C + DEFINE(UCSR1C) +#else + MISSING(UCSR1C) +#endif + +#ifdef UCSR1D + DEFINE(UCSR1D) +#else + MISSING(UCSR1D) +#endif + +#ifdef UCSR2A + DEFINE(UCSR2A) +#else + MISSING(UCSR2A) +#endif + +#ifdef UCSR2B + DEFINE(UCSR2B) +#else + MISSING(UCSR2B) +#endif + +#ifdef UCSR2C + DEFINE(UCSR2C) +#else + MISSING(UCSR2C) +#endif + +#ifdef UCSR3A + DEFINE(UCSR3A) +#else + MISSING(UCSR3A) +#endif + +#ifdef UCSR3B + DEFINE(UCSR3B) +#else + MISSING(UCSR3B) +#endif + +#ifdef UCSR3C + DEFINE(UCSR3C) +#else + MISSING(UCSR3C) +#endif + +#ifdef UCSRA + DEFINE(UCSRA) +#else + MISSING(UCSRA) +#endif + +#ifdef UCSRB + DEFINE(UCSRB) +#else + MISSING(UCSRB) +#endif + +#ifdef UCSRC + DEFINE(UCSRC) +#else + MISSING(UCSRC) +#endif + +#ifdef UDADDR + DEFINE(UDADDR) +#else + MISSING(UDADDR) +#endif + +#ifdef UDCON + DEFINE(UDCON) +#else + MISSING(UDCON) +#endif + +#ifdef UDFNUM + DEFINE(UDFNUM) +#else + MISSING(UDFNUM) +#endif + +#ifdef UDFNUMH + DEFINE(UDFNUMH) +#else + MISSING(UDFNUMH) +#endif + +#ifdef UDFNUML + DEFINE(UDFNUML) +#else + MISSING(UDFNUML) +#endif + +#ifdef UDIEN + DEFINE(UDIEN) +#else + MISSING(UDIEN) +#endif + +#ifdef UDINT + DEFINE(UDINT) +#else + MISSING(UDINT) +#endif + +#ifdef UDMFN + DEFINE(UDMFN) +#else + MISSING(UDMFN) +#endif + +#ifdef UDPADD + DEFINE(UDPADD) +#else + MISSING(UDPADD) +#endif + +#ifdef UDPADDH + DEFINE(UDPADDH) +#else + MISSING(UDPADDH) +#endif + +#ifdef UDPADDL + DEFINE(UDPADDL) +#else + MISSING(UDPADDL) +#endif + +#ifdef UDR + DEFINE(UDR) +#else + MISSING(UDR) +#endif + +#ifdef UDR0 + DEFINE(UDR0) +#else + MISSING(UDR0) +#endif + +#ifdef UDR1 + DEFINE(UDR1) +#else + MISSING(UDR1) +#endif + +#ifdef UDR2 + DEFINE(UDR2) +#else + MISSING(UDR2) +#endif + +#ifdef UDR3 + DEFINE(UDR3) +#else + MISSING(UDR3) +#endif + +#ifdef UDTST + DEFINE(UDTST) +#else + MISSING(UDTST) +#endif + +#ifdef UEBCHX + DEFINE(UEBCHX) +#else + MISSING(UEBCHX) +#endif + +#ifdef UEBCLX + DEFINE(UEBCLX) +#else + MISSING(UEBCLX) +#endif + +#ifdef UEBCX + DEFINE(UEBCX) +#else + MISSING(UEBCX) +#endif + +#ifdef UECFG0X + DEFINE(UECFG0X) +#else + MISSING(UECFG0X) +#endif + +#ifdef UECFG1X + DEFINE(UECFG1X) +#else + MISSING(UECFG1X) +#endif + +#ifdef UECONX + DEFINE(UECONX) +#else + MISSING(UECONX) +#endif + +#ifdef UEDATX + DEFINE(UEDATX) +#else + MISSING(UEDATX) +#endif + +#ifdef UEIENX + DEFINE(UEIENX) +#else + MISSING(UEIENX) +#endif + +#ifdef UEINT + DEFINE(UEINT) +#else + MISSING(UEINT) +#endif + +#ifdef UEINTX + DEFINE(UEINTX) +#else + MISSING(UEINTX) +#endif + +#ifdef UENUM + DEFINE(UENUM) +#else + MISSING(UENUM) +#endif + +#ifdef UERST + DEFINE(UERST) +#else + MISSING(UERST) +#endif + +#ifdef UESTA0X + DEFINE(UESTA0X) +#else + MISSING(UESTA0X) +#endif + +#ifdef UESTA1X + DEFINE(UESTA1X) +#else + MISSING(UESTA1X) +#endif + +#ifdef UHADDR + DEFINE(UHADDR) +#else + MISSING(UHADDR) +#endif + +#ifdef UHCON + DEFINE(UHCON) +#else + MISSING(UHCON) +#endif + +#ifdef UHCR + DEFINE(UHCR) +#else + MISSING(UHCR) +#endif + +#ifdef UHFLEN + DEFINE(UHFLEN) +#else + MISSING(UHFLEN) +#endif + +#ifdef UHFNUM + DEFINE(UHFNUM) +#else + MISSING(UHFNUM) +#endif + +#ifdef UHFNUMH + DEFINE(UHFNUMH) +#else + MISSING(UHFNUMH) +#endif + +#ifdef UHFNUML + DEFINE(UHFNUML) +#else + MISSING(UHFNUML) +#endif + +#ifdef UHIEN + DEFINE(UHIEN) +#else + MISSING(UHIEN) +#endif + +#ifdef UHINT + DEFINE(UHINT) +#else + MISSING(UHINT) +#endif + +#ifdef UHSR + DEFINE(UHSR) +#else + MISSING(UHSR) +#endif + +#ifdef UHWCON + DEFINE(UHWCON) +#else + MISSING(UHWCON) +#endif + +#ifdef UPBCHX + DEFINE(UPBCHX) +#else + MISSING(UPBCHX) +#endif + +#ifdef UPBCLX + DEFINE(UPBCLX) +#else + MISSING(UPBCLX) +#endif + +#ifdef UPBCX + DEFINE(UPBCX) +#else + MISSING(UPBCX) +#endif + +#ifdef UPBCXH + DEFINE(UPBCXH) +#else + MISSING(UPBCXH) +#endif + +#ifdef UPBCXL + DEFINE(UPBCXL) +#else + MISSING(UPBCXL) +#endif + +#ifdef UPCFG0X + DEFINE(UPCFG0X) +#else + MISSING(UPCFG0X) +#endif + +#ifdef UPCFG1X + DEFINE(UPCFG1X) +#else + MISSING(UPCFG1X) +#endif + +#ifdef UPCFG2X + DEFINE(UPCFG2X) +#else + MISSING(UPCFG2X) +#endif + +#ifdef UPCONX + DEFINE(UPCONX) +#else + MISSING(UPCONX) +#endif + +#ifdef UPCRX + DEFINE(UPCRX) +#else + MISSING(UPCRX) +#endif + +#ifdef UPDATX + DEFINE(UPDATX) +#else + MISSING(UPDATX) +#endif + +#ifdef UPERRX + DEFINE(UPERRX) +#else + MISSING(UPERRX) +#endif + +#ifdef UPIENX + DEFINE(UPIENX) +#else + MISSING(UPIENX) +#endif + +#ifdef UPINRQX + DEFINE(UPINRQX) +#else + MISSING(UPINRQX) +#endif + +#ifdef UPINT + DEFINE(UPINT) +#else + MISSING(UPINT) +#endif + +#ifdef UPINTX + DEFINE(UPINTX) +#else + MISSING(UPINTX) +#endif + +#ifdef UPNUM + DEFINE(UPNUM) +#else + MISSING(UPNUM) +#endif + +#ifdef UPOE + DEFINE(UPOE) +#else + MISSING(UPOE) +#endif + +#ifdef UPRST + DEFINE(UPRST) +#else + MISSING(UPRST) +#endif + +#ifdef UPSTAX + DEFINE(UPSTAX) +#else + MISSING(UPSTAX) +#endif + +#ifdef USARTC0_BAUDCTRLA + DEFINE(USARTC0_BAUDCTRLA) +#else + MISSING(USARTC0_BAUDCTRLA) +#endif + +#ifdef USARTC0_BAUDCTRLB + DEFINE(USARTC0_BAUDCTRLB) +#else + MISSING(USARTC0_BAUDCTRLB) +#endif + +#ifdef USARTC0_CTRLA + DEFINE(USARTC0_CTRLA) +#else + MISSING(USARTC0_CTRLA) +#endif + +#ifdef USARTC0_CTRLB + DEFINE(USARTC0_CTRLB) +#else + MISSING(USARTC0_CTRLB) +#endif + +#ifdef USARTC0_CTRLC + DEFINE(USARTC0_CTRLC) +#else + MISSING(USARTC0_CTRLC) +#endif + +#ifdef USARTC0_DATA + DEFINE(USARTC0_DATA) +#else + MISSING(USARTC0_DATA) +#endif + +#ifdef USARTC0_STATUS + DEFINE(USARTC0_STATUS) +#else + MISSING(USARTC0_STATUS) +#endif + +#ifdef USARTC1_BAUDCTRLA + DEFINE(USARTC1_BAUDCTRLA) +#else + MISSING(USARTC1_BAUDCTRLA) +#endif + +#ifdef USARTC1_BAUDCTRLB + DEFINE(USARTC1_BAUDCTRLB) +#else + MISSING(USARTC1_BAUDCTRLB) +#endif + +#ifdef USARTC1_CTRLA + DEFINE(USARTC1_CTRLA) +#else + MISSING(USARTC1_CTRLA) +#endif + +#ifdef USARTC1_CTRLB + DEFINE(USARTC1_CTRLB) +#else + MISSING(USARTC1_CTRLB) +#endif + +#ifdef USARTC1_CTRLC + DEFINE(USARTC1_CTRLC) +#else + MISSING(USARTC1_CTRLC) +#endif + +#ifdef USARTC1_DATA + DEFINE(USARTC1_DATA) +#else + MISSING(USARTC1_DATA) +#endif + +#ifdef USARTC1_STATUS + DEFINE(USARTC1_STATUS) +#else + MISSING(USARTC1_STATUS) +#endif + +#ifdef USARTD0_BAUDCTRLA + DEFINE(USARTD0_BAUDCTRLA) +#else + MISSING(USARTD0_BAUDCTRLA) +#endif + +#ifdef USARTD0_BAUDCTRLB + DEFINE(USARTD0_BAUDCTRLB) +#else + MISSING(USARTD0_BAUDCTRLB) +#endif + +#ifdef USARTD0_CTRLA + DEFINE(USARTD0_CTRLA) +#else + MISSING(USARTD0_CTRLA) +#endif + +#ifdef USARTD0_CTRLB + DEFINE(USARTD0_CTRLB) +#else + MISSING(USARTD0_CTRLB) +#endif + +#ifdef USARTD0_CTRLC + DEFINE(USARTD0_CTRLC) +#else + MISSING(USARTD0_CTRLC) +#endif + +#ifdef USARTD0_DATA + DEFINE(USARTD0_DATA) +#else + MISSING(USARTD0_DATA) +#endif + +#ifdef USARTD0_STATUS + DEFINE(USARTD0_STATUS) +#else + MISSING(USARTD0_STATUS) +#endif + +#ifdef USARTD1_BAUDCTRLA + DEFINE(USARTD1_BAUDCTRLA) +#else + MISSING(USARTD1_BAUDCTRLA) +#endif + +#ifdef USARTD1_BAUDCTRLB + DEFINE(USARTD1_BAUDCTRLB) +#else + MISSING(USARTD1_BAUDCTRLB) +#endif + +#ifdef USARTD1_CTRLA + DEFINE(USARTD1_CTRLA) +#else + MISSING(USARTD1_CTRLA) +#endif + +#ifdef USARTD1_CTRLB + DEFINE(USARTD1_CTRLB) +#else + MISSING(USARTD1_CTRLB) +#endif + +#ifdef USARTD1_CTRLC + DEFINE(USARTD1_CTRLC) +#else + MISSING(USARTD1_CTRLC) +#endif + +#ifdef USARTD1_DATA + DEFINE(USARTD1_DATA) +#else + MISSING(USARTD1_DATA) +#endif + +#ifdef USARTD1_STATUS + DEFINE(USARTD1_STATUS) +#else + MISSING(USARTD1_STATUS) +#endif + +#ifdef USARTE0_BAUDCTRLA + DEFINE(USARTE0_BAUDCTRLA) +#else + MISSING(USARTE0_BAUDCTRLA) +#endif + +#ifdef USARTE0_BAUDCTRLB + DEFINE(USARTE0_BAUDCTRLB) +#else + MISSING(USARTE0_BAUDCTRLB) +#endif + +#ifdef USARTE0_CTRLA + DEFINE(USARTE0_CTRLA) +#else + MISSING(USARTE0_CTRLA) +#endif + +#ifdef USARTE0_CTRLB + DEFINE(USARTE0_CTRLB) +#else + MISSING(USARTE0_CTRLB) +#endif + +#ifdef USARTE0_CTRLC + DEFINE(USARTE0_CTRLC) +#else + MISSING(USARTE0_CTRLC) +#endif + +#ifdef USARTE0_DATA + DEFINE(USARTE0_DATA) +#else + MISSING(USARTE0_DATA) +#endif + +#ifdef USARTE0_STATUS + DEFINE(USARTE0_STATUS) +#else + MISSING(USARTE0_STATUS) +#endif + +#ifdef USARTE1_BAUDCTRLA + DEFINE(USARTE1_BAUDCTRLA) +#else + MISSING(USARTE1_BAUDCTRLA) +#endif + +#ifdef USARTE1_BAUDCTRLB + DEFINE(USARTE1_BAUDCTRLB) +#else + MISSING(USARTE1_BAUDCTRLB) +#endif + +#ifdef USARTE1_CTRLA + DEFINE(USARTE1_CTRLA) +#else + MISSING(USARTE1_CTRLA) +#endif + +#ifdef USARTE1_CTRLB + DEFINE(USARTE1_CTRLB) +#else + MISSING(USARTE1_CTRLB) +#endif + +#ifdef USARTE1_CTRLC + DEFINE(USARTE1_CTRLC) +#else + MISSING(USARTE1_CTRLC) +#endif + +#ifdef USARTE1_DATA + DEFINE(USARTE1_DATA) +#else + MISSING(USARTE1_DATA) +#endif + +#ifdef USARTE1_STATUS + DEFINE(USARTE1_STATUS) +#else + MISSING(USARTE1_STATUS) +#endif + +#ifdef USARTF0_BAUDCTRLA + DEFINE(USARTF0_BAUDCTRLA) +#else + MISSING(USARTF0_BAUDCTRLA) +#endif + +#ifdef USARTF0_BAUDCTRLB + DEFINE(USARTF0_BAUDCTRLB) +#else + MISSING(USARTF0_BAUDCTRLB) +#endif + +#ifdef USARTF0_CTRLA + DEFINE(USARTF0_CTRLA) +#else + MISSING(USARTF0_CTRLA) +#endif + +#ifdef USARTF0_CTRLB + DEFINE(USARTF0_CTRLB) +#else + MISSING(USARTF0_CTRLB) +#endif + +#ifdef USARTF0_CTRLC + DEFINE(USARTF0_CTRLC) +#else + MISSING(USARTF0_CTRLC) +#endif + +#ifdef USARTF0_DATA + DEFINE(USARTF0_DATA) +#else + MISSING(USARTF0_DATA) +#endif + +#ifdef USARTF0_STATUS + DEFINE(USARTF0_STATUS) +#else + MISSING(USARTF0_STATUS) +#endif + +#ifdef USARTF1_BAUDCTRLA + DEFINE(USARTF1_BAUDCTRLA) +#else + MISSING(USARTF1_BAUDCTRLA) +#endif + +#ifdef USARTF1_BAUDCTRLB + DEFINE(USARTF1_BAUDCTRLB) +#else + MISSING(USARTF1_BAUDCTRLB) +#endif + +#ifdef USARTF1_CTRLA + DEFINE(USARTF1_CTRLA) +#else + MISSING(USARTF1_CTRLA) +#endif + +#ifdef USARTF1_CTRLB + DEFINE(USARTF1_CTRLB) +#else + MISSING(USARTF1_CTRLB) +#endif + +#ifdef USARTF1_CTRLC + DEFINE(USARTF1_CTRLC) +#else + MISSING(USARTF1_CTRLC) +#endif + +#ifdef USARTF1_DATA + DEFINE(USARTF1_DATA) +#else + MISSING(USARTF1_DATA) +#endif + +#ifdef USARTF1_STATUS + DEFINE(USARTF1_STATUS) +#else + MISSING(USARTF1_STATUS) +#endif + +#ifdef USBCON + DEFINE(USBCON) +#else + MISSING(USBCON) +#endif + +#ifdef USBCR + DEFINE(USBCR) +#else + MISSING(USBCR) +#endif + +#ifdef USBCSEX + DEFINE(USBCSEX) +#else + MISSING(USBCSEX) +#endif + +#ifdef USBDBCEX + DEFINE(USBDBCEX) +#else + MISSING(USBDBCEX) +#endif + +#ifdef USBDMAB + DEFINE(USBDMAB) +#else + MISSING(USBDMAB) +#endif + +#ifdef USBDMACS + DEFINE(USBDMACS) +#else + MISSING(USBDMACS) +#endif + +#ifdef USBDMAD + DEFINE(USBDMAD) +#else + MISSING(USBDMAD) +#endif + +#ifdef USBDMADH + DEFINE(USBDMADH) +#else + MISSING(USBDMADH) +#endif + +#ifdef USBDMADL + DEFINE(USBDMADL) +#else + MISSING(USBDMADL) +#endif + +#ifdef USBEI + DEFINE(USBEI) +#else + MISSING(USBEI) +#endif + +#ifdef USBEIM + DEFINE(USBEIM) +#else + MISSING(USBEIM) +#endif + +#ifdef USBENUM + DEFINE(USBENUM) +#else + MISSING(USBENUM) +#endif + +#ifdef USBFA + DEFINE(USBFA) +#else + MISSING(USBFA) +#endif + +#ifdef USBFCEX + DEFINE(USBFCEX) +#else + MISSING(USBFCEX) +#endif + +#ifdef USBFN + DEFINE(USBFN) +#else + MISSING(USBFN) +#endif + +#ifdef USBFNH + DEFINE(USBFNH) +#else + MISSING(USBFNH) +#endif + +#ifdef USBFNL + DEFINE(USBFNL) +#else + MISSING(USBFNL) +#endif + +#ifdef USBGS + DEFINE(USBGS) +#else + MISSING(USBGS) +#endif + +#ifdef USBINT + DEFINE(USBINT) +#else + MISSING(USBINT) +#endif + +#ifdef USBPI + DEFINE(USBPI) +#else + MISSING(USBPI) +#endif + +#ifdef USBPIM + DEFINE(USBPIM) +#else + MISSING(USBPIM) +#endif + +#ifdef USBRSTE + DEFINE(USBRSTE) +#else + MISSING(USBRSTE) +#endif + +#ifdef USBSTA + DEFINE(USBSTA) +#else + MISSING(USBSTA) +#endif + +#ifdef USB_ADDR + DEFINE(USB_ADDR) +#else + MISSING(USB_ADDR) +#endif + +#ifdef USB_CAL0 + DEFINE(USB_CAL0) +#else + MISSING(USB_CAL0) +#endif + +#ifdef USB_CAL1 + DEFINE(USB_CAL1) +#else + MISSING(USB_CAL1) +#endif + +#ifdef USB_CTRLA + DEFINE(USB_CTRLA) +#else + MISSING(USB_CTRLA) +#endif + +#ifdef USB_CTRLB + DEFINE(USB_CTRLB) +#else + MISSING(USB_CTRLB) +#endif + +#ifdef USB_EPPTR + DEFINE(USB_EPPTR) +#else + MISSING(USB_EPPTR) +#endif + +#ifdef USB_EP_TABLE_EP0IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP0IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP0IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP0IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP0IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP0IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_CNTH + DEFINE(USB_EP_TABLE_EP0IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP0IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP0IN_CNTL + DEFINE(USB_EP_TABLE_EP0IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP0IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_CTRL + DEFINE(USB_EP_TABLE_EP0IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP0IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP0IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP0IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP0IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP0IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP0IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP0IN_STATUS + DEFINE(USB_EP_TABLE_EP0IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP0IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP0OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP0OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_CNTH + DEFINE(USB_EP_TABLE_EP0OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP0OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_CNTL + DEFINE(USB_EP_TABLE_EP0OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP0OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_CTRL + DEFINE(USB_EP_TABLE_EP0OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP0OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP0OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP0OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP0OUT_STATUS + DEFINE(USB_EP_TABLE_EP0OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP0OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP10IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP10IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP10IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP10IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP10IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP10IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_CNTH + DEFINE(USB_EP_TABLE_EP10IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP10IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP10IN_CNTL + DEFINE(USB_EP_TABLE_EP10IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP10IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_CTRL + DEFINE(USB_EP_TABLE_EP10IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP10IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP10IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP10IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP10IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP10IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP10IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP10IN_STATUS + DEFINE(USB_EP_TABLE_EP10IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP10IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP10OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP10OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_CNTH + DEFINE(USB_EP_TABLE_EP10OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP10OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_CNTL + DEFINE(USB_EP_TABLE_EP10OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP10OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_CTRL + DEFINE(USB_EP_TABLE_EP10OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP10OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP10OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP10OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP10OUT_STATUS + DEFINE(USB_EP_TABLE_EP10OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP10OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP11IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP11IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP11IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP11IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP11IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP11IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_CNTH + DEFINE(USB_EP_TABLE_EP11IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP11IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP11IN_CNTL + DEFINE(USB_EP_TABLE_EP11IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP11IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_CTRL + DEFINE(USB_EP_TABLE_EP11IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP11IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP11IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP11IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP11IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP11IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP11IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP11IN_STATUS + DEFINE(USB_EP_TABLE_EP11IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP11IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP11OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP11OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_CNTH + DEFINE(USB_EP_TABLE_EP11OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP11OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_CNTL + DEFINE(USB_EP_TABLE_EP11OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP11OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_CTRL + DEFINE(USB_EP_TABLE_EP11OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP11OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP11OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP11OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP11OUT_STATUS + DEFINE(USB_EP_TABLE_EP11OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP11OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP12IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP12IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP12IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP12IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP12IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP12IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_CNTH + DEFINE(USB_EP_TABLE_EP12IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP12IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP12IN_CNTL + DEFINE(USB_EP_TABLE_EP12IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP12IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_CTRL + DEFINE(USB_EP_TABLE_EP12IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP12IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP12IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP12IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP12IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP12IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP12IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP12IN_STATUS + DEFINE(USB_EP_TABLE_EP12IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP12IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP12OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP12OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_CNTH + DEFINE(USB_EP_TABLE_EP12OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP12OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_CNTL + DEFINE(USB_EP_TABLE_EP12OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP12OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_CTRL + DEFINE(USB_EP_TABLE_EP12OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP12OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP12OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP12OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP12OUT_STATUS + DEFINE(USB_EP_TABLE_EP12OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP12OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP13IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP13IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP13IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP13IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP13IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP13IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_CNTH + DEFINE(USB_EP_TABLE_EP13IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP13IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP13IN_CNTL + DEFINE(USB_EP_TABLE_EP13IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP13IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_CTRL + DEFINE(USB_EP_TABLE_EP13IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP13IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP13IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP13IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP13IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP13IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP13IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP13IN_STATUS + DEFINE(USB_EP_TABLE_EP13IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP13IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP13OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP13OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_CNTH + DEFINE(USB_EP_TABLE_EP13OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP13OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_CNTL + DEFINE(USB_EP_TABLE_EP13OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP13OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_CTRL + DEFINE(USB_EP_TABLE_EP13OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP13OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP13OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP13OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP13OUT_STATUS + DEFINE(USB_EP_TABLE_EP13OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP13OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP14IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP14IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP14IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP14IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP14IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP14IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_CNTH + DEFINE(USB_EP_TABLE_EP14IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP14IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP14IN_CNTL + DEFINE(USB_EP_TABLE_EP14IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP14IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_CTRL + DEFINE(USB_EP_TABLE_EP14IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP14IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP14IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP14IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP14IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP14IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP14IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP14IN_STATUS + DEFINE(USB_EP_TABLE_EP14IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP14IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP14OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP14OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_CNTH + DEFINE(USB_EP_TABLE_EP14OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP14OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_CNTL + DEFINE(USB_EP_TABLE_EP14OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP14OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_CTRL + DEFINE(USB_EP_TABLE_EP14OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP14OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP14OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP14OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP14OUT_STATUS + DEFINE(USB_EP_TABLE_EP14OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP14OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP15IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP15IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP15IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP15IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP15IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP15IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_CNTH + DEFINE(USB_EP_TABLE_EP15IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP15IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP15IN_CNTL + DEFINE(USB_EP_TABLE_EP15IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP15IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_CTRL + DEFINE(USB_EP_TABLE_EP15IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP15IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP15IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP15IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP15IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP15IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP15IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP15IN_STATUS + DEFINE(USB_EP_TABLE_EP15IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP15IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP15OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP15OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_CNTH + DEFINE(USB_EP_TABLE_EP15OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP15OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_CNTL + DEFINE(USB_EP_TABLE_EP15OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP15OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_CTRL + DEFINE(USB_EP_TABLE_EP15OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP15OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP15OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP15OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP15OUT_STATUS + DEFINE(USB_EP_TABLE_EP15OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP15OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP1IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP1IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP1IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP1IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP1IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP1IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_CNTH + DEFINE(USB_EP_TABLE_EP1IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP1IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP1IN_CNTL + DEFINE(USB_EP_TABLE_EP1IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP1IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_CTRL + DEFINE(USB_EP_TABLE_EP1IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP1IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP1IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP1IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP1IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP1IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP1IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP1IN_STATUS + DEFINE(USB_EP_TABLE_EP1IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP1IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP1OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP1OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_CNTH + DEFINE(USB_EP_TABLE_EP1OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP1OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_CNTL + DEFINE(USB_EP_TABLE_EP1OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP1OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_CTRL + DEFINE(USB_EP_TABLE_EP1OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP1OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP1OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP1OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP1OUT_STATUS + DEFINE(USB_EP_TABLE_EP1OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP1OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP2IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP2IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP2IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP2IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP2IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP2IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_CNTH + DEFINE(USB_EP_TABLE_EP2IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP2IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP2IN_CNTL + DEFINE(USB_EP_TABLE_EP2IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP2IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_CTRL + DEFINE(USB_EP_TABLE_EP2IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP2IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP2IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP2IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP2IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP2IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP2IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP2IN_STATUS + DEFINE(USB_EP_TABLE_EP2IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP2IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP2OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP2OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_CNTH + DEFINE(USB_EP_TABLE_EP2OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP2OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_CNTL + DEFINE(USB_EP_TABLE_EP2OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP2OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_CTRL + DEFINE(USB_EP_TABLE_EP2OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP2OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP2OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP2OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP2OUT_STATUS + DEFINE(USB_EP_TABLE_EP2OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP2OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP3IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP3IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP3IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP3IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP3IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP3IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_CNTH + DEFINE(USB_EP_TABLE_EP3IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP3IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP3IN_CNTL + DEFINE(USB_EP_TABLE_EP3IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP3IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_CTRL + DEFINE(USB_EP_TABLE_EP3IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP3IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP3IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP3IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP3IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP3IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP3IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP3IN_STATUS + DEFINE(USB_EP_TABLE_EP3IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP3IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP3OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP3OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_CNTH + DEFINE(USB_EP_TABLE_EP3OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP3OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_CNTL + DEFINE(USB_EP_TABLE_EP3OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP3OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_CTRL + DEFINE(USB_EP_TABLE_EP3OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP3OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP3OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP3OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP3OUT_STATUS + DEFINE(USB_EP_TABLE_EP3OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP3OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP4IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP4IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP4IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP4IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP4IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP4IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_CNTH + DEFINE(USB_EP_TABLE_EP4IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP4IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP4IN_CNTL + DEFINE(USB_EP_TABLE_EP4IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP4IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_CTRL + DEFINE(USB_EP_TABLE_EP4IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP4IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP4IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP4IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP4IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP4IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP4IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP4IN_STATUS + DEFINE(USB_EP_TABLE_EP4IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP4IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP4OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP4OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_CNTH + DEFINE(USB_EP_TABLE_EP4OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP4OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_CNTL + DEFINE(USB_EP_TABLE_EP4OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP4OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_CTRL + DEFINE(USB_EP_TABLE_EP4OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP4OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP4OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP4OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP4OUT_STATUS + DEFINE(USB_EP_TABLE_EP4OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP4OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP5IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP5IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP5IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP5IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP5IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP5IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_CNTH + DEFINE(USB_EP_TABLE_EP5IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP5IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP5IN_CNTL + DEFINE(USB_EP_TABLE_EP5IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP5IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_CTRL + DEFINE(USB_EP_TABLE_EP5IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP5IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP5IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP5IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP5IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP5IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP5IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP5IN_STATUS + DEFINE(USB_EP_TABLE_EP5IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP5IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP5OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP5OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_CNTH + DEFINE(USB_EP_TABLE_EP5OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP5OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_CNTL + DEFINE(USB_EP_TABLE_EP5OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP5OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_CTRL + DEFINE(USB_EP_TABLE_EP5OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP5OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP5OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP5OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP5OUT_STATUS + DEFINE(USB_EP_TABLE_EP5OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP5OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP6IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP6IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP6IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP6IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP6IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP6IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_CNTH + DEFINE(USB_EP_TABLE_EP6IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP6IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP6IN_CNTL + DEFINE(USB_EP_TABLE_EP6IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP6IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_CTRL + DEFINE(USB_EP_TABLE_EP6IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP6IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP6IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP6IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP6IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP6IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP6IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP6IN_STATUS + DEFINE(USB_EP_TABLE_EP6IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP6IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP6OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP6OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_CNTH + DEFINE(USB_EP_TABLE_EP6OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP6OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_CNTL + DEFINE(USB_EP_TABLE_EP6OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP6OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_CTRL + DEFINE(USB_EP_TABLE_EP6OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP6OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP6OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP6OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP6OUT_STATUS + DEFINE(USB_EP_TABLE_EP6OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP6OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP7IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP7IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP7IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP7IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP7IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP7IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_CNTH + DEFINE(USB_EP_TABLE_EP7IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP7IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP7IN_CNTL + DEFINE(USB_EP_TABLE_EP7IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP7IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_CTRL + DEFINE(USB_EP_TABLE_EP7IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP7IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP7IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP7IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP7IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP7IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP7IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP7IN_STATUS + DEFINE(USB_EP_TABLE_EP7IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP7IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP7OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP7OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_CNTH + DEFINE(USB_EP_TABLE_EP7OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP7OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_CNTL + DEFINE(USB_EP_TABLE_EP7OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP7OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_CTRL + DEFINE(USB_EP_TABLE_EP7OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP7OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP7OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP7OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP7OUT_STATUS + DEFINE(USB_EP_TABLE_EP7OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP7OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP8IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP8IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP8IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP8IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP8IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP8IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_CNTH + DEFINE(USB_EP_TABLE_EP8IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP8IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP8IN_CNTL + DEFINE(USB_EP_TABLE_EP8IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP8IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_CTRL + DEFINE(USB_EP_TABLE_EP8IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP8IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP8IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP8IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP8IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP8IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP8IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP8IN_STATUS + DEFINE(USB_EP_TABLE_EP8IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP8IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP8OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP8OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_CNTH + DEFINE(USB_EP_TABLE_EP8OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP8OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_CNTL + DEFINE(USB_EP_TABLE_EP8OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP8OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_CTRL + DEFINE(USB_EP_TABLE_EP8OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP8OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP8OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP8OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP8OUT_STATUS + DEFINE(USB_EP_TABLE_EP8OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP8OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP9IN_AUXDATAH + DEFINE(USB_EP_TABLE_EP9IN_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP9IN_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP9IN_AUXDATAL + DEFINE(USB_EP_TABLE_EP9IN_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP9IN_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_CNTH + DEFINE(USB_EP_TABLE_EP9IN_CNTH) +#else + MISSING(USB_EP_TABLE_EP9IN_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP9IN_CNTL + DEFINE(USB_EP_TABLE_EP9IN_CNTL) +#else + MISSING(USB_EP_TABLE_EP9IN_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_CTRL + DEFINE(USB_EP_TABLE_EP9IN_CTRL) +#else + MISSING(USB_EP_TABLE_EP9IN_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_DATAPTRH + DEFINE(USB_EP_TABLE_EP9IN_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP9IN_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP9IN_DATAPTRL + DEFINE(USB_EP_TABLE_EP9IN_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP9IN_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP9IN_STATUS + DEFINE(USB_EP_TABLE_EP9IN_STATUS) +#else + MISSING(USB_EP_TABLE_EP9IN_STATUS) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_AUXDATAH + DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAH) +#else + MISSING(USB_EP_TABLE_EP9OUT_AUXDATAH) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_AUXDATAL + DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAL) +#else + MISSING(USB_EP_TABLE_EP9OUT_AUXDATAL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_CNTH + DEFINE(USB_EP_TABLE_EP9OUT_CNTH) +#else + MISSING(USB_EP_TABLE_EP9OUT_CNTH) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_CNTL + DEFINE(USB_EP_TABLE_EP9OUT_CNTL) +#else + MISSING(USB_EP_TABLE_EP9OUT_CNTL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_CTRL + DEFINE(USB_EP_TABLE_EP9OUT_CTRL) +#else + MISSING(USB_EP_TABLE_EP9OUT_CTRL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_DATAPTRH + DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRH) +#else + MISSING(USB_EP_TABLE_EP9OUT_DATAPTRH) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_DATAPTRL + DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRL) +#else + MISSING(USB_EP_TABLE_EP9OUT_DATAPTRL) +#endif + +#ifdef USB_EP_TABLE_EP9OUT_STATUS + DEFINE(USB_EP_TABLE_EP9OUT_STATUS) +#else + MISSING(USB_EP_TABLE_EP9OUT_STATUS) +#endif + +#ifdef USB_EP_TABLE_FRAMENUMH + DEFINE(USB_EP_TABLE_FRAMENUMH) +#else + MISSING(USB_EP_TABLE_FRAMENUMH) +#endif + +#ifdef USB_EP_TABLE_FRAMENUML + DEFINE(USB_EP_TABLE_FRAMENUML) +#else + MISSING(USB_EP_TABLE_FRAMENUML) +#endif + +#ifdef USB_FIFORP + DEFINE(USB_FIFORP) +#else + MISSING(USB_FIFORP) +#endif + +#ifdef USB_FIFOWP + DEFINE(USB_FIFOWP) +#else + MISSING(USB_FIFOWP) +#endif + +#ifdef USB_INTCTRLA + DEFINE(USB_INTCTRLA) +#else + MISSING(USB_INTCTRLA) +#endif + +#ifdef USB_INTCTRLB + DEFINE(USB_INTCTRLB) +#else + MISSING(USB_INTCTRLB) +#endif + +#ifdef USB_INTFLAGSACLR + DEFINE(USB_INTFLAGSACLR) +#else + MISSING(USB_INTFLAGSACLR) +#endif + +#ifdef USB_INTFLAGSASET + DEFINE(USB_INTFLAGSASET) +#else + MISSING(USB_INTFLAGSASET) +#endif + +#ifdef USB_INTFLAGSBCLR + DEFINE(USB_INTFLAGSBCLR) +#else + MISSING(USB_INTFLAGSBCLR) +#endif + +#ifdef USB_INTFLAGSBSET + DEFINE(USB_INTFLAGSBSET) +#else + MISSING(USB_INTFLAGSBSET) +#endif + +#ifdef USB_STATUS + DEFINE(USB_STATUS) +#else + MISSING(USB_STATUS) +#endif + +#ifdef USIBR + DEFINE(USIBR) +#else + MISSING(USIBR) +#endif + +#ifdef USICR + DEFINE(USICR) +#else + MISSING(USICR) +#endif + +#ifdef USIDR + DEFINE(USIDR) +#else + MISSING(USIDR) +#endif + +#ifdef USIPP + DEFINE(USIPP) +#else + MISSING(USIPP) +#endif + +#ifdef USISR + DEFINE(USISR) +#else + MISSING(USISR) +#endif + +#ifdef USPCR + DEFINE(USPCR) +#else + MISSING(USPCR) +#endif + +#ifdef USPDR + DEFINE(USPDR) +#else + MISSING(USPDR) +#endif + +#ifdef USPSR + DEFINE(USPSR) +#else + MISSING(USPSR) +#endif + +#ifdef USR + DEFINE(USR) +#else + MISSING(USR) +#endif + +#ifdef VADAC0 + DEFINE(VADAC0) +#else + MISSING(VADAC0) +#endif + +#ifdef VADAC1 + DEFINE(VADAC1) +#else + MISSING(VADAC1) +#endif + +#ifdef VADAC2 + DEFINE(VADAC2) +#else + MISSING(VADAC2) +#endif + +#ifdef VADAC3 + DEFINE(VADAC3) +#else + MISSING(VADAC3) +#endif + +#ifdef VADC + DEFINE(VADC) +#else + MISSING(VADC) +#endif + +#ifdef VADCH + DEFINE(VADCH) +#else + MISSING(VADCH) +#endif + +#ifdef VADCL + DEFINE(VADCL) +#else + MISSING(VADCL) +#endif + +#ifdef VADCSR + DEFINE(VADCSR) +#else + MISSING(VADCSR) +#endif + +#ifdef VADIC + DEFINE(VADIC) +#else + MISSING(VADIC) +#endif + +#ifdef VADICH + DEFINE(VADICH) +#else + MISSING(VADICH) +#endif + +#ifdef VADICL + DEFINE(VADICL) +#else + MISSING(VADICL) +#endif + +#ifdef VADMUX + DEFINE(VADMUX) +#else + MISSING(VADMUX) +#endif + +#ifdef VBAT_BACKUP0 + DEFINE(VBAT_BACKUP0) +#else + MISSING(VBAT_BACKUP0) +#endif + +#ifdef VBAT_BACKUP1 + DEFINE(VBAT_BACKUP1) +#else + MISSING(VBAT_BACKUP1) +#endif + +#ifdef VBAT_CTRL + DEFINE(VBAT_CTRL) +#else + MISSING(VBAT_CTRL) +#endif + +#ifdef VBAT_STATUS + DEFINE(VBAT_STATUS) +#else + MISSING(VBAT_STATUS) +#endif + +#ifdef VCOTUNE + DEFINE(VCOTUNE) +#else + MISSING(VCOTUNE) +#endif + +#ifdef VELACC1 + DEFINE(VELACC1) +#else + MISSING(VELACC1) +#endif + +#ifdef VELACC2 + DEFINE(VELACC2) +#else + MISSING(VELACC2) +#endif + +#ifdef VELACC3 + DEFINE(VELACC3) +#else + MISSING(VELACC3) +#endif + +#ifdef VELCVEL + DEFINE(VELCVEL) +#else + MISSING(VELCVEL) +#endif + +#ifdef VELDEC1 + DEFINE(VELDEC1) +#else + MISSING(VELDEC1) +#endif + +#ifdef VELDEC2 + DEFINE(VELDEC2) +#else + MISSING(VELDEC2) +#endif + +#ifdef VELDEC3 + DEFINE(VELDEC3) +#else + MISSING(VELDEC3) +#endif + +#ifdef VELHI1 + DEFINE(VELHI1) +#else + MISSING(VELHI1) +#endif + +#ifdef VELHI2 + DEFINE(VELHI2) +#else + MISSING(VELHI2) +#endif + +#ifdef VELHI3 + DEFINE(VELHI3) +#else + MISSING(VELHI3) +#endif + +#ifdef VELIFLG + DEFINE(VELIFLG) +#else + MISSING(VELIFLG) +#endif + +#ifdef VELIMSK + DEFINE(VELIMSK) +#else + MISSING(VELIMSK) +#endif + +#ifdef VELLOW1 + DEFINE(VELLOW1) +#else + MISSING(VELLOW1) +#endif + +#ifdef VELLOW2 + DEFINE(VELLOW2) +#else + MISSING(VELLOW2) +#endif + +#ifdef VELLOW3 + DEFINE(VELLOW3) +#else + MISSING(VELLOW3) +#endif + +#ifdef VELSTB + DEFINE(VELSTB) +#else + MISSING(VELSTB) +#endif + +#ifdef VELTVEL + DEFINE(VELTVEL) +#else + MISSING(VELTVEL) +#endif + +#ifdef VELVGCTL + DEFINE(VELVGCTL) +#else + MISSING(VELVGCTL) +#endif + +#ifdef VERSION_NUM + DEFINE(VERSION_NUM) +#else + MISSING(VERSION_NUM) +#endif + +#ifdef VLMCSR + DEFINE(VLMCSR) +#else + MISSING(VLMCSR) +#endif + +#ifdef VMCSR + DEFINE(VMCSR) +#else + MISSING(VMCSR) +#endif + +#ifdef VPORT0_DIR + DEFINE(VPORT0_DIR) +#else + MISSING(VPORT0_DIR) +#endif + +#ifdef VPORT0_IN + DEFINE(VPORT0_IN) +#else + MISSING(VPORT0_IN) +#endif + +#ifdef VPORT0_INTFLAGS + DEFINE(VPORT0_INTFLAGS) +#else + MISSING(VPORT0_INTFLAGS) +#endif + +#ifdef VPORT0_OUT + DEFINE(VPORT0_OUT) +#else + MISSING(VPORT0_OUT) +#endif + +#ifdef VPORT1_DIR + DEFINE(VPORT1_DIR) +#else + MISSING(VPORT1_DIR) +#endif + +#ifdef VPORT1_IN + DEFINE(VPORT1_IN) +#else + MISSING(VPORT1_IN) +#endif + +#ifdef VPORT1_INTFLAGS + DEFINE(VPORT1_INTFLAGS) +#else + MISSING(VPORT1_INTFLAGS) +#endif + +#ifdef VPORT1_OUT + DEFINE(VPORT1_OUT) +#else + MISSING(VPORT1_OUT) +#endif + +#ifdef VPORT2_DIR + DEFINE(VPORT2_DIR) +#else + MISSING(VPORT2_DIR) +#endif + +#ifdef VPORT2_IN + DEFINE(VPORT2_IN) +#else + MISSING(VPORT2_IN) +#endif + +#ifdef VPORT2_INTFLAGS + DEFINE(VPORT2_INTFLAGS) +#else + MISSING(VPORT2_INTFLAGS) +#endif + +#ifdef VPORT2_OUT + DEFINE(VPORT2_OUT) +#else + MISSING(VPORT2_OUT) +#endif + +#ifdef VPORT3_DIR + DEFINE(VPORT3_DIR) +#else + MISSING(VPORT3_DIR) +#endif + +#ifdef VPORT3_IN + DEFINE(VPORT3_IN) +#else + MISSING(VPORT3_IN) +#endif + +#ifdef VPORT3_INTFLAGS + DEFINE(VPORT3_INTFLAGS) +#else + MISSING(VPORT3_INTFLAGS) +#endif + +#ifdef VPORT3_OUT + DEFINE(VPORT3_OUT) +#else + MISSING(VPORT3_OUT) +#endif + +#ifdef VREG_CTRL + DEFINE(VREG_CTRL) +#else + MISSING(VREG_CTRL) +#endif + +#ifdef WDTCKD + DEFINE(WDTCKD) +#else + MISSING(WDTCKD) +#endif + +#ifdef WDTCLR + DEFINE(WDTCLR) +#else + MISSING(WDTCLR) +#endif + +#ifdef WDTCR + DEFINE(WDTCR) +#else + MISSING(WDTCR) +#endif + +#ifdef WDTCSR + DEFINE(WDTCSR) +#else + MISSING(WDTCSR) +#endif + +#ifdef WDT_CTRL + DEFINE(WDT_CTRL) +#else + MISSING(WDT_CTRL) +#endif + +#ifdef WDT_STATUS + DEFINE(WDT_STATUS) +#else + MISSING(WDT_STATUS) +#endif + +#ifdef WDT_WINCTRL + DEFINE(WDT_WINCTRL) +#else + MISSING(WDT_WINCTRL) +#endif + +#ifdef WUTCSR + DEFINE(WUTCSR) +#else + MISSING(WUTCSR) +#endif + +#ifdef XAH_CTRL_0 + DEFINE(XAH_CTRL_0) +#else + MISSING(XAH_CTRL_0) +#endif + +#ifdef XAH_CTRL_1 + DEFINE(XAH_CTRL_1) +#else + MISSING(XAH_CTRL_1) +#endif + +#ifdef XDIV + DEFINE(XDIV) +#else + MISSING(XDIV) +#endif + +#ifdef XMCRA + DEFINE(XMCRA) +#else + MISSING(XMCRA) +#endif + +#ifdef XMCRB + DEFINE(XMCRB) +#else + MISSING(XMCRB) +#endif + +#ifdef XOSC_CTRL + DEFINE(XOSC_CTRL) +#else + MISSING(XOSC_CTRL) +#endif diff --git a/generated_intdefs.h b/generated_intdefs.h new file mode 100644 index 0000000..0e14d7d --- /dev/null +++ b/generated_intdefs.h @@ -0,0 +1,69 @@ + +// Generated file, do not edit! + +#define LONGEST_STRING_IN_INTDEFS_H 20 + + +#ifdef NUM_DIGITAL_PINS + DEFINE(NUM_DIGITAL_PINS) +#endif + +#ifdef RAMSTART + DEFINE(RAMSTART) +#endif + +#ifdef RAMEND + DEFINE(RAMEND) +#endif + +#ifdef XRAMEND + DEFINE(XRAMEND) +#endif + +#ifdef E2END + DEFINE(E2END) +#endif + +#ifdef FLASHEND + DEFINE(FLASHEND) +#endif + +#ifdef SPM_PAGESIZE + DEFINE(SPM_PAGESIZE) +#endif + +#ifdef E2PAGESIZE + DEFINE(E2PAGESIZE) +#endif + +#ifdef F_CPU + DEFINE(F_CPU) +#endif + +#ifdef ARDUINO + DEFINE(ARDUINO) +#endif + +#ifdef __AVR_LIBC_DATE_ + DEFINE(__AVR_LIBC_DATE_) +#endif + +#ifdef __AVR_LIBC_VERSION__ + DEFINE(__AVR_LIBC_VERSION__) +#endif + +#ifdef IRAM0_ADDR + DEFINE(IRAM0_ADDR) +#endif + +#ifdef IRAM0_SIZE + DEFINE(IRAM0_SIZE) +#endif + +#ifdef IRAM1_ADDR + DEFINE(IRAM1_ADDR) +#endif + +#ifdef IRAM1_SIZE + DEFINE(IRAM1_SIZE) +#endif diff --git a/generated_mcu.h b/generated_mcu.h new file mode 100644 index 0000000..69ac374 --- /dev/null +++ b/generated_mcu.h @@ -0,0 +1,1287 @@ + +// this file was generated by codegen.py + +// __AVR_LIBC_VERSION_STRING__ = "1.8.0" +// __AVR_LIBC_DATE_STRING__ = "20111228" + + +#ifdef __AVR_AT43USB320__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT43USB320__" +#endif + +#ifdef __AVR_AT43USB355__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT43USB355__" +#endif + +#ifdef __AVR_AT76C711__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT76C711__" +#endif + +#ifdef __AVR_AT86RF401__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT86RF401__" +#endif + +#ifdef __AVR_AT90C8534__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90C8534__" +#endif + +#ifdef __AVR_AT90CAN128__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90CAN128__" +#endif + +#ifdef __AVR_AT90CAN32__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90CAN32__" +#endif + +#ifdef __AVR_AT90CAN64__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90CAN64__" +#endif + +#ifdef __AVR_AT90PWM1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM1__" +#endif + +#ifdef __AVR_AT90PWM216__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM216__" +#endif + +#ifdef __AVR_AT90PWM2B__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM2B__" +#endif + +#ifdef __AVR_AT90PWM2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM2__" +#endif + +#ifdef __AVR_AT90PWM316__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM316__" +#endif + +#ifdef __AVR_AT90PWM3B__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM3B__" +#endif + +#ifdef __AVR_AT90PWM3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM3__" +#endif + +#ifdef __AVR_AT90PWM81__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90PWM81__" +#endif + +#ifdef __AVR_AT90S1200__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S1200__" +#endif + +#ifdef __AVR_AT90S2313__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2313__" +#endif + +#ifdef __AVR_AT90S2323__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2323__" +#endif + +#ifdef __AVR_AT90S2333__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2333__" +#endif + +#ifdef __AVR_AT90S2343__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S2343__" +#endif + +#ifdef __AVR_AT90S4414__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S4414__" +#endif + +#ifdef __AVR_AT90S4433__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S4433__" +#endif + +#ifdef __AVR_AT90S4434__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S4434__" +#endif + +#ifdef __AVR_AT90S8515__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S8515__" +#endif + +#ifdef __AVR_AT90S8535__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90S8535__" +#endif + +#ifdef __AVR_AT90SCR100__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90SCR100__" +#endif + +#ifdef __AVR_AT90USB1286__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB1286__" +#endif + +#ifdef __AVR_AT90USB1287__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB1287__" +#endif + +#ifdef __AVR_AT90USB162__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB162__" +#endif + +#ifdef __AVR_AT90USB646__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB646__" +#endif + +#ifdef __AVR_AT90USB647__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB647__" +#endif + +#ifdef __AVR_AT90USB82__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT90USB82__" +#endif + +#ifdef __AVR_AT94K__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_AT94K__" +#endif + +#ifdef __AVR_ATA6289__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATA6289__" +#endif + +#ifdef __AVR_ATmega103__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega103__" +#endif + +#ifdef __AVR_ATmega1280__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega1280__" +#endif + +#ifdef __AVR_ATmega1281__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega1281__" +#endif + +#ifdef __AVR_ATmega1284P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega1284P__" +#endif + +#ifdef __AVR_ATmega128RFA1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega128RFA1__" +#endif + +#ifdef __AVR_ATmega128__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega128__" +#endif + +#ifdef __AVR_ATmega161__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega161__" +#endif + +#ifdef __AVR_ATmega162__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega162__" +#endif + +#ifdef __AVR_ATmega163__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega163__" +#endif + +#ifdef __AVR_ATmega164A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega164A__" +#endif + +#ifdef __AVR_ATmega164P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega164P__" +#endif + +#ifdef __AVR_ATmega164__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega164__" +#endif + +#ifdef __AVR_ATmega165A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega165A__" +#endif + +#ifdef __AVR_ATmega165P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega165P__" +#endif + +#ifdef __AVR_ATmega165__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega165__" +#endif + +#ifdef __AVR_ATmega168A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega168A__" +#endif + +#ifdef __AVR_ATmega168P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega168P__" +#endif + +#ifdef __AVR_ATmega168__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega168__" +#endif + +#ifdef __AVR_ATmega169A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169A__" +#endif + +#ifdef __AVR_ATmega169PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169PA__" +#endif + +#ifdef __AVR_ATmega169P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169P__" +#endif + +#ifdef __AVR_ATmega169__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega169__" +#endif + +#ifdef __AVR_ATmega16A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16A__" +#endif + +#ifdef __AVR_ATmega16HVA2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVA2__" +#endif + +#ifdef __AVR_ATmega16HVA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVA__" +#endif + +#ifdef __AVR_ATmega16HVBREVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVBREVB__" +#endif + +#ifdef __AVR_ATmega16HVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16HVB__" +#endif + +#ifdef __AVR_ATmega16M1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16M1__" +#endif + +#ifdef __AVR_ATmega16U2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16U2__" +#endif + +#ifdef __AVR_ATmega16U4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16U4__" +#endif + +#ifdef __AVR_ATmega16__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega16__" +#endif + +#ifdef __AVR_ATmega2560__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega2560__" +#endif + +#ifdef __AVR_ATmega2561__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega2561__" +#endif + +#ifdef __AVR_ATmega323__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega323__" +#endif + +#ifdef __AVR_ATmega324A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega324A__" +#endif + +#ifdef __AVR_ATmega324PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega324PA__" +#endif + +#ifdef __AVR_ATmega324P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega324P__" +#endif + +#ifdef __AVR_ATmega3250A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3250A__" +#endif + +#ifdef __AVR_ATmega3250P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3250P__" +#endif + +#ifdef __AVR_ATmega3250__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3250__" +#endif + +#ifdef __AVR_ATmega325A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega325A__" +#endif + +#ifdef __AVR_ATmega325P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega325P__" +#endif + +#ifdef __AVR_ATmega325__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega325__" +#endif + +#ifdef __AVR_ATmega328P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega328P__" +#endif + +#ifdef __AVR_ATmega328__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega328__" +#endif + +#ifdef __AVR_ATmega3290A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3290A__" +#endif + +#ifdef __AVR_ATmega3290P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3290P__" +#endif + +#ifdef __AVR_ATmega3290__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega3290__" +#endif + +#ifdef __AVR_ATmega329A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329A__" +#endif + +#ifdef __AVR_ATmega329PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329PA__" +#endif + +#ifdef __AVR_ATmega329P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329P__" +#endif + +#ifdef __AVR_ATmega329__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega329__" +#endif + +#ifdef __AVR_ATmega32C1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32C1__" +#endif + +#ifdef __AVR_ATmega32HVBREVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32HVBREVB__" +#endif + +#ifdef __AVR_ATmega32HVB__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32HVB__" +#endif + +#ifdef __AVR_ATmega32M1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32M1__" +#endif + +#ifdef __AVR_ATmega32U2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32U2__" +#endif + +#ifdef __AVR_ATmega32U4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32U4__" +#endif + +#ifdef __AVR_ATmega32U6__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32U6__" +#endif + +#ifdef __AVR_ATmega32__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega32__" +#endif + +#ifdef __AVR_ATmega406__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega406__" +#endif + +#ifdef __AVR_ATmega48A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega48A__" +#endif + +#ifdef __AVR_ATmega48P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega48P__" +#endif + +#ifdef __AVR_ATmega48__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega48__" +#endif + +#ifdef __AVR_ATmega640__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega640__" +#endif + +#ifdef __AVR_ATmega644A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644A__" +#endif + +#ifdef __AVR_ATmega644PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644PA__" +#endif + +#ifdef __AVR_ATmega644P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644P__" +#endif + +#ifdef __AVR_ATmega644__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega644__" +#endif + +#ifdef __AVR_ATmega6450A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6450A__" +#endif + +#ifdef __AVR_ATmega6450P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6450P__" +#endif + +#ifdef __AVR_ATmega6450__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6450__" +#endif + +#ifdef __AVR_ATmega645A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega645A__" +#endif + +#ifdef __AVR_ATmega645P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega645P__" +#endif + +#ifdef __AVR_ATmega645__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega645__" +#endif + +#ifdef __AVR_ATmega6490A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6490A__" +#endif + +#ifdef __AVR_ATmega6490P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6490P__" +#endif + +#ifdef __AVR_ATmega6490__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega6490__" +#endif + +#ifdef __AVR_ATmega649A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega649A__" +#endif + +#ifdef __AVR_ATmega649P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega649P__" +#endif + +#ifdef __AVR_ATmega649__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega649__" +#endif + +#ifdef __AVR_ATmega64C1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64C1__" +#endif + +#ifdef __AVR_ATmega64HVE__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64HVE__" +#endif + +#ifdef __AVR_ATmega64M1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64M1__" +#endif + +#ifdef __AVR_ATmega64__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega64__" +#endif + +#ifdef __AVR_ATmega8515__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8515__" +#endif + +#ifdef __AVR_ATmega8535__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8535__" +#endif + +#ifdef __AVR_ATmega88A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88A__" +#endif + +#ifdef __AVR_ATmega88PA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88PA__" +#endif + +#ifdef __AVR_ATmega88P__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88P__" +#endif + +#ifdef __AVR_ATmega88__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega88__" +#endif + +#ifdef __AVR_ATmega8HVA__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8HVA__" +#endif + +#ifdef __AVR_ATmega8U2__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8U2__" +#endif + +#ifdef __AVR_ATmega8__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATmega8__" +#endif + +#ifdef __AVR_ATtiny10__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny10__" +#endif + +#ifdef __AVR_ATtiny11__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny11__" +#endif + +#ifdef __AVR_ATtiny12__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny12__" +#endif + +#ifdef __AVR_ATtiny13A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny13A__" +#endif + +#ifdef __AVR_ATtiny13__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny13__" +#endif + +#ifdef __AVR_ATtiny15__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny15__" +#endif + +#ifdef __AVR_ATtiny167__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny167__" +#endif + +#ifdef __AVR_ATtiny20__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny20__" +#endif + +#ifdef __AVR_ATtiny22__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny22__" +#endif + +#ifdef __AVR_ATtiny2313A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny2313A__" +#endif + +#ifdef __AVR_ATtiny2313__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny2313__" +#endif + +#ifdef __AVR_ATtiny24A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny24A__" +#endif + +#ifdef __AVR_ATtiny24__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny24__" +#endif + +#ifdef __AVR_ATtiny25__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny25__" +#endif + +#ifdef __AVR_ATtiny261A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny261A__" +#endif + +#ifdef __AVR_ATtiny261__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny261__" +#endif + +#ifdef __AVR_ATtiny26__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny26__" +#endif + +#ifdef __AVR_ATtiny28__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny28__" +#endif + +#ifdef __AVR_ATtiny40__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny40__" +#endif + +#ifdef __AVR_ATtiny4313__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny4313__" +#endif + +#ifdef __AVR_ATtiny43U__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny43U__" +#endif + +#ifdef __AVR_ATtiny44A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny44A__" +#endif + +#ifdef __AVR_ATtiny44__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny44__" +#endif + +#ifdef __AVR_ATtiny45__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny45__" +#endif + +#ifdef __AVR_ATtiny461A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny461A__" +#endif + +#ifdef __AVR_ATtiny461__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny461__" +#endif + +#ifdef __AVR_ATtiny48__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny48__" +#endif + +#ifdef __AVR_ATtiny4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny4__" +#endif + +#ifdef __AVR_ATtiny5__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny5__" +#endif + +#ifdef __AVR_ATtiny84A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny84A__" +#endif + +#ifdef __AVR_ATtiny84__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny84__" +#endif + +#ifdef __AVR_ATtiny85__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny85__" +#endif + +#ifdef __AVR_ATtiny861A__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny861A__" +#endif + +#ifdef __AVR_ATtiny861__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny861__" +#endif + +#ifdef __AVR_ATtiny87__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny87__" +#endif + +#ifdef __AVR_ATtiny88__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny88__" +#endif + +#ifdef __AVR_ATtiny9__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATtiny9__" +#endif + +#ifdef __AVR_ATxmega128A1U__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128A1U__" +#endif + +#ifdef __AVR_ATxmega128A1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128A1__" +#endif + +#ifdef __AVR_ATxmega128A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128A3__" +#endif + +#ifdef __AVR_ATxmega128D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega128D3__" +#endif + +#ifdef __AVR_ATxmega16A4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega16A4__" +#endif + +#ifdef __AVR_ATxmega16D4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega16D4__" +#endif + +#ifdef __AVR_ATxmega192A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega192A3__" +#endif + +#ifdef __AVR_ATxmega192D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega192D3__" +#endif + +#ifdef __AVR_ATxmega256A3B__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega256A3B__" +#endif + +#ifdef __AVR_ATxmega256A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega256A3__" +#endif + +#ifdef __AVR_ATxmega256D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega256D3__" +#endif + +#ifdef __AVR_ATxmega32A4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega32A4__" +#endif + +#ifdef __AVR_ATxmega32D4__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega32D4__" +#endif + +#ifdef __AVR_ATxmega64A1U__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64A1U__" +#endif + +#ifdef __AVR_ATxmega64A1__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64A1__" +#endif + +#ifdef __AVR_ATxmega64A3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64A3__" +#endif + +#ifdef __AVR_ATxmega64D3__ +# ifdef MCU +# error "MCU is already defined" +# endif +# define MCU "__AVR_ATxmega64D3__" +#endif diff --git a/intdefs.h b/intdefs.h new file mode 100644 index 0000000..d1e9215 --- /dev/null +++ b/intdefs.h @@ -0,0 +1,11 @@ + +// const int variables cannot be checked automatically like defines + +DEFINE(A0) + +#ifdef ARDUINO_ARCH_AVR + DEFINE(SS) + DEFINE(MOSI) + DEFINE(MISO) + DEFINE(SCK) +#endif diff --git a/timers.h b/timers.h new file mode 100644 index 0000000..6a8c3f5 --- /dev/null +++ b/timers.h @@ -0,0 +1,501 @@ + +#ifndef FreqCount_timers_h_ +#define FreqCount_timers_h_ + +#include +#include + +// Arduino Mega +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + // #define COUNTER_USE_TIMER1 // T1 is not connected + // #define COUNTER_USE_TIMER3 // T3 is not connected + // #define COUNTER_USE_TIMER4 // T4 is not connected + #define COUNTER_USE_TIMER5 // T5 is pin 47 + #define TIMER_USE_TIMER2 + +// Teensy 2.0 +#elif defined(__AVR_ATmega32U4__) + #define COUNTER_USE_TIMER1 // T1 is pin 11 (has LED connected) + #define TIMER_USE_TIMER4H + +// Teensy++ 1.0 & 2.0 +#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) + #define COUNTER_USE_TIMER1 // T1 is pin 6 (has LED connected) + //#define COUNTER_USE_TIMER3 // T3 is pin 13 + #define TIMER_USE_TIMER2 + +// Sanguino +#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) + #define COUNTER_USE_TIMER1 // T1 is pin 1 + #define TIMER_USE_TIMER2 + +// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc +#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) + #define COUNTER_USE_TIMER1 // T1 is pin 5 + #define TIMER_USE_TIMER2 + +#else + #error "Unknown chip, please edit me with timer+counter definitions" + +#endif + + +/**********************************************/ +/* Counter Hardware Abstraction */ +/**********************************************/ + +#if defined(COUNTER_USE_TIMER1) // 16 bit Timer 1 + +static uint8_t saveTCCR1A, saveTCCR1B; + +static inline void counter_init(void) +{ + saveTCCR1A = TCCR1A; + saveTCCR1B = TCCR1B; + TCCR1B = 0; + TCCR1A = 0; + TCNT1 = 0; + TIFR1 = (1<= 16000000L + #define TIMER2_OCR2A_1MS_VAL 124 // div 125 + #define TIMER2_TCCR2B_1MS_VAL (1<> 3; + OCR2A = TIMER2_OCR2A_8MS_VAL; + startTCCR2B = TIMER2_TCCR2B_8MS_VAL; + } else if ((msec & 3) == 0) { + gate_len = msec >> 2; + OCR2A = TIMER2_OCR2A_4MS_VAL; + startTCCR2B = TIMER2_TCCR2B_4MS_VAL; + } else if ((msec & 1) == 0) { + gate_len = msec >> 1; + OCR2A = TIMER2_OCR2A_2MS_VAL; + startTCCR2B = TIMER2_TCCR2B_2MS_VAL; + } else { + gate_len = msec; + OCR2A = TIMER2_OCR2A_1MS_VAL; + startTCCR2B = TIMER2_TCCR2B_1MS_VAL; + } + TIFR2 = (1<: +2 326: 1f 92 push r1 +2 328: 0f 92 push r0 +1 32a: 0f b6 in r0, 0x3f ; 63 +2 32c: 0f 92 push r0 +1 32e: 11 24 eor r1, r1 +2 330: ef 92 push r14 +2 332: ff 92 push r15 +2 334: 0f 93 push r16 +2 336: 1f 93 push r17 +2 338: 2f 93 push r18 +2 33a: 3f 93 push r19 +2 33c: 4f 93 push r20 +2 33e: 5f 93 push r21 +2 340: 8f 93 push r24 +2 342: 9f 93 push r25 +2 344: af 93 push r26 +2 346: bf 93 push r27 +*/ +#define TIMER_LATENCY_CYCLES 34 + + + +#elif defined(TIMER_USE_TIMER4H) // 10 bit "high speed" Timer 4 + +#define TIMER4H_OCR4C_VAL 124 // always div 125 +#if F_CPU == 16000000L + #define TIMER4H_TCCR4B_1MS_VAL (1<> 3; + startTCCR4B = TIMER4H_TCCR4B_8MS_VAL | (1<> 2; + startTCCR4B = TIMER4H_TCCR4B_4MS_VAL | (1<> 1; + startTCCR4B = TIMER4H_TCCR4B_2MS_VAL | (1< Date: Thu, 13 Aug 2020 11:02:35 -0500 Subject: [PATCH 340/344] Updated cfg check --- cfg_check.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfg_check.h b/cfg_check.h index dfb8930..ca8b1aa 100644 --- a/cfg_check.h +++ b/cfg_check.h @@ -10,7 +10,7 @@ #define USE_Register 0 #define USE_Watchdog 0 #define USE_Counter 0 -#define USE_DHT 1 +#define USE_DHT 0 #define USE_LiquidCrystal_I2C 0 #define USE_LiquidCrystal 0 #endif From d21aeda1f63ea58bfeb41c57ca8e47d2ebe830b7 Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Thu, 13 Aug 2020 11:13:07 -0500 Subject: [PATCH 341/344] Revert "Merge branch 'master' of https://github.com/mudpi/nanpy" This reverts commit 78cca19ccf26e4d5cf0f89aaaf56e1ff73cd1b9c, reversing changes made to a99d150cee2f726d7121684c0671d97e49b93a67. --- .coveragerc | 5 - .gitignore | 24 -- .travis.yml | 16 -- CONTRIBUTORS | 21 -- ISSUE_TEMPLATE.md | 47 --- LICENSE | 21 -- README.rst | 168 ----------- docs/css/extra.css | 21 -- docs/img/nanpy_logo_min.png | Bin 427 -> 0 bytes docs/index.md | 187 ------------ mkdocs.yml | 3 - nanpy/DigiPotX9Cxxx.py | 79 ----- nanpy/MCP41xxx.py | 15 - nanpy/PCF8574.py | 43 --- nanpy/TLC5947.py | 17 -- nanpy/__init__.py | 31 -- nanpy/ad9850.py | 101 ------- nanpy/arduinoapi.py | 59 ---- nanpy/arduinoboard.py | 171 ----------- nanpy/arduinocore.py | 68 ----- nanpy/arduinopin.py | 270 ------------------ nanpy/arduinotree.py | 155 ---------- nanpy/bmp180.py | 117 -------- nanpy/capacitivesensor.py | 20 -- nanpy/classinfo.py | 78 ----- nanpy/colorsensor.py | 14 - nanpy/counter.py | 85 ------ nanpy/dallastemperature.py | 55 ---- nanpy/define.py | 87 ------ nanpy/dht.py | 29 -- nanpy/eeprom.py | 25 -- nanpy/esp.py | 109 ------- nanpy/examples/PCF8574.py | 50 ---- nanpy/examples/__init__.py | 0 nanpy/examples/blink.py | 18 -- nanpy/examples/blink_2boards.py | 28 -- nanpy/examples/blink_esp8266.py | 19 -- nanpy/examples/boottime.py | 17 -- nanpy/examples/checkspeed.py | 68 ----- nanpy/examples/clock.py | 33 --- nanpy/examples/counterdemo.py | 39 --- nanpy/examples/dallastemperature.py | 26 -- nanpy/examples/dds.py | 22 -- nanpy/examples/dht.py | 14 - nanpy/examples/digipot.py | 40 --- nanpy/examples/dump.py | 121 -------- nanpy/examples/eepromread.py | 31 -- nanpy/examples/firmware_check.py | 19 -- nanpy/examples/highfreqpwm.py | 22 -- nanpy/examples/i2c_scanner.py | 22 -- nanpy/examples/i2c_send.py | 23 -- nanpy/examples/lcd_autoscroll.py | 34 --- nanpy/examples/lcd_createchar.py | 25 -- nanpy/examples/lcd_hello.py | 27 -- nanpy/examples/melody.py | 17 -- nanpy/examples/power.py | 15 - nanpy/examples/pressure.py | 24 -- nanpy/examples/pwm_demo.py | 29 -- nanpy/examples/ramdump.py | 33 --- nanpy/examples/reset.py | 39 --- nanpy/examples/servo.py | 13 - nanpy/examples/stepper.py | 15 - nanpy/fwinfo.py | 107 ------- nanpy/i2c.py | 110 ------- nanpy/lcd.py | 41 --- nanpy/lcd_i2c.py | 26 -- nanpy/memo.py | 34 --- nanpy/mock/__init__.py | 0 nanpy/mock/mockconnection.py | 77 ----- nanpy/mock/mockeeprom.py | 17 -- nanpy/mock/mockinfo.py | 18 -- nanpy/mock/mockobject.py | 12 - nanpy/mock/mockram.py | 20 -- nanpy/mock/mockservo.py | 33 --- nanpy/mock/mockstepper.py | 29 -- nanpy/nullconnection.py | 10 - nanpy/onewire.py | 37 --- nanpy/pwm.py | 270 ------------------ nanpy/ram.py | 30 -- nanpy/register.py | 176 ------------ nanpy/serialmanager.py | 117 -------- nanpy/servo.py | 35 --- nanpy/shiftout.py | 36 --- nanpy/sockconnection.py | 62 ---- nanpy/stepper.py | 22 -- nanpy/tone.py | 111 ------- nanpy/ultrasonic.py | 18 -- nanpy/util.py | 9 - nanpy/vcc.py | 59 ---- nanpy/watchdog.py | 43 --- nanpy/wire.py | 117 -------- requirements.txt | 1 - setup.py | 40 --- tests/README.md | 9 - tests/__init__.py | 0 tests/test_offline/test.py | 39 --- tests/test_offline/test_fwinfo.py | 46 --- tests/test_offline/test_memo.py | 36 --- .../test_mockconnection/test_eeprom.py | 16 -- .../test_mockconnection/test_ram.py | 18 -- .../test_mockconnection/test_servo.py | 32 --- .../test_mockconnection/test_stepper.py | 12 - tests/test_serial/common.py | 12 - tests/test_serial/config.py | 33 --- tests/test_serial/test.py | 21 -- tests/test_serial/test_arduino.py | 22 -- tests/test_serial/test_arduinocore.py | 37 --- tests/test_serial/test_counter.py | 42 --- tests/test_serial/test_define.py | 44 --- tests/test_serial/test_eeprom.py | 14 - tests/test_serial/test_examples.py | 45 --- tests/test_serial/test_pin.py | 139 --------- tests/test_serial/test_pwm.py | 73 ----- tests/test_serial/test_register.py | 52 ---- tests/test_serial/test_reset.py | 16 -- tests/test_serial/test_shiftout.py | 31 -- tests/test_serial/test_watchdog.py | 21 -- tests/util.py | 41 --- tox.ini | 16 -- 119 files changed, 5608 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .gitignore delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTORS delete mode 100644 ISSUE_TEMPLATE.md delete mode 100644 LICENSE delete mode 100644 README.rst delete mode 100644 docs/css/extra.css delete mode 100644 docs/img/nanpy_logo_min.png delete mode 100644 docs/index.md delete mode 100644 mkdocs.yml delete mode 100644 nanpy/DigiPotX9Cxxx.py delete mode 100644 nanpy/MCP41xxx.py delete mode 100644 nanpy/PCF8574.py delete mode 100644 nanpy/TLC5947.py delete mode 100644 nanpy/__init__.py delete mode 100644 nanpy/ad9850.py delete mode 100644 nanpy/arduinoapi.py delete mode 100644 nanpy/arduinoboard.py delete mode 100644 nanpy/arduinocore.py delete mode 100644 nanpy/arduinopin.py delete mode 100644 nanpy/arduinotree.py delete mode 100755 nanpy/bmp180.py delete mode 100644 nanpy/capacitivesensor.py delete mode 100644 nanpy/classinfo.py delete mode 100644 nanpy/colorsensor.py delete mode 100644 nanpy/counter.py delete mode 100644 nanpy/dallastemperature.py delete mode 100644 nanpy/define.py delete mode 100644 nanpy/dht.py delete mode 100644 nanpy/eeprom.py delete mode 100644 nanpy/esp.py delete mode 100644 nanpy/examples/PCF8574.py delete mode 100644 nanpy/examples/__init__.py delete mode 100755 nanpy/examples/blink.py delete mode 100644 nanpy/examples/blink_2boards.py delete mode 100755 nanpy/examples/blink_esp8266.py delete mode 100644 nanpy/examples/boottime.py delete mode 100644 nanpy/examples/checkspeed.py delete mode 100755 nanpy/examples/clock.py delete mode 100644 nanpy/examples/counterdemo.py delete mode 100755 nanpy/examples/dallastemperature.py delete mode 100644 nanpy/examples/dds.py delete mode 100755 nanpy/examples/dht.py delete mode 100644 nanpy/examples/digipot.py delete mode 100644 nanpy/examples/dump.py delete mode 100755 nanpy/examples/eepromread.py delete mode 100644 nanpy/examples/firmware_check.py delete mode 100644 nanpy/examples/highfreqpwm.py delete mode 100755 nanpy/examples/i2c_scanner.py delete mode 100755 nanpy/examples/i2c_send.py delete mode 100644 nanpy/examples/lcd_autoscroll.py delete mode 100644 nanpy/examples/lcd_createchar.py delete mode 100755 nanpy/examples/lcd_hello.py delete mode 100755 nanpy/examples/melody.py delete mode 100755 nanpy/examples/power.py delete mode 100755 nanpy/examples/pressure.py delete mode 100644 nanpy/examples/pwm_demo.py delete mode 100755 nanpy/examples/ramdump.py delete mode 100755 nanpy/examples/reset.py delete mode 100644 nanpy/examples/servo.py delete mode 100755 nanpy/examples/stepper.py delete mode 100644 nanpy/fwinfo.py delete mode 100644 nanpy/i2c.py delete mode 100644 nanpy/lcd.py delete mode 100644 nanpy/lcd_i2c.py delete mode 100644 nanpy/memo.py delete mode 100644 nanpy/mock/__init__.py delete mode 100644 nanpy/mock/mockconnection.py delete mode 100644 nanpy/mock/mockeeprom.py delete mode 100644 nanpy/mock/mockinfo.py delete mode 100644 nanpy/mock/mockobject.py delete mode 100644 nanpy/mock/mockram.py delete mode 100644 nanpy/mock/mockservo.py delete mode 100644 nanpy/mock/mockstepper.py delete mode 100644 nanpy/nullconnection.py delete mode 100644 nanpy/onewire.py delete mode 100644 nanpy/pwm.py delete mode 100644 nanpy/ram.py delete mode 100644 nanpy/register.py delete mode 100644 nanpy/serialmanager.py delete mode 100644 nanpy/servo.py delete mode 100644 nanpy/shiftout.py delete mode 100644 nanpy/sockconnection.py delete mode 100644 nanpy/stepper.py delete mode 100644 nanpy/tone.py delete mode 100644 nanpy/ultrasonic.py delete mode 100644 nanpy/util.py delete mode 100644 nanpy/vcc.py delete mode 100644 nanpy/watchdog.py delete mode 100644 nanpy/wire.py delete mode 100644 requirements.txt delete mode 100644 setup.py delete mode 100644 tests/README.md delete mode 100644 tests/__init__.py delete mode 100644 tests/test_offline/test.py delete mode 100644 tests/test_offline/test_fwinfo.py delete mode 100644 tests/test_offline/test_memo.py delete mode 100644 tests/test_offline/test_mockconnection/test_eeprom.py delete mode 100644 tests/test_offline/test_mockconnection/test_ram.py delete mode 100644 tests/test_offline/test_mockconnection/test_servo.py delete mode 100644 tests/test_offline/test_mockconnection/test_stepper.py delete mode 100644 tests/test_serial/common.py delete mode 100644 tests/test_serial/config.py delete mode 100644 tests/test_serial/test.py delete mode 100644 tests/test_serial/test_arduino.py delete mode 100644 tests/test_serial/test_arduinocore.py delete mode 100644 tests/test_serial/test_counter.py delete mode 100644 tests/test_serial/test_define.py delete mode 100644 tests/test_serial/test_eeprom.py delete mode 100644 tests/test_serial/test_examples.py delete mode 100644 tests/test_serial/test_pin.py delete mode 100644 tests/test_serial/test_pwm.py delete mode 100644 tests/test_serial/test_register.py delete mode 100644 tests/test_serial/test_reset.py delete mode 100644 tests/test_serial/test_shiftout.py delete mode 100644 tests/test_serial/test_watchdog.py delete mode 100644 tests/util.py delete mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 4dbfced..0000000 --- a/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ -[report] -omit = - */python?.?/* - */site-packages/nose/* - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0fe6650..0000000 --- a/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -#General -.DS_Store -*~ -*.swp -build/ -dist/ -nanpy.egg-info/ -cfg.h -setup_makefile.sh -firmware -venv - -#Python -*.pyc - -#hidden files -.* -!.gitignore -!.gitattributes -!.travis* -!.coveragerc - -#Docs -site/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 48c1df4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: python -python: - - "2.7" - - "3.3" - - "3.4" - - "3.5" - -install: - - pip install coveralls coverage - - pip install pyserial - -script: - - python setup.py nosetests -w tests/test_offline --with-coverage --cover-package=nanpy - -after_success: - - coveralls diff --git a/CONTRIBUTORS b/CONTRIBUTORS deleted file mode 100644 index b288d42..0000000 --- a/CONTRIBUTORS +++ /dev/null @@ -1,21 +0,0 @@ -Written by ----------- -- Andrea Stagi (https://github.com/astagi) -- Ponty (https://github.com/ponty) - -Contributors ------------- -- Kevin Ng (kevin.ngkf@gmail.com) -- Andrea Grandi (https://github.com/andreagrandi) -- Tim Marston (tim@ed.am) -- Fernando Molina (Twitter @F_M_A) -- Laurent Désarmes (https://github.com/llaurent) -- Anthony Goodhew (tony.goodhew@ntlworld.com) -- Richard Giles (https://github.com/wrik) -- Graeme Pyle (https://github.com/graemian) -- Justin Youngblood (darksotm@gmail.com) -- Pierrick Brun (https://github.com/Pi3R1k) -- Balz Reber (https://github.com/balzreber) -- Michal Opler (https://github.com/joppi) -- Stefan Krastanov (https://github.com/Krastanov) -- egarris2 (https://github.com/egarris2) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md deleted file mode 100644 index 89128e1..0000000 --- a/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,47 +0,0 @@ - - -Make sure these boxes are checked before submitting your issue - thank you! - -- [ ] Try `examples/blink.py` -- [ ] Try to test the function without Nanpy, using only Arduino code. -- [ ] Check cfg.h. All needed functions are enabled? -- [ ] Run `examples/firmware_check.py` to check cfg.h again. All needed functions are listed? -- [ ] Your program should be as small as possible which demonstrates the bug. -- [ ] Enable logging in program: `import logging;logging.basicConfig(level=logging.DEBUG)` - - -### Your Python code - - -```python -import logging -logging.basicConfig(level=logging.DEBUG) - -from nanpy import ... -``` - -### Your log messages - -``` -DEBUG:nanpy.serialmanager:opening port:/dev/ttyACM0 [115200 baud] -... -``` - -### Your cfg.h - -```c -#define USE_Info 1 -... -``` -### Output of examples/firmware_check.py - -``` -Firmware classes enabled in cfg.h: - ... -``` - -### Your hardware - -- Arduino board: ` ` -- Additional hardware: ` ` - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f887ad0..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2012-2016 Andrea Stagi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.rst b/README.rst deleted file mode 100644 index f2cc304..0000000 --- a/README.rst +++ /dev/null @@ -1,168 +0,0 @@ -Nanpy -===== - -|Travis| |Latest Version| |Supported Python versions| |Downloads| - -Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy - -Overview --------- - -Nanpy is a library that use your Arduino as a slave, controlled by a master device where you run your scripts, such as a PC, a Raspberry Pi etc. - -The main purpose of Nanpy is making programmers' life easier, providing them a powerful library to create prototypes faster and make Arduino programming a game for kids. - -:: - - from nanpy import ArduinoApi - - a = ArduinoApi() - a.pinMode(13, a.OUTPUT) - a.digitalWrite(13, a.HIGH) - -I know, there are a lot of projects able to do that, but hey, Nanpy can do more! - -Nanpy is easily extensible and can theoretically use every library, -allowing you to create how many objects you want. We support OneWire, Lcd, Stepper, Servo, DallasTemperature and many -more... - -Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and show your first "Hello world"! - -:: - - from nanpy import Lcd - - lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) - lcd.printString('Hello World!') - -really straightforward now, isn't it? :) - -Serial communication -~~~~~~~~~~~~~~~~~~~~ - -Nanpy autodetects the serial port for you, anyway you can manually -specify another serial port: - -:: - - from nanpy import SerialManager - connection = SerialManager(device='/dev/ttyACM1') - -and use it with your objects - -:: - - from nanpy import ArduinoApi - a = ArduinoApi(connection=connection) - a.pinMode(13, a.OUTPUT) - a.digitalWrite(13, a.HIGH) - -You can specify how many SerialManager objects you want and control more -than one Arduino board within the same script. - -How to build and install ------------------------- - -First of all, you need to build the firmware and upload it on your -Arduino, to do that clone the `nanpy-firmware repository on -Github `__ or `download it from -PyPi `__. - -:: - - git clone https://github.com/nanpy/nanpy-firmware.git - cd nanpy-firmware - ./configure.sh - -| You can now edit Nanpy/cfg.h generated file to configure your Nanpy - firmware, selecting the features you want to include and the baud - rate. -| To build and install Nanpy firmware, copy Nanpy directory under your - "sketchbook" directory, start your Arduino IDE, open Sketchbook -> - Nanpy and click on "Upload". - -To install Nanpy Python library on your master device just type: - -:: - - pip install nanpy - -To uninstall:: - - pip uninstall nanpy - -To install the latest version from Github:: - - pip install https://github.com/nanpy/nanpy/archive/master.zip - - -How to contribute ------------------ - -Nanpy still needs a lot of work. You can contribute with patches -(bugfixing, improvements, adding support for a new library not included -in Nanpy yet, writing examples and so on), writing documentation, -reporting bugs, creating packages or simply spreading Nanpy through the -web if you like it :) If you have any doubt or problem, please contact -me at stagi.andrea@gmail.com - -Do you want to support us with a coffee? We need a lot of caffeine to -code all night long! if you like this project and you want to support -us, `please donate using -Paypal `__ - -Bug reports ------------ - -- try the blink.py example -- try to test the function without Nanpy, using only Arduino code. If the problem remains then it is not a Nanpy bug. -- enable logging: `import logging;logging.basicConfig(level=logging.DEBUG)` -- attach the log messages -- attach your program. The program should be as small as possible which demonstrates the bug. -- check cfg.h. All needed functions are enabled? -- Run `examples/firmware_check.py` to check cfg.h again. All needed functions are listed? -- attach your cfg.h -- describe your hardware - -Supported hardware ------------------- - -board: - - ATmega boards (ATtiny has not enough RAM) - - ESP8266 (communication over serial or WiFi connection) - -external hardware: - - BMP180 Digital pressure sensor - - AD9850 Direct Digital Synthesizer - - TLC5947 LED Driver - - DHT11, DHT22, DHT21, AM2301 humidity sensors - - HD44780 LCD controller - - PCF8574 8-Bit I/O Expander for I2C - - X9C1xxx (xxx = 102,103,104,503) digital potentiometers - - HC-SR04 (ultrasonic sensor) - -internal hardware: - - counter, frequency measurement - - PWM (advanced PWM functions are hardcoded for Uno compatible boards) - - ADC - - I2C - - read, write RAM - - read, write EEPROM - - read, write all registers - - tone() - - -License -------- - -This software is released under MIT License. Copyright (c) 2012-2016 -Andrea Stagi stagi.andrea@gmail.com - -.. |Travis| image:: http://img.shields.io/travis/nanpy/nanpy.svg - :target: https://travis-ci.org/nanpy/nanpy/ -.. |Latest Version| image:: https://img.shields.io/pypi/v/nanpy.svg - :target: https://pypi.python.org/pypi/nanpy/ -.. |Supported Python versions| image:: https://img.shields.io/badge/python-2.7%2C%203.3%2C%203.4%2C%203.5-blue.svg - :target: https://pypi.python.org/pypi/nanpy/ -.. |Downloads| image:: https://img.shields.io/pypi/dm/nanpy.svg - :target: https://pypi.python.org/pypi/nanpy/ diff --git a/docs/css/extra.css b/docs/css/extra.css deleted file mode 100644 index 968e58d..0000000 --- a/docs/css/extra.css +++ /dev/null @@ -1,21 +0,0 @@ -div.col-md-9 h1:first-of-type { - text-align: center; - font-size: 60px; - font-weight: 300; -} -div.col-md-9 p:first-of-type { - text-align: center; -} -.navbar { - background-image: none; - background-color: #31a8ae; -} -.navbar-brand:before { - content: ''; - display: inline-block; - width: 18px; - height: 18px; - margin-right: 5px; - vertical-align: middle; - background: url(../img/nanpy_logo_min.png) center center no-repeat; -} \ No newline at end of file diff --git a/docs/img/nanpy_logo_min.png b/docs/img/nanpy_logo_min.png deleted file mode 100644 index 8c5f76e4da07af98d7c458fd04e447d1a2fe3d6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 427 zcmV;c0aX5pP)72sTutX1nDxvTdTu>kdiohwLrlki?5hy~=zzLj|GfxC(;c#bG>-7bVe=BnhtT4h0~~NOXg>my9mY3*Uth zIkR&ZU7XdnRrS|$W|k_lpz$9h)`9#JQPk`5Ih`__OlFG`sQG#mYN8XHnKcs*u%#>8 z0QSCl>`=#IUmcT`GUiqpk-kQ>c-v-n?EC(S-b$LL^9^9MT1{| Nanpy and click on "Upload". - -To install Nanpy Python library on your master device just type: - - pip install nanpy - ---- - -## How to contribute - -Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at - -Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, [please donate using Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TDTPP5JHVJK8J) - ---- - -## How to extend Nanpy - -First of all create some boilerplate code starting with Python. Suppose you want initially support two methods of the Centpiede library - - void portWrite(int port, int value); - int portRead(int port); - -You can create your centipede.py module and put it in nanpy/ - - from nanpy.arduinoboard import ArduinoObject - from nanpy.arduinoboard import (arduinoobjectmethod, returns) - - class Centipede(ArduinoObject): - - def __init__(self, your_parameters connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', your_parameters) - - @arduinoobjectmethod - def portWrite(self, port, value): - pass - - @returns(int) - @arduinoobjectmethod - def portRead(self, port): - pass - -After that you can include this module in the __init__.py to make it available in Nanpy (nanpy/__init__.py https://github.com/nanpy/nanpy/blob/master/nanpy/__init__.py) - - from nanpy.centipede import Centipede - -You're done with Python :) Let's see how to add the firmware part (https://github.com/nanpy/nanpy-firmware) - -First of all modify sample.cfg adding - - #define USE_Centipede 1 - -or do it directly on your cfg.h file :) - -You need to create CentipedeClass.h and CentipedeClass.cpp - -In CentipedeClass.h you need - - #ifndef CENTIPEDE_CLASS - #define CENTIPEDE_CLASS - - #include "BaseClass.h" - #include "MethodDescriptor.h" - - class Centipede; - - namespace nanpy { - class CentipedeClass: public ObjectsManager { - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - }; - } - - #endif - -And in Centipede.cpp - - #include "cfg.h" - - #if USE_Centipede - - #include - #include //!!!Your real Centipede Library!!!! - #include "CentipedeClass.h" - #include - - const char* nanpy::CentipedeClass::get_firmware_id() - { - return "Centipede"; - } - - void nanpy::CentipedeClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - Centipede* cent; - cent = new Centipede (m->getInt(0), m->getInt(1), m->getInt(2)); - cent->begin(); - v.insert(cent); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "portWrite") == 0) { - m->returns(v[m->getObjectId()]->portWrite(m->getInt(0), m->getInt(1))); - } - - if (strcmp(m->getName(), "portRead") == 0) { - m->returns(v[m->getObjectId()]->portRead(m->getInt(0))); - } - }; - - #endif - -Finally you need to register your class in the main loop! Open Nanpy.ino file and add - - //... - - #if USE_Centipede - #include - #endif - - #include "CentipedeClass.h" - - //... - - REGISTER_CLASS_CONDITIONAL(CentipedeClass, USE_Centipede); - ---- - -## License - -This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 7eaab3c..0000000 --- a/mkdocs.yml +++ /dev/null @@ -1,3 +0,0 @@ -site_name: Nanpy - -repo_url: https://github.com/nanpy/ \ No newline at end of file diff --git a/nanpy/DigiPotX9Cxxx.py b/nanpy/DigiPotX9Cxxx.py deleted file mode 100644 index 5ad101c..0000000 --- a/nanpy/DigiPotX9Cxxx.py +++ /dev/null @@ -1,79 +0,0 @@ -# based on https:#sites.google.com/site/tfagerscode/home/digipotx9cxxx -from nanpy.util import constrain - - -DIGIPOT_MAX_AMOUNT = 99 - -LOW, HIGH = 0, 1 -INPUT, OUTPUT = 0, 1 - - -class DigiPot(): - _udLastValue = None - _currentValue = None - range = (0, DIGIPOT_MAX_AMOUNT) - - def __init__(self, incPin, udPin, csPin): - self._incPin = incPin - self._udPin = udPin - self._csPin = csPin - - self._incPin.write_mode(OUTPUT) - self._incPin.write_digital_value(HIGH) - - self._udPin.write_mode(OUTPUT) - - self._csPin.write_mode(OUTPUT) - self._csPin.write_digital_value(LOW) - - self.set(0) - - def reset(self): - # change down maximum number of times to ensure the value is 0 - self.decrease(DIGIPOT_MAX_AMOUNT) - self._currentValue = 0 - - def set(self, value): - value = constrain(value, 0, DIGIPOT_MAX_AMOUNT) - if self._currentValue is None: - self.reset() - if self._currentValue > value: - self.change(-1, self._currentValue - value) - elif self._currentValue < value: - self.change(1, value - self._currentValue) - - def get(self): - return self._currentValue - - def increase(self, amount): - amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) - self.change(1, amount) - - def decrease(self, amount): - amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) - self.change(-1, amount) - - def change(self, direction, amount): - if direction == 1: - ud = HIGH - elif direction == -1: - ud = LOW - else: - raise ValueError('invalid direction: %s', direction) - - amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT) - if amount == 0: - return - - if self._udLastValue != ud: - self._udPin.write_digital_value(ud) - - for _ in range(amount): - self._incPin.write_digital_value(LOW) - self._incPin.write_digital_value(HIGH) - if self._currentValue is not None: - self._currentValue += direction - self._currentValue = constrain( - self._currentValue, - 0, - DIGIPOT_MAX_AMOUNT) diff --git a/nanpy/MCP41xxx.py b/nanpy/MCP41xxx.py deleted file mode 100644 index 9f1ffc8..0000000 --- a/nanpy/MCP41xxx.py +++ /dev/null @@ -1,15 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class MCP41xxx(ArduinoObject): - cfg_h_name = 'USE_MCP41xxx' - - def __init__(self, dac, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', dac) - - - @arduinoobjectmethod - def analogWrite(self, gate, value): - pass - diff --git a/nanpy/PCF8574.py b/nanpy/PCF8574.py deleted file mode 100644 index e65c227..0000000 --- a/nanpy/PCF8574.py +++ /dev/null @@ -1,43 +0,0 @@ -import logging -from nanpy.i2c import I2C_Master - - -log = logging.getLogger(__name__) - - -class PCF8574_Error(Exception): - pass - - -class PCF8574(object): - - def __init__(self, wire, address): - self._address = address - self.master = I2C_Master(wire) - - def read8(self): - ls = self.master.request(self._address, 1) - - # HACK: without beginTransmission all second read is empty - self.master.wire.beginTransmission(self._address) - error_code = self.master.wire.endTransmission() - - if len(ls) >= 1: - return ls[0] - else: - raise PCF8574_Error('no data received from PCF8574') - - def write8(self, value): - self.master.send(self._address, [value]) - - def readPin(self, pin): - d = self.read8() - return (d & (1 << pin)) > 0 - - def writePin(self, pin, value): - d = self.read8() - if value: - d |= (1 << pin) - else: - d &= ~(1 << pin) - self.write8(d) diff --git a/nanpy/TLC5947.py b/nanpy/TLC5947.py deleted file mode 100644 index 2d1ee92..0000000 --- a/nanpy/TLC5947.py +++ /dev/null @@ -1,17 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class TLC5947(ArduinoObject): - cfg_h_name = 'USE_TLC5947' - - def __init__(self, boardTotal, clock, data, latch, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', boardTotal, clock, data, latch) - - @arduinoobjectmethod - def setLED(self, led, r, g, b): - pass - - @arduinoobjectmethod - def write(self): - pass \ No newline at end of file diff --git a/nanpy/__init__.py b/nanpy/__init__.py deleted file mode 100644 index 35969ab..0000000 --- a/nanpy/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# Nanpy -# Copyright 2012 Andrea Stagi -# See LICENSE for details. - -""" -Nanpy library -""" -__version__ = '0.9.6' -__author__ = 'Andrea Stagi' -__license__ = 'MIT' - -from nanpy.arduinoboard import ArduinoObject -from nanpy.serialmanager import SerialManager -from nanpy.serialmanager import serial_manager - -from nanpy.lcd import Lcd -from nanpy.onewire import OneWire -from nanpy.stepper import Stepper -from nanpy.servo import Servo -from nanpy.dallastemperature import DallasTemperature -from nanpy.tone import Tone -from nanpy.capacitivesensor import CapacitiveSensor -from nanpy.dht import DHT -from nanpy.arduinoapi import ArduinoApi -from nanpy.eeprom import EEPROM - -from nanpy.TLC5947 import TLC5947 - -# GW-Robotics Modules -from nanpy.ultrasonic import Ultrasonic -from nanpy.colorsensor import ColorSensor diff --git a/nanpy/ad9850.py b/nanpy/ad9850.py deleted file mode 100644 index 1a6aa3b..0000000 --- a/nanpy/ad9850.py +++ /dev/null @@ -1,101 +0,0 @@ -from __future__ import division -from nanpy.arduinotree import ArduinoTree -from nanpy.memo import memoized -from nanpy.shiftout import ShiftOut - - -LOW, HIGH = 0, 1 -OUTPUT = 1 - - -class AD9850(object): - - """controllling the AD9850 DDS module. - - code is based on this info: http://nr8o.dhlpilotcentral.com/?p=83 - - """ - clock = 125000000 # note 125 MHz clock on 9850 - _frequency = 0 - - def __init__(self, pin_names, connection=None): - ''' - :param pin_names: [W_CLK, FQ_UD, DATA, RESET] - W_CLK // Pin 8 - connect to AD9850 module word load clock pin (CLK) - FQ_UD // Pin 9 - connect to freq update pin (FQ) - DATA // Pin 10 - connect to serial data load pin (DATA) - RESET // Pin 11 - connect to reset pin (RST). - ''' - self.connection = connection - self.pin_names = dict( - W_CLK=pin_names[0], - FQ_UD=pin_names[1], - DATA=pin_names[2], - RESET=pin_names[3]) - - @property - @memoized - def arduino(self): - return ArduinoTree(connection=self.connection) - - def create_pin_object(self, name): - return self.arduino.pin.get(self.pin_names[name]) - - @property - @memoized - def W_CLK(self): - return self.create_pin_object('W_CLK') - - @property - @memoized - def FQ_UD(self): - return self.create_pin_object('FQ_UD') - - @property - @memoized - def DATA(self): - return self.create_pin_object('DATA') - - @property - @memoized - def RESET(self): - return self.create_pin_object('RESET') - - @property - @memoized - def shift(self): - return ShiftOut(self.DATA, self.W_CLK, 0, connection=self.connection) - - def pulse_high(self, pin): - pin.write_digital_value(HIGH) - pin.write_digital_value(LOW) - - def setup(self): - self.FQ_UD.write_mode(OUTPUT) - self.W_CLK.write_mode(OUTPUT) - self.DATA.write_mode(OUTPUT) - self.RESET.write_mode(OUTPUT) - - self.pulse_high(self.RESET) - self.pulse_high(self.W_CLK) - # this pulse enables serial mode - Datasheet page 12 figure 10 - self.pulse_high(self.FQ_UD) - - def tfr_byte(self, value): - self.shift.write_data(value) - - def write_frequency(self, frequency): - # frequency calc from datasheet page 8 = - # * /2^32 - CONST = 4294967295 # 2^32 - 1 - freq = frequency * CONST / self.clock - freq = int(freq) - for b in range(4): - self.tfr_byte((freq >> (8 * b)) & 0xFF) - - self.tfr_byte(0x000) # Final control byte, all 0 for 9850 chip - self.pulse_high(self.FQ_UD) # Done! Should see output - self._frequency = frequency - - # frequency read is not implemented - frequency = property(lambda self: self._frequency, write_frequency) diff --git a/nanpy/arduinoapi.py b/nanpy/arduinoapi.py deleted file mode 100644 index 930d7d4..0000000 --- a/nanpy/arduinoapi.py +++ /dev/null @@ -1,59 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware - - -@check4firmware -class ArduinoApi(FirmwareClass): - - """access to Arduino public API functions.""" - firmware_id = 'A' - - LOW, HIGH = 0, 1 - INPUT, OUTPUT, INPUT_PULLUP = 0, 1, 2 - LSBFIRST, MSBFIRST = 0, 1 - - @arduinomethod('dw') - def digitalWrite(self, pin, value): - pass - - @returns(int) - @arduinomethod('r') - def digitalRead(self, pin): - pass - - @arduinomethod('aw') - def analogWrite(self, pin, value): - pass - - @returns(int) - @arduinomethod('a') - def analogRead(self, pin): - pass - - @arduinomethod('pm') - def pinMode(self, pin, mode): - pass - - @returns(int) - @arduinomethod('m') - def millis(self): - pass - - @returns(int) - @arduinomethod('pi') - def pulseIn(self, pin, value): - pass - - @returns(int) - @arduinomethod('s') - def shiftOut(self, dataPin, clockPin, bitOrder, value): - """Shifts out a byte of data one bit at a time. - - :param dataPin: the pin on which to output each bit (int) - :param clockPin: the pin to toggle once the dataPin has been set to the correct value (int) - :param bitOrder: which order to shift out the bits; either MSBFIRST or LSBFIRST. - :param value: the data to shift out. (byte) - - http://arduino.cc/en/Reference/shiftOut - - """ diff --git a/nanpy/arduinoboard.py b/nanpy/arduinoboard.py deleted file mode 100644 index 203d1b7..0000000 --- a/nanpy/arduinoboard.py +++ /dev/null @@ -1,171 +0,0 @@ -from nanpy.serialmanager import serial_manager -from threading import Lock - -mutex = Lock() - - -def _write(data, connection): - if connection: - connection.write('%s\0' % str(data)) - else: - serial_manager.write('%s\0' % str(data)) - - -def return_value(connection): - if connection: - return connection.readline().replace('\r\n', '') - else: - return serial_manager.readline().replace('\r\n', '') - - -def _call(namespace, id, args, connection): - - toprint = [] - nel = 0 - - mutex.acquire() - try: - _write(namespace, connection) - _write(id, connection) - - for arg in args: - if type(arg) == type(list()): - for el in arg: - if el != None: - toprint.append(el) - nel += 1 - else: - if arg != None: - toprint.append(arg) - nel += 1 - - _write(nel - 1, connection) - - for elprint in toprint: - _write(elprint, connection) - - ret = return_value(connection) - finally: - mutex.release() - return ret - - -def returns(fconv): - def wrapf(func): - def wrapper(self, *args, **kwargs): -# try: - return fconv(func(self, *args, **kwargs)) -# except ValueError: -# return -1 - return wrapper - return wrapf - - -def arduinoobjectmethod(funct, *args, **kwargs): - def wrapper(self, *args, **kwargs): - call_pars = [funct.__name__] - call_pars.extend(args) - funct(self, *args, **kwargs) - connection = self.connection if hasattr(self, 'connection') else None - return _call(self.namespace, self.id, call_pars, connection=connection) - return wrapper - -# def arduinoclassmethod(funct): -# def wrapper(cls, *args, **kwargs): -# call_pars = [funct.__name__] -# call_pars.extend(args) -# funct(cls, *args, **kwargs) -# return _call(cls.__name__, 0, call_pars) -# return wrapper - - -def class_get_firmware_id(cls): - if hasattr(cls, 'get_firmware_id'): - return cls.get_firmware_id() - elif hasattr(cls, 'firmware_id'): - return cls.firmware_id - else: - return cls.__name__ - - -# def arduinoclassmethod(param): -# is_func = hasattr(param, '__call__') -# if is_func: -# funct = param -# -# def wrapper(cls, *args, **kwargs): -# cls_name = class_get_firmware_id(cls) -# call_pars = [funct.__name__] -# call_pars.extend(args) -# funct(cls, *args, **kwargs) -# return _call(cls_name, 0, call_pars, connection=None) -# return wrapper -# else: -# name = param -# -# def wrapper2(funct): -# def wrapper(cls, *args, **kwargs): -# cls_name = class_get_firmware_id(cls) -# call_pars = [name] -# call_pars.extend(args) -# funct(cls, *args, **kwargs) -# return _call(cls_name, 0, call_pars, connection=None) -# return wrapper -# return wrapper2 - - -def _wrapper3(name): - def wrapper2(funct): - def wrapper(obj, *args, **kwargs): - cls_name = class_get_firmware_id(obj.__class__) - connection = obj.connection if hasattr(obj, 'connection') else None - call_pars = [name if name else funct.__name__] - call_pars.extend(args) - funct(obj, *args, **kwargs) - return _call(cls_name, 0, call_pars, connection=connection) - return wrapper - return wrapper2 - - -def arduinomethod(param): - is_func = hasattr(param, '__call__') - if is_func: - funct = param - name = None - return _wrapper3(name)(funct) - else: - name = param - return _wrapper3(name) - - -class ArduinoObject(object): - connection=None - - def __init__(self, connection=None): - self.namespace = self.__class__.__name__ - self.id = 0 - self.connection = connection - - def call(self, *args): - return _call(self.namespace, self.id, args, self.connection) - -# def __del__(self): -# return _call(self.namespace, self.id, ["remove"], self.connection) - - -class FirmwareClass(object): - connection = None - firmware_id = None - cfg_h_name = 'missing implementation!' - - @classmethod - def get_firmware_id(cls): - if cls.firmware_id: - return cls.firmware_id - else: - return cls.__name__ - - def __init__(self, connection=None): - self.connection = connection - - diff --git a/nanpy/arduinocore.py b/nanpy/arduinocore.py deleted file mode 100644 index 464b7b7..0000000 --- a/nanpy/arduinocore.py +++ /dev/null @@ -1,68 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -from nanpy.memo import memoized - - -@check4firmware -class ArduinoCore(FirmwareClass): - - """Access to Arduino functions which are not part of the public API. - AVR only. SAM has different interface. - """ - - cfg_h_name = 'USE_ArduinoCore' - firmware_id = 'Core' - - @memoized - @returns(int) - @arduinomethod - def digitalPinToBitMask(self, pin): - """nonpublic Arduino function.""" - - @memoized - @returns(int) - @arduinomethod - def digitalPinToPort(self, pin): - """nonpublic Arduino function.""" - - @memoized - @returns(int) - @arduinomethod - def digitalPinToTimer(self, pin): - """nonpublic Arduino function.""" - - @memoized - @returns(int) - @arduinomethod - def analogInPinToBit(self, pin): - """nonpublic Arduino function.""" - - @memoized - @returns(int) - @arduinomethod - def portOutputRegister(self, port): - """nonpublic Arduino function. - - @return: address - - """ - - @memoized - @returns(int) - @arduinomethod - def portInputRegister(self, port): - """nonpublic Arduino function. - - @return: address - - """ - - @memoized - @returns(int) - @arduinomethod - def portModeRegister(self, port): - """nonpublic Arduino function. - - @return: address - - """ diff --git a/nanpy/arduinopin.py b/nanpy/arduinopin.py deleted file mode 100644 index 960bf63..0000000 --- a/nanpy/arduinopin.py +++ /dev/null @@ -1,270 +0,0 @@ -from nanpy.memo import memoized -from nanpy.pwm import ArduinoPwmPin -import sys - -LOW, HIGH = 0, 1 -INPUT, OUTPUT = 0, 1 - -# from six -PY3 = sys.version_info[0] == 3 -if PY3: - string_types = str, -else: - string_types = basestring, - - -class PinError(Exception): - pass - - -def to_pin_number(pin_name, A0=None): - try: - if isinstance(pin_name, string_types): - if pin_name[0] == 'D': - nr = int(pin_name[1:]) - if A0 is not None: - if nr >= A0: - raise ValueError('invalid pin id:%r' % pin_name) - elif pin_name[0] == 'A': - if A0 is None: - raise ValueError('A0 is None, but analog pin was set! (%s)' % pin_name) - nr = int(pin_name[1:]) + A0 - else: - nr = int(pin_name) - elif hasattr(pin_name, 'pin_number'): - nr=pin_name.pin_number - else: - nr = int(pin_name) - except IndexError: - raise ValueError('invalid pin id:%r' % pin_name) - return nr - - -class ArduinoPin(object): - - '''Object-oriented representation of an Arduino pin - - Examples: - - # they do the same - a=ArduinoTree() - a.pin.get(0).value - a.pin.get('D0').value - a.pin.get('D0').read_value() - ''' - - def __init__(self, name, total_pin_count, define, register, core, ram, api): - """name can be int or string.""" - self.register = register - self.core = core - self.ram = ram - self.api = api - self.define = define - self.A0 = define.get('A0') - self.pin_number = to_pin_number(name, self.A0) - if self.pin_number >= total_pin_count: - raise ValueError('pin %s (Nr:%s) not in range' % - (name, self.pin_number)) - - @property - @memoized - def pwm(self): - '''Object-oriented representation of the pin PWM functionality - ''' - return ( - ArduinoPwmPin( - self.pin_number, - self.define, - self.register, - self.core, - self.api) - ) - - @property - def is_digital(self): - return self.pin_number < self.A0 - - @property - def is_analog(self): - return not self.is_digital - - @property - def avr_port(self): - '''AVR port name (example: "B") - AVR only. - ''' - x = self.core.digitalPinToPort(self.pin_number) - return chr(ord('A') + x - 1) - - @property - def avr_bit(self): - '''AVR bit name (example: "2") - AVR only. - ''' - bitmask = self.core.digitalPinToBitMask(self.pin_number) - i = 0 - while bitmask != 1: - bitmask >>= 1 - i += 1 - return i - - @property - def avr_pin(self): - '''AVR pin name (example: "PB2") - ''' - return 'P%s%s' % (self.avr_port, self.avr_bit) - - @property - def name(self): - """Arduino pin name. - - D -> digital - A -> analog - (examples: "D2", "A0") - - """ - if self.is_digital: - return 'D%s' % self.pin_number - else: - return 'A%s' % self.pin_number_analog - - @property - def pin_number_analog(self): - x = self.pin_number - self.A0 - if x >= 0: - return x - - @property - def programming_function(self): - """programming function (MISO, MOSI, SCK or SS)""" - if self.pin_number == self.define.get('MISO'): - return 'MISO' - if self.pin_number == self.define.get('MOSI'): - return 'MOSI' - if self.pin_number == self.define.get('SCK'): - return 'SCK' - if self.pin_number == self.define.get('SS'): - return 'SS' - - def reset(self): - '''reset to the pin default state: INPUT, no pullup - ''' - self.write_mode(INPUT) - self.write_pullup(LOW) - if self.pwm.available: - self.pwm.reset() - - def write_pullup(self, value): - """set pullup (0/1)""" - self.write_mode(INPUT) - return self.write_digital_value(value) - - def read_digital_value(self, direction=None): - """read digital value (0/1) - - direction can be set, if 'direction' parameter exists - - """ - if direction is not None: - self.write_mode(direction) - return self.api.digitalRead(self.pin_number) - - def write_digital_value(self, value, direction=None): - """write digital value (0/1) - - direction can be set, if 'direction' parameter exists, and it is - not INPUT - - """ - if direction == INPUT: - raise ValueError('write_digital_value() to INPUT??') - if direction is not None: - self.write_mode(direction) - value = 1 if value else 0 - return self.api.digitalWrite(self.pin_number, value) - - digital_value = property(read_digital_value, write_digital_value) - - def read_analog_value(self): - '''read analog value (0-1023) - ''' - if not self.is_analog: - return None - return self.api.analogRead(self.pin_number) - analog_value = property(read_analog_value) - - def read_mode(self): - """read mode (0/1)""" - bitmask = self.core.digitalPinToBitMask(self.pin_number) - port = self.core.digitalPinToPort(self.pin_number) - reg_address = self.core.portModeRegister(port) - reg_value = self.ram.read(reg_address) - mode = OUTPUT if reg_value & bitmask else INPUT - return mode - - def write_mode(self, value): - """write mode (0/1)""" - return self.api.pinMode(self.pin_number, value) - mode = property(read_mode, write_mode) - - -class PinFeature(object): - - def __init__(self, define, register, core, ram, api): - self.A0 = define.get('A0') - self.define = define - self.register = register - self.core = core - self.ram = ram - self.api = api - - @memoized - def get(self, name): - return ( - ArduinoPin( - name, - self.count, - self.define, - self.register, - self.core, - self.ram, - self.api) - ) - - @property - @memoized - def count_analog(self): - """Count of analog pins.""" - return len(self.names_analog) - - @property - @memoized - def count_digital(self): - """Count of digital pins.""" - return len(self.names_digital) - - @property - @memoized - def count(self): - """Count of all pins. - """ - return self.define.get('NUM_DIGITAL_PINS') - - @property - def names(self): - """List of all pin names.""" - return self.names_digital + self.names_analog - - @property - def names_digital(self): - """List of digital pin names.""" - A0 = self.A0 - return ['D%s' % x for x in range(0, A0)] - - @property - def names_analog(self): - """List of analog pin names.""" - A0 = self.A0 - return ( - ['A%s' % (x - A0) for x in range(A0, self.count)] - ) diff --git a/nanpy/arduinotree.py b/nanpy/arduinotree.py deleted file mode 100644 index 6e89db7..0000000 --- a/nanpy/arduinotree.py +++ /dev/null @@ -1,155 +0,0 @@ -from __future__ import division - -from nanpy.arduinoapi import ArduinoApi -from nanpy.arduinocore import ArduinoCore -from nanpy.arduinopin import PinFeature -from nanpy.classinfo import ClassInfo, FirmwareMissingFeatureError -from nanpy.counter import Counter -from nanpy.define import DefineFeature -from nanpy.eeprom import EEPROM -from nanpy.fwinfo import firmware_info -from nanpy.memo import memoized -from nanpy.ram import RAM -from nanpy.register import RegisterFeature -from nanpy.serialmanager import serial_manager -from nanpy.vcc import Vcc -from nanpy.watchdog import Watchdog -from nanpy.wire import Wire -import time - -from nanpy.esp import Esp - - -class ArduinoTree(object): - - """Object tree model of an Arduino. - - Examples: - - a=ArduinoTree() - a.pin.get(9).read_digital_value() - - """ - - def __init__(self, connection=None): - '' - self.connection = connection - if not connection: - self.connection = serial_manager - if not hasattr(self.connection, 'classinfo'): - self.connection.classinfo = ClassInfo(self.connection) - - @property - @memoized - def api(self): - """Access to Arduino API.""" - return ArduinoApi(self.connection) - - @property - @memoized - def pin(self): - """Object-oriented representation of an Arduino pin""" -# if not self.register: -# return None -# if not self.define: -# return None -# if not self.core: -# return None -# if not self.ram: -# return None - return PinFeature(self.define, self.register, self.core, self.ram, self.api) - - @property - @memoized - def define(self): - """Access to firmware constants.""" - return DefineFeature(self.connection) - - @property - @memoized - def register(self): - """Direct access to AVR registers.""" - try: - return RegisterFeature(self.connection) - except FirmwareMissingFeatureError: - return None - - @property - @memoized - def watchdog(self): - """Direct access to watchdog timer.""" - return Watchdog(self.connection) - - @property - @memoized - def eeprom(self): - """Access to EEPROM.""" - return EEPROM(self.connection) - - @property - @memoized - def ram(self): - """Access to RAM.""" - try: - return RAM(self.connection) - except FirmwareMissingFeatureError: - return None - - @property - @memoized - def counter(self): - """Access to counter.""" - return Counter(self.connection, F_CPU=self.define.get('F_CPU')) - - @property - @memoized - def core(self): - """Access to Arduino functions which are not part of the public API.""" - try: - return ArduinoCore(self.connection) - except FirmwareMissingFeatureError: - return None - - @property - @memoized - def vcc(self): - """Access to VCC.""" - if not self.register: - return None - if not self.define: - return None - return Vcc(self.register, MCU=self.define.get('MCU')) - - def soft_reset(self): - """Resets the AVR, the registers will be reset to their known, default - settings. - - Details: http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset - - """ - self.watchdog.enable(self.watchdog.WDTO_60MS) - time.sleep(0.2) - - # TODO: after restart the first read is not correct (why?) - # This command helps cleaning the read buffer - self.connection.flush_input() - - @property - @memoized - def wire(self): - """Access to Wire.""" - return Wire(self.connection) - - @property - @memoized - def firmware_info(self): - """""" - return firmware_info(self.define.as_dict) - - @property - @memoized - def esp(self): - try: - return Esp(self.connection) - except FirmwareMissingFeatureError: - return None diff --git a/nanpy/bmp180.py b/nanpy/bmp180.py deleted file mode 100755 index f7356fd..0000000 --- a/nanpy/bmp180.py +++ /dev/null @@ -1,117 +0,0 @@ -from __future__ import division - -import logging -from nanpy.i2c import I2C_Master -from nanpy.memo import memoized -import time - - -log = logging.getLogger(__name__) - - -def to_s16(n): - return (n + 2 ** 15) % 2 ** 16 - 2 ** 15 - - -class Bmp180(object): - """Control of BMP180 Digital pressure sensor (I2C) - - calculation is based on Bosch datasheet.""" - - def __init__(self, wire, address=0x77, oss=3): - self.i2c = I2C_Master(wire) - self.address = address - self.oss = oss - - def read_bytes(self, address, count): - self.i2c.send(self.address, [address]) - x = self.i2c.request(self.address, count) - return x - - def write_byte(self, address, data): - self.i2c.send(self.address, [address, data]) - - @property - @memoized - def eeprom(self): - return self.read_bytes(0xaa, 22) - - def read_temperature_raw(self): - self.write_byte(0xf4, 0x2e) - time.sleep(0.005) - - MSB, LSB = self.read_bytes(0xf6, 2) - - UT = (MSB << 8) + LSB - return UT - - def read_pressure_raw(self): - self.write_byte(0xf4, 0x34 + (self.oss << 6)) - time.sleep(0.005) - MSB, LSB, XLSB = self.read_bytes(0xf6, 3) - - UP = ((MSB << 16) + (LSB << 8) + XLSB) >> (8 - self.oss) - return UP - - @classmethod - def calculate(cls, pressure_raw, temperature_raw, oss, eeprom): - ''' - return: Pascal, Celsius - ''' - UT = temperature_raw - UP = pressure_raw - - def ushort(i): - return (eeprom[2 * i] << 8) + eeprom[2 * i + 1] - - def short(i): - return to_s16(ushort(i)) - - AC1 = short(0) - AC2 = short(1) - AC3 = short(2) - AC4 = ushort(3) - AC5 = ushort(4) - AC6 = ushort(5) - B1 = short(6) - B2 = short(7) -# MB = short(8) - MC = short(9) - MD = short(10) - - X1 = ((UT - AC6) * AC5) >> 15 - X2 = (MC << 11) // (X1 + MD) - B5 = X1 + X2 - T = (B5 + 8) >> 4 - - B6 = B5 - 4000 - X1 = (B2 * ((B6 * B6) >> 12)) >> 11 - X2 = (AC2 * B6) >> 11 - X3 = X1 + X2 - B3 = (((AC1 * 4 + X3) << oss) + 2) // 4 - X1 = (AC3 * B6) >> 13 - X2 = (B1 * ((B6 * B6) >> 12)) >> 16 - X3 = ((X1 + X2) + 2) // 4 - B4 = (AC4 * (X3 + 32768)) >> 15 - B7 = (UP - B3) * (50000 >> oss) - p = (B7 * 2) // B4 if B7 < 0x80000000 else (B7 // B4) * 2 - X1 = (p >> 8) * (p >> 8) - X1 = (X1 * 3038) >> 16 - X2 = (-7357 * p) >> 16 - p += (X1 + X2 + 3791) >> 4 - - return p, T / 10 - - def read(self): - ''' - return: Pascal, Celsius - ''' - temperature_raw = self.read_temperature_raw() - pressure_raw = self.read_pressure_raw() - - return self.calculate( - pressure_raw, - temperature_raw, - self.oss, - self.eeprom, - ) diff --git a/nanpy/capacitivesensor.py b/nanpy/capacitivesensor.py deleted file mode 100644 index 713e2de..0000000 --- a/nanpy/capacitivesensor.py +++ /dev/null @@ -1,20 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class CapacitiveSensor(ArduinoObject): - cfg_h_name = 'USE_CapacitiveSensor' - - def __init__(self, pin1, pin2, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pin1, pin2) - - @returns(int) - @arduinoobjectmethod - def capacitiveSensor(self, samples): - pass - - @returns(int) - @arduinoobjectmethod - def capacitiveSensorRaw(self, samples): - pass - diff --git a/nanpy/classinfo.py b/nanpy/classinfo.py deleted file mode 100644 index 1b0b774..0000000 --- a/nanpy/classinfo.py +++ /dev/null @@ -1,78 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.memo import memoized - - -class FirmwareMissingFeatureError(Exception): - pass - - -def check4firmware(cls): - if not hasattr(check4firmware, 'names'): - check4firmware.names = dict() - cls_name = cls.get_firmware_id() - assert cls_name not in check4firmware.names.keys() - check4firmware.names[cls_name] = cls - - def getinstance(connection): - if cls_name == 'Info': - return cls(connection) - - if connection is not None: - if not hasattr(connection, 'classinfo'): - connection.classinfo = ClassInfo(connection) - if cls_name not in connection.classinfo.firmware_id_list: - raise FirmwareMissingFeatureError( - '''%s ['%s'] is missing from firmware! -Please enable it in your cfg.h: -#define %s 1 - ''' % - (cls, cls_name, cls.cfg_h_name)) - return cls(connection) -# getinstance.__name__ = cls.__name__ - return getinstance - - -@check4firmware -class ClassInfoArray(FirmwareClass): - cfg_h_name = 'USE_Info' - firmware_id = 'Info' - - @property - @memoized - @returns(int) - @arduinomethod - def count(self): - pass - - @memoized - @arduinomethod - def name(self, index): - pass - - -class ClassInfo(object): - - """Which classes are compiled into the firmware?""" - - def __init__(self, connection): - self.firmware_class_status = dict() - self.unknown_firmware_ids = [] - self.firmware_name_list = [] - - self._arr = ClassInfoArray(connection=connection) - - ls = [self._arr.name(i) for i in range(self._arr.count)] - assert len(ls) - self.firmware_id_list = sorted(ls) - - for cls in check4firmware.names.values(): - self.firmware_class_status[cls.__name__] = False - - for x in self.firmware_id_list: - cls = check4firmware.names.get(x) - if cls: - self.firmware_name_list.append(str(cls.__name__)) - self.firmware_class_status[cls.__name__] = True - else: - self.firmware_name_list.append(str(x)) - self.unknown_firmware_ids.append(x) diff --git a/nanpy/colorsensor.py b/nanpy/colorsensor.py deleted file mode 100644 index f5a0762..0000000 --- a/nanpy/colorsensor.py +++ /dev/null @@ -1,14 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class ColorSensor(ArduinoObject): - cfg_h_name = 'USE_ColorSensor' - - def __init__(self, s0, s1, s2, s3, sensorInput, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', s0, s1, s2, s3, sensorInput) - - @returns(int) - @arduinoobjectmethod - def get_color(self, color): - pass diff --git a/nanpy/counter.py b/nanpy/counter.py deleted file mode 100644 index 3352867..0000000 --- a/nanpy/counter.py +++ /dev/null @@ -1,85 +0,0 @@ -from __future__ import division -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -import time - - -@check4firmware -class CounterLib(FirmwareClass): - cfg_h_name = 'USE_Counter' - firmware_id = 'Counter' - - @arduinomethod - def begin(self, gate_time_ms): - pass - - @arduinomethod - def end(self): - pass - - @returns(bool) - @arduinomethod - def available(self): - pass - - @returns(int) - @arduinomethod - def read(self): - pass - - -class Counter(object): - - """Access to counter. - - Examples: - - Counter.read() - - original lib: http://www.pjrc.com/teensy/td_libs_FreqCount.html - - """ - def __init__(self, connection=None, F_CPU=None): - self.connection = connection - self.lib = CounterLib(connection) - self.multiplier = 1 - if F_CPU: - self.multiplier = self.calculate_multiplier(F_CPU) - - @classmethod - def calculate_multiplier(cls, F_CPU): - multiplier = 1 - # calculate multiplier for non supported frequencies - if F_CPU >= 16000000: - multiplier = F_CPU / 16000000 - elif F_CPU >= 8000000: - multiplier = F_CPU / 8000000 - elif F_CPU >= 4000000: - multiplier = F_CPU / 4000000 - elif F_CPU >= 2000000: - multiplier = F_CPU / 2000000 - elif F_CPU >= 1000000: - multiplier = F_CPU / 1000000 - else: - multiplier = 1000000 / F_CPU - return multiplier - - def read(self, gate_time=1): - """read pulse count under ``gate_time`` seconds.""" - gate_time_ms = int(1000 * gate_time) - self.lib.begin(gate_time_ms) - try: - time.sleep(gate_time * 1.1) - n = self.lib.read() - finally: - self.lib.end() - return n * self.multiplier - - def read_frequency(self, gate_time=1): - """read frequency in hertz using ``gate_time`` in seconds.""" - return self.read(gate_time) / gate_time - - def error(self, gate_time=1): - """frequency measurement error in hertz using ``gate_time`` in - seconds.""" - return self.multiplier / gate_time diff --git a/nanpy/dallastemperature.py b/nanpy/dallastemperature.py deleted file mode 100644 index 080e156..0000000 --- a/nanpy/dallastemperature.py +++ /dev/null @@ -1,55 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class DallasTemperature(ArduinoObject): - cfg_h_name = 'USE_DallasTemperature' - - def __init__(self, pin, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.pin = pin - self.id = self.call('new', pin) - - @arduinoobjectmethod - def setResolution(self, bits): - pass - - @returns(int) - @arduinoobjectmethod - def getResolution(self, bits): - pass - - @returns(int) - @arduinoobjectmethod - def getDeviceCount(self): - pass - - @arduinoobjectmethod - def getAddress(self, index): - val = self.call('getAddress') - if val == "1": - return val - return val.split(' ') - - - @arduinoobjectmethod - def requestTemperatures(self, address_or_index = None): - pass - - @returns(float) - @arduinoobjectmethod - def getTempC(self, address_or_index): - pass - - @returns(float) - @arduinoobjectmethod - def getTempF(self, address_or_index): - pass - - @classmethod - def toCelsius(cls, value): - return (value - 32) * 5/9 - - @classmethod - def toFahrenheit(cls, value): - return (value * 9/5) + 32 - diff --git a/nanpy/define.py b/nanpy/define.py deleted file mode 100644 index f4c1bed..0000000 --- a/nanpy/define.py +++ /dev/null @@ -1,87 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -from nanpy.memo import memoized - - -def auto_convert(x): - try: - return int(x) - except ValueError: - return x - - -@check4firmware -class DefineArray(FirmwareClass): - cfg_h_name = 'USE_Define' - firmware_id = 'D' - - @property - @memoized - @returns(int) - @arduinomethod('c') - def count(self): - pass - - @memoized - @arduinomethod('n') - def name(self, index): - pass - - @memoized - @returns(auto_convert) - @arduinomethod('v') - def value(self, index): - pass - - -class DefineFeature(object): - - """Access to firmware constants. - - Examples: - - a=ArduinoTree() - a.define.get('F_CPU') # AVR frequency - a.define.get('__DATE__') # firmware upload date - - """ - - def __init__(self, connection=None): - self._arr = DefineArray(connection) - - @property - @memoized - def as_dict(self): - """return all constants and their values in a dictionary.""" - d = dict() - for i in range(self._arr.count): - d[self._arr.name(i)] = self._arr.value(i) - assert len(d) - return d - - @property - def names(self): - return sorted(self.as_dict.keys()) - - @property - @memoized - def count(self): - return len(self.as_dict) - - def get(self, name, defaultValue=None): - """get a constant. - - Examples: - - a=ArduinoTree() - a.define.get('F_CPU') # AVR frequency - - """ - count = self._arr.count - assert count - for i in range(count): - n = self._arr.name(i) - if n == name: - return self._arr.value(i) - return defaultValue -# raise ValueError('%s was not found!' % name) diff --git a/nanpy/dht.py b/nanpy/dht.py deleted file mode 100644 index 17cd5cb..0000000 --- a/nanpy/dht.py +++ /dev/null @@ -1,29 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class DHT(ArduinoObject): - cfg_h_name = 'USE_DHT' - - DHT11 = 11 - DHT22 = 22 - DHT21 = 21 - AM2301 = 21 - - def __init__(self, pin, _type, count=6, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pin, _type, count) - - @returns(int) - @arduinoobjectmethod - def begin(self): - pass - - @returns(float) - @arduinoobjectmethod - def readHumidity(self): - pass - - @returns(float) - @arduinoobjectmethod - def readTemperature(self, value=False): - pass diff --git a/nanpy/eeprom.py b/nanpy/eeprom.py deleted file mode 100644 index 902dbbb..0000000 --- a/nanpy/eeprom.py +++ /dev/null @@ -1,25 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -from nanpy.memo import memoized - - -@check4firmware -class EEPROM(FirmwareClass): - cfg_h_name = 'USE_EEPROM' - firmware_id = 'EEPROM' - - @arduinomethod - def write(self, address, value): - pass - - @returns(int) - @arduinomethod - def read(self, address): - pass - - @property - @memoized - @returns(int) - @arduinomethod - def size(self): - pass diff --git a/nanpy/esp.py b/nanpy/esp.py deleted file mode 100644 index 7dd6df4..0000000 --- a/nanpy/esp.py +++ /dev/null @@ -1,109 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -from nanpy.memo import memoized - - -@check4firmware -class Esp(FirmwareClass): - firmware_id = 'Esp' - - @arduinomethod - def wdtEnable(self): - pass - - @arduinomethod - def wdtDisable(self): - pass - - @arduinomethod - def wdtFeed(self): - pass - - @arduinomethod - def reset(self): - pass - - @arduinomethod - def restart(self): - pass - - @returns(int) - @arduinomethod - def getVcc(self): - pass - - @arduinomethod - def getFreeHeap(self): - pass - - @arduinomethod - def getChipId(self): - pass - - @arduinomethod - def getSdkVersion(self): - pass - - @arduinomethod - def getBootVersion(self): - pass - - @arduinomethod - def getBootMode(self): - pass - - @arduinomethod - def getCpuFreqMHz(self): - pass - - @arduinomethod - def getFlashChipId(self): - pass - - @arduinomethod - def getFlashChipRealSize(self): - pass - - @arduinomethod - def getFlashChipSize(self): - pass - - @arduinomethod - def getFlashChipSpeed(self): - pass - - @arduinomethod - def getFlashChipMode(self): - pass - - @arduinomethod - def getFlashChipSizeByChipId(self): - pass - - @arduinomethod - def getResetReason(self): - pass - - @arduinomethod - def getResetInfo(self): - pass - - @arduinomethod - def getSketchSize(self): - pass - - @arduinomethod - def getFreeSketchSpace(self): - pass - - @arduinomethod - def flashEraseSector(self): - pass - - @arduinomethod - def flashWrite(self): - pass - - @arduinomethod - def flashRead(self): - pass diff --git a/nanpy/examples/PCF8574.py b/nanpy/examples/PCF8574.py deleted file mode 100644 index d59d1fc..0000000 --- a/nanpy/examples/PCF8574.py +++ /dev/null @@ -1,50 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager -from nanpy.PCF8574 import PCF8574 - - -I2C_ADDRESS = 0x27 - - -def main(): - print ('PCF8574 demo') - print ('address: 0x%X' % I2C_ADDRESS) - connection = SerialManager(sleep_after_connect=2) - connection.open() - a = ArduinoTree(connection=connection) - pcf = PCF8574(a.wire, I2C_ADDRESS) - - def write(d): - print ('write: %s' % bin(d)) - pcf.write8(d) - - def read(): - d = pcf.read8() - print ('read: %s' % bin(d)) - - read() - - d = pcf.readPin(0) - print ('read pin 0: %s' % d) - print ('write pin 0: %s' % 1) - pcf.writePin(0, 1) - d = pcf.readPin(0) - print ('read pin 0: %s' % d) - - read() - - write(0b11111111) - read() - - write(0b10101010) - read() - - write(0b01010101) - read() - - write(0b00000000) - read() - - -if __name__ == '__main__': - main() diff --git a/nanpy/examples/__init__.py b/nanpy/examples/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/nanpy/examples/blink.py b/nanpy/examples/blink.py deleted file mode 100755 index 17bf75b..0000000 --- a/nanpy/examples/blink.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: keeps your led blinking -# Dependencies: None - -from nanpy import (ArduinoApi, SerialManager) -from time import sleep - -connection = SerialManager() -a = ArduinoApi(connection=connection) - -a.pinMode(13, a.OUTPUT) - -for i in range(10000): - a.digitalWrite(13, (i + 1) % 2) - sleep(0.2) - diff --git a/nanpy/examples/blink_2boards.py b/nanpy/examples/blink_2boards.py deleted file mode 100644 index 3c8855e..0000000 --- a/nanpy/examples/blink_2boards.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: keeps your led blinking on 2 boards -# Dependencies: None - -from nanpy import (ArduinoApi, SerialManager) -from time import sleep - - -device_1 = '/dev/tty.usbmodem1411' -device_2 = '/dev/tty.usbmodem1431' - -connection_1 = SerialManager(device=device_1) -connection_2 = SerialManager(device=device_2) - -a1 = ArduinoApi(connection=connection_1) -a1.pinMode(13, a1.OUTPUT) - -a2 = ArduinoApi(connection=connection_2) -a2.pinMode(13, a2.OUTPUT) - -for i in range(10000): - a1.digitalWrite(13, (i + 1) % 2) - sleep(1) - a2.digitalWrite(13, (i + 1) % 2) - sleep(1) - diff --git a/nanpy/examples/blink_esp8266.py b/nanpy/examples/blink_esp8266.py deleted file mode 100755 index 76eae01..0000000 --- a/nanpy/examples/blink_esp8266.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python - -from nanpy import ArduinoApi -from time import sleep -from nanpy.sockconnection import SocketManager -# import logging -# logging.basicConfig(level=logging.DEBUG) - -PIN=2 - -connection = SocketManager() -a = ArduinoApi(connection=connection) - -a.pinMode(PIN, a.OUTPUT) - -for i in range(10000): - a.digitalWrite(PIN, (i + 1) % 2) - sleep(0.2) - diff --git a/nanpy/examples/boottime.py b/nanpy/examples/boottime.py deleted file mode 100644 index b838798..0000000 --- a/nanpy/examples/boottime.py +++ /dev/null @@ -1,17 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager -import time - - -def boot_time(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - a.watchdog.enable(a.watchdog.WDTO_500MS) - time.sleep(1) - a.connection.flush_input() - x = a.api.millis() - return 1000 - 500 - x - - -if __name__ == '__main__': - print ('boot_time %s ms' % boot_time()) diff --git a/nanpy/examples/checkspeed.py b/nanpy/examples/checkspeed.py deleted file mode 100644 index 539246b..0000000 --- a/nanpy/examples/checkspeed.py +++ /dev/null @@ -1,68 +0,0 @@ -from nanpy.ad9850 import AD9850 -from nanpy.arduinotree import ArduinoTree -import time -from nanpy.serialmanager import SerialManager - - -def measure(a, n, f, root='a'): - start = time.time() - for _ in range(n): - cmd = root + '.' + f - try: - locals()[root] = a - exec (cmd) - except: - print (cmd) - raise - dt = time.time() - start - print ( - '%-35s %8.2f ms per call, %5.0f call per second' % - (f, 1000.0 * dt / n, 1.0 / dt * n)) - - -def checkspeed(n): - connection = SerialManager() - connection.open() - a = ArduinoTree(connection=connection) - - print ('performance test for ArduinoTree()') - print ('n=%s' % n) - print('') - - measure(a, n, 'api.digitalRead(0)') - measure(a, n, 'api.digitalWrite(0,0)') - measure(a, n, 'api.analogRead(0)') - measure(a, n, 'api.analogWrite(0,0)') - measure(a, n, 'api.pinMode(0,0)') - measure(a, n, 'api.millis()') - measure(a, n, 'api.shiftOut(0, 1, 0, 15)') - - a.define.get('__TIME__') # init cache - measure(a, n, 'define.get("__TIME__")') - - a.register.get('DDRB') # init cache - measure(a, n, 'register.get("DDRB").read_value()') - measure(a, n, 'register.get("DDRB").address') - measure(a, n, 'register.get("DDRB").size') - - a.vcc.read() # init cache - measure(a, n, 'vcc.read()') - - measure(a, n, 'pin.get(0).read_digital_value()') - measure(a, n, 'pin.get(0).read_mode()') - - a.eeprom.size # init cache - measure(a, n, 'eeprom.size') - measure(a, n, 'eeprom.read(0)') - - print('') - print ('performance test for AD9850()') - print('') - - ad9850 = AD9850([0, 1, 2, 3]) - measure(ad9850, n, 'setup()', root='ad9850') - measure(ad9850, n, 'write_frequency(400)', root='ad9850') - - -if __name__ == '__main__': - checkspeed(n=100) diff --git a/nanpy/examples/clock.py b/nanpy/examples/clock.py deleted file mode 100755 index 7ee71ba..0000000 --- a/nanpy/examples/clock.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: get the current time from a ntp server and show it on a lcd -# Dependencies: ntplib (http://pypi.python.org/pypi/ntplib/) - -import ntplib -from nanpy import (SerialManager, Lcd) -from datetime import datetime -from time import sleep - -connection = SerialManager() - -ntp_client = ntplib.NTPClient() -response = ntp_client.request('europe.pool.ntp.org', version=3) - -time = int(response.tx_time) - -pins = [7, 8, 9, 10, 11, 12] -cols, rows = 16, 2 -lcd = Lcd(pins, [cols, rows], connection=connection) - -while (1): - lcd.setCursor(0, 0) - lcd.printString((datetime.fromtimestamp(time)).strftime('%Y-%m-%d')) - if time % 2: - time_format = '%H:%M' - else: - time_format = '%H %M' - lcd.setCursor(0, 1) - lcd.printString((datetime.fromtimestamp(time)).strftime(time_format)) - sleep(1) - time += 1 diff --git a/nanpy/examples/counterdemo.py b/nanpy/examples/counterdemo.py deleted file mode 100644 index dfafcd4..0000000 --- a/nanpy/examples/counterdemo.py +++ /dev/null @@ -1,39 +0,0 @@ -"""This demo sets a PWM frequency on pin 5, then measures it using a counter. - -For measuring external frequency the PWM should be disabled. - -""" - -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager -import time - - -EXTERNAL_FREQUENCY = False -GATE_TIME = 0.7 # sec - -INPUT, OUTPUT = 0, 1 - - -def counterdemo(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - p = a.pin.get(5) - - if not EXTERNAL_FREQUENCY: - p.write_mode(OUTPUT) - p.pwm.write_value(128) - p.pwm.frequency = p.pwm.frequencies_available[-2] - print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) - print ('frequency set: %s' % p.pwm.frequency) - - t1 = time.time() - fread = a.counter.read_frequency(GATE_TIME) - t2 = time.time() - - print ('frequency read: %s' % fread) - print ('gate time: %s sec' % (GATE_TIME)) - print ('time elapsed: %s sec' % (t2 - t1)) - -if __name__ == '__main__': - counterdemo() diff --git a/nanpy/examples/dallastemperature.py b/nanpy/examples/dallastemperature.py deleted file mode 100755 index eeac564..0000000 --- a/nanpy/examples/dallastemperature.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: just a test for DallasTemperature -# Dependencies: None - -from nanpy import DallasTemperature - -sensors = DallasTemperature(5) -n_sensors = sensors.getDeviceCount() - -print("There are %d devices connected on pin %d" % (n_sensors, sensors.pin)) -addresses = [] - -for i in range(n_sensors): - addresses.append(sensors.getAddress(i)) - -sensors.setResolution(12) - -while True: - sensors.requestTemperatures() - for i in range(n_sensors): - temp = sensors.getTempC(i) - print("Device %d (%s) temperature, in Celsius degrees is %0.2f" % (i, addresses[i], temp)) - print("Let's convert it in Fahrenheit degrees: %0.2f" % DallasTemperature.toFahrenheit(temp)) - print("\n") diff --git a/nanpy/examples/dds.py b/nanpy/examples/dds.py deleted file mode 100644 index 6e72c7c..0000000 --- a/nanpy/examples/dds.py +++ /dev/null @@ -1,22 +0,0 @@ -from nanpy.ad9850 import AD9850 -from nanpy.serialmanager import SerialManager - -# http://nr8o.dhlpilotcentral.com/?p=83 -W_CLK = 'A5' # Pin 8 - connect to AD9850 module word load clock pin (CLK) -FQ_UD = 'A4' # Pin 9 - connect to freq update pin (FQ) -DATA = 'A3' # Pin 10 - connect to serial data load pin (DATA) -RESET = 'A2' # Pin 11 - connect to reset pin (RST). - -F = 440 # Hz - - -def dds(): - connection = SerialManager() - dds = AD9850([W_CLK, FQ_UD, DATA, RESET], connection=connection) - - dds.setup() - dds.write_frequency(F) - - -if __name__ == '__main__': - dds() diff --git a/nanpy/examples/dht.py b/nanpy/examples/dht.py deleted file mode 100755 index 411b27f..0000000 --- a/nanpy/examples/dht.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -# a simple example to read from a DHT sensor - -from nanpy import DHT - -# http://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor -# DHT sensor connected to digital pin 10 -dht = DHT(10, DHT.DHT22) - -print("Temperature is %.2f degrees Celcius" % dht.readTemperature(False)) -print("Temperature is %.2f degrees Fahrenheit" % dht.readTemperature(True)) -print("Humidity is %.2f %%" % dht.readHumidity()) - diff --git a/nanpy/examples/digipot.py b/nanpy/examples/digipot.py deleted file mode 100644 index cbe27cf..0000000 --- a/nanpy/examples/digipot.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# DigiPot.pde - Example sketch for Arduino library for managing digital potentiometers X9C1xxx (xxx = 102,103,104,503). -# By Timo Fager, Jul 29, 2011. -# Released to public domain. -# -# For this example, connect your X9C103P (or the like) as follows: -# 1 - INC - Arduino pin 2 -# 2 - U/D - Arduino pin 3 -# 3 - VH - 5V -# 4 - VSS - GND -# 5 - VW - Output: A0 and 150 Ohm resistor -> LED -> GND -# 6 - VL - GND -# 7 - CS - Arduino pin 4 -# 8 - VCC - 5V -# - -from nanpy import SerialManager -from nanpy.arduinotree import ArduinoTree -from time import sleep - -from nanpy.DigiPotX9Cxxx import DigiPot - - -connection = SerialManager() -a = ArduinoTree(connection=connection) -incPin = a.pin.get(2) -udPin = a.pin.get(3) -csPin = a.pin.get(4) - -anPin = a.pin.get('A0') - -pot = DigiPot(incPin, udPin, csPin) - -for i in range(100) + list(reversed(range(100))): - pot.set(i) - an = anPin.read_analog_value() - print('set pot to %s, read analog: %s' % (i, an)) - sleep(0.1) - - diff --git a/nanpy/examples/dump.py b/nanpy/examples/dump.py deleted file mode 100644 index d4a833e..0000000 --- a/nanpy/examples/dump.py +++ /dev/null @@ -1,121 +0,0 @@ -"""Dump all possible values from the AVR.""" - -import inspect -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager -from pprint import pprint -from nanpy.classinfo import FirmwareMissingFeatureError -# import logging -# logging.basicConfig(level=logging.DEBUG) - -FORMAT = '%-20s = %20s' - - -def dump(obj, selected_names=None): - if selected_names: - ls = selected_names - else: - ls = dir(obj) - for attr in ls: - if not attr.startswith('__'): - if not inspect.ismethod(getattr(obj, attr)): - print(FORMAT % (attr, getattr(obj, attr))) - - -def dump_dict(d): - for defname in sorted(d.keys()): - defvalue = d[defname] - print(FORMAT % (defname, defvalue)) - -def myprint(template, name, func): - try: - print(template % (name, func())) - except FirmwareMissingFeatureError: - pass - -def dumpall(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - - if a.vcc: - myprint(FORMAT + ' V', 'read_vcc', lambda : a.vcc.read()) - myprint(FORMAT + ' sec', 'uptime', lambda : a.api.millis() / 1000.0) - - print('') - print('================================') - print('firmware classes:') - print('================================') - pprint(a.connection.classinfo.firmware_name_list) - - print('') - print('================================') - print('defines:') - print('================================') - dump_dict(a.define.as_dict) - - if a.esp: - print('') - print('================================') - print('ESP:') - print('================================') - myprint(FORMAT , 'getVcc', lambda :a.esp.getVcc()) - myprint(FORMAT , 'getFreeHeap', lambda :a.esp.getFreeHeap()) - myprint(FORMAT , 'getChipId', lambda :a.esp.getChipId()) - myprint(FORMAT , 'getSdkVersion', lambda :a.esp.getSdkVersion()) - myprint(FORMAT , 'getBootVersion', lambda :a.esp.getBootVersion()) - myprint(FORMAT , 'getBootMode', lambda :a.esp.getBootMode()) - myprint(FORMAT , 'getCpuFreqMHz', lambda :a.esp.getCpuFreqMHz()) - myprint(FORMAT , 'getFlashChipId', lambda :a.esp.getFlashChipId()) - myprint(FORMAT , 'getFlashChipRealSize', lambda :a.esp.getFlashChipRealSize()) - myprint(FORMAT , 'getFlashChipSize', lambda :a.esp.getFlashChipSize()) - myprint(FORMAT , 'getFlashChipSpeed', lambda :a.esp.getFlashChipSpeed()) - myprint(FORMAT , 'getFlashChipMode', lambda :a.esp.getFlashChipMode()) - myprint(FORMAT , 'getFlashChipSizeByChipId', lambda :a.esp.getFlashChipSizeByChipId()) - myprint(FORMAT , 'getResetReason', lambda :a.esp.getResetReason()) - myprint(FORMAT , 'getResetInfo', lambda :a.esp.getResetInfo()) - myprint(FORMAT , 'getSketchSize', lambda :a.esp.getSketchSize()) - myprint(FORMAT , 'getFreeSketchSpace', lambda :a.esp.getFreeSketchSpace()) - - print('') - print('================================') - print('pins:') - print('================================') - - myprint(FORMAT , 'total_pin_count', lambda :a.pin.count) - myprint(FORMAT , 'digital_names', lambda :a.pin.names_digital) - myprint(FORMAT , 'analog_names', lambda :a.pin.names_analog) - - for pin_number in range(a.pin.count): - print('---------- pin_number=%s ---------------' % pin_number) - pin = a.pin.get(pin_number) - dump( - pin, - 'name pin_number pin_number_analog is_digital is_analog avr_pin mode digital_value analog_value programming_function'.split()) - if pin.pwm.available: - print('--- pwm ---') - dump(pin.pwm, '''frequency frequencies_available base_divisor divisor divisors_available - timer_mode - timer_register_name_a - timer_register_name_b - wgm - '''.split()) - - - if a.register: - print('') - print('================================') - print('registers:') - print('================================') - for x in a.register.names: - r = a.register.get(x) - if r.size == 2: - v = '0x%04X' % (r.value) - else: - v = ' 0x%02X' % (r.value) - - print('%-20s = %s @0x%2X (size:%s)' % (r.name, v, r.address, r.size)) - - - -if __name__ == '__main__': - dumpall() diff --git a/nanpy/examples/eepromread.py b/nanpy/examples/eepromread.py deleted file mode 100755 index 85dc3a8..0000000 --- a/nanpy/examples/eepromread.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# Author: Kevin Ng -# Description: read from EEPROM -# Dependencies: None - -from nanpy import (EEPROM, SerialManager) -import sys - -connection = SerialManager() -e = EEPROM(connection=connection) - - -def display(a_list): - for i in range(0, e.size // 16 - 1): - for j in range(16): - sys.stdout.write("%02x:" % a_list[j + i * 16]) - print - - -def read_eeprom(): - data_list = [] - for i in range(0, e.size): - s = e.read(i) - data_list.append(s) - return data_list - - -if __name__ == "__main__": - print("Reading eeprom (%s bytes)..." % e.size) - display(read_eeprom()) diff --git a/nanpy/examples/firmware_check.py b/nanpy/examples/firmware_check.py deleted file mode 100644 index a7f7e2f..0000000 --- a/nanpy/examples/firmware_check.py +++ /dev/null @@ -1,19 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager - - -def fw_check(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - - print('Firmware classes enabled in cfg.h:') - print(' ' + '\n '.join(a.connection.classinfo.firmware_name_list)) - - d = a.define.as_dict - print( - '\nYour firmware was built on:\n %s %s' % - (d.get('__DATE__'), d.get('__TIME__'))) - - -if __name__ == '__main__': - fw_check() diff --git a/nanpy/examples/highfreqpwm.py b/nanpy/examples/highfreqpwm.py deleted file mode 100644 index e3a5234..0000000 --- a/nanpy/examples/highfreqpwm.py +++ /dev/null @@ -1,22 +0,0 @@ -"""High frequency PWM mode demo.""" - -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager - -FREQ = 10007 - - -def highfreqpwm(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - pin9 = a.pin.get(9) - pin9.mode = 1 - pin9.write_digital_value(1) - pwm = pin9.pwm - print ('set frequency=%s Hz' % FREQ) - pwm.set_high_freq_around(FREQ) - print ('real frequency=%s Hz' % pwm.read_frequency()) - - -if __name__ == '__main__': - highfreqpwm() diff --git a/nanpy/examples/i2c_scanner.py b/nanpy/examples/i2c_scanner.py deleted file mode 100755 index 3d2f236..0000000 --- a/nanpy/examples/i2c_scanner.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python - -# Description: - -from nanpy.arduinotree import ArduinoTree -from nanpy.i2c import I2C_Master -from nanpy.serialmanager import SerialManager -import logging -log = logging.getLogger(__name__) - - -def main(): - connection = SerialManager(sleep_after_connect=2) - connection.open() - print (connection.device) - a = ArduinoTree(connection=connection) - master = I2C_Master(a.wire) - print (['0x%02x' % x for x in master.scan()]) - - -if __name__ == '__main__': - main() diff --git a/nanpy/examples/i2c_send.py b/nanpy/examples/i2c_send.py deleted file mode 100755 index e17cb82..0000000 --- a/nanpy/examples/i2c_send.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -# Description: sending a byte to PCF8574 - -from nanpy.arduinotree import ArduinoTree -from nanpy.i2c import I2C_Master -from nanpy.serialmanager import SerialManager -import logging -log = logging.getLogger(__name__) - -I2C_ADDRESS = 0x27 - -def main(): - connection = SerialManager(sleep_after_connect=2) - connection.open() - print (connection.device) - a = ArduinoTree(connection=connection) - master = I2C_Master(a.wire) - master.send(I2C_ADDRESS, [0b00001000]) - - -if __name__ == '__main__': - main() diff --git a/nanpy/examples/lcd_autoscroll.py b/nanpy/examples/lcd_autoscroll.py deleted file mode 100644 index f24fa6e..0000000 --- a/nanpy/examples/lcd_autoscroll.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python - -import time - -from nanpy import SerialManager -from nanpy.lcd import Lcd - - -if __name__ == '__main__': - - connection = SerialManager(sleep_after_connect=2) - - cols, rows = 16, 2 - - pins = [7, 8, 9, 10, 11, 12] - lcd = Lcd(pins, [cols, rows], connection=connection) - - while True: - - lcd.setCursor(0, 0); - - for char in range(10): - lcd.printString(char) - time.sleep(0.5) - - lcd.setCursor(16, 1) - lcd.autoscroll() - - for char in range(10): - lcd.printString(char) - time.sleep(0.5) - - lcd.noAutoscroll() - lcd.clear() \ No newline at end of file diff --git a/nanpy/examples/lcd_createchar.py b/nanpy/examples/lcd_createchar.py deleted file mode 100644 index 81bd4ff..0000000 --- a/nanpy/examples/lcd_createchar.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python - -from nanpy.lcd import Lcd - - -if __name__ == '__main__': - - pins = [7, 8, 9, 10, 11, 12] - cols, rows = 16, 2 - lcd = Lcd(pins, [cols, rows]) - - smiley = [ - 0b00000, - 0b10001, - 0b00000, - 0b00000, - 0b10001, - 0b01110, - 0b00000, - 0b00000 - ] - - lcd.createChar(0,smiley) - lcd.setCursor(0,0) - lcd.write(0) diff --git a/nanpy/examples/lcd_hello.py b/nanpy/examples/lcd_hello.py deleted file mode 100755 index 9ab2982..0000000 --- a/nanpy/examples/lcd_hello.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python - -from nanpy import SerialManager -from nanpy.lcd import Lcd -from nanpy.lcd_i2c import Lcd_I2C - -I2C = True - - -def hello(): - connection = SerialManager(sleep_after_connect=2) - - cols, rows = 16, 2 - - if I2C: - pins = [0x27, 2, 1, 0, 4, 5, 6, 7, 3, 0] # "ebay" version - lcd = Lcd_I2C(pins, [cols, rows], connection=connection) - lcd.setBacklight(0) - else: - pins = [7, 8, 9, 10, 11, 12] - lcd = Lcd(pins, [cols, rows], connection=connection) - - lcd.setCursor(0, 0) - lcd.printString('hello') - -if __name__ == '__main__': - hello() diff --git a/nanpy/examples/melody.py b/nanpy/examples/melody.py deleted file mode 100755 index cc2a6df..0000000 --- a/nanpy/examples/melody.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: play a melody -# Dependencies: None - -from nanpy import Tone - -melody = [[Tone.NOTE_C4, 4], [Tone.NOTE_G3, 8], [Tone.NOTE_G3, 8], - [Tone.NOTE_A3, 4], [Tone.NOTE_G3, 4], [0, 4], - [Tone.NOTE_B3, 4], [Tone.NOTE_C4, 4]] - -tone = Tone(4) - -for note in melody: - tone.play(note[0] , 1000/note[1]) - diff --git a/nanpy/examples/power.py b/nanpy/examples/power.py deleted file mode 100755 index 9920e78..0000000 --- a/nanpy/examples/power.py +++ /dev/null @@ -1,15 +0,0 @@ -"""power read demo.""" - -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager - - -def power_demo(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - Vcc = a.vcc.read() - msg = 'Power supply= %0.2f V' % Vcc - print(msg) - -if __name__ == '__main__': - power_demo() diff --git a/nanpy/examples/pressure.py b/nanpy/examples/pressure.py deleted file mode 100755 index d710b20..0000000 --- a/nanpy/examples/pressure.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Pressure sensor demo. - -Connect the BMP180 to the I2C bus. - -""" -from __future__ import division - -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager - -from nanpy.bmp180 import Bmp180 - - -def main(): - connection = SerialManager(sleep_after_connect=2) - connection.open() - a = ArduinoTree(connection=connection) - bmp = Bmp180(a.wire) - p, t = bmp.read() - print ('pressure: %s kPa' % (p / 1000)) - print ('temperature: %s C' % t) - -if __name__ == '__main__': - main() diff --git a/nanpy/examples/pwm_demo.py b/nanpy/examples/pwm_demo.py deleted file mode 100644 index 020dddf..0000000 --- a/nanpy/examples/pwm_demo.py +++ /dev/null @@ -1,29 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager - -PIN = 5 - -# 0-255 -VALUE = 128 -DUTY_CYCLE = VALUE / 256.0 - -INPUT, OUTPUT = 0, 1 - - -def pwm_demo(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - p = a.pin.get(PIN) - print ('PWM frequencies_available: %s' % p.pwm.frequencies_available) - p.write_mode(OUTPUT) - p.pwm.write_value(VALUE) - - # set frequency here - p.pwm.frequency = 61 - - print ('PWM frequency: %s' % p.pwm.frequency) - print ('PWM duty cycle: %s %% ' % (DUTY_CYCLE * 100)) - - -if __name__ == '__main__': - pwm_demo() diff --git a/nanpy/examples/ramdump.py b/nanpy/examples/ramdump.py deleted file mode 100755 index 8782fb0..0000000 --- a/nanpy/examples/ramdump.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -# Description: read all RAM - -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager -import sys - - -def display(a_list, size): - for i in range(0, size // 16 - 1): - for j in range(16): - sys.stdout.write('%02x:' % a_list[j + i * 16]) - print - - -def ramdump(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - size = a.ram.size - free = a.ram.free() - print('Reading RAM (%s bytes, %s bytes free)...' % (size, free)) - - data_list = [] - for i in range(0, size): - s = a.ram.read(i) - data_list.append(s) - - display(data_list, size) - - -if __name__ == '__main__': - ramdump() diff --git a/nanpy/examples/reset.py b/nanpy/examples/reset.py deleted file mode 100755 index f4546c3..0000000 --- a/nanpy/examples/reset.py +++ /dev/null @@ -1,39 +0,0 @@ -"""soft reset demo. - -https://github.com/nanpy/nanpy/issues/72 - -watchdog doesn't work with some bootloaders. -Soft_reset() is based on watchdog. - -More information: -http://arduino.stackexchange.com/questions/2922/watchdog-timer-stuck-in-restart-loop-green-led-flashing -"The OP is using an Adriuni Pro Mini clone. -The included bootloader on the Arduino Pro Mini -does not support system restarts by the WDT. -Essentially, on a device with a bootloader -that does not support WDT restarts, -the board will restart but the timer / reset will not causing -the board to continuously reset on reboot. -There are alternative bootloaders for arduino boards -that may resolve this issue." - -""" - -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import SerialManager - - -def print_millis(a): - print ('uptime: %s sec' % (a.api.millis() / 1000.0)) - - -def reset_demo(): - connection = SerialManager() - a = ArduinoTree(connection=connection) - print_millis(a) - print ('soft reset') - a.soft_reset() - print_millis(a) - -if __name__ == '__main__': - reset_demo() diff --git a/nanpy/examples/servo.py b/nanpy/examples/servo.py deleted file mode 100644 index 54c9f3e..0000000 --- a/nanpy/examples/servo.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: move a servo motor -# Dependencies: None - -from nanpy import Servo -import time - -servo = Servo(7) -for move in [0, 90, 180, 90, 0]: - servo.write(move) - time.sleep(1) diff --git a/nanpy/examples/stepper.py b/nanpy/examples/stepper.py deleted file mode 100755 index ad92db5..0000000 --- a/nanpy/examples/stepper.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -# Author: Andrea Stagi -# Description: just a test for Stepper module -# Dependencies: None - -from nanpy import Stepper -from nanpy import Arduino - -motor = Stepper(100, 9 , 10, 1000) - -while True: - motor.step(-10) - Arduino.delay(1000) - diff --git a/nanpy/fwinfo.py b/nanpy/fwinfo.py deleted file mode 100644 index c4ed2cc..0000000 --- a/nanpy/fwinfo.py +++ /dev/null @@ -1,107 +0,0 @@ -import datetime - - -def avr_name(MCU): - """The name of the AVR. - - Example: __AVR_ATmega328P__ -> ATmega328P - - """ - return MCU.strip('_').split('_')[-1] - - -def arduino_version(ARDUINO): - """ - Example: 105 -> 1.0.5 - 10608 -> 1.6.8 - """ - s = str(ARDUINO) - if len(s) == 5: - return '%s.%s.%s' % (s[0], int(s[1:3]), int(s[3:5])) - else: - return '.'.join(s) - - -def parse_month(s): - '''gcc month - Jan -> 1 - ... - ''' - if s == 'Jan': - return 1 - if s == 'Feb': - return 2 - if s == 'Mar': - return 3 - if s == 'Apr': - return 4 - if s == 'May': - return 5 - if s == 'Jun': - return 6 - if s == 'Jul': - return 7 - if s == 'Aug': - return 8 - if s == 'Sep': - return 9 - if s == 'Oct': - return 10 - if s == 'Nov': - return 11 - if s == 'Dec': - return 12 - raise ValueError('invalid month: %s' % s) - - -def compile_datetime(DATE, TIME): - ''' - Example: Mar 28 2014, 17:40:12 - -> datetime.datetime(2008, 3, 28, 17, 40, 12) - ''' - dls = DATE.strip().split() - d = datetime.date(int(dls[2]), parse_month(dls[0]), int(dls[1])) - t = datetime.datetime.strptime(TIME, '%H:%M:%S') - dt = datetime.datetime.combine(d, t.time()) -# dt = datetime.datetime.strptime( -# DATE + ' ' + TIME, -# '%b %d %Y %H:%M:%S') - return dt - - -def libc_version(AVR_LIBC_VERSION): - """ - Example: 10604 -> 1.6.4 - - """ - s = str(AVR_LIBC_VERSION) - ls = [s[0], s[1:3], s[3:5]] - ls = map(int, ls) - ls = map(str, ls) - return '.'.join(ls) - - -def libc_date(AVR_LIBC_DATE): - """ - Example: 20081106 -> 2008.11.06 - - """ - s = str(AVR_LIBC_DATE) - ls = [s[0:4], s[4:6], s[6:8]] - ls = map(int, ls) - d = datetime.date(*ls) - return d - - -def firmware_info(define_dict): - d = dict() - d['avr_name'] = avr_name(define_dict['MCU']) - d['arduino_version'] = arduino_version(define_dict['ARDUINO']) - d['compile_datetime'] = compile_datetime(define_dict['__DATE__'], - define_dict['__TIME__'], - ) - d['gcc_version'] = define_dict['__VERSION__'] - d['libc_version'] = libc_version(define_dict['__AVR_LIBC_VERSION__']) - d['libc_date'] = libc_date(define_dict['__AVR_LIBC_DATE_']) - - return d diff --git a/nanpy/i2c.py b/nanpy/i2c.py deleted file mode 100644 index dd1eaa8..0000000 --- a/nanpy/i2c.py +++ /dev/null @@ -1,110 +0,0 @@ -import logging -log = logging.getLogger(__name__) - - -class I2C_CommunicationError(Exception): - error_texts = { - # 0: 'success', - 1: 'data too long to fit in transmit buffer', - 2: 'received NACK on transmit of address', - 3: 'received NACK on transmit of data', - 4: 'other error', - } - - def __init__(self, error_code): - self.error_code = error_code - Exception.__init__(self, self.error_texts[error_code]) - - -class I2C_Base(object): - - '' - bus_initialised = False - address = None - - def _begin(self): - if not self.bus_initialised: - self.wire.begin(self.address) - self.bus_initialised = True - - -class I2C_Master(I2C_Base): - - """High level interface for I2C Master.""" - - def __init__(self, wire): - self.wire = wire - - def request(self, address, quantity): - """Used by the master to request bytes from a slave device. - - :param address: the 7-bit address of the device to request bytes from - :param quantity: the number of bytes to request - :param stop: boolean. true will send a stop message after the request, releasing the bus. false will continually send a restart after the request, keeping the connection active. - :returns: list : the list of bytes returned from the slave device - - http://arduino.cc/en/Reference/WireRequestFrom - - """ - self._begin() - n = self.wire.requestFrom(address, quantity, stop=True) - if n < quantity: - log.info('slave sent less bytes than requested') - ls = n * [None] - for i in range(n): - ls[i] = self.wire.read() - return ls - - def send(self, address, data): - """""" - self._begin() - self.wire.beginTransmission(address) - for b in data: - self.wire.write(b) - error_code = self.wire.endTransmission() - if error_code != 0: - raise I2C_CommunicationError(error_code) - - def scan(self): - """The i2c_scanner uses the return value of the Write.endTransmisstion - to see if a device did acknowledge to the address. - - original source: http://playground.arduino.cc/Main/I2cScanner#.Uxs4Wdt4iJM - - """ - self._begin() - ls = [] - for address in range(128): - try: - self.send(address, []) - ls.append(address) - except I2C_CommunicationError: - pass - - return ls - - -class I2C_Slave(I2C_Base): - - """High level interface for I2C Slave.""" - - def __init__(self, wire, address): - ''' - :param address: slave address - ''' - self.wire = wire - self.address = address - - def receive(self): - self._begin() - n = self.wire.available() - ls = n * [None] - for i in range(n): - ls[i] = self.wire.read() - return ls - - def send(self, data): - """""" - self._begin() - for b in data: - self.wire.write(b) diff --git a/nanpy/lcd.py b/nanpy/lcd.py deleted file mode 100644 index 49b6b37..0000000 --- a/nanpy/lcd.py +++ /dev/null @@ -1,41 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod - -class Lcd(ArduinoObject): - cfg_h_name = 'USE_LiquidCrystal' - - def __init__(self, pins, begin, connection=None): - ''' - :param pins: [rs, enable, d4, d5, d6, d7] - :param begin: [cols, rows] - ''' - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pins, begin) - - @arduinoobjectmethod - def printString(self, value, col = None, row = None): - pass - - @arduinoobjectmethod - def setCursor(self, col, row): - pass - - @arduinoobjectmethod - def autoscroll(self): - pass - - @arduinoobjectmethod - def noAutoscroll(self): - pass - - @arduinoobjectmethod - def clear(self): - pass - - @arduinoobjectmethod - def createChar(self, num, data): - pass - - @arduinoobjectmethod - def write(self, data): - pass diff --git a/nanpy/lcd_i2c.py b/nanpy/lcd_i2c.py deleted file mode 100644 index e0b2b7f..0000000 --- a/nanpy/lcd_i2c.py +++ /dev/null @@ -1,26 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod - - -class Lcd_I2C(ArduinoObject): - cfg_h_name = 'USE_LiquidCrystal_I2C' - - def __init__(self, pins, begin, connection=None): - ''' - :param pins: [lcd_Addr, enable, Rw, Rs, d4, d5, d6, d7, backlighPin, pol] - :param begin: [cols, rows] - ''' - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pins, begin) - - @arduinoobjectmethod - def printString(self, value, col=None, row=None): - pass - - @arduinoobjectmethod - def setCursor(self, col, row): - pass - - @arduinoobjectmethod - def setBacklight(self, value): - pass diff --git a/nanpy/memo.py b/nanpy/memo.py deleted file mode 100644 index 86087e1..0000000 --- a/nanpy/memo.py +++ /dev/null @@ -1,34 +0,0 @@ -import functools - - -class memoized(object): - """Decorator that caches a function's return value each time it is called. - If called later with the same arguments, the cached value is returned, and - not re-evaluated. - - http://wiki.python.org/moin/PythonDecoratorLibrary - - """ - def __init__(self, func): - self.func = func - self.cache = {} - - def __call__(self, *args): - try: - return self.cache[args] - except KeyError: - value = self.func(*args) - self.cache[args] = value - return value - except TypeError: - # uncachable -- for instance, passing a list as an argument. - # Better to not cache than to blow up entirely. - return self.func(*args) - - def __repr__(self): - """Return the function's docstring.""" - return self.func.__doc__ - - def __get__(self, obj, objtype): - """Support instance methods.""" - return functools.partial(self.__call__, obj) diff --git a/nanpy/mock/__init__.py b/nanpy/mock/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/nanpy/mock/mockconnection.py b/nanpy/mock/mockconnection.py deleted file mode 100644 index a0af841..0000000 --- a/nanpy/mock/mockconnection.py +++ /dev/null @@ -1,77 +0,0 @@ -import logging - -from nanpy.mock.mockeeprom import MockEEPROM -from nanpy.mock.mockinfo import MockInfo -from nanpy.mock.mockram import MockRAM -from nanpy.mock.mockservo import MockServo -from nanpy.mock.mockstepper import MockStepper - - -log = logging.getLogger(__name__) - - -ALL_CLASSES = [ - MockInfo, - MockRAM, - MockEEPROM, - MockServo, - MockStepper, - ] - - -class MockConnection(object): - state = 0 - obj_id = 0 - param_count = 0 - - def __init__(self): - self.objects = dict([(c.firmware_id, c()) for c in ALL_CLASSES]) - self.objects['Info'].class_names = [x.firmware_id for x in ALL_CLASSES] - - def elaborate(self,): - for n, x in self.objects.items(): - if n == self.class_name: - self.return_value = x.elaborate(self.obj_id, self.func_name, self.params) - return - assert 0 - - def write(self, value): - log.debug('sending:%s', repr(value)) - assert value.endswith('\x00') - - value = value[0:-1] - - assert value == value.strip() - - if self.state == 0: - self.class_name = value - self.state += 1 - elif self.state == 1: - self.obj_id = int(value) - self.state += 1 - elif self.state == 2: - self.param_count = int(value) - self.state += 1 - elif self.state == 3: - self.func_name = value - self.params = [] - self.state += 1 - if self.param_count == 0: - self.elaborate() - self.state = 0 - elif self.state == 4: - self.params.append(value) - self.param_count -= 1 - if self.param_count == 0: - self.elaborate() - self.state = 0 - - assert self.state<=4 - assert self.param_count<=10 - assert self.param_count>=0 - - def readline(self): - s = '%s\r\n' % self.return_value - log.debug('received:%s', repr(s)) - return s - diff --git a/nanpy/mock/mockeeprom.py b/nanpy/mock/mockeeprom.py deleted file mode 100644 index 6aaab30..0000000 --- a/nanpy/mock/mockeeprom.py +++ /dev/null @@ -1,17 +0,0 @@ -import logging - -log = logging.getLogger(__name__) - -class MockEEPROM(object): - firmware_id = "EEPROM" - - def __init__(self): - self.memory = [0, 1, 2, 3, 4, 5, 255, 255] - - def elaborate(self, obj_id, name, params): - if name == "size": - return len(self.memory) - elif name == "read": - return self.memory[int(params[0])] - elif name == "write": - self.memory[int(params[0])] = int(params[1]) diff --git a/nanpy/mock/mockinfo.py b/nanpy/mock/mockinfo.py deleted file mode 100644 index 8f3a9f4..0000000 --- a/nanpy/mock/mockinfo.py +++ /dev/null @@ -1,18 +0,0 @@ -import logging - -log = logging.getLogger(__name__) - - -class MockInfo(object): - firmware_id = "Info" - - def __init__(self, class_names=None): - self.class_names = class_names - - - def elaborate(self, obj_id, name, params): - if name == "count": - return len(self.class_names) - elif name == "name": - return self.class_names[int(params[0])] - diff --git a/nanpy/mock/mockobject.py b/nanpy/mock/mockobject.py deleted file mode 100644 index f8c825c..0000000 --- a/nanpy/mock/mockobject.py +++ /dev/null @@ -1,12 +0,0 @@ -class MockObject(object): - def __init__(self): - self.objects = [] - - def elaborate(self, obj_id, name, params): - if name == "new": - x = self.factory(params) - self.objects.append(x) - return len(self.objects) - 1 - if name == "remove": - del self.objects[int(params[0])] - return 0 diff --git a/nanpy/mock/mockram.py b/nanpy/mock/mockram.py deleted file mode 100644 index 7a24fa3..0000000 --- a/nanpy/mock/mockram.py +++ /dev/null @@ -1,20 +0,0 @@ -import logging - -log = logging.getLogger(__name__) - -class MockRAM(object): - firmware_id = "RAM" - - def __init__(self): - self.memory = [0, 1, 2, 3, 4, 5, 255, 255] - self.free = 3 - - def elaborate(self, obj_id, name, params): - if name == "size": - return len(self.memory) - elif name == "read": - return self.memory[int(params[0])] - elif name == "write": - self.memory[int(params[0])] = int(params[1]) - elif name == "free": - return self.free diff --git a/nanpy/mock/mockservo.py b/nanpy/mock/mockservo.py deleted file mode 100644 index 39868b8..0000000 --- a/nanpy/mock/mockservo.py +++ /dev/null @@ -1,33 +0,0 @@ -import logging - -from nanpy.mock.mockobject import MockObject - - -log = logging.getLogger(__name__) - -class MockServo(MockObject): - firmware_id = "Servo" - - def factory(self, params): - d = dict( - pin=int(params[0]), - angle=0, - ) - return d - - def elaborate(self, obj_id, name, params): - if name == "read": - return self.objects[obj_id]['angle'] - elif name == "write": - self.objects[obj_id]['angle'] = int(params[0]) - return 0 - elif name == "writeMicroseconds": - raise NotImplementedError - elif name == "readMicroseconds": - raise NotImplementedError - elif name == "detach": - self.objects[obj_id]['pin'] = None - return 0 - elif name == "attached": - return self.objects[obj_id]['pin'] is not None - return MockObject.elaborate(self, obj_id, name, params) diff --git a/nanpy/mock/mockstepper.py b/nanpy/mock/mockstepper.py deleted file mode 100644 index 1c06d53..0000000 --- a/nanpy/mock/mockstepper.py +++ /dev/null @@ -1,29 +0,0 @@ -import logging - -from nanpy.mock.mockobject import MockObject - - -log = logging.getLogger(__name__) - - -class MockStepper(MockObject): - firmware_id = "Stepper" - - def factory(self, params): - d = dict( - revsteps=int(params[0]), - pin1=int(params[1]), - pin2=int(params[2]), - speed=0, - ) - return d - - def elaborate(self, obj_id, name, params): - if name == "setSpeed": - self.objects[obj_id]['speed'] = int(params[0]) - return 0 - elif name == "step": - assert self.objects[obj_id] - return 0 - return MockObject.elaborate(self, obj_id, name, params) - diff --git a/nanpy/nullconnection.py b/nanpy/nullconnection.py deleted file mode 100644 index e24ff94..0000000 --- a/nanpy/nullconnection.py +++ /dev/null @@ -1,10 +0,0 @@ -class NullConnection(object): - - def write(self, value): - print('sending:%s' % repr(value)) - - def readline(self): - return '' - - def flush_input(self): - """Flush input buffer, discarding all it's contents.""" diff --git a/nanpy/onewire.py b/nanpy/onewire.py deleted file mode 100644 index 0377ed2..0000000 --- a/nanpy/onewire.py +++ /dev/null @@ -1,37 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class OneWire(ArduinoObject): - cfg_h_name = 'USE_OneWire' - - def __init__(self, pin, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pin) - - def search(self): - val = self.call('search') - if val == "1": - return val - return val.split(' ') - - @arduinoobjectmethod - def select(self, address): - pass - - @returns(int) - @arduinoobjectmethod - def read(self): - pass - - @arduinoobjectmethod - def reset_search(self): - pass - - @arduinoobjectmethod - def reset(self): - pass - - @arduinoobjectmethod - def write(self, address, value=None): - pass - diff --git a/nanpy/pwm.py b/nanpy/pwm.py deleted file mode 100644 index 703bdd9..0000000 --- a/nanpy/pwm.py +++ /dev/null @@ -1,270 +0,0 @@ -from __future__ import division -import logging - -log = logging.getLogger(__name__) - - -class PwmError(Exception): - pass - - -class BiDict(object): - def __init__(self, dic): - self.norm = dic - self.inv = dict([(v, k) for k, v in dic.items()]) - -base_divisor = { - 3: 512, - 5: 256, - 6: 256, - 9: 512, - 10: 512, - 11: 512, -} - - -_div1 = BiDict({ - # 0: None, - 1: 1, - 2: 8, - 3: 64, - 4: 256, - 5: 1024, - # 6: None, - # 7: None, - }) -_div2 = BiDict({ - # 0: None, - 1: 1, - 2: 8, - 3: 32, - 4: 64, - 5: 128, - 6: 256, - 7: 1024, - }) -divisor_mapping = { - 3: _div2, - 5: _div1, - 6: _div1, - 9: _div1, - 10: _div1, - 11: _div2, -} - -TIMERS_A = ['NOT_ON_TIMER', - 'TCCR0A', - 'TCCR0A', - 'TCCR1A', - 'TCCR1A', - None, # TODO: atmega8 - 'TCCR2A', - 'TCCR2A', - ] - -TIMERS_B = ['NOT_ON_TIMER', - 'TCCR0B', - 'TCCR0B', - 'TCCR1B', - 'TCCR1B', - 'TCCR2', - 'TCCR2B', - 'TCCR2B', - ] - -timer_mask = 7 # 0b111 - -# TODO: pwm_mode read/write -# TODO: read mappings - - -class ArduinoPwmPin(object): - - '''Object-oriented representation of the pin PWM functionality - ''' - DEFAULT_DIVISOR = 64 - - def __init__(self, nr, define, register, core, api): - self.nr = nr - self.register = register - self.F_CPU = define.get('F_CPU') - self.api = api - self.core = core - - def reset(self): - '''reset to the PWM default state: default frequency is set - ''' - if not self.available: - return - self.write_divisor(self.DEFAULT_DIVISOR) - - @property - def available(self): - """PWM is available for this pin?""" - timer_id = self._timer_id() - return timer_id > 0 and timer_id < len(TIMERS_B) -# return self.nr in timer_register - - def _check(self): - if not self.available: - raise PwmError('pwm not available for pin: %s' % self.nr) - - def write_value(self, value): - """same as analogWrite.""" - self._check() -# assert self.mcu.pins.read_mode(self.nr) == OUTPUT - self.api.analogWrite(self.nr, value) - - @property - def divisors_available(self): - """list of available divisors.""" - try: - return list(divisor_mapping[self.nr].norm.values()) - except KeyError: - return [] - - def read_divisor(self): - """read current divisor.""" - if self.register is None: - return - self._check() - d = divisor_mapping[self.nr] - return d.norm[self.read_timer_mode()] - - def write_divisor(self, value): - """write current divisor.""" - self._check() - d = divisor_mapping[self.nr] - self.write_timer_mode(d.inv[value]) - divisor = property(read_divisor, write_divisor) - - def _timer_id(self): - return self.core.digitalPinToTimer(self.nr) - - def _timer_register_name(self, variant='B'): - self._check() - i = self._timer_id() - return dict(A=TIMERS_A, B=TIMERS_B)[variant][i] - - @property - def timer_register_name_a(self): - return self._timer_register_name(variant='A') - - @property - def timer_register_name_b(self): - return self._timer_register_name(variant='B') - - def read_timer_mode(self): - if self.register is None: - return - reg_name = self.timer_register_name_b - return self.register.get(reg_name).read_value() & timer_mask - - def write_timer_mode(self, value): - assert value <= 7 - reg_name = self.timer_register_name_b - reg = self.register.get(reg_name) - old = reg.value & ~timer_mask - reg.value = (old | value) - - timer_mode = property(read_timer_mode, write_timer_mode) - - @property - def base_divisor(self): - self._check() - return base_divisor[self.nr] - - def calculate_frequency(self, divisor): - if self.register is None: - return - return 1.0 * self.F_CPU / self.base_divisor / divisor - - @property - def frequencies_available(self): - """list of available frequencies.""" - ls = sorted([self.calculate_frequency(x) - for x in self.divisors_available]) - return ls - - def read_frequency(self): - self._check() - wgm = self.read_wgm() - if wgm == 14: - # high freq mode - return self.F_CPU / self.register.get('ICR1').value - else: - return self.calculate_frequency(self.read_divisor()) - - def write_frequency(self, value): - self._check() - d = divisor_mapping[self.nr] - for x in self.divisors_available: - f = self.calculate_frequency(x) - if abs(f - value) <= 1: - self.write_timer_mode(d.inv[x]) - return - frequency = property(read_frequency, write_frequency) - - def read_wgm(self): - """read waveform generation mode.""" - if self.register is None: - return - self._check() - rega = self.timer_register_name_a - regb = self.timer_register_name_b - if regb == 'TCCR1B': - maskb = 24 # 0b00011000 - else: - maskb = 8 # 0b00001000 - maska = 3 # 0b00000011 - a = self.register.get(rega).value & maska - b = self.register.get(regb).value & maskb - return a + (b >> 1) - - wgm = property(read_wgm, None) - - def _check_high_freq(self): - # TODO: read config - if self.nr not in [9, 10]: - raise PwmError('high freq pwm not available for pin: %s' % self.nr) - - def set_high_freq_around_pwm(self, top, fill): - 'F_CPU/divisor' - # TODO: - d = top - self._check_high_freq() - assert d >= 2 - - self.write_divisor(1) - self.write_value(128) - - TCCR1A = self.register.get('TCCR1A') - TCCR1B = self.register.get('TCCR1B') - TCNT1 = self.register.get('TCNT1') - ICR1 = self.register.get('ICR1') - OCR1A = self.register.get('OCR1A') - OCR1B = self.register.get('OCR1B') - - TCCR1A.value = 2 + \ - (240 & TCCR1A.value) # 0b00000010 + (0b11110000 & reg.TCCR1A) - TCCR1B.value = 25 # 0b00011001 - - TCNT1.value = 0 - ICR1.value = d - OCR1A.value = fill - OCR1B.value = fill - - def set_high_freq_around(self, freq): - """set high frequency mode, and try to set frequency as close as - possible. - - available frequencies: F_CPU/N (N=2..65535) - - Example: F_CPU=16000000 (default) -> frequencies=244Hz-8MHz - - TODO: test it on more AVRs, read config from firmware - - """ - top = int(self.F_CPU / freq + 0.5) - assert 1 < top < (1 << 16) - self.set_high_freq_around_pwm(top, int(top / 2)) diff --git a/nanpy/ram.py b/nanpy/ram.py deleted file mode 100644 index bd2a3b1..0000000 --- a/nanpy/ram.py +++ /dev/null @@ -1,30 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -from nanpy.memo import memoized - - -@check4firmware -class RAM(FirmwareClass): - cfg_h_name = 'USE_RAM' - firmware_id = 'RAM' - - @arduinomethod - def write(self, address, value): - pass - - @returns(int) - @arduinomethod - def read(self, address): - pass - - @property - @memoized - @returns(int) - @arduinomethod - def size(self): - pass - - @returns(int) - @arduinomethod - def free(self): - pass diff --git a/nanpy/register.py b/nanpy/register.py deleted file mode 100644 index 49eda01..0000000 --- a/nanpy/register.py +++ /dev/null @@ -1,176 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware -from nanpy.memo import memoized - - -@check4firmware -class RegisterArray(FirmwareClass): - cfg_h_name = 'USE_Register' - firmware_id = 'R' - - @memoized - @returns(int) - @arduinomethod('c') - def count(self): - pass - - @returns(int) - @arduinomethod('r') - def read(self, index): - pass - - @arduinomethod('w') - def write(self, index, value): - pass - - @memoized - @returns(int) - @arduinomethod('a') - def address(self, index): - pass - - @memoized - @returns(int) - @arduinomethod('s') - def size(self, index): - pass - - @memoized - @arduinomethod('n') - def name(self, index): - pass - - -class Register(object): - - """Representation of an AVR register.""" - - def __init__(self, index, arr): - """""" - self._arr = arr - self.index = index - - def read_value(self): - """Read register value. - - Examples: - - a=ArduinoTree() - a.register.get('DDRB').read_value() - - """ - return self._arr.read(self.index) - - def write_value(self, value): - """Write register value. - - Examples: - - a=ArduinoTree() - a.register.get('DDRB').write_value(1) - - """ - return self._arr.write(self.index, value) - - value = property(read_value, write_value) - - @property - def name(self): - """Register name. - """ - return self._arr.name(self.index) - - @property - def address(self): - """Register address. - - Examples: - - a=ArduinoTree() - a.register.get('DDRB').address - - """ - return self._arr.address(self.index) - - @property - def size(self): - """Register size in bytes. 1 or 2. - - Examples: - - a=ArduinoTree() - a.register.get('DDRB').size - - """ - return self._arr.size(self.index) - - -class RegisterProxy(object): - - """Proxy object to allow easy register access. - - Examples: - - a=ArduinoTree() - a.register.proxy.DDRB = 1 - print( a.register.proxy.DDRB ) - - """ - - def __init__(self, arr, name_index_dict): - self._name_index_dict = name_index_dict - self._arr = arr - - def __getattr__(self, name): - if name in ['_name_index_dict', '_arr']: - return object.__getattribute__(self, name) - - index = self._name_index_dict[name] - return self._arr.read(index) - - def __setattr__(self, name, value): - if name in ['_name_index_dict', '_arr']: - self.__dict__[name] = value - return - - index = self._name_index_dict[name] - return self._arr.write(index, value) - - -class RegisterFeature(object): - - def __init__(self, connection=None): - self._arr = RegisterArray(connection) - - @property - @memoized - def name_index_dict(self): - d = dict() - for i in range(self._arr.count()): - d[self._arr.name(i)] = i - assert len(d) - return d - - @property - def names(self): - """Get all register names as a sorted list.""" - return sorted(self.name_index_dict.keys()) - - @property - @memoized - def count(self): - """Get register count.""" - return len(self.name_index_dict.keys()) - - @memoized - def get(self, name): - try: - index = self.name_index_dict[name] - except KeyError: - raise ValueError('Unknown register: %s' % name) - return Register(index, self._arr) - - @property - @memoized - def proxy(self): - return RegisterProxy(self._arr, self.name_index_dict) diff --git a/nanpy/serialmanager.py b/nanpy/serialmanager.py deleted file mode 100644 index a4b7fdb..0000000 --- a/nanpy/serialmanager.py +++ /dev/null @@ -1,117 +0,0 @@ -import fnmatch -import logging -import serial -import sys -import time - -DEFAULT_BAUDRATE = 115200 - -log = logging.getLogger(__name__) - -PY3 = sys.version_info[0] == 3 - - -class SerialManagerError(Exception): - pass - - -def _auto_detect_serial_unix(preferred_list=None): - import glob - glist = glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') - glist += ['/dev/ttyS0', '/dev/ttyS1'] - ret = [] - - if preferred_list is None: - preferred_list = ['*'] - - for d in glist: - for preferred in preferred_list: - if fnmatch.fnmatch(d, preferred): - ret.append(d) - if len(ret) > 0: - return ret - - for d in glist: - ret.append(d) - return ret - - -class NoneSerialManager(object): - - def write(self, val): - pass - - def read(self): - return "" - - def readline(self): - return "" - - -class SerialManager(object): - _serial = None - - def __init__(self, device=None, - baudrate=DEFAULT_BAUDRATE, - sleep_after_connect=2, - timeout=7, - rtscts=False): - self.device = device - self.baudrate = baudrate - self.sleep_after_connect = sleep_after_connect - self.timeout = timeout - self.rtscts = rtscts - - def open(self, device=None): - '''open connection''' - if device: - self.device = device - - if not self.device: - ports = _auto_detect_serial_unix() - if not len(ports): - raise SerialManagerError("No port was set, and no port was found!") - self.device = ports[0] - log.debug('opening port:%s [%s baud]', self.device, self.baudrate) - assert self.device - self._serial = serial.Serial(self.device, - self.baudrate, - timeout=self.timeout, - rtscts=self.rtscts) - if self.sleep_after_connect: - time.sleep(self.sleep_after_connect) - self._serial.flushInput() - - def write(self, value): - if not self._serial: - self.open() - log.debug('sending:%s', repr(value)) - if PY3: - self._serial.write(bytes(value, 'latin-1')) - else: - self._serial.write(value) - - def readline(self): - if not self._serial: - self.open() - s = self._serial.readline() - log.debug('received:%s', repr(s)) - s = s.decode() - if not len(s): - raise SerialManagerError('Serial timeout!') - return s - - def flush_input(self): - '''Flush input buffer, discarding all it's contents.''' - if not self._serial: - self.open() - self._serial.flushInput() - - def close(self): - '''close connection''' - if self._serial: - self._serial.close() - self._serial = None - -serial_manager = SerialManager() - diff --git a/nanpy/servo.py b/nanpy/servo.py deleted file mode 100644 index 1a1fe53..0000000 --- a/nanpy/servo.py +++ /dev/null @@ -1,35 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class Servo(ArduinoObject): - cfg_h_name = 'USE_Servo' - - def __init__(self, pin, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pin) - - @arduinoobjectmethod - def write(self, value): - pass - - @returns(int) - @arduinoobjectmethod - def read(self): - pass - - @arduinoobjectmethod - def writeMicroseconds(self, value): - pass - - @returns(int) - @arduinoobjectmethod - def readMicroseconds(self, value): - pass - - @arduinoobjectmethod - def attached(self): - pass - - @arduinoobjectmethod - def detach(self): - pass diff --git a/nanpy/shiftout.py b/nanpy/shiftout.py deleted file mode 100644 index 1d82820..0000000 --- a/nanpy/shiftout.py +++ /dev/null @@ -1,36 +0,0 @@ -from nanpy.arduinoapi import ArduinoApi -from nanpy.arduinopin import to_pin_number - - -class ShiftOut(object): - LSBFIRST, MSBFIRST = 0, 1 - - def __init__(self, data_pin, clock_pin, - bit_order=0, connection=None, A0=None): - """Shifts out a byte of data one bit at a time. - - :param data_pin: the pin on which to output each bit (int or string) - :param clock_pin: the pin to toggle once the dataPin has been set to the correct value (int or string) - :param bit_order: which order to shift out the bits; either MSBFIRST or LSBFIRST. - - """ - if connection and hasattr(connection, 'shiftOut'): - self._shiftOut_func = connection.shiftOut - else: - api = ArduinoApi(connection=connection) - self._shiftOut_func = api.shiftOut - self.bit_order = bit_order - self.data_pin_number = to_pin_number(data_pin, A0) - self.clock_pin_number = to_pin_number(clock_pin, A0) - - def write_data(self, data): - """Shifts out a byte of data one bit at a time. - - :param data: the data to shift out. (byte) - - """ - self._shiftOut_func( - self.data_pin_number, - self.clock_pin_number, - self.bit_order, - data) diff --git a/nanpy/sockconnection.py b/nanpy/sockconnection.py deleted file mode 100644 index 8307818..0000000 --- a/nanpy/sockconnection.py +++ /dev/null @@ -1,62 +0,0 @@ -import logging -import socket - -log = logging.getLogger(__name__) - - -class SocketManagerError(Exception): - pass - - -class SocketManager(object): - _socket = None - - def __init__(self, host='nanpy.local', port=5678): - self.host = host - self.port = port - - def open(self): - log.debug('opening:%s:%s', self.host, self.port) - self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self._socket.settimeout(120) - try: - self._socket.connect((self.host, self.port)) - except OSError: - raise SocketManagerError('Host not found!') - - def close(self): - log.debug('closing:%s:%s', self.host, self.port) - if self._socket: - self._socket.close() - self._socket = None - - def write(self, value): - if not self._socket: - self.open() - log.debug('sending:%s', repr(value)) - self._socket.sendall(bytes(value, 'latin-1')) - - def readline(self): - if not self._socket: - self.open() - s = b'' - while 1: - try: - self._socket.settimeout(120) - c = self._socket.recv(1) - log.debug('recv: %s', repr(c.decode())) - if c.decode() == '\r': - continue - if c.decode() == '\n': - break - if c.decode() == '': - break - s += c - except socket.timeout: - raise SocketManagerError('Socket Timeout!') - - log.debug('received:%s', repr(s)) - s = s.decode() - if not len(s): - raise SocketManagerError('timeout!') - return s diff --git a/nanpy/stepper.py b/nanpy/stepper.py deleted file mode 100644 index b38d19e..0000000 --- a/nanpy/stepper.py +++ /dev/null @@ -1,22 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod - -class Stepper(ArduinoObject): - cfg_h_name = 'USE_Stepper' - - def __init__(self, revsteps, pin1, pin2, speed=None, connection=None, pin3=None, pin4=None): - ArduinoObject.__init__(self, connection=connection) - if pin3 is not None and pin4 is not None: - self.id = self.call('new', revsteps, pin1, pin2, pin3, pin4) - else: - self.id = self.call('new', revsteps, pin1, pin2) - if speed: - self.setSpeed(speed) - - @arduinoobjectmethod - def setSpeed(self, value): - pass - - @arduinoobjectmethod - def step(self, value): - pass diff --git a/nanpy/tone.py b/nanpy/tone.py deleted file mode 100644 index 0837ed6..0000000 --- a/nanpy/tone.py +++ /dev/null @@ -1,111 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import arduinoobjectmethod -import time - - -class Tone(ArduinoObject): - cfg_h_name = 'USE_Tone' - - NOTE_B0 = 31 - NOTE_C1 = 33 - NOTE_CS1 = 35 - NOTE_D1 = 37 - NOTE_DS1 = 39 - NOTE_E1 = 41 - NOTE_F1 = 44 - NOTE_FS1 = 46 - NOTE_G1 = 49 - NOTE_GS1 = 52 - NOTE_A1 = 55 - NOTE_AS1 = 58 - NOTE_B1 = 62 - NOTE_C2 = 65 - NOTE_CS2 = 69 - NOTE_D2 = 73 - NOTE_DS2 = 78 - NOTE_E2 = 82 - NOTE_F2 = 87 - NOTE_FS2 = 93 - NOTE_G2 = 98 - NOTE_GS2 = 104 - NOTE_A2 = 110 - NOTE_AS2 = 117 - NOTE_B2 = 123 - NOTE_C3 = 131 - NOTE_CS3 = 139 - NOTE_D3 = 147 - NOTE_DS3 = 156 - NOTE_E3 = 165 - NOTE_F3 = 175 - NOTE_FS3 = 185 - NOTE_G3 = 196 - NOTE_GS3 = 208 - NOTE_A3 = 220 - NOTE_AS3 = 233 - NOTE_B3 = 247 - NOTE_C4 = 262 - NOTE_CS4 = 277 - NOTE_D4 = 294 - NOTE_DS4 = 311 - NOTE_E4 = 330 - NOTE_F4 = 349 - NOTE_FS4 = 370 - NOTE_G4 = 392 - NOTE_GS4 = 415 - NOTE_A4 = 440 - NOTE_AS4 = 466 - NOTE_B4 = 494 - NOTE_C5 = 523 - NOTE_CS5 = 554 - NOTE_D5 = 587 - NOTE_DS5 = 622 - NOTE_E5 = 659 - NOTE_F5 = 698 - NOTE_FS5 = 740 - NOTE_G5 = 784 - NOTE_GS5 = 831 - NOTE_A5 = 880 - NOTE_AS5 = 932 - NOTE_B5 = 988 - NOTE_C6 = 1047 - NOTE_CS6 = 1109 - NOTE_D6 = 1175 - NOTE_DS6 = 1245 - NOTE_E6 = 1319 - NOTE_F6 = 1397 - NOTE_FS6 = 1480 - NOTE_G6 = 1568 - NOTE_GS6 = 1661 - NOTE_A6 = 1760 - NOTE_AS6 = 1865 - NOTE_B6 = 1976 - NOTE_C7 = 2093 - NOTE_CS7 = 2217 - NOTE_D7 = 2349 - NOTE_DS7 = 2489 - NOTE_E7 = 2637 - NOTE_F7 = 2794 - NOTE_FS7 = 2960 - NOTE_G7 = 3136 - NOTE_GS7 = 3322 - NOTE_A7 = 3520 - NOTE_AS7 = 3729 - NOTE_B7 = 3951 - NOTE_C8 = 4186 - NOTE_CS8 = 4435 - NOTE_D8 = 4699 - NOTE_DS8 = 4978 - - def __init__(self, pin, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', pin) - - @arduinoobjectmethod - def play(self, note, duration=0): - if duration != 0: - time.sleep(duration/1000.0) - self.stop() - - @arduinoobjectmethod - def stop(self): - pass diff --git a/nanpy/ultrasonic.py b/nanpy/ultrasonic.py deleted file mode 100644 index a00ae4d..0000000 --- a/nanpy/ultrasonic.py +++ /dev/null @@ -1,18 +0,0 @@ -from nanpy.arduinoboard import ArduinoObject -from nanpy.arduinoboard import (arduinoobjectmethod, returns) - -class Ultrasonic(ArduinoObject): - cfg_h_name = 'USE_Ultrasonic' - - def __init__(self, echo, trig, useInches, connection=None): - ArduinoObject.__init__(self, connection=connection) - self.id = self.call('new', echo, trig, useInches) - - @returns(float) - @arduinoobjectmethod - def get_distance(self): - pass - - def reading_in_range(self, low, high): - return low <= self.get_distance() <= high - diff --git a/nanpy/util.py b/nanpy/util.py deleted file mode 100644 index 9cc4379..0000000 --- a/nanpy/util.py +++ /dev/null @@ -1,9 +0,0 @@ - - -def constrain(value, xmin, xmax): - if value < xmin: - return xmin - if value > xmax: - return xmax - return value - diff --git a/nanpy/vcc.py b/nanpy/vcc.py deleted file mode 100644 index 1f969f5..0000000 --- a/nanpy/vcc.py +++ /dev/null @@ -1,59 +0,0 @@ -import time - -MUX0=1 << 0 -MUX1=1 << 1 -MUX2=1 << 2 -MUX3=1 << 3 -MUX4=1 << 4 -MUX5=1 << 5 -REFS0=1 << 6 -REFS1=1 << 7 - -class Vcc(object): - bandgap_voltage = 1.1 # Volt - def __init__(self, register, MCU=None): - self.register = register - self.MCU = MCU - - def read(self): - """VCC in Volt. Bandgap voltage precision: +-10% - - Source: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter - - How it works - - The Arduino 328 and 168 have a built in precision voltage reference of 1.1V. - This is used sometimes for precision measurement, - although for Arduino it usually makes more sense to measure against Vcc, - the positive power rail. - The chip has an internal switch that selects which pin the analogue to digital converter reads. - That switch has a few leftover connections, so the chip designers wired them up to useful signals. - One of those signals is that 1.1V reference. - So if you measure how large the known 1.1V reference is in comparison to Vcc, - you can back-calculate what Vcc is with a little algebra. That is how this works. - - """ - - reg = self.register.proxy - - - if self.MCU in ['__AVR_ATmega32U4__' , '__AVR_ATmega1280__' , '__AVR_ATmega2560__']: - cfg = REFS0 | MUX4 | MUX3 | MUX2 | MUX1 - elif self.MCU in ['__AVR_ATtiny24__' , '__AVR_ATtiny44__' , '__AVR_ATtiny84__']: - cfg = MUX5 | MUX0 - elif self.MCU in ['__AVR_ATtiny25__' , '__AVR_ATtiny45__' , '__AVR_ATtiny85__']: - cfg = MUX3 | MUX2 - else: - cfg = REFS0 | MUX3 | MUX2 | MUX1 - - reg.ADMUX = cfg - # Wait for Vref to settle - time.sleep(0.002) - # Convert - reg.ADCSRA |= 0x40 # 0b01000000 = _BV(ADSC) - while reg.ADCSRA & 0x40: # bit_is_set(ADCSRA, ADSC) - time.sleep(0.001) - result = reg.ADCL | (reg.ADCH << 8) - - result = (self.bandgap_voltage * 1024) / result - return result diff --git a/nanpy/watchdog.py b/nanpy/watchdog.py deleted file mode 100644 index a0648c5..0000000 --- a/nanpy/watchdog.py +++ /dev/null @@ -1,43 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, FirmwareClass -from nanpy.classinfo import check4firmware - - -@check4firmware -class Watchdog(FirmwareClass): - - """Direct access to watchdog timer. - - Details: http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html - - """ - cfg_h_name = 'USE_Watchdog' - - WDTO_15MS = 0 - WDTO_30MS = 1 - WDTO_60MS = 2 - WDTO_120MS = 3 - WDTO_250MS = 4 - WDTO_500MS = 5 - WDTO_1S = 6 - WDTO_2S = 7 - WDTO_4S = 8 - WDTO_8S = 9 - - @arduinomethod - def reset(self): - """Reset the watchdog timer. (wdt_reset) - - When the watchdog timer is enabled, - a call to this instruction is required before the timer expires, - otherwise a watchdog-initiated device reset will occur. - - """ - - @arduinomethod - def enable(self, timeout): - """Enable the watchdog timer, configuring it for expiry after - timeout. (wdt_enable)""" - - @arduinomethod - def disable(self): - """Disable the watchdog timer, if possible. (wdt_disable)""" diff --git a/nanpy/wire.py b/nanpy/wire.py deleted file mode 100644 index 5781e88..0000000 --- a/nanpy/wire.py +++ /dev/null @@ -1,117 +0,0 @@ -from nanpy.arduinoboard import arduinomethod, returns, FirmwareClass -from nanpy.classinfo import check4firmware - - -@check4firmware -class Wire(FirmwareClass): - - """access to Wire library - http://arduino.cc/en/reference/wire - """ - firmware_id = 'Wire' - cfg_h_name = 'USE_Wire' - - @arduinomethod - def begin(self, address=None): - """Initiate the Wire library and join the I2C bus as a master or slave. - This should normally be called only once. - - :param address: the 7-bit slave address (optional); if not specified, - join the bus as a master. - :returns: None - - http://arduino.cc/en/Reference/WireBegin - - """ - - @returns(int) - @arduinomethod - def requestFrom(self, address, quantity, stop=True): - """Used by the master to request bytes from a slave device. The bytes - may then be retrieved with the available() and read() functions. - - :param address: the 7-bit address of the device to request bytes from - :param quantity: the number of bytes to request - :param stop: boolean. true will send a stop message after the request, - releasing the bus. false will continually send a restart after the request, - keeping the connection active. - :returns: byte : the number of bytes returned from the slave device - - http://arduino.cc/en/Reference/WireRequestFrom - - """ - - @arduinomethod - def beginTransmission(self, address): - """Begin a transmission to the I2C slave device with the given address. - Subsequently, queue bytes for transmission with the write() function - and transmit them by calling endTransmission(). - - :param address: the 7-bit address of the device to transmit to - :returns: None - - http://arduino.cc/en/Reference/WireBeginTransmission - - """ - - @returns(int) - @arduinomethod - def endTransmission(self, stop=True): - """Ends a transmission to a slave device that was begun by - beginTransmission() and transmits the bytes that were queued by - write(). - - :param stop: boolean. true will send a stop message, - releasing the bus after transmission. false will send a restart, - keeping the connection active. - :returns: byte, which indicates the status of the transmission: - 0:success - 1:data too long to fit in transmit buffer - 2:received NACK on transmit of address - 3:received NACK on transmit of data - 4:other error - - http://arduino.cc/en/Reference/WireEndTransmission - - """ - - @returns(int) - @arduinomethod - def write(self, value): - """Writes data from a slave device in response to a request from a - master, or queues bytes for transmission from a master to slave device. - - (in-between calls to beginTransmission() and endTransmission()). - - :param value: a value to send as a single byte - :returns: byte: write() will return the number of bytes written - - http://arduino.cc/en/Reference/WireWrite - - """ - - @returns(int) - @arduinomethod - def available(self, pin, value): - """Returns the number of bytes available for retrieval with read(). - This should be called on a master device after a call to requestFrom() - or on a slave inside the onReceive() handler. - - :returns: The number of bytes available for reading. - - http://arduino.cc/en/Reference/WireAvailable - - """ - - @returns(int) - @arduinomethod - def read(self): - """Reads a byte that was transmitted from a slave device to a master - after a call to requestFrom() or was transmitted from a master to a - slave. - - :returns: The next byte received - - http://arduino.cc/en/Reference/WireRead - - """ diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9a1ffa9..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyserial==3.0.1 diff --git a/setup.py b/setup.py deleted file mode 100644 index fda965c..0000000 --- a/setup.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup, find_packages -import os, sys - - -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -classifiers = [ -# Get more strings from -# http://pypi.python.org/pypi?%3Aaction=list_classifiers -"License :: OSI Approved :: MIT License", -"Natural Language :: English", -"Operating System :: OS Independent", -"Programming Language :: Python", -"Programming Language :: Python :: 2", -"Programming Language :: Python :: 2.7", -"Programming Language :: Python :: 3", -"Programming Language :: Python :: 3.3", -"Programming Language :: Python :: 3.4", -"Programming Language :: Python :: 3.5", -] - -setup(name="nanpy", - version="0.9.6", - description="Use your Arduino board with Python", - long_description=read('README.rst'), - license="MIT", - author="Andrea Stagi", - author_email="stagi.andrea@gmail.com", - url="http://github.com/nanpy/nanpy", - packages = find_packages(), - keywords= "arduino library prototype serial communication rpc", - install_requires=[ - "pyserial", - ], - classifiers=classifiers, - zip_safe = True) diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 9d14451..0000000 --- a/tests/README.md +++ /dev/null @@ -1,9 +0,0 @@ -Testing -============ - - - Install tox (http://tox.readthedocs.org) - - connect Arduino with Nanpy firmware - - edit config.py - - run tox in project directory: - - tox diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_offline/test.py b/tests/test_offline/test.py deleted file mode 100644 index dd7874d..0000000 --- a/tests/test_offline/test.py +++ /dev/null @@ -1,39 +0,0 @@ -from nanpy.arduinopin import to_pin_number -from nanpy.counter import Counter -from nose.tools import eq_ -from tests.util import exc_ - - -def test_to_pin_number(): - eq_(to_pin_number(0), 0) - eq_(to_pin_number(1, A0=None), 1) - eq_(to_pin_number(20, A0=5), 20) - - eq_(to_pin_number('D0', A0=None), 0) - eq_(to_pin_number('D7', A0=8), 7) - exc_(ValueError, lambda: to_pin_number('D7', A0=7)) - eq_(to_pin_number('D20', A0=21), 20) - - eq_(to_pin_number('A0', A0=0), 0) - eq_(to_pin_number('A0', A0=7), 7) - eq_(to_pin_number('A15', A0=5), 20) - exc_(ValueError, lambda: to_pin_number('A7', A0=None)) - - class Dummy(object): - pass - obj = Dummy() - obj.pin_number = 23 - eq_(to_pin_number(obj, A0=0), 23) - - -def test_calculate_multiplier(): - Mhz = 1e6 - - eq_(Counter.calculate_multiplier(16 * Mhz), 1) - eq_(Counter.calculate_multiplier(8 * Mhz), 1) - eq_(Counter.calculate_multiplier(4 * Mhz), 1) - eq_(Counter.calculate_multiplier(2 * Mhz), 1) - eq_(Counter.calculate_multiplier(1 * Mhz), 1) - - eq_(Counter.calculate_multiplier(20 * Mhz), 20 / 16.0) - eq_(Counter.calculate_multiplier(10 * Mhz), 10 / 8.0) diff --git a/tests/test_offline/test_fwinfo.py b/tests/test_offline/test_fwinfo.py deleted file mode 100644 index b205760..0000000 --- a/tests/test_offline/test_fwinfo.py +++ /dev/null @@ -1,46 +0,0 @@ -from nanpy.fwinfo import libc_version, arduino_version, avr_name, libc_date, \ - compile_datetime, firmware_info -from nose.tools import eq_ -import datetime - - -def test(): - eq_(libc_version(10604), '1.6.4') - eq_(libc_version('10604'), '1.6.4') - eq_(libc_version(11111), '1.11.11') - - eq_(libc_date(20081106), datetime.date(2008, 11, 6)) - eq_(libc_date('20081106'), datetime.date(2008, 11, 6)) - - eq_(arduino_version(105), '1.0.5') - eq_(arduino_version('105'), '1.0.5') - eq_(arduino_version(10608), '1.6.8') - eq_(arduino_version('10608'), '1.6.8') - eq_(arduino_version('52417'), '5.24.17') - - eq_(avr_name('__AVR_ATmega328P__'), 'ATmega328P') - - eq_(compile_datetime('Mar 28 2008', '17:40:12'), - datetime.datetime(2008, 3, 28, 17, 40, 12)) - eq_(compile_datetime('Apr 10 2016', '15:54:18'), - datetime.datetime(2016, 4, 10, 15, 54, 18)) - - eq_(firmware_info(dict( - MCU='__AVR_ATmega328P__', - ARDUINO='105', - __DATE__='Mar 28 2014', - __TIME__='17:40:12', - __VERSION__='4.3.2', - __AVR_LIBC_DATE_='20081106', - __AVR_LIBC_VERSION__='10604', - - )), - {'gcc_version': '4.3.2', - 'libc_version': '1.6.4', - 'libc_date': datetime.date(2008, 11, 6), - 'arduino_version': '1.0.5', - 'avr_name': 'ATmega328P', - 'compile_datetime': - datetime.datetime(2014, 3, 28, 17, 40, 12), - } - ) diff --git a/tests/test_offline/test_memo.py b/tests/test_offline/test_memo.py deleted file mode 100644 index c7359df..0000000 --- a/tests/test_offline/test_memo.py +++ /dev/null @@ -1,36 +0,0 @@ -from nanpy.memo import memoized -from nose.tools import eq_ - - -class TestClass(object): - i = 1 - - @memoized - def met(self, x): - TestClass.i += 1 - return TestClass.i - - -def test1(): - o = TestClass() - eq_(o.i, 1) - o.met(3) - eq_(o.i, 2) - o.met(3) - eq_(o.i, 2) - o.met(4) - eq_(o.i, 3) - o.met(4) - o.met(4) - o.met(3) - o.met(3) - o.met(4) - eq_(o.i, 3) - - o2 = TestClass() - eq_(o.i, 3) - o2.met(4) - o2.met(4) - o2.met(4) - o2.met(4) - eq_(o.i, 4) diff --git a/tests/test_offline/test_mockconnection/test_eeprom.py b/tests/test_offline/test_mockconnection/test_eeprom.py deleted file mode 100644 index f4f442a..0000000 --- a/tests/test_offline/test_mockconnection/test_eeprom.py +++ /dev/null @@ -1,16 +0,0 @@ -from nose.tools import eq_, ok_ - -from nanpy.mock.mockconnection import MockConnection -from nanpy.eeprom import EEPROM - - -def test(): - mock = MockConnection() - x = EEPROM(connection=mock) - - mock.objects['EEPROM'].memory = [1, 2, 3] - eq_(x.size, 3) - eq_(x.read(0), 1) - eq_(x.read(1), 2) - eq_(x.read(2), 3) - diff --git a/tests/test_offline/test_mockconnection/test_ram.py b/tests/test_offline/test_mockconnection/test_ram.py deleted file mode 100644 index e1ee0fa..0000000 --- a/tests/test_offline/test_mockconnection/test_ram.py +++ /dev/null @@ -1,18 +0,0 @@ -from nanpy.ram import RAM -from nose.tools import eq_, ok_ - -from nanpy.mock.mockconnection import MockConnection - - -def test(): - mock = MockConnection() - x = RAM(connection=mock) - - mock.objects['RAM'].memory = [1, 2, 3] - mock.objects['RAM'].free = 2 - eq_(x.size, 3) - eq_(x.free(), 2) - eq_(x.read(0), 1) - eq_(x.read(1), 2) - eq_(x.read(2), 3) - diff --git a/tests/test_offline/test_mockconnection/test_servo.py b/tests/test_offline/test_mockconnection/test_servo.py deleted file mode 100644 index fa096db..0000000 --- a/tests/test_offline/test_mockconnection/test_servo.py +++ /dev/null @@ -1,32 +0,0 @@ -from nanpy.servo import Servo -from nose.tools import eq_, ok_ - -from nanpy.mock.mockconnection import MockConnection - - -def test(): - mock = MockConnection() - x = Servo(pin=3, connection=mock) - - ok_(x.attached()) - x.write(42) - eq_(x.read(), 42) - - -def test_more(): - mock = MockConnection() - - def objs(): - return mock.objects['Servo'].objects - - eq_(len(objs()), 0) - - x1 = Servo(pin=5, connection=mock) - - eq_(len(objs()), 1) - - x2 = Servo(pin=6, connection=mock) - - eq_(len(objs()), 2) - - \ No newline at end of file diff --git a/tests/test_offline/test_mockconnection/test_stepper.py b/tests/test_offline/test_mockconnection/test_stepper.py deleted file mode 100644 index c816cc2..0000000 --- a/tests/test_offline/test_mockconnection/test_stepper.py +++ /dev/null @@ -1,12 +0,0 @@ -from nanpy.stepper import Stepper -from nose.tools import eq_, ok_ - -from nanpy.mock.mockconnection import MockConnection - - -def test(): - mock = MockConnection() - x = Stepper(revsteps=100, pin1=3, pin2=4, connection=mock) - x.step(3) - x.setSpeed(3) - diff --git a/tests/test_serial/common.py b/tests/test_serial/common.py deleted file mode 100644 index 0aabcf9..0000000 --- a/tests/test_serial/common.py +++ /dev/null @@ -1,12 +0,0 @@ -from config import config -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import serial_manager - - -def soft_reset(): - serial_manager.sleep_after_connect = config['sleep_after_connect'] - ArduinoTree().soft_reset() - - -def setup(): - soft_reset() diff --git a/tests/test_serial/config.py b/tests/test_serial/config.py deleted file mode 100644 index cde65e8..0000000 --- a/tests/test_serial/config.py +++ /dev/null @@ -1,33 +0,0 @@ -# sleep_after_connect=2 is required for most of the boards ! - - -# custom board with 20MHz quartz and ATMEGA328P -# config = dict( -# A0=14, -# ARDUINO=105, -# F_CPU=20000000.0, -# MCU='__AVR_ATmega328P__', -# avr_name='ATmega328P', -# sleep_after_connect=0, -# ) - -# custom board with 16MHz quartz and ATMEGA328P -config = dict( - A0=14, - ARDUINO=105, - F_CPU=16000000.0, - MCU='__AVR_ATmega328P__', - avr_name='ATmega328P', - sleep_after_connect=0, -) - - -# Uno (not tested) -# config = dict( -# A0=14, -# ARDUINO=105, -# F_CPU=16000000.0, -# MCU='__AVR_ATmega328__', -# avr_name='ATmega328', -# sleep_after_connect=2, -# ) diff --git a/tests/test_serial/test.py b/tests/test_serial/test.py deleted file mode 100644 index dc2328a..0000000 --- a/tests/test_serial/test.py +++ /dev/null @@ -1,21 +0,0 @@ -from config import config -from nanpy.arduinotree import ArduinoTree -from nanpy.register import RegisterFeature -from nanpy.vcc import Vcc -from nose.tools import eq_, ok_ -from tests.util import ok_vcc -import common - - -def setup(): - common.setup() - - -def test_vcc(): - a = ArduinoTree() - ok_vcc(a.vcc.read()) - - -def test_vcc2(): - vcc = Vcc(RegisterFeature()) - ok_vcc(vcc.read()) diff --git a/tests/test_serial/test_arduino.py b/tests/test_serial/test_arduino.py deleted file mode 100644 index aeea59c..0000000 --- a/tests/test_serial/test_arduino.py +++ /dev/null @@ -1,22 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nose.tools import eq_, ok_ -from tests.util import ok_an -import common - - -def setup(): - common.setup() - - -def test(): - a = ArduinoTree() - pin13 = a.pin.get(13) - ok_(a.api.millis() > 1) - - ok_an(a.api.analogRead(0)) - - eq_(pin13.read_mode(), 0) - a.api.pinMode(13, 1) - eq_(pin13.read_mode(), 1) - a.api.pinMode(13, 0) - eq_(pin13.read_mode(), 0) diff --git a/tests/test_serial/test_arduinocore.py b/tests/test_serial/test_arduinocore.py deleted file mode 100644 index 16d5523..0000000 --- a/tests/test_serial/test_arduinocore.py +++ /dev/null @@ -1,37 +0,0 @@ -import common -from nanpy.arduinotree import ArduinoTree -from nose.tools import eq_ -from nose.tools import ok_ - - -def setup(): - common.setup() - - -def test(): - a = ArduinoTree() - eq_(a.core.digitalPinToBitMask(2), 4) - eq_(a.core.digitalPinToPort(2), 4) - eq_(a.core.digitalPinToTimer(2), 0) - eq_(a.core.analogInPinToBit(2), 2) - - -def test_ports(): - a = ArduinoTree() - eq_(a.core.portInputRegister(0), 0) # NOT_A_PORT - eq_(a.core.portInputRegister(1), 0) # NOT_A_PORT - eq_(a.core.portInputRegister(2), 35) # PINB - eq_(a.core.portInputRegister(3), 38) # PINC - eq_(a.core.portInputRegister(4), 41) # PIND - - eq_(a.core.portModeRegister(0), 0) # NOT_A_PORT - eq_(a.core.portModeRegister(1), 0) # NOT_A_PORT - eq_(a.core.portModeRegister(2), 36) # DDRB - eq_(a.core.portModeRegister(3), 39) # DDRC - eq_(a.core.portModeRegister(4), 42) # DDRD - - eq_(a.core.portOutputRegister(0), 0) # NOT_A_PORT - eq_(a.core.portOutputRegister(1), 0) # NOT_A_PORT - eq_(a.core.portOutputRegister(2), 37) # PORTB - eq_(a.core.portOutputRegister(3), 40) # PORTC - eq_(a.core.portOutputRegister(4), 43) # PORTD diff --git a/tests/test_serial/test_counter.py b/tests/test_serial/test_counter.py deleted file mode 100644 index 5d2d4cf..0000000 --- a/tests/test_serial/test_counter.py +++ /dev/null @@ -1,42 +0,0 @@ -from __future__ import with_statement -from nanpy.arduinotree import ArduinoTree -from nanpy.counter import Counter -from nose.tools import ok_, eq_ -from config import config -import common - -OUTPUT = 1 - - -def setup(): - common.setup() - - -def test_counter(): - a = ArduinoTree() - p = a.pin.get(5) - p.write_mode(OUTPUT) - p.pwm.write_value(128) - - counter1 = a.counter - counter2 = Counter(F_CPU=config['F_CPU']) - - print ('frequencies_available: %s' % p.pwm.frequencies_available) - for fset in p.pwm.frequencies_available: - p.pwm.frequency = fset - print('---------------------------') - print('fset=%s' % fset) - print('---------------------------') - for ms in [10, 20, 50, 100, 200, 500, 1000]: - print ('gate=%s ms' % ms) - t = ms / 1000.0 - error = a.counter.error(t) - print ('error=%s' % error) - - f1 = counter1.read_frequency(t) - f2 = counter2.read_frequency(t) - print (f1, f2) - diff1 = abs(f1 - fset) - diff2 = abs(f2 - fset) - ok_(diff1 <= (1.1 * error)) - ok_(diff2 <= (1.1 * error)) diff --git a/tests/test_serial/test_define.py b/tests/test_serial/test_define.py deleted file mode 100644 index 9a45ad1..0000000 --- a/tests/test_serial/test_define.py +++ /dev/null @@ -1,44 +0,0 @@ -from config import config -from nose.tools import eq_, ok_ -import common -from nanpy.arduinotree import ArduinoTree -from nanpy.define import DefineFeature - - -def setup(): - common.setup() - - -def test_defs(): - a = ArduinoTree() - - eq_(a.define.get('A0'), config['A0']) - - d = a.define.as_dict - print (d) - - eq_(a.define.get('ARDUINO'), config['ARDUINO']) - eq_(d['ARDUINO'], config['ARDUINO']) - - eq_(d['A0'], config['A0']) - eq_(d['F_CPU'], config['F_CPU']) - eq_(d['MCU'], config['MCU']) - ok_('xx' not in d) - ok_(len(d.keys()) > 15, len(d.keys())) - - ARDUINO = a.define.get('ARDUINO') - ok_(ARDUINO >= 100) - ok_(ARDUINO < 200) - - NUM_DIGITAL_PINS = a.define.get('NUM_DIGITAL_PINS') - ok_(NUM_DIGITAL_PINS >= 10) - ok_(NUM_DIGITAL_PINS < 1000) - - for x in d: - assert x.strip(), 'empty define:-->%s<--' % x - - -def test_defs2(): - a = ArduinoTree() - define = DefineFeature() - eq_(define.as_dict, a.define.as_dict) diff --git a/tests/test_serial/test_eeprom.py b/tests/test_serial/test_eeprom.py deleted file mode 100644 index 5382155..0000000 --- a/tests/test_serial/test_eeprom.py +++ /dev/null @@ -1,14 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nose.tools import eq_ -import common - - -def setup(): - common.setup() - - -def test(): - a = ArduinoTree() - - eq_(a.eeprom.size, 1024) - eq_(a.eeprom.read(17), 255) diff --git a/tests/test_serial/test_examples.py b/tests/test_serial/test_examples.py deleted file mode 100644 index 326e6bb..0000000 --- a/tests/test_serial/test_examples.py +++ /dev/null @@ -1,45 +0,0 @@ -from nanpy.examples.boottime import boot_time -from nanpy.examples.checkspeed import checkspeed -from nanpy.examples.counterdemo import counterdemo -from nanpy.examples.dds import dds -from nanpy.examples.dump import dumpall -from nanpy.examples.highfreqpwm import highfreqpwm -from nanpy.examples.ramdump import ramdump -from nanpy.examples.reset import reset_demo -import common - - -def setup(): - common.setup() - - -def test_dump(): - dumpall() - - -def test_boot_time(): - boot_time() - - -def test_reset_demo(): - reset_demo() - - -def test_highfreqpwm(): - highfreqpwm() - - -def test_counter(): - counterdemo() - - -def test_dds(): - dds() - - -def test_checkspeed(): - checkspeed(n=1) - - -def test_ramdump(): - ramdump() diff --git a/tests/test_serial/test_pin.py b/tests/test_serial/test_pin.py deleted file mode 100644 index 4482d9a..0000000 --- a/tests/test_serial/test_pin.py +++ /dev/null @@ -1,139 +0,0 @@ -from nose.tools import eq_ -from nose.tools import ok_ -from tests.util import ok_an, exc_ -from nanpy.arduinotree import ArduinoTree -import common - - -def setup(): - common.setup() - - -INPUT, OUTPUT = 0, 1 - - -def test_pin_nr(): - a = ArduinoTree() - pin = a.pin.get(8) - - eq_(pin.pin_number, 8) - eq_(pin.pin_number_analog, None) - - pin = a.pin.get(14) - eq_(pin.pin_number, 14) - eq_(pin.pin_number_analog, 0) - - pin = a.pin.get('A1') - eq_(pin.pin_number, 15) - eq_(pin.pin_number_analog, 1) - - pin = a.pin.get('D9') - eq_(pin.pin_number, 9) - eq_(pin.pin_number_analog, None) - - pin = a.pin.get('A2') - eq_(pin.pin_number, 16) - eq_(pin.pin_number_analog, 2) - - -def test_is(): - a = ArduinoTree() - eq_(a.pin.get(8).is_digital, True) - eq_(a.pin.get(8).is_analog, False) - eq_(a.pin.get('A2').is_digital, False) - eq_(a.pin.get('A2').is_analog, True) - - -def test_name(): - a = ArduinoTree() - eq_(a.pin.get(8).name, 'D8') - eq_(a.pin.get('D8').name, 'D8') - eq_(a.pin.get(15).name, 'A1') - eq_(a.pin.get('A2').name, 'A2') - - -def test_dig(): - a = ArduinoTree() - pin = a.pin.get(8) - pin.reset() - - pin.write_mode(OUTPUT) - - pin.write_digital_value(1) - - eq_(pin.read_digital_value(), 1) - eq_(pin.digital_value, 1) - - pin.write_mode(INPUT) - pin.write_mode(OUTPUT) - - pin.write_digital_value(0) - eq_(pin.read_digital_value(), 0) - eq_(pin.digital_value, 0) - - pin.write_mode(INPUT) - pin.write_mode(OUTPUT) - - pin.write_mode(INPUT) - pin.write_pullup(True) - - eq_(pin.read_digital_value(), 1) - eq_(pin.digital_value, 1) - - -def test_an(): - a = ArduinoTree() - pin = a.pin.get('A0') - pin.mode = INPUT - ok_an(pin.read_analog_value()) - ok_an(pin.analog_value) - - pin.write_pullup(True) - - ok_an(pin.read_analog_value(), pullup=True) - - -def test_mode(): - a = ArduinoTree() - DDRB = a.register.get('DDRB') - pin = a.pin.get(8) - pin.reset() - - eq_(pin.mode, INPUT) - eq_(pin.read_mode(), INPUT) - eq_(DDRB.value, 0) - - pin.write_mode(OUTPUT) - eq_(pin.mode, OUTPUT) - eq_(pin.read_mode(), OUTPUT) - eq_(DDRB.value, 1) - - DDRB.value = 0 - eq_(pin.mode, INPUT) - - pin.mode = OUTPUT - eq_(pin.mode, OUTPUT) - - pin.reset() - eq_(pin.mode, INPUT) - - -def test_pullup(): - a = ArduinoTree() - pin = a.pin.get(8) - pin.write_pullup(True) - - -def test_pin_range(): - a = ArduinoTree() - eq_(a.pin.count, 20) - eq_(a.pin.count_analog, 6) - eq_(a.pin.count_digital, 14) - -# eq_(a.pin.get.range_all, range(0, 20)) -# eq_(a.pin.get.range_analog, range(14, 20)) -# eq_(a.pin.get.range_digital, range(0, 14)) - - a.pin.get('A5') - exc_(ValueError, lambda: a.pin.get('A6')) - exc_(ValueError, lambda: a.pin.get('D14')) diff --git a/tests/test_serial/test_pwm.py b/tests/test_serial/test_pwm.py deleted file mode 100644 index f96f09a..0000000 --- a/tests/test_serial/test_pwm.py +++ /dev/null @@ -1,73 +0,0 @@ -from config import config -from nose.tools import eq_ -from nanpy.arduinotree import ArduinoTree -import common - - -def setup(): - common.setup() - - -INPUT, OUTPUT = 0, 1 -F_CPU = config.get('F_CPU') - - -def test_pwm(): - a = ArduinoTree() - pin8 = a.pin.get(8) - pin9 = a.pin.get(9) - - TCCR1B = a.register.get('TCCR1B') - - eq_(pin8.pwm.available, False) - eq_(pin9.pwm.available, True) - eq_(pin9.pwm.timer_register_name_b, 'TCCR1B') - eq_(pin9.pwm.base_divisor, 512) - eq_(pin9.pwm.divisors_available, [1, 8, 64, 256, 1024]) - - frequencies = sorted([F_CPU / 2 ** 9, - F_CPU / 2 ** 12, - F_CPU / 2 ** 15, - F_CPU / 2 ** 17, - F_CPU / 2 ** 19, - ]) - eq_(pin9.pwm.frequencies_available, frequencies) - - TCCR1B.value = 3 - eq_(TCCR1B.value, 3) - - eq_(pin9.pwm.read_divisor(), 2 ** 6) - eq_(pin9.pwm.divisor, 2 ** 6) - eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 15) - eq_(pin9.pwm.frequency, F_CPU / 2 ** 15) - - pin9.pwm.write_frequency(int(F_CPU / 2 ** 19)) - eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 19) - eq_(TCCR1B.value, 5) - - TCCR1B.value = 2 - eq_(pin9.pwm.read_divisor(), 2 ** 3) - eq_(pin9.pwm.divisor, 2 ** 3) - eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 12) - eq_(pin9.pwm.frequency, F_CPU / 2 ** 12) - eq_(TCCR1B.value, 2) - - pin9.pwm.divisor = 2 ** 10 - eq_(pin9.pwm.read_divisor(), 2 ** 10) - eq_(pin9.pwm.divisor, 2 ** 10) - eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 19) - eq_(pin9.pwm.frequency, F_CPU / 2 ** 19) - eq_(TCCR1B.value, 5) - - pin9.pwm.write_frequency(F_CPU / 2 ** 9) - eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 9) - eq_(TCCR1B.value, 1) - - pin9.pwm.frequency = F_CPU / 2 ** 17 - eq_(pin9.pwm.read_frequency(), F_CPU / 2 ** 17) - eq_(TCCR1B.value, 4) - - TCCR1B.value = 3 - eq_(TCCR1B.value, 3) - - pin9.pwm.write_value(45) diff --git a/tests/test_serial/test_register.py b/tests/test_serial/test_register.py deleted file mode 100644 index 606486c..0000000 --- a/tests/test_serial/test_register.py +++ /dev/null @@ -1,52 +0,0 @@ -from nose.tools import eq_, ok_, eq_, ok_ -from tests.util import exc_ -from nanpy.arduinotree import ArduinoTree -import common - - -def setup(): - common.setup() - - -def test_registers(): - a = ArduinoTree() - print (a.register.names) - ok_(len(a.register.names) > 77) - - eq_(a.register.get('DDRB').read_value(), 0) - eq_(a.register.get('DDRB').value, 0) - exc_(ValueError, lambda x: a.register.get('xxx').value, 0) - - a.register.get('DDRB').write_value(5) - eq_(a.register.get('DDRB').value, 5) - a.register.get('DDRB').value = 3 - eq_(a.register.get('DDRB').value, 3) - a.register.get('DDRB').write_value(0) - - eq_(a.register.get('DDRB').address, 0x24) - eq_(a.register.get('DDRB').name, 'DDRB') - eq_(a.register.get('DDRB').size, 1) - - # 9 bit - eq_(a.register.get('EEAR').size, 2) - a.register.get('EEAR').value = 511 - eq_(a.register.get('EEAR').value, 511) - - -def test_register_proxy(): - a = ArduinoTree() - r = a.register.proxy - - eq_(r.DDRB, 0) - - r.DDRB = 5 - eq_(r.DDRB, 5) - r.DDRB = 3 - eq_(r.DDRB, 3) - eq_(a.register.get('DDRB').value, 3) - - r.DDRB = 0 - - # 9 bit - r.EEAR = 511 - eq_(r.EEAR, 511) diff --git a/tests/test_serial/test_reset.py b/tests/test_serial/test_reset.py deleted file mode 100644 index 6079222..0000000 --- a/tests/test_serial/test_reset.py +++ /dev/null @@ -1,16 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -import common - - -def setup(): - common.setup() - -# set it to 1000 for a good test (4 minutes) -REPEAT_TEST = 10 - - -def test_long(): - a = ArduinoTree() - for x in range(REPEAT_TEST): - print (x, ('uptime: %s sec' % (a.api.millis() / 1000.0))) - a.soft_reset() diff --git a/tests/test_serial/test_shiftout.py b/tests/test_serial/test_shiftout.py deleted file mode 100644 index a252454..0000000 --- a/tests/test_serial/test_shiftout.py +++ /dev/null @@ -1,31 +0,0 @@ -from __future__ import with_statement -from config import config -from nanpy.arduinotree import ArduinoTree -from nanpy.shiftout import ShiftOut -from nose.tools import ok_ -from nose.tools import eq_ -import common - - -A0 = config['A0'] - - -def setup(): - common.setup() - - -def test_shift1(): - s = ShiftOut('D13', 'D12', 0, A0=A0) - s.write_data(0b01010101) - - -def test_shift2(): - s = ShiftOut(13, 'A1', 0, A0=A0) - s.write_data(0b01010101) - - -def test_shift3(): - a = ArduinoTree() - p = a.pin.get(13) - s = ShiftOut(p, 12, 0, A0=A0) - s.write_data(0b01010101) diff --git a/tests/test_serial/test_watchdog.py b/tests/test_serial/test_watchdog.py deleted file mode 100644 index 84b1298..0000000 --- a/tests/test_serial/test_watchdog.py +++ /dev/null @@ -1,21 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nanpy.watchdog import Watchdog -import common - - -def setup(): - common.setup() - - -def test(): - a = ArduinoTree(connection=None) - a.watchdog.reset() - a.watchdog.enable(a.watchdog.WDTO_1S) - a.watchdog.disable() - - -def test2(): - watchdog = Watchdog(connection=None) - watchdog.reset() - watchdog.enable(watchdog.WDTO_1S) - watchdog.disable() diff --git a/tests/util.py b/tests/util.py deleted file mode 100644 index a8977e0..0000000 --- a/tests/util.py +++ /dev/null @@ -1,41 +0,0 @@ -from nanpy.arduinotree import ArduinoTree -from nanpy.serialmanager import serial_manager -from nose.tools import ok_ -import tempfile - - -def exc_(excClass, callableObj, *args, **kwargs): - """Fail unless an exception of class excClass is thrown by callableObj when - invoked with arguments args and keyword arguments kwargs. - - If a different type of exception is thrown, it will not be caught, - and the test case will be deemed to have suffered an error, exactly - as for an unexpected exception. - - """ - try: - callableObj(*args, **kwargs) - except excClass: - return - else: - if hasattr(excClass, '__name__'): - excName = excClass.__name__ - else: - excName = str(excClass) - raise Exception('%s not raised' % excName) - - -def ok_an(x, pullup=False): - print (x) - ok_(x in range(1024)) - - -def ok_vcc(vcc): - print ('vcc=', vcc) - ok_(vcc < 5.5) - ok_(vcc > 3) - - -def tmpdir(dir=None, suffix=''): - x = tempfile.mkdtemp(suffix=suffix, prefix='nanpy_test_', dir=dir) - return x diff --git a/tox.ini b/tox.ini deleted file mode 100644 index e4f2075..0000000 --- a/tox.ini +++ /dev/null @@ -1,16 +0,0 @@ - -[tox] -envlist = py27,py33,py34,py35 - -[testenv] -deps= - nose - pyserial - -changedir=tests/test_offline - -# if you have an Arduino connected -#changedir=tests - -commands=nosetests -v - From 2c21e7533b445feeeb50983acd3692a233d71d72 Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Thu, 13 Aug 2020 11:28:10 -0500 Subject: [PATCH 342/344] Merge esp updates to main branch --- ArduinoClass.cpp | 54 - ArduinoClass.h | 17 - ArduinoCoreClass.cpp | 42 - ArduinoCoreClass.h | 14 - BaseClass.cpp | 6 - BaseClass.h | 71 - CapacitiveSensorClass.cpp | 31 - CapacitiveSensorClass.h | 19 - ColorSensorClass.cpp | 23 - ColorSensorClass.h | 19 - ColorSensorWrapper.cpp | 40 - ColorSensorWrapper.h | 12 - ComChannel.cpp | 233 - ComChannel.h | 28 - CounterClass.cpp | 35 - CounterClass.h | 14 - DHTClass.cpp | 39 - DHTClass.h | 19 - DallasTemperatureClass.cpp | 99 - DallasTemperatureClass.h | 19 - DefineClass.cpp | 130 - DefineClass.h | 14 - EEPROMClass.cpp | 28 - EEPROMClass.h | 17 - EspClass.cpp | 237 - EspClass.h | 18 - FreqCount.cpp | 115 - FreqCount.h | 13 - InfoClass.cpp | 26 - InfoClass.h | 14 - LiquidCrystalClass.cpp | 71 - LiquidCrystalClass.h | 20 - LiquidCrystalClass_I2C.cpp | 57 - LiquidCrystalClass_I2C.h | 20 - MCP41xxxClass.cpp | 32 - MCP41xxxClass.h | 17 - MethodDescriptor.cpp | 127 - MethodDescriptor.h | 44 - Nanpy/ArduinoClass.cpp | 3 +- Nanpy/ArduinoCoreClass.h | 1 - CONTRIBUTORS => Nanpy/CONTRIBUTORS | 0 Nanpy/ComChannel.cpp | 79 +- Nanpy/ComChannel.h | 1 - Nanpy/CounterClass.h | 1 - Nanpy/DHTClass.cpp | 4 +- Nanpy/DefineClass.h | 1 - Nanpy/EspClass.cpp | 117 + Nanpy/FreqCount.h | 1 - Nanpy/InfoClass.h | 1 - LICENSE => Nanpy/LICENSE | 0 Nanpy/MethodDescriptor.cpp | 1 - Nanpy-MudPi.ino => Nanpy/Nanpy-MudPi.ino | 0 README.md => Nanpy/README.md | 0 Nanpy/RegisterClass.cpp | 1 - Nanpy/RegisterClass.h | 1 - Nanpy/ServoClass.cpp | 1 - Nanpy/cfg_check.h | 14 +- Nanpy/cfg_defaults.h | 2 +- configure.sh => Nanpy/configure.sh | 0 Nanpy/consts.h | 1 - Nanpy/freeram.c | 2 +- Nanpy/freeram.h | 1 - Nanpy/generated_avr_registers.h | 2 +- Nanpy/generated_mcu.h | 2 +- Nanpy/intdefs.h | 2 - sample_cfg.h => Nanpy/sample_cfg.h | 0 OneWireClass.cpp | 76 - OneWireClass.h | 19 - RAMClass.cpp | 43 - RAMClass.h | 17 - RegisterClass.cpp | 112 - RegisterClass.h | 13 - ServoClass.cpp | 52 - ServoClass.h | 19 - SlimArray.h | 92 - StepperClass.cpp | 40 - StepperClass.h | 19 - TLC5947Class.cpp | 36 - TLC5947Class.h | 17 - ToneClass.cpp | 32 - ToneClass.h | 110 - ToneWrapper.cpp | 20 - ToneWrapper.h | 20 - UltrasonicClass.cpp | 22 - UltrasonicClass.h | 19 - UltrasonicWrapper.cpp | 48 - UltrasonicWrapper.h | 12 - WatchdogClass.cpp | 48 - WatchdogClass.h | 16 - WireClass.cpp | 60 - WireClass.h | 19 - cfg.h | 86 - cfg_all.h | 5 - cfg_check.h | 44 - cfg_defaults.h | 105 - consts.h | 3 - freeram.c | 65 - freeram.h | 14 - generated_avr_registers.h | 13764 --------------------- generated_intdefs.h | 69 - generated_mcu.h | 1287 -- intdefs.h | 11 - timers.h | 501 - 103 files changed, 189 insertions(+), 18819 deletions(-) delete mode 100644 ArduinoClass.cpp delete mode 100644 ArduinoClass.h delete mode 100644 ArduinoCoreClass.cpp delete mode 100644 ArduinoCoreClass.h delete mode 100644 BaseClass.cpp delete mode 100644 BaseClass.h delete mode 100644 CapacitiveSensorClass.cpp delete mode 100644 CapacitiveSensorClass.h delete mode 100644 ColorSensorClass.cpp delete mode 100644 ColorSensorClass.h delete mode 100644 ColorSensorWrapper.cpp delete mode 100644 ColorSensorWrapper.h delete mode 100644 ComChannel.cpp delete mode 100644 ComChannel.h delete mode 100644 CounterClass.cpp delete mode 100644 CounterClass.h delete mode 100644 DHTClass.cpp delete mode 100644 DHTClass.h delete mode 100644 DallasTemperatureClass.cpp delete mode 100644 DallasTemperatureClass.h delete mode 100644 DefineClass.cpp delete mode 100644 DefineClass.h delete mode 100644 EEPROMClass.cpp delete mode 100644 EEPROMClass.h delete mode 100644 EspClass.cpp delete mode 100644 EspClass.h delete mode 100644 FreqCount.cpp delete mode 100644 FreqCount.h delete mode 100644 InfoClass.cpp delete mode 100644 InfoClass.h delete mode 100644 LiquidCrystalClass.cpp delete mode 100644 LiquidCrystalClass.h delete mode 100644 LiquidCrystalClass_I2C.cpp delete mode 100644 LiquidCrystalClass_I2C.h delete mode 100644 MCP41xxxClass.cpp delete mode 100644 MCP41xxxClass.h delete mode 100644 MethodDescriptor.cpp delete mode 100644 MethodDescriptor.h rename CONTRIBUTORS => Nanpy/CONTRIBUTORS (100%) rename LICENSE => Nanpy/LICENSE (100%) rename Nanpy-MudPi.ino => Nanpy/Nanpy-MudPi.ino (100%) rename README.md => Nanpy/README.md (100%) rename configure.sh => Nanpy/configure.sh (100%) rename sample_cfg.h => Nanpy/sample_cfg.h (100%) delete mode 100644 OneWireClass.cpp delete mode 100644 OneWireClass.h delete mode 100644 RAMClass.cpp delete mode 100644 RAMClass.h delete mode 100644 RegisterClass.cpp delete mode 100644 RegisterClass.h delete mode 100644 ServoClass.cpp delete mode 100644 ServoClass.h delete mode 100644 SlimArray.h delete mode 100644 StepperClass.cpp delete mode 100644 StepperClass.h delete mode 100644 TLC5947Class.cpp delete mode 100644 TLC5947Class.h delete mode 100644 ToneClass.cpp delete mode 100644 ToneClass.h delete mode 100644 ToneWrapper.cpp delete mode 100644 ToneWrapper.h delete mode 100644 UltrasonicClass.cpp delete mode 100644 UltrasonicClass.h delete mode 100644 UltrasonicWrapper.cpp delete mode 100644 UltrasonicWrapper.h delete mode 100644 WatchdogClass.cpp delete mode 100644 WatchdogClass.h delete mode 100644 WireClass.cpp delete mode 100644 WireClass.h delete mode 100644 cfg.h delete mode 100644 cfg_all.h delete mode 100644 cfg_check.h delete mode 100644 cfg_defaults.h delete mode 100644 consts.h delete mode 100644 freeram.c delete mode 100644 freeram.h delete mode 100644 generated_avr_registers.h delete mode 100644 generated_intdefs.h delete mode 100644 generated_mcu.h delete mode 100644 intdefs.h delete mode 100644 timers.h diff --git a/ArduinoClass.cpp b/ArduinoClass.cpp deleted file mode 100644 index 46ff927..0000000 --- a/ArduinoClass.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include "ArduinoClass.h" -#include - - -const char* nanpy::ArduinoClass::get_firmware_id() -{ - return "A"; -} - -void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "dw") == 0) { // digitalWrite - digitalWrite(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "r") == 0) { // digitalRead - m->returns(digitalRead(m->getInt(0))); - } -#ifndef ESP32 - if (strcmp(m->getName(), "aw") == 0) { // analogWrite - analogWrite(m->getInt(0), m->getInt(1)); - m->returns(0); - } -#endif - - if (strcmp(m->getName(), "a") == 0) { // analogRead - m->returns(analogRead(m->getInt(0))); - } - - if (strcmp(m->getName(), "pm") == 0) { // pinMode - pinMode(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "delay") == 0) { - m->returns(0); - } - - if (strcmp(m->getName(), "m") == 0) { // millis - m->returns(millis()); - } - - if (strcmp(m->getName(), "pi") == 0) { // pulseIn - pulseIn(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "s") == 0) { // shiftOut - // shiftOut(dataPin, clockPin, bitOrder, value) - shiftOut(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); - m->returns(0); - } -}; diff --git a/ArduinoClass.h b/ArduinoClass.h deleted file mode 100644 index c3ca79a..0000000 --- a/ArduinoClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ARDUINO_CLASS -#define ARDUINO_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class ArduinoClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - -#endif diff --git a/ArduinoCoreClass.cpp b/ArduinoCoreClass.cpp deleted file mode 100644 index 287f49a..0000000 --- a/ArduinoCoreClass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "cfg_all.h" - -#if USE_ArduinoCore - -#include -#include "ArduinoCoreClass.h" -#include - -#define RETURN_PIN_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns(x(m->getInt(0))); } -#define RETURN_PORT_FUNC(x) if (strcmp(m->getName(), #x) == 0) { m->returns((uint32_t)x(m->getInt(0))); } - -const char* nanpy::ArduinoCoreClass::get_firmware_id() -{ - return "Core"; -} - -void nanpy::ArduinoCoreClass::elaborate(nanpy::MethodDescriptor* m) -{ - RETURN_PIN_FUNC(digitalPinToBitMask); - RETURN_PIN_FUNC(digitalPinToPort); - RETURN_PIN_FUNC(digitalPinToTimer); - - if (strcmp(m->getName(), "analogInPinToBit") == 0) - { -#ifdef analogInPinToBit - m->returns(analogInPinToBit(m->getInt(0))); -#else - m->returns(-1); -#endif - } -// RETURN_PIN_FUNC(analogInPinToBit); - -// if (strcmp(m->getName(), "portModeRegister") == 0) -// { -// m->returns((uint32_t)portModeRegister(m->getInt(0))); -// } - RETURN_PORT_FUNC(portModeRegister); - RETURN_PORT_FUNC(portOutputRegister); - RETURN_PORT_FUNC(portInputRegister); -} - -#endif diff --git a/ArduinoCoreClass.h b/ArduinoCoreClass.h deleted file mode 100644 index 25af72f..0000000 --- a/ArduinoCoreClass.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class ArduinoCoreClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; diff --git a/BaseClass.cpp b/BaseClass.cpp deleted file mode 100644 index 333413f..0000000 --- a/BaseClass.cpp +++ /dev/null @@ -1,6 +0,0 @@ - -#include "BaseClass.h" - -using namespace nanpy; - -SlimArray Register::classes; diff --git a/BaseClass.h b/BaseClass.h deleted file mode 100644 index 1ae6765..0000000 --- a/BaseClass.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef BASE_CLASS -#define BASE_CLASS - -#include "cfg_all.h" -#include "SlimArray.h" -#include "MethodDescriptor.h" - -namespace nanpy { - - class BaseClass { - - public: - virtual void elaborate( nanpy::MethodDescriptor* m ) = 0; - virtual const char* get_firmware_id() = 0; - - }; - - template class ObjectsManager : public BaseClass { - - protected: - nanpy::SlimArray v; - - public: - ObjectsManager() {} - void elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "remove") == 0) { - delete(v[m->getObjectId()]); - v.remove(m->getObjectId()); - COMM_SERIAL.println("0"); - } - } - - }; - - - class Register { - static nanpy::SlimArray classes; - - public: - - template static void registerClass() { - nanpy::BaseClass* obj = (nanpy::BaseClass*)new T(); - classes.insert(obj); - } - - static nanpy::SlimArray * get_classes() { - return &classes; - } - - static void elaborate(nanpy::MethodDescriptor* m) { - for(int i = 0 ; i < classes.getSize() ; i++) - { - if (strcmp(m->getClass(), classes[i]->get_firmware_id()) == 0) - { - classes[i]->elaborate(m); - } - } - - if(m != NULL) { - delete(m); - m = NULL; - } - } - - }; -} - -#define REGISTER_CLASS_CONDITIONAL(cls, condition) if(condition) Register::registerClass(); -#define REGISTER_CLASS(cls) REGISTER_CLASS_CONDITIONAL(cls, 1); - -#endif diff --git a/CapacitiveSensorClass.cpp b/CapacitiveSensorClass.cpp deleted file mode 100644 index 44292ed..0000000 --- a/CapacitiveSensorClass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "cfg_all.h" - -#if USE_CapacitiveSensor - -#include -#include -#include "CapacitiveSensorClass.h" - -const char* nanpy::CapacitiveSensorClass::get_firmware_id() -{ - return "CapacitiveSensor"; -} - -void nanpy::CapacitiveSensorClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new CapacitiveSensor(m->getInt(0), m->getInt(1))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "capacitiveSensor") == 0) { - m->returns(v[m->getObjectId()]->capacitiveSensor(m->getInt(0))); - } - - if (strcmp(m->getName(), "capacitiveSensorRaw") == 0) { - m->returns(v[m->getObjectId()]->capacitiveSensorRaw(m->getInt(0))); - } -}; - -#endif diff --git a/CapacitiveSensorClass.h b/CapacitiveSensorClass.h deleted file mode 100644 index 92ab2df..0000000 --- a/CapacitiveSensorClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CAPACITIVE_SENSOR_CLASS -#define CAPACITIVE_SENSOR_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class CapacitiveSensor; - -namespace nanpy { - class CapacitiveSensorClass : public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/ColorSensorClass.cpp b/ColorSensorClass.cpp deleted file mode 100644 index d4f2ef7..0000000 --- a/ColorSensorClass.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "cfg_all.h" - -#include -#include "ColorSensorClass.h" -#include - -const char* nanpy::ColorSensorClass::get_firmware_id() { - return "ColorSensor"; -} - -void nanpy::ColorSensorClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new ColorSensorWrapper(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3), m->getInt(4))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "get_color") == 0) { - char* p = m->getString(0); - m->returns(v[m->getObjectId()]->getColor(*p)); - } -} diff --git a/ColorSensorClass.h b/ColorSensorClass.h deleted file mode 100644 index 63e8c48..0000000 --- a/ColorSensorClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef COLORSENSOR_CLASS -#define COLORSENSOR_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" -#include "ColorSensorWrapper.h" - -class ColorSensor; - -namespace nanpy { - class ColorSensorClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - }; -} - -#endif diff --git a/ColorSensorWrapper.cpp b/ColorSensorWrapper.cpp deleted file mode 100644 index 3d96e23..0000000 --- a/ColorSensorWrapper.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "cfg_all.h" - -#if USE_ColorSensor - -#include "ColorSensorWrapper.h" -#include - -nanpy::ColorSensorWrapper::ColorSensorWrapper(int s0Pin, int s1Pin, int s2Pin, int s3Pin, int sensorOutPin) { - s0 = s0Pin; - s1 = s1Pin; - s2 = s2Pin; - s3 = s3Pin; - sensorOut = sensorOutPin; - - pinMode(s0, OUTPUT); - pinMode(s1, OUTPUT); - pinMode(s2, OUTPUT); - pinMode(s3, OUTPUT); - pinMode(sensorOut, INPUT); - - digitalWrite(s0, HIGH); - digitalWrite(s1, LOW); -} - -int nanpy::ColorSensorWrapper::getColor(char color) { - if (color == 'r') { - digitalWrite(s2, HIGH); - digitalWrite(s3, LOW); - } else if (color == 'g') { - digitalWrite(s2, HIGH); - digitalWrite(s3, HIGH); - } else if (color == 'b') { - digitalWrite(s2, LOW); - digitalWrite(s3, HIGH); - } - - return pulseIn(sensorOut, LOW); -} - -#endif diff --git a/ColorSensorWrapper.h b/ColorSensorWrapper.h deleted file mode 100644 index 2212d04..0000000 --- a/ColorSensorWrapper.h +++ /dev/null @@ -1,12 +0,0 @@ -namespace nanpy { - - class ColorSensorWrapper { - - private: - int s0, s1, s2, s3, sensorOut; - - public: - ColorSensorWrapper(int s0, int s1, int s2, int s3, int sensorOut); - int getColor(char color); - }; -} diff --git a/ComChannel.cpp b/ComChannel.cpp deleted file mode 100644 index 174c0bc..0000000 --- a/ComChannel.cpp +++ /dev/null @@ -1,233 +0,0 @@ -#include "ComChannel.h" -#include - -#if USE_WIFI_CONNECTION - -#ifdef ESP8266 -#include -#include -#else -#ifdef ESP32 -#include -#include -#endif -#endif - -#define DNS_NAME "mudpi" -#define SERVER_PORT 5678 -#define SerialDebug Serial -#define TIMEOUT 50 - -WiFiServer server(SERVER_PORT); -WiFiClient client; - -unsigned long currentTime = millis(); -unsigned long previousTime = 0; -const long timeoutTime = 10000; - -void nanpy::ComChannel::connect() -{ - SerialDebug.begin(115200); - SerialDebug.println(""); - WiFi.disconnect(); //Flush WiFi - delay(2000); - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - SerialDebug.print("\nConnecting to "); - SerialDebug.println(WIFI_SSID); - uint8_t i = 0; - while (WiFi.status() != WL_CONNECTED && i++ < TIMEOUT) - { - delay(1000); - Serial.print("."); - } - if(i > TIMEOUT) - { - SerialDebug.println(""); - SerialDebug.print("Could not connect to "); - SerialDebug.println(WIFI_SSID); - while(1) - { - delay(500); - } - } - - SerialDebug.println(""); - - if (MDNS.begin(DNS_NAME)) - { - SerialDebug.println("MDNS responder started"); - SerialDebug.print("ping "); - SerialDebug.print(DNS_NAME); - SerialDebug.println(".local"); - } - - SerialDebug.println(""); - - //start UART and the server - server.begin(); - server.setNoDelay(true); - - SerialDebug.print("ping "); - SerialDebug.println(WiFi.localIP()); - - SerialDebug.print("port:"); - SerialDebug.println(SERVER_PORT); -} - -bool nanpy::ComChannel::available() -{ - currentTime = millis(); - if (previousTime == 0) { - previousTime = currentTime; - } - if(client) { - previousTime = currentTime; - // read data from the connected client - if (client.connected() && currentTime - previousTime <= timeoutTime) { - previousTime = currentTime; - return (client.available() > 0); - } - else { - client.stop(); - Serial.println("Client Disconnected."); - } - } - else - { - // try to connect to a new client - client = server.available(); - if (client.connected()) { - SerialDebug.println("Client connected"); - } - } - return false; -} - -char nanpy::ComChannel::read_buffer[MAX_READ_BUFFER_SIZE] = {0}; - -void readLineFromSerial(char* extbuff) { - if(client) { - if(client.connected()) { - int i=0; - char ch = '0'; - char* buff = nanpy::ComChannel::read_buffer; - do { - ch = client.read(); - if(ch < 255 && ch >= 0) { - buff[i++] = ch; - } - if (i == MAX_READ_BUFFER_SIZE - 1) { - buff[i] = '\0'; - break; - } - } while(ch != '\0'); - strcpy(extbuff, buff); - } - } -}; - -void nanpy::ComChannel::readLine(char* extbuff) { - readLineFromSerial(extbuff); -} - -void nanpy::ComChannel::println(String& val) { - client.println(val); -} - -void nanpy::ComChannel::println(const char* val) { - client.println(val); -} - -void nanpy::ComChannel::println(int val) { - client.println(val); -} - -void nanpy::ComChannel::println(unsigned int val) { - client.println(val); -} - -void nanpy::ComChannel::println(float val) { - client.println(val); -} - -void nanpy::ComChannel::println(double val) { - client.println(val); -} - -void nanpy::ComChannel::println(long val) { - client.println(val); -} - -void nanpy::ComChannel::println(unsigned long val) { - client.println(val); -} - - -#else -char nanpy::ComChannel::read_buffer[MAX_READ_BUFFER_SIZE] = {0}; - -void readLineFromSerial(char* extbuff) { - int i=0; - char ch = '0'; - char* buff = nanpy::ComChannel::read_buffer; - do { - ch = COMM_SERIAL.read(); - if(ch < 255 && ch >= 0) { - buff[i++] = ch; - } - if (i == MAX_READ_BUFFER_SIZE - 1) { - buff[i] = '\0'; - break; - } - } while(ch != '\0'); - strcpy(extbuff, buff); -}; - -bool nanpy::ComChannel::available() { - if (COMM_SERIAL.available() > 0) - return true; - else - return false; -} - -void nanpy::ComChannel::connect() { - COMM_SERIAL.begin(BAUDRATE); -} - -void nanpy::ComChannel::println(String& val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(const char* val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(int val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(unsigned int val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(float val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(double val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(long val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::println(unsigned long val) { - COMM_SERIAL.println(val); -} - -void nanpy::ComChannel::readLine(char* extbuff) { - readLineFromSerial(extbuff); -} - -#endif diff --git a/ComChannel.h b/ComChannel.h deleted file mode 100644 index f6cc480..0000000 --- a/ComChannel.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef COM_CHANNEL -#define COM_CHANNEL - -#include "cfg_all.h" -#include "consts.h" - -#include - -namespace nanpy { - class ComChannel { - - public: - static char read_buffer[MAX_READ_BUFFER_SIZE]; - static bool available(); - static void connect(); - static void println(String& val); - static void println(const char* val); - static void println(int val); - static void println(unsigned int val); - static void println(float val); - static void println(double val); - static void println(long val); - static void println(unsigned long val); - static void readLine(char* extbuff); - }; -} - -#endif diff --git a/CounterClass.cpp b/CounterClass.cpp deleted file mode 100644 index 73911e4..0000000 --- a/CounterClass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "cfg_all.h" - -#if USE_Counter - -#include "CounterClass.h" -#include "FreqCount.h" - -const char* nanpy::CounterClass::get_firmware_id() -{ - return "Counter"; -} - -void nanpy::CounterClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "begin") == 0) - { - FreqCount.begin(m->getInt(0)); - m->returns(0); - } - if (strcmp(m->getName(), "available") == 0) - { - m->returns(FreqCount.available()); - } - if (strcmp(m->getName(), "read") == 0) - { - m->returns(FreqCount.read()); - } - if (strcmp(m->getName(), "end") == 0) - { - FreqCount.end(); - m->returns(0); - } -} - -#endif diff --git a/CounterClass.h b/CounterClass.h deleted file mode 100644 index 8a145c0..0000000 --- a/CounterClass.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class CounterClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; diff --git a/DHTClass.cpp b/DHTClass.cpp deleted file mode 100644 index 6416895..0000000 --- a/DHTClass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "cfg_all.h" - -#if USE_DHT - -#include -#include -#include "DHTClass.h" -#include - -const char* nanpy::DHTClass::get_firmware_id() -{ - return "DHT"; -} - -void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - DHT* dht; - if (m->getNArgs() == 3) { - dht = new DHT (m->getInt(0), m->getInt(1), m->getInt(2)); - } else { - dht = new DHT (m->getInt(0), m->getInt(1)); - } - dht->begin(); - v.insert(dht); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "readHumidity") == 0) { - m->returns(v[m->getObjectId()]->readHumidity()); - } - - if (strcmp(m->getName(), "readTemperature") == 0) { - m->returns(v[m->getObjectId()]->readTemperature(m->getBool(0))); - } -}; - -#endif diff --git a/DHTClass.h b/DHTClass.h deleted file mode 100644 index b14cd8f..0000000 --- a/DHTClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DHT_CLASS -#define DHT_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class DHT; - -namespace nanpy { - class DHTClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/DallasTemperatureClass.cpp b/DallasTemperatureClass.cpp deleted file mode 100644 index bbc088b..0000000 --- a/DallasTemperatureClass.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "cfg_all.h" - -#if USE_DallasTemperature - -#include -#include -#include -#include "DallasTemperatureClass.h" -#include - -const char* nanpy::DallasTemperatureClass::get_firmware_id() -{ - return "DallasTemperature"; -} - -void nanpy::DallasTemperatureClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - int prm = 0; - OneWire* wr = new OneWire(m->getInt(0)); - DallasTemperature* dt = new DallasTemperature(&(*wr)); - v.insert(dt); - dt->begin(); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "setResolution") == 0) { - v[m->getObjectId()]->setResolution(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "getResolution") == 0) { - m->returns(v[m->getObjectId()]->getResolution()); - } - - if (strcmp(m->getName(), "requestTemperatures") == 0) { - if (m->getNArgs() == 1) { - m->returns(v[m->getObjectId()]->requestTemperaturesByIndex(m->getInt(0))); - } else if (m->getNArgs() > 1) { - byte addr[8]; - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = m->getByte(i); - } - m->returns(v[m->getObjectId()]->requestTemperaturesByAddress(addr)); - } else { - v[m->getObjectId()]->requestTemperatures(); - m->returns(0); - } - } - - if (strcmp(m->getName(), "getTempC") == 0) { - if(m->getNArgs() == 1) { - m->returns(v[m->getObjectId()]->getTempCByIndex(m->getInt(0))); - } else { - byte addr[8]; - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = m->getByte(i); - } - m->returns(v[m->getObjectId()]->getTempC(addr)); - } - } - - if (strcmp(m->getName(), "getTempF") == 0) { - if(m->getNArgs() == 1) { - m->returns(v[m->getObjectId()]->getTempFByIndex(m->getInt(0))); - } else { - byte addr[8]; - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = m->getByte(i); - } - m->returns(v[m->getObjectId()]->getTempF(addr)); - } - } - - if (strcmp(m->getName(), "getAddress") == 0) { - byte addr[8]; - String addr_hex = String(); - if(!v[m->getObjectId()]->getAddress(addr, m->getInt(0))) { - m->returns(1); - return; - } - - char stmp[3]; - for( int cc = 0; cc < 8; cc++ ) - { - sprintf(stmp, "%02X", addr[cc]); - addr_hex.concat( stmp ); - if (cc < 7) - addr_hex.concat( "." ); - } - m->returns(addr_hex); - } - - if (strcmp(m->getName(), "getDeviceCount") == 0) { - m->returns(v[m->getObjectId()]->getDeviceCount()); - } -}; -#endif diff --git a/DallasTemperatureClass.h b/DallasTemperatureClass.h deleted file mode 100644 index 30639c5..0000000 --- a/DallasTemperatureClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DALLAS_TEMP_CLASS -#define DALLAS_TEMP_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class DallasTemperature; - -namespace nanpy { - class DallasTemperatureClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/DefineClass.cpp b/DefineClass.cpp deleted file mode 100644 index d50ef2a..0000000 --- a/DefineClass.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "cfg_all.h" - -#if USE_Define - -#include -#include "DefineClass.h" -#include - -#include "generated_mcu.h" -#ifndef MCU -// unknown MCU -# define MCU "" -#endif - -#ifdef ARDUINO_ARCH_AVR -# define USE_PGM -#endif - -#ifdef USE_PGM -# define MY_PROGMEM PROGMEM -#else -# define MY_PROGMEM -#endif - - -// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html - -// example: -// char string_A0[] PROGMEM = "A0"; -#define DEFINE(x) const char string_##x[] MY_PROGMEM = #x; -#include "generated_intdefs.h" -#include "intdefs.h" -#undef DEFINE - -const char * const name_table[] MY_PROGMEM = -{ -// example: -// string_A0, -#define DEFINE(x) string_##x, -#include "generated_intdefs.h" -#include "intdefs.h" -#undef DEFINE -}; - -const int32_t value_table[] MY_PROGMEM = -{ -// example: -// A0, -#define DEFINE(x) x, -#include "generated_intdefs.h" -#include "intdefs.h" -#undef DEFINE -}; - - -#define COUNT_INT_DEFS sizeof(name_table)/sizeof(name_table[0]) - -#define COUNT_STR_DEFS 4 -// __TIME__, __DATE__, __VERSION__, MCU - -const char* nanpy::DefineClass::get_firmware_id() -{ - return "D"; -} - -void nanpy::DefineClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "c") == 0) // count - { - m->returns(COUNT_INT_DEFS + COUNT_STR_DEFS); - } - if (strcmp(m->getName(), "n") == 0) // name - { - int index = m->getInt(0); - switch (index) - { - case COUNT_INT_DEFS + 0: - m->returns("__TIME__"); - break; - case COUNT_INT_DEFS + 1: - m->returns("__DATE__"); - break; - case COUNT_INT_DEFS + 2: - m->returns("__VERSION__"); - break; - case COUNT_INT_DEFS + 3: - m->returns("MCU"); - break; - - default: - char buffer[LONGEST_STRING_IN_INTDEFS_H+1]; -#ifdef USE_PGM - strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[index]))); -#else - strcpy(buffer, name_table[index]); -#endif - m->returns(buffer); - } - } - if (strcmp(m->getName(), "v") == 0) // value - { - int index = m->getInt(0); - switch (index) - { - case COUNT_INT_DEFS + 0: - m->returns(__TIME__); - break; - case COUNT_INT_DEFS + 1: - m->returns(__DATE__); - break; - case COUNT_INT_DEFS + 2: - m->returns(__VERSION__); - break; - case COUNT_INT_DEFS + 3: - m->returns(MCU); - break; - - default: -#ifdef USE_PGM - int32_t value = pgm_read_dword(&(value_table[index])); -#else - int32_t value = value_table[index]; -#endif - m->returns(value); - } - } - -} - -#endif diff --git a/DefineClass.h b/DefineClass.h deleted file mode 100644 index bc4433e..0000000 --- a/DefineClass.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class DefineClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; diff --git a/EEPROMClass.cpp b/EEPROMClass.cpp deleted file mode 100644 index a5d127f..0000000 --- a/EEPROMClass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "cfg_all.h" - -#if USE_EEPROM - -#include -#include "EEPROMClass.h" -#include - -const char* nanpy::EEPROMClass::get_firmware_id() -{ - return "EEPROM"; -} - -void nanpy::EEPROMClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "write") == 0) { - EEPROM.write(m->getInt(0), m->getInt(1)); - m->returns(0); - } - if (strcmp(m->getName(), "read") == 0) { - m->returns(EEPROM.read(m->getInt(0))); - } - - if (strcmp(m->getName(), "size") == 0) { - m->returns(E2END+1); - } -}; - -#endif diff --git a/EEPROMClass.h b/EEPROMClass.h deleted file mode 100644 index 06cae2e..0000000 --- a/EEPROMClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef EEPROM_CLASS -#define EEPROM_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class EEPROMClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/EspClass.cpp b/EspClass.cpp deleted file mode 100644 index 92a7ef8..0000000 --- a/EspClass.cpp +++ /dev/null @@ -1,237 +0,0 @@ -//#include "cfg_all.h" - -#ifdef ESP8266 - -#include "EspClass.h" -#include - -const char* nanpy::EspClass::get_firmware_id() -{ - return "Esp"; -} - -//https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Esp.cpp -void nanpy::EspClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "wdtEnable") == 0) { - ESP.wdtEnable(100); - m->returns(0); - } - if (strcmp(m->getName(), "wdtDisable") == 0) { - ESP.wdtDisable(); - m->returns(0); - } - - if (strcmp(m->getName(), "wdtFeed") == 0) { - ESP.wdtFeed(); - m->returns(0); - } -// if (strcmp(m->getName(), "deepSleep") == 0) { -// ESP.deepSleep(); -// m->returns(0); -// } - if (strcmp(m->getName(), "reset") == 0) { - ESP.reset(); - m->returns(0); - } - if (strcmp(m->getName(), "restart") == 0) { - ESP.restart(); - m->returns(0); - } - if (strcmp(m->getName(), "getVcc") == 0) { - m->returns(ESP.getVcc()); - } - if (strcmp(m->getName(), "getFreeHeap") == 0) { - m->returns(ESP.getFreeHeap()); - } - if (strcmp(m->getName(), "getChipId") == 0) { - m->returns(ESP.getChipId()); - } - if (strcmp(m->getName(), "getSdkVersion") == 0) { - m->returns(ESP.getSdkVersion()); - } - if (strcmp(m->getName(), "getBootVersion") == 0) { - m->returns(ESP.getBootVersion()); - } - if (strcmp(m->getName(), "getBootMode") == 0) { - m->returns(ESP.getBootMode()); - } - if (strcmp(m->getName(), "getCpuFreqMHz") == 0) { - m->returns(ESP.getCpuFreqMHz()); - } - if (strcmp(m->getName(), "getFlashChipId") == 0) { - m->returns(ESP.getFlashChipId()); - } - if (strcmp(m->getName(), "getFlashChipRealSize") == 0) { - m->returns(ESP.getFlashChipRealSize()); - } - - if (strcmp(m->getName(), "getFlashChipSize") == 0) { - m->returns(ESP.getFlashChipSize()); - } - if (strcmp(m->getName(), "getFlashChipSpeed") == 0) { - m->returns(ESP.getFlashChipSpeed()); - } - if (strcmp(m->getName(), "getFlashChipMode") == 0) { - m->returns(ESP.getFlashChipMode()); - } -// if (strcmp(m->getName(), "magicFlashChipSize") == 0) { -// m->returns(ESP.magicFlashChipSize()); -// } -// if (strcmp(m->getName(), "magicFlashChipSpeed") == 0) { -// m->returns(ESP.magicFlashChipSpeed()); -// } -// if (strcmp(m->getName(), "magicFlashChipMode") == 0) { -// m->returns(ESP.magicFlashChipMode()); -// } - if (strcmp(m->getName(), "getFlashChipSizeByChipId") == 0) { - m->returns(ESP.getFlashChipSizeByChipId()); - } -// if (strcmp(m->getName(), "checkFlashConfig") == 0) { -// m->returns(ESP.checkFlashConfig()); -// } - if (strcmp(m->getName(), "getResetReason") == 0) { - String s = ESP.getResetReason(); - m->returns(s); - } - if (strcmp(m->getName(), "getResetInfo") == 0) { - String s = ESP.getResetInfo(); - m->returns(s); - } - if (strcmp(m->getName(), "getSketchSize") == 0) { - m->returns(ESP.getSketchSize()); - } - if (strcmp(m->getName(), "getFreeSketchSpace") == 0) { - m->returns(ESP.getFreeSketchSpace()); - } - if (strcmp(m->getName(), "flashEraseSector") == 0) { - m->returns(ESP.flashEraseSector(m->getInt(0))); - } - if (strcmp(m->getName(), "flashWrite") == 0) { - uint32_t data = m->getInt(1); - m->returns(ESP.flashWrite(m->getInt(0), &data, 1)); - } - if (strcmp(m->getName(), "flashRead") == 0) { - uint32_t data; - ESP.flashRead(m->getInt(0), &data, 1); - m->returns(data); - } -}; - -#else -#ifdef ESP32 -#include "EspClass.h" -#include - -const char* nanpy::EspClass::get_firmware_id() -{ - return "Esp"; -} -//https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Esp.cpp -void nanpy::EspClass::elaborate( nanpy::MethodDescriptor* m ) { -// if (strcmp(m->getName(), "wdtEnable") == 0) { -// ESP.wdtEnable(100); -// m->returns(0); -// } -// if (strcmp(m->getName(), "wdtDisable") == 0) { -// ESP.wdtDisable(); -// m->returns(0); -// } -// -// if (strcmp(m->getName(), "wdtFeed") == 0) { -// ESP.wdtFeed(); -// m->returns(0); -// } -// if (strcmp(m->getName(), "deepSleep") == 0) { -// ESP.deepSleep(); -// m->returns(0); -// } - if (strcmp(m->getName(), "reset") == 0) { - ESP.restart(); - m->returns(0); - } - if (strcmp(m->getName(), "restart") == 0) { - ESP.restart(); - m->returns(0); - } -// if (strcmp(m->getName(), "getVcc") == 0) { -//// m->returns(ESP.getVcc()); -// } - if (strcmp(m->getName(), "getFreeHeap") == 0) { - m->returns(ESP.getFreeHeap()); - } - if (strcmp(m->getName(), "getChipId") == 0) { - m->returns(ESP.getChipRevision()); - } - if (strcmp(m->getName(), "getSdkVersion") == 0) { - m->returns(ESP.getSdkVersion()); - } -// if (strcmp(m->getName(), "getBootVersion") == 0) { -//// m->returns(ESP.getBootVersion()); -// } -// if (strcmp(m->getName(), "getBootMode") == 0) { -//// m->returns(ESP.getFlashChipMode()); -// } - if (strcmp(m->getName(), "getCpuFreqMHz") == 0) { - m->returns("80MHZ"); - } -// if (strcmp(m->getName(), "getFlashChipId") == 0) { -// m->returns(ESP.getFlashChipId()); -// } -// if (strcmp(m->getName(), "getFlashChipRealSize") == 0) { -// m->returns(ESP.getFlashChipRealSize()); -// } - - if (strcmp(m->getName(), "getFlashChipSize") == 0) { - m->returns(ESP.getFlashChipSize()); - } - if (strcmp(m->getName(), "getFlashChipSpeed") == 0) { - m->returns(ESP.getFlashChipSpeed()); - } - if (strcmp(m->getName(), "getFlashChipMode") == 0) { - m->returns(ESP.getFlashChipMode()); - } -// if (strcmp(m->getName(), "magicFlashChipSize") == 0) { -// m->returns(ESP.magicFlashChipSize()); -// } -// if (strcmp(m->getName(), "magicFlashChipSpeed") == 0) { -// m->returns(ESP.magicFlashChipSpeed()); -// } -// if (strcmp(m->getName(), "magicFlashChipMode") == 0) { -// m->returns(ESP.magicFlashChipMode()); -// } -// if (strcmp(m->getName(), "getFlashChipSizeByChipId") == 0) { -// m->returns(ESP.getFlashChipSizeByChipId()); -// } -// if (strcmp(m->getName(), "checkFlashConfig") == 0) { -// m->returns(ESP.checkFlashConfig()); -// } -// if (strcmp(m->getName(), "getResetReason") == 0) { -// String s = ESP.getResetReason(); -// m->returns(s); -// } -// if (strcmp(m->getName(), "getResetInfo") == 0) { -// String s = ESP.getResetInfo(); -// m->returns(s); -// } - if (strcmp(m->getName(), "getSketchSize") == 0) { - m->returns(ESP.getSketchSize()); - } - if (strcmp(m->getName(), "getFreeSketchSpace") == 0) { - m->returns(ESP.getFreeSketchSpace()); - } - if (strcmp(m->getName(), "flashEraseSector") == 0) { - m->returns(ESP.flashEraseSector(m->getInt(0))); - } - if (strcmp(m->getName(), "flashWrite") == 0) { - uint32_t data = m->getInt(1); - m->returns(ESP.flashWrite(m->getInt(0), &data, 1)); - } - if (strcmp(m->getName(), "flashRead") == 0) { - uint32_t data; - ESP.flashRead(m->getInt(0), &data, 1); - m->returns(data); - } -}; - -#endif -#endif diff --git a/EspClass.h b/EspClass.h deleted file mode 100644 index 4a94786..0000000 --- a/EspClass.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -//#ifdef ESP8266 - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class EspClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - -//#endif diff --git a/FreqCount.cpp b/FreqCount.cpp deleted file mode 100644 index 6cba70d..0000000 --- a/FreqCount.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -/* FreqCount Library, for measuring frequencies - * http://www.pjrc.com/teensy/td_libs_FreqCount.html - * Copyright (c) 2011 PJRC.COM, LLC - Paul Stoffregen - * - * Version 1.0 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// FreqCount Library was so modified that it can be included in Nanpy - -#include "cfg_all.h" -#if USE_Counter - -#include "FreqCount.h" -#include "timers.h" - -static uint16_t count_msw; -static uint32_t count_prev; -static volatile uint32_t count_output; -static volatile uint8_t count_ready; -static uint16_t gate_length; -static uint16_t gate_index; - - -void FreqCountClass::begin(uint16_t msec) -{ - if (msec < 10) return; - gate_index = 0; - count_msw = 0; - count_prev = 0; - count_ready = 0; - counter_init(); - gate_length = timer_init(msec); - uint8_t status = SREG; - cli(); - timer_start(); - timer_isr_latency_delay(); - counter_start(); - SREG = status; -} - -uint8_t FreqCountClass::available(void) -{ - return count_ready; -} - -uint32_t FreqCountClass::read(void) -{ - uint32_t count; - uint8_t status; - - status = SREG; - cli(); - count = count_output; - count_ready = 0; - SREG = status; - return count; -} - -void FreqCountClass::end(void) -{ - timer_shutdown(); - counter_shutdown(); -} - - -ISR(TIMER_ISR_VECTOR) -{ - uint16_t count_lsw; - uint32_t count; - uint16_t index, length; - - count_lsw = counter_read(); - if (counter_overflow()) { - counter_overflow_reset(); - count_msw++; - } - index = gate_index + 1; - length = gate_length; - if (index >= length) { - gate_index = 0; - count = ((uint32_t)count_msw << 16) + count_lsw; - count_output = count - count_prev; - count_prev = count; - count_ready = 1; - restore_other_interrupts(); - } else { - if (index == length - 1) disable_other_interrupts(); - gate_index = index; - } -} - - -FreqCountClass FreqCount; - - -#endif diff --git a/FreqCount.h b/FreqCount.h deleted file mode 100644 index 8db9663..0000000 --- a/FreqCount.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -class FreqCountClass { -public: - static void begin(uint16_t msec); - static uint8_t available(void); - static uint32_t read(void); - static void end(void); -}; - -extern FreqCountClass FreqCount; diff --git a/InfoClass.cpp b/InfoClass.cpp deleted file mode 100644 index 249b53e..0000000 --- a/InfoClass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "cfg_all.h" - -#if USE_Info - -#include "InfoClass.h" -#include - -const char* nanpy::InfoClass::get_firmware_id() -{ - return "Info"; -} - -void nanpy::InfoClass::elaborate(nanpy::MethodDescriptor* m) -{ - nanpy::SlimArray * classes = Register::get_classes(); - if (strcmp(m->getName(), "count") == 0) - { - m->returns(classes->getSize()); - } - if (strcmp(m->getName(), "name") == 0) - { - int index = m->getInt(0); - m->returns(classes->get(index)->get_firmware_id()); - } -} -#endif diff --git a/InfoClass.h b/InfoClass.h deleted file mode 100644 index 3f31212..0000000 --- a/InfoClass.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class InfoClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; diff --git a/LiquidCrystalClass.cpp b/LiquidCrystalClass.cpp deleted file mode 100644 index 2169680..0000000 --- a/LiquidCrystalClass.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "cfg_all.h" - -#if USE_LiquidCrystal - -#include -#include -#include "LiquidCrystalClass.h" -#include -#include - -const char* nanpy::LiquidCrystalClass::get_firmware_id() -{ - return "Lcd"; -} - -void nanpy::LiquidCrystalClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - int prm = 0; - v.insert(new LiquidCrystal (m->getInt(prm++), m->getInt(prm++), - m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); - v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "printString") == 0) { - if(m->getNArgs() == 3) { - v[m->getObjectId()]->setCursor(m->getInt(1), m->getInt(2)); - v[m->getObjectId()]->print(m->getString(0)); - } - else - v[m->getObjectId()]->print(m->getString(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "setCursor") == 0) { - v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "autoscroll") == 0) { - v[m->getObjectId()]->autoscroll(); - m->returns(0); - } - - if (strcmp(m->getName(), "noAutoscroll") == 0) { - v[m->getObjectId()]->noAutoscroll(); - m->returns(0); - } - - if (strcmp(m->getName(), "clear") == 0) { - v[m->getObjectId()]->clear(); - m->returns(0); - } - - if (strcmp(m->getName(), "createChar") == 0) { - byte chr[8]; - for(int i = 0; i < 8; i++) { - chr[i] = m->getByte(i+1); - } - v[m->getObjectId()]->createChar(m->getByte(0), chr); - m->returns(0); - } - - if (strcmp(m->getName(), "write") == 0) { - v[m->getObjectId()]->write(m->getByte(0)); - m->returns(0); - } -}; -#endif diff --git a/LiquidCrystalClass.h b/LiquidCrystalClass.h deleted file mode 100644 index 4811ced..0000000 --- a/LiquidCrystalClass.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIQUID_CRYSTAL_CLASS -#define LIQUID_CRYSTAL_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class LiquidCrystal; - -namespace nanpy { - class LiquidCrystalClass : public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - - -#endif diff --git a/LiquidCrystalClass_I2C.cpp b/LiquidCrystalClass_I2C.cpp deleted file mode 100644 index 4c785cd..0000000 --- a/LiquidCrystalClass_I2C.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "cfg_all.h" - -#if USE_LiquidCrystal_I2C - -#include -#include -#include "LiquidCrystalClass_I2C.h" -#include -#include - -const char* nanpy::LiquidCrystalClass_I2C::get_firmware_id() -{ - return "Lcd_I2C"; -} - -void nanpy::LiquidCrystalClass_I2C::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - int prm = 0; - // lcd_Addr, En, Rw, Rs, d4, d5, d6, d7 - v.insert(new LiquidCrystal_I2C ( - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - m->getInt(prm++), - (t_backlighPol)m->getInt(prm++))); - v[m->getObjectId()]->begin(m->getInt(prm++), m->getInt(prm++)); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "printString") == 0) { - if(m->getNArgs() == 3) { - v[m->getObjectId()]->setCursor(m->getInt(1), m->getInt(2)); - v[m->getObjectId()]->print(m->getString(0)); - } - else - v[m->getObjectId()]->print(m->getString(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "setCursor") == 0) { - v[m->getObjectId()]->setCursor(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "setBacklight") == 0) { - v[m->getObjectId()]->setBacklight(m->getInt(0)); - m->returns(0); - } -}; -#endif diff --git a/LiquidCrystalClass_I2C.h b/LiquidCrystalClass_I2C.h deleted file mode 100644 index e6ccb04..0000000 --- a/LiquidCrystalClass_I2C.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIQUID_CRYSTAL_CLASS_I2C -#define LIQUID_CRYSTAL_CLASS_I2C - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class LiquidCrystal_I2C; - -namespace nanpy { - class LiquidCrystalClass_I2C : public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - - -#endif diff --git a/MCP41xxxClass.cpp b/MCP41xxxClass.cpp deleted file mode 100644 index 2c3e7a1..0000000 --- a/MCP41xxxClass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "cfg.h" - -#if USE_MCP41xxx - -#include -#include -#include "MCP41xxxClass.h" -#include "SPI.h" -#include - -const char* nanpy::MCP41xxxClass::get_firmware_id(){ - return "MCP41xxx"; -} - -void nanpy::MCP41xxxClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - MCP41xxx* pot; - pot = new MCP41xxx (m->getInt(0)); - pot->begin(); - v.insert(pot); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "analogWrite") == 0) { - v[m->getObjectId()]->analogWrite(m->getInt(0), m->getInt(1)); - m->returns(0); - } -} - -#endif diff --git a/MCP41xxxClass.h b/MCP41xxxClass.h deleted file mode 100644 index 323fbac..0000000 --- a/MCP41xxxClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef MCP41XXX_CLASS -#define MCP41XXX_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class MCP41xxx; - -namespace nanpy{ - class MCP41xxxClass: public ObjectsManager{ - public: - void elaborate( nanpy::MethodDescriptor* m); - const char* get_firmware_id(); - }; -} - -#endif diff --git a/MethodDescriptor.cpp b/MethodDescriptor.cpp deleted file mode 100644 index a2850de..0000000 --- a/MethodDescriptor.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "MethodDescriptor.h" -#include -#include -#include "ComChannel.h" -#include "consts.h" - -char** nanpy::MethodDescriptor::stack_pool = 0; -int nanpy::MethodDescriptor::stack_pool_size = 3; - -nanpy::MethodDescriptor::MethodDescriptor() { - - char buff[MAX_READ_BUFFER_SIZE]; - - ComChannel::readLine(this->classname); - - ComChannel::readLine(buff); - this->objid = atoi(buff); - - ComChannel::readLine(buff); - this->n_args = atoi(buff); - - ComChannel::readLine(this->name); - - if (this->n_args > nanpy::MethodDescriptor::stack_pool_size) { - if(nanpy::MethodDescriptor::stack_pool != 0) { - for(int n = 0; n < nanpy::MethodDescriptor::stack_pool_size; n++) { - delete(nanpy::MethodDescriptor::stack_pool[n]); - } - delete(nanpy::MethodDescriptor::stack_pool); - } - nanpy::MethodDescriptor::stack_pool = 0; - nanpy::MethodDescriptor::stack_pool_size = this->n_args; - } - - if (nanpy::MethodDescriptor::stack_pool == 0) { - nanpy::MethodDescriptor::stack_pool = (char**)malloc(sizeof(char*) * nanpy::MethodDescriptor::stack_pool_size); - for(int i = 0; i < nanpy::MethodDescriptor::stack_pool_size; i++) { - nanpy::MethodDescriptor::stack_pool[i] = (char*)malloc(sizeof(char) * MAX_READ_BUFFER_SIZE); - } - } - - this->stack = nanpy::MethodDescriptor::stack_pool; - - for(int n = 0; n < this->n_args; n++) { - ComChannel::readLine(this->stack[n]); - } -}; - -int nanpy::MethodDescriptor::getNArgs() { - return this->n_args; -}; - -bool nanpy::MethodDescriptor::getBool(int n) { - return strcmp(this->stack[n], "True") == 0 ? true : false; -}; - -int nanpy::MethodDescriptor::getInt(int n) { - return atoi(this->stack[n]); -}; - -byte nanpy::MethodDescriptor::getByte(int n) { - return byte(getInt(n)); -}; - -float nanpy::MethodDescriptor::getFloat(int n) { - return atof(this->stack[n]); -}; - -double nanpy::MethodDescriptor::getDouble(int n) { - return atof(this->stack[n]); -}; - -char* nanpy::MethodDescriptor::getString(int n) { - return this->stack[n]; -}; - -char* nanpy::MethodDescriptor::getClass() { - return this->classname; -}; - -int nanpy::MethodDescriptor::getObjectId() { - return this->objid; -}; - -char* nanpy::MethodDescriptor::getName() { - return this->name; -}; - -void nanpy::MethodDescriptor::returns(String& val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(const char* val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(char val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(unsigned char val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(int val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(unsigned int val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(float val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(double val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(long val) { - ComChannel::println(val); -} - -void nanpy::MethodDescriptor::returns(unsigned long val) { - ComChannel::println(val); -} diff --git a/MethodDescriptor.h b/MethodDescriptor.h deleted file mode 100644 index 8d1ac3b..0000000 --- a/MethodDescriptor.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef METHOD_DESCRIPTOR -#define METHOD_DESCRIPTOR - -#include -#include - -namespace nanpy { - class MethodDescriptor { - - private: - char name[50]; - int objid; - char classname[50]; - int n_args; - char **stack; - static char **stack_pool; - static int stack_pool_size; - - public: - MethodDescriptor(); - int getNArgs(); - char* getClass(); - int getObjectId(); - bool getBool(int n); - int getInt(int n); - byte getByte(int n); - float getFloat(int n); - double getDouble(int n); - char* getString(int n); - char* getName(); - void returns(String& val); - void returns(const char* val); - void returns(char val); - void returns(unsigned char val); - void returns(int val); - void returns(unsigned int val); - void returns(float val); - void returns(double val); - void returns(long val); - void returns(unsigned long val); - - }; -} -#endif diff --git a/Nanpy/ArduinoClass.cpp b/Nanpy/ArduinoClass.cpp index ba86a41..46ff927 100644 --- a/Nanpy/ArduinoClass.cpp +++ b/Nanpy/ArduinoClass.cpp @@ -17,11 +17,12 @@ void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { if (strcmp(m->getName(), "r") == 0) { // digitalRead m->returns(digitalRead(m->getInt(0))); } - +#ifndef ESP32 if (strcmp(m->getName(), "aw") == 0) { // analogWrite analogWrite(m->getInt(0), m->getInt(1)); m->returns(0); } +#endif if (strcmp(m->getName(), "a") == 0) { // analogRead m->returns(analogRead(m->getInt(0))); diff --git a/Nanpy/ArduinoCoreClass.h b/Nanpy/ArduinoCoreClass.h index df1def5..25af72f 100644 --- a/Nanpy/ArduinoCoreClass.h +++ b/Nanpy/ArduinoCoreClass.h @@ -12,4 +12,3 @@ namespace nanpy { }; }; - diff --git a/CONTRIBUTORS b/Nanpy/CONTRIBUTORS similarity index 100% rename from CONTRIBUTORS rename to Nanpy/CONTRIBUTORS diff --git a/Nanpy/ComChannel.cpp b/Nanpy/ComChannel.cpp index 419047e..174c0bc 100644 --- a/Nanpy/ComChannel.cpp +++ b/Nanpy/ComChannel.cpp @@ -3,21 +3,34 @@ #if USE_WIFI_CONNECTION +#ifdef ESP8266 #include #include +#else +#ifdef ESP32 +#include +#include +#endif +#endif -#define DNS_NAME "nanpy" +#define DNS_NAME "mudpi" #define SERVER_PORT 5678 #define SerialDebug Serial -#define TIMEOUT 10 +#define TIMEOUT 50 WiFiServer server(SERVER_PORT); WiFiClient client; +unsigned long currentTime = millis(); +unsigned long previousTime = 0; +const long timeoutTime = 10000; + void nanpy::ComChannel::connect() { SerialDebug.begin(115200); SerialDebug.println(""); + WiFi.disconnect(); //Flush WiFi + delay(2000); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); SerialDebug.print("\nConnecting to "); SerialDebug.println(WIFI_SSID); @@ -63,17 +76,29 @@ void nanpy::ComChannel::connect() bool nanpy::ComChannel::available() { - if (!client.connected()) - { - // try to connect to a new client - client = server.available(); - if (client.connected()) - SerialDebug.println("client connected"); - } + currentTime = millis(); + if (previousTime == 0) { + previousTime = currentTime; + } + if(client) { + previousTime = currentTime; + // read data from the connected client + if (client.connected() && currentTime - previousTime <= timeoutTime) { + previousTime = currentTime; + return (client.available() > 0); + } + else { + client.stop(); + Serial.println("Client Disconnected."); + } + } else { - // read data from the connected client - return (client.available() > 0); + // try to connect to a new client + client = server.available(); + if (client.connected()) { + SerialDebug.println("Client connected"); + } } return false; } @@ -81,20 +106,24 @@ bool nanpy::ComChannel::available() char nanpy::ComChannel::read_buffer[MAX_READ_BUFFER_SIZE] = {0}; void readLineFromSerial(char* extbuff) { - int i=0; - char ch = '0'; - char* buff = nanpy::ComChannel::read_buffer; - do { - ch = client.read(); - if(ch < 255 && ch >= 0) { - buff[i++] = ch; - } - if (i == MAX_READ_BUFFER_SIZE - 1) { - buff[i] = '\0'; - break; - } - } while(ch != '\0'); - strcpy(extbuff, buff); + if(client) { + if(client.connected()) { + int i=0; + char ch = '0'; + char* buff = nanpy::ComChannel::read_buffer; + do { + ch = client.read(); + if(ch < 255 && ch >= 0) { + buff[i++] = ch; + } + if (i == MAX_READ_BUFFER_SIZE - 1) { + buff[i] = '\0'; + break; + } + } while(ch != '\0'); + strcpy(extbuff, buff); + } + } }; void nanpy::ComChannel::readLine(char* extbuff) { diff --git a/Nanpy/ComChannel.h b/Nanpy/ComChannel.h index 687fb4a..f6cc480 100644 --- a/Nanpy/ComChannel.h +++ b/Nanpy/ComChannel.h @@ -26,4 +26,3 @@ namespace nanpy { } #endif - diff --git a/Nanpy/CounterClass.h b/Nanpy/CounterClass.h index d148990..8a145c0 100644 --- a/Nanpy/CounterClass.h +++ b/Nanpy/CounterClass.h @@ -12,4 +12,3 @@ namespace nanpy { }; }; - diff --git a/Nanpy/DHTClass.cpp b/Nanpy/DHTClass.cpp index a052060..6416895 100644 --- a/Nanpy/DHTClass.cpp +++ b/Nanpy/DHTClass.cpp @@ -18,9 +18,9 @@ void nanpy::DHTClass::elaborate( MethodDescriptor* m ) { if (strcmp(m->getName(),"new") == 0) { DHT* dht; if (m->getNArgs() == 3) { - dht = new DHT (m->getInt(0), m->getInt(1), m->getInt(2)); + dht = new DHT (m->getInt(0), m->getInt(1), m->getInt(2)); } else { - dht = new DHT (m->getInt(0), m->getInt(1)); + dht = new DHT (m->getInt(0), m->getInt(1)); } dht->begin(); v.insert(dht); diff --git a/Nanpy/DefineClass.h b/Nanpy/DefineClass.h index 3cd7d0a..bc4433e 100644 --- a/Nanpy/DefineClass.h +++ b/Nanpy/DefineClass.h @@ -12,4 +12,3 @@ namespace nanpy { }; }; - diff --git a/Nanpy/EspClass.cpp b/Nanpy/EspClass.cpp index 5293bc7..92a7ef8 100644 --- a/Nanpy/EspClass.cpp +++ b/Nanpy/EspClass.cpp @@ -117,4 +117,121 @@ void nanpy::EspClass::elaborate( nanpy::MethodDescriptor* m ) { } }; +#else +#ifdef ESP32 +#include "EspClass.h" +#include + +const char* nanpy::EspClass::get_firmware_id() +{ + return "Esp"; +} +//https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Esp.cpp +void nanpy::EspClass::elaborate( nanpy::MethodDescriptor* m ) { +// if (strcmp(m->getName(), "wdtEnable") == 0) { +// ESP.wdtEnable(100); +// m->returns(0); +// } +// if (strcmp(m->getName(), "wdtDisable") == 0) { +// ESP.wdtDisable(); +// m->returns(0); +// } +// +// if (strcmp(m->getName(), "wdtFeed") == 0) { +// ESP.wdtFeed(); +// m->returns(0); +// } +// if (strcmp(m->getName(), "deepSleep") == 0) { +// ESP.deepSleep(); +// m->returns(0); +// } + if (strcmp(m->getName(), "reset") == 0) { + ESP.restart(); + m->returns(0); + } + if (strcmp(m->getName(), "restart") == 0) { + ESP.restart(); + m->returns(0); + } +// if (strcmp(m->getName(), "getVcc") == 0) { +//// m->returns(ESP.getVcc()); +// } + if (strcmp(m->getName(), "getFreeHeap") == 0) { + m->returns(ESP.getFreeHeap()); + } + if (strcmp(m->getName(), "getChipId") == 0) { + m->returns(ESP.getChipRevision()); + } + if (strcmp(m->getName(), "getSdkVersion") == 0) { + m->returns(ESP.getSdkVersion()); + } +// if (strcmp(m->getName(), "getBootVersion") == 0) { +//// m->returns(ESP.getBootVersion()); +// } +// if (strcmp(m->getName(), "getBootMode") == 0) { +//// m->returns(ESP.getFlashChipMode()); +// } + if (strcmp(m->getName(), "getCpuFreqMHz") == 0) { + m->returns("80MHZ"); + } +// if (strcmp(m->getName(), "getFlashChipId") == 0) { +// m->returns(ESP.getFlashChipId()); +// } +// if (strcmp(m->getName(), "getFlashChipRealSize") == 0) { +// m->returns(ESP.getFlashChipRealSize()); +// } + + if (strcmp(m->getName(), "getFlashChipSize") == 0) { + m->returns(ESP.getFlashChipSize()); + } + if (strcmp(m->getName(), "getFlashChipSpeed") == 0) { + m->returns(ESP.getFlashChipSpeed()); + } + if (strcmp(m->getName(), "getFlashChipMode") == 0) { + m->returns(ESP.getFlashChipMode()); + } +// if (strcmp(m->getName(), "magicFlashChipSize") == 0) { +// m->returns(ESP.magicFlashChipSize()); +// } +// if (strcmp(m->getName(), "magicFlashChipSpeed") == 0) { +// m->returns(ESP.magicFlashChipSpeed()); +// } +// if (strcmp(m->getName(), "magicFlashChipMode") == 0) { +// m->returns(ESP.magicFlashChipMode()); +// } +// if (strcmp(m->getName(), "getFlashChipSizeByChipId") == 0) { +// m->returns(ESP.getFlashChipSizeByChipId()); +// } +// if (strcmp(m->getName(), "checkFlashConfig") == 0) { +// m->returns(ESP.checkFlashConfig()); +// } +// if (strcmp(m->getName(), "getResetReason") == 0) { +// String s = ESP.getResetReason(); +// m->returns(s); +// } +// if (strcmp(m->getName(), "getResetInfo") == 0) { +// String s = ESP.getResetInfo(); +// m->returns(s); +// } + if (strcmp(m->getName(), "getSketchSize") == 0) { + m->returns(ESP.getSketchSize()); + } + if (strcmp(m->getName(), "getFreeSketchSpace") == 0) { + m->returns(ESP.getFreeSketchSpace()); + } + if (strcmp(m->getName(), "flashEraseSector") == 0) { + m->returns(ESP.flashEraseSector(m->getInt(0))); + } + if (strcmp(m->getName(), "flashWrite") == 0) { + uint32_t data = m->getInt(1); + m->returns(ESP.flashWrite(m->getInt(0), &data, 1)); + } + if (strcmp(m->getName(), "flashRead") == 0) { + uint32_t data; + ESP.flashRead(m->getInt(0), &data, 1); + m->returns(data); + } +}; + +#endif #endif diff --git a/Nanpy/FreqCount.h b/Nanpy/FreqCount.h index dc74526..8db9663 100644 --- a/Nanpy/FreqCount.h +++ b/Nanpy/FreqCount.h @@ -11,4 +11,3 @@ class FreqCountClass { }; extern FreqCountClass FreqCount; - diff --git a/Nanpy/InfoClass.h b/Nanpy/InfoClass.h index 7f9dce2..3f31212 100644 --- a/Nanpy/InfoClass.h +++ b/Nanpy/InfoClass.h @@ -12,4 +12,3 @@ namespace nanpy { }; }; - diff --git a/LICENSE b/Nanpy/LICENSE similarity index 100% rename from LICENSE rename to Nanpy/LICENSE diff --git a/Nanpy/MethodDescriptor.cpp b/Nanpy/MethodDescriptor.cpp index 5a389b9..a2850de 100644 --- a/Nanpy/MethodDescriptor.cpp +++ b/Nanpy/MethodDescriptor.cpp @@ -125,4 +125,3 @@ void nanpy::MethodDescriptor::returns(long val) { void nanpy::MethodDescriptor::returns(unsigned long val) { ComChannel::println(val); } - diff --git a/Nanpy-MudPi.ino b/Nanpy/Nanpy-MudPi.ino similarity index 100% rename from Nanpy-MudPi.ino rename to Nanpy/Nanpy-MudPi.ino diff --git a/README.md b/Nanpy/README.md similarity index 100% rename from README.md rename to Nanpy/README.md diff --git a/Nanpy/RegisterClass.cpp b/Nanpy/RegisterClass.cpp index 6468562..4223c58 100644 --- a/Nanpy/RegisterClass.cpp +++ b/Nanpy/RegisterClass.cpp @@ -110,4 +110,3 @@ void nanpy::RegisterClass::elaborate(nanpy::MethodDescriptor* m) } #endif - diff --git a/Nanpy/RegisterClass.h b/Nanpy/RegisterClass.h index d30bb9c..d151798 100644 --- a/Nanpy/RegisterClass.h +++ b/Nanpy/RegisterClass.h @@ -11,4 +11,3 @@ namespace nanpy { }; }; - diff --git a/Nanpy/ServoClass.cpp b/Nanpy/ServoClass.cpp index b28f1a1..01425c9 100644 --- a/Nanpy/ServoClass.cpp +++ b/Nanpy/ServoClass.cpp @@ -50,4 +50,3 @@ void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { } #endif - diff --git a/Nanpy/cfg_check.h b/Nanpy/cfg_check.h index 9729e90..ca8b1aa 100644 --- a/Nanpy/cfg_check.h +++ b/Nanpy/cfg_check.h @@ -5,14 +5,14 @@ #ifndef ARDUINO_ARCH_AVR // disable AVR only features #define USE_ArduinoCore 0 -//#define USE_RAM 0 +//#define USE_RAM 0 #define USE_EEPROM 0 #define USE_Register 0 #define USE_Watchdog 0 #define USE_Counter 0 #define USE_DHT 0 #define USE_LiquidCrystal_I2C 0 -#define USE_LiquidCrystal 0 +#define USE_LiquidCrystal 0 #endif // check configuration for problems @@ -28,11 +28,17 @@ #ifdef ESP8266 # define USE_ESP 1 #else +#ifdef ESP32 +# define USE_ESP_32 1 +# define USE_ESP 1 +# define USE_DHT 1 +#else # define USE_ESP 0 #endif +#endif #ifndef ESP8266 +#ifndef ESP32 # define USE_WIFI_CONNECTION 0 #endif - - +#endif diff --git a/Nanpy/cfg_defaults.h b/Nanpy/cfg_defaults.h index 38e8dba..3e835f0 100644 --- a/Nanpy/cfg_defaults.h +++ b/Nanpy/cfg_defaults.h @@ -81,7 +81,7 @@ #endif #ifndef USE_DHT -# define USE_DHT 0 +# define USE_DHT 1 #endif #ifndef USE_LiquidCrystal_I2C diff --git a/configure.sh b/Nanpy/configure.sh similarity index 100% rename from configure.sh rename to Nanpy/configure.sh diff --git a/Nanpy/consts.h b/Nanpy/consts.h index c647711..3cd1b46 100644 --- a/Nanpy/consts.h +++ b/Nanpy/consts.h @@ -1,4 +1,3 @@ #pragma once #define MAX_READ_BUFFER_SIZE 50 - diff --git a/Nanpy/freeram.c b/Nanpy/freeram.c index 48cefe8..9056f39 100644 --- a/Nanpy/freeram.c +++ b/Nanpy/freeram.c @@ -62,4 +62,4 @@ int free_ram3() return size; } -#endif \ No newline at end of file +#endif diff --git a/Nanpy/freeram.h b/Nanpy/freeram.h index c0ba485..f1dba7a 100644 --- a/Nanpy/freeram.h +++ b/Nanpy/freeram.h @@ -12,4 +12,3 @@ int free_ram3(); #ifdef __cplusplus } #endif - diff --git a/Nanpy/generated_avr_registers.h b/Nanpy/generated_avr_registers.h index caf238d..dce2e9b 100644 --- a/Nanpy/generated_avr_registers.h +++ b/Nanpy/generated_avr_registers.h @@ -13761,4 +13761,4 @@ DEFINE(XOSC_CTRL) #else MISSING(XOSC_CTRL) -#endif \ No newline at end of file +#endif diff --git a/Nanpy/generated_mcu.h b/Nanpy/generated_mcu.h index dfce6ac..69ac374 100644 --- a/Nanpy/generated_mcu.h +++ b/Nanpy/generated_mcu.h @@ -1284,4 +1284,4 @@ # error "MCU is already defined" # endif # define MCU "__AVR_ATxmega64D3__" -#endif \ No newline at end of file +#endif diff --git a/Nanpy/intdefs.h b/Nanpy/intdefs.h index bf66de1..d1e9215 100644 --- a/Nanpy/intdefs.h +++ b/Nanpy/intdefs.h @@ -9,5 +9,3 @@ DEFINE(A0) DEFINE(MISO) DEFINE(SCK) #endif - - diff --git a/sample_cfg.h b/Nanpy/sample_cfg.h similarity index 100% rename from sample_cfg.h rename to Nanpy/sample_cfg.h diff --git a/OneWireClass.cpp b/OneWireClass.cpp deleted file mode 100644 index e4fb1b4..0000000 --- a/OneWireClass.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "cfg_all.h" - -#if USE_OneWire - -#include -#include "OneWireClass.h" -#include - -const char* nanpy::OneWireClass::get_firmware_id() -{ - return "OneWire"; -} - -void nanpy::OneWireClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new OneWire(m->getInt(0))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "search") == 0) { - byte addr[8]; - int res = v[m->getObjectId()]->search(addr); - - if(!res) { - v[m->getObjectId()]->reset_search(); - delay(250); - m->returns(1); - } - - else { - String addr_hex = String(); - for( int cc = 0; cc < 7; cc++ ) - addr_hex += String(addr[cc]) + " "; - addr_hex += String(addr[7]); - m->returns(addr_hex); - } - } - - if (strcmp(m->getName(), "reset_search") == 0) { - v[m->getObjectId()]->reset_search(); - m->returns(0); - } - - if (strcmp(m->getName(), "reset") == 0) { - m->returns(v[m->getObjectId()]->reset()); - } - - if (strcmp(m->getName(), "select") == 0) { - byte* addr = (byte*)malloc(m->getNArgs() * sizeof(byte)); - - for(int i = 0 ; i < m->getNArgs() ; i++) { - addr[i] = m->getByte(i); - } - - v[m->getObjectId()]->select(addr); - - delete(addr); - m->returns(0); - } - - if (strcmp(m->getName(), "write") == 0) { - if(m->getNArgs() == 1) - v[m->getObjectId()]->write(m->getInt(0)); - else - v[m->getObjectId()]->write(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "read") == 0) { - m->returns(v[m->getObjectId()]->read()); - } -}; - -#endif diff --git a/OneWireClass.h b/OneWireClass.h deleted file mode 100644 index 52e4842..0000000 --- a/OneWireClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ONE_WIRE_CLASS -#define ONE_WIRE_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class OneWire; - -namespace nanpy { - class OneWireClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/RAMClass.cpp b/RAMClass.cpp deleted file mode 100644 index ce9e6cc..0000000 --- a/RAMClass.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "cfg_all.h" - -#if USE_RAM - -#include "RAMClass.h" -#include -#include "freeram.h" - - -const char* nanpy::RAMClass::get_firmware_id() -{ - return "RAM"; -} - -void nanpy::RAMClass::elaborate( nanpy::MethodDescriptor* m ) { - if (strcmp(m->getName(), "write") == 0) { - uint8_t* p = (uint8_t*)(m->getInt(0)); - *p = m->getInt(1); - m->returns(0); - } - if (strcmp(m->getName(), "read") == 0) { - uint8_t* p = (uint8_t*)(m->getInt(0)); - m->returns(*p); - } - - if (strcmp(m->getName(), "size") == 0) { -#ifdef RAMEND - m->returns(RAMEND+1); -#else - m->returns(0); -#endif - } - - if (strcmp(m->getName(), "free") == 0) { -#ifdef __AVR__ - m->returns(free_ram2()); -#else - m->returns(0); -#endif - } -}; - -#endif diff --git a/RAMClass.h b/RAMClass.h deleted file mode 100644 index bd234a2..0000000 --- a/RAMClass.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef RAM_CLASS -#define RAM_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class RAMClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/RegisterClass.cpp b/RegisterClass.cpp deleted file mode 100644 index 4223c58..0000000 --- a/RegisterClass.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "cfg_all.h" - -#if USE_Register - -#include -#include "RegisterClass.h" -#include - -// http://www.nongnu.org/avr-libc/user-manual/pgmspace.html - -#define MISSING(x) - -// example: -// char string_OCR2A[] PROGMEM = "OCR2A"; -#define DEFINE(x) const char string_##x[] PROGMEM = #x; -#include "generated_avr_registers.h" -#undef DEFINE - -const char * const name_table[] PROGMEM = -{ -// example: -// string_OCR2A, -#define DEFINE(x) string_##x, -#include "generated_avr_registers.h" -#undef DEFINE -}; - -#define DEFINE(x) (uint16_t)(&x), -const uint16_t reg_list[] PROGMEM = -{ -#include "generated_avr_registers.h" -}; -#undef DEFINE - -#define DEFINE(x) sizeof(x), -const uint16_t sizeof_list[] PROGMEM = -{ -#include "generated_avr_registers.h" -}; -#undef DEFINE - -const int REG_COUNT = sizeof(sizeof_list) / sizeof(sizeof_list[0]); - -#define LONGEST_REGISTER_NAME 21 - -const char* nanpy::RegisterClass::get_firmware_id() -{ - return "R"; -} - -void nanpy::RegisterClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "c") == 0) // count - { - m->returns(REG_COUNT); - } - else if (strcmp(m->getName(), "n") == 0) // name - { - word regindex = m->getInt(0); - char buffer[LONGEST_REGISTER_NAME]; - strcpy_P(buffer, (PGM_P) pgm_read_word(&(name_table[regindex]))); - m->returns(buffer); - } - else - { - word regindex = m->getInt(0); - word regvalue = m->getInt(1); - - word regaddr = pgm_read_word(®_list[regindex]); - byte regsize = pgm_read_byte(&sizeof_list[regindex]); - - volatile byte* preg8 = (volatile byte*) regaddr; - volatile word* preg16 = (volatile word*) regaddr; - - if (strcmp(m->getName(), "r") == 0) // read - { - switch (regsize) - { - case 1: - m->returns(*preg8); - break; - case 2: - m->returns(*preg16); - break; - } - } - else if (strcmp(m->getName(), "w") == 0) // write - { - switch (regsize) - { - case 1: - *preg8 = (byte) regvalue; - break; - case 2: - *preg16 = regvalue; - break; - } - m->returns(0); - } - else if (strcmp(m->getName(), "a") == 0) // address - { - m->returns(regaddr); - } - else if (strcmp(m->getName(), "s") == 0) // size - { - m->returns(regsize); - } - - } -} - -#endif diff --git a/RegisterClass.h b/RegisterClass.h deleted file mode 100644 index d151798..0000000 --- a/RegisterClass.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class RegisterClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; diff --git a/ServoClass.cpp b/ServoClass.cpp deleted file mode 100644 index 01425c9..0000000 --- a/ServoClass.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "cfg_all.h" - -#if USE_Servo - -#include -#include -#include "ServoClass.h" -#include - -const char* nanpy::ServoClass::get_firmware_id() -{ - return "Servo"; -} - -void nanpy::ServoClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - v.insert(new Servo()); - v[v.getLastIndex()]->attach(m->getInt(0)); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "write") == 0) { - v[m->getObjectId()]->write(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "read") == 0) { - m->returns(v[m->getObjectId()]->read()); - } - - if (strcmp(m->getName(), "writeMicroseconds") == 0) { - v[m->getObjectId()]->writeMicroseconds(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "readMicroseconds") == 0) { - m->returns(v[m->getObjectId()]->readMicroseconds()); - } - - if (strcmp(m->getName(), "detach") == 0) { - v[m->getObjectId()]->detach(); - m->returns(0); - } - - if (strcmp(m->getName(), "attached") == 0) { - m->returns(v[m->getObjectId()]->attached()); - } -} - -#endif diff --git a/ServoClass.h b/ServoClass.h deleted file mode 100644 index e35fad2..0000000 --- a/ServoClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef SERVO_CLASS -#define SERVO_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class Servo; - -namespace nanpy { - class ServoClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/SlimArray.h b/SlimArray.h deleted file mode 100644 index 30cb23f..0000000 --- a/SlimArray.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SLIM_ARRAY -#define SLIM_ARRAY - -#include - -namespace nanpy { - template class SlimArray { - - private: - - int size; - int cur_size; - T *v; - - public: - - SlimArray(int s=0) : size(s), v((T*)malloc(sizeof(T) * size)) { - for(int i = 0; i < size; i++) - v[i] = 0; - cur_size = 0; - } - - SlimArray(T *x, int s) : size(s), v((T*)malloc(sizeof(T) * size)) { - size = s; - for(int i = 0; i < size; i++) - v[i] = x[i]; - } - - void insert(T el) { - this->insert(cur_size, el); - } - - void remove(int pos) { - if(pos > size - 1) - return; - - T* newv = (T*)malloc(sizeof(T) * (size - 1)); - - int j = 0; - - for(int i = 0; i < size; i++) { - if(i != pos) { - newv[j] = v[i]; - j++; - } - } - - free(v); - v = newv; - cur_size--; - size--; - } - - void insert(int pos, T el) { - if(pos > size - 1) { - T* newv = (T*)malloc(sizeof(T) * (pos + 1)); - newv[pos] = el; - for(int i = 0; i < size; i++) - newv[i] = v[i]; - free(v); - size = pos + 1; - v = newv; - } else { - v[pos] = el; - } - cur_size++; - } - - T get(int pos) { - return v[pos]; - } - - T& operator[] ( int pos ) { - return v[pos]; - } - - int getSize() { - return this->size; - } - - int getLastIndex() { - return (this->cur_size - 1); - } - - ~SlimArray() { - free(v); - } - - }; -} - -#endif diff --git a/StepperClass.cpp b/StepperClass.cpp deleted file mode 100644 index 2174c3c..0000000 --- a/StepperClass.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "cfg_all.h" - -#if USE_Stepper - -#include -#include -#include "StepperClass.h" -#include - -const char* nanpy::StepperClass::get_firmware_id() -{ - return "Stepper"; -} - -void nanpy::StepperClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - int prm = 0; - if (m->getNArgs() == 3) { - v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); - } else { - v.insert(new Stepper (m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++), m->getInt(prm++))); - } - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "setSpeed") == 0) { - v[m->getObjectId()]->setSpeed(m->getInt(0)); - m->returns(0); - } - - if (strcmp(m->getName(), "step") == 0) { - v[m->getObjectId()]->step(m->getInt(0)); - m->returns(0); - } -} - - -#endif diff --git a/StepperClass.h b/StepperClass.h deleted file mode 100644 index 7311f17..0000000 --- a/StepperClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef STEPPER_CLASS -#define STEPPER_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class Stepper; - -namespace nanpy { - class StepperClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/TLC5947Class.cpp b/TLC5947Class.cpp deleted file mode 100644 index f419cca..0000000 --- a/TLC5947Class.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "cfg.h" - -#if USE_TLC5947 - -#include -#include -#include "TLC5947Class.h" -#include - -const char* nanpy::TLC5947Class::get_firmware_id() { - return "TLC5947"; -} - -void nanpy::TLC5947Class::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if(strcmp(m->getName(), "new") == 0) { - Adafruit_TLC5947* tlc = new Adafruit_TLC5947(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); - tlc->begin(); - v.insert(tlc); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "setLED") == 0) { - v[m->getObjectId()]->setLED(m->getInt(0), m->getInt(1), m->getInt(2), m->getInt(3)); - m->returns(0); - } - - if (strcmp(m->getName(), "write") == 0) { - v[m->getObjectId()]->write(); - m->returns(0); - } - -} - -#endif diff --git a/TLC5947Class.h b/TLC5947Class.h deleted file mode 100644 index b30864a..0000000 --- a/TLC5947Class.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef TLC5947_CLASS -#define TLC5947_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class Adafruit_TLC5947; - -namespace nanpy { - class TLC5947Class: public ObjectsManager { - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - }; -} - -#endif diff --git a/ToneClass.cpp b/ToneClass.cpp deleted file mode 100644 index 0508804..0000000 --- a/ToneClass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "cfg_all.h" - -#if USE_Tone - -#include -#include "ToneClass.h" -#include - -const char* nanpy::ToneClass::get_firmware_id() -{ - return "Tone"; -} - -void nanpy::ToneClass::elaborate( nanpy::MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(),"new") == 0) { - v.insert(new ToneWrapper (m->getInt(0))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "play") == 0) { - v[m->getObjectId()]->play(m->getInt(0), m->getInt(1)); - m->returns(0); - } - - if (strcmp(m->getName(), "stop") == 0) { - v[m->getObjectId()]->stop(); - m->returns(0); - } -}; -#endif diff --git a/ToneClass.h b/ToneClass.h deleted file mode 100644 index 75bcefa..0000000 --- a/ToneClass.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef TONE_CLASS -#define TONE_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -#define NOTE_B0 31 -#define NOTE_C1 33 -#define NOTE_CS1 35 -#define NOTE_D1 37 -#define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 -#define NOTE_FS1 46 -#define NOTE_G1 49 -#define NOTE_GS1 52 -#define NOTE_A1 55 -#define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 -#define NOTE_CS2 69 -#define NOTE_D2 73 -#define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 -#define NOTE_FS2 93 -#define NOTE_G2 98 -#define NOTE_GS2 104 -#define NOTE_A2 110 -#define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 -#define NOTE_CS3 139 -#define NOTE_D3 147 -#define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 -#define NOTE_FS3 185 -#define NOTE_G3 196 -#define NOTE_GS3 208 -#define NOTE_A3 220 -#define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 -#define NOTE_CS4 277 -#define NOTE_D4 294 -#define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 -#define NOTE_FS4 370 -#define NOTE_G4 392 -#define NOTE_GS4 415 -#define NOTE_A4 440 -#define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 -#define NOTE_CS5 554 -#define NOTE_D5 587 -#define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 -#define NOTE_FS5 740 -#define NOTE_G5 784 -#define NOTE_GS5 831 -#define NOTE_A5 880 -#define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 -#define NOTE_CS6 1109 -#define NOTE_D6 1175 -#define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 -#define NOTE_FS6 1480 -#define NOTE_G6 1568 -#define NOTE_GS6 1661 -#define NOTE_A6 1760 -#define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 -#define NOTE_CS7 2217 -#define NOTE_D7 2349 -#define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 -#define NOTE_FS7 2960 -#define NOTE_G7 3136 -#define NOTE_GS7 3322 -#define NOTE_A7 3520 -#define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 -#define NOTE_CS8 4435 -#define NOTE_D8 4699 -#define NOTE_DS8 4978 - -#include "ToneWrapper.h" - -namespace nanpy { - - class ToneClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/ToneWrapper.cpp b/ToneWrapper.cpp deleted file mode 100644 index 2042d21..0000000 --- a/ToneWrapper.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "cfg_all.h" - -#if USE_Tone - -#include "ToneWrapper.h" -#include - -void nanpy::ToneWrapper::play(int note, int duration) { - #if defined(__AVR__) - tone(pin, note); - #endif -} - -void nanpy::ToneWrapper::stop(void) { - #if defined(__AVR__) - noTone(pin); - #endif -} - -#endif diff --git a/ToneWrapper.h b/ToneWrapper.h deleted file mode 100644 index bd64b18..0000000 --- a/ToneWrapper.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TONE_WRAPPER_H -#define TONE_WRAPPER_H - -namespace nanpy { -class ToneWrapper { - - private: - - int pin; - - public: - - ToneWrapper(int pin) : pin(pin) {} - void play(int note, int duration); - void stop(void); - -}; -} - -#endif diff --git a/UltrasonicClass.cpp b/UltrasonicClass.cpp deleted file mode 100644 index 2e977c3..0000000 --- a/UltrasonicClass.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "cfg_all.h" - -#include -#include "UltrasonicClass.h" -#include - -const char* nanpy::UltrasonicClass::get_firmware_id() { - return "Ultrasonic"; -} - -void nanpy::UltrasonicClass::elaborate( MethodDescriptor* m ) { - ObjectsManager::elaborate(m); - - if (strcmp(m->getName(), "new") == 0) { - v.insert(new UltrasonicWrapper(m->getInt(0), m->getInt(1), m->getBool(2))); - m->returns(v.getLastIndex()); - } - - if (strcmp(m->getName(), "get_distance") == 0) { - m->returns(v[m->getObjectId()]->getDistance()); - } -} diff --git a/UltrasonicClass.h b/UltrasonicClass.h deleted file mode 100644 index 5ded5f0..0000000 --- a/UltrasonicClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ULTRASONIC_CLASS -#define ULTRASONIC_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" -#include "UltrasonicWrapper.h" - -class Ultrasonic; - -namespace nanpy { - class UltrasonicClass: public ObjectsManager { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - }; -} - -#endif diff --git a/UltrasonicWrapper.cpp b/UltrasonicWrapper.cpp deleted file mode 100644 index ee5f266..0000000 --- a/UltrasonicWrapper.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "cfg_all.h" - -#if USE_Ultrasonic - -#include "UltrasonicWrapper.h" -#include - -nanpy::UltrasonicWrapper::UltrasonicWrapper(int echoPin, int trigPin, bool useInches) { - echo = echoPin; - trig = trigPin; - - if (useInches) { - conversionFactor = 74; - } else { - conversionFactor = 29; - } - - pinMode(echo, INPUT); - pinMode(trig, OUTPUT); - } - -float nanpy::UltrasonicWrapper::getDistance() { - // Code goes here for getDistance() - int duration; - float distance; - - digitalWrite(trig, LOW); - delayMicroseconds(2); - digitalWrite(trig, HIGH); - delayMicroseconds(10); - digitalWrite(trig, LOW); - - // Get the echo pulse that will last the time between the ultrasound signal has been emited and its echo has been received. - duration = pulseIn(echo, HIGH); - // Sound speed throw the air is 343m/s at 20ºC. Given that pulseIn returns microseconds and the pulse has travelled - // twice the distance between the sensor and the blocking object, we have: - // distance (in meters) = duration (in microseconds) x 343 / 1000000 (microseconds per second) / 2 - // We are working with distances ranging from 10 to 200 cm so meters are too big for us. We need to work with cm. - // Sound speed will be 34300 cm/s andif we invert that 34300 / 1000000 => 1000000 / 34300 = 29,15... - // we can express the same formula as: - // distance (in centimeters) = duration (in microseconds) / 29 / 2 that is much simpler and faster to compute. - - distance = duration / conversionFactor / 2; - - return distance; -} - -#endif diff --git a/UltrasonicWrapper.h b/UltrasonicWrapper.h deleted file mode 100644 index 20f0d84..0000000 --- a/UltrasonicWrapper.h +++ /dev/null @@ -1,12 +0,0 @@ -namespace nanpy { - - class UltrasonicWrapper { - - private: - int echo, trig, conversionFactor; - - public: - UltrasonicWrapper(int echoPin, int trigPin, bool useInches); - float getDistance(); - }; -} diff --git a/WatchdogClass.cpp b/WatchdogClass.cpp deleted file mode 100644 index 884ee65..0000000 --- a/WatchdogClass.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "cfg_all.h" - -#if USE_Watchdog - -#include -#include "WatchdogClass.h" -#include -#include - -const char* nanpy::WatchdogClass::get_firmware_id() -{ - return "Watchdog"; -} - -void nanpy::WatchdogClass::elaborate(nanpy::MethodDescriptor* m) -{ - if (strcmp(m->getName(), "reset") == 0) - { - wdt_reset(); - m->returns(0); - } - if (strcmp(m->getName(), "enable") == 0) - { - wdt_enable(m->getInt(0)); - m->returns(0); - } - if (strcmp(m->getName(), "disable") == 0) - { - wdt_disable(); - m->returns(0); - } -} - -#endif - -void disable_watchdog_at_startup() -{ - // disable watchdog at startup - // http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html - // "the watchdog timer remains active even after a system reset (except a power-on condition), - // using the fastest prescaler value (approximately 15 ms). - // It is therefore required to turn off the watchdog early during program startup,.." - // "..clearing the watchdog reset flag before disabling the watchdog is required, according to the datasheet." -#ifdef MCUSR - MCUSR = 0; - wdt_disable(); -#endif -} diff --git a/WatchdogClass.h b/WatchdogClass.h deleted file mode 100644 index 8383785..0000000 --- a/WatchdogClass.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -namespace nanpy { - class WatchdogClass : public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -}; - -void disable_watchdog_at_startup(); diff --git a/WireClass.cpp b/WireClass.cpp deleted file mode 100644 index bc9d536..0000000 --- a/WireClass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "cfg_all.h" - -#if USE_Wire - -#include -#include -#include "WireClass.h" -#include - -const char* nanpy::WireClass::get_firmware_id() -{ - return "Wire"; -} - -void nanpy::WireClass::elaborate( MethodDescriptor* m ) { - - if (strcmp(m->getName(), "begin") == 0) { - if (m->getNArgs()) - { - // slave - Wire.begin(m->getInt(0)); - } - else - { - // master - Wire.begin(); - } - m->returns(0); - } - if (strcmp(m->getName(), "requestFrom") == 0) { - byte x = Wire.requestFrom(m->getInt(0), m->getInt(1), m->getInt(2)); - m->returns(x); - } - if (strcmp(m->getName(), "beginTransmission") == 0) { - Wire.beginTransmission(m->getInt(0)); - m->returns(0); - } - if (strcmp(m->getName(), "endTransmission") == 0) { - byte x = Wire.endTransmission(m->getInt(0)); - m->returns(x); - } - if (strcmp(m->getName(), "write") == 0) { - // string and array writes are not implemented - byte x = Wire.write(m->getInt(0)); - m->returns(x); - } - if (strcmp(m->getName(), "available") == 0) { - int x = Wire.available(); - m->returns(x); - } - if (strcmp(m->getName(), "read") == 0) { - byte x = Wire.read(); - m->returns(x); - } - - // onReceive and onRequest are not implemented - -}; - -#endif diff --git a/WireClass.h b/WireClass.h deleted file mode 100644 index bd69378..0000000 --- a/WireClass.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef Wire_CLASS -#define Wire_CLASS - -#include "BaseClass.h" -#include "MethodDescriptor.h" - -class Wire; - -namespace nanpy { - class WireClass: public BaseClass { - - public: - void elaborate( nanpy::MethodDescriptor* m ); - const char* get_firmware_id(); - - }; -} - -#endif diff --git a/cfg.h b/cfg.h deleted file mode 100644 index c84dcb2..0000000 --- a/cfg.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once - - -// only for ESP8266 -#define USE_WIFI_CONNECTION 1 - -// for WIFI connection -#define WIFI_SSID "Infected Network Detected" -#define WIFI_PASSWORD "DeaDlyDavisson" - - -// for serial connection -#define BAUDRATE 115200 -#define COMM_SERIAL Serial - -// info about existence of other features -#define USE_Info 1 - -// definitions: MCU type, frequency, Arduino version, -// EEPROM size, RAM size, pin count, build time,.. -#define USE_Define 1 - -// low level mapping of pins and ports -#define USE_ArduinoCore 1 - -// read, write RAM -#define USE_RAM 1 - -// read, write EEPROM -#define USE_EEPROM 1 - -// read, write AVR registers -#define USE_Register 0 - -// watchdog and reset -#define USE_Watchdog 0 - -#define USE_Tone 0 - -#define USE_LiquidCrystal 0 - -// I2C -#define USE_Wire 0 - -#define USE_Servo 0 - -#define USE_Stepper 0 - -// frequency counter, USE_Tone should be off! -#define USE_Counter 0 - -// GW Robotics Classes -#define USE_Ultrasonic 0 -#define USE_ColorSensor 0 - -/////////////////////////////////////////////////////////////////////// -// external libraries should be installed for the following features: -/////////////////////////////////////////////////////////////////////// - -// install with Library Manager: "OneWire" -// https://github.com/PaulStoffregen/OneWire -#define USE_OneWire 0 - -// install with Library Manager: "DallasTemperature" -// https://github.com/milesburton/Arduino-Temperature-Control-Library -#define USE_DallasTemperature 0 - - -// install with Library Manager: "CapacitiveSensor" -// https://github.com/PaulStoffregen/CapacitiveSensor -#define USE_CapacitiveSensor 0 - -// install with Library Manager: "DHT sensor library","Adafruit Unified Sensor" -// https://github.com/adafruit/DHT-sensor-library -#define USE_DHT 1 - -// https://bitbucket.org/fmalpartida/new-liquidcrystal -#define USE_LiquidCrystal_I2C 0 - -// install with Library Manager: "Adafruit TLC5947" -// https://github.com/adafruit/Adafruit_TLC5947 -#define USE_TLC5947 0 - -// install with Library Manager: "MCP41XXX" -// https://github.com/ArduinoMax/MCP41xxx -#define USE_MCP41xxx 0 diff --git a/cfg_all.h b/cfg_all.h deleted file mode 100644 index bcd533c..0000000 --- a/cfg_all.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include "cfg.h" -#include "cfg_defaults.h" -#include "cfg_check.h" diff --git a/cfg_check.h b/cfg_check.h deleted file mode 100644 index ca8b1aa..0000000 --- a/cfg_check.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -// check configuration for compatibility - -#ifndef ARDUINO_ARCH_AVR -// disable AVR only features -#define USE_ArduinoCore 0 -//#define USE_RAM 0 -#define USE_EEPROM 0 -#define USE_Register 0 -#define USE_Watchdog 0 -#define USE_Counter 0 -#define USE_DHT 0 -#define USE_LiquidCrystal_I2C 0 -#define USE_LiquidCrystal 0 -#endif - -// check configuration for problems - -#ifdef ARDUINO_ARCH_AVR -#if USE_Tone -# if USE_Counter -# error "USE_Tone conflicts with USE_Counter!" -# endif -#endif -#endif - -#ifdef ESP8266 -# define USE_ESP 1 -#else -#ifdef ESP32 -# define USE_ESP_32 1 -# define USE_ESP 1 -# define USE_DHT 1 -#else -# define USE_ESP 0 -#endif -#endif - -#ifndef ESP8266 -#ifndef ESP32 -# define USE_WIFI_CONNECTION 0 -#endif -#endif diff --git a/cfg_defaults.h b/cfg_defaults.h deleted file mode 100644 index 3e835f0..0000000 --- a/cfg_defaults.h +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -// default configuration - -// All these settings can be overwritten in cfg.h - -#ifndef COMM_SERIAL -# define COMM_SERIAL Serial -#endif - -#ifndef USE_WIFI_CONNECTION -# define USE_WIFI_CONNECTION 0 -#endif - -#ifndef BAUDRATE -# define BAUDRATE 115200 -#endif - -#ifndef USE_Servo -# define USE_Servo 0 -#endif - -#ifndef USE_Tone -# define USE_Tone 0 -#endif - -#ifndef USE_LiquidCrystal -# define USE_LiquidCrystal 0 -#endif - -#ifndef USE_Stepper -# define USE_Stepper 0 -#endif - -#ifndef USE_EEPROM -# define USE_EEPROM 0 -#endif - -#ifndef USE_RAM -# define USE_RAM 0 -#endif - -#ifndef USE_Define -# define USE_Define 0 -#endif - -#ifndef USE_ArduinoCore -# define USE_ArduinoCore 0 -#endif - -#ifndef USE_Watchdog -# define USE_Watchdog 0 -#endif - -#ifndef USE_Register -# define USE_Register 0 -#endif - -#ifndef USE_Info -# define USE_Info 0 -#endif - -#ifndef USE_Counter -# define USE_Counter 0 -#endif - -#ifndef USE_Wire -# define USE_Wire 0 -#endif - -#ifndef USE_OneWire -# define USE_OneWire 0 -#endif - -#ifndef USE_DallasTemperature -# define USE_DallasTemperature 0 -#endif - -#ifndef USE_CapacitiveSensor -# define USE_CapacitiveSensor 0 -#endif - -#ifndef USE_DHT -# define USE_DHT 1 -#endif - -#ifndef USE_LiquidCrystal_I2C -# define USE_LiquidCrystal_I2C 0 -#endif - -#ifndef USE_TLC5947 -# define USE_TLC5947 0 -#endif - -#ifndef USE_MCP41xxx -# define USE_MCP41xxx 0 -#endif - -#ifndef USE_Ultrasonic -# define USE_Ultrasonic 0 -#endif - -#ifndef USE_ColorSensor -# define USE_ColorSensor 0 -#endif diff --git a/consts.h b/consts.h deleted file mode 100644 index 3cd1b46..0000000 --- a/consts.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define MAX_READ_BUFFER_SIZE 50 diff --git a/freeram.c b/freeram.c deleted file mode 100644 index 9056f39..0000000 --- a/freeram.c +++ /dev/null @@ -1,65 +0,0 @@ -#if defined(__AVR__) -#include -#include - - -extern unsigned int __bss_end; -extern unsigned int __heap_start; -extern void *__brkval; -extern unsigned int __data_start; - -/// return available RAM -int free_ram1() -{ - /// copy from http://arduino.cc/playground/Code/AvailableMemory - int free_memory; - - if ((int) __brkval == 0) - free_memory = ((int) &free_memory) - ((int) &__bss_end); - else - free_memory = ((int) &free_memory) - ((int) __brkval); - - return free_memory; -} - -/// return available RAM -/*! This function places the current value of the heap and stack pointers in the - * variables. You can call it from any place in your code and save the data for - * outputting or displaying later. This allows you to check at different parts of - * your program flow. - * The stack pointer starts at the top of RAM and grows downwards. The heap pointer - * starts just above the static variables etc. and grows upwards. SP should always - * be larger than HP or you'll be in big trouble! The smaller the gap, the more - * careful you need to be. Julian Gall 6-Feb-2009. - */ -int free_ram2() -{ - /// copy from http://arduino.cc/playground/Code/AvailableMemory - uint8_t * heapptr, *stackptr; - - stackptr = (uint8_t *) malloc(4); // use stackptr temporarily - heapptr = stackptr; // save value of heap pointer - free(stackptr); // free up the memory again (sets stackptr to 0) - stackptr = (uint8_t *) (SP); // save value of stack pointer - return (int) (stackptr - heapptr); -} - -/// return available RAM - -/// this function will return the number of bytes currently free in RAM -/// written by David A. Mellis -/// based on code by Rob Faludi http://www.faludi.com -int free_ram3() -{ - /// copy from http://arduino.cc/playground/Code/AvailableMemory - int size = (int) RAMEND - (int) &__data_start; - uint8_t *buf; - - while ((buf = (uint8_t *) malloc(--size)) == NULL) - ; - - free(buf); - - return size; -} -#endif diff --git a/freeram.h b/freeram.h deleted file mode 100644 index f1dba7a..0000000 --- a/freeram.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" -{ -#endif - -int free_ram1(); -int free_ram2(); -int free_ram3(); - -#ifdef __cplusplus -} -#endif diff --git a/generated_avr_registers.h b/generated_avr_registers.h deleted file mode 100644 index dce2e9b..0000000 --- a/generated_avr_registers.h +++ /dev/null @@ -1,13764 +0,0 @@ - -// this file was generated by codegen.py - -// __AVR_LIBC_VERSION_STRING__ = "1.8.0" -// __AVR_LIBC_DATE_STRING__ = "20111228" - - -#ifdef AC0CON - DEFINE(AC0CON) -#else - MISSING(AC0CON) -#endif - -#ifdef AC1CON - DEFINE(AC1CON) -#else - MISSING(AC1CON) -#endif - -#ifdef AC1ECON - DEFINE(AC1ECON) -#else - MISSING(AC1ECON) -#endif - -#ifdef AC2CON - DEFINE(AC2CON) -#else - MISSING(AC2CON) -#endif - -#ifdef AC2ECON - DEFINE(AC2ECON) -#else - MISSING(AC2ECON) -#endif - -#ifdef AC3CON - DEFINE(AC3CON) -#else - MISSING(AC3CON) -#endif - -#ifdef AC3ECON - DEFINE(AC3ECON) -#else - MISSING(AC3ECON) -#endif - -#ifdef ACA_AC0CTRL - DEFINE(ACA_AC0CTRL) -#else - MISSING(ACA_AC0CTRL) -#endif - -#ifdef ACA_AC0MUXCTRL - DEFINE(ACA_AC0MUXCTRL) -#else - MISSING(ACA_AC0MUXCTRL) -#endif - -#ifdef ACA_AC1CTRL - DEFINE(ACA_AC1CTRL) -#else - MISSING(ACA_AC1CTRL) -#endif - -#ifdef ACA_AC1MUXCTRL - DEFINE(ACA_AC1MUXCTRL) -#else - MISSING(ACA_AC1MUXCTRL) -#endif - -#ifdef ACA_CTRLA - DEFINE(ACA_CTRLA) -#else - MISSING(ACA_CTRLA) -#endif - -#ifdef ACA_CTRLB - DEFINE(ACA_CTRLB) -#else - MISSING(ACA_CTRLB) -#endif - -#ifdef ACA_STATUS - DEFINE(ACA_STATUS) -#else - MISSING(ACA_STATUS) -#endif - -#ifdef ACA_WINCTRL - DEFINE(ACA_WINCTRL) -#else - MISSING(ACA_WINCTRL) -#endif - -#ifdef ACB_AC0CTRL - DEFINE(ACB_AC0CTRL) -#else - MISSING(ACB_AC0CTRL) -#endif - -#ifdef ACB_AC0MUXCTRL - DEFINE(ACB_AC0MUXCTRL) -#else - MISSING(ACB_AC0MUXCTRL) -#endif - -#ifdef ACB_AC1CTRL - DEFINE(ACB_AC1CTRL) -#else - MISSING(ACB_AC1CTRL) -#endif - -#ifdef ACB_AC1MUXCTRL - DEFINE(ACB_AC1MUXCTRL) -#else - MISSING(ACB_AC1MUXCTRL) -#endif - -#ifdef ACB_CTRLA - DEFINE(ACB_CTRLA) -#else - MISSING(ACB_CTRLA) -#endif - -#ifdef ACB_CTRLB - DEFINE(ACB_CTRLB) -#else - MISSING(ACB_CTRLB) -#endif - -#ifdef ACB_STATUS - DEFINE(ACB_STATUS) -#else - MISSING(ACB_STATUS) -#endif - -#ifdef ACB_WINCTRL - DEFINE(ACB_WINCTRL) -#else - MISSING(ACB_WINCTRL) -#endif - -#ifdef ACSR - DEFINE(ACSR) -#else - MISSING(ACSR) -#endif - -#ifdef ACSRA - DEFINE(ACSRA) -#else - MISSING(ACSRA) -#endif - -#ifdef ACSRB - DEFINE(ACSRB) -#else - MISSING(ACSRB) -#endif - -#ifdef ADC - DEFINE(ADC) -#else - MISSING(ADC) -#endif - -#ifdef ADCA_CAL - DEFINE(ADCA_CAL) -#else - MISSING(ADCA_CAL) -#endif - -#ifdef ADCA_CH0RES - DEFINE(ADCA_CH0RES) -#else - MISSING(ADCA_CH0RES) -#endif - -#ifdef ADCA_CH0_CTRL - DEFINE(ADCA_CH0_CTRL) -#else - MISSING(ADCA_CH0_CTRL) -#endif - -#ifdef ADCA_CH0_INTCTRL - DEFINE(ADCA_CH0_INTCTRL) -#else - MISSING(ADCA_CH0_INTCTRL) -#endif - -#ifdef ADCA_CH0_INTFLAGS - DEFINE(ADCA_CH0_INTFLAGS) -#else - MISSING(ADCA_CH0_INTFLAGS) -#endif - -#ifdef ADCA_CH0_MUXCTRL - DEFINE(ADCA_CH0_MUXCTRL) -#else - MISSING(ADCA_CH0_MUXCTRL) -#endif - -#ifdef ADCA_CH0_RES - DEFINE(ADCA_CH0_RES) -#else - MISSING(ADCA_CH0_RES) -#endif - -#ifdef ADCA_CH1RES - DEFINE(ADCA_CH1RES) -#else - MISSING(ADCA_CH1RES) -#endif - -#ifdef ADCA_CH1_CTRL - DEFINE(ADCA_CH1_CTRL) -#else - MISSING(ADCA_CH1_CTRL) -#endif - -#ifdef ADCA_CH1_INTCTRL - DEFINE(ADCA_CH1_INTCTRL) -#else - MISSING(ADCA_CH1_INTCTRL) -#endif - -#ifdef ADCA_CH1_INTFLAGS - DEFINE(ADCA_CH1_INTFLAGS) -#else - MISSING(ADCA_CH1_INTFLAGS) -#endif - -#ifdef ADCA_CH1_MUXCTRL - DEFINE(ADCA_CH1_MUXCTRL) -#else - MISSING(ADCA_CH1_MUXCTRL) -#endif - -#ifdef ADCA_CH1_RES - DEFINE(ADCA_CH1_RES) -#else - MISSING(ADCA_CH1_RES) -#endif - -#ifdef ADCA_CH2RES - DEFINE(ADCA_CH2RES) -#else - MISSING(ADCA_CH2RES) -#endif - -#ifdef ADCA_CH2_CTRL - DEFINE(ADCA_CH2_CTRL) -#else - MISSING(ADCA_CH2_CTRL) -#endif - -#ifdef ADCA_CH2_INTCTRL - DEFINE(ADCA_CH2_INTCTRL) -#else - MISSING(ADCA_CH2_INTCTRL) -#endif - -#ifdef ADCA_CH2_INTFLAGS - DEFINE(ADCA_CH2_INTFLAGS) -#else - MISSING(ADCA_CH2_INTFLAGS) -#endif - -#ifdef ADCA_CH2_MUXCTRL - DEFINE(ADCA_CH2_MUXCTRL) -#else - MISSING(ADCA_CH2_MUXCTRL) -#endif - -#ifdef ADCA_CH2_RES - DEFINE(ADCA_CH2_RES) -#else - MISSING(ADCA_CH2_RES) -#endif - -#ifdef ADCA_CH3RES - DEFINE(ADCA_CH3RES) -#else - MISSING(ADCA_CH3RES) -#endif - -#ifdef ADCA_CH3_CTRL - DEFINE(ADCA_CH3_CTRL) -#else - MISSING(ADCA_CH3_CTRL) -#endif - -#ifdef ADCA_CH3_INTCTRL - DEFINE(ADCA_CH3_INTCTRL) -#else - MISSING(ADCA_CH3_INTCTRL) -#endif - -#ifdef ADCA_CH3_INTFLAGS - DEFINE(ADCA_CH3_INTFLAGS) -#else - MISSING(ADCA_CH3_INTFLAGS) -#endif - -#ifdef ADCA_CH3_MUXCTRL - DEFINE(ADCA_CH3_MUXCTRL) -#else - MISSING(ADCA_CH3_MUXCTRL) -#endif - -#ifdef ADCA_CH3_RES - DEFINE(ADCA_CH3_RES) -#else - MISSING(ADCA_CH3_RES) -#endif - -#ifdef ADCA_CMP - DEFINE(ADCA_CMP) -#else - MISSING(ADCA_CMP) -#endif - -#ifdef ADCA_CTRLA - DEFINE(ADCA_CTRLA) -#else - MISSING(ADCA_CTRLA) -#endif - -#ifdef ADCA_CTRLB - DEFINE(ADCA_CTRLB) -#else - MISSING(ADCA_CTRLB) -#endif - -#ifdef ADCA_EVCTRL - DEFINE(ADCA_EVCTRL) -#else - MISSING(ADCA_EVCTRL) -#endif - -#ifdef ADCA_INTFLAGS - DEFINE(ADCA_INTFLAGS) -#else - MISSING(ADCA_INTFLAGS) -#endif - -#ifdef ADCA_PRESCALER - DEFINE(ADCA_PRESCALER) -#else - MISSING(ADCA_PRESCALER) -#endif - -#ifdef ADCA_REFCTRL - DEFINE(ADCA_REFCTRL) -#else - MISSING(ADCA_REFCTRL) -#endif - -#ifdef ADCA_TEMP - DEFINE(ADCA_TEMP) -#else - MISSING(ADCA_TEMP) -#endif - -#ifdef ADCB_CAL - DEFINE(ADCB_CAL) -#else - MISSING(ADCB_CAL) -#endif - -#ifdef ADCB_CH0RES - DEFINE(ADCB_CH0RES) -#else - MISSING(ADCB_CH0RES) -#endif - -#ifdef ADCB_CH0_CTRL - DEFINE(ADCB_CH0_CTRL) -#else - MISSING(ADCB_CH0_CTRL) -#endif - -#ifdef ADCB_CH0_INTCTRL - DEFINE(ADCB_CH0_INTCTRL) -#else - MISSING(ADCB_CH0_INTCTRL) -#endif - -#ifdef ADCB_CH0_INTFLAGS - DEFINE(ADCB_CH0_INTFLAGS) -#else - MISSING(ADCB_CH0_INTFLAGS) -#endif - -#ifdef ADCB_CH0_MUXCTRL - DEFINE(ADCB_CH0_MUXCTRL) -#else - MISSING(ADCB_CH0_MUXCTRL) -#endif - -#ifdef ADCB_CH0_RES - DEFINE(ADCB_CH0_RES) -#else - MISSING(ADCB_CH0_RES) -#endif - -#ifdef ADCB_CH1RES - DEFINE(ADCB_CH1RES) -#else - MISSING(ADCB_CH1RES) -#endif - -#ifdef ADCB_CH1_CTRL - DEFINE(ADCB_CH1_CTRL) -#else - MISSING(ADCB_CH1_CTRL) -#endif - -#ifdef ADCB_CH1_INTCTRL - DEFINE(ADCB_CH1_INTCTRL) -#else - MISSING(ADCB_CH1_INTCTRL) -#endif - -#ifdef ADCB_CH1_INTFLAGS - DEFINE(ADCB_CH1_INTFLAGS) -#else - MISSING(ADCB_CH1_INTFLAGS) -#endif - -#ifdef ADCB_CH1_MUXCTRL - DEFINE(ADCB_CH1_MUXCTRL) -#else - MISSING(ADCB_CH1_MUXCTRL) -#endif - -#ifdef ADCB_CH1_RES - DEFINE(ADCB_CH1_RES) -#else - MISSING(ADCB_CH1_RES) -#endif - -#ifdef ADCB_CH2RES - DEFINE(ADCB_CH2RES) -#else - MISSING(ADCB_CH2RES) -#endif - -#ifdef ADCB_CH2_CTRL - DEFINE(ADCB_CH2_CTRL) -#else - MISSING(ADCB_CH2_CTRL) -#endif - -#ifdef ADCB_CH2_INTCTRL - DEFINE(ADCB_CH2_INTCTRL) -#else - MISSING(ADCB_CH2_INTCTRL) -#endif - -#ifdef ADCB_CH2_INTFLAGS - DEFINE(ADCB_CH2_INTFLAGS) -#else - MISSING(ADCB_CH2_INTFLAGS) -#endif - -#ifdef ADCB_CH2_MUXCTRL - DEFINE(ADCB_CH2_MUXCTRL) -#else - MISSING(ADCB_CH2_MUXCTRL) -#endif - -#ifdef ADCB_CH2_RES - DEFINE(ADCB_CH2_RES) -#else - MISSING(ADCB_CH2_RES) -#endif - -#ifdef ADCB_CH3RES - DEFINE(ADCB_CH3RES) -#else - MISSING(ADCB_CH3RES) -#endif - -#ifdef ADCB_CH3_CTRL - DEFINE(ADCB_CH3_CTRL) -#else - MISSING(ADCB_CH3_CTRL) -#endif - -#ifdef ADCB_CH3_INTCTRL - DEFINE(ADCB_CH3_INTCTRL) -#else - MISSING(ADCB_CH3_INTCTRL) -#endif - -#ifdef ADCB_CH3_INTFLAGS - DEFINE(ADCB_CH3_INTFLAGS) -#else - MISSING(ADCB_CH3_INTFLAGS) -#endif - -#ifdef ADCB_CH3_MUXCTRL - DEFINE(ADCB_CH3_MUXCTRL) -#else - MISSING(ADCB_CH3_MUXCTRL) -#endif - -#ifdef ADCB_CH3_RES - DEFINE(ADCB_CH3_RES) -#else - MISSING(ADCB_CH3_RES) -#endif - -#ifdef ADCB_CMP - DEFINE(ADCB_CMP) -#else - MISSING(ADCB_CMP) -#endif - -#ifdef ADCB_CTRLA - DEFINE(ADCB_CTRLA) -#else - MISSING(ADCB_CTRLA) -#endif - -#ifdef ADCB_CTRLB - DEFINE(ADCB_CTRLB) -#else - MISSING(ADCB_CTRLB) -#endif - -#ifdef ADCB_EVCTRL - DEFINE(ADCB_EVCTRL) -#else - MISSING(ADCB_EVCTRL) -#endif - -#ifdef ADCB_INTFLAGS - DEFINE(ADCB_INTFLAGS) -#else - MISSING(ADCB_INTFLAGS) -#endif - -#ifdef ADCB_PRESCALER - DEFINE(ADCB_PRESCALER) -#else - MISSING(ADCB_PRESCALER) -#endif - -#ifdef ADCB_REFCTRL - DEFINE(ADCB_REFCTRL) -#else - MISSING(ADCB_REFCTRL) -#endif - -#ifdef ADCB_TEMP - DEFINE(ADCB_TEMP) -#else - MISSING(ADCB_TEMP) -#endif - -#ifdef ADCH - DEFINE(ADCH) -#else - MISSING(ADCH) -#endif - -#ifdef ADCL - DEFINE(ADCL) -#else - MISSING(ADCL) -#endif - -#ifdef ADCRA - DEFINE(ADCRA) -#else - MISSING(ADCRA) -#endif - -#ifdef ADCRB - DEFINE(ADCRB) -#else - MISSING(ADCRB) -#endif - -#ifdef ADCRC - DEFINE(ADCRC) -#else - MISSING(ADCRC) -#endif - -#ifdef ADCRD - DEFINE(ADCRD) -#else - MISSING(ADCRD) -#endif - -#ifdef ADCRE - DEFINE(ADCRE) -#else - MISSING(ADCRE) -#endif - -#ifdef ADCSR - DEFINE(ADCSR) -#else - MISSING(ADCSR) -#endif - -#ifdef ADCSRA - DEFINE(ADCSRA) -#else - MISSING(ADCSRA) -#endif - -#ifdef ADCSRB - DEFINE(ADCSRB) -#else - MISSING(ADCSRB) -#endif - -#ifdef ADCSRC - DEFINE(ADCSRC) -#else - MISSING(ADCSRC) -#endif - -#ifdef ADCW - DEFINE(ADCW) -#else - MISSING(ADCW) -#endif - -#ifdef ADCWH - DEFINE(ADCWH) -#else - MISSING(ADCWH) -#endif - -#ifdef ADCWL - DEFINE(ADCWL) -#else - MISSING(ADCWL) -#endif - -#ifdef ADIFR - DEFINE(ADIFR) -#else - MISSING(ADIFR) -#endif - -#ifdef ADIMR - DEFINE(ADIMR) -#else - MISSING(ADIMR) -#endif - -#ifdef ADMUX - DEFINE(ADMUX) -#else - MISSING(ADMUX) -#endif - -#ifdef ADRSLT - DEFINE(ADRSLT) -#else - MISSING(ADRSLT) -#endif - -#ifdef ADRSLTH - DEFINE(ADRSLTH) -#else - MISSING(ADRSLTH) -#endif - -#ifdef ADRSLTHI - DEFINE(ADRSLTHI) -#else - MISSING(ADRSLTHI) -#endif - -#ifdef ADRSLTL - DEFINE(ADRSLTL) -#else - MISSING(ADRSLTL) -#endif - -#ifdef ADRSLTLO - DEFINE(ADRSLTLO) -#else - MISSING(ADRSLTLO) -#endif - -#ifdef ADSCSRA - DEFINE(ADSCSRA) -#else - MISSING(ADSCSRA) -#endif - -#ifdef ADSCSRB - DEFINE(ADSCSRB) -#else - MISSING(ADSCSRB) -#endif - -#ifdef AESACR - DEFINE(AESACR) -#else - MISSING(AESACR) -#endif - -#ifdef AESADDR - DEFINE(AESADDR) -#else - MISSING(AESADDR) -#endif - -#ifdef AESCR - DEFINE(AESCR) -#else - MISSING(AESCR) -#endif - -#ifdef AESDR - DEFINE(AESDR) -#else - MISSING(AESDR) -#endif - -#ifdef AES_CTRL - DEFINE(AES_CTRL) -#else - MISSING(AES_CTRL) -#endif - -#ifdef AES_INTCTRL - DEFINE(AES_INTCTRL) -#else - MISSING(AES_INTCTRL) -#endif - -#ifdef AES_KEY - DEFINE(AES_KEY) -#else - MISSING(AES_KEY) -#endif - -#ifdef AES_STATE - DEFINE(AES_STATE) -#else - MISSING(AES_STATE) -#endif - -#ifdef AES_STATUS - DEFINE(AES_STATUS) -#else - MISSING(AES_STATUS) -#endif - -#ifdef AGPDDR - DEFINE(AGPDDR) -#else - MISSING(AGPDDR) -#endif - -#ifdef AGPPIN - DEFINE(AGPPIN) -#else - MISSING(AGPPIN) -#endif - -#ifdef AGPPORT - DEFINE(AGPPORT) -#else - MISSING(AGPPORT) -#endif - -#ifdef AMISCR - DEFINE(AMISCR) -#else - MISSING(AMISCR) -#endif - -#ifdef AMP0CSR - DEFINE(AMP0CSR) -#else - MISSING(AMP0CSR) -#endif - -#ifdef AMP1CSR - DEFINE(AMP1CSR) -#else - MISSING(AMP1CSR) -#endif - -#ifdef AMP2CSR - DEFINE(AMP2CSR) -#else - MISSING(AMP2CSR) -#endif - -#ifdef AMUXCTL - DEFINE(AMUXCTL) -#else - MISSING(AMUXCTL) -#endif - -#ifdef ANT_DIV - DEFINE(ANT_DIV) -#else - MISSING(ANT_DIV) -#endif - -#ifdef ASSR - DEFINE(ASSR) -#else - MISSING(ASSR) -#endif - -#ifdef AVR_CONFIG - DEFINE(AVR_CONFIG) -#else - MISSING(AVR_CONFIG) -#endif - -#ifdef AWEXC_CTRL - DEFINE(AWEXC_CTRL) -#else - MISSING(AWEXC_CTRL) -#endif - -#ifdef AWEXC_DTBOTH - DEFINE(AWEXC_DTBOTH) -#else - MISSING(AWEXC_DTBOTH) -#endif - -#ifdef AWEXC_DTBOTHBUF - DEFINE(AWEXC_DTBOTHBUF) -#else - MISSING(AWEXC_DTBOTHBUF) -#endif - -#ifdef AWEXC_DTHS - DEFINE(AWEXC_DTHS) -#else - MISSING(AWEXC_DTHS) -#endif - -#ifdef AWEXC_DTHSBUF - DEFINE(AWEXC_DTHSBUF) -#else - MISSING(AWEXC_DTHSBUF) -#endif - -#ifdef AWEXC_DTLS - DEFINE(AWEXC_DTLS) -#else - MISSING(AWEXC_DTLS) -#endif - -#ifdef AWEXC_DTLSBUF - DEFINE(AWEXC_DTLSBUF) -#else - MISSING(AWEXC_DTLSBUF) -#endif - -#ifdef AWEXC_FDCTRL - DEFINE(AWEXC_FDCTRL) -#else - MISSING(AWEXC_FDCTRL) -#endif - -#ifdef AWEXC_FDEMASK - DEFINE(AWEXC_FDEMASK) -#else - MISSING(AWEXC_FDEMASK) -#endif - -#ifdef AWEXC_OUTOVEN - DEFINE(AWEXC_OUTOVEN) -#else - MISSING(AWEXC_OUTOVEN) -#endif - -#ifdef AWEXC_STATUS - DEFINE(AWEXC_STATUS) -#else - MISSING(AWEXC_STATUS) -#endif - -#ifdef AWEXE_CTRL - DEFINE(AWEXE_CTRL) -#else - MISSING(AWEXE_CTRL) -#endif - -#ifdef AWEXE_DTBOTH - DEFINE(AWEXE_DTBOTH) -#else - MISSING(AWEXE_DTBOTH) -#endif - -#ifdef AWEXE_DTBOTHBUF - DEFINE(AWEXE_DTBOTHBUF) -#else - MISSING(AWEXE_DTBOTHBUF) -#endif - -#ifdef AWEXE_DTHS - DEFINE(AWEXE_DTHS) -#else - MISSING(AWEXE_DTHS) -#endif - -#ifdef AWEXE_DTHSBUF - DEFINE(AWEXE_DTHSBUF) -#else - MISSING(AWEXE_DTHSBUF) -#endif - -#ifdef AWEXE_DTLS - DEFINE(AWEXE_DTLS) -#else - MISSING(AWEXE_DTLS) -#endif - -#ifdef AWEXE_DTLSBUF - DEFINE(AWEXE_DTLSBUF) -#else - MISSING(AWEXE_DTLSBUF) -#endif - -#ifdef AWEXE_FDCTRL - DEFINE(AWEXE_FDCTRL) -#else - MISSING(AWEXE_FDCTRL) -#endif - -#ifdef AWEXE_FDEMASK - DEFINE(AWEXE_FDEMASK) -#else - MISSING(AWEXE_FDEMASK) -#endif - -#ifdef AWEXE_OUTOVEN - DEFINE(AWEXE_OUTOVEN) -#else - MISSING(AWEXE_OUTOVEN) -#endif - -#ifdef AWEXE_STATUS - DEFINE(AWEXE_STATUS) -#else - MISSING(AWEXE_STATUS) -#endif - -#ifdef BATMON - DEFINE(BATMON) -#else - MISSING(BATMON) -#endif - -#ifdef BGCAL - DEFINE(BGCAL) -#else - MISSING(BGCAL) -#endif - -#ifdef BGCCR - DEFINE(BGCCR) -#else - MISSING(BGCCR) -#endif - -#ifdef BGCR - DEFINE(BGCR) -#else - MISSING(BGCR) -#endif - -#ifdef BGCRA - DEFINE(BGCRA) -#else - MISSING(BGCRA) -#endif - -#ifdef BGCRB - DEFINE(BGCRB) -#else - MISSING(BGCRB) -#endif - -#ifdef BGCRR - DEFINE(BGCRR) -#else - MISSING(BGCRR) -#endif - -#ifdef BGCSR - DEFINE(BGCSR) -#else - MISSING(BGCSR) -#endif - -#ifdef BGCSRA - DEFINE(BGCSRA) -#else - MISSING(BGCSRA) -#endif - -#ifdef BGLR - DEFINE(BGLR) -#else - MISSING(BGLR) -#endif - -#ifdef BGPDDR - DEFINE(BGPDDR) -#else - MISSING(BGPDDR) -#endif - -#ifdef BGPPIN - DEFINE(BGPPIN) -#else - MISSING(BGPPIN) -#endif - -#ifdef BGPPORT - DEFINE(BGPPORT) -#else - MISSING(BGPPORT) -#endif - -#ifdef BL_CONFIG - DEFINE(BL_CONFIG) -#else - MISSING(BL_CONFIG) -#endif - -#ifdef BODCR - DEFINE(BODCR) -#else - MISSING(BODCR) -#endif - -#ifdef BPCHCD - DEFINE(BPCHCD) -#else - MISSING(BPCHCD) -#endif - -#ifdef BPCOCD - DEFINE(BPCOCD) -#else - MISSING(BPCOCD) -#endif - -#ifdef BPCR - DEFINE(BPCR) -#else - MISSING(BPCR) -#endif - -#ifdef BPDHCD - DEFINE(BPDHCD) -#else - MISSING(BPDHCD) -#endif - -#ifdef BPDOCD - DEFINE(BPDOCD) -#else - MISSING(BPDOCD) -#endif - -#ifdef BPDUV - DEFINE(BPDUV) -#else - MISSING(BPDUV) -#endif - -#ifdef BPHCTR - DEFINE(BPHCTR) -#else - MISSING(BPHCTR) -#endif - -#ifdef BPIFR - DEFINE(BPIFR) -#else - MISSING(BPIFR) -#endif - -#ifdef BPIMSK - DEFINE(BPIMSK) -#else - MISSING(BPIMSK) -#endif - -#ifdef BPIR - DEFINE(BPIR) -#else - MISSING(BPIR) -#endif - -#ifdef BPOCD - DEFINE(BPOCD) -#else - MISSING(BPOCD) -#endif - -#ifdef BPOCTR - DEFINE(BPOCTR) -#else - MISSING(BPOCTR) -#endif - -#ifdef BPPLR - DEFINE(BPPLR) -#else - MISSING(BPPLR) -#endif - -#ifdef BPSCD - DEFINE(BPSCD) -#else - MISSING(BPSCD) -#endif - -#ifdef BPSCTR - DEFINE(BPSCTR) -#else - MISSING(BPSCTR) -#endif - -#ifdef BTCNT - DEFINE(BTCNT) -#else - MISSING(BTCNT) -#endif - -#ifdef BTCR - DEFINE(BTCR) -#else - MISSING(BTCR) -#endif - -#ifdef B_DET - DEFINE(B_DET) -#else - MISSING(B_DET) -#endif - -#ifdef CADAC0 - DEFINE(CADAC0) -#else - MISSING(CADAC0) -#endif - -#ifdef CADAC1 - DEFINE(CADAC1) -#else - MISSING(CADAC1) -#endif - -#ifdef CADAC2 - DEFINE(CADAC2) -#else - MISSING(CADAC2) -#endif - -#ifdef CADAC3 - DEFINE(CADAC3) -#else - MISSING(CADAC3) -#endif - -#ifdef CADCSRA - DEFINE(CADCSRA) -#else - MISSING(CADCSRA) -#endif - -#ifdef CADCSRB - DEFINE(CADCSRB) -#else - MISSING(CADCSRB) -#endif - -#ifdef CADCSRC - DEFINE(CADCSRC) -#else - MISSING(CADCSRC) -#endif - -#ifdef CADIC - DEFINE(CADIC) -#else - MISSING(CADIC) -#endif - -#ifdef CADICH - DEFINE(CADICH) -#else - MISSING(CADICH) -#endif - -#ifdef CADICL - DEFINE(CADICL) -#else - MISSING(CADICL) -#endif - -#ifdef CADRC - DEFINE(CADRC) -#else - MISSING(CADRC) -#endif - -#ifdef CADRCC - DEFINE(CADRCC) -#else - MISSING(CADRCC) -#endif - -#ifdef CADRCL - DEFINE(CADRCL) -#else - MISSING(CADRCL) -#endif - -#ifdef CADRCLH - DEFINE(CADRCLH) -#else - MISSING(CADRCLH) -#endif - -#ifdef CADRCLL - DEFINE(CADRCLL) -#else - MISSING(CADRCLL) -#endif - -#ifdef CADRDC - DEFINE(CADRDC) -#else - MISSING(CADRDC) -#endif - -#ifdef CANBT1 - DEFINE(CANBT1) -#else - MISSING(CANBT1) -#endif - -#ifdef CANBT2 - DEFINE(CANBT2) -#else - MISSING(CANBT2) -#endif - -#ifdef CANBT3 - DEFINE(CANBT3) -#else - MISSING(CANBT3) -#endif - -#ifdef CANCDMOB - DEFINE(CANCDMOB) -#else - MISSING(CANCDMOB) -#endif - -#ifdef CANEN - DEFINE(CANEN) -#else - MISSING(CANEN) -#endif - -#ifdef CANEN1 - DEFINE(CANEN1) -#else - MISSING(CANEN1) -#endif - -#ifdef CANEN2 - DEFINE(CANEN2) -#else - MISSING(CANEN2) -#endif - -#ifdef CANGCON - DEFINE(CANGCON) -#else - MISSING(CANGCON) -#endif - -#ifdef CANGIE - DEFINE(CANGIE) -#else - MISSING(CANGIE) -#endif - -#ifdef CANGIT - DEFINE(CANGIT) -#else - MISSING(CANGIT) -#endif - -#ifdef CANGSTA - DEFINE(CANGSTA) -#else - MISSING(CANGSTA) -#endif - -#ifdef CANHPMOB - DEFINE(CANHPMOB) -#else - MISSING(CANHPMOB) -#endif - -#ifdef CANIDM1 - DEFINE(CANIDM1) -#else - MISSING(CANIDM1) -#endif - -#ifdef CANIDM2 - DEFINE(CANIDM2) -#else - MISSING(CANIDM2) -#endif - -#ifdef CANIDM3 - DEFINE(CANIDM3) -#else - MISSING(CANIDM3) -#endif - -#ifdef CANIDM4 - DEFINE(CANIDM4) -#else - MISSING(CANIDM4) -#endif - -#ifdef CANIDT1 - DEFINE(CANIDT1) -#else - MISSING(CANIDT1) -#endif - -#ifdef CANIDT2 - DEFINE(CANIDT2) -#else - MISSING(CANIDT2) -#endif - -#ifdef CANIDT3 - DEFINE(CANIDT3) -#else - MISSING(CANIDT3) -#endif - -#ifdef CANIDT4 - DEFINE(CANIDT4) -#else - MISSING(CANIDT4) -#endif - -#ifdef CANIE - DEFINE(CANIE) -#else - MISSING(CANIE) -#endif - -#ifdef CANIE1 - DEFINE(CANIE1) -#else - MISSING(CANIE1) -#endif - -#ifdef CANIE2 - DEFINE(CANIE2) -#else - MISSING(CANIE2) -#endif - -#ifdef CANMSG - DEFINE(CANMSG) -#else - MISSING(CANMSG) -#endif - -#ifdef CANPAGE - DEFINE(CANPAGE) -#else - MISSING(CANPAGE) -#endif - -#ifdef CANREC - DEFINE(CANREC) -#else - MISSING(CANREC) -#endif - -#ifdef CANSIT - DEFINE(CANSIT) -#else - MISSING(CANSIT) -#endif - -#ifdef CANSIT1 - DEFINE(CANSIT1) -#else - MISSING(CANSIT1) -#endif - -#ifdef CANSIT2 - DEFINE(CANSIT2) -#else - MISSING(CANSIT2) -#endif - -#ifdef CANSTM - DEFINE(CANSTM) -#else - MISSING(CANSTM) -#endif - -#ifdef CANSTMH - DEFINE(CANSTMH) -#else - MISSING(CANSTMH) -#endif - -#ifdef CANSTML - DEFINE(CANSTML) -#else - MISSING(CANSTML) -#endif - -#ifdef CANSTMOB - DEFINE(CANSTMOB) -#else - MISSING(CANSTMOB) -#endif - -#ifdef CANTCON - DEFINE(CANTCON) -#else - MISSING(CANTCON) -#endif - -#ifdef CANTEC - DEFINE(CANTEC) -#else - MISSING(CANTEC) -#endif - -#ifdef CANTIM - DEFINE(CANTIM) -#else - MISSING(CANTIM) -#endif - -#ifdef CANTIMH - DEFINE(CANTIMH) -#else - MISSING(CANTIMH) -#endif - -#ifdef CANTIML - DEFINE(CANTIML) -#else - MISSING(CANTIML) -#endif - -#ifdef CANTTC - DEFINE(CANTTC) -#else - MISSING(CANTTC) -#endif - -#ifdef CANTTCH - DEFINE(CANTTCH) -#else - MISSING(CANTTCH) -#endif - -#ifdef CANTTCL - DEFINE(CANTTCL) -#else - MISSING(CANTTCL) -#endif - -#ifdef CBCR - DEFINE(CBCR) -#else - MISSING(CBCR) -#endif - -#ifdef CBPTR - DEFINE(CBPTR) -#else - MISSING(CBPTR) -#endif - -#ifdef CBTR1 - DEFINE(CBTR1) -#else - MISSING(CBTR1) -#endif - -#ifdef CBTR2 - DEFINE(CBTR2) -#else - MISSING(CBTR2) -#endif - -#ifdef CBTR3 - DEFINE(CBTR3) -#else - MISSING(CBTR3) -#endif - -#ifdef CCA_THRES - DEFINE(CCA_THRES) -#else - MISSING(CCA_THRES) -#endif - -#ifdef CCFLG - DEFINE(CCFLG) -#else - MISSING(CCFLG) -#endif - -#ifdef CCISR - DEFINE(CCISR) -#else - MISSING(CCISR) -#endif - -#ifdef CCP - DEFINE(CCP) -#else - MISSING(CCP) -#endif - -#ifdef CCSR - DEFINE(CCSR) -#else - MISSING(CCSR) -#endif - -#ifdef CDIVCAN - DEFINE(CDIVCAN) -#else - MISSING(CDIVCAN) -#endif - -#ifdef CEFR - DEFINE(CEFR) -#else - MISSING(CEFR) -#endif - -#ifdef CGPDDR - DEFINE(CGPDDR) -#else - MISSING(CGPDDR) -#endif - -#ifdef CGPPIN - DEFINE(CGPPIN) -#else - MISSING(CGPPIN) -#endif - -#ifdef CGPPORT - DEFINE(CGPPORT) -#else - MISSING(CGPPORT) -#endif - -#ifdef CHGDCSR - DEFINE(CHGDCSR) -#else - MISSING(CHGDCSR) -#endif - -#ifdef CIDAH0 - DEFINE(CIDAH0) -#else - MISSING(CIDAH0) -#endif - -#ifdef CIDAH1 - DEFINE(CIDAH1) -#else - MISSING(CIDAH1) -#endif - -#ifdef CIER - DEFINE(CIER) -#else - MISSING(CIER) -#endif - -#ifdef CKSEL0 - DEFINE(CKSEL0) -#else - MISSING(CKSEL0) -#endif - -#ifdef CKSEL1 - DEFINE(CKSEL1) -#else - MISSING(CKSEL1) -#endif - -#ifdef CKSTA - DEFINE(CKSTA) -#else - MISSING(CKSTA) -#endif - -#ifdef CLKCSR - DEFINE(CLKCSR) -#else - MISSING(CLKCSR) -#endif - -#ifdef CLKMSR - DEFINE(CLKMSR) -#else - MISSING(CLKMSR) -#endif - -#ifdef CLKPR - DEFINE(CLKPR) -#else - MISSING(CLKPR) -#endif - -#ifdef CLKPSR - DEFINE(CLKPSR) -#else - MISSING(CLKPSR) -#endif - -#ifdef CLKSEL0 - DEFINE(CLKSEL0) -#else - MISSING(CLKSEL0) -#endif - -#ifdef CLKSEL1 - DEFINE(CLKSEL1) -#else - MISSING(CLKSEL1) -#endif - -#ifdef CLKSELR - DEFINE(CLKSELR) -#else - MISSING(CLKSELR) -#endif - -#ifdef CLKSTA - DEFINE(CLKSTA) -#else - MISSING(CLKSTA) -#endif - -#ifdef CLK_CNTR - DEFINE(CLK_CNTR) -#else - MISSING(CLK_CNTR) -#endif - -#ifdef CLK_CTRL - DEFINE(CLK_CTRL) -#else - MISSING(CLK_CTRL) -#endif - -#ifdef CLK_LOCK - DEFINE(CLK_LOCK) -#else - MISSING(CLK_LOCK) -#endif - -#ifdef CLK_PSCTRL - DEFINE(CLK_PSCTRL) -#else - MISSING(CLK_PSCTRL) -#endif - -#ifdef CLK_RTCCTRL - DEFINE(CLK_RTCCTRL) -#else - MISSING(CLK_RTCCTRL) -#endif - -#ifdef CLK_USBCTRL - DEFINE(CLK_USBCTRL) -#else - MISSING(CLK_USBCTRL) -#endif - -#ifdef CMCR - DEFINE(CMCR) -#else - MISSING(CMCR) -#endif - -#ifdef CMIMR - DEFINE(CMIMR) -#else - MISSING(CMIMR) -#endif - -#ifdef CMSR - DEFINE(CMSR) -#else - MISSING(CMSR) -#endif - -#ifdef COSDAC - DEFINE(COSDAC) -#else - MISSING(COSDAC) -#endif - -#ifdef COSDACH - DEFINE(COSDACH) -#else - MISSING(COSDACH) -#endif - -#ifdef COSDACL - DEFINE(COSDACL) -#else - MISSING(COSDACL) -#endif - -#ifdef CPU_CCP - DEFINE(CPU_CCP) -#else - MISSING(CPU_CCP) -#endif - -#ifdef CPU_EIND - DEFINE(CPU_EIND) -#else - MISSING(CPU_EIND) -#endif - -#ifdef CPU_RAMPD - DEFINE(CPU_RAMPD) -#else - MISSING(CPU_RAMPD) -#endif - -#ifdef CPU_RAMPX - DEFINE(CPU_RAMPX) -#else - MISSING(CPU_RAMPX) -#endif - -#ifdef CPU_RAMPY - DEFINE(CPU_RAMPY) -#else - MISSING(CPU_RAMPY) -#endif - -#ifdef CPU_RAMPZ - DEFINE(CPU_RAMPZ) -#else - MISSING(CPU_RAMPZ) -#endif - -#ifdef CPU_SPH - DEFINE(CPU_SPH) -#else - MISSING(CPU_SPH) -#endif - -#ifdef CPU_SPL - DEFINE(CPU_SPL) -#else - MISSING(CPU_SPL) -#endif - -#ifdef CPU_SREG - DEFINE(CPU_SREG) -#else - MISSING(CPU_SREG) -#endif - -#ifdef CRAFEN - DEFINE(CRAFEN) -#else - MISSING(CRAFEN) -#endif - -#ifdef CRC_CHECKSUM0 - DEFINE(CRC_CHECKSUM0) -#else - MISSING(CRC_CHECKSUM0) -#endif - -#ifdef CRC_CHECKSUM1 - DEFINE(CRC_CHECKSUM1) -#else - MISSING(CRC_CHECKSUM1) -#endif - -#ifdef CRC_CHECKSUM2 - DEFINE(CRC_CHECKSUM2) -#else - MISSING(CRC_CHECKSUM2) -#endif - -#ifdef CRC_CHECKSUM3 - DEFINE(CRC_CHECKSUM3) -#else - MISSING(CRC_CHECKSUM3) -#endif - -#ifdef CRC_CTRL - DEFINE(CRC_CTRL) -#else - MISSING(CRC_CTRL) -#endif - -#ifdef CRC_DATAIN - DEFINE(CRC_DATAIN) -#else - MISSING(CRC_DATAIN) -#endif - -#ifdef CRC_STATUS - DEFINE(CRC_STATUS) -#else - MISSING(CRC_STATUS) -#endif - -#ifdef CRXERR - DEFINE(CRXERR) -#else - MISSING(CRXERR) -#endif - -#ifdef CSMA_BE - DEFINE(CSMA_BE) -#else - MISSING(CSMA_BE) -#endif - -#ifdef CSMA_SEED_0 - DEFINE(CSMA_SEED_0) -#else - MISSING(CSMA_SEED_0) -#endif - -#ifdef CSMA_SEED_1 - DEFINE(CSMA_SEED_1) -#else - MISSING(CSMA_SEED_1) -#endif - -#ifdef CTARR - DEFINE(CTARR) -#else - MISSING(CTARR) -#endif - -#ifdef CTXERR - DEFINE(CTXERR) -#else - MISSING(CTXERR) -#endif - -#ifdef CURIRED - DEFINE(CURIRED) -#else - MISSING(CURIRED) -#endif - -#ifdef CURIRUN - DEFINE(CURIRUN) -#else - MISSING(CURIRUN) -#endif - -#ifdef CURRDLY - DEFINE(CURRDLY) -#else - MISSING(CURRDLY) -#endif - -#ifdef CVER - DEFINE(CVER) -#else - MISSING(CVER) -#endif - -#ifdef DAC - DEFINE(DAC) -#else - MISSING(DAC) -#endif - -#ifdef DACA_CH0DATA - DEFINE(DACA_CH0DATA) -#else - MISSING(DACA_CH0DATA) -#endif - -#ifdef DACA_CH0GAINCAL - DEFINE(DACA_CH0GAINCAL) -#else - MISSING(DACA_CH0GAINCAL) -#endif - -#ifdef DACA_CH0OFFSETCAL - DEFINE(DACA_CH0OFFSETCAL) -#else - MISSING(DACA_CH0OFFSETCAL) -#endif - -#ifdef DACA_CH1DATA - DEFINE(DACA_CH1DATA) -#else - MISSING(DACA_CH1DATA) -#endif - -#ifdef DACA_CH1GAINCAL - DEFINE(DACA_CH1GAINCAL) -#else - MISSING(DACA_CH1GAINCAL) -#endif - -#ifdef DACA_CH1OFFSETCAL - DEFINE(DACA_CH1OFFSETCAL) -#else - MISSING(DACA_CH1OFFSETCAL) -#endif - -#ifdef DACA_CTRLA - DEFINE(DACA_CTRLA) -#else - MISSING(DACA_CTRLA) -#endif - -#ifdef DACA_CTRLB - DEFINE(DACA_CTRLB) -#else - MISSING(DACA_CTRLB) -#endif - -#ifdef DACA_CTRLC - DEFINE(DACA_CTRLC) -#else - MISSING(DACA_CTRLC) -#endif - -#ifdef DACA_EVCTRL - DEFINE(DACA_EVCTRL) -#else - MISSING(DACA_EVCTRL) -#endif - -#ifdef DACA_GAINCAL - DEFINE(DACA_GAINCAL) -#else - MISSING(DACA_GAINCAL) -#endif - -#ifdef DACA_OFFSETCAL - DEFINE(DACA_OFFSETCAL) -#else - MISSING(DACA_OFFSETCAL) -#endif - -#ifdef DACA_STATUS - DEFINE(DACA_STATUS) -#else - MISSING(DACA_STATUS) -#endif - -#ifdef DACA_TIMCTRL - DEFINE(DACA_TIMCTRL) -#else - MISSING(DACA_TIMCTRL) -#endif - -#ifdef DACB_CH0DATA - DEFINE(DACB_CH0DATA) -#else - MISSING(DACB_CH0DATA) -#endif - -#ifdef DACB_CH0GAINCAL - DEFINE(DACB_CH0GAINCAL) -#else - MISSING(DACB_CH0GAINCAL) -#endif - -#ifdef DACB_CH0OFFSETCAL - DEFINE(DACB_CH0OFFSETCAL) -#else - MISSING(DACB_CH0OFFSETCAL) -#endif - -#ifdef DACB_CH1DATA - DEFINE(DACB_CH1DATA) -#else - MISSING(DACB_CH1DATA) -#endif - -#ifdef DACB_CH1GAINCAL - DEFINE(DACB_CH1GAINCAL) -#else - MISSING(DACB_CH1GAINCAL) -#endif - -#ifdef DACB_CH1OFFSETCAL - DEFINE(DACB_CH1OFFSETCAL) -#else - MISSING(DACB_CH1OFFSETCAL) -#endif - -#ifdef DACB_CTRLA - DEFINE(DACB_CTRLA) -#else - MISSING(DACB_CTRLA) -#endif - -#ifdef DACB_CTRLB - DEFINE(DACB_CTRLB) -#else - MISSING(DACB_CTRLB) -#endif - -#ifdef DACB_CTRLC - DEFINE(DACB_CTRLC) -#else - MISSING(DACB_CTRLC) -#endif - -#ifdef DACB_EVCTRL - DEFINE(DACB_EVCTRL) -#else - MISSING(DACB_EVCTRL) -#endif - -#ifdef DACB_GAINCAL - DEFINE(DACB_GAINCAL) -#else - MISSING(DACB_GAINCAL) -#endif - -#ifdef DACB_OFFSETCAL - DEFINE(DACB_OFFSETCAL) -#else - MISSING(DACB_OFFSETCAL) -#endif - -#ifdef DACB_STATUS - DEFINE(DACB_STATUS) -#else - MISSING(DACB_STATUS) -#endif - -#ifdef DACB_TIMCTRL - DEFINE(DACB_TIMCTRL) -#else - MISSING(DACB_TIMCTRL) -#endif - -#ifdef DACCTRL - DEFINE(DACCTRL) -#else - MISSING(DACCTRL) -#endif - -#ifdef DACH - DEFINE(DACH) -#else - MISSING(DACH) -#endif - -#ifdef DACL - DEFINE(DACL) -#else - MISSING(DACL) -#endif - -#ifdef DACON - DEFINE(DACON) -#else - MISSING(DACON) -#endif - -#ifdef DACVAL - DEFINE(DACVAL) -#else - MISSING(DACVAL) -#endif - -#ifdef DACVALH - DEFINE(DACVALH) -#else - MISSING(DACVALH) -#endif - -#ifdef DACVALHI - DEFINE(DACVALHI) -#else - MISSING(DACVALHI) -#endif - -#ifdef DACVALL - DEFINE(DACVALL) -#else - MISSING(DACVALL) -#endif - -#ifdef DACVALLO - DEFINE(DACVALLO) -#else - MISSING(DACVALLO) -#endif - -#ifdef DCCR - DEFINE(DCCR) -#else - MISSING(DCCR) -#endif - -#ifdef DDRA - DEFINE(DDRA) -#else - MISSING(DDRA) -#endif - -#ifdef DDRB - DEFINE(DDRB) -#else - MISSING(DDRB) -#endif - -#ifdef DDRC - DEFINE(DDRC) -#else - MISSING(DDRC) -#endif - -#ifdef DDRD - DEFINE(DDRD) -#else - MISSING(DDRD) -#endif - -#ifdef DDRE - DEFINE(DDRE) -#else - MISSING(DDRE) -#endif - -#ifdef DDRF - DEFINE(DDRF) -#else - MISSING(DDRF) -#endif - -#ifdef DDRG - DEFINE(DDRG) -#else - MISSING(DDRG) -#endif - -#ifdef DDRH - DEFINE(DDRH) -#else - MISSING(DDRH) -#endif - -#ifdef DDRJ - DEFINE(DDRJ) -#else - MISSING(DDRJ) -#endif - -#ifdef DDRK - DEFINE(DDRK) -#else - MISSING(DDRK) -#endif - -#ifdef DDRL - DEFINE(DDRL) -#else - MISSING(DDRL) -#endif - -#ifdef DEEAR - DEFINE(DEEAR) -#else - MISSING(DEEAR) -#endif - -#ifdef DEEARL - DEFINE(DEEARL) -#else - MISSING(DEEARL) -#endif - -#ifdef DEECR - DEFINE(DEECR) -#else - MISSING(DEECR) -#endif - -#ifdef DEEDR - DEFINE(DEEDR) -#else - MISSING(DEEDR) -#endif - -#ifdef DFLLRC2M_CALA - DEFINE(DFLLRC2M_CALA) -#else - MISSING(DFLLRC2M_CALA) -#endif - -#ifdef DFLLRC2M_CALB - DEFINE(DFLLRC2M_CALB) -#else - MISSING(DFLLRC2M_CALB) -#endif - -#ifdef DFLLRC2M_COMP0 - DEFINE(DFLLRC2M_COMP0) -#else - MISSING(DFLLRC2M_COMP0) -#endif - -#ifdef DFLLRC2M_COMP1 - DEFINE(DFLLRC2M_COMP1) -#else - MISSING(DFLLRC2M_COMP1) -#endif - -#ifdef DFLLRC2M_COMP2 - DEFINE(DFLLRC2M_COMP2) -#else - MISSING(DFLLRC2M_COMP2) -#endif - -#ifdef DFLLRC2M_CTRL - DEFINE(DFLLRC2M_CTRL) -#else - MISSING(DFLLRC2M_CTRL) -#endif - -#ifdef DFLLRC32M_CALA - DEFINE(DFLLRC32M_CALA) -#else - MISSING(DFLLRC32M_CALA) -#endif - -#ifdef DFLLRC32M_CALB - DEFINE(DFLLRC32M_CALB) -#else - MISSING(DFLLRC32M_CALB) -#endif - -#ifdef DFLLRC32M_COMP0 - DEFINE(DFLLRC32M_COMP0) -#else - MISSING(DFLLRC32M_COMP0) -#endif - -#ifdef DFLLRC32M_COMP1 - DEFINE(DFLLRC32M_COMP1) -#else - MISSING(DFLLRC32M_COMP1) -#endif - -#ifdef DFLLRC32M_COMP2 - DEFINE(DFLLRC32M_COMP2) -#else - MISSING(DFLLRC32M_COMP2) -#endif - -#ifdef DFLLRC32M_CTRL - DEFINE(DFLLRC32M_CTRL) -#else - MISSING(DFLLRC32M_CTRL) -#endif - -#ifdef DIDR - DEFINE(DIDR) -#else - MISSING(DIDR) -#endif - -#ifdef DIDR0 - DEFINE(DIDR0) -#else - MISSING(DIDR0) -#endif - -#ifdef DIDR1 - DEFINE(DIDR1) -#else - MISSING(DIDR1) -#endif - -#ifdef DIDR2 - DEFINE(DIDR2) -#else - MISSING(DIDR2) -#endif - -#ifdef DMA_CH0_ADDRCTRL - DEFINE(DMA_CH0_ADDRCTRL) -#else - MISSING(DMA_CH0_ADDRCTRL) -#endif - -#ifdef DMA_CH0_CTRLA - DEFINE(DMA_CH0_CTRLA) -#else - MISSING(DMA_CH0_CTRLA) -#endif - -#ifdef DMA_CH0_CTRLB - DEFINE(DMA_CH0_CTRLB) -#else - MISSING(DMA_CH0_CTRLB) -#endif - -#ifdef DMA_CH0_DESTADDR0 - DEFINE(DMA_CH0_DESTADDR0) -#else - MISSING(DMA_CH0_DESTADDR0) -#endif - -#ifdef DMA_CH0_DESTADDR1 - DEFINE(DMA_CH0_DESTADDR1) -#else - MISSING(DMA_CH0_DESTADDR1) -#endif - -#ifdef DMA_CH0_DESTADDR2 - DEFINE(DMA_CH0_DESTADDR2) -#else - MISSING(DMA_CH0_DESTADDR2) -#endif - -#ifdef DMA_CH0_REPCNT - DEFINE(DMA_CH0_REPCNT) -#else - MISSING(DMA_CH0_REPCNT) -#endif - -#ifdef DMA_CH0_SRCADDR0 - DEFINE(DMA_CH0_SRCADDR0) -#else - MISSING(DMA_CH0_SRCADDR0) -#endif - -#ifdef DMA_CH0_SRCADDR1 - DEFINE(DMA_CH0_SRCADDR1) -#else - MISSING(DMA_CH0_SRCADDR1) -#endif - -#ifdef DMA_CH0_SRCADDR2 - DEFINE(DMA_CH0_SRCADDR2) -#else - MISSING(DMA_CH0_SRCADDR2) -#endif - -#ifdef DMA_CH0_TRFCNT - DEFINE(DMA_CH0_TRFCNT) -#else - MISSING(DMA_CH0_TRFCNT) -#endif - -#ifdef DMA_CH0_TRIGSRC - DEFINE(DMA_CH0_TRIGSRC) -#else - MISSING(DMA_CH0_TRIGSRC) -#endif - -#ifdef DMA_CH1_ADDRCTRL - DEFINE(DMA_CH1_ADDRCTRL) -#else - MISSING(DMA_CH1_ADDRCTRL) -#endif - -#ifdef DMA_CH1_CTRLA - DEFINE(DMA_CH1_CTRLA) -#else - MISSING(DMA_CH1_CTRLA) -#endif - -#ifdef DMA_CH1_CTRLB - DEFINE(DMA_CH1_CTRLB) -#else - MISSING(DMA_CH1_CTRLB) -#endif - -#ifdef DMA_CH1_DESTADDR0 - DEFINE(DMA_CH1_DESTADDR0) -#else - MISSING(DMA_CH1_DESTADDR0) -#endif - -#ifdef DMA_CH1_DESTADDR1 - DEFINE(DMA_CH1_DESTADDR1) -#else - MISSING(DMA_CH1_DESTADDR1) -#endif - -#ifdef DMA_CH1_DESTADDR2 - DEFINE(DMA_CH1_DESTADDR2) -#else - MISSING(DMA_CH1_DESTADDR2) -#endif - -#ifdef DMA_CH1_REPCNT - DEFINE(DMA_CH1_REPCNT) -#else - MISSING(DMA_CH1_REPCNT) -#endif - -#ifdef DMA_CH1_SRCADDR0 - DEFINE(DMA_CH1_SRCADDR0) -#else - MISSING(DMA_CH1_SRCADDR0) -#endif - -#ifdef DMA_CH1_SRCADDR1 - DEFINE(DMA_CH1_SRCADDR1) -#else - MISSING(DMA_CH1_SRCADDR1) -#endif - -#ifdef DMA_CH1_SRCADDR2 - DEFINE(DMA_CH1_SRCADDR2) -#else - MISSING(DMA_CH1_SRCADDR2) -#endif - -#ifdef DMA_CH1_TRFCNT - DEFINE(DMA_CH1_TRFCNT) -#else - MISSING(DMA_CH1_TRFCNT) -#endif - -#ifdef DMA_CH1_TRIGSRC - DEFINE(DMA_CH1_TRIGSRC) -#else - MISSING(DMA_CH1_TRIGSRC) -#endif - -#ifdef DMA_CH2_ADDRCTRL - DEFINE(DMA_CH2_ADDRCTRL) -#else - MISSING(DMA_CH2_ADDRCTRL) -#endif - -#ifdef DMA_CH2_CTRLA - DEFINE(DMA_CH2_CTRLA) -#else - MISSING(DMA_CH2_CTRLA) -#endif - -#ifdef DMA_CH2_CTRLB - DEFINE(DMA_CH2_CTRLB) -#else - MISSING(DMA_CH2_CTRLB) -#endif - -#ifdef DMA_CH2_DESTADDR0 - DEFINE(DMA_CH2_DESTADDR0) -#else - MISSING(DMA_CH2_DESTADDR0) -#endif - -#ifdef DMA_CH2_DESTADDR1 - DEFINE(DMA_CH2_DESTADDR1) -#else - MISSING(DMA_CH2_DESTADDR1) -#endif - -#ifdef DMA_CH2_DESTADDR2 - DEFINE(DMA_CH2_DESTADDR2) -#else - MISSING(DMA_CH2_DESTADDR2) -#endif - -#ifdef DMA_CH2_REPCNT - DEFINE(DMA_CH2_REPCNT) -#else - MISSING(DMA_CH2_REPCNT) -#endif - -#ifdef DMA_CH2_SRCADDR0 - DEFINE(DMA_CH2_SRCADDR0) -#else - MISSING(DMA_CH2_SRCADDR0) -#endif - -#ifdef DMA_CH2_SRCADDR1 - DEFINE(DMA_CH2_SRCADDR1) -#else - MISSING(DMA_CH2_SRCADDR1) -#endif - -#ifdef DMA_CH2_SRCADDR2 - DEFINE(DMA_CH2_SRCADDR2) -#else - MISSING(DMA_CH2_SRCADDR2) -#endif - -#ifdef DMA_CH2_TRFCNT - DEFINE(DMA_CH2_TRFCNT) -#else - MISSING(DMA_CH2_TRFCNT) -#endif - -#ifdef DMA_CH2_TRIGSRC - DEFINE(DMA_CH2_TRIGSRC) -#else - MISSING(DMA_CH2_TRIGSRC) -#endif - -#ifdef DMA_CH3_ADDRCTRL - DEFINE(DMA_CH3_ADDRCTRL) -#else - MISSING(DMA_CH3_ADDRCTRL) -#endif - -#ifdef DMA_CH3_CTRLA - DEFINE(DMA_CH3_CTRLA) -#else - MISSING(DMA_CH3_CTRLA) -#endif - -#ifdef DMA_CH3_CTRLB - DEFINE(DMA_CH3_CTRLB) -#else - MISSING(DMA_CH3_CTRLB) -#endif - -#ifdef DMA_CH3_DESTADDR0 - DEFINE(DMA_CH3_DESTADDR0) -#else - MISSING(DMA_CH3_DESTADDR0) -#endif - -#ifdef DMA_CH3_DESTADDR1 - DEFINE(DMA_CH3_DESTADDR1) -#else - MISSING(DMA_CH3_DESTADDR1) -#endif - -#ifdef DMA_CH3_DESTADDR2 - DEFINE(DMA_CH3_DESTADDR2) -#else - MISSING(DMA_CH3_DESTADDR2) -#endif - -#ifdef DMA_CH3_REPCNT - DEFINE(DMA_CH3_REPCNT) -#else - MISSING(DMA_CH3_REPCNT) -#endif - -#ifdef DMA_CH3_SRCADDR0 - DEFINE(DMA_CH3_SRCADDR0) -#else - MISSING(DMA_CH3_SRCADDR0) -#endif - -#ifdef DMA_CH3_SRCADDR1 - DEFINE(DMA_CH3_SRCADDR1) -#else - MISSING(DMA_CH3_SRCADDR1) -#endif - -#ifdef DMA_CH3_SRCADDR2 - DEFINE(DMA_CH3_SRCADDR2) -#else - MISSING(DMA_CH3_SRCADDR2) -#endif - -#ifdef DMA_CH3_TRFCNT - DEFINE(DMA_CH3_TRFCNT) -#else - MISSING(DMA_CH3_TRFCNT) -#endif - -#ifdef DMA_CH3_TRIGSRC - DEFINE(DMA_CH3_TRIGSRC) -#else - MISSING(DMA_CH3_TRIGSRC) -#endif - -#ifdef DMA_CTRL - DEFINE(DMA_CTRL) -#else - MISSING(DMA_CTRL) -#endif - -#ifdef DMA_INTFLAGS - DEFINE(DMA_INTFLAGS) -#else - MISSING(DMA_INTFLAGS) -#endif - -#ifdef DMA_STATUS - DEFINE(DMA_STATUS) -#else - MISSING(DMA_STATUS) -#endif - -#ifdef DMA_TEMP - DEFINE(DMA_TEMP) -#else - MISSING(DMA_TEMP) -#endif - -#ifdef DPDS0 - DEFINE(DPDS0) -#else - MISSING(DPDS0) -#endif - -#ifdef DPDS1 - DEFINE(DPDS1) -#else - MISSING(DPDS1) -#endif - -#ifdef DRTRAM0 - DEFINE(DRTRAM0) -#else - MISSING(DRTRAM0) -#endif - -#ifdef DRTRAM1 - DEFINE(DRTRAM1) -#else - MISSING(DRTRAM1) -#endif - -#ifdef DRTRAM2 - DEFINE(DRTRAM2) -#else - MISSING(DRTRAM2) -#endif - -#ifdef DRTRAM3 - DEFINE(DRTRAM3) -#else - MISSING(DRTRAM3) -#endif - -#ifdef DT1 - DEFINE(DT1) -#else - MISSING(DT1) -#endif - -#ifdef DT1A - DEFINE(DT1A) -#else - MISSING(DT1A) -#endif - -#ifdef DT1B - DEFINE(DT1B) -#else - MISSING(DT1B) -#endif - -#ifdef DT4 - DEFINE(DT4) -#else - MISSING(DT4) -#endif - -#ifdef DTPS1 - DEFINE(DTPS1) -#else - MISSING(DTPS1) -#endif - -#ifdef DWDR - DEFINE(DWDR) -#else - MISSING(DWDR) -#endif - -#ifdef EBI_CS0_BASEADDR - DEFINE(EBI_CS0_BASEADDR) -#else - MISSING(EBI_CS0_BASEADDR) -#endif - -#ifdef EBI_CS0_CTRLA - DEFINE(EBI_CS0_CTRLA) -#else - MISSING(EBI_CS0_CTRLA) -#endif - -#ifdef EBI_CS0_CTRLB - DEFINE(EBI_CS0_CTRLB) -#else - MISSING(EBI_CS0_CTRLB) -#endif - -#ifdef EBI_CS1_BASEADDR - DEFINE(EBI_CS1_BASEADDR) -#else - MISSING(EBI_CS1_BASEADDR) -#endif - -#ifdef EBI_CS1_CTRLA - DEFINE(EBI_CS1_CTRLA) -#else - MISSING(EBI_CS1_CTRLA) -#endif - -#ifdef EBI_CS1_CTRLB - DEFINE(EBI_CS1_CTRLB) -#else - MISSING(EBI_CS1_CTRLB) -#endif - -#ifdef EBI_CS2_BASEADDR - DEFINE(EBI_CS2_BASEADDR) -#else - MISSING(EBI_CS2_BASEADDR) -#endif - -#ifdef EBI_CS2_CTRLA - DEFINE(EBI_CS2_CTRLA) -#else - MISSING(EBI_CS2_CTRLA) -#endif - -#ifdef EBI_CS2_CTRLB - DEFINE(EBI_CS2_CTRLB) -#else - MISSING(EBI_CS2_CTRLB) -#endif - -#ifdef EBI_CS3_BASEADDR - DEFINE(EBI_CS3_BASEADDR) -#else - MISSING(EBI_CS3_BASEADDR) -#endif - -#ifdef EBI_CS3_CTRLA - DEFINE(EBI_CS3_CTRLA) -#else - MISSING(EBI_CS3_CTRLA) -#endif - -#ifdef EBI_CS3_CTRLB - DEFINE(EBI_CS3_CTRLB) -#else - MISSING(EBI_CS3_CTRLB) -#endif - -#ifdef EBI_CTRL - DEFINE(EBI_CTRL) -#else - MISSING(EBI_CTRL) -#endif - -#ifdef EBI_INITDLY - DEFINE(EBI_INITDLY) -#else - MISSING(EBI_INITDLY) -#endif - -#ifdef EBI_REFRESH - DEFINE(EBI_REFRESH) -#else - MISSING(EBI_REFRESH) -#endif - -#ifdef EBI_SDRAMCTRLA - DEFINE(EBI_SDRAMCTRLA) -#else - MISSING(EBI_SDRAMCTRLA) -#endif - -#ifdef EBI_SDRAMCTRLB - DEFINE(EBI_SDRAMCTRLB) -#else - MISSING(EBI_SDRAMCTRLB) -#endif - -#ifdef EBI_SDRAMCTRLC - DEFINE(EBI_SDRAMCTRLC) -#else - MISSING(EBI_SDRAMCTRLC) -#endif - -#ifdef EEAR - DEFINE(EEAR) -#else - MISSING(EEAR) -#endif - -#ifdef EEARH - DEFINE(EEARH) -#else - MISSING(EEARH) -#endif - -#ifdef EEARL - DEFINE(EEARL) -#else - MISSING(EEARL) -#endif - -#ifdef EECR - DEFINE(EECR) -#else - MISSING(EECR) -#endif - -#ifdef EEDR - DEFINE(EEDR) -#else - MISSING(EEDR) -#endif - -#ifdef EICR - DEFINE(EICR) -#else - MISSING(EICR) -#endif - -#ifdef EICRA - DEFINE(EICRA) -#else - MISSING(EICRA) -#endif - -#ifdef EICRB - DEFINE(EICRB) -#else - MISSING(EICRB) -#endif - -#ifdef EIFR - DEFINE(EIFR) -#else - MISSING(EIFR) -#endif - -#ifdef EIMF - DEFINE(EIMF) -#else - MISSING(EIMF) -#endif - -#ifdef EIMSK - DEFINE(EIMSK) -#else - MISSING(EIMSK) -#endif - -#ifdef EIND - DEFINE(EIND) -#else - MISSING(EIND) -#endif - -#ifdef EIRR - DEFINE(EIRR) -#else - MISSING(EIRR) -#endif - -#ifdef EMCUCR - DEFINE(EMCUCR) -#else - MISSING(EMCUCR) -#endif - -#ifdef ETIFR - DEFINE(ETIFR) -#else - MISSING(ETIFR) -#endif - -#ifdef ETIMSK - DEFINE(ETIMSK) -#else - MISSING(ETIMSK) -#endif - -#ifdef EUCSRA - DEFINE(EUCSRA) -#else - MISSING(EUCSRA) -#endif - -#ifdef EUCSRB - DEFINE(EUCSRB) -#else - MISSING(EUCSRB) -#endif - -#ifdef EUCSRC - DEFINE(EUCSRC) -#else - MISSING(EUCSRC) -#endif - -#ifdef EUDR - DEFINE(EUDR) -#else - MISSING(EUDR) -#endif - -#ifdef EVSYS_CH0CTRL - DEFINE(EVSYS_CH0CTRL) -#else - MISSING(EVSYS_CH0CTRL) -#endif - -#ifdef EVSYS_CH0MUX - DEFINE(EVSYS_CH0MUX) -#else - MISSING(EVSYS_CH0MUX) -#endif - -#ifdef EVSYS_CH1CTRL - DEFINE(EVSYS_CH1CTRL) -#else - MISSING(EVSYS_CH1CTRL) -#endif - -#ifdef EVSYS_CH1MUX - DEFINE(EVSYS_CH1MUX) -#else - MISSING(EVSYS_CH1MUX) -#endif - -#ifdef EVSYS_CH2CTRL - DEFINE(EVSYS_CH2CTRL) -#else - MISSING(EVSYS_CH2CTRL) -#endif - -#ifdef EVSYS_CH2MUX - DEFINE(EVSYS_CH2MUX) -#else - MISSING(EVSYS_CH2MUX) -#endif - -#ifdef EVSYS_CH3CTRL - DEFINE(EVSYS_CH3CTRL) -#else - MISSING(EVSYS_CH3CTRL) -#endif - -#ifdef EVSYS_CH3MUX - DEFINE(EVSYS_CH3MUX) -#else - MISSING(EVSYS_CH3MUX) -#endif - -#ifdef EVSYS_CH4CTRL - DEFINE(EVSYS_CH4CTRL) -#else - MISSING(EVSYS_CH4CTRL) -#endif - -#ifdef EVSYS_CH4MUX - DEFINE(EVSYS_CH4MUX) -#else - MISSING(EVSYS_CH4MUX) -#endif - -#ifdef EVSYS_CH5CTRL - DEFINE(EVSYS_CH5CTRL) -#else - MISSING(EVSYS_CH5CTRL) -#endif - -#ifdef EVSYS_CH5MUX - DEFINE(EVSYS_CH5MUX) -#else - MISSING(EVSYS_CH5MUX) -#endif - -#ifdef EVSYS_CH6CTRL - DEFINE(EVSYS_CH6CTRL) -#else - MISSING(EVSYS_CH6CTRL) -#endif - -#ifdef EVSYS_CH6MUX - DEFINE(EVSYS_CH6MUX) -#else - MISSING(EVSYS_CH6MUX) -#endif - -#ifdef EVSYS_CH7CTRL - DEFINE(EVSYS_CH7CTRL) -#else - MISSING(EVSYS_CH7CTRL) -#endif - -#ifdef EVSYS_CH7MUX - DEFINE(EVSYS_CH7MUX) -#else - MISSING(EVSYS_CH7MUX) -#endif - -#ifdef EVSYS_DATA - DEFINE(EVSYS_DATA) -#else - MISSING(EVSYS_DATA) -#endif - -#ifdef EVSYS_STROBE - DEFINE(EVSYS_STROBE) -#else - MISSING(EVSYS_STROBE) -#endif - -#ifdef EXOCR1A - DEFINE(EXOCR1A) -#else - MISSING(EXOCR1A) -#endif - -#ifdef EXOCR1AH - DEFINE(EXOCR1AH) -#else - MISSING(EXOCR1AH) -#endif - -#ifdef EXOCR1AL - DEFINE(EXOCR1AL) -#else - MISSING(EXOCR1AL) -#endif - -#ifdef EXOCR1B - DEFINE(EXOCR1B) -#else - MISSING(EXOCR1B) -#endif - -#ifdef EXOCR1BH - DEFINE(EXOCR1BH) -#else - MISSING(EXOCR1BH) -#endif - -#ifdef EXOCR1BL - DEFINE(EXOCR1BL) -#else - MISSING(EXOCR1BL) -#endif - -#ifdef EXTCCR0 - DEFINE(EXTCCR0) -#else - MISSING(EXTCCR0) -#endif - -#ifdef EXTCCR1A - DEFINE(EXTCCR1A) -#else - MISSING(EXTCCR1A) -#endif - -#ifdef EXTCCR1B - DEFINE(EXTCCR1B) -#else - MISSING(EXTCCR1B) -#endif - -#ifdef EXTCNT - DEFINE(EXTCNT) -#else - MISSING(EXTCNT) -#endif - -#ifdef EXTCNT1 - DEFINE(EXTCNT1) -#else - MISSING(EXTCNT1) -#endif - -#ifdef EXTCNT1H - DEFINE(EXTCNT1H) -#else - MISSING(EXTCNT1H) -#endif - -#ifdef EXTCNT1L - DEFINE(EXTCNT1L) -#else - MISSING(EXTCNT1L) -#endif - -#ifdef EXTIFR - DEFINE(EXTIFR) -#else - MISSING(EXTIFR) -#endif - -#ifdef EXTIMSK - DEFINE(EXTIMSK) -#else - MISSING(EXTIMSK) -#endif - -#ifdef FCSR - DEFINE(FCSR) -#else - MISSING(FCSR) -#endif - -#ifdef FISCR - DEFINE(FISCR) -#else - MISSING(FISCR) -#endif - -#ifdef FISUA - DEFINE(FISUA) -#else - MISSING(FISUA) -#endif - -#ifdef FISUB - DEFINE(FISUB) -#else - MISSING(FISUB) -#endif - -#ifdef FISUC - DEFINE(FISUC) -#else - MISSING(FISUC) -#endif - -#ifdef FISUD - DEFINE(FISUD) -#else - MISSING(FISUD) -#endif - -#ifdef FOSCCAL - DEFINE(FOSCCAL) -#else - MISSING(FOSCCAL) -#endif - -#ifdef FPGAD - DEFINE(FPGAD) -#else - MISSING(FPGAD) -#endif - -#ifdef FPGAX - DEFINE(FPGAX) -#else - MISSING(FPGAX) -#endif - -#ifdef FPGAY - DEFINE(FPGAY) -#else - MISSING(FPGAY) -#endif - -#ifdef FPGAZ - DEFINE(FPGAZ) -#else - MISSING(FPGAZ) -#endif - -#ifdef FRCCAL - DEFINE(FRCCAL) -#else - MISSING(FRCCAL) -#endif - -#ifdef FTN_CTRL - DEFINE(FTN_CTRL) -#else - MISSING(FTN_CTRL) -#endif - -#ifdef GAINDAC - DEFINE(GAINDAC) -#else - MISSING(GAINDAC) -#endif - -#ifdef GICR - DEFINE(GICR) -#else - MISSING(GICR) -#endif - -#ifdef GIFR - DEFINE(GIFR) -#else - MISSING(GIFR) -#endif - -#ifdef GIMSK - DEFINE(GIMSK) -#else - MISSING(GIMSK) -#endif - -#ifdef GIPR - DEFINE(GIPR) -#else - MISSING(GIPR) -#endif - -#ifdef GPIO0 - DEFINE(GPIO0) -#else - MISSING(GPIO0) -#endif - -#ifdef GPIO1 - DEFINE(GPIO1) -#else - MISSING(GPIO1) -#endif - -#ifdef GPIO2 - DEFINE(GPIO2) -#else - MISSING(GPIO2) -#endif - -#ifdef GPIO3 - DEFINE(GPIO3) -#else - MISSING(GPIO3) -#endif - -#ifdef GPIO4 - DEFINE(GPIO4) -#else - MISSING(GPIO4) -#endif - -#ifdef GPIO5 - DEFINE(GPIO5) -#else - MISSING(GPIO5) -#endif - -#ifdef GPIO6 - DEFINE(GPIO6) -#else - MISSING(GPIO6) -#endif - -#ifdef GPIO7 - DEFINE(GPIO7) -#else - MISSING(GPIO7) -#endif - -#ifdef GPIO8 - DEFINE(GPIO8) -#else - MISSING(GPIO8) -#endif - -#ifdef GPIO9 - DEFINE(GPIO9) -#else - MISSING(GPIO9) -#endif - -#ifdef GPIOA - DEFINE(GPIOA) -#else - MISSING(GPIOA) -#endif - -#ifdef GPIOB - DEFINE(GPIOB) -#else - MISSING(GPIOB) -#endif - -#ifdef GPIOC - DEFINE(GPIOC) -#else - MISSING(GPIOC) -#endif - -#ifdef GPIOD - DEFINE(GPIOD) -#else - MISSING(GPIOD) -#endif - -#ifdef GPIOE - DEFINE(GPIOE) -#else - MISSING(GPIOE) -#endif - -#ifdef GPIOF - DEFINE(GPIOF) -#else - MISSING(GPIOF) -#endif - -#ifdef GPIOR0 - DEFINE(GPIOR0) -#else - MISSING(GPIOR0) -#endif - -#ifdef GPIOR1 - DEFINE(GPIOR1) -#else - MISSING(GPIOR1) -#endif - -#ifdef GPIOR2 - DEFINE(GPIOR2) -#else - MISSING(GPIOR2) -#endif - -#ifdef GPIOR3 - DEFINE(GPIOR3) -#else - MISSING(GPIOR3) -#endif - -#ifdef GPIOR4 - DEFINE(GPIOR4) -#else - MISSING(GPIOR4) -#endif - -#ifdef GPIOR5 - DEFINE(GPIOR5) -#else - MISSING(GPIOR5) -#endif - -#ifdef GPIOR6 - DEFINE(GPIOR6) -#else - MISSING(GPIOR6) -#endif - -#ifdef GPIOR7 - DEFINE(GPIOR7) -#else - MISSING(GPIOR7) -#endif - -#ifdef GPIOR8 - DEFINE(GPIOR8) -#else - MISSING(GPIOR8) -#endif - -#ifdef GPIOR9 - DEFINE(GPIOR9) -#else - MISSING(GPIOR9) -#endif - -#ifdef GPIORA - DEFINE(GPIORA) -#else - MISSING(GPIORA) -#endif - -#ifdef GPIORB - DEFINE(GPIORB) -#else - MISSING(GPIORB) -#endif - -#ifdef GPIORC - DEFINE(GPIORC) -#else - MISSING(GPIORC) -#endif - -#ifdef GPIORD - DEFINE(GPIORD) -#else - MISSING(GPIORD) -#endif - -#ifdef GPIORE - DEFINE(GPIORE) -#else - MISSING(GPIORE) -#endif - -#ifdef GPIORF - DEFINE(GPIORF) -#else - MISSING(GPIORF) -#endif - -#ifdef GPIO_GPIO0 - DEFINE(GPIO_GPIO0) -#else - MISSING(GPIO_GPIO0) -#endif - -#ifdef GPIO_GPIO1 - DEFINE(GPIO_GPIO1) -#else - MISSING(GPIO_GPIO1) -#endif - -#ifdef GPIO_GPIO2 - DEFINE(GPIO_GPIO2) -#else - MISSING(GPIO_GPIO2) -#endif - -#ifdef GPIO_GPIO3 - DEFINE(GPIO_GPIO3) -#else - MISSING(GPIO_GPIO3) -#endif - -#ifdef GPIO_GPIO4 - DEFINE(GPIO_GPIO4) -#else - MISSING(GPIO_GPIO4) -#endif - -#ifdef GPIO_GPIO5 - DEFINE(GPIO_GPIO5) -#else - MISSING(GPIO_GPIO5) -#endif - -#ifdef GPIO_GPIO6 - DEFINE(GPIO_GPIO6) -#else - MISSING(GPIO_GPIO6) -#endif - -#ifdef GPIO_GPIO7 - DEFINE(GPIO_GPIO7) -#else - MISSING(GPIO_GPIO7) -#endif - -#ifdef GPIO_GPIO8 - DEFINE(GPIO_GPIO8) -#else - MISSING(GPIO_GPIO8) -#endif - -#ifdef GPIO_GPIO9 - DEFINE(GPIO_GPIO9) -#else - MISSING(GPIO_GPIO9) -#endif - -#ifdef GPIO_GPIOA - DEFINE(GPIO_GPIOA) -#else - MISSING(GPIO_GPIOA) -#endif - -#ifdef GPIO_GPIOB - DEFINE(GPIO_GPIOB) -#else - MISSING(GPIO_GPIOB) -#endif - -#ifdef GPIO_GPIOC - DEFINE(GPIO_GPIOC) -#else - MISSING(GPIO_GPIOC) -#endif - -#ifdef GPIO_GPIOD - DEFINE(GPIO_GPIOD) -#else - MISSING(GPIO_GPIOD) -#endif - -#ifdef GPIO_GPIOE - DEFINE(GPIO_GPIOE) -#else - MISSING(GPIO_GPIOE) -#endif - -#ifdef GPIO_GPIOF - DEFINE(GPIO_GPIOF) -#else - MISSING(GPIO_GPIOF) -#endif - -#ifdef GPIO_GPIOR0 - DEFINE(GPIO_GPIOR0) -#else - MISSING(GPIO_GPIOR0) -#endif - -#ifdef GPIO_GPIOR1 - DEFINE(GPIO_GPIOR1) -#else - MISSING(GPIO_GPIOR1) -#endif - -#ifdef GPIO_GPIOR2 - DEFINE(GPIO_GPIOR2) -#else - MISSING(GPIO_GPIOR2) -#endif - -#ifdef GPIO_GPIOR3 - DEFINE(GPIO_GPIOR3) -#else - MISSING(GPIO_GPIOR3) -#endif - -#ifdef GPIO_GPIOR4 - DEFINE(GPIO_GPIOR4) -#else - MISSING(GPIO_GPIOR4) -#endif - -#ifdef GPIO_GPIOR5 - DEFINE(GPIO_GPIOR5) -#else - MISSING(GPIO_GPIOR5) -#endif - -#ifdef GPIO_GPIOR6 - DEFINE(GPIO_GPIOR6) -#else - MISSING(GPIO_GPIOR6) -#endif - -#ifdef GPIO_GPIOR7 - DEFINE(GPIO_GPIOR7) -#else - MISSING(GPIO_GPIOR7) -#endif - -#ifdef GPIO_GPIOR8 - DEFINE(GPIO_GPIOR8) -#else - MISSING(GPIO_GPIOR8) -#endif - -#ifdef GPIO_GPIOR9 - DEFINE(GPIO_GPIOR9) -#else - MISSING(GPIO_GPIOR9) -#endif - -#ifdef GPIO_GPIORA - DEFINE(GPIO_GPIORA) -#else - MISSING(GPIO_GPIORA) -#endif - -#ifdef GPIO_GPIORB - DEFINE(GPIO_GPIORB) -#else - MISSING(GPIO_GPIORB) -#endif - -#ifdef GPIO_GPIORC - DEFINE(GPIO_GPIORC) -#else - MISSING(GPIO_GPIORC) -#endif - -#ifdef GPIO_GPIORD - DEFINE(GPIO_GPIORD) -#else - MISSING(GPIO_GPIORD) -#endif - -#ifdef GPIO_GPIORE - DEFINE(GPIO_GPIORE) -#else - MISSING(GPIO_GPIORE) -#endif - -#ifdef GPIO_GPIORF - DEFINE(GPIO_GPIORF) -#else - MISSING(GPIO_GPIORF) -#endif - -#ifdef GTCCR - DEFINE(GTCCR) -#else - MISSING(GTCCR) -#endif - -#ifdef HIRESC_CTRLA - DEFINE(HIRESC_CTRLA) -#else - MISSING(HIRESC_CTRLA) -#endif - -#ifdef HIRESD_CTRLA - DEFINE(HIRESD_CTRLA) -#else - MISSING(HIRESD_CTRLA) -#endif - -#ifdef HIRESE_CTRLA - DEFINE(HIRESE_CTRLA) -#else - MISSING(HIRESE_CTRLA) -#endif - -#ifdef HIRESF_CTRLA - DEFINE(HIRESF_CTRLA) -#else - MISSING(HIRESF_CTRLA) -#endif - -#ifdef HSSPICFG - DEFINE(HSSPICFG) -#else - MISSING(HSSPICFG) -#endif - -#ifdef HSSPICNT - DEFINE(HSSPICNT) -#else - MISSING(HSSPICNT) -#endif - -#ifdef HSSPICR - DEFINE(HSSPICR) -#else - MISSING(HSSPICR) -#endif - -#ifdef HSSPIDMAB - DEFINE(HSSPIDMAB) -#else - MISSING(HSSPIDMAB) -#endif - -#ifdef HSSPIDMACS - DEFINE(HSSPIDMACS) -#else - MISSING(HSSPIDMACS) -#endif - -#ifdef HSSPIDMAD - DEFINE(HSSPIDMAD) -#else - MISSING(HSSPIDMAD) -#endif - -#ifdef HSSPIDMADH - DEFINE(HSSPIDMADH) -#else - MISSING(HSSPIDMADH) -#endif - -#ifdef HSSPIDMADL - DEFINE(HSSPIDMADL) -#else - MISSING(HSSPIDMADL) -#endif - -#ifdef HSSPIGTR - DEFINE(HSSPIGTR) -#else - MISSING(HSSPIGTR) -#endif - -#ifdef HSSPIIER - DEFINE(HSSPIIER) -#else - MISSING(HSSPIIER) -#endif - -#ifdef HSSPIIR - DEFINE(HSSPIIR) -#else - MISSING(HSSPIIR) -#endif - -#ifdef HSSPIRDR - DEFINE(HSSPIRDR) -#else - MISSING(HSSPIRDR) -#endif - -#ifdef HSSPISR - DEFINE(HSSPISR) -#else - MISSING(HSSPISR) -#endif - -#ifdef HSSPITDR - DEFINE(HSSPITDR) -#else - MISSING(HSSPITDR) -#endif - -#ifdef HSSPITO - DEFINE(HSSPITO) -#else - MISSING(HSSPITO) -#endif - -#ifdef HSSPITOH - DEFINE(HSSPITOH) -#else - MISSING(HSSPITOH) -#endif - -#ifdef HSSPITOL - DEFINE(HSSPITOL) -#else - MISSING(HSSPITOL) -#endif - -#ifdef ICR - DEFINE(ICR) -#else - MISSING(ICR) -#endif - -#ifdef ICR0 - DEFINE(ICR0) -#else - MISSING(ICR0) -#endif - -#ifdef ICR0H - DEFINE(ICR0H) -#else - MISSING(ICR0H) -#endif - -#ifdef ICR0L - DEFINE(ICR0L) -#else - MISSING(ICR0L) -#endif - -#ifdef ICR1 - DEFINE(ICR1) -#else - MISSING(ICR1) -#endif - -#ifdef ICR1H - DEFINE(ICR1H) -#else - MISSING(ICR1H) -#endif - -#ifdef ICR1L - DEFINE(ICR1L) -#else - MISSING(ICR1L) -#endif - -#ifdef ICR3 - DEFINE(ICR3) -#else - MISSING(ICR3) -#endif - -#ifdef ICR3H - DEFINE(ICR3H) -#else - MISSING(ICR3H) -#endif - -#ifdef ICR3L - DEFINE(ICR3L) -#else - MISSING(ICR3L) -#endif - -#ifdef ICR4 - DEFINE(ICR4) -#else - MISSING(ICR4) -#endif - -#ifdef ICR4H - DEFINE(ICR4H) -#else - MISSING(ICR4H) -#endif - -#ifdef ICR4L - DEFINE(ICR4L) -#else - MISSING(ICR4L) -#endif - -#ifdef ICR5 - DEFINE(ICR5) -#else - MISSING(ICR5) -#endif - -#ifdef ICR5H - DEFINE(ICR5H) -#else - MISSING(ICR5H) -#endif - -#ifdef ICR5L - DEFINE(ICR5L) -#else - MISSING(ICR5L) -#endif - -#ifdef IDXCTRL - DEFINE(IDXCTRL) -#else - MISSING(IDXCTRL) -#endif - -#ifdef IDXIFLG - DEFINE(IDXIFLG) -#else - MISSING(IDXIFLG) -#endif - -#ifdef IDXIMSK - DEFINE(IDXIMSK) -#else - MISSING(IDXIMSK) -#endif - -#ifdef IDXMSDT - DEFINE(IDXMSDT) -#else - MISSING(IDXMSDT) -#endif - -#ifdef IDXSTRB - DEFINE(IDXSTRB) -#else - MISSING(IDXSTRB) -#endif - -#ifdef IEEE_ADDR_0 - DEFINE(IEEE_ADDR_0) -#else - MISSING(IEEE_ADDR_0) -#endif - -#ifdef IEEE_ADDR_1 - DEFINE(IEEE_ADDR_1) -#else - MISSING(IEEE_ADDR_1) -#endif - -#ifdef IEEE_ADDR_2 - DEFINE(IEEE_ADDR_2) -#else - MISSING(IEEE_ADDR_2) -#endif - -#ifdef IEEE_ADDR_3 - DEFINE(IEEE_ADDR_3) -#else - MISSING(IEEE_ADDR_3) -#endif - -#ifdef IEEE_ADDR_4 - DEFINE(IEEE_ADDR_4) -#else - MISSING(IEEE_ADDR_4) -#endif - -#ifdef IEEE_ADDR_5 - DEFINE(IEEE_ADDR_5) -#else - MISSING(IEEE_ADDR_5) -#endif - -#ifdef IEEE_ADDR_6 - DEFINE(IEEE_ADDR_6) -#else - MISSING(IEEE_ADDR_6) -#endif - -#ifdef IEEE_ADDR_7 - DEFINE(IEEE_ADDR_7) -#else - MISSING(IEEE_ADDR_7) -#endif - -#ifdef IFR - DEFINE(IFR) -#else - MISSING(IFR) -#endif - -#ifdef INOCR1A - DEFINE(INOCR1A) -#else - MISSING(INOCR1A) -#endif - -#ifdef INOCR1AH - DEFINE(INOCR1AH) -#else - MISSING(INOCR1AH) -#endif - -#ifdef INOCR1AL - DEFINE(INOCR1AL) -#else - MISSING(INOCR1AL) -#endif - -#ifdef INOCR1B - DEFINE(INOCR1B) -#else - MISSING(INOCR1B) -#endif - -#ifdef INOCR1BH - DEFINE(INOCR1BH) -#else - MISSING(INOCR1BH) -#endif - -#ifdef INOCR1BL - DEFINE(INOCR1BL) -#else - MISSING(INOCR1BL) -#endif - -#ifdef INTCCR0 - DEFINE(INTCCR0) -#else - MISSING(INTCCR0) -#endif - -#ifdef INTCCR1A - DEFINE(INTCCR1A) -#else - MISSING(INTCCR1A) -#endif - -#ifdef INTCCR1B - DEFINE(INTCCR1B) -#else - MISSING(INTCCR1B) -#endif - -#ifdef INTCNT - DEFINE(INTCNT) -#else - MISSING(INTCNT) -#endif - -#ifdef INTCNT1 - DEFINE(INTCNT1) -#else - MISSING(INTCNT1) -#endif - -#ifdef INTCNT1H - DEFINE(INTCNT1H) -#else - MISSING(INTCNT1H) -#endif - -#ifdef INTCNT1L - DEFINE(INTCNT1L) -#else - MISSING(INTCNT1L) -#endif - -#ifdef INTIFR - DEFINE(INTIFR) -#else - MISSING(INTIFR) -#endif - -#ifdef INTIMSK - DEFINE(INTIMSK) -#else - MISSING(INTIMSK) -#endif - -#ifdef IOF - DEFINE(IOF) -#else - MISSING(IOF) -#endif - -#ifdef IO_DATIN - DEFINE(IO_DATIN) -#else - MISSING(IO_DATIN) -#endif - -#ifdef IO_DATOUT - DEFINE(IO_DATOUT) -#else - MISSING(IO_DATOUT) -#endif - -#ifdef IO_ENAB - DEFINE(IO_ENAB) -#else - MISSING(IO_ENAB) -#endif - -#ifdef IPA - DEFINE(IPA) -#else - MISSING(IPA) -#endif - -#ifdef IPAH - DEFINE(IPAH) -#else - MISSING(IPAH) -#endif - -#ifdef IPAL - DEFINE(IPAL) -#else - MISSING(IPAL) -#endif - -#ifdef IPCR - DEFINE(IPCR) -#else - MISSING(IPCR) -#endif - -#ifdef IPD - DEFINE(IPD) -#else - MISSING(IPD) -#endif - -#ifdef IPDH - DEFINE(IPDH) -#else - MISSING(IPDH) -#endif - -#ifdef IPDL - DEFINE(IPDL) -#else - MISSING(IPDL) -#endif - -#ifdef IRCOM_CTRL - DEFINE(IRCOM_CTRL) -#else - MISSING(IRCOM_CTRL) -#endif - -#ifdef IRCOM_RXPLCTRL - DEFINE(IRCOM_RXPLCTRL) -#else - MISSING(IRCOM_RXPLCTRL) -#endif - -#ifdef IRCOM_TXPLCTRL - DEFINE(IRCOM_TXPLCTRL) -#else - MISSING(IRCOM_TXPLCTRL) -#endif - -#ifdef IRDAMOD - DEFINE(IRDAMOD) -#else - MISSING(IRDAMOD) -#endif - -#ifdef IRQ_MASK - DEFINE(IRQ_MASK) -#else - MISSING(IRQ_MASK) -#endif - -#ifdef IRQ_STATUS - DEFINE(IRQ_STATUS) -#else - MISSING(IRQ_STATUS) -#endif - -#ifdef KBER - DEFINE(KBER) -#else - MISSING(KBER) -#endif - -#ifdef KBFR - DEFINE(KBFR) -#else - MISSING(KBFR) -#endif - -#ifdef KBLSR - DEFINE(KBLSR) -#else - MISSING(KBLSR) -#endif - -#ifdef LCDCCR - DEFINE(LCDCCR) -#else - MISSING(LCDCCR) -#endif - -#ifdef LCDCRA - DEFINE(LCDCRA) -#else - MISSING(LCDCRA) -#endif - -#ifdef LCDCRB - DEFINE(LCDCRB) -#else - MISSING(LCDCRB) -#endif - -#ifdef LCDDR0 - DEFINE(LCDDR0) -#else - MISSING(LCDDR0) -#endif - -#ifdef LCDDR00 - DEFINE(LCDDR00) -#else - MISSING(LCDDR00) -#endif - -#ifdef LCDDR01 - DEFINE(LCDDR01) -#else - MISSING(LCDDR01) -#endif - -#ifdef LCDDR02 - DEFINE(LCDDR02) -#else - MISSING(LCDDR02) -#endif - -#ifdef LCDDR03 - DEFINE(LCDDR03) -#else - MISSING(LCDDR03) -#endif - -#ifdef LCDDR04 - DEFINE(LCDDR04) -#else - MISSING(LCDDR04) -#endif - -#ifdef LCDDR05 - DEFINE(LCDDR05) -#else - MISSING(LCDDR05) -#endif - -#ifdef LCDDR06 - DEFINE(LCDDR06) -#else - MISSING(LCDDR06) -#endif - -#ifdef LCDDR07 - DEFINE(LCDDR07) -#else - MISSING(LCDDR07) -#endif - -#ifdef LCDDR08 - DEFINE(LCDDR08) -#else - MISSING(LCDDR08) -#endif - -#ifdef LCDDR09 - DEFINE(LCDDR09) -#else - MISSING(LCDDR09) -#endif - -#ifdef LCDDR1 - DEFINE(LCDDR1) -#else - MISSING(LCDDR1) -#endif - -#ifdef LCDDR10 - DEFINE(LCDDR10) -#else - MISSING(LCDDR10) -#endif - -#ifdef LCDDR11 - DEFINE(LCDDR11) -#else - MISSING(LCDDR11) -#endif - -#ifdef LCDDR12 - DEFINE(LCDDR12) -#else - MISSING(LCDDR12) -#endif - -#ifdef LCDDR13 - DEFINE(LCDDR13) -#else - MISSING(LCDDR13) -#endif - -#ifdef LCDDR14 - DEFINE(LCDDR14) -#else - MISSING(LCDDR14) -#endif - -#ifdef LCDDR15 - DEFINE(LCDDR15) -#else - MISSING(LCDDR15) -#endif - -#ifdef LCDDR16 - DEFINE(LCDDR16) -#else - MISSING(LCDDR16) -#endif - -#ifdef LCDDR17 - DEFINE(LCDDR17) -#else - MISSING(LCDDR17) -#endif - -#ifdef LCDDR18 - DEFINE(LCDDR18) -#else - MISSING(LCDDR18) -#endif - -#ifdef LCDDR19 - DEFINE(LCDDR19) -#else - MISSING(LCDDR19) -#endif - -#ifdef LCDDR2 - DEFINE(LCDDR2) -#else - MISSING(LCDDR2) -#endif - -#ifdef LCDDR3 - DEFINE(LCDDR3) -#else - MISSING(LCDDR3) -#endif - -#ifdef LCDDR4 - DEFINE(LCDDR4) -#else - MISSING(LCDDR4) -#endif - -#ifdef LCDDR5 - DEFINE(LCDDR5) -#else - MISSING(LCDDR5) -#endif - -#ifdef LCDDR6 - DEFINE(LCDDR6) -#else - MISSING(LCDDR6) -#endif - -#ifdef LCDDR7 - DEFINE(LCDDR7) -#else - MISSING(LCDDR7) -#endif - -#ifdef LCDDR8 - DEFINE(LCDDR8) -#else - MISSING(LCDDR8) -#endif - -#ifdef LCDDR9 - DEFINE(LCDDR9) -#else - MISSING(LCDDR9) -#endif - -#ifdef LCDFRR - DEFINE(LCDFRR) -#else - MISSING(LCDFRR) -#endif - -#ifdef LEDCR - DEFINE(LEDCR) -#else - MISSING(LEDCR) -#endif - -#ifdef LFCAL - DEFINE(LFCAL) -#else - MISSING(LFCAL) -#endif - -#ifdef LFCALH - DEFINE(LFCALH) -#else - MISSING(LFCALH) -#endif - -#ifdef LFCALL - DEFINE(LFCALL) -#else - MISSING(LFCALL) -#endif - -#ifdef LFCDR - DEFINE(LFCDR) -#else - MISSING(LFCDR) -#endif - -#ifdef LFFR - DEFINE(LFFR) -#else - MISSING(LFFR) -#endif - -#ifdef LFHCR - DEFINE(LFHCR) -#else - MISSING(LFHCR) -#endif - -#ifdef LFIDC - DEFINE(LFIDC) -#else - MISSING(LFIDC) -#endif - -#ifdef LFIDCH - DEFINE(LFIDCH) -#else - MISSING(LFIDCH) -#endif - -#ifdef LFIDCL - DEFINE(LFIDCL) -#else - MISSING(LFIDCL) -#endif - -#ifdef LFIMR - DEFINE(LFIMR) -#else - MISSING(LFIMR) -#endif - -#ifdef LFRB - DEFINE(LFRB) -#else - MISSING(LFRB) -#endif - -#ifdef LFRCR - DEFINE(LFRCR) -#else - MISSING(LFRCR) -#endif - -#ifdef LFRR - DEFINE(LFRR) -#else - MISSING(LFRR) -#endif - -#ifdef LFSR0 - DEFINE(LFSR0) -#else - MISSING(LFSR0) -#endif - -#ifdef LFSR1 - DEFINE(LFSR1) -#else - MISSING(LFSR1) -#endif - -#ifdef LFSR2 - DEFINE(LFSR2) -#else - MISSING(LFSR2) -#endif - -#ifdef LFSR3 - DEFINE(LFSR3) -#else - MISSING(LFSR3) -#endif - -#ifdef LINBRR - DEFINE(LINBRR) -#else - MISSING(LINBRR) -#endif - -#ifdef LINBRRH - DEFINE(LINBRRH) -#else - MISSING(LINBRRH) -#endif - -#ifdef LINBRRL - DEFINE(LINBRRL) -#else - MISSING(LINBRRL) -#endif - -#ifdef LINBTR - DEFINE(LINBTR) -#else - MISSING(LINBTR) -#endif - -#ifdef LINCR - DEFINE(LINCR) -#else - MISSING(LINCR) -#endif - -#ifdef LINDAT - DEFINE(LINDAT) -#else - MISSING(LINDAT) -#endif - -#ifdef LINDLR - DEFINE(LINDLR) -#else - MISSING(LINDLR) -#endif - -#ifdef LINENIR - DEFINE(LINENIR) -#else - MISSING(LINENIR) -#endif - -#ifdef LINERR - DEFINE(LINERR) -#else - MISSING(LINERR) -#endif - -#ifdef LINIDR - DEFINE(LINIDR) -#else - MISSING(LINIDR) -#endif - -#ifdef LINSEL - DEFINE(LINSEL) -#else - MISSING(LINSEL) -#endif - -#ifdef LINSIR - DEFINE(LINSIR) -#else - MISSING(LINSIR) -#endif - -#ifdef LLCR - DEFINE(LLCR) -#else - MISSING(LLCR) -#endif - -#ifdef LLDRH - DEFINE(LLDRH) -#else - MISSING(LLDRH) -#endif - -#ifdef LLDRL - DEFINE(LLDRL) -#else - MISSING(LLDRL) -#endif - -#ifdef LOCKDET1 - DEFINE(LOCKDET1) -#else - MISSING(LOCKDET1) -#endif - -#ifdef LOCKDET2 - DEFINE(LOCKDET2) -#else - MISSING(LOCKDET2) -#endif - -#ifdef MAN_ID_0 - DEFINE(MAN_ID_0) -#else - MISSING(MAN_ID_0) -#endif - -#ifdef MAN_ID_1 - DEFINE(MAN_ID_1) -#else - MISSING(MAN_ID_1) -#endif - -#ifdef MCSR - DEFINE(MCSR) -#else - MISSING(MCSR) -#endif - -#ifdef MCUCR - DEFINE(MCUCR) -#else - MISSING(MCUCR) -#endif - -#ifdef MCUCS - DEFINE(MCUCS) -#else - MISSING(MCUCS) -#endif - -#ifdef MCUCSR - DEFINE(MCUCSR) -#else - MISSING(MCUCSR) -#endif - -#ifdef MCUR - DEFINE(MCUR) -#else - MISSING(MCUR) -#endif - -#ifdef MCUSR - DEFINE(MCUSR) -#else - MISSING(MCUSR) -#endif - -#ifdef MCU_ANAINIT - DEFINE(MCU_ANAINIT) -#else - MISSING(MCU_ANAINIT) -#endif - -#ifdef MCU_AWEXLOCK - DEFINE(MCU_AWEXLOCK) -#else - MISSING(MCU_AWEXLOCK) -#endif - -#ifdef MCU_DEVID0 - DEFINE(MCU_DEVID0) -#else - MISSING(MCU_DEVID0) -#endif - -#ifdef MCU_DEVID1 - DEFINE(MCU_DEVID1) -#else - MISSING(MCU_DEVID1) -#endif - -#ifdef MCU_DEVID2 - DEFINE(MCU_DEVID2) -#else - MISSING(MCU_DEVID2) -#endif - -#ifdef MCU_EVSYSLOCK - DEFINE(MCU_EVSYSLOCK) -#else - MISSING(MCU_EVSYSLOCK) -#endif - -#ifdef MCU_JTAGUID - DEFINE(MCU_JTAGUID) -#else - MISSING(MCU_JTAGUID) -#endif - -#ifdef MCU_MCUCR - DEFINE(MCU_MCUCR) -#else - MISSING(MCU_MCUCR) -#endif - -#ifdef MCU_REVID - DEFINE(MCU_REVID) -#else - MISSING(MCU_REVID) -#endif - -#ifdef MODCR - DEFINE(MODCR) -#else - MISSING(MODCR) -#endif - -#ifdef MONDR - DEFINE(MONDR) -#else - MISSING(MONDR) -#endif - -#ifdef MSELR - DEFINE(MSELR) -#else - MISSING(MSELR) -#endif - -#ifdef MSMCR - DEFINE(MSMCR) -#else - MISSING(MSMCR) -#endif - -#ifdef MSPCR - DEFINE(MSPCR) -#else - MISSING(MSPCR) -#endif - -#ifdef MSPDR - DEFINE(MSPDR) -#else - MISSING(MSPDR) -#endif - -#ifdef MSPSR - DEFINE(MSPSR) -#else - MISSING(MSPSR) -#endif - -#ifdef MSVCAL - DEFINE(MSVCAL) -#else - MISSING(MSVCAL) -#endif - -#ifdef MUBRR - DEFINE(MUBRR) -#else - MISSING(MUBRR) -#endif - -#ifdef MUBRRH - DEFINE(MUBRRH) -#else - MISSING(MUBRRH) -#endif - -#ifdef MUBRRL - DEFINE(MUBRRL) -#else - MISSING(MUBRRL) -#endif - -#ifdef NEMCR - DEFINE(NEMCR) -#else - MISSING(NEMCR) -#endif - -#ifdef NVMCMD - DEFINE(NVMCMD) -#else - MISSING(NVMCMD) -#endif - -#ifdef NVMCSR - DEFINE(NVMCSR) -#else - MISSING(NVMCSR) -#endif - -#ifdef NVM_ADDR0 - DEFINE(NVM_ADDR0) -#else - MISSING(NVM_ADDR0) -#endif - -#ifdef NVM_ADDR1 - DEFINE(NVM_ADDR1) -#else - MISSING(NVM_ADDR1) -#endif - -#ifdef NVM_ADDR2 - DEFINE(NVM_ADDR2) -#else - MISSING(NVM_ADDR2) -#endif - -#ifdef NVM_CMD - DEFINE(NVM_CMD) -#else - MISSING(NVM_CMD) -#endif - -#ifdef NVM_CTRLA - DEFINE(NVM_CTRLA) -#else - MISSING(NVM_CTRLA) -#endif - -#ifdef NVM_CTRLB - DEFINE(NVM_CTRLB) -#else - MISSING(NVM_CTRLB) -#endif - -#ifdef NVM_DATA0 - DEFINE(NVM_DATA0) -#else - MISSING(NVM_DATA0) -#endif - -#ifdef NVM_DATA1 - DEFINE(NVM_DATA1) -#else - MISSING(NVM_DATA1) -#endif - -#ifdef NVM_DATA2 - DEFINE(NVM_DATA2) -#else - MISSING(NVM_DATA2) -#endif - -#ifdef NVM_INTCTRL - DEFINE(NVM_INTCTRL) -#else - MISSING(NVM_INTCTRL) -#endif - -#ifdef NVM_LOCKBITS - DEFINE(NVM_LOCKBITS) -#else - MISSING(NVM_LOCKBITS) -#endif - -#ifdef NVM_STATUS - DEFINE(NVM_STATUS) -#else - MISSING(NVM_STATUS) -#endif - -#ifdef OCDR - DEFINE(OCDR) -#else - MISSING(OCDR) -#endif - -#ifdef OCD_OCDR0 - DEFINE(OCD_OCDR0) -#else - MISSING(OCD_OCDR0) -#endif - -#ifdef OCD_OCDR1 - DEFINE(OCD_OCDR1) -#else - MISSING(OCD_OCDR1) -#endif - -#ifdef OCR0 - DEFINE(OCR0) -#else - MISSING(OCR0) -#endif - -#ifdef OCR0A - DEFINE(OCR0A) -#else - MISSING(OCR0A) -#endif - -#ifdef OCR0AH - DEFINE(OCR0AH) -#else - MISSING(OCR0AH) -#endif - -#ifdef OCR0AL - DEFINE(OCR0AL) -#else - MISSING(OCR0AL) -#endif - -#ifdef OCR0B - DEFINE(OCR0B) -#else - MISSING(OCR0B) -#endif - -#ifdef OCR0BH - DEFINE(OCR0BH) -#else - MISSING(OCR0BH) -#endif - -#ifdef OCR0BL - DEFINE(OCR0BL) -#else - MISSING(OCR0BL) -#endif - -#ifdef OCR0RA - DEFINE(OCR0RA) -#else - MISSING(OCR0RA) -#endif - -#ifdef OCR0RAH - DEFINE(OCR0RAH) -#else - MISSING(OCR0RAH) -#endif - -#ifdef OCR0RAL - DEFINE(OCR0RAL) -#else - MISSING(OCR0RAL) -#endif - -#ifdef OCR0RB - DEFINE(OCR0RB) -#else - MISSING(OCR0RB) -#endif - -#ifdef OCR0RBH - DEFINE(OCR0RBH) -#else - MISSING(OCR0RBH) -#endif - -#ifdef OCR0RBL - DEFINE(OCR0RBL) -#else - MISSING(OCR0RBL) -#endif - -#ifdef OCR0SA - DEFINE(OCR0SA) -#else - MISSING(OCR0SA) -#endif - -#ifdef OCR0SAH - DEFINE(OCR0SAH) -#else - MISSING(OCR0SAH) -#endif - -#ifdef OCR0SAL - DEFINE(OCR0SAL) -#else - MISSING(OCR0SAL) -#endif - -#ifdef OCR0SB - DEFINE(OCR0SB) -#else - MISSING(OCR0SB) -#endif - -#ifdef OCR0SBH - DEFINE(OCR0SBH) -#else - MISSING(OCR0SBH) -#endif - -#ifdef OCR0SBL - DEFINE(OCR0SBL) -#else - MISSING(OCR0SBL) -#endif - -#ifdef OCR1 - DEFINE(OCR1) -#else - MISSING(OCR1) -#endif - -#ifdef OCR1A - DEFINE(OCR1A) -#else - MISSING(OCR1A) -#endif - -#ifdef OCR1AH - DEFINE(OCR1AH) -#else - MISSING(OCR1AH) -#endif - -#ifdef OCR1AL - DEFINE(OCR1AL) -#else - MISSING(OCR1AL) -#endif - -#ifdef OCR1B - DEFINE(OCR1B) -#else - MISSING(OCR1B) -#endif - -#ifdef OCR1BH - DEFINE(OCR1BH) -#else - MISSING(OCR1BH) -#endif - -#ifdef OCR1BL - DEFINE(OCR1BL) -#else - MISSING(OCR1BL) -#endif - -#ifdef OCR1C - DEFINE(OCR1C) -#else - MISSING(OCR1C) -#endif - -#ifdef OCR1CH - DEFINE(OCR1CH) -#else - MISSING(OCR1CH) -#endif - -#ifdef OCR1CL - DEFINE(OCR1CL) -#else - MISSING(OCR1CL) -#endif - -#ifdef OCR1D - DEFINE(OCR1D) -#else - MISSING(OCR1D) -#endif - -#ifdef OCR1H - DEFINE(OCR1H) -#else - MISSING(OCR1H) -#endif - -#ifdef OCR1L - DEFINE(OCR1L) -#else - MISSING(OCR1L) -#endif - -#ifdef OCR1RA - DEFINE(OCR1RA) -#else - MISSING(OCR1RA) -#endif - -#ifdef OCR1RAH - DEFINE(OCR1RAH) -#else - MISSING(OCR1RAH) -#endif - -#ifdef OCR1RAL - DEFINE(OCR1RAL) -#else - MISSING(OCR1RAL) -#endif - -#ifdef OCR1RB - DEFINE(OCR1RB) -#else - MISSING(OCR1RB) -#endif - -#ifdef OCR1RBH - DEFINE(OCR1RBH) -#else - MISSING(OCR1RBH) -#endif - -#ifdef OCR1RBL - DEFINE(OCR1RBL) -#else - MISSING(OCR1RBL) -#endif - -#ifdef OCR1SA - DEFINE(OCR1SA) -#else - MISSING(OCR1SA) -#endif - -#ifdef OCR1SAH - DEFINE(OCR1SAH) -#else - MISSING(OCR1SAH) -#endif - -#ifdef OCR1SAL - DEFINE(OCR1SAL) -#else - MISSING(OCR1SAL) -#endif - -#ifdef OCR1SB - DEFINE(OCR1SB) -#else - MISSING(OCR1SB) -#endif - -#ifdef OCR1SBH - DEFINE(OCR1SBH) -#else - MISSING(OCR1SBH) -#endif - -#ifdef OCR1SBL - DEFINE(OCR1SBL) -#else - MISSING(OCR1SBL) -#endif - -#ifdef OCR2 - DEFINE(OCR2) -#else - MISSING(OCR2) -#endif - -#ifdef OCR2A - DEFINE(OCR2A) -#else - MISSING(OCR2A) -#endif - -#ifdef OCR2B - DEFINE(OCR2B) -#else - MISSING(OCR2B) -#endif - -#ifdef OCR2RA - DEFINE(OCR2RA) -#else - MISSING(OCR2RA) -#endif - -#ifdef OCR2RAH - DEFINE(OCR2RAH) -#else - MISSING(OCR2RAH) -#endif - -#ifdef OCR2RAL - DEFINE(OCR2RAL) -#else - MISSING(OCR2RAL) -#endif - -#ifdef OCR2RB - DEFINE(OCR2RB) -#else - MISSING(OCR2RB) -#endif - -#ifdef OCR2RBH - DEFINE(OCR2RBH) -#else - MISSING(OCR2RBH) -#endif - -#ifdef OCR2RBL - DEFINE(OCR2RBL) -#else - MISSING(OCR2RBL) -#endif - -#ifdef OCR2SA - DEFINE(OCR2SA) -#else - MISSING(OCR2SA) -#endif - -#ifdef OCR2SAH - DEFINE(OCR2SAH) -#else - MISSING(OCR2SAH) -#endif - -#ifdef OCR2SAL - DEFINE(OCR2SAL) -#else - MISSING(OCR2SAL) -#endif - -#ifdef OCR2SB - DEFINE(OCR2SB) -#else - MISSING(OCR2SB) -#endif - -#ifdef OCR2SBH - DEFINE(OCR2SBH) -#else - MISSING(OCR2SBH) -#endif - -#ifdef OCR2SBL - DEFINE(OCR2SBL) -#else - MISSING(OCR2SBL) -#endif - -#ifdef OCR3A - DEFINE(OCR3A) -#else - MISSING(OCR3A) -#endif - -#ifdef OCR3AH - DEFINE(OCR3AH) -#else - MISSING(OCR3AH) -#endif - -#ifdef OCR3AL - DEFINE(OCR3AL) -#else - MISSING(OCR3AL) -#endif - -#ifdef OCR3B - DEFINE(OCR3B) -#else - MISSING(OCR3B) -#endif - -#ifdef OCR3BH - DEFINE(OCR3BH) -#else - MISSING(OCR3BH) -#endif - -#ifdef OCR3BL - DEFINE(OCR3BL) -#else - MISSING(OCR3BL) -#endif - -#ifdef OCR3C - DEFINE(OCR3C) -#else - MISSING(OCR3C) -#endif - -#ifdef OCR3CH - DEFINE(OCR3CH) -#else - MISSING(OCR3CH) -#endif - -#ifdef OCR3CL - DEFINE(OCR3CL) -#else - MISSING(OCR3CL) -#endif - -#ifdef OCR4A - DEFINE(OCR4A) -#else - MISSING(OCR4A) -#endif - -#ifdef OCR4AH - DEFINE(OCR4AH) -#else - MISSING(OCR4AH) -#endif - -#ifdef OCR4AL - DEFINE(OCR4AL) -#else - MISSING(OCR4AL) -#endif - -#ifdef OCR4B - DEFINE(OCR4B) -#else - MISSING(OCR4B) -#endif - -#ifdef OCR4BH - DEFINE(OCR4BH) -#else - MISSING(OCR4BH) -#endif - -#ifdef OCR4BL - DEFINE(OCR4BL) -#else - MISSING(OCR4BL) -#endif - -#ifdef OCR4C - DEFINE(OCR4C) -#else - MISSING(OCR4C) -#endif - -#ifdef OCR4CH - DEFINE(OCR4CH) -#else - MISSING(OCR4CH) -#endif - -#ifdef OCR4CL - DEFINE(OCR4CL) -#else - MISSING(OCR4CL) -#endif - -#ifdef OCR4D - DEFINE(OCR4D) -#else - MISSING(OCR4D) -#endif - -#ifdef OCR5A - DEFINE(OCR5A) -#else - MISSING(OCR5A) -#endif - -#ifdef OCR5AH - DEFINE(OCR5AH) -#else - MISSING(OCR5AH) -#endif - -#ifdef OCR5AL - DEFINE(OCR5AL) -#else - MISSING(OCR5AL) -#endif - -#ifdef OCR5B - DEFINE(OCR5B) -#else - MISSING(OCR5B) -#endif - -#ifdef OCR5BH - DEFINE(OCR5BH) -#else - MISSING(OCR5BH) -#endif - -#ifdef OCR5BL - DEFINE(OCR5BL) -#else - MISSING(OCR5BL) -#endif - -#ifdef OCR5C - DEFINE(OCR5C) -#else - MISSING(OCR5C) -#endif - -#ifdef OCR5CH - DEFINE(OCR5CH) -#else - MISSING(OCR5CH) -#endif - -#ifdef OCR5CL - DEFINE(OCR5CL) -#else - MISSING(OCR5CL) -#endif - -#ifdef OCRA1 - DEFINE(OCRA1) -#else - MISSING(OCRA1) -#endif - -#ifdef OCRA1H - DEFINE(OCRA1H) -#else - MISSING(OCRA1H) -#endif - -#ifdef OCRA1L - DEFINE(OCRA1L) -#else - MISSING(OCRA1L) -#endif - -#ifdef OCRB1 - DEFINE(OCRB1) -#else - MISSING(OCRB1) -#endif - -#ifdef OCRB1H - DEFINE(OCRB1H) -#else - MISSING(OCRB1H) -#endif - -#ifdef OCRB1L - DEFINE(OCRB1L) -#else - MISSING(OCRB1L) -#endif - -#ifdef OSCCAL - DEFINE(OSCCAL) -#else - MISSING(OSCCAL) -#endif - -#ifdef OSC_CTRL - DEFINE(OSC_CTRL) -#else - MISSING(OSC_CTRL) -#endif - -#ifdef OSC_DFLLCTRL - DEFINE(OSC_DFLLCTRL) -#else - MISSING(OSC_DFLLCTRL) -#endif - -#ifdef OSC_PLLCTRL - DEFINE(OSC_PLLCTRL) -#else - MISSING(OSC_PLLCTRL) -#endif - -#ifdef OSC_RC32KCAL - DEFINE(OSC_RC32KCAL) -#else - MISSING(OSC_RC32KCAL) -#endif - -#ifdef OSC_STATUS - DEFINE(OSC_STATUS) -#else - MISSING(OSC_STATUS) -#endif - -#ifdef OSC_XOSCCTRL - DEFINE(OSC_XOSCCTRL) -#else - MISSING(OSC_XOSCCTRL) -#endif - -#ifdef OSC_XOSCFAIL - DEFINE(OSC_XOSCFAIL) -#else - MISSING(OSC_XOSCFAIL) -#endif - -#ifdef OSICSR - DEFINE(OSICSR) -#else - MISSING(OSICSR) -#endif - -#ifdef OTGCON - DEFINE(OTGCON) -#else - MISSING(OTGCON) -#endif - -#ifdef OTGIEN - DEFINE(OTGIEN) -#else - MISSING(OTGIEN) -#endif - -#ifdef OTGINT - DEFINE(OTGINT) -#else - MISSING(OTGINT) -#endif - -#ifdef OTGTCON - DEFINE(OTGTCON) -#else - MISSING(OTGTCON) -#endif - -#ifdef PACR - DEFINE(PACR) -#else - MISSING(PACR) -#endif - -#ifdef PAN_ID_0 - DEFINE(PAN_ID_0) -#else - MISSING(PAN_ID_0) -#endif - -#ifdef PAN_ID_1 - DEFINE(PAN_ID_1) -#else - MISSING(PAN_ID_1) -#endif - -#ifdef PART_NUM - DEFINE(PART_NUM) -#else - MISSING(PART_NUM) -#endif - -#ifdef PASDLY2 - DEFINE(PASDLY2) -#else - MISSING(PASDLY2) -#endif - -#ifdef PBOV - DEFINE(PBOV) -#else - MISSING(PBOV) -#endif - -#ifdef PCICR - DEFINE(PCICR) -#else - MISSING(PCICR) -#endif - -#ifdef PCIFR - DEFINE(PCIFR) -#else - MISSING(PCIFR) -#endif - -#ifdef PCMSK - DEFINE(PCMSK) -#else - MISSING(PCMSK) -#endif - -#ifdef PCMSK0 - DEFINE(PCMSK0) -#else - MISSING(PCMSK0) -#endif - -#ifdef PCMSK1 - DEFINE(PCMSK1) -#else - MISSING(PCMSK1) -#endif - -#ifdef PCMSK2 - DEFINE(PCMSK2) -#else - MISSING(PCMSK2) -#endif - -#ifdef PCMSK3 - DEFINE(PCMSK3) -#else - MISSING(PCMSK3) -#endif - -#ifdef PCNF - DEFINE(PCNF) -#else - MISSING(PCNF) -#endif - -#ifdef PCNF0 - DEFINE(PCNF0) -#else - MISSING(PCNF0) -#endif - -#ifdef PCNF1 - DEFINE(PCNF1) -#else - MISSING(PCNF1) -#endif - -#ifdef PCNF2 - DEFINE(PCNF2) -#else - MISSING(PCNF2) -#endif - -#ifdef PCNFE2 - DEFINE(PCNFE2) -#else - MISSING(PCNFE2) -#endif - -#ifdef PCTL - DEFINE(PCTL) -#else - MISSING(PCTL) -#endif - -#ifdef PCTL0 - DEFINE(PCTL0) -#else - MISSING(PCTL0) -#endif - -#ifdef PCTL1 - DEFINE(PCTL1) -#else - MISSING(PCTL1) -#endif - -#ifdef PCTL2 - DEFINE(PCTL2) -#else - MISSING(PCTL2) -#endif - -#ifdef PERIPHEN - DEFINE(PERIPHEN) -#else - MISSING(PERIPHEN) -#endif - -#ifdef PFRC0A - DEFINE(PFRC0A) -#else - MISSING(PFRC0A) -#endif - -#ifdef PFRC0B - DEFINE(PFRC0B) -#else - MISSING(PFRC0B) -#endif - -#ifdef PFRC1A - DEFINE(PFRC1A) -#else - MISSING(PFRC1A) -#endif - -#ifdef PFRC1B - DEFINE(PFRC1B) -#else - MISSING(PFRC1B) -#endif - -#ifdef PFRC2A - DEFINE(PFRC2A) -#else - MISSING(PFRC2A) -#endif - -#ifdef PFRC2B - DEFINE(PFRC2B) -#else - MISSING(PFRC2B) -#endif - -#ifdef PHY_CC_CCA - DEFINE(PHY_CC_CCA) -#else - MISSING(PHY_CC_CCA) -#endif - -#ifdef PHY_ED_LEVEL - DEFINE(PHY_ED_LEVEL) -#else - MISSING(PHY_ED_LEVEL) -#endif - -#ifdef PHY_RSSI - DEFINE(PHY_RSSI) -#else - MISSING(PHY_RSSI) -#endif - -#ifdef PHY_TX_PWR - DEFINE(PHY_TX_PWR) -#else - MISSING(PHY_TX_PWR) -#endif - -#ifdef PICR0 - DEFINE(PICR0) -#else - MISSING(PICR0) -#endif - -#ifdef PICR0H - DEFINE(PICR0H) -#else - MISSING(PICR0H) -#endif - -#ifdef PICR0L - DEFINE(PICR0L) -#else - MISSING(PICR0L) -#endif - -#ifdef PICR1 - DEFINE(PICR1) -#else - MISSING(PICR1) -#endif - -#ifdef PICR1H - DEFINE(PICR1H) -#else - MISSING(PICR1H) -#endif - -#ifdef PICR1L - DEFINE(PICR1L) -#else - MISSING(PICR1L) -#endif - -#ifdef PICR2 - DEFINE(PICR2) -#else - MISSING(PICR2) -#endif - -#ifdef PICR2H - DEFINE(PICR2H) -#else - MISSING(PICR2H) -#endif - -#ifdef PICR2L - DEFINE(PICR2L) -#else - MISSING(PICR2L) -#endif - -#ifdef PIFR - DEFINE(PIFR) -#else - MISSING(PIFR) -#endif - -#ifdef PIFR0 - DEFINE(PIFR0) -#else - MISSING(PIFR0) -#endif - -#ifdef PIFR1 - DEFINE(PIFR1) -#else - MISSING(PIFR1) -#endif - -#ifdef PIFR2 - DEFINE(PIFR2) -#else - MISSING(PIFR2) -#endif - -#ifdef PIM - DEFINE(PIM) -#else - MISSING(PIM) -#endif - -#ifdef PIM0 - DEFINE(PIM0) -#else - MISSING(PIM0) -#endif - -#ifdef PIM1 - DEFINE(PIM1) -#else - MISSING(PIM1) -#endif - -#ifdef PIM2 - DEFINE(PIM2) -#else - MISSING(PIM2) -#endif - -#ifdef PINA - DEFINE(PINA) -#else - MISSING(PINA) -#endif - -#ifdef PINB - DEFINE(PINB) -#else - MISSING(PINB) -#endif - -#ifdef PINC - DEFINE(PINC) -#else - MISSING(PINC) -#endif - -#ifdef PIND - DEFINE(PIND) -#else - MISSING(PIND) -#endif - -#ifdef PINE - DEFINE(PINE) -#else - MISSING(PINE) -#endif - -#ifdef PINF - DEFINE(PINF) -#else - MISSING(PINF) -#endif - -#ifdef PING - DEFINE(PING) -#else - MISSING(PING) -#endif - -#ifdef PINH - DEFINE(PINH) -#else - MISSING(PINH) -#endif - -#ifdef PINJ - DEFINE(PINJ) -#else - MISSING(PINJ) -#endif - -#ifdef PINK - DEFINE(PINK) -#else - MISSING(PINK) -#endif - -#ifdef PINL - DEFINE(PINL) -#else - MISSING(PINL) -#endif - -#ifdef PLLCR - DEFINE(PLLCR) -#else - MISSING(PLLCR) -#endif - -#ifdef PLLCSR - DEFINE(PLLCSR) -#else - MISSING(PLLCSR) -#endif - -#ifdef PLLFRQ - DEFINE(PLLFRQ) -#else - MISSING(PLLFRQ) -#endif - -#ifdef PLL_CF - DEFINE(PLL_CF) -#else - MISSING(PLL_CF) -#endif - -#ifdef PLL_DCU - DEFINE(PLL_DCU) -#else - MISSING(PLL_DCU) -#endif - -#ifdef PMIC0 - DEFINE(PMIC0) -#else - MISSING(PMIC0) -#endif - -#ifdef PMIC1 - DEFINE(PMIC1) -#else - MISSING(PMIC1) -#endif - -#ifdef PMIC2 - DEFINE(PMIC2) -#else - MISSING(PMIC2) -#endif - -#ifdef PMIC_CTRL - DEFINE(PMIC_CTRL) -#else - MISSING(PMIC_CTRL) -#endif - -#ifdef PMIC_INTPRI - DEFINE(PMIC_INTPRI) -#else - MISSING(PMIC_INTPRI) -#endif - -#ifdef PMIC_STATUS - DEFINE(PMIC_STATUS) -#else - MISSING(PMIC_STATUS) -#endif - -#ifdef POC - DEFINE(POC) -#else - MISSING(POC) -#endif - -#ifdef POCR0RA - DEFINE(POCR0RA) -#else - MISSING(POCR0RA) -#endif - -#ifdef POCR0RAH - DEFINE(POCR0RAH) -#else - MISSING(POCR0RAH) -#endif - -#ifdef POCR0RAL - DEFINE(POCR0RAL) -#else - MISSING(POCR0RAL) -#endif - -#ifdef POCR0SA - DEFINE(POCR0SA) -#else - MISSING(POCR0SA) -#endif - -#ifdef POCR0SAH - DEFINE(POCR0SAH) -#else - MISSING(POCR0SAH) -#endif - -#ifdef POCR0SAL - DEFINE(POCR0SAL) -#else - MISSING(POCR0SAL) -#endif - -#ifdef POCR0SB - DEFINE(POCR0SB) -#else - MISSING(POCR0SB) -#endif - -#ifdef POCR0SBH - DEFINE(POCR0SBH) -#else - MISSING(POCR0SBH) -#endif - -#ifdef POCR0SBL - DEFINE(POCR0SBL) -#else - MISSING(POCR0SBL) -#endif - -#ifdef POCR1RA - DEFINE(POCR1RA) -#else - MISSING(POCR1RA) -#endif - -#ifdef POCR1RAH - DEFINE(POCR1RAH) -#else - MISSING(POCR1RAH) -#endif - -#ifdef POCR1RAL - DEFINE(POCR1RAL) -#else - MISSING(POCR1RAL) -#endif - -#ifdef POCR1SA - DEFINE(POCR1SA) -#else - MISSING(POCR1SA) -#endif - -#ifdef POCR1SAH - DEFINE(POCR1SAH) -#else - MISSING(POCR1SAH) -#endif - -#ifdef POCR1SAL - DEFINE(POCR1SAL) -#else - MISSING(POCR1SAL) -#endif - -#ifdef POCR1SB - DEFINE(POCR1SB) -#else - MISSING(POCR1SB) -#endif - -#ifdef POCR1SBH - DEFINE(POCR1SBH) -#else - MISSING(POCR1SBH) -#endif - -#ifdef POCR1SBL - DEFINE(POCR1SBL) -#else - MISSING(POCR1SBL) -#endif - -#ifdef POCR2RA - DEFINE(POCR2RA) -#else - MISSING(POCR2RA) -#endif - -#ifdef POCR2RAH - DEFINE(POCR2RAH) -#else - MISSING(POCR2RAH) -#endif - -#ifdef POCR2RAL - DEFINE(POCR2RAL) -#else - MISSING(POCR2RAL) -#endif - -#ifdef POCR2SA - DEFINE(POCR2SA) -#else - MISSING(POCR2SA) -#endif - -#ifdef POCR2SAH - DEFINE(POCR2SAH) -#else - MISSING(POCR2SAH) -#endif - -#ifdef POCR2SAL - DEFINE(POCR2SAL) -#else - MISSING(POCR2SAL) -#endif - -#ifdef POCR2SB - DEFINE(POCR2SB) -#else - MISSING(POCR2SB) -#endif - -#ifdef POCR2SBH - DEFINE(POCR2SBH) -#else - MISSING(POCR2SBH) -#endif - -#ifdef POCR2SBL - DEFINE(POCR2SBL) -#else - MISSING(POCR2SBL) -#endif - -#ifdef POCR_RB - DEFINE(POCR_RB) -#else - MISSING(POCR_RB) -#endif - -#ifdef POCR_RBH - DEFINE(POCR_RBH) -#else - MISSING(POCR_RBH) -#endif - -#ifdef POCR_RBL - DEFINE(POCR_RBL) -#else - MISSING(POCR_RBL) -#endif - -#ifdef POCRxRB - DEFINE(POCRxRB) -#else - MISSING(POCRxRB) -#endif - -#ifdef POCRxRBH - DEFINE(POCRxRBH) -#else - MISSING(POCRxRBH) -#endif - -#ifdef POCRxRBL - DEFINE(POCRxRBL) -#else - MISSING(POCRxRBL) -#endif - -#ifdef POM2 - DEFINE(POM2) -#else - MISSING(POM2) -#endif - -#ifdef PORTA - DEFINE(PORTA) -#else - MISSING(PORTA) -#endif - -#ifdef PORTA_DIR - DEFINE(PORTA_DIR) -#else - MISSING(PORTA_DIR) -#endif - -#ifdef PORTA_DIRCLR - DEFINE(PORTA_DIRCLR) -#else - MISSING(PORTA_DIRCLR) -#endif - -#ifdef PORTA_DIRSET - DEFINE(PORTA_DIRSET) -#else - MISSING(PORTA_DIRSET) -#endif - -#ifdef PORTA_DIRTGL - DEFINE(PORTA_DIRTGL) -#else - MISSING(PORTA_DIRTGL) -#endif - -#ifdef PORTA_IN - DEFINE(PORTA_IN) -#else - MISSING(PORTA_IN) -#endif - -#ifdef PORTA_INT0MASK - DEFINE(PORTA_INT0MASK) -#else - MISSING(PORTA_INT0MASK) -#endif - -#ifdef PORTA_INT1MASK - DEFINE(PORTA_INT1MASK) -#else - MISSING(PORTA_INT1MASK) -#endif - -#ifdef PORTA_INTCTRL - DEFINE(PORTA_INTCTRL) -#else - MISSING(PORTA_INTCTRL) -#endif - -#ifdef PORTA_INTFLAGS - DEFINE(PORTA_INTFLAGS) -#else - MISSING(PORTA_INTFLAGS) -#endif - -#ifdef PORTA_OUT - DEFINE(PORTA_OUT) -#else - MISSING(PORTA_OUT) -#endif - -#ifdef PORTA_OUTCLR - DEFINE(PORTA_OUTCLR) -#else - MISSING(PORTA_OUTCLR) -#endif - -#ifdef PORTA_OUTSET - DEFINE(PORTA_OUTSET) -#else - MISSING(PORTA_OUTSET) -#endif - -#ifdef PORTA_OUTTGL - DEFINE(PORTA_OUTTGL) -#else - MISSING(PORTA_OUTTGL) -#endif - -#ifdef PORTA_PIN0CTRL - DEFINE(PORTA_PIN0CTRL) -#else - MISSING(PORTA_PIN0CTRL) -#endif - -#ifdef PORTA_PIN1CTRL - DEFINE(PORTA_PIN1CTRL) -#else - MISSING(PORTA_PIN1CTRL) -#endif - -#ifdef PORTA_PIN2CTRL - DEFINE(PORTA_PIN2CTRL) -#else - MISSING(PORTA_PIN2CTRL) -#endif - -#ifdef PORTA_PIN3CTRL - DEFINE(PORTA_PIN3CTRL) -#else - MISSING(PORTA_PIN3CTRL) -#endif - -#ifdef PORTA_PIN4CTRL - DEFINE(PORTA_PIN4CTRL) -#else - MISSING(PORTA_PIN4CTRL) -#endif - -#ifdef PORTA_PIN5CTRL - DEFINE(PORTA_PIN5CTRL) -#else - MISSING(PORTA_PIN5CTRL) -#endif - -#ifdef PORTA_PIN6CTRL - DEFINE(PORTA_PIN6CTRL) -#else - MISSING(PORTA_PIN6CTRL) -#endif - -#ifdef PORTA_PIN7CTRL - DEFINE(PORTA_PIN7CTRL) -#else - MISSING(PORTA_PIN7CTRL) -#endif - -#ifdef PORTB - DEFINE(PORTB) -#else - MISSING(PORTB) -#endif - -#ifdef PORTB_DIR - DEFINE(PORTB_DIR) -#else - MISSING(PORTB_DIR) -#endif - -#ifdef PORTB_DIRCLR - DEFINE(PORTB_DIRCLR) -#else - MISSING(PORTB_DIRCLR) -#endif - -#ifdef PORTB_DIRSET - DEFINE(PORTB_DIRSET) -#else - MISSING(PORTB_DIRSET) -#endif - -#ifdef PORTB_DIRTGL - DEFINE(PORTB_DIRTGL) -#else - MISSING(PORTB_DIRTGL) -#endif - -#ifdef PORTB_IN - DEFINE(PORTB_IN) -#else - MISSING(PORTB_IN) -#endif - -#ifdef PORTB_INT0MASK - DEFINE(PORTB_INT0MASK) -#else - MISSING(PORTB_INT0MASK) -#endif - -#ifdef PORTB_INT1MASK - DEFINE(PORTB_INT1MASK) -#else - MISSING(PORTB_INT1MASK) -#endif - -#ifdef PORTB_INTCTRL - DEFINE(PORTB_INTCTRL) -#else - MISSING(PORTB_INTCTRL) -#endif - -#ifdef PORTB_INTFLAGS - DEFINE(PORTB_INTFLAGS) -#else - MISSING(PORTB_INTFLAGS) -#endif - -#ifdef PORTB_OUT - DEFINE(PORTB_OUT) -#else - MISSING(PORTB_OUT) -#endif - -#ifdef PORTB_OUTCLR - DEFINE(PORTB_OUTCLR) -#else - MISSING(PORTB_OUTCLR) -#endif - -#ifdef PORTB_OUTSET - DEFINE(PORTB_OUTSET) -#else - MISSING(PORTB_OUTSET) -#endif - -#ifdef PORTB_OUTTGL - DEFINE(PORTB_OUTTGL) -#else - MISSING(PORTB_OUTTGL) -#endif - -#ifdef PORTB_PIN0CTRL - DEFINE(PORTB_PIN0CTRL) -#else - MISSING(PORTB_PIN0CTRL) -#endif - -#ifdef PORTB_PIN1CTRL - DEFINE(PORTB_PIN1CTRL) -#else - MISSING(PORTB_PIN1CTRL) -#endif - -#ifdef PORTB_PIN2CTRL - DEFINE(PORTB_PIN2CTRL) -#else - MISSING(PORTB_PIN2CTRL) -#endif - -#ifdef PORTB_PIN3CTRL - DEFINE(PORTB_PIN3CTRL) -#else - MISSING(PORTB_PIN3CTRL) -#endif - -#ifdef PORTB_PIN4CTRL - DEFINE(PORTB_PIN4CTRL) -#else - MISSING(PORTB_PIN4CTRL) -#endif - -#ifdef PORTB_PIN5CTRL - DEFINE(PORTB_PIN5CTRL) -#else - MISSING(PORTB_PIN5CTRL) -#endif - -#ifdef PORTB_PIN6CTRL - DEFINE(PORTB_PIN6CTRL) -#else - MISSING(PORTB_PIN6CTRL) -#endif - -#ifdef PORTB_PIN7CTRL - DEFINE(PORTB_PIN7CTRL) -#else - MISSING(PORTB_PIN7CTRL) -#endif - -#ifdef PORTC - DEFINE(PORTC) -#else - MISSING(PORTC) -#endif - -#ifdef PORTCFG_CLKEVOUT - DEFINE(PORTCFG_CLKEVOUT) -#else - MISSING(PORTCFG_CLKEVOUT) -#endif - -#ifdef PORTCFG_MPCMASK - DEFINE(PORTCFG_MPCMASK) -#else - MISSING(PORTCFG_MPCMASK) -#endif - -#ifdef PORTCFG_VPCTRLA - DEFINE(PORTCFG_VPCTRLA) -#else - MISSING(PORTCFG_VPCTRLA) -#endif - -#ifdef PORTCFG_VPCTRLB - DEFINE(PORTCFG_VPCTRLB) -#else - MISSING(PORTCFG_VPCTRLB) -#endif - -#ifdef PORTCR - DEFINE(PORTCR) -#else - MISSING(PORTCR) -#endif - -#ifdef PORTC_DIR - DEFINE(PORTC_DIR) -#else - MISSING(PORTC_DIR) -#endif - -#ifdef PORTC_DIRCLR - DEFINE(PORTC_DIRCLR) -#else - MISSING(PORTC_DIRCLR) -#endif - -#ifdef PORTC_DIRSET - DEFINE(PORTC_DIRSET) -#else - MISSING(PORTC_DIRSET) -#endif - -#ifdef PORTC_DIRTGL - DEFINE(PORTC_DIRTGL) -#else - MISSING(PORTC_DIRTGL) -#endif - -#ifdef PORTC_IN - DEFINE(PORTC_IN) -#else - MISSING(PORTC_IN) -#endif - -#ifdef PORTC_INT0MASK - DEFINE(PORTC_INT0MASK) -#else - MISSING(PORTC_INT0MASK) -#endif - -#ifdef PORTC_INT1MASK - DEFINE(PORTC_INT1MASK) -#else - MISSING(PORTC_INT1MASK) -#endif - -#ifdef PORTC_INTCTRL - DEFINE(PORTC_INTCTRL) -#else - MISSING(PORTC_INTCTRL) -#endif - -#ifdef PORTC_INTFLAGS - DEFINE(PORTC_INTFLAGS) -#else - MISSING(PORTC_INTFLAGS) -#endif - -#ifdef PORTC_OUT - DEFINE(PORTC_OUT) -#else - MISSING(PORTC_OUT) -#endif - -#ifdef PORTC_OUTCLR - DEFINE(PORTC_OUTCLR) -#else - MISSING(PORTC_OUTCLR) -#endif - -#ifdef PORTC_OUTSET - DEFINE(PORTC_OUTSET) -#else - MISSING(PORTC_OUTSET) -#endif - -#ifdef PORTC_OUTTGL - DEFINE(PORTC_OUTTGL) -#else - MISSING(PORTC_OUTTGL) -#endif - -#ifdef PORTC_PIN0CTRL - DEFINE(PORTC_PIN0CTRL) -#else - MISSING(PORTC_PIN0CTRL) -#endif - -#ifdef PORTC_PIN1CTRL - DEFINE(PORTC_PIN1CTRL) -#else - MISSING(PORTC_PIN1CTRL) -#endif - -#ifdef PORTC_PIN2CTRL - DEFINE(PORTC_PIN2CTRL) -#else - MISSING(PORTC_PIN2CTRL) -#endif - -#ifdef PORTC_PIN3CTRL - DEFINE(PORTC_PIN3CTRL) -#else - MISSING(PORTC_PIN3CTRL) -#endif - -#ifdef PORTC_PIN4CTRL - DEFINE(PORTC_PIN4CTRL) -#else - MISSING(PORTC_PIN4CTRL) -#endif - -#ifdef PORTC_PIN5CTRL - DEFINE(PORTC_PIN5CTRL) -#else - MISSING(PORTC_PIN5CTRL) -#endif - -#ifdef PORTC_PIN6CTRL - DEFINE(PORTC_PIN6CTRL) -#else - MISSING(PORTC_PIN6CTRL) -#endif - -#ifdef PORTC_PIN7CTRL - DEFINE(PORTC_PIN7CTRL) -#else - MISSING(PORTC_PIN7CTRL) -#endif - -#ifdef PORTD - DEFINE(PORTD) -#else - MISSING(PORTD) -#endif - -#ifdef PORTD_DIR - DEFINE(PORTD_DIR) -#else - MISSING(PORTD_DIR) -#endif - -#ifdef PORTD_DIRCLR - DEFINE(PORTD_DIRCLR) -#else - MISSING(PORTD_DIRCLR) -#endif - -#ifdef PORTD_DIRSET - DEFINE(PORTD_DIRSET) -#else - MISSING(PORTD_DIRSET) -#endif - -#ifdef PORTD_DIRTGL - DEFINE(PORTD_DIRTGL) -#else - MISSING(PORTD_DIRTGL) -#endif - -#ifdef PORTD_IN - DEFINE(PORTD_IN) -#else - MISSING(PORTD_IN) -#endif - -#ifdef PORTD_INT0MASK - DEFINE(PORTD_INT0MASK) -#else - MISSING(PORTD_INT0MASK) -#endif - -#ifdef PORTD_INT1MASK - DEFINE(PORTD_INT1MASK) -#else - MISSING(PORTD_INT1MASK) -#endif - -#ifdef PORTD_INTCTRL - DEFINE(PORTD_INTCTRL) -#else - MISSING(PORTD_INTCTRL) -#endif - -#ifdef PORTD_INTFLAGS - DEFINE(PORTD_INTFLAGS) -#else - MISSING(PORTD_INTFLAGS) -#endif - -#ifdef PORTD_OUT - DEFINE(PORTD_OUT) -#else - MISSING(PORTD_OUT) -#endif - -#ifdef PORTD_OUTCLR - DEFINE(PORTD_OUTCLR) -#else - MISSING(PORTD_OUTCLR) -#endif - -#ifdef PORTD_OUTSET - DEFINE(PORTD_OUTSET) -#else - MISSING(PORTD_OUTSET) -#endif - -#ifdef PORTD_OUTTGL - DEFINE(PORTD_OUTTGL) -#else - MISSING(PORTD_OUTTGL) -#endif - -#ifdef PORTD_PIN0CTRL - DEFINE(PORTD_PIN0CTRL) -#else - MISSING(PORTD_PIN0CTRL) -#endif - -#ifdef PORTD_PIN1CTRL - DEFINE(PORTD_PIN1CTRL) -#else - MISSING(PORTD_PIN1CTRL) -#endif - -#ifdef PORTD_PIN2CTRL - DEFINE(PORTD_PIN2CTRL) -#else - MISSING(PORTD_PIN2CTRL) -#endif - -#ifdef PORTD_PIN3CTRL - DEFINE(PORTD_PIN3CTRL) -#else - MISSING(PORTD_PIN3CTRL) -#endif - -#ifdef PORTD_PIN4CTRL - DEFINE(PORTD_PIN4CTRL) -#else - MISSING(PORTD_PIN4CTRL) -#endif - -#ifdef PORTD_PIN5CTRL - DEFINE(PORTD_PIN5CTRL) -#else - MISSING(PORTD_PIN5CTRL) -#endif - -#ifdef PORTD_PIN6CTRL - DEFINE(PORTD_PIN6CTRL) -#else - MISSING(PORTD_PIN6CTRL) -#endif - -#ifdef PORTD_PIN7CTRL - DEFINE(PORTD_PIN7CTRL) -#else - MISSING(PORTD_PIN7CTRL) -#endif - -#ifdef PORTE - DEFINE(PORTE) -#else - MISSING(PORTE) -#endif - -#ifdef PORTE_DIR - DEFINE(PORTE_DIR) -#else - MISSING(PORTE_DIR) -#endif - -#ifdef PORTE_DIRCLR - DEFINE(PORTE_DIRCLR) -#else - MISSING(PORTE_DIRCLR) -#endif - -#ifdef PORTE_DIRSET - DEFINE(PORTE_DIRSET) -#else - MISSING(PORTE_DIRSET) -#endif - -#ifdef PORTE_DIRTGL - DEFINE(PORTE_DIRTGL) -#else - MISSING(PORTE_DIRTGL) -#endif - -#ifdef PORTE_IN - DEFINE(PORTE_IN) -#else - MISSING(PORTE_IN) -#endif - -#ifdef PORTE_INT0MASK - DEFINE(PORTE_INT0MASK) -#else - MISSING(PORTE_INT0MASK) -#endif - -#ifdef PORTE_INT1MASK - DEFINE(PORTE_INT1MASK) -#else - MISSING(PORTE_INT1MASK) -#endif - -#ifdef PORTE_INTCTRL - DEFINE(PORTE_INTCTRL) -#else - MISSING(PORTE_INTCTRL) -#endif - -#ifdef PORTE_INTFLAGS - DEFINE(PORTE_INTFLAGS) -#else - MISSING(PORTE_INTFLAGS) -#endif - -#ifdef PORTE_OUT - DEFINE(PORTE_OUT) -#else - MISSING(PORTE_OUT) -#endif - -#ifdef PORTE_OUTCLR - DEFINE(PORTE_OUTCLR) -#else - MISSING(PORTE_OUTCLR) -#endif - -#ifdef PORTE_OUTSET - DEFINE(PORTE_OUTSET) -#else - MISSING(PORTE_OUTSET) -#endif - -#ifdef PORTE_OUTTGL - DEFINE(PORTE_OUTTGL) -#else - MISSING(PORTE_OUTTGL) -#endif - -#ifdef PORTE_PIN0CTRL - DEFINE(PORTE_PIN0CTRL) -#else - MISSING(PORTE_PIN0CTRL) -#endif - -#ifdef PORTE_PIN1CTRL - DEFINE(PORTE_PIN1CTRL) -#else - MISSING(PORTE_PIN1CTRL) -#endif - -#ifdef PORTE_PIN2CTRL - DEFINE(PORTE_PIN2CTRL) -#else - MISSING(PORTE_PIN2CTRL) -#endif - -#ifdef PORTE_PIN3CTRL - DEFINE(PORTE_PIN3CTRL) -#else - MISSING(PORTE_PIN3CTRL) -#endif - -#ifdef PORTE_PIN4CTRL - DEFINE(PORTE_PIN4CTRL) -#else - MISSING(PORTE_PIN4CTRL) -#endif - -#ifdef PORTE_PIN5CTRL - DEFINE(PORTE_PIN5CTRL) -#else - MISSING(PORTE_PIN5CTRL) -#endif - -#ifdef PORTE_PIN6CTRL - DEFINE(PORTE_PIN6CTRL) -#else - MISSING(PORTE_PIN6CTRL) -#endif - -#ifdef PORTE_PIN7CTRL - DEFINE(PORTE_PIN7CTRL) -#else - MISSING(PORTE_PIN7CTRL) -#endif - -#ifdef PORTF - DEFINE(PORTF) -#else - MISSING(PORTF) -#endif - -#ifdef PORTF_DIR - DEFINE(PORTF_DIR) -#else - MISSING(PORTF_DIR) -#endif - -#ifdef PORTF_DIRCLR - DEFINE(PORTF_DIRCLR) -#else - MISSING(PORTF_DIRCLR) -#endif - -#ifdef PORTF_DIRSET - DEFINE(PORTF_DIRSET) -#else - MISSING(PORTF_DIRSET) -#endif - -#ifdef PORTF_DIRTGL - DEFINE(PORTF_DIRTGL) -#else - MISSING(PORTF_DIRTGL) -#endif - -#ifdef PORTF_IN - DEFINE(PORTF_IN) -#else - MISSING(PORTF_IN) -#endif - -#ifdef PORTF_INT0MASK - DEFINE(PORTF_INT0MASK) -#else - MISSING(PORTF_INT0MASK) -#endif - -#ifdef PORTF_INT1MASK - DEFINE(PORTF_INT1MASK) -#else - MISSING(PORTF_INT1MASK) -#endif - -#ifdef PORTF_INTCTRL - DEFINE(PORTF_INTCTRL) -#else - MISSING(PORTF_INTCTRL) -#endif - -#ifdef PORTF_INTFLAGS - DEFINE(PORTF_INTFLAGS) -#else - MISSING(PORTF_INTFLAGS) -#endif - -#ifdef PORTF_OUT - DEFINE(PORTF_OUT) -#else - MISSING(PORTF_OUT) -#endif - -#ifdef PORTF_OUTCLR - DEFINE(PORTF_OUTCLR) -#else - MISSING(PORTF_OUTCLR) -#endif - -#ifdef PORTF_OUTSET - DEFINE(PORTF_OUTSET) -#else - MISSING(PORTF_OUTSET) -#endif - -#ifdef PORTF_OUTTGL - DEFINE(PORTF_OUTTGL) -#else - MISSING(PORTF_OUTTGL) -#endif - -#ifdef PORTF_PIN0CTRL - DEFINE(PORTF_PIN0CTRL) -#else - MISSING(PORTF_PIN0CTRL) -#endif - -#ifdef PORTF_PIN1CTRL - DEFINE(PORTF_PIN1CTRL) -#else - MISSING(PORTF_PIN1CTRL) -#endif - -#ifdef PORTF_PIN2CTRL - DEFINE(PORTF_PIN2CTRL) -#else - MISSING(PORTF_PIN2CTRL) -#endif - -#ifdef PORTF_PIN3CTRL - DEFINE(PORTF_PIN3CTRL) -#else - MISSING(PORTF_PIN3CTRL) -#endif - -#ifdef PORTF_PIN4CTRL - DEFINE(PORTF_PIN4CTRL) -#else - MISSING(PORTF_PIN4CTRL) -#endif - -#ifdef PORTF_PIN5CTRL - DEFINE(PORTF_PIN5CTRL) -#else - MISSING(PORTF_PIN5CTRL) -#endif - -#ifdef PORTF_PIN6CTRL - DEFINE(PORTF_PIN6CTRL) -#else - MISSING(PORTF_PIN6CTRL) -#endif - -#ifdef PORTF_PIN7CTRL - DEFINE(PORTF_PIN7CTRL) -#else - MISSING(PORTF_PIN7CTRL) -#endif - -#ifdef PORTG - DEFINE(PORTG) -#else - MISSING(PORTG) -#endif - -#ifdef PORTH - DEFINE(PORTH) -#else - MISSING(PORTH) -#endif - -#ifdef PORTH_DIR - DEFINE(PORTH_DIR) -#else - MISSING(PORTH_DIR) -#endif - -#ifdef PORTH_DIRCLR - DEFINE(PORTH_DIRCLR) -#else - MISSING(PORTH_DIRCLR) -#endif - -#ifdef PORTH_DIRSET - DEFINE(PORTH_DIRSET) -#else - MISSING(PORTH_DIRSET) -#endif - -#ifdef PORTH_DIRTGL - DEFINE(PORTH_DIRTGL) -#else - MISSING(PORTH_DIRTGL) -#endif - -#ifdef PORTH_IN - DEFINE(PORTH_IN) -#else - MISSING(PORTH_IN) -#endif - -#ifdef PORTH_INT0MASK - DEFINE(PORTH_INT0MASK) -#else - MISSING(PORTH_INT0MASK) -#endif - -#ifdef PORTH_INT1MASK - DEFINE(PORTH_INT1MASK) -#else - MISSING(PORTH_INT1MASK) -#endif - -#ifdef PORTH_INTCTRL - DEFINE(PORTH_INTCTRL) -#else - MISSING(PORTH_INTCTRL) -#endif - -#ifdef PORTH_INTFLAGS - DEFINE(PORTH_INTFLAGS) -#else - MISSING(PORTH_INTFLAGS) -#endif - -#ifdef PORTH_OUT - DEFINE(PORTH_OUT) -#else - MISSING(PORTH_OUT) -#endif - -#ifdef PORTH_OUTCLR - DEFINE(PORTH_OUTCLR) -#else - MISSING(PORTH_OUTCLR) -#endif - -#ifdef PORTH_OUTSET - DEFINE(PORTH_OUTSET) -#else - MISSING(PORTH_OUTSET) -#endif - -#ifdef PORTH_OUTTGL - DEFINE(PORTH_OUTTGL) -#else - MISSING(PORTH_OUTTGL) -#endif - -#ifdef PORTH_PIN0CTRL - DEFINE(PORTH_PIN0CTRL) -#else - MISSING(PORTH_PIN0CTRL) -#endif - -#ifdef PORTH_PIN1CTRL - DEFINE(PORTH_PIN1CTRL) -#else - MISSING(PORTH_PIN1CTRL) -#endif - -#ifdef PORTH_PIN2CTRL - DEFINE(PORTH_PIN2CTRL) -#else - MISSING(PORTH_PIN2CTRL) -#endif - -#ifdef PORTH_PIN3CTRL - DEFINE(PORTH_PIN3CTRL) -#else - MISSING(PORTH_PIN3CTRL) -#endif - -#ifdef PORTH_PIN4CTRL - DEFINE(PORTH_PIN4CTRL) -#else - MISSING(PORTH_PIN4CTRL) -#endif - -#ifdef PORTH_PIN5CTRL - DEFINE(PORTH_PIN5CTRL) -#else - MISSING(PORTH_PIN5CTRL) -#endif - -#ifdef PORTH_PIN6CTRL - DEFINE(PORTH_PIN6CTRL) -#else - MISSING(PORTH_PIN6CTRL) -#endif - -#ifdef PORTH_PIN7CTRL - DEFINE(PORTH_PIN7CTRL) -#else - MISSING(PORTH_PIN7CTRL) -#endif - -#ifdef PORTJ - DEFINE(PORTJ) -#else - MISSING(PORTJ) -#endif - -#ifdef PORTJ_DIR - DEFINE(PORTJ_DIR) -#else - MISSING(PORTJ_DIR) -#endif - -#ifdef PORTJ_DIRCLR - DEFINE(PORTJ_DIRCLR) -#else - MISSING(PORTJ_DIRCLR) -#endif - -#ifdef PORTJ_DIRSET - DEFINE(PORTJ_DIRSET) -#else - MISSING(PORTJ_DIRSET) -#endif - -#ifdef PORTJ_DIRTGL - DEFINE(PORTJ_DIRTGL) -#else - MISSING(PORTJ_DIRTGL) -#endif - -#ifdef PORTJ_IN - DEFINE(PORTJ_IN) -#else - MISSING(PORTJ_IN) -#endif - -#ifdef PORTJ_INT0MASK - DEFINE(PORTJ_INT0MASK) -#else - MISSING(PORTJ_INT0MASK) -#endif - -#ifdef PORTJ_INT1MASK - DEFINE(PORTJ_INT1MASK) -#else - MISSING(PORTJ_INT1MASK) -#endif - -#ifdef PORTJ_INTCTRL - DEFINE(PORTJ_INTCTRL) -#else - MISSING(PORTJ_INTCTRL) -#endif - -#ifdef PORTJ_INTFLAGS - DEFINE(PORTJ_INTFLAGS) -#else - MISSING(PORTJ_INTFLAGS) -#endif - -#ifdef PORTJ_OUT - DEFINE(PORTJ_OUT) -#else - MISSING(PORTJ_OUT) -#endif - -#ifdef PORTJ_OUTCLR - DEFINE(PORTJ_OUTCLR) -#else - MISSING(PORTJ_OUTCLR) -#endif - -#ifdef PORTJ_OUTSET - DEFINE(PORTJ_OUTSET) -#else - MISSING(PORTJ_OUTSET) -#endif - -#ifdef PORTJ_OUTTGL - DEFINE(PORTJ_OUTTGL) -#else - MISSING(PORTJ_OUTTGL) -#endif - -#ifdef PORTJ_PIN0CTRL - DEFINE(PORTJ_PIN0CTRL) -#else - MISSING(PORTJ_PIN0CTRL) -#endif - -#ifdef PORTJ_PIN1CTRL - DEFINE(PORTJ_PIN1CTRL) -#else - MISSING(PORTJ_PIN1CTRL) -#endif - -#ifdef PORTJ_PIN2CTRL - DEFINE(PORTJ_PIN2CTRL) -#else - MISSING(PORTJ_PIN2CTRL) -#endif - -#ifdef PORTJ_PIN3CTRL - DEFINE(PORTJ_PIN3CTRL) -#else - MISSING(PORTJ_PIN3CTRL) -#endif - -#ifdef PORTJ_PIN4CTRL - DEFINE(PORTJ_PIN4CTRL) -#else - MISSING(PORTJ_PIN4CTRL) -#endif - -#ifdef PORTJ_PIN5CTRL - DEFINE(PORTJ_PIN5CTRL) -#else - MISSING(PORTJ_PIN5CTRL) -#endif - -#ifdef PORTJ_PIN6CTRL - DEFINE(PORTJ_PIN6CTRL) -#else - MISSING(PORTJ_PIN6CTRL) -#endif - -#ifdef PORTJ_PIN7CTRL - DEFINE(PORTJ_PIN7CTRL) -#else - MISSING(PORTJ_PIN7CTRL) -#endif - -#ifdef PORTK - DEFINE(PORTK) -#else - MISSING(PORTK) -#endif - -#ifdef PORTK_DIR - DEFINE(PORTK_DIR) -#else - MISSING(PORTK_DIR) -#endif - -#ifdef PORTK_DIRCLR - DEFINE(PORTK_DIRCLR) -#else - MISSING(PORTK_DIRCLR) -#endif - -#ifdef PORTK_DIRSET - DEFINE(PORTK_DIRSET) -#else - MISSING(PORTK_DIRSET) -#endif - -#ifdef PORTK_DIRTGL - DEFINE(PORTK_DIRTGL) -#else - MISSING(PORTK_DIRTGL) -#endif - -#ifdef PORTK_IN - DEFINE(PORTK_IN) -#else - MISSING(PORTK_IN) -#endif - -#ifdef PORTK_INT0MASK - DEFINE(PORTK_INT0MASK) -#else - MISSING(PORTK_INT0MASK) -#endif - -#ifdef PORTK_INT1MASK - DEFINE(PORTK_INT1MASK) -#else - MISSING(PORTK_INT1MASK) -#endif - -#ifdef PORTK_INTCTRL - DEFINE(PORTK_INTCTRL) -#else - MISSING(PORTK_INTCTRL) -#endif - -#ifdef PORTK_INTFLAGS - DEFINE(PORTK_INTFLAGS) -#else - MISSING(PORTK_INTFLAGS) -#endif - -#ifdef PORTK_OUT - DEFINE(PORTK_OUT) -#else - MISSING(PORTK_OUT) -#endif - -#ifdef PORTK_OUTCLR - DEFINE(PORTK_OUTCLR) -#else - MISSING(PORTK_OUTCLR) -#endif - -#ifdef PORTK_OUTSET - DEFINE(PORTK_OUTSET) -#else - MISSING(PORTK_OUTSET) -#endif - -#ifdef PORTK_OUTTGL - DEFINE(PORTK_OUTTGL) -#else - MISSING(PORTK_OUTTGL) -#endif - -#ifdef PORTK_PIN0CTRL - DEFINE(PORTK_PIN0CTRL) -#else - MISSING(PORTK_PIN0CTRL) -#endif - -#ifdef PORTK_PIN1CTRL - DEFINE(PORTK_PIN1CTRL) -#else - MISSING(PORTK_PIN1CTRL) -#endif - -#ifdef PORTK_PIN2CTRL - DEFINE(PORTK_PIN2CTRL) -#else - MISSING(PORTK_PIN2CTRL) -#endif - -#ifdef PORTK_PIN3CTRL - DEFINE(PORTK_PIN3CTRL) -#else - MISSING(PORTK_PIN3CTRL) -#endif - -#ifdef PORTK_PIN4CTRL - DEFINE(PORTK_PIN4CTRL) -#else - MISSING(PORTK_PIN4CTRL) -#endif - -#ifdef PORTK_PIN5CTRL - DEFINE(PORTK_PIN5CTRL) -#else - MISSING(PORTK_PIN5CTRL) -#endif - -#ifdef PORTK_PIN6CTRL - DEFINE(PORTK_PIN6CTRL) -#else - MISSING(PORTK_PIN6CTRL) -#endif - -#ifdef PORTK_PIN7CTRL - DEFINE(PORTK_PIN7CTRL) -#else - MISSING(PORTK_PIN7CTRL) -#endif - -#ifdef PORTL - DEFINE(PORTL) -#else - MISSING(PORTL) -#endif - -#ifdef PORTQ_DIR - DEFINE(PORTQ_DIR) -#else - MISSING(PORTQ_DIR) -#endif - -#ifdef PORTQ_DIRCLR - DEFINE(PORTQ_DIRCLR) -#else - MISSING(PORTQ_DIRCLR) -#endif - -#ifdef PORTQ_DIRSET - DEFINE(PORTQ_DIRSET) -#else - MISSING(PORTQ_DIRSET) -#endif - -#ifdef PORTQ_DIRTGL - DEFINE(PORTQ_DIRTGL) -#else - MISSING(PORTQ_DIRTGL) -#endif - -#ifdef PORTQ_IN - DEFINE(PORTQ_IN) -#else - MISSING(PORTQ_IN) -#endif - -#ifdef PORTQ_INT0MASK - DEFINE(PORTQ_INT0MASK) -#else - MISSING(PORTQ_INT0MASK) -#endif - -#ifdef PORTQ_INT1MASK - DEFINE(PORTQ_INT1MASK) -#else - MISSING(PORTQ_INT1MASK) -#endif - -#ifdef PORTQ_INTCTRL - DEFINE(PORTQ_INTCTRL) -#else - MISSING(PORTQ_INTCTRL) -#endif - -#ifdef PORTQ_INTFLAGS - DEFINE(PORTQ_INTFLAGS) -#else - MISSING(PORTQ_INTFLAGS) -#endif - -#ifdef PORTQ_OUT - DEFINE(PORTQ_OUT) -#else - MISSING(PORTQ_OUT) -#endif - -#ifdef PORTQ_OUTCLR - DEFINE(PORTQ_OUTCLR) -#else - MISSING(PORTQ_OUTCLR) -#endif - -#ifdef PORTQ_OUTSET - DEFINE(PORTQ_OUTSET) -#else - MISSING(PORTQ_OUTSET) -#endif - -#ifdef PORTQ_OUTTGL - DEFINE(PORTQ_OUTTGL) -#else - MISSING(PORTQ_OUTTGL) -#endif - -#ifdef PORTQ_PIN0CTRL - DEFINE(PORTQ_PIN0CTRL) -#else - MISSING(PORTQ_PIN0CTRL) -#endif - -#ifdef PORTQ_PIN1CTRL - DEFINE(PORTQ_PIN1CTRL) -#else - MISSING(PORTQ_PIN1CTRL) -#endif - -#ifdef PORTQ_PIN2CTRL - DEFINE(PORTQ_PIN2CTRL) -#else - MISSING(PORTQ_PIN2CTRL) -#endif - -#ifdef PORTQ_PIN3CTRL - DEFINE(PORTQ_PIN3CTRL) -#else - MISSING(PORTQ_PIN3CTRL) -#endif - -#ifdef PORTQ_PIN4CTRL - DEFINE(PORTQ_PIN4CTRL) -#else - MISSING(PORTQ_PIN4CTRL) -#endif - -#ifdef PORTQ_PIN5CTRL - DEFINE(PORTQ_PIN5CTRL) -#else - MISSING(PORTQ_PIN5CTRL) -#endif - -#ifdef PORTQ_PIN6CTRL - DEFINE(PORTQ_PIN6CTRL) -#else - MISSING(PORTQ_PIN6CTRL) -#endif - -#ifdef PORTQ_PIN7CTRL - DEFINE(PORTQ_PIN7CTRL) -#else - MISSING(PORTQ_PIN7CTRL) -#endif - -#ifdef PORTR_DIR - DEFINE(PORTR_DIR) -#else - MISSING(PORTR_DIR) -#endif - -#ifdef PORTR_DIRCLR - DEFINE(PORTR_DIRCLR) -#else - MISSING(PORTR_DIRCLR) -#endif - -#ifdef PORTR_DIRSET - DEFINE(PORTR_DIRSET) -#else - MISSING(PORTR_DIRSET) -#endif - -#ifdef PORTR_DIRTGL - DEFINE(PORTR_DIRTGL) -#else - MISSING(PORTR_DIRTGL) -#endif - -#ifdef PORTR_IN - DEFINE(PORTR_IN) -#else - MISSING(PORTR_IN) -#endif - -#ifdef PORTR_INT0MASK - DEFINE(PORTR_INT0MASK) -#else - MISSING(PORTR_INT0MASK) -#endif - -#ifdef PORTR_INT1MASK - DEFINE(PORTR_INT1MASK) -#else - MISSING(PORTR_INT1MASK) -#endif - -#ifdef PORTR_INTCTRL - DEFINE(PORTR_INTCTRL) -#else - MISSING(PORTR_INTCTRL) -#endif - -#ifdef PORTR_INTFLAGS - DEFINE(PORTR_INTFLAGS) -#else - MISSING(PORTR_INTFLAGS) -#endif - -#ifdef PORTR_OUT - DEFINE(PORTR_OUT) -#else - MISSING(PORTR_OUT) -#endif - -#ifdef PORTR_OUTCLR - DEFINE(PORTR_OUTCLR) -#else - MISSING(PORTR_OUTCLR) -#endif - -#ifdef PORTR_OUTSET - DEFINE(PORTR_OUTSET) -#else - MISSING(PORTR_OUTSET) -#endif - -#ifdef PORTR_OUTTGL - DEFINE(PORTR_OUTTGL) -#else - MISSING(PORTR_OUTTGL) -#endif - -#ifdef PORTR_PIN0CTRL - DEFINE(PORTR_PIN0CTRL) -#else - MISSING(PORTR_PIN0CTRL) -#endif - -#ifdef PORTR_PIN1CTRL - DEFINE(PORTR_PIN1CTRL) -#else - MISSING(PORTR_PIN1CTRL) -#endif - -#ifdef PORTR_PIN2CTRL - DEFINE(PORTR_PIN2CTRL) -#else - MISSING(PORTR_PIN2CTRL) -#endif - -#ifdef PORTR_PIN3CTRL - DEFINE(PORTR_PIN3CTRL) -#else - MISSING(PORTR_PIN3CTRL) -#endif - -#ifdef PORTR_PIN4CTRL - DEFINE(PORTR_PIN4CTRL) -#else - MISSING(PORTR_PIN4CTRL) -#endif - -#ifdef PORTR_PIN5CTRL - DEFINE(PORTR_PIN5CTRL) -#else - MISSING(PORTR_PIN5CTRL) -#endif - -#ifdef PORTR_PIN6CTRL - DEFINE(PORTR_PIN6CTRL) -#else - MISSING(PORTR_PIN6CTRL) -#endif - -#ifdef PORTR_PIN7CTRL - DEFINE(PORTR_PIN7CTRL) -#else - MISSING(PORTR_PIN7CTRL) -#endif - -#ifdef PRELD - DEFINE(PRELD) -#else - MISSING(PRELD) -#endif - -#ifdef PRR - DEFINE(PRR) -#else - MISSING(PRR) -#endif - -#ifdef PRR0 - DEFINE(PRR0) -#else - MISSING(PRR0) -#endif - -#ifdef PRR1 - DEFINE(PRR1) -#else - MISSING(PRR1) -#endif - -#ifdef PRR2 - DEFINE(PRR2) -#else - MISSING(PRR2) -#endif - -#ifdef PR_PRGEN - DEFINE(PR_PRGEN) -#else - MISSING(PR_PRGEN) -#endif - -#ifdef PR_PRPA - DEFINE(PR_PRPA) -#else - MISSING(PR_PRPA) -#endif - -#ifdef PR_PRPB - DEFINE(PR_PRPB) -#else - MISSING(PR_PRPB) -#endif - -#ifdef PR_PRPC - DEFINE(PR_PRPC) -#else - MISSING(PR_PRPC) -#endif - -#ifdef PR_PRPD - DEFINE(PR_PRPD) -#else - MISSING(PR_PRPD) -#endif - -#ifdef PR_PRPE - DEFINE(PR_PRPE) -#else - MISSING(PR_PRPE) -#endif - -#ifdef PR_PRPF - DEFINE(PR_PRPF) -#else - MISSING(PR_PRPF) -#endif - -#ifdef PS2CON - DEFINE(PS2CON) -#else - MISSING(PS2CON) -#endif - -#ifdef PSOC0 - DEFINE(PSOC0) -#else - MISSING(PSOC0) -#endif - -#ifdef PSOC1 - DEFINE(PSOC1) -#else - MISSING(PSOC1) -#endif - -#ifdef PSOC2 - DEFINE(PSOC2) -#else - MISSING(PSOC2) -#endif - -#ifdef PSYNC - DEFINE(PSYNC) -#else - MISSING(PSYNC) -#endif - -#ifdef PUEA - DEFINE(PUEA) -#else - MISSING(PUEA) -#endif - -#ifdef PUEB - DEFINE(PUEB) -#else - MISSING(PUEB) -#endif - -#ifdef PUEC - DEFINE(PUEC) -#else - MISSING(PUEC) -#endif - -#ifdef PWMCTL - DEFINE(PWMCTL) -#else - MISSING(PWMCTL) -#endif - -#ifdef PWMMSK - DEFINE(PWMMSK) -#else - MISSING(PWMMSK) -#endif - -#ifdef PWMPER - DEFINE(PWMPER) -#else - MISSING(PWMPER) -#endif - -#ifdef PWMSFRQ - DEFINE(PWMSFRQ) -#else - MISSING(PWMSFRQ) -#endif - -#ifdef PWR_ATTEN - DEFINE(PWR_ATTEN) -#else - MISSING(PWR_ATTEN) -#endif - -#ifdef QTCSR - DEFINE(QTCSR) -#else - MISSING(QTCSR) -#endif - -#ifdef RAMAR - DEFINE(RAMAR) -#else - MISSING(RAMAR) -#endif - -#ifdef RAMDR - DEFINE(RAMDR) -#else - MISSING(RAMDR) -#endif - -#ifdef RAMPD - DEFINE(RAMPD) -#else - MISSING(RAMPD) -#endif - -#ifdef RAMPX - DEFINE(RAMPX) -#else - MISSING(RAMPX) -#endif - -#ifdef RAMPY - DEFINE(RAMPY) -#else - MISSING(RAMPY) -#endif - -#ifdef RAMPZ - DEFINE(RAMPZ) -#else - MISSING(RAMPZ) -#endif - -#ifdef RCCTRL - DEFINE(RCCTRL) -#else - MISSING(RCCTRL) -#endif - -#ifdef RDWDR - DEFINE(RDWDR) -#else - MISSING(RDWDR) -#endif - -#ifdef REGCR - DEFINE(REGCR) -#else - MISSING(REGCR) -#endif - -#ifdef RNGCR - DEFINE(RNGCR) -#else - MISSING(RNGCR) -#endif - -#ifdef ROCR - DEFINE(ROCR) -#else - MISSING(ROCR) -#endif - -#ifdef RSTFLR - DEFINE(RSTFLR) -#else - MISSING(RSTFLR) -#endif - -#ifdef RST_CTRL - DEFINE(RST_CTRL) -#else - MISSING(RST_CTRL) -#endif - -#ifdef RST_STATUS - DEFINE(RST_STATUS) -#else - MISSING(RST_STATUS) -#endif - -#ifdef RTC32_CTRL - DEFINE(RTC32_CTRL) -#else - MISSING(RTC32_CTRL) -#endif - -#ifdef RTC32_INTCTRL - DEFINE(RTC32_INTCTRL) -#else - MISSING(RTC32_INTCTRL) -#endif - -#ifdef RTC32_INTFLAGS - DEFINE(RTC32_INTFLAGS) -#else - MISSING(RTC32_INTFLAGS) -#endif - -#ifdef RTC32_SYNCCTRL - DEFINE(RTC32_SYNCCTRL) -#else - MISSING(RTC32_SYNCCTRL) -#endif - -#ifdef RTC_CNT - DEFINE(RTC_CNT) -#else - MISSING(RTC_CNT) -#endif - -#ifdef RTC_COMP - DEFINE(RTC_COMP) -#else - MISSING(RTC_COMP) -#endif - -#ifdef RTC_CTRL - DEFINE(RTC_CTRL) -#else - MISSING(RTC_CTRL) -#endif - -#ifdef RTC_INTCTRL - DEFINE(RTC_INTCTRL) -#else - MISSING(RTC_INTCTRL) -#endif - -#ifdef RTC_INTFLAGS - DEFINE(RTC_INTFLAGS) -#else - MISSING(RTC_INTFLAGS) -#endif - -#ifdef RTC_PER - DEFINE(RTC_PER) -#else - MISSING(RTC_PER) -#endif - -#ifdef RTC_STATUS - DEFINE(RTC_STATUS) -#else - MISSING(RTC_STATUS) -#endif - -#ifdef RTC_TEMP - DEFINE(RTC_TEMP) -#else - MISSING(RTC_TEMP) -#endif - -#ifdef RXB - DEFINE(RXB) -#else - MISSING(RXB) -#endif - -#ifdef RX_CTRL - DEFINE(RX_CTRL) -#else - MISSING(RX_CTRL) -#endif - -#ifdef RX_SYN - DEFINE(RX_SYN) -#else - MISSING(RX_SYN) -#endif - -#ifdef SCBTSRHH - DEFINE(SCBTSRHH) -#else - MISSING(SCBTSRHH) -#endif - -#ifdef SCBTSRHL - DEFINE(SCBTSRHL) -#else - MISSING(SCBTSRHL) -#endif - -#ifdef SCBTSRLH - DEFINE(SCBTSRLH) -#else - MISSING(SCBTSRLH) -#endif - -#ifdef SCBTSRLL - DEFINE(SCBTSRLL) -#else - MISSING(SCBTSRLL) -#endif - -#ifdef SCCNTHH - DEFINE(SCCNTHH) -#else - MISSING(SCCNTHH) -#endif - -#ifdef SCCNTHL - DEFINE(SCCNTHL) -#else - MISSING(SCCNTHL) -#endif - -#ifdef SCCNTLH - DEFINE(SCCNTLH) -#else - MISSING(SCCNTLH) -#endif - -#ifdef SCCNTLL - DEFINE(SCCNTLL) -#else - MISSING(SCCNTLL) -#endif - -#ifdef SCCON - DEFINE(SCCON) -#else - MISSING(SCCON) -#endif - -#ifdef SCCR - DEFINE(SCCR) -#else - MISSING(SCCR) -#endif - -#ifdef SCCR0 - DEFINE(SCCR0) -#else - MISSING(SCCR0) -#endif - -#ifdef SCCR1 - DEFINE(SCCR1) -#else - MISSING(SCCR1) -#endif - -#ifdef SCETU - DEFINE(SCETU) -#else - MISSING(SCETU) -#endif - -#ifdef SCETUH - DEFINE(SCETUH) -#else - MISSING(SCETUH) -#endif - -#ifdef SCETUL - DEFINE(SCETUL) -#else - MISSING(SCETUL) -#endif - -#ifdef SCGT - DEFINE(SCGT) -#else - MISSING(SCGT) -#endif - -#ifdef SCGTH - DEFINE(SCGTH) -#else - MISSING(SCGTH) -#endif - -#ifdef SCGTL - DEFINE(SCGTL) -#else - MISSING(SCGTL) -#endif - -#ifdef SCIBUF - DEFINE(SCIBUF) -#else - MISSING(SCIBUF) -#endif - -#ifdef SCICLK - DEFINE(SCICLK) -#else - MISSING(SCICLK) -#endif - -#ifdef SCICR - DEFINE(SCICR) -#else - MISSING(SCICR) -#endif - -#ifdef SCIER - DEFINE(SCIER) -#else - MISSING(SCIER) -#endif - -#ifdef SCIIR - DEFINE(SCIIR) -#else - MISSING(SCIIR) -#endif - -#ifdef SCIO - DEFINE(SCIO) -#else - MISSING(SCIO) -#endif - -#ifdef SCIRQM - DEFINE(SCIRQM) -#else - MISSING(SCIRQM) -#endif - -#ifdef SCIRQS - DEFINE(SCIRQS) -#else - MISSING(SCIRQS) -#endif - -#ifdef SCISR - DEFINE(SCISR) -#else - MISSING(SCISR) -#endif - -#ifdef SCOCR1HH - DEFINE(SCOCR1HH) -#else - MISSING(SCOCR1HH) -#endif - -#ifdef SCOCR1HL - DEFINE(SCOCR1HL) -#else - MISSING(SCOCR1HL) -#endif - -#ifdef SCOCR1LH - DEFINE(SCOCR1LH) -#else - MISSING(SCOCR1LH) -#endif - -#ifdef SCOCR1LL - DEFINE(SCOCR1LL) -#else - MISSING(SCOCR1LL) -#endif - -#ifdef SCOCR2HH - DEFINE(SCOCR2HH) -#else - MISSING(SCOCR2HH) -#endif - -#ifdef SCOCR2HL - DEFINE(SCOCR2HL) -#else - MISSING(SCOCR2HL) -#endif - -#ifdef SCOCR2LH - DEFINE(SCOCR2LH) -#else - MISSING(SCOCR2LH) -#endif - -#ifdef SCOCR2LL - DEFINE(SCOCR2LL) -#else - MISSING(SCOCR2LL) -#endif - -#ifdef SCOCR3HH - DEFINE(SCOCR3HH) -#else - MISSING(SCOCR3HH) -#endif - -#ifdef SCOCR3HL - DEFINE(SCOCR3HL) -#else - MISSING(SCOCR3HL) -#endif - -#ifdef SCOCR3LH - DEFINE(SCOCR3LH) -#else - MISSING(SCOCR3LH) -#endif - -#ifdef SCOCR3LL - DEFINE(SCOCR3LL) -#else - MISSING(SCOCR3LL) -#endif - -#ifdef SCR - DEFINE(SCR) -#else - MISSING(SCR) -#endif - -#ifdef SCSR - DEFINE(SCSR) -#else - MISSING(SCSR) -#endif - -#ifdef SCSW - DEFINE(SCSW) -#else - MISSING(SCSW) -#endif - -#ifdef SCTSRHH - DEFINE(SCTSRHH) -#else - MISSING(SCTSRHH) -#endif - -#ifdef SCTSRHL - DEFINE(SCTSRHL) -#else - MISSING(SCTSRHL) -#endif - -#ifdef SCTSRLH - DEFINE(SCTSRLH) -#else - MISSING(SCTSRLH) -#endif - -#ifdef SCTSRLL - DEFINE(SCTSRLL) -#else - MISSING(SCTSRLL) -#endif - -#ifdef SCWT0 - DEFINE(SCWT0) -#else - MISSING(SCWT0) -#endif - -#ifdef SCWT1 - DEFINE(SCWT1) -#else - MISSING(SCWT1) -#endif - -#ifdef SCWT2 - DEFINE(SCWT2) -#else - MISSING(SCWT2) -#endif - -#ifdef SCWT3 - DEFINE(SCWT3) -#else - MISSING(SCWT3) -#endif - -#ifdef SFD_VALUE - DEFINE(SFD_VALUE) -#else - MISSING(SFD_VALUE) -#endif - -#ifdef SFIOR - DEFINE(SFIOR) -#else - MISSING(SFIOR) -#endif - -#ifdef SFTCR - DEFINE(SFTCR) -#else - MISSING(SFTCR) -#endif - -#ifdef SHORT_ADDR_0 - DEFINE(SHORT_ADDR_0) -#else - MISSING(SHORT_ADDR_0) -#endif - -#ifdef SHORT_ADDR_1 - DEFINE(SHORT_ADDR_1) -#else - MISSING(SHORT_ADDR_1) -#endif - -#ifdef SIMSK - DEFINE(SIMSK) -#else - MISSING(SIMSK) -#endif - -#ifdef SINDAC - DEFINE(SINDAC) -#else - MISSING(SINDAC) -#endif - -#ifdef SINDACH - DEFINE(SINDACH) -#else - MISSING(SINDACH) -#endif - -#ifdef SINDACL - DEFINE(SINDACL) -#else - MISSING(SINDACL) -#endif - -#ifdef SLEEP_CTRL - DEFINE(SLEEP_CTRL) -#else - MISSING(SLEEP_CTRL) -#endif - -#ifdef SMCR - DEFINE(SMCR) -#else - MISSING(SMCR) -#endif - -#ifdef SMONCR - DEFINE(SMONCR) -#else - MISSING(SMONCR) -#endif - -#ifdef SOSCCALA - DEFINE(SOSCCALA) -#else - MISSING(SOSCCALA) -#endif - -#ifdef SOSCCALB - DEFINE(SOSCCALB) -#else - MISSING(SOSCCALB) -#endif - -#ifdef SP - DEFINE(SP) -#else - MISSING(SP) -#endif - -#ifdef SPCR - DEFINE(SPCR) -#else - MISSING(SPCR) -#endif - -#ifdef SPCR0 - DEFINE(SPCR0) -#else - MISSING(SPCR0) -#endif - -#ifdef SPDR - DEFINE(SPDR) -#else - MISSING(SPDR) -#endif - -#ifdef SPH - DEFINE(SPH) -#else - MISSING(SPH) -#endif - -#ifdef SPIC_CTRL - DEFINE(SPIC_CTRL) -#else - MISSING(SPIC_CTRL) -#endif - -#ifdef SPIC_DATA - DEFINE(SPIC_DATA) -#else - MISSING(SPIC_DATA) -#endif - -#ifdef SPIC_INTCTRL - DEFINE(SPIC_INTCTRL) -#else - MISSING(SPIC_INTCTRL) -#endif - -#ifdef SPIC_STATUS - DEFINE(SPIC_STATUS) -#else - MISSING(SPIC_STATUS) -#endif - -#ifdef SPID_CTRL - DEFINE(SPID_CTRL) -#else - MISSING(SPID_CTRL) -#endif - -#ifdef SPID_DATA - DEFINE(SPID_DATA) -#else - MISSING(SPID_DATA) -#endif - -#ifdef SPID_INTCTRL - DEFINE(SPID_INTCTRL) -#else - MISSING(SPID_INTCTRL) -#endif - -#ifdef SPID_STATUS - DEFINE(SPID_STATUS) -#else - MISSING(SPID_STATUS) -#endif - -#ifdef SPIE_CTRL - DEFINE(SPIE_CTRL) -#else - MISSING(SPIE_CTRL) -#endif - -#ifdef SPIE_DATA - DEFINE(SPIE_DATA) -#else - MISSING(SPIE_DATA) -#endif - -#ifdef SPIE_INTCTRL - DEFINE(SPIE_INTCTRL) -#else - MISSING(SPIE_INTCTRL) -#endif - -#ifdef SPIE_STATUS - DEFINE(SPIE_STATUS) -#else - MISSING(SPIE_STATUS) -#endif - -#ifdef SPIF_CTRL - DEFINE(SPIF_CTRL) -#else - MISSING(SPIF_CTRL) -#endif - -#ifdef SPIF_DATA - DEFINE(SPIF_DATA) -#else - MISSING(SPIF_DATA) -#endif - -#ifdef SPIF_INTCTRL - DEFINE(SPIF_INTCTRL) -#else - MISSING(SPIF_INTCTRL) -#endif - -#ifdef SPIF_STATUS - DEFINE(SPIF_STATUS) -#else - MISSING(SPIF_STATUS) -#endif - -#ifdef SPL - DEFINE(SPL) -#else - MISSING(SPL) -#endif - -#ifdef SPMCR - DEFINE(SPMCR) -#else - MISSING(SPMCR) -#endif - -#ifdef SPMCSR - DEFINE(SPMCSR) -#else - MISSING(SPMCSR) -#endif - -#ifdef SPSR - DEFINE(SPSR) -#else - MISSING(SPSR) -#endif - -#ifdef SPSR0 - DEFINE(SPSR0) -#else - MISSING(SPSR0) -#endif - -#ifdef SPWMCTL - DEFINE(SPWMCTL) -#else - MISSING(SPWMCTL) -#endif - -#ifdef SRCCAL - DEFINE(SRCCAL) -#else - MISSING(SRCCAL) -#endif - -#ifdef SREG - DEFINE(SREG) -#else - MISSING(SREG) -#endif - -#ifdef SSFR - DEFINE(SSFR) -#else - MISSING(SSFR) -#endif - -#ifdef STAT - DEFINE(STAT) -#else - MISSING(STAT) -#endif - -#ifdef SVCR - DEFINE(SVCR) -#else - MISSING(SVCR) -#endif - -#ifdef T0CR - DEFINE(T0CR) -#else - MISSING(T0CR) -#endif - -#ifdef T10IFR - DEFINE(T10IFR) -#else - MISSING(T10IFR) -#endif - -#ifdef T1CR - DEFINE(T1CR) -#else - MISSING(T1CR) -#endif - -#ifdef T2COR - DEFINE(T2COR) -#else - MISSING(T2COR) -#endif - -#ifdef T2CORH - DEFINE(T2CORH) -#else - MISSING(T2CORH) -#endif - -#ifdef T2CORL - DEFINE(T2CORL) -#else - MISSING(T2CORL) -#endif - -#ifdef T2CRA - DEFINE(T2CRA) -#else - MISSING(T2CRA) -#endif - -#ifdef T2CRB - DEFINE(T2CRB) -#else - MISSING(T2CRB) -#endif - -#ifdef T2ICR - DEFINE(T2ICR) -#else - MISSING(T2ICR) -#endif - -#ifdef T2ICRH - DEFINE(T2ICRH) -#else - MISSING(T2ICRH) -#endif - -#ifdef T2ICRL - DEFINE(T2ICRL) -#else - MISSING(T2ICRL) -#endif - -#ifdef T2IFR - DEFINE(T2IFR) -#else - MISSING(T2IFR) -#endif - -#ifdef T2IMR - DEFINE(T2IMR) -#else - MISSING(T2IMR) -#endif - -#ifdef T2MDR - DEFINE(T2MDR) -#else - MISSING(T2MDR) -#endif - -#ifdef T2MRA - DEFINE(T2MRA) -#else - MISSING(T2MRA) -#endif - -#ifdef T2MRB - DEFINE(T2MRB) -#else - MISSING(T2MRB) -#endif - -#ifdef T3CORA - DEFINE(T3CORA) -#else - MISSING(T3CORA) -#endif - -#ifdef T3CORAH - DEFINE(T3CORAH) -#else - MISSING(T3CORAH) -#endif - -#ifdef T3CORAL - DEFINE(T3CORAL) -#else - MISSING(T3CORAL) -#endif - -#ifdef T3CORB - DEFINE(T3CORB) -#else - MISSING(T3CORB) -#endif - -#ifdef T3CORBH - DEFINE(T3CORBH) -#else - MISSING(T3CORBH) -#endif - -#ifdef T3CORBL - DEFINE(T3CORBL) -#else - MISSING(T3CORBL) -#endif - -#ifdef T3CRA - DEFINE(T3CRA) -#else - MISSING(T3CRA) -#endif - -#ifdef T3CRB - DEFINE(T3CRB) -#else - MISSING(T3CRB) -#endif - -#ifdef T3ICR - DEFINE(T3ICR) -#else - MISSING(T3ICR) -#endif - -#ifdef T3ICRH - DEFINE(T3ICRH) -#else - MISSING(T3ICRH) -#endif - -#ifdef T3ICRL - DEFINE(T3ICRL) -#else - MISSING(T3ICRL) -#endif - -#ifdef T3IFR - DEFINE(T3IFR) -#else - MISSING(T3IFR) -#endif - -#ifdef T3IMR - DEFINE(T3IMR) -#else - MISSING(T3IMR) -#endif - -#ifdef T3MRA - DEFINE(T3MRA) -#else - MISSING(T3MRA) -#endif - -#ifdef T3MRB - DEFINE(T3MRB) -#else - MISSING(T3MRB) -#endif - -#ifdef TC1H - DEFINE(TC1H) -#else - MISSING(TC1H) -#endif - -#ifdef TC4H - DEFINE(TC4H) -#else - MISSING(TC4H) -#endif - -#ifdef TCC0_CCA - DEFINE(TCC0_CCA) -#else - MISSING(TCC0_CCA) -#endif - -#ifdef TCC0_CCABUF - DEFINE(TCC0_CCABUF) -#else - MISSING(TCC0_CCABUF) -#endif - -#ifdef TCC0_CCB - DEFINE(TCC0_CCB) -#else - MISSING(TCC0_CCB) -#endif - -#ifdef TCC0_CCBBUF - DEFINE(TCC0_CCBBUF) -#else - MISSING(TCC0_CCBBUF) -#endif - -#ifdef TCC0_CCC - DEFINE(TCC0_CCC) -#else - MISSING(TCC0_CCC) -#endif - -#ifdef TCC0_CCCBUF - DEFINE(TCC0_CCCBUF) -#else - MISSING(TCC0_CCCBUF) -#endif - -#ifdef TCC0_CCD - DEFINE(TCC0_CCD) -#else - MISSING(TCC0_CCD) -#endif - -#ifdef TCC0_CCDBUF - DEFINE(TCC0_CCDBUF) -#else - MISSING(TCC0_CCDBUF) -#endif - -#ifdef TCC0_CNT - DEFINE(TCC0_CNT) -#else - MISSING(TCC0_CNT) -#endif - -#ifdef TCC0_CTRLA - DEFINE(TCC0_CTRLA) -#else - MISSING(TCC0_CTRLA) -#endif - -#ifdef TCC0_CTRLB - DEFINE(TCC0_CTRLB) -#else - MISSING(TCC0_CTRLB) -#endif - -#ifdef TCC0_CTRLC - DEFINE(TCC0_CTRLC) -#else - MISSING(TCC0_CTRLC) -#endif - -#ifdef TCC0_CTRLD - DEFINE(TCC0_CTRLD) -#else - MISSING(TCC0_CTRLD) -#endif - -#ifdef TCC0_CTRLE - DEFINE(TCC0_CTRLE) -#else - MISSING(TCC0_CTRLE) -#endif - -#ifdef TCC0_CTRLFCLR - DEFINE(TCC0_CTRLFCLR) -#else - MISSING(TCC0_CTRLFCLR) -#endif - -#ifdef TCC0_CTRLFSET - DEFINE(TCC0_CTRLFSET) -#else - MISSING(TCC0_CTRLFSET) -#endif - -#ifdef TCC0_CTRLGCLR - DEFINE(TCC0_CTRLGCLR) -#else - MISSING(TCC0_CTRLGCLR) -#endif - -#ifdef TCC0_CTRLGSET - DEFINE(TCC0_CTRLGSET) -#else - MISSING(TCC0_CTRLGSET) -#endif - -#ifdef TCC0_INTCTRLA - DEFINE(TCC0_INTCTRLA) -#else - MISSING(TCC0_INTCTRLA) -#endif - -#ifdef TCC0_INTCTRLB - DEFINE(TCC0_INTCTRLB) -#else - MISSING(TCC0_INTCTRLB) -#endif - -#ifdef TCC0_INTFLAGS - DEFINE(TCC0_INTFLAGS) -#else - MISSING(TCC0_INTFLAGS) -#endif - -#ifdef TCC0_PER - DEFINE(TCC0_PER) -#else - MISSING(TCC0_PER) -#endif - -#ifdef TCC0_PERBUF - DEFINE(TCC0_PERBUF) -#else - MISSING(TCC0_PERBUF) -#endif - -#ifdef TCC0_TEMP - DEFINE(TCC0_TEMP) -#else - MISSING(TCC0_TEMP) -#endif - -#ifdef TCC1_CCA - DEFINE(TCC1_CCA) -#else - MISSING(TCC1_CCA) -#endif - -#ifdef TCC1_CCABUF - DEFINE(TCC1_CCABUF) -#else - MISSING(TCC1_CCABUF) -#endif - -#ifdef TCC1_CCB - DEFINE(TCC1_CCB) -#else - MISSING(TCC1_CCB) -#endif - -#ifdef TCC1_CCBBUF - DEFINE(TCC1_CCBBUF) -#else - MISSING(TCC1_CCBBUF) -#endif - -#ifdef TCC1_CNT - DEFINE(TCC1_CNT) -#else - MISSING(TCC1_CNT) -#endif - -#ifdef TCC1_CTRLA - DEFINE(TCC1_CTRLA) -#else - MISSING(TCC1_CTRLA) -#endif - -#ifdef TCC1_CTRLB - DEFINE(TCC1_CTRLB) -#else - MISSING(TCC1_CTRLB) -#endif - -#ifdef TCC1_CTRLC - DEFINE(TCC1_CTRLC) -#else - MISSING(TCC1_CTRLC) -#endif - -#ifdef TCC1_CTRLD - DEFINE(TCC1_CTRLD) -#else - MISSING(TCC1_CTRLD) -#endif - -#ifdef TCC1_CTRLE - DEFINE(TCC1_CTRLE) -#else - MISSING(TCC1_CTRLE) -#endif - -#ifdef TCC1_CTRLFCLR - DEFINE(TCC1_CTRLFCLR) -#else - MISSING(TCC1_CTRLFCLR) -#endif - -#ifdef TCC1_CTRLFSET - DEFINE(TCC1_CTRLFSET) -#else - MISSING(TCC1_CTRLFSET) -#endif - -#ifdef TCC1_CTRLGCLR - DEFINE(TCC1_CTRLGCLR) -#else - MISSING(TCC1_CTRLGCLR) -#endif - -#ifdef TCC1_CTRLGSET - DEFINE(TCC1_CTRLGSET) -#else - MISSING(TCC1_CTRLGSET) -#endif - -#ifdef TCC1_INTCTRLA - DEFINE(TCC1_INTCTRLA) -#else - MISSING(TCC1_INTCTRLA) -#endif - -#ifdef TCC1_INTCTRLB - DEFINE(TCC1_INTCTRLB) -#else - MISSING(TCC1_INTCTRLB) -#endif - -#ifdef TCC1_INTFLAGS - DEFINE(TCC1_INTFLAGS) -#else - MISSING(TCC1_INTFLAGS) -#endif - -#ifdef TCC1_PER - DEFINE(TCC1_PER) -#else - MISSING(TCC1_PER) -#endif - -#ifdef TCC1_PERBUF - DEFINE(TCC1_PERBUF) -#else - MISSING(TCC1_PERBUF) -#endif - -#ifdef TCC1_TEMP - DEFINE(TCC1_TEMP) -#else - MISSING(TCC1_TEMP) -#endif - -#ifdef TCCR0 - DEFINE(TCCR0) -#else - MISSING(TCCR0) -#endif - -#ifdef TCCR0A - DEFINE(TCCR0A) -#else - MISSING(TCCR0A) -#endif - -#ifdef TCCR0B - DEFINE(TCCR0B) -#else - MISSING(TCCR0B) -#endif - -#ifdef TCCR0C - DEFINE(TCCR0C) -#else - MISSING(TCCR0C) -#endif - -#ifdef TCCR1 - DEFINE(TCCR1) -#else - MISSING(TCCR1) -#endif - -#ifdef TCCR1A - DEFINE(TCCR1A) -#else - MISSING(TCCR1A) -#endif - -#ifdef TCCR1B - DEFINE(TCCR1B) -#else - MISSING(TCCR1B) -#endif - -#ifdef TCCR1C - DEFINE(TCCR1C) -#else - MISSING(TCCR1C) -#endif - -#ifdef TCCR1D - DEFINE(TCCR1D) -#else - MISSING(TCCR1D) -#endif - -#ifdef TCCR1E - DEFINE(TCCR1E) -#else - MISSING(TCCR1E) -#endif - -#ifdef TCCR2 - DEFINE(TCCR2) -#else - MISSING(TCCR2) -#endif - -#ifdef TCCR2A - DEFINE(TCCR2A) -#else - MISSING(TCCR2A) -#endif - -#ifdef TCCR2B - DEFINE(TCCR2B) -#else - MISSING(TCCR2B) -#endif - -#ifdef TCCR3A - DEFINE(TCCR3A) -#else - MISSING(TCCR3A) -#endif - -#ifdef TCCR3B - DEFINE(TCCR3B) -#else - MISSING(TCCR3B) -#endif - -#ifdef TCCR3C - DEFINE(TCCR3C) -#else - MISSING(TCCR3C) -#endif - -#ifdef TCCR4A - DEFINE(TCCR4A) -#else - MISSING(TCCR4A) -#endif - -#ifdef TCCR4B - DEFINE(TCCR4B) -#else - MISSING(TCCR4B) -#endif - -#ifdef TCCR4C - DEFINE(TCCR4C) -#else - MISSING(TCCR4C) -#endif - -#ifdef TCCR4D - DEFINE(TCCR4D) -#else - MISSING(TCCR4D) -#endif - -#ifdef TCCR4E - DEFINE(TCCR4E) -#else - MISSING(TCCR4E) -#endif - -#ifdef TCCR5A - DEFINE(TCCR5A) -#else - MISSING(TCCR5A) -#endif - -#ifdef TCCR5B - DEFINE(TCCR5B) -#else - MISSING(TCCR5B) -#endif - -#ifdef TCCR5C - DEFINE(TCCR5C) -#else - MISSING(TCCR5C) -#endif - -#ifdef TCD0_CCA - DEFINE(TCD0_CCA) -#else - MISSING(TCD0_CCA) -#endif - -#ifdef TCD0_CCABUF - DEFINE(TCD0_CCABUF) -#else - MISSING(TCD0_CCABUF) -#endif - -#ifdef TCD0_CCB - DEFINE(TCD0_CCB) -#else - MISSING(TCD0_CCB) -#endif - -#ifdef TCD0_CCBBUF - DEFINE(TCD0_CCBBUF) -#else - MISSING(TCD0_CCBBUF) -#endif - -#ifdef TCD0_CCC - DEFINE(TCD0_CCC) -#else - MISSING(TCD0_CCC) -#endif - -#ifdef TCD0_CCCBUF - DEFINE(TCD0_CCCBUF) -#else - MISSING(TCD0_CCCBUF) -#endif - -#ifdef TCD0_CCD - DEFINE(TCD0_CCD) -#else - MISSING(TCD0_CCD) -#endif - -#ifdef TCD0_CCDBUF - DEFINE(TCD0_CCDBUF) -#else - MISSING(TCD0_CCDBUF) -#endif - -#ifdef TCD0_CNT - DEFINE(TCD0_CNT) -#else - MISSING(TCD0_CNT) -#endif - -#ifdef TCD0_CTRLA - DEFINE(TCD0_CTRLA) -#else - MISSING(TCD0_CTRLA) -#endif - -#ifdef TCD0_CTRLB - DEFINE(TCD0_CTRLB) -#else - MISSING(TCD0_CTRLB) -#endif - -#ifdef TCD0_CTRLC - DEFINE(TCD0_CTRLC) -#else - MISSING(TCD0_CTRLC) -#endif - -#ifdef TCD0_CTRLD - DEFINE(TCD0_CTRLD) -#else - MISSING(TCD0_CTRLD) -#endif - -#ifdef TCD0_CTRLE - DEFINE(TCD0_CTRLE) -#else - MISSING(TCD0_CTRLE) -#endif - -#ifdef TCD0_CTRLFCLR - DEFINE(TCD0_CTRLFCLR) -#else - MISSING(TCD0_CTRLFCLR) -#endif - -#ifdef TCD0_CTRLFSET - DEFINE(TCD0_CTRLFSET) -#else - MISSING(TCD0_CTRLFSET) -#endif - -#ifdef TCD0_CTRLGCLR - DEFINE(TCD0_CTRLGCLR) -#else - MISSING(TCD0_CTRLGCLR) -#endif - -#ifdef TCD0_CTRLGSET - DEFINE(TCD0_CTRLGSET) -#else - MISSING(TCD0_CTRLGSET) -#endif - -#ifdef TCD0_INTCTRLA - DEFINE(TCD0_INTCTRLA) -#else - MISSING(TCD0_INTCTRLA) -#endif - -#ifdef TCD0_INTCTRLB - DEFINE(TCD0_INTCTRLB) -#else - MISSING(TCD0_INTCTRLB) -#endif - -#ifdef TCD0_INTFLAGS - DEFINE(TCD0_INTFLAGS) -#else - MISSING(TCD0_INTFLAGS) -#endif - -#ifdef TCD0_PER - DEFINE(TCD0_PER) -#else - MISSING(TCD0_PER) -#endif - -#ifdef TCD0_PERBUF - DEFINE(TCD0_PERBUF) -#else - MISSING(TCD0_PERBUF) -#endif - -#ifdef TCD0_TEMP - DEFINE(TCD0_TEMP) -#else - MISSING(TCD0_TEMP) -#endif - -#ifdef TCD1_CCA - DEFINE(TCD1_CCA) -#else - MISSING(TCD1_CCA) -#endif - -#ifdef TCD1_CCABUF - DEFINE(TCD1_CCABUF) -#else - MISSING(TCD1_CCABUF) -#endif - -#ifdef TCD1_CCB - DEFINE(TCD1_CCB) -#else - MISSING(TCD1_CCB) -#endif - -#ifdef TCD1_CCBBUF - DEFINE(TCD1_CCBBUF) -#else - MISSING(TCD1_CCBBUF) -#endif - -#ifdef TCD1_CNT - DEFINE(TCD1_CNT) -#else - MISSING(TCD1_CNT) -#endif - -#ifdef TCD1_CTRLA - DEFINE(TCD1_CTRLA) -#else - MISSING(TCD1_CTRLA) -#endif - -#ifdef TCD1_CTRLB - DEFINE(TCD1_CTRLB) -#else - MISSING(TCD1_CTRLB) -#endif - -#ifdef TCD1_CTRLC - DEFINE(TCD1_CTRLC) -#else - MISSING(TCD1_CTRLC) -#endif - -#ifdef TCD1_CTRLD - DEFINE(TCD1_CTRLD) -#else - MISSING(TCD1_CTRLD) -#endif - -#ifdef TCD1_CTRLE - DEFINE(TCD1_CTRLE) -#else - MISSING(TCD1_CTRLE) -#endif - -#ifdef TCD1_CTRLFCLR - DEFINE(TCD1_CTRLFCLR) -#else - MISSING(TCD1_CTRLFCLR) -#endif - -#ifdef TCD1_CTRLFSET - DEFINE(TCD1_CTRLFSET) -#else - MISSING(TCD1_CTRLFSET) -#endif - -#ifdef TCD1_CTRLGCLR - DEFINE(TCD1_CTRLGCLR) -#else - MISSING(TCD1_CTRLGCLR) -#endif - -#ifdef TCD1_CTRLGSET - DEFINE(TCD1_CTRLGSET) -#else - MISSING(TCD1_CTRLGSET) -#endif - -#ifdef TCD1_INTCTRLA - DEFINE(TCD1_INTCTRLA) -#else - MISSING(TCD1_INTCTRLA) -#endif - -#ifdef TCD1_INTCTRLB - DEFINE(TCD1_INTCTRLB) -#else - MISSING(TCD1_INTCTRLB) -#endif - -#ifdef TCD1_INTFLAGS - DEFINE(TCD1_INTFLAGS) -#else - MISSING(TCD1_INTFLAGS) -#endif - -#ifdef TCD1_PER - DEFINE(TCD1_PER) -#else - MISSING(TCD1_PER) -#endif - -#ifdef TCD1_PERBUF - DEFINE(TCD1_PERBUF) -#else - MISSING(TCD1_PERBUF) -#endif - -#ifdef TCD1_TEMP - DEFINE(TCD1_TEMP) -#else - MISSING(TCD1_TEMP) -#endif - -#ifdef TCE0_CCA - DEFINE(TCE0_CCA) -#else - MISSING(TCE0_CCA) -#endif - -#ifdef TCE0_CCABUF - DEFINE(TCE0_CCABUF) -#else - MISSING(TCE0_CCABUF) -#endif - -#ifdef TCE0_CCB - DEFINE(TCE0_CCB) -#else - MISSING(TCE0_CCB) -#endif - -#ifdef TCE0_CCBBUF - DEFINE(TCE0_CCBBUF) -#else - MISSING(TCE0_CCBBUF) -#endif - -#ifdef TCE0_CCC - DEFINE(TCE0_CCC) -#else - MISSING(TCE0_CCC) -#endif - -#ifdef TCE0_CCCBUF - DEFINE(TCE0_CCCBUF) -#else - MISSING(TCE0_CCCBUF) -#endif - -#ifdef TCE0_CCD - DEFINE(TCE0_CCD) -#else - MISSING(TCE0_CCD) -#endif - -#ifdef TCE0_CCDBUF - DEFINE(TCE0_CCDBUF) -#else - MISSING(TCE0_CCDBUF) -#endif - -#ifdef TCE0_CNT - DEFINE(TCE0_CNT) -#else - MISSING(TCE0_CNT) -#endif - -#ifdef TCE0_CTRLA - DEFINE(TCE0_CTRLA) -#else - MISSING(TCE0_CTRLA) -#endif - -#ifdef TCE0_CTRLB - DEFINE(TCE0_CTRLB) -#else - MISSING(TCE0_CTRLB) -#endif - -#ifdef TCE0_CTRLC - DEFINE(TCE0_CTRLC) -#else - MISSING(TCE0_CTRLC) -#endif - -#ifdef TCE0_CTRLD - DEFINE(TCE0_CTRLD) -#else - MISSING(TCE0_CTRLD) -#endif - -#ifdef TCE0_CTRLE - DEFINE(TCE0_CTRLE) -#else - MISSING(TCE0_CTRLE) -#endif - -#ifdef TCE0_CTRLFCLR - DEFINE(TCE0_CTRLFCLR) -#else - MISSING(TCE0_CTRLFCLR) -#endif - -#ifdef TCE0_CTRLFSET - DEFINE(TCE0_CTRLFSET) -#else - MISSING(TCE0_CTRLFSET) -#endif - -#ifdef TCE0_CTRLGCLR - DEFINE(TCE0_CTRLGCLR) -#else - MISSING(TCE0_CTRLGCLR) -#endif - -#ifdef TCE0_CTRLGSET - DEFINE(TCE0_CTRLGSET) -#else - MISSING(TCE0_CTRLGSET) -#endif - -#ifdef TCE0_INTCTRLA - DEFINE(TCE0_INTCTRLA) -#else - MISSING(TCE0_INTCTRLA) -#endif - -#ifdef TCE0_INTCTRLB - DEFINE(TCE0_INTCTRLB) -#else - MISSING(TCE0_INTCTRLB) -#endif - -#ifdef TCE0_INTFLAGS - DEFINE(TCE0_INTFLAGS) -#else - MISSING(TCE0_INTFLAGS) -#endif - -#ifdef TCE0_PER - DEFINE(TCE0_PER) -#else - MISSING(TCE0_PER) -#endif - -#ifdef TCE0_PERBUF - DEFINE(TCE0_PERBUF) -#else - MISSING(TCE0_PERBUF) -#endif - -#ifdef TCE0_TEMP - DEFINE(TCE0_TEMP) -#else - MISSING(TCE0_TEMP) -#endif - -#ifdef TCE1_CCA - DEFINE(TCE1_CCA) -#else - MISSING(TCE1_CCA) -#endif - -#ifdef TCE1_CCABUF - DEFINE(TCE1_CCABUF) -#else - MISSING(TCE1_CCABUF) -#endif - -#ifdef TCE1_CCB - DEFINE(TCE1_CCB) -#else - MISSING(TCE1_CCB) -#endif - -#ifdef TCE1_CCBBUF - DEFINE(TCE1_CCBBUF) -#else - MISSING(TCE1_CCBBUF) -#endif - -#ifdef TCE1_CNT - DEFINE(TCE1_CNT) -#else - MISSING(TCE1_CNT) -#endif - -#ifdef TCE1_CTRLA - DEFINE(TCE1_CTRLA) -#else - MISSING(TCE1_CTRLA) -#endif - -#ifdef TCE1_CTRLB - DEFINE(TCE1_CTRLB) -#else - MISSING(TCE1_CTRLB) -#endif - -#ifdef TCE1_CTRLC - DEFINE(TCE1_CTRLC) -#else - MISSING(TCE1_CTRLC) -#endif - -#ifdef TCE1_CTRLD - DEFINE(TCE1_CTRLD) -#else - MISSING(TCE1_CTRLD) -#endif - -#ifdef TCE1_CTRLE - DEFINE(TCE1_CTRLE) -#else - MISSING(TCE1_CTRLE) -#endif - -#ifdef TCE1_CTRLFCLR - DEFINE(TCE1_CTRLFCLR) -#else - MISSING(TCE1_CTRLFCLR) -#endif - -#ifdef TCE1_CTRLFSET - DEFINE(TCE1_CTRLFSET) -#else - MISSING(TCE1_CTRLFSET) -#endif - -#ifdef TCE1_CTRLGCLR - DEFINE(TCE1_CTRLGCLR) -#else - MISSING(TCE1_CTRLGCLR) -#endif - -#ifdef TCE1_CTRLGSET - DEFINE(TCE1_CTRLGSET) -#else - MISSING(TCE1_CTRLGSET) -#endif - -#ifdef TCE1_INTCTRLA - DEFINE(TCE1_INTCTRLA) -#else - MISSING(TCE1_INTCTRLA) -#endif - -#ifdef TCE1_INTCTRLB - DEFINE(TCE1_INTCTRLB) -#else - MISSING(TCE1_INTCTRLB) -#endif - -#ifdef TCE1_INTFLAGS - DEFINE(TCE1_INTFLAGS) -#else - MISSING(TCE1_INTFLAGS) -#endif - -#ifdef TCE1_PER - DEFINE(TCE1_PER) -#else - MISSING(TCE1_PER) -#endif - -#ifdef TCE1_PERBUF - DEFINE(TCE1_PERBUF) -#else - MISSING(TCE1_PERBUF) -#endif - -#ifdef TCE1_TEMP - DEFINE(TCE1_TEMP) -#else - MISSING(TCE1_TEMP) -#endif - -#ifdef TCF0_CCA - DEFINE(TCF0_CCA) -#else - MISSING(TCF0_CCA) -#endif - -#ifdef TCF0_CCABUF - DEFINE(TCF0_CCABUF) -#else - MISSING(TCF0_CCABUF) -#endif - -#ifdef TCF0_CCB - DEFINE(TCF0_CCB) -#else - MISSING(TCF0_CCB) -#endif - -#ifdef TCF0_CCBBUF - DEFINE(TCF0_CCBBUF) -#else - MISSING(TCF0_CCBBUF) -#endif - -#ifdef TCF0_CCC - DEFINE(TCF0_CCC) -#else - MISSING(TCF0_CCC) -#endif - -#ifdef TCF0_CCCBUF - DEFINE(TCF0_CCCBUF) -#else - MISSING(TCF0_CCCBUF) -#endif - -#ifdef TCF0_CCD - DEFINE(TCF0_CCD) -#else - MISSING(TCF0_CCD) -#endif - -#ifdef TCF0_CCDBUF - DEFINE(TCF0_CCDBUF) -#else - MISSING(TCF0_CCDBUF) -#endif - -#ifdef TCF0_CNT - DEFINE(TCF0_CNT) -#else - MISSING(TCF0_CNT) -#endif - -#ifdef TCF0_CTRLA - DEFINE(TCF0_CTRLA) -#else - MISSING(TCF0_CTRLA) -#endif - -#ifdef TCF0_CTRLB - DEFINE(TCF0_CTRLB) -#else - MISSING(TCF0_CTRLB) -#endif - -#ifdef TCF0_CTRLC - DEFINE(TCF0_CTRLC) -#else - MISSING(TCF0_CTRLC) -#endif - -#ifdef TCF0_CTRLD - DEFINE(TCF0_CTRLD) -#else - MISSING(TCF0_CTRLD) -#endif - -#ifdef TCF0_CTRLE - DEFINE(TCF0_CTRLE) -#else - MISSING(TCF0_CTRLE) -#endif - -#ifdef TCF0_CTRLFCLR - DEFINE(TCF0_CTRLFCLR) -#else - MISSING(TCF0_CTRLFCLR) -#endif - -#ifdef TCF0_CTRLFSET - DEFINE(TCF0_CTRLFSET) -#else - MISSING(TCF0_CTRLFSET) -#endif - -#ifdef TCF0_CTRLGCLR - DEFINE(TCF0_CTRLGCLR) -#else - MISSING(TCF0_CTRLGCLR) -#endif - -#ifdef TCF0_CTRLGSET - DEFINE(TCF0_CTRLGSET) -#else - MISSING(TCF0_CTRLGSET) -#endif - -#ifdef TCF0_INTCTRLA - DEFINE(TCF0_INTCTRLA) -#else - MISSING(TCF0_INTCTRLA) -#endif - -#ifdef TCF0_INTCTRLB - DEFINE(TCF0_INTCTRLB) -#else - MISSING(TCF0_INTCTRLB) -#endif - -#ifdef TCF0_INTFLAGS - DEFINE(TCF0_INTFLAGS) -#else - MISSING(TCF0_INTFLAGS) -#endif - -#ifdef TCF0_PER - DEFINE(TCF0_PER) -#else - MISSING(TCF0_PER) -#endif - -#ifdef TCF0_PERBUF - DEFINE(TCF0_PERBUF) -#else - MISSING(TCF0_PERBUF) -#endif - -#ifdef TCF0_TEMP - DEFINE(TCF0_TEMP) -#else - MISSING(TCF0_TEMP) -#endif - -#ifdef TCF1_CCA - DEFINE(TCF1_CCA) -#else - MISSING(TCF1_CCA) -#endif - -#ifdef TCF1_CCABUF - DEFINE(TCF1_CCABUF) -#else - MISSING(TCF1_CCABUF) -#endif - -#ifdef TCF1_CCB - DEFINE(TCF1_CCB) -#else - MISSING(TCF1_CCB) -#endif - -#ifdef TCF1_CCBBUF - DEFINE(TCF1_CCBBUF) -#else - MISSING(TCF1_CCBBUF) -#endif - -#ifdef TCF1_CNT - DEFINE(TCF1_CNT) -#else - MISSING(TCF1_CNT) -#endif - -#ifdef TCF1_CTRLA - DEFINE(TCF1_CTRLA) -#else - MISSING(TCF1_CTRLA) -#endif - -#ifdef TCF1_CTRLB - DEFINE(TCF1_CTRLB) -#else - MISSING(TCF1_CTRLB) -#endif - -#ifdef TCF1_CTRLC - DEFINE(TCF1_CTRLC) -#else - MISSING(TCF1_CTRLC) -#endif - -#ifdef TCF1_CTRLD - DEFINE(TCF1_CTRLD) -#else - MISSING(TCF1_CTRLD) -#endif - -#ifdef TCF1_CTRLE - DEFINE(TCF1_CTRLE) -#else - MISSING(TCF1_CTRLE) -#endif - -#ifdef TCF1_CTRLFCLR - DEFINE(TCF1_CTRLFCLR) -#else - MISSING(TCF1_CTRLFCLR) -#endif - -#ifdef TCF1_CTRLFSET - DEFINE(TCF1_CTRLFSET) -#else - MISSING(TCF1_CTRLFSET) -#endif - -#ifdef TCF1_CTRLGCLR - DEFINE(TCF1_CTRLGCLR) -#else - MISSING(TCF1_CTRLGCLR) -#endif - -#ifdef TCF1_CTRLGSET - DEFINE(TCF1_CTRLGSET) -#else - MISSING(TCF1_CTRLGSET) -#endif - -#ifdef TCF1_INTCTRLA - DEFINE(TCF1_INTCTRLA) -#else - MISSING(TCF1_INTCTRLA) -#endif - -#ifdef TCF1_INTCTRLB - DEFINE(TCF1_INTCTRLB) -#else - MISSING(TCF1_INTCTRLB) -#endif - -#ifdef TCF1_INTFLAGS - DEFINE(TCF1_INTFLAGS) -#else - MISSING(TCF1_INTFLAGS) -#endif - -#ifdef TCF1_PER - DEFINE(TCF1_PER) -#else - MISSING(TCF1_PER) -#endif - -#ifdef TCF1_PERBUF - DEFINE(TCF1_PERBUF) -#else - MISSING(TCF1_PERBUF) -#endif - -#ifdef TCF1_TEMP - DEFINE(TCF1_TEMP) -#else - MISSING(TCF1_TEMP) -#endif - -#ifdef TCNT0 - DEFINE(TCNT0) -#else - MISSING(TCNT0) -#endif - -#ifdef TCNT0H - DEFINE(TCNT0H) -#else - MISSING(TCNT0H) -#endif - -#ifdef TCNT0L - DEFINE(TCNT0L) -#else - MISSING(TCNT0L) -#endif - -#ifdef TCNT1 - DEFINE(TCNT1) -#else - MISSING(TCNT1) -#endif - -#ifdef TCNT1H - DEFINE(TCNT1H) -#else - MISSING(TCNT1H) -#endif - -#ifdef TCNT1L - DEFINE(TCNT1L) -#else - MISSING(TCNT1L) -#endif - -#ifdef TCNT2 - DEFINE(TCNT2) -#else - MISSING(TCNT2) -#endif - -#ifdef TCNT3 - DEFINE(TCNT3) -#else - MISSING(TCNT3) -#endif - -#ifdef TCNT3H - DEFINE(TCNT3H) -#else - MISSING(TCNT3H) -#endif - -#ifdef TCNT3L - DEFINE(TCNT3L) -#else - MISSING(TCNT3L) -#endif - -#ifdef TCNT4 - DEFINE(TCNT4) -#else - MISSING(TCNT4) -#endif - -#ifdef TCNT4H - DEFINE(TCNT4H) -#else - MISSING(TCNT4H) -#endif - -#ifdef TCNT4L - DEFINE(TCNT4L) -#else - MISSING(TCNT4L) -#endif - -#ifdef TCNT5 - DEFINE(TCNT5) -#else - MISSING(TCNT5) -#endif - -#ifdef TCNT5H - DEFINE(TCNT5H) -#else - MISSING(TCNT5H) -#endif - -#ifdef TCNT5L - DEFINE(TCNT5L) -#else - MISSING(TCNT5L) -#endif - -#ifdef TIFR - DEFINE(TIFR) -#else - MISSING(TIFR) -#endif - -#ifdef TIFR0 - DEFINE(TIFR0) -#else - MISSING(TIFR0) -#endif - -#ifdef TIFR1 - DEFINE(TIFR1) -#else - MISSING(TIFR1) -#endif - -#ifdef TIFR2 - DEFINE(TIFR2) -#else - MISSING(TIFR2) -#endif - -#ifdef TIFR3 - DEFINE(TIFR3) -#else - MISSING(TIFR3) -#endif - -#ifdef TIFR4 - DEFINE(TIFR4) -#else - MISSING(TIFR4) -#endif - -#ifdef TIFR5 - DEFINE(TIFR5) -#else - MISSING(TIFR5) -#endif - -#ifdef TIMSK - DEFINE(TIMSK) -#else - MISSING(TIMSK) -#endif - -#ifdef TIMSK0 - DEFINE(TIMSK0) -#else - MISSING(TIMSK0) -#endif - -#ifdef TIMSK1 - DEFINE(TIMSK1) -#else - MISSING(TIMSK1) -#endif - -#ifdef TIMSK2 - DEFINE(TIMSK2) -#else - MISSING(TIMSK2) -#endif - -#ifdef TIMSK3 - DEFINE(TIMSK3) -#else - MISSING(TIMSK3) -#endif - -#ifdef TIMSK4 - DEFINE(TIMSK4) -#else - MISSING(TIMSK4) -#endif - -#ifdef TIMSK5 - DEFINE(TIMSK5) -#else - MISSING(TIMSK5) -#endif - -#ifdef TRXFBEND - DEFINE(TRXFBEND) -#else - MISSING(TRXFBEND) -#endif - -#ifdef TRXFBST - DEFINE(TRXFBST) -#else - MISSING(TRXFBST) -#endif - -#ifdef TRXPR - DEFINE(TRXPR) -#else - MISSING(TRXPR) -#endif - -#ifdef TRX_CTRL_0 - DEFINE(TRX_CTRL_0) -#else - MISSING(TRX_CTRL_0) -#endif - -#ifdef TRX_CTRL_1 - DEFINE(TRX_CTRL_1) -#else - MISSING(TRX_CTRL_1) -#endif - -#ifdef TRX_CTRL_2 - DEFINE(TRX_CTRL_2) -#else - MISSING(TRX_CTRL_2) -#endif - -#ifdef TRX_STATE - DEFINE(TRX_STATE) -#else - MISSING(TRX_STATE) -#endif - -#ifdef TRX_STATUS - DEFINE(TRX_STATUS) -#else - MISSING(TRX_STATUS) -#endif - -#ifdef TSCR - DEFINE(TSCR) -#else - MISSING(TSCR) -#endif - -#ifdef TST_CTRL_DIGI - DEFINE(TST_CTRL_DIGI) -#else - MISSING(TST_CTRL_DIGI) -#endif - -#ifdef TST_RX_LENGTH - DEFINE(TST_RX_LENGTH) -#else - MISSING(TST_RX_LENGTH) -#endif - -#ifdef TWAMR - DEFINE(TWAMR) -#else - MISSING(TWAMR) -#endif - -#ifdef TWAR - DEFINE(TWAR) -#else - MISSING(TWAR) -#endif - -#ifdef TWBCSR - DEFINE(TWBCSR) -#else - MISSING(TWBCSR) -#endif - -#ifdef TWBR - DEFINE(TWBR) -#else - MISSING(TWBR) -#endif - -#ifdef TWCR - DEFINE(TWCR) -#else - MISSING(TWCR) -#endif - -#ifdef TWDR - DEFINE(TWDR) -#else - MISSING(TWDR) -#endif - -#ifdef TWHSR - DEFINE(TWHSR) -#else - MISSING(TWHSR) -#endif - -#ifdef TWIC_CTRL - DEFINE(TWIC_CTRL) -#else - MISSING(TWIC_CTRL) -#endif - -#ifdef TWIC_MASTER_ADDR - DEFINE(TWIC_MASTER_ADDR) -#else - MISSING(TWIC_MASTER_ADDR) -#endif - -#ifdef TWIC_MASTER_BAUD - DEFINE(TWIC_MASTER_BAUD) -#else - MISSING(TWIC_MASTER_BAUD) -#endif - -#ifdef TWIC_MASTER_CTRLA - DEFINE(TWIC_MASTER_CTRLA) -#else - MISSING(TWIC_MASTER_CTRLA) -#endif - -#ifdef TWIC_MASTER_CTRLB - DEFINE(TWIC_MASTER_CTRLB) -#else - MISSING(TWIC_MASTER_CTRLB) -#endif - -#ifdef TWIC_MASTER_CTRLC - DEFINE(TWIC_MASTER_CTRLC) -#else - MISSING(TWIC_MASTER_CTRLC) -#endif - -#ifdef TWIC_MASTER_DATA - DEFINE(TWIC_MASTER_DATA) -#else - MISSING(TWIC_MASTER_DATA) -#endif - -#ifdef TWIC_MASTER_STATUS - DEFINE(TWIC_MASTER_STATUS) -#else - MISSING(TWIC_MASTER_STATUS) -#endif - -#ifdef TWIC_SLAVE_ADDR - DEFINE(TWIC_SLAVE_ADDR) -#else - MISSING(TWIC_SLAVE_ADDR) -#endif - -#ifdef TWIC_SLAVE_ADDRMASK - DEFINE(TWIC_SLAVE_ADDRMASK) -#else - MISSING(TWIC_SLAVE_ADDRMASK) -#endif - -#ifdef TWIC_SLAVE_CTRLA - DEFINE(TWIC_SLAVE_CTRLA) -#else - MISSING(TWIC_SLAVE_CTRLA) -#endif - -#ifdef TWIC_SLAVE_CTRLB - DEFINE(TWIC_SLAVE_CTRLB) -#else - MISSING(TWIC_SLAVE_CTRLB) -#endif - -#ifdef TWIC_SLAVE_DATA - DEFINE(TWIC_SLAVE_DATA) -#else - MISSING(TWIC_SLAVE_DATA) -#endif - -#ifdef TWIC_SLAVE_STATUS - DEFINE(TWIC_SLAVE_STATUS) -#else - MISSING(TWIC_SLAVE_STATUS) -#endif - -#ifdef TWID_CTRL - DEFINE(TWID_CTRL) -#else - MISSING(TWID_CTRL) -#endif - -#ifdef TWID_MASTER_ADDR - DEFINE(TWID_MASTER_ADDR) -#else - MISSING(TWID_MASTER_ADDR) -#endif - -#ifdef TWID_MASTER_BAUD - DEFINE(TWID_MASTER_BAUD) -#else - MISSING(TWID_MASTER_BAUD) -#endif - -#ifdef TWID_MASTER_CTRLA - DEFINE(TWID_MASTER_CTRLA) -#else - MISSING(TWID_MASTER_CTRLA) -#endif - -#ifdef TWID_MASTER_CTRLB - DEFINE(TWID_MASTER_CTRLB) -#else - MISSING(TWID_MASTER_CTRLB) -#endif - -#ifdef TWID_MASTER_CTRLC - DEFINE(TWID_MASTER_CTRLC) -#else - MISSING(TWID_MASTER_CTRLC) -#endif - -#ifdef TWID_MASTER_DATA - DEFINE(TWID_MASTER_DATA) -#else - MISSING(TWID_MASTER_DATA) -#endif - -#ifdef TWID_MASTER_STATUS - DEFINE(TWID_MASTER_STATUS) -#else - MISSING(TWID_MASTER_STATUS) -#endif - -#ifdef TWID_SLAVE_ADDR - DEFINE(TWID_SLAVE_ADDR) -#else - MISSING(TWID_SLAVE_ADDR) -#endif - -#ifdef TWID_SLAVE_ADDRMASK - DEFINE(TWID_SLAVE_ADDRMASK) -#else - MISSING(TWID_SLAVE_ADDRMASK) -#endif - -#ifdef TWID_SLAVE_CTRLA - DEFINE(TWID_SLAVE_CTRLA) -#else - MISSING(TWID_SLAVE_CTRLA) -#endif - -#ifdef TWID_SLAVE_CTRLB - DEFINE(TWID_SLAVE_CTRLB) -#else - MISSING(TWID_SLAVE_CTRLB) -#endif - -#ifdef TWID_SLAVE_DATA - DEFINE(TWID_SLAVE_DATA) -#else - MISSING(TWID_SLAVE_DATA) -#endif - -#ifdef TWID_SLAVE_STATUS - DEFINE(TWID_SLAVE_STATUS) -#else - MISSING(TWID_SLAVE_STATUS) -#endif - -#ifdef TWIE_CTRL - DEFINE(TWIE_CTRL) -#else - MISSING(TWIE_CTRL) -#endif - -#ifdef TWIE_MASTER_ADDR - DEFINE(TWIE_MASTER_ADDR) -#else - MISSING(TWIE_MASTER_ADDR) -#endif - -#ifdef TWIE_MASTER_BAUD - DEFINE(TWIE_MASTER_BAUD) -#else - MISSING(TWIE_MASTER_BAUD) -#endif - -#ifdef TWIE_MASTER_CTRLA - DEFINE(TWIE_MASTER_CTRLA) -#else - MISSING(TWIE_MASTER_CTRLA) -#endif - -#ifdef TWIE_MASTER_CTRLB - DEFINE(TWIE_MASTER_CTRLB) -#else - MISSING(TWIE_MASTER_CTRLB) -#endif - -#ifdef TWIE_MASTER_CTRLC - DEFINE(TWIE_MASTER_CTRLC) -#else - MISSING(TWIE_MASTER_CTRLC) -#endif - -#ifdef TWIE_MASTER_DATA - DEFINE(TWIE_MASTER_DATA) -#else - MISSING(TWIE_MASTER_DATA) -#endif - -#ifdef TWIE_MASTER_STATUS - DEFINE(TWIE_MASTER_STATUS) -#else - MISSING(TWIE_MASTER_STATUS) -#endif - -#ifdef TWIE_SLAVE_ADDR - DEFINE(TWIE_SLAVE_ADDR) -#else - MISSING(TWIE_SLAVE_ADDR) -#endif - -#ifdef TWIE_SLAVE_ADDRMASK - DEFINE(TWIE_SLAVE_ADDRMASK) -#else - MISSING(TWIE_SLAVE_ADDRMASK) -#endif - -#ifdef TWIE_SLAVE_CTRLA - DEFINE(TWIE_SLAVE_CTRLA) -#else - MISSING(TWIE_SLAVE_CTRLA) -#endif - -#ifdef TWIE_SLAVE_CTRLB - DEFINE(TWIE_SLAVE_CTRLB) -#else - MISSING(TWIE_SLAVE_CTRLB) -#endif - -#ifdef TWIE_SLAVE_DATA - DEFINE(TWIE_SLAVE_DATA) -#else - MISSING(TWIE_SLAVE_DATA) -#endif - -#ifdef TWIE_SLAVE_STATUS - DEFINE(TWIE_SLAVE_STATUS) -#else - MISSING(TWIE_SLAVE_STATUS) -#endif - -#ifdef TWIF_CTRL - DEFINE(TWIF_CTRL) -#else - MISSING(TWIF_CTRL) -#endif - -#ifdef TWIF_MASTER_ADDR - DEFINE(TWIF_MASTER_ADDR) -#else - MISSING(TWIF_MASTER_ADDR) -#endif - -#ifdef TWIF_MASTER_BAUD - DEFINE(TWIF_MASTER_BAUD) -#else - MISSING(TWIF_MASTER_BAUD) -#endif - -#ifdef TWIF_MASTER_CTRLA - DEFINE(TWIF_MASTER_CTRLA) -#else - MISSING(TWIF_MASTER_CTRLA) -#endif - -#ifdef TWIF_MASTER_CTRLB - DEFINE(TWIF_MASTER_CTRLB) -#else - MISSING(TWIF_MASTER_CTRLB) -#endif - -#ifdef TWIF_MASTER_CTRLC - DEFINE(TWIF_MASTER_CTRLC) -#else - MISSING(TWIF_MASTER_CTRLC) -#endif - -#ifdef TWIF_MASTER_DATA - DEFINE(TWIF_MASTER_DATA) -#else - MISSING(TWIF_MASTER_DATA) -#endif - -#ifdef TWIF_MASTER_STATUS - DEFINE(TWIF_MASTER_STATUS) -#else - MISSING(TWIF_MASTER_STATUS) -#endif - -#ifdef TWIF_SLAVE_ADDR - DEFINE(TWIF_SLAVE_ADDR) -#else - MISSING(TWIF_SLAVE_ADDR) -#endif - -#ifdef TWIF_SLAVE_ADDRMASK - DEFINE(TWIF_SLAVE_ADDRMASK) -#else - MISSING(TWIF_SLAVE_ADDRMASK) -#endif - -#ifdef TWIF_SLAVE_CTRLA - DEFINE(TWIF_SLAVE_CTRLA) -#else - MISSING(TWIF_SLAVE_CTRLA) -#endif - -#ifdef TWIF_SLAVE_CTRLB - DEFINE(TWIF_SLAVE_CTRLB) -#else - MISSING(TWIF_SLAVE_CTRLB) -#endif - -#ifdef TWIF_SLAVE_DATA - DEFINE(TWIF_SLAVE_DATA) -#else - MISSING(TWIF_SLAVE_DATA) -#endif - -#ifdef TWIF_SLAVE_STATUS - DEFINE(TWIF_SLAVE_STATUS) -#else - MISSING(TWIF_SLAVE_STATUS) -#endif - -#ifdef TWIHSR - DEFINE(TWIHSR) -#else - MISSING(TWIHSR) -#endif - -#ifdef TWSA - DEFINE(TWSA) -#else - MISSING(TWSA) -#endif - -#ifdef TWSAM - DEFINE(TWSAM) -#else - MISSING(TWSAM) -#endif - -#ifdef TWSCRA - DEFINE(TWSCRA) -#else - MISSING(TWSCRA) -#endif - -#ifdef TWSCRB - DEFINE(TWSCRB) -#else - MISSING(TWSCRB) -#endif - -#ifdef TWSD - DEFINE(TWSD) -#else - MISSING(TWSD) -#endif - -#ifdef TWSR - DEFINE(TWSR) -#else - MISSING(TWSR) -#endif - -#ifdef TWSSRA - DEFINE(TWSSRA) -#else - MISSING(TWSSRA) -#endif - -#ifdef TXB - DEFINE(TXB) -#else - MISSING(TXB) -#endif - -#ifdef TX_CNTL - DEFINE(TX_CNTL) -#else - MISSING(TX_CNTL) -#endif - -#ifdef UBRR - DEFINE(UBRR) -#else - MISSING(UBRR) -#endif - -#ifdef UBRR0 - DEFINE(UBRR0) -#else - MISSING(UBRR0) -#endif - -#ifdef UBRR0H - DEFINE(UBRR0H) -#else - MISSING(UBRR0H) -#endif - -#ifdef UBRR0L - DEFINE(UBRR0L) -#else - MISSING(UBRR0L) -#endif - -#ifdef UBRR1 - DEFINE(UBRR1) -#else - MISSING(UBRR1) -#endif - -#ifdef UBRR1H - DEFINE(UBRR1H) -#else - MISSING(UBRR1H) -#endif - -#ifdef UBRR1L - DEFINE(UBRR1L) -#else - MISSING(UBRR1L) -#endif - -#ifdef UBRR2 - DEFINE(UBRR2) -#else - MISSING(UBRR2) -#endif - -#ifdef UBRR2H - DEFINE(UBRR2H) -#else - MISSING(UBRR2H) -#endif - -#ifdef UBRR2L - DEFINE(UBRR2L) -#else - MISSING(UBRR2L) -#endif - -#ifdef UBRR3 - DEFINE(UBRR3) -#else - MISSING(UBRR3) -#endif - -#ifdef UBRR3H - DEFINE(UBRR3H) -#else - MISSING(UBRR3H) -#endif - -#ifdef UBRR3L - DEFINE(UBRR3L) -#else - MISSING(UBRR3L) -#endif - -#ifdef UBRRH - DEFINE(UBRRH) -#else - MISSING(UBRRH) -#endif - -#ifdef UBRRHI - DEFINE(UBRRHI) -#else - MISSING(UBRRHI) -#endif - -#ifdef UBRRL - DEFINE(UBRRL) -#else - MISSING(UBRRL) -#endif - -#ifdef UBRRLO - DEFINE(UBRRLO) -#else - MISSING(UBRRLO) -#endif - -#ifdef UCR - DEFINE(UCR) -#else - MISSING(UCR) -#endif - -#ifdef UCRA - DEFINE(UCRA) -#else - MISSING(UCRA) -#endif - -#ifdef UCRB - DEFINE(UCRB) -#else - MISSING(UCRB) -#endif - -#ifdef UCSR0A - DEFINE(UCSR0A) -#else - MISSING(UCSR0A) -#endif - -#ifdef UCSR0B - DEFINE(UCSR0B) -#else - MISSING(UCSR0B) -#endif - -#ifdef UCSR0C - DEFINE(UCSR0C) -#else - MISSING(UCSR0C) -#endif - -#ifdef UCSR1A - DEFINE(UCSR1A) -#else - MISSING(UCSR1A) -#endif - -#ifdef UCSR1B - DEFINE(UCSR1B) -#else - MISSING(UCSR1B) -#endif - -#ifdef UCSR1C - DEFINE(UCSR1C) -#else - MISSING(UCSR1C) -#endif - -#ifdef UCSR1D - DEFINE(UCSR1D) -#else - MISSING(UCSR1D) -#endif - -#ifdef UCSR2A - DEFINE(UCSR2A) -#else - MISSING(UCSR2A) -#endif - -#ifdef UCSR2B - DEFINE(UCSR2B) -#else - MISSING(UCSR2B) -#endif - -#ifdef UCSR2C - DEFINE(UCSR2C) -#else - MISSING(UCSR2C) -#endif - -#ifdef UCSR3A - DEFINE(UCSR3A) -#else - MISSING(UCSR3A) -#endif - -#ifdef UCSR3B - DEFINE(UCSR3B) -#else - MISSING(UCSR3B) -#endif - -#ifdef UCSR3C - DEFINE(UCSR3C) -#else - MISSING(UCSR3C) -#endif - -#ifdef UCSRA - DEFINE(UCSRA) -#else - MISSING(UCSRA) -#endif - -#ifdef UCSRB - DEFINE(UCSRB) -#else - MISSING(UCSRB) -#endif - -#ifdef UCSRC - DEFINE(UCSRC) -#else - MISSING(UCSRC) -#endif - -#ifdef UDADDR - DEFINE(UDADDR) -#else - MISSING(UDADDR) -#endif - -#ifdef UDCON - DEFINE(UDCON) -#else - MISSING(UDCON) -#endif - -#ifdef UDFNUM - DEFINE(UDFNUM) -#else - MISSING(UDFNUM) -#endif - -#ifdef UDFNUMH - DEFINE(UDFNUMH) -#else - MISSING(UDFNUMH) -#endif - -#ifdef UDFNUML - DEFINE(UDFNUML) -#else - MISSING(UDFNUML) -#endif - -#ifdef UDIEN - DEFINE(UDIEN) -#else - MISSING(UDIEN) -#endif - -#ifdef UDINT - DEFINE(UDINT) -#else - MISSING(UDINT) -#endif - -#ifdef UDMFN - DEFINE(UDMFN) -#else - MISSING(UDMFN) -#endif - -#ifdef UDPADD - DEFINE(UDPADD) -#else - MISSING(UDPADD) -#endif - -#ifdef UDPADDH - DEFINE(UDPADDH) -#else - MISSING(UDPADDH) -#endif - -#ifdef UDPADDL - DEFINE(UDPADDL) -#else - MISSING(UDPADDL) -#endif - -#ifdef UDR - DEFINE(UDR) -#else - MISSING(UDR) -#endif - -#ifdef UDR0 - DEFINE(UDR0) -#else - MISSING(UDR0) -#endif - -#ifdef UDR1 - DEFINE(UDR1) -#else - MISSING(UDR1) -#endif - -#ifdef UDR2 - DEFINE(UDR2) -#else - MISSING(UDR2) -#endif - -#ifdef UDR3 - DEFINE(UDR3) -#else - MISSING(UDR3) -#endif - -#ifdef UDTST - DEFINE(UDTST) -#else - MISSING(UDTST) -#endif - -#ifdef UEBCHX - DEFINE(UEBCHX) -#else - MISSING(UEBCHX) -#endif - -#ifdef UEBCLX - DEFINE(UEBCLX) -#else - MISSING(UEBCLX) -#endif - -#ifdef UEBCX - DEFINE(UEBCX) -#else - MISSING(UEBCX) -#endif - -#ifdef UECFG0X - DEFINE(UECFG0X) -#else - MISSING(UECFG0X) -#endif - -#ifdef UECFG1X - DEFINE(UECFG1X) -#else - MISSING(UECFG1X) -#endif - -#ifdef UECONX - DEFINE(UECONX) -#else - MISSING(UECONX) -#endif - -#ifdef UEDATX - DEFINE(UEDATX) -#else - MISSING(UEDATX) -#endif - -#ifdef UEIENX - DEFINE(UEIENX) -#else - MISSING(UEIENX) -#endif - -#ifdef UEINT - DEFINE(UEINT) -#else - MISSING(UEINT) -#endif - -#ifdef UEINTX - DEFINE(UEINTX) -#else - MISSING(UEINTX) -#endif - -#ifdef UENUM - DEFINE(UENUM) -#else - MISSING(UENUM) -#endif - -#ifdef UERST - DEFINE(UERST) -#else - MISSING(UERST) -#endif - -#ifdef UESTA0X - DEFINE(UESTA0X) -#else - MISSING(UESTA0X) -#endif - -#ifdef UESTA1X - DEFINE(UESTA1X) -#else - MISSING(UESTA1X) -#endif - -#ifdef UHADDR - DEFINE(UHADDR) -#else - MISSING(UHADDR) -#endif - -#ifdef UHCON - DEFINE(UHCON) -#else - MISSING(UHCON) -#endif - -#ifdef UHCR - DEFINE(UHCR) -#else - MISSING(UHCR) -#endif - -#ifdef UHFLEN - DEFINE(UHFLEN) -#else - MISSING(UHFLEN) -#endif - -#ifdef UHFNUM - DEFINE(UHFNUM) -#else - MISSING(UHFNUM) -#endif - -#ifdef UHFNUMH - DEFINE(UHFNUMH) -#else - MISSING(UHFNUMH) -#endif - -#ifdef UHFNUML - DEFINE(UHFNUML) -#else - MISSING(UHFNUML) -#endif - -#ifdef UHIEN - DEFINE(UHIEN) -#else - MISSING(UHIEN) -#endif - -#ifdef UHINT - DEFINE(UHINT) -#else - MISSING(UHINT) -#endif - -#ifdef UHSR - DEFINE(UHSR) -#else - MISSING(UHSR) -#endif - -#ifdef UHWCON - DEFINE(UHWCON) -#else - MISSING(UHWCON) -#endif - -#ifdef UPBCHX - DEFINE(UPBCHX) -#else - MISSING(UPBCHX) -#endif - -#ifdef UPBCLX - DEFINE(UPBCLX) -#else - MISSING(UPBCLX) -#endif - -#ifdef UPBCX - DEFINE(UPBCX) -#else - MISSING(UPBCX) -#endif - -#ifdef UPBCXH - DEFINE(UPBCXH) -#else - MISSING(UPBCXH) -#endif - -#ifdef UPBCXL - DEFINE(UPBCXL) -#else - MISSING(UPBCXL) -#endif - -#ifdef UPCFG0X - DEFINE(UPCFG0X) -#else - MISSING(UPCFG0X) -#endif - -#ifdef UPCFG1X - DEFINE(UPCFG1X) -#else - MISSING(UPCFG1X) -#endif - -#ifdef UPCFG2X - DEFINE(UPCFG2X) -#else - MISSING(UPCFG2X) -#endif - -#ifdef UPCONX - DEFINE(UPCONX) -#else - MISSING(UPCONX) -#endif - -#ifdef UPCRX - DEFINE(UPCRX) -#else - MISSING(UPCRX) -#endif - -#ifdef UPDATX - DEFINE(UPDATX) -#else - MISSING(UPDATX) -#endif - -#ifdef UPERRX - DEFINE(UPERRX) -#else - MISSING(UPERRX) -#endif - -#ifdef UPIENX - DEFINE(UPIENX) -#else - MISSING(UPIENX) -#endif - -#ifdef UPINRQX - DEFINE(UPINRQX) -#else - MISSING(UPINRQX) -#endif - -#ifdef UPINT - DEFINE(UPINT) -#else - MISSING(UPINT) -#endif - -#ifdef UPINTX - DEFINE(UPINTX) -#else - MISSING(UPINTX) -#endif - -#ifdef UPNUM - DEFINE(UPNUM) -#else - MISSING(UPNUM) -#endif - -#ifdef UPOE - DEFINE(UPOE) -#else - MISSING(UPOE) -#endif - -#ifdef UPRST - DEFINE(UPRST) -#else - MISSING(UPRST) -#endif - -#ifdef UPSTAX - DEFINE(UPSTAX) -#else - MISSING(UPSTAX) -#endif - -#ifdef USARTC0_BAUDCTRLA - DEFINE(USARTC0_BAUDCTRLA) -#else - MISSING(USARTC0_BAUDCTRLA) -#endif - -#ifdef USARTC0_BAUDCTRLB - DEFINE(USARTC0_BAUDCTRLB) -#else - MISSING(USARTC0_BAUDCTRLB) -#endif - -#ifdef USARTC0_CTRLA - DEFINE(USARTC0_CTRLA) -#else - MISSING(USARTC0_CTRLA) -#endif - -#ifdef USARTC0_CTRLB - DEFINE(USARTC0_CTRLB) -#else - MISSING(USARTC0_CTRLB) -#endif - -#ifdef USARTC0_CTRLC - DEFINE(USARTC0_CTRLC) -#else - MISSING(USARTC0_CTRLC) -#endif - -#ifdef USARTC0_DATA - DEFINE(USARTC0_DATA) -#else - MISSING(USARTC0_DATA) -#endif - -#ifdef USARTC0_STATUS - DEFINE(USARTC0_STATUS) -#else - MISSING(USARTC0_STATUS) -#endif - -#ifdef USARTC1_BAUDCTRLA - DEFINE(USARTC1_BAUDCTRLA) -#else - MISSING(USARTC1_BAUDCTRLA) -#endif - -#ifdef USARTC1_BAUDCTRLB - DEFINE(USARTC1_BAUDCTRLB) -#else - MISSING(USARTC1_BAUDCTRLB) -#endif - -#ifdef USARTC1_CTRLA - DEFINE(USARTC1_CTRLA) -#else - MISSING(USARTC1_CTRLA) -#endif - -#ifdef USARTC1_CTRLB - DEFINE(USARTC1_CTRLB) -#else - MISSING(USARTC1_CTRLB) -#endif - -#ifdef USARTC1_CTRLC - DEFINE(USARTC1_CTRLC) -#else - MISSING(USARTC1_CTRLC) -#endif - -#ifdef USARTC1_DATA - DEFINE(USARTC1_DATA) -#else - MISSING(USARTC1_DATA) -#endif - -#ifdef USARTC1_STATUS - DEFINE(USARTC1_STATUS) -#else - MISSING(USARTC1_STATUS) -#endif - -#ifdef USARTD0_BAUDCTRLA - DEFINE(USARTD0_BAUDCTRLA) -#else - MISSING(USARTD0_BAUDCTRLA) -#endif - -#ifdef USARTD0_BAUDCTRLB - DEFINE(USARTD0_BAUDCTRLB) -#else - MISSING(USARTD0_BAUDCTRLB) -#endif - -#ifdef USARTD0_CTRLA - DEFINE(USARTD0_CTRLA) -#else - MISSING(USARTD0_CTRLA) -#endif - -#ifdef USARTD0_CTRLB - DEFINE(USARTD0_CTRLB) -#else - MISSING(USARTD0_CTRLB) -#endif - -#ifdef USARTD0_CTRLC - DEFINE(USARTD0_CTRLC) -#else - MISSING(USARTD0_CTRLC) -#endif - -#ifdef USARTD0_DATA - DEFINE(USARTD0_DATA) -#else - MISSING(USARTD0_DATA) -#endif - -#ifdef USARTD0_STATUS - DEFINE(USARTD0_STATUS) -#else - MISSING(USARTD0_STATUS) -#endif - -#ifdef USARTD1_BAUDCTRLA - DEFINE(USARTD1_BAUDCTRLA) -#else - MISSING(USARTD1_BAUDCTRLA) -#endif - -#ifdef USARTD1_BAUDCTRLB - DEFINE(USARTD1_BAUDCTRLB) -#else - MISSING(USARTD1_BAUDCTRLB) -#endif - -#ifdef USARTD1_CTRLA - DEFINE(USARTD1_CTRLA) -#else - MISSING(USARTD1_CTRLA) -#endif - -#ifdef USARTD1_CTRLB - DEFINE(USARTD1_CTRLB) -#else - MISSING(USARTD1_CTRLB) -#endif - -#ifdef USARTD1_CTRLC - DEFINE(USARTD1_CTRLC) -#else - MISSING(USARTD1_CTRLC) -#endif - -#ifdef USARTD1_DATA - DEFINE(USARTD1_DATA) -#else - MISSING(USARTD1_DATA) -#endif - -#ifdef USARTD1_STATUS - DEFINE(USARTD1_STATUS) -#else - MISSING(USARTD1_STATUS) -#endif - -#ifdef USARTE0_BAUDCTRLA - DEFINE(USARTE0_BAUDCTRLA) -#else - MISSING(USARTE0_BAUDCTRLA) -#endif - -#ifdef USARTE0_BAUDCTRLB - DEFINE(USARTE0_BAUDCTRLB) -#else - MISSING(USARTE0_BAUDCTRLB) -#endif - -#ifdef USARTE0_CTRLA - DEFINE(USARTE0_CTRLA) -#else - MISSING(USARTE0_CTRLA) -#endif - -#ifdef USARTE0_CTRLB - DEFINE(USARTE0_CTRLB) -#else - MISSING(USARTE0_CTRLB) -#endif - -#ifdef USARTE0_CTRLC - DEFINE(USARTE0_CTRLC) -#else - MISSING(USARTE0_CTRLC) -#endif - -#ifdef USARTE0_DATA - DEFINE(USARTE0_DATA) -#else - MISSING(USARTE0_DATA) -#endif - -#ifdef USARTE0_STATUS - DEFINE(USARTE0_STATUS) -#else - MISSING(USARTE0_STATUS) -#endif - -#ifdef USARTE1_BAUDCTRLA - DEFINE(USARTE1_BAUDCTRLA) -#else - MISSING(USARTE1_BAUDCTRLA) -#endif - -#ifdef USARTE1_BAUDCTRLB - DEFINE(USARTE1_BAUDCTRLB) -#else - MISSING(USARTE1_BAUDCTRLB) -#endif - -#ifdef USARTE1_CTRLA - DEFINE(USARTE1_CTRLA) -#else - MISSING(USARTE1_CTRLA) -#endif - -#ifdef USARTE1_CTRLB - DEFINE(USARTE1_CTRLB) -#else - MISSING(USARTE1_CTRLB) -#endif - -#ifdef USARTE1_CTRLC - DEFINE(USARTE1_CTRLC) -#else - MISSING(USARTE1_CTRLC) -#endif - -#ifdef USARTE1_DATA - DEFINE(USARTE1_DATA) -#else - MISSING(USARTE1_DATA) -#endif - -#ifdef USARTE1_STATUS - DEFINE(USARTE1_STATUS) -#else - MISSING(USARTE1_STATUS) -#endif - -#ifdef USARTF0_BAUDCTRLA - DEFINE(USARTF0_BAUDCTRLA) -#else - MISSING(USARTF0_BAUDCTRLA) -#endif - -#ifdef USARTF0_BAUDCTRLB - DEFINE(USARTF0_BAUDCTRLB) -#else - MISSING(USARTF0_BAUDCTRLB) -#endif - -#ifdef USARTF0_CTRLA - DEFINE(USARTF0_CTRLA) -#else - MISSING(USARTF0_CTRLA) -#endif - -#ifdef USARTF0_CTRLB - DEFINE(USARTF0_CTRLB) -#else - MISSING(USARTF0_CTRLB) -#endif - -#ifdef USARTF0_CTRLC - DEFINE(USARTF0_CTRLC) -#else - MISSING(USARTF0_CTRLC) -#endif - -#ifdef USARTF0_DATA - DEFINE(USARTF0_DATA) -#else - MISSING(USARTF0_DATA) -#endif - -#ifdef USARTF0_STATUS - DEFINE(USARTF0_STATUS) -#else - MISSING(USARTF0_STATUS) -#endif - -#ifdef USARTF1_BAUDCTRLA - DEFINE(USARTF1_BAUDCTRLA) -#else - MISSING(USARTF1_BAUDCTRLA) -#endif - -#ifdef USARTF1_BAUDCTRLB - DEFINE(USARTF1_BAUDCTRLB) -#else - MISSING(USARTF1_BAUDCTRLB) -#endif - -#ifdef USARTF1_CTRLA - DEFINE(USARTF1_CTRLA) -#else - MISSING(USARTF1_CTRLA) -#endif - -#ifdef USARTF1_CTRLB - DEFINE(USARTF1_CTRLB) -#else - MISSING(USARTF1_CTRLB) -#endif - -#ifdef USARTF1_CTRLC - DEFINE(USARTF1_CTRLC) -#else - MISSING(USARTF1_CTRLC) -#endif - -#ifdef USARTF1_DATA - DEFINE(USARTF1_DATA) -#else - MISSING(USARTF1_DATA) -#endif - -#ifdef USARTF1_STATUS - DEFINE(USARTF1_STATUS) -#else - MISSING(USARTF1_STATUS) -#endif - -#ifdef USBCON - DEFINE(USBCON) -#else - MISSING(USBCON) -#endif - -#ifdef USBCR - DEFINE(USBCR) -#else - MISSING(USBCR) -#endif - -#ifdef USBCSEX - DEFINE(USBCSEX) -#else - MISSING(USBCSEX) -#endif - -#ifdef USBDBCEX - DEFINE(USBDBCEX) -#else - MISSING(USBDBCEX) -#endif - -#ifdef USBDMAB - DEFINE(USBDMAB) -#else - MISSING(USBDMAB) -#endif - -#ifdef USBDMACS - DEFINE(USBDMACS) -#else - MISSING(USBDMACS) -#endif - -#ifdef USBDMAD - DEFINE(USBDMAD) -#else - MISSING(USBDMAD) -#endif - -#ifdef USBDMADH - DEFINE(USBDMADH) -#else - MISSING(USBDMADH) -#endif - -#ifdef USBDMADL - DEFINE(USBDMADL) -#else - MISSING(USBDMADL) -#endif - -#ifdef USBEI - DEFINE(USBEI) -#else - MISSING(USBEI) -#endif - -#ifdef USBEIM - DEFINE(USBEIM) -#else - MISSING(USBEIM) -#endif - -#ifdef USBENUM - DEFINE(USBENUM) -#else - MISSING(USBENUM) -#endif - -#ifdef USBFA - DEFINE(USBFA) -#else - MISSING(USBFA) -#endif - -#ifdef USBFCEX - DEFINE(USBFCEX) -#else - MISSING(USBFCEX) -#endif - -#ifdef USBFN - DEFINE(USBFN) -#else - MISSING(USBFN) -#endif - -#ifdef USBFNH - DEFINE(USBFNH) -#else - MISSING(USBFNH) -#endif - -#ifdef USBFNL - DEFINE(USBFNL) -#else - MISSING(USBFNL) -#endif - -#ifdef USBGS - DEFINE(USBGS) -#else - MISSING(USBGS) -#endif - -#ifdef USBINT - DEFINE(USBINT) -#else - MISSING(USBINT) -#endif - -#ifdef USBPI - DEFINE(USBPI) -#else - MISSING(USBPI) -#endif - -#ifdef USBPIM - DEFINE(USBPIM) -#else - MISSING(USBPIM) -#endif - -#ifdef USBRSTE - DEFINE(USBRSTE) -#else - MISSING(USBRSTE) -#endif - -#ifdef USBSTA - DEFINE(USBSTA) -#else - MISSING(USBSTA) -#endif - -#ifdef USB_ADDR - DEFINE(USB_ADDR) -#else - MISSING(USB_ADDR) -#endif - -#ifdef USB_CAL0 - DEFINE(USB_CAL0) -#else - MISSING(USB_CAL0) -#endif - -#ifdef USB_CAL1 - DEFINE(USB_CAL1) -#else - MISSING(USB_CAL1) -#endif - -#ifdef USB_CTRLA - DEFINE(USB_CTRLA) -#else - MISSING(USB_CTRLA) -#endif - -#ifdef USB_CTRLB - DEFINE(USB_CTRLB) -#else - MISSING(USB_CTRLB) -#endif - -#ifdef USB_EPPTR - DEFINE(USB_EPPTR) -#else - MISSING(USB_EPPTR) -#endif - -#ifdef USB_EP_TABLE_EP0IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP0IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP0IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP0IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP0IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP0IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_CNTH - DEFINE(USB_EP_TABLE_EP0IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP0IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP0IN_CNTL - DEFINE(USB_EP_TABLE_EP0IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP0IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_CTRL - DEFINE(USB_EP_TABLE_EP0IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP0IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP0IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP0IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP0IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP0IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP0IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP0IN_STATUS - DEFINE(USB_EP_TABLE_EP0IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP0IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP0OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP0OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP0OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_CNTH - DEFINE(USB_EP_TABLE_EP0OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP0OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_CNTL - DEFINE(USB_EP_TABLE_EP0OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP0OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_CTRL - DEFINE(USB_EP_TABLE_EP0OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP0OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP0OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP0OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP0OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP0OUT_STATUS - DEFINE(USB_EP_TABLE_EP0OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP0OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP10IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP10IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP10IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP10IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP10IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP10IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_CNTH - DEFINE(USB_EP_TABLE_EP10IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP10IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP10IN_CNTL - DEFINE(USB_EP_TABLE_EP10IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP10IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_CTRL - DEFINE(USB_EP_TABLE_EP10IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP10IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP10IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP10IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP10IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP10IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP10IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP10IN_STATUS - DEFINE(USB_EP_TABLE_EP10IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP10IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP10OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP10OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP10OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_CNTH - DEFINE(USB_EP_TABLE_EP10OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP10OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_CNTL - DEFINE(USB_EP_TABLE_EP10OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP10OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_CTRL - DEFINE(USB_EP_TABLE_EP10OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP10OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP10OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP10OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP10OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP10OUT_STATUS - DEFINE(USB_EP_TABLE_EP10OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP10OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP11IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP11IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP11IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP11IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP11IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP11IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_CNTH - DEFINE(USB_EP_TABLE_EP11IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP11IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP11IN_CNTL - DEFINE(USB_EP_TABLE_EP11IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP11IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_CTRL - DEFINE(USB_EP_TABLE_EP11IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP11IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP11IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP11IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP11IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP11IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP11IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP11IN_STATUS - DEFINE(USB_EP_TABLE_EP11IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP11IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP11OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP11OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP11OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_CNTH - DEFINE(USB_EP_TABLE_EP11OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP11OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_CNTL - DEFINE(USB_EP_TABLE_EP11OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP11OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_CTRL - DEFINE(USB_EP_TABLE_EP11OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP11OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP11OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP11OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP11OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP11OUT_STATUS - DEFINE(USB_EP_TABLE_EP11OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP11OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP12IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP12IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP12IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP12IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP12IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP12IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_CNTH - DEFINE(USB_EP_TABLE_EP12IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP12IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP12IN_CNTL - DEFINE(USB_EP_TABLE_EP12IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP12IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_CTRL - DEFINE(USB_EP_TABLE_EP12IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP12IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP12IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP12IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP12IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP12IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP12IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP12IN_STATUS - DEFINE(USB_EP_TABLE_EP12IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP12IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP12OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP12OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP12OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_CNTH - DEFINE(USB_EP_TABLE_EP12OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP12OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_CNTL - DEFINE(USB_EP_TABLE_EP12OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP12OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_CTRL - DEFINE(USB_EP_TABLE_EP12OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP12OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP12OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP12OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP12OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP12OUT_STATUS - DEFINE(USB_EP_TABLE_EP12OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP12OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP13IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP13IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP13IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP13IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP13IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP13IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_CNTH - DEFINE(USB_EP_TABLE_EP13IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP13IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP13IN_CNTL - DEFINE(USB_EP_TABLE_EP13IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP13IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_CTRL - DEFINE(USB_EP_TABLE_EP13IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP13IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP13IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP13IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP13IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP13IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP13IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP13IN_STATUS - DEFINE(USB_EP_TABLE_EP13IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP13IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP13OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP13OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP13OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_CNTH - DEFINE(USB_EP_TABLE_EP13OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP13OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_CNTL - DEFINE(USB_EP_TABLE_EP13OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP13OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_CTRL - DEFINE(USB_EP_TABLE_EP13OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP13OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP13OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP13OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP13OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP13OUT_STATUS - DEFINE(USB_EP_TABLE_EP13OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP13OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP14IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP14IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP14IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP14IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP14IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP14IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_CNTH - DEFINE(USB_EP_TABLE_EP14IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP14IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP14IN_CNTL - DEFINE(USB_EP_TABLE_EP14IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP14IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_CTRL - DEFINE(USB_EP_TABLE_EP14IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP14IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP14IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP14IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP14IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP14IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP14IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP14IN_STATUS - DEFINE(USB_EP_TABLE_EP14IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP14IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP14OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP14OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP14OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_CNTH - DEFINE(USB_EP_TABLE_EP14OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP14OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_CNTL - DEFINE(USB_EP_TABLE_EP14OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP14OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_CTRL - DEFINE(USB_EP_TABLE_EP14OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP14OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP14OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP14OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP14OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP14OUT_STATUS - DEFINE(USB_EP_TABLE_EP14OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP14OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP15IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP15IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP15IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP15IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP15IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP15IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_CNTH - DEFINE(USB_EP_TABLE_EP15IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP15IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP15IN_CNTL - DEFINE(USB_EP_TABLE_EP15IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP15IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_CTRL - DEFINE(USB_EP_TABLE_EP15IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP15IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP15IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP15IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP15IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP15IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP15IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP15IN_STATUS - DEFINE(USB_EP_TABLE_EP15IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP15IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP15OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP15OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP15OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_CNTH - DEFINE(USB_EP_TABLE_EP15OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP15OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_CNTL - DEFINE(USB_EP_TABLE_EP15OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP15OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_CTRL - DEFINE(USB_EP_TABLE_EP15OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP15OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP15OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP15OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP15OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP15OUT_STATUS - DEFINE(USB_EP_TABLE_EP15OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP15OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP1IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP1IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP1IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP1IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP1IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP1IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_CNTH - DEFINE(USB_EP_TABLE_EP1IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP1IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP1IN_CNTL - DEFINE(USB_EP_TABLE_EP1IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP1IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_CTRL - DEFINE(USB_EP_TABLE_EP1IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP1IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP1IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP1IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP1IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP1IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP1IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP1IN_STATUS - DEFINE(USB_EP_TABLE_EP1IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP1IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP1OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP1OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP1OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_CNTH - DEFINE(USB_EP_TABLE_EP1OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP1OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_CNTL - DEFINE(USB_EP_TABLE_EP1OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP1OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_CTRL - DEFINE(USB_EP_TABLE_EP1OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP1OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP1OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP1OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP1OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP1OUT_STATUS - DEFINE(USB_EP_TABLE_EP1OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP1OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP2IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP2IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP2IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP2IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP2IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP2IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_CNTH - DEFINE(USB_EP_TABLE_EP2IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP2IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP2IN_CNTL - DEFINE(USB_EP_TABLE_EP2IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP2IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_CTRL - DEFINE(USB_EP_TABLE_EP2IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP2IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP2IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP2IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP2IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP2IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP2IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP2IN_STATUS - DEFINE(USB_EP_TABLE_EP2IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP2IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP2OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP2OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP2OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_CNTH - DEFINE(USB_EP_TABLE_EP2OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP2OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_CNTL - DEFINE(USB_EP_TABLE_EP2OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP2OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_CTRL - DEFINE(USB_EP_TABLE_EP2OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP2OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP2OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP2OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP2OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP2OUT_STATUS - DEFINE(USB_EP_TABLE_EP2OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP2OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP3IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP3IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP3IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP3IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP3IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP3IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_CNTH - DEFINE(USB_EP_TABLE_EP3IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP3IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP3IN_CNTL - DEFINE(USB_EP_TABLE_EP3IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP3IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_CTRL - DEFINE(USB_EP_TABLE_EP3IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP3IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP3IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP3IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP3IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP3IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP3IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP3IN_STATUS - DEFINE(USB_EP_TABLE_EP3IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP3IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP3OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP3OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP3OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_CNTH - DEFINE(USB_EP_TABLE_EP3OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP3OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_CNTL - DEFINE(USB_EP_TABLE_EP3OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP3OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_CTRL - DEFINE(USB_EP_TABLE_EP3OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP3OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP3OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP3OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP3OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP3OUT_STATUS - DEFINE(USB_EP_TABLE_EP3OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP3OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP4IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP4IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP4IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP4IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP4IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP4IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_CNTH - DEFINE(USB_EP_TABLE_EP4IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP4IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP4IN_CNTL - DEFINE(USB_EP_TABLE_EP4IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP4IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_CTRL - DEFINE(USB_EP_TABLE_EP4IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP4IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP4IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP4IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP4IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP4IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP4IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP4IN_STATUS - DEFINE(USB_EP_TABLE_EP4IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP4IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP4OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP4OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP4OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_CNTH - DEFINE(USB_EP_TABLE_EP4OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP4OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_CNTL - DEFINE(USB_EP_TABLE_EP4OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP4OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_CTRL - DEFINE(USB_EP_TABLE_EP4OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP4OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP4OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP4OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP4OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP4OUT_STATUS - DEFINE(USB_EP_TABLE_EP4OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP4OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP5IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP5IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP5IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP5IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP5IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP5IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_CNTH - DEFINE(USB_EP_TABLE_EP5IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP5IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP5IN_CNTL - DEFINE(USB_EP_TABLE_EP5IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP5IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_CTRL - DEFINE(USB_EP_TABLE_EP5IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP5IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP5IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP5IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP5IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP5IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP5IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP5IN_STATUS - DEFINE(USB_EP_TABLE_EP5IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP5IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP5OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP5OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP5OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_CNTH - DEFINE(USB_EP_TABLE_EP5OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP5OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_CNTL - DEFINE(USB_EP_TABLE_EP5OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP5OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_CTRL - DEFINE(USB_EP_TABLE_EP5OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP5OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP5OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP5OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP5OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP5OUT_STATUS - DEFINE(USB_EP_TABLE_EP5OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP5OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP6IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP6IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP6IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP6IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP6IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP6IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_CNTH - DEFINE(USB_EP_TABLE_EP6IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP6IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP6IN_CNTL - DEFINE(USB_EP_TABLE_EP6IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP6IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_CTRL - DEFINE(USB_EP_TABLE_EP6IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP6IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP6IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP6IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP6IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP6IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP6IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP6IN_STATUS - DEFINE(USB_EP_TABLE_EP6IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP6IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP6OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP6OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP6OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_CNTH - DEFINE(USB_EP_TABLE_EP6OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP6OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_CNTL - DEFINE(USB_EP_TABLE_EP6OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP6OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_CTRL - DEFINE(USB_EP_TABLE_EP6OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP6OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP6OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP6OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP6OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP6OUT_STATUS - DEFINE(USB_EP_TABLE_EP6OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP6OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP7IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP7IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP7IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP7IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP7IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP7IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_CNTH - DEFINE(USB_EP_TABLE_EP7IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP7IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP7IN_CNTL - DEFINE(USB_EP_TABLE_EP7IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP7IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_CTRL - DEFINE(USB_EP_TABLE_EP7IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP7IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP7IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP7IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP7IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP7IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP7IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP7IN_STATUS - DEFINE(USB_EP_TABLE_EP7IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP7IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP7OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP7OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP7OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_CNTH - DEFINE(USB_EP_TABLE_EP7OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP7OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_CNTL - DEFINE(USB_EP_TABLE_EP7OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP7OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_CTRL - DEFINE(USB_EP_TABLE_EP7OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP7OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP7OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP7OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP7OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP7OUT_STATUS - DEFINE(USB_EP_TABLE_EP7OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP7OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP8IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP8IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP8IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP8IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP8IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP8IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_CNTH - DEFINE(USB_EP_TABLE_EP8IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP8IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP8IN_CNTL - DEFINE(USB_EP_TABLE_EP8IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP8IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_CTRL - DEFINE(USB_EP_TABLE_EP8IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP8IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP8IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP8IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP8IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP8IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP8IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP8IN_STATUS - DEFINE(USB_EP_TABLE_EP8IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP8IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP8OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP8OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP8OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_CNTH - DEFINE(USB_EP_TABLE_EP8OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP8OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_CNTL - DEFINE(USB_EP_TABLE_EP8OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP8OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_CTRL - DEFINE(USB_EP_TABLE_EP8OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP8OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP8OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP8OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP8OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP8OUT_STATUS - DEFINE(USB_EP_TABLE_EP8OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP8OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP9IN_AUXDATAH - DEFINE(USB_EP_TABLE_EP9IN_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP9IN_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP9IN_AUXDATAL - DEFINE(USB_EP_TABLE_EP9IN_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP9IN_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_CNTH - DEFINE(USB_EP_TABLE_EP9IN_CNTH) -#else - MISSING(USB_EP_TABLE_EP9IN_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP9IN_CNTL - DEFINE(USB_EP_TABLE_EP9IN_CNTL) -#else - MISSING(USB_EP_TABLE_EP9IN_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_CTRL - DEFINE(USB_EP_TABLE_EP9IN_CTRL) -#else - MISSING(USB_EP_TABLE_EP9IN_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_DATAPTRH - DEFINE(USB_EP_TABLE_EP9IN_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP9IN_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP9IN_DATAPTRL - DEFINE(USB_EP_TABLE_EP9IN_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP9IN_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP9IN_STATUS - DEFINE(USB_EP_TABLE_EP9IN_STATUS) -#else - MISSING(USB_EP_TABLE_EP9IN_STATUS) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_AUXDATAH - DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAH) -#else - MISSING(USB_EP_TABLE_EP9OUT_AUXDATAH) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_AUXDATAL - DEFINE(USB_EP_TABLE_EP9OUT_AUXDATAL) -#else - MISSING(USB_EP_TABLE_EP9OUT_AUXDATAL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_CNTH - DEFINE(USB_EP_TABLE_EP9OUT_CNTH) -#else - MISSING(USB_EP_TABLE_EP9OUT_CNTH) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_CNTL - DEFINE(USB_EP_TABLE_EP9OUT_CNTL) -#else - MISSING(USB_EP_TABLE_EP9OUT_CNTL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_CTRL - DEFINE(USB_EP_TABLE_EP9OUT_CTRL) -#else - MISSING(USB_EP_TABLE_EP9OUT_CTRL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_DATAPTRH - DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRH) -#else - MISSING(USB_EP_TABLE_EP9OUT_DATAPTRH) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_DATAPTRL - DEFINE(USB_EP_TABLE_EP9OUT_DATAPTRL) -#else - MISSING(USB_EP_TABLE_EP9OUT_DATAPTRL) -#endif - -#ifdef USB_EP_TABLE_EP9OUT_STATUS - DEFINE(USB_EP_TABLE_EP9OUT_STATUS) -#else - MISSING(USB_EP_TABLE_EP9OUT_STATUS) -#endif - -#ifdef USB_EP_TABLE_FRAMENUMH - DEFINE(USB_EP_TABLE_FRAMENUMH) -#else - MISSING(USB_EP_TABLE_FRAMENUMH) -#endif - -#ifdef USB_EP_TABLE_FRAMENUML - DEFINE(USB_EP_TABLE_FRAMENUML) -#else - MISSING(USB_EP_TABLE_FRAMENUML) -#endif - -#ifdef USB_FIFORP - DEFINE(USB_FIFORP) -#else - MISSING(USB_FIFORP) -#endif - -#ifdef USB_FIFOWP - DEFINE(USB_FIFOWP) -#else - MISSING(USB_FIFOWP) -#endif - -#ifdef USB_INTCTRLA - DEFINE(USB_INTCTRLA) -#else - MISSING(USB_INTCTRLA) -#endif - -#ifdef USB_INTCTRLB - DEFINE(USB_INTCTRLB) -#else - MISSING(USB_INTCTRLB) -#endif - -#ifdef USB_INTFLAGSACLR - DEFINE(USB_INTFLAGSACLR) -#else - MISSING(USB_INTFLAGSACLR) -#endif - -#ifdef USB_INTFLAGSASET - DEFINE(USB_INTFLAGSASET) -#else - MISSING(USB_INTFLAGSASET) -#endif - -#ifdef USB_INTFLAGSBCLR - DEFINE(USB_INTFLAGSBCLR) -#else - MISSING(USB_INTFLAGSBCLR) -#endif - -#ifdef USB_INTFLAGSBSET - DEFINE(USB_INTFLAGSBSET) -#else - MISSING(USB_INTFLAGSBSET) -#endif - -#ifdef USB_STATUS - DEFINE(USB_STATUS) -#else - MISSING(USB_STATUS) -#endif - -#ifdef USIBR - DEFINE(USIBR) -#else - MISSING(USIBR) -#endif - -#ifdef USICR - DEFINE(USICR) -#else - MISSING(USICR) -#endif - -#ifdef USIDR - DEFINE(USIDR) -#else - MISSING(USIDR) -#endif - -#ifdef USIPP - DEFINE(USIPP) -#else - MISSING(USIPP) -#endif - -#ifdef USISR - DEFINE(USISR) -#else - MISSING(USISR) -#endif - -#ifdef USPCR - DEFINE(USPCR) -#else - MISSING(USPCR) -#endif - -#ifdef USPDR - DEFINE(USPDR) -#else - MISSING(USPDR) -#endif - -#ifdef USPSR - DEFINE(USPSR) -#else - MISSING(USPSR) -#endif - -#ifdef USR - DEFINE(USR) -#else - MISSING(USR) -#endif - -#ifdef VADAC0 - DEFINE(VADAC0) -#else - MISSING(VADAC0) -#endif - -#ifdef VADAC1 - DEFINE(VADAC1) -#else - MISSING(VADAC1) -#endif - -#ifdef VADAC2 - DEFINE(VADAC2) -#else - MISSING(VADAC2) -#endif - -#ifdef VADAC3 - DEFINE(VADAC3) -#else - MISSING(VADAC3) -#endif - -#ifdef VADC - DEFINE(VADC) -#else - MISSING(VADC) -#endif - -#ifdef VADCH - DEFINE(VADCH) -#else - MISSING(VADCH) -#endif - -#ifdef VADCL - DEFINE(VADCL) -#else - MISSING(VADCL) -#endif - -#ifdef VADCSR - DEFINE(VADCSR) -#else - MISSING(VADCSR) -#endif - -#ifdef VADIC - DEFINE(VADIC) -#else - MISSING(VADIC) -#endif - -#ifdef VADICH - DEFINE(VADICH) -#else - MISSING(VADICH) -#endif - -#ifdef VADICL - DEFINE(VADICL) -#else - MISSING(VADICL) -#endif - -#ifdef VADMUX - DEFINE(VADMUX) -#else - MISSING(VADMUX) -#endif - -#ifdef VBAT_BACKUP0 - DEFINE(VBAT_BACKUP0) -#else - MISSING(VBAT_BACKUP0) -#endif - -#ifdef VBAT_BACKUP1 - DEFINE(VBAT_BACKUP1) -#else - MISSING(VBAT_BACKUP1) -#endif - -#ifdef VBAT_CTRL - DEFINE(VBAT_CTRL) -#else - MISSING(VBAT_CTRL) -#endif - -#ifdef VBAT_STATUS - DEFINE(VBAT_STATUS) -#else - MISSING(VBAT_STATUS) -#endif - -#ifdef VCOTUNE - DEFINE(VCOTUNE) -#else - MISSING(VCOTUNE) -#endif - -#ifdef VELACC1 - DEFINE(VELACC1) -#else - MISSING(VELACC1) -#endif - -#ifdef VELACC2 - DEFINE(VELACC2) -#else - MISSING(VELACC2) -#endif - -#ifdef VELACC3 - DEFINE(VELACC3) -#else - MISSING(VELACC3) -#endif - -#ifdef VELCVEL - DEFINE(VELCVEL) -#else - MISSING(VELCVEL) -#endif - -#ifdef VELDEC1 - DEFINE(VELDEC1) -#else - MISSING(VELDEC1) -#endif - -#ifdef VELDEC2 - DEFINE(VELDEC2) -#else - MISSING(VELDEC2) -#endif - -#ifdef VELDEC3 - DEFINE(VELDEC3) -#else - MISSING(VELDEC3) -#endif - -#ifdef VELHI1 - DEFINE(VELHI1) -#else - MISSING(VELHI1) -#endif - -#ifdef VELHI2 - DEFINE(VELHI2) -#else - MISSING(VELHI2) -#endif - -#ifdef VELHI3 - DEFINE(VELHI3) -#else - MISSING(VELHI3) -#endif - -#ifdef VELIFLG - DEFINE(VELIFLG) -#else - MISSING(VELIFLG) -#endif - -#ifdef VELIMSK - DEFINE(VELIMSK) -#else - MISSING(VELIMSK) -#endif - -#ifdef VELLOW1 - DEFINE(VELLOW1) -#else - MISSING(VELLOW1) -#endif - -#ifdef VELLOW2 - DEFINE(VELLOW2) -#else - MISSING(VELLOW2) -#endif - -#ifdef VELLOW3 - DEFINE(VELLOW3) -#else - MISSING(VELLOW3) -#endif - -#ifdef VELSTB - DEFINE(VELSTB) -#else - MISSING(VELSTB) -#endif - -#ifdef VELTVEL - DEFINE(VELTVEL) -#else - MISSING(VELTVEL) -#endif - -#ifdef VELVGCTL - DEFINE(VELVGCTL) -#else - MISSING(VELVGCTL) -#endif - -#ifdef VERSION_NUM - DEFINE(VERSION_NUM) -#else - MISSING(VERSION_NUM) -#endif - -#ifdef VLMCSR - DEFINE(VLMCSR) -#else - MISSING(VLMCSR) -#endif - -#ifdef VMCSR - DEFINE(VMCSR) -#else - MISSING(VMCSR) -#endif - -#ifdef VPORT0_DIR - DEFINE(VPORT0_DIR) -#else - MISSING(VPORT0_DIR) -#endif - -#ifdef VPORT0_IN - DEFINE(VPORT0_IN) -#else - MISSING(VPORT0_IN) -#endif - -#ifdef VPORT0_INTFLAGS - DEFINE(VPORT0_INTFLAGS) -#else - MISSING(VPORT0_INTFLAGS) -#endif - -#ifdef VPORT0_OUT - DEFINE(VPORT0_OUT) -#else - MISSING(VPORT0_OUT) -#endif - -#ifdef VPORT1_DIR - DEFINE(VPORT1_DIR) -#else - MISSING(VPORT1_DIR) -#endif - -#ifdef VPORT1_IN - DEFINE(VPORT1_IN) -#else - MISSING(VPORT1_IN) -#endif - -#ifdef VPORT1_INTFLAGS - DEFINE(VPORT1_INTFLAGS) -#else - MISSING(VPORT1_INTFLAGS) -#endif - -#ifdef VPORT1_OUT - DEFINE(VPORT1_OUT) -#else - MISSING(VPORT1_OUT) -#endif - -#ifdef VPORT2_DIR - DEFINE(VPORT2_DIR) -#else - MISSING(VPORT2_DIR) -#endif - -#ifdef VPORT2_IN - DEFINE(VPORT2_IN) -#else - MISSING(VPORT2_IN) -#endif - -#ifdef VPORT2_INTFLAGS - DEFINE(VPORT2_INTFLAGS) -#else - MISSING(VPORT2_INTFLAGS) -#endif - -#ifdef VPORT2_OUT - DEFINE(VPORT2_OUT) -#else - MISSING(VPORT2_OUT) -#endif - -#ifdef VPORT3_DIR - DEFINE(VPORT3_DIR) -#else - MISSING(VPORT3_DIR) -#endif - -#ifdef VPORT3_IN - DEFINE(VPORT3_IN) -#else - MISSING(VPORT3_IN) -#endif - -#ifdef VPORT3_INTFLAGS - DEFINE(VPORT3_INTFLAGS) -#else - MISSING(VPORT3_INTFLAGS) -#endif - -#ifdef VPORT3_OUT - DEFINE(VPORT3_OUT) -#else - MISSING(VPORT3_OUT) -#endif - -#ifdef VREG_CTRL - DEFINE(VREG_CTRL) -#else - MISSING(VREG_CTRL) -#endif - -#ifdef WDTCKD - DEFINE(WDTCKD) -#else - MISSING(WDTCKD) -#endif - -#ifdef WDTCLR - DEFINE(WDTCLR) -#else - MISSING(WDTCLR) -#endif - -#ifdef WDTCR - DEFINE(WDTCR) -#else - MISSING(WDTCR) -#endif - -#ifdef WDTCSR - DEFINE(WDTCSR) -#else - MISSING(WDTCSR) -#endif - -#ifdef WDT_CTRL - DEFINE(WDT_CTRL) -#else - MISSING(WDT_CTRL) -#endif - -#ifdef WDT_STATUS - DEFINE(WDT_STATUS) -#else - MISSING(WDT_STATUS) -#endif - -#ifdef WDT_WINCTRL - DEFINE(WDT_WINCTRL) -#else - MISSING(WDT_WINCTRL) -#endif - -#ifdef WUTCSR - DEFINE(WUTCSR) -#else - MISSING(WUTCSR) -#endif - -#ifdef XAH_CTRL_0 - DEFINE(XAH_CTRL_0) -#else - MISSING(XAH_CTRL_0) -#endif - -#ifdef XAH_CTRL_1 - DEFINE(XAH_CTRL_1) -#else - MISSING(XAH_CTRL_1) -#endif - -#ifdef XDIV - DEFINE(XDIV) -#else - MISSING(XDIV) -#endif - -#ifdef XMCRA - DEFINE(XMCRA) -#else - MISSING(XMCRA) -#endif - -#ifdef XMCRB - DEFINE(XMCRB) -#else - MISSING(XMCRB) -#endif - -#ifdef XOSC_CTRL - DEFINE(XOSC_CTRL) -#else - MISSING(XOSC_CTRL) -#endif diff --git a/generated_intdefs.h b/generated_intdefs.h deleted file mode 100644 index 0e14d7d..0000000 --- a/generated_intdefs.h +++ /dev/null @@ -1,69 +0,0 @@ - -// Generated file, do not edit! - -#define LONGEST_STRING_IN_INTDEFS_H 20 - - -#ifdef NUM_DIGITAL_PINS - DEFINE(NUM_DIGITAL_PINS) -#endif - -#ifdef RAMSTART - DEFINE(RAMSTART) -#endif - -#ifdef RAMEND - DEFINE(RAMEND) -#endif - -#ifdef XRAMEND - DEFINE(XRAMEND) -#endif - -#ifdef E2END - DEFINE(E2END) -#endif - -#ifdef FLASHEND - DEFINE(FLASHEND) -#endif - -#ifdef SPM_PAGESIZE - DEFINE(SPM_PAGESIZE) -#endif - -#ifdef E2PAGESIZE - DEFINE(E2PAGESIZE) -#endif - -#ifdef F_CPU - DEFINE(F_CPU) -#endif - -#ifdef ARDUINO - DEFINE(ARDUINO) -#endif - -#ifdef __AVR_LIBC_DATE_ - DEFINE(__AVR_LIBC_DATE_) -#endif - -#ifdef __AVR_LIBC_VERSION__ - DEFINE(__AVR_LIBC_VERSION__) -#endif - -#ifdef IRAM0_ADDR - DEFINE(IRAM0_ADDR) -#endif - -#ifdef IRAM0_SIZE - DEFINE(IRAM0_SIZE) -#endif - -#ifdef IRAM1_ADDR - DEFINE(IRAM1_ADDR) -#endif - -#ifdef IRAM1_SIZE - DEFINE(IRAM1_SIZE) -#endif diff --git a/generated_mcu.h b/generated_mcu.h deleted file mode 100644 index 69ac374..0000000 --- a/generated_mcu.h +++ /dev/null @@ -1,1287 +0,0 @@ - -// this file was generated by codegen.py - -// __AVR_LIBC_VERSION_STRING__ = "1.8.0" -// __AVR_LIBC_DATE_STRING__ = "20111228" - - -#ifdef __AVR_AT43USB320__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT43USB320__" -#endif - -#ifdef __AVR_AT43USB355__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT43USB355__" -#endif - -#ifdef __AVR_AT76C711__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT76C711__" -#endif - -#ifdef __AVR_AT86RF401__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT86RF401__" -#endif - -#ifdef __AVR_AT90C8534__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90C8534__" -#endif - -#ifdef __AVR_AT90CAN128__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90CAN128__" -#endif - -#ifdef __AVR_AT90CAN32__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90CAN32__" -#endif - -#ifdef __AVR_AT90CAN64__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90CAN64__" -#endif - -#ifdef __AVR_AT90PWM1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM1__" -#endif - -#ifdef __AVR_AT90PWM216__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM216__" -#endif - -#ifdef __AVR_AT90PWM2B__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM2B__" -#endif - -#ifdef __AVR_AT90PWM2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM2__" -#endif - -#ifdef __AVR_AT90PWM316__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM316__" -#endif - -#ifdef __AVR_AT90PWM3B__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM3B__" -#endif - -#ifdef __AVR_AT90PWM3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM3__" -#endif - -#ifdef __AVR_AT90PWM81__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90PWM81__" -#endif - -#ifdef __AVR_AT90S1200__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S1200__" -#endif - -#ifdef __AVR_AT90S2313__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2313__" -#endif - -#ifdef __AVR_AT90S2323__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2323__" -#endif - -#ifdef __AVR_AT90S2333__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2333__" -#endif - -#ifdef __AVR_AT90S2343__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S2343__" -#endif - -#ifdef __AVR_AT90S4414__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S4414__" -#endif - -#ifdef __AVR_AT90S4433__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S4433__" -#endif - -#ifdef __AVR_AT90S4434__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S4434__" -#endif - -#ifdef __AVR_AT90S8515__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S8515__" -#endif - -#ifdef __AVR_AT90S8535__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90S8535__" -#endif - -#ifdef __AVR_AT90SCR100__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90SCR100__" -#endif - -#ifdef __AVR_AT90USB1286__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB1286__" -#endif - -#ifdef __AVR_AT90USB1287__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB1287__" -#endif - -#ifdef __AVR_AT90USB162__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB162__" -#endif - -#ifdef __AVR_AT90USB646__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB646__" -#endif - -#ifdef __AVR_AT90USB647__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB647__" -#endif - -#ifdef __AVR_AT90USB82__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT90USB82__" -#endif - -#ifdef __AVR_AT94K__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_AT94K__" -#endif - -#ifdef __AVR_ATA6289__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATA6289__" -#endif - -#ifdef __AVR_ATmega103__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega103__" -#endif - -#ifdef __AVR_ATmega1280__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega1280__" -#endif - -#ifdef __AVR_ATmega1281__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega1281__" -#endif - -#ifdef __AVR_ATmega1284P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega1284P__" -#endif - -#ifdef __AVR_ATmega128RFA1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega128RFA1__" -#endif - -#ifdef __AVR_ATmega128__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega128__" -#endif - -#ifdef __AVR_ATmega161__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega161__" -#endif - -#ifdef __AVR_ATmega162__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega162__" -#endif - -#ifdef __AVR_ATmega163__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega163__" -#endif - -#ifdef __AVR_ATmega164A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega164A__" -#endif - -#ifdef __AVR_ATmega164P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega164P__" -#endif - -#ifdef __AVR_ATmega164__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega164__" -#endif - -#ifdef __AVR_ATmega165A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega165A__" -#endif - -#ifdef __AVR_ATmega165P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega165P__" -#endif - -#ifdef __AVR_ATmega165__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega165__" -#endif - -#ifdef __AVR_ATmega168A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega168A__" -#endif - -#ifdef __AVR_ATmega168P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega168P__" -#endif - -#ifdef __AVR_ATmega168__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega168__" -#endif - -#ifdef __AVR_ATmega169A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169A__" -#endif - -#ifdef __AVR_ATmega169PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169PA__" -#endif - -#ifdef __AVR_ATmega169P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169P__" -#endif - -#ifdef __AVR_ATmega169__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega169__" -#endif - -#ifdef __AVR_ATmega16A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16A__" -#endif - -#ifdef __AVR_ATmega16HVA2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVA2__" -#endif - -#ifdef __AVR_ATmega16HVA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVA__" -#endif - -#ifdef __AVR_ATmega16HVBREVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVBREVB__" -#endif - -#ifdef __AVR_ATmega16HVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16HVB__" -#endif - -#ifdef __AVR_ATmega16M1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16M1__" -#endif - -#ifdef __AVR_ATmega16U2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16U2__" -#endif - -#ifdef __AVR_ATmega16U4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16U4__" -#endif - -#ifdef __AVR_ATmega16__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega16__" -#endif - -#ifdef __AVR_ATmega2560__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega2560__" -#endif - -#ifdef __AVR_ATmega2561__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega2561__" -#endif - -#ifdef __AVR_ATmega323__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega323__" -#endif - -#ifdef __AVR_ATmega324A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega324A__" -#endif - -#ifdef __AVR_ATmega324PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega324PA__" -#endif - -#ifdef __AVR_ATmega324P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega324P__" -#endif - -#ifdef __AVR_ATmega3250A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3250A__" -#endif - -#ifdef __AVR_ATmega3250P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3250P__" -#endif - -#ifdef __AVR_ATmega3250__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3250__" -#endif - -#ifdef __AVR_ATmega325A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega325A__" -#endif - -#ifdef __AVR_ATmega325P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega325P__" -#endif - -#ifdef __AVR_ATmega325__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega325__" -#endif - -#ifdef __AVR_ATmega328P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega328P__" -#endif - -#ifdef __AVR_ATmega328__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega328__" -#endif - -#ifdef __AVR_ATmega3290A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3290A__" -#endif - -#ifdef __AVR_ATmega3290P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3290P__" -#endif - -#ifdef __AVR_ATmega3290__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega3290__" -#endif - -#ifdef __AVR_ATmega329A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329A__" -#endif - -#ifdef __AVR_ATmega329PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329PA__" -#endif - -#ifdef __AVR_ATmega329P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329P__" -#endif - -#ifdef __AVR_ATmega329__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega329__" -#endif - -#ifdef __AVR_ATmega32C1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32C1__" -#endif - -#ifdef __AVR_ATmega32HVBREVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32HVBREVB__" -#endif - -#ifdef __AVR_ATmega32HVB__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32HVB__" -#endif - -#ifdef __AVR_ATmega32M1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32M1__" -#endif - -#ifdef __AVR_ATmega32U2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32U2__" -#endif - -#ifdef __AVR_ATmega32U4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32U4__" -#endif - -#ifdef __AVR_ATmega32U6__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32U6__" -#endif - -#ifdef __AVR_ATmega32__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega32__" -#endif - -#ifdef __AVR_ATmega406__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega406__" -#endif - -#ifdef __AVR_ATmega48A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega48A__" -#endif - -#ifdef __AVR_ATmega48P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega48P__" -#endif - -#ifdef __AVR_ATmega48__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega48__" -#endif - -#ifdef __AVR_ATmega640__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega640__" -#endif - -#ifdef __AVR_ATmega644A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644A__" -#endif - -#ifdef __AVR_ATmega644PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644PA__" -#endif - -#ifdef __AVR_ATmega644P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644P__" -#endif - -#ifdef __AVR_ATmega644__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega644__" -#endif - -#ifdef __AVR_ATmega6450A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6450A__" -#endif - -#ifdef __AVR_ATmega6450P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6450P__" -#endif - -#ifdef __AVR_ATmega6450__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6450__" -#endif - -#ifdef __AVR_ATmega645A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega645A__" -#endif - -#ifdef __AVR_ATmega645P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega645P__" -#endif - -#ifdef __AVR_ATmega645__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega645__" -#endif - -#ifdef __AVR_ATmega6490A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6490A__" -#endif - -#ifdef __AVR_ATmega6490P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6490P__" -#endif - -#ifdef __AVR_ATmega6490__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega6490__" -#endif - -#ifdef __AVR_ATmega649A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega649A__" -#endif - -#ifdef __AVR_ATmega649P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega649P__" -#endif - -#ifdef __AVR_ATmega649__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega649__" -#endif - -#ifdef __AVR_ATmega64C1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64C1__" -#endif - -#ifdef __AVR_ATmega64HVE__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64HVE__" -#endif - -#ifdef __AVR_ATmega64M1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64M1__" -#endif - -#ifdef __AVR_ATmega64__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega64__" -#endif - -#ifdef __AVR_ATmega8515__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8515__" -#endif - -#ifdef __AVR_ATmega8535__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8535__" -#endif - -#ifdef __AVR_ATmega88A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88A__" -#endif - -#ifdef __AVR_ATmega88PA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88PA__" -#endif - -#ifdef __AVR_ATmega88P__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88P__" -#endif - -#ifdef __AVR_ATmega88__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega88__" -#endif - -#ifdef __AVR_ATmega8HVA__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8HVA__" -#endif - -#ifdef __AVR_ATmega8U2__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8U2__" -#endif - -#ifdef __AVR_ATmega8__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATmega8__" -#endif - -#ifdef __AVR_ATtiny10__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny10__" -#endif - -#ifdef __AVR_ATtiny11__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny11__" -#endif - -#ifdef __AVR_ATtiny12__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny12__" -#endif - -#ifdef __AVR_ATtiny13A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny13A__" -#endif - -#ifdef __AVR_ATtiny13__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny13__" -#endif - -#ifdef __AVR_ATtiny15__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny15__" -#endif - -#ifdef __AVR_ATtiny167__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny167__" -#endif - -#ifdef __AVR_ATtiny20__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny20__" -#endif - -#ifdef __AVR_ATtiny22__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny22__" -#endif - -#ifdef __AVR_ATtiny2313A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny2313A__" -#endif - -#ifdef __AVR_ATtiny2313__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny2313__" -#endif - -#ifdef __AVR_ATtiny24A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny24A__" -#endif - -#ifdef __AVR_ATtiny24__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny24__" -#endif - -#ifdef __AVR_ATtiny25__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny25__" -#endif - -#ifdef __AVR_ATtiny261A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny261A__" -#endif - -#ifdef __AVR_ATtiny261__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny261__" -#endif - -#ifdef __AVR_ATtiny26__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny26__" -#endif - -#ifdef __AVR_ATtiny28__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny28__" -#endif - -#ifdef __AVR_ATtiny40__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny40__" -#endif - -#ifdef __AVR_ATtiny4313__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny4313__" -#endif - -#ifdef __AVR_ATtiny43U__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny43U__" -#endif - -#ifdef __AVR_ATtiny44A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny44A__" -#endif - -#ifdef __AVR_ATtiny44__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny44__" -#endif - -#ifdef __AVR_ATtiny45__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny45__" -#endif - -#ifdef __AVR_ATtiny461A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny461A__" -#endif - -#ifdef __AVR_ATtiny461__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny461__" -#endif - -#ifdef __AVR_ATtiny48__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny48__" -#endif - -#ifdef __AVR_ATtiny4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny4__" -#endif - -#ifdef __AVR_ATtiny5__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny5__" -#endif - -#ifdef __AVR_ATtiny84A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny84A__" -#endif - -#ifdef __AVR_ATtiny84__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny84__" -#endif - -#ifdef __AVR_ATtiny85__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny85__" -#endif - -#ifdef __AVR_ATtiny861A__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny861A__" -#endif - -#ifdef __AVR_ATtiny861__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny861__" -#endif - -#ifdef __AVR_ATtiny87__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny87__" -#endif - -#ifdef __AVR_ATtiny88__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny88__" -#endif - -#ifdef __AVR_ATtiny9__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATtiny9__" -#endif - -#ifdef __AVR_ATxmega128A1U__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128A1U__" -#endif - -#ifdef __AVR_ATxmega128A1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128A1__" -#endif - -#ifdef __AVR_ATxmega128A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128A3__" -#endif - -#ifdef __AVR_ATxmega128D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega128D3__" -#endif - -#ifdef __AVR_ATxmega16A4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega16A4__" -#endif - -#ifdef __AVR_ATxmega16D4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega16D4__" -#endif - -#ifdef __AVR_ATxmega192A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega192A3__" -#endif - -#ifdef __AVR_ATxmega192D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega192D3__" -#endif - -#ifdef __AVR_ATxmega256A3B__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega256A3B__" -#endif - -#ifdef __AVR_ATxmega256A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega256A3__" -#endif - -#ifdef __AVR_ATxmega256D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega256D3__" -#endif - -#ifdef __AVR_ATxmega32A4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega32A4__" -#endif - -#ifdef __AVR_ATxmega32D4__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega32D4__" -#endif - -#ifdef __AVR_ATxmega64A1U__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64A1U__" -#endif - -#ifdef __AVR_ATxmega64A1__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64A1__" -#endif - -#ifdef __AVR_ATxmega64A3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64A3__" -#endif - -#ifdef __AVR_ATxmega64D3__ -# ifdef MCU -# error "MCU is already defined" -# endif -# define MCU "__AVR_ATxmega64D3__" -#endif diff --git a/intdefs.h b/intdefs.h deleted file mode 100644 index d1e9215..0000000 --- a/intdefs.h +++ /dev/null @@ -1,11 +0,0 @@ - -// const int variables cannot be checked automatically like defines - -DEFINE(A0) - -#ifdef ARDUINO_ARCH_AVR - DEFINE(SS) - DEFINE(MOSI) - DEFINE(MISO) - DEFINE(SCK) -#endif diff --git a/timers.h b/timers.h deleted file mode 100644 index 6a8c3f5..0000000 --- a/timers.h +++ /dev/null @@ -1,501 +0,0 @@ - -#ifndef FreqCount_timers_h_ -#define FreqCount_timers_h_ - -#include -#include - -// Arduino Mega -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - // #define COUNTER_USE_TIMER1 // T1 is not connected - // #define COUNTER_USE_TIMER3 // T3 is not connected - // #define COUNTER_USE_TIMER4 // T4 is not connected - #define COUNTER_USE_TIMER5 // T5 is pin 47 - #define TIMER_USE_TIMER2 - -// Teensy 2.0 -#elif defined(__AVR_ATmega32U4__) - #define COUNTER_USE_TIMER1 // T1 is pin 11 (has LED connected) - #define TIMER_USE_TIMER4H - -// Teensy++ 1.0 & 2.0 -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) - #define COUNTER_USE_TIMER1 // T1 is pin 6 (has LED connected) - //#define COUNTER_USE_TIMER3 // T3 is pin 13 - #define TIMER_USE_TIMER2 - -// Sanguino -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) - #define COUNTER_USE_TIMER1 // T1 is pin 1 - #define TIMER_USE_TIMER2 - -// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc -#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) - #define COUNTER_USE_TIMER1 // T1 is pin 5 - #define TIMER_USE_TIMER2 - -#else - #error "Unknown chip, please edit me with timer+counter definitions" - -#endif - - -/**********************************************/ -/* Counter Hardware Abstraction */ -/**********************************************/ - -#if defined(COUNTER_USE_TIMER1) // 16 bit Timer 1 - -static uint8_t saveTCCR1A, saveTCCR1B; - -static inline void counter_init(void) -{ - saveTCCR1A = TCCR1A; - saveTCCR1B = TCCR1B; - TCCR1B = 0; - TCCR1A = 0; - TCNT1 = 0; - TIFR1 = (1<= 16000000L - #define TIMER2_OCR2A_1MS_VAL 124 // div 125 - #define TIMER2_TCCR2B_1MS_VAL (1<> 3; - OCR2A = TIMER2_OCR2A_8MS_VAL; - startTCCR2B = TIMER2_TCCR2B_8MS_VAL; - } else if ((msec & 3) == 0) { - gate_len = msec >> 2; - OCR2A = TIMER2_OCR2A_4MS_VAL; - startTCCR2B = TIMER2_TCCR2B_4MS_VAL; - } else if ((msec & 1) == 0) { - gate_len = msec >> 1; - OCR2A = TIMER2_OCR2A_2MS_VAL; - startTCCR2B = TIMER2_TCCR2B_2MS_VAL; - } else { - gate_len = msec; - OCR2A = TIMER2_OCR2A_1MS_VAL; - startTCCR2B = TIMER2_TCCR2B_1MS_VAL; - } - TIFR2 = (1<: -2 326: 1f 92 push r1 -2 328: 0f 92 push r0 -1 32a: 0f b6 in r0, 0x3f ; 63 -2 32c: 0f 92 push r0 -1 32e: 11 24 eor r1, r1 -2 330: ef 92 push r14 -2 332: ff 92 push r15 -2 334: 0f 93 push r16 -2 336: 1f 93 push r17 -2 338: 2f 93 push r18 -2 33a: 3f 93 push r19 -2 33c: 4f 93 push r20 -2 33e: 5f 93 push r21 -2 340: 8f 93 push r24 -2 342: 9f 93 push r25 -2 344: af 93 push r26 -2 346: bf 93 push r27 -*/ -#define TIMER_LATENCY_CYCLES 34 - - - -#elif defined(TIMER_USE_TIMER4H) // 10 bit "high speed" Timer 4 - -#define TIMER4H_OCR4C_VAL 124 // always div 125 -#if F_CPU == 16000000L - #define TIMER4H_TCCR4B_1MS_VAL (1<> 3; - startTCCR4B = TIMER4H_TCCR4B_8MS_VAL | (1<> 2; - startTCCR4B = TIMER4H_TCCR4B_4MS_VAL | (1<> 1; - startTCCR4B = TIMER4H_TCCR4B_2MS_VAL | (1< Date: Thu, 13 Aug 2020 11:40:27 -0500 Subject: [PATCH 343/344] Fixed sample file locations --- Nanpy/configure.sh => configure.sh | 0 Nanpy/sample_cfg.h => sample_cfg.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Nanpy/configure.sh => configure.sh (100%) rename Nanpy/sample_cfg.h => sample_cfg.h (100%) diff --git a/Nanpy/configure.sh b/configure.sh similarity index 100% rename from Nanpy/configure.sh rename to configure.sh diff --git a/Nanpy/sample_cfg.h b/sample_cfg.h similarity index 100% rename from Nanpy/sample_cfg.h rename to sample_cfg.h From 1d615eef80a637b1988aa2e76575268d1eacbd89 Mon Sep 17 00:00:00 2001 From: Eric Davisson Date: Sat, 17 Apr 2021 22:48:18 -0500 Subject: [PATCH 344/344] Fix for ESP32 pinMode For some reason INPUT = 1 and OUTPUT = 2 on esp32. All other boards INPUT = 0 and OUTPUT = 1. Added a fix for this. --- Nanpy/ArduinoClass.cpp | 6 +- Nanpy/Nanpy-MudPi.ino | 131 ----------------------------------------- 2 files changed, 5 insertions(+), 132 deletions(-) delete mode 100644 Nanpy/Nanpy-MudPi.ino diff --git a/Nanpy/ArduinoClass.cpp b/Nanpy/ArduinoClass.cpp index 46ff927..c484a12 100644 --- a/Nanpy/ArduinoClass.cpp +++ b/Nanpy/ArduinoClass.cpp @@ -29,7 +29,11 @@ void nanpy::ArduinoClass::elaborate( nanpy::MethodDescriptor* m ) { } if (strcmp(m->getName(), "pm") == 0) { // pinMode - pinMode(m->getInt(0), m->getInt(1)); + int _mode = m->getInt(1); + #ifdef ESP32 + _mode++; + #endif + pinMode(m->getInt(0), _mode); m->returns(0); } diff --git a/Nanpy/Nanpy-MudPi.ino b/Nanpy/Nanpy-MudPi.ino deleted file mode 100644 index 065a182..0000000 --- a/Nanpy/Nanpy-MudPi.ino +++ /dev/null @@ -1,131 +0,0 @@ -#include "cfg_all.h" - -// external libraries should be put inside #if ... #endif -// internal headers not. - -#if USE_MCP41xxx -#include -#endif - -#if USE_EEPROM -#include -#endif - -#if USE_Servo -#include -#endif - -#if USE_LiquidCrystal -#include -#endif - -#if USE_LiquidCrystal_I2C -#include -#endif - -#if USE_Stepper -#include -#endif - -#if USE_OneWire -#include -#endif - -#if USE_DallasTemperature -#include -#endif - -#if USE_CapacitiveSensor -#include -#endif - -#if USE_DHT -#include -#endif - -#if USE_Wire -#include -#endif - -#if USE_TLC5947 -#include -#endif - - -#include "MCP41xxxClass.h" -#include "BaseClass.h" -#include "ArduinoClass.h" -#include "OneWireClass.h" -#include "StepperClass.h" -#include "ServoClass.h" -#include "DallasTemperatureClass.h" -#include "LiquidCrystalClass.h" -#include "LiquidCrystalClass_I2C.h" -#include "CapacitiveSensorClass.h" -#include "ToneClass.h" -#include "MethodDescriptor.h" -#include "ComChannel.h" -#include "EEPROMClass.h" -#include "RAMClass.h" -#include "DHTClass.h" - -#include "DefineClass.h" -#include "ArduinoCoreClass.h" -#include "WatchdogClass.h" -#include "RegisterClass.h" -#include "CounterClass.h" -#include "InfoClass.h" -#include "WireClass.h" - -#include "TLC5947Class.h" -#include "EspClass.h" -#include "UltrasonicClass.h" -#include "ColorSensorClass.h" - -using namespace nanpy; - -MethodDescriptor *m = NULL; - -void setup() { - disable_watchdog_at_startup(); - - REGISTER_CLASS(ArduinoClass); // 0.8 k -// - REGISTER_CLASS_CONDITIONAL(MCP41xxxClass, USE_MCP41xxx); - REGISTER_CLASS_CONDITIONAL(nanpy::EEPROMClass, USE_EEPROM); // 0.3 k - REGISTER_CLASS_CONDITIONAL(nanpy::RAMClass, USE_RAM); // - REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass, USE_LiquidCrystal); // 2.3 k - REGISTER_CLASS_CONDITIONAL(LiquidCrystalClass_I2C, USE_LiquidCrystal_I2C); - REGISTER_CLASS_CONDITIONAL(OneWireClass, USE_OneWire); // 1.7 k - REGISTER_CLASS_CONDITIONAL(DallasTemperatureClass, USE_DallasTemperature); // 6.1 k - REGISTER_CLASS_CONDITIONAL(StepperClass, USE_Stepper); // 0.8 k - REGISTER_CLASS_CONDITIONAL(ServoClass, USE_Servo); // 2.5 k - REGISTER_CLASS_CONDITIONAL(ToneClass, USE_Tone); // 2.2 k - REGISTER_CLASS_CONDITIONAL(CapacitiveSensorClass, USE_CapacitiveSensor); // 2.2 k - REGISTER_CLASS_CONDITIONAL(DefineClass, USE_Define); // 0.6 k - REGISTER_CLASS_CONDITIONAL(ArduinoCoreClass, USE_ArduinoCore); // - REGISTER_CLASS_CONDITIONAL(WatchdogClass, USE_Watchdog); // 0.2 k - REGISTER_CLASS_CONDITIONAL(RegisterClass, USE_Register); // 1.5 k - - REGISTER_CLASS_CONDITIONAL(CounterClass, USE_Counter); - REGISTER_CLASS_CONDITIONAL(InfoClass, USE_Info); - REGISTER_CLASS_CONDITIONAL(DHTClass, USE_DHT); - REGISTER_CLASS_CONDITIONAL(WireClass, USE_Wire); - - REGISTER_CLASS_CONDITIONAL(TLC5947Class, USE_TLC5947); - - REGISTER_CLASS_CONDITIONAL(nanpy::EspClass, USE_ESP); - - // GW Classes - REGISTER_CLASS_CONDITIONAL(UltrasonicClass, USE_Ultrasonic); - REGISTER_CLASS_CONDITIONAL(ColorSensorClass, USE_ColorSensor); - - ComChannel::connect(); -} - -void loop() { - if(ComChannel::available()) { - m = new MethodDescriptor(); - Register::elaborate(m); - } -}