aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2013-02-26 16:38:19 +0100
committerJakob Odersky <jodersky@gmail.com>2013-02-26 16:38:19 +0100
commit5d4fd43bbccd3b1da97d3139b95eab9173777bef (patch)
treee0c4afeda484259bf725f25c3d891e30853ee8dd
parentac31762b462f37d49999daae8dba7763d8d870b3 (diff)
downloadace-5d4fd43bbccd3b1da97d3139b95eab9173777bef.tar.gz
ace-5d4fd43bbccd3b1da97d3139b95eab9173777bef.tar.bz2
ace-5d4fd43bbccd3b1da97d3139b95eab9173777bef.zip
remove old c/c++ implementations
-rw-r--r--arduino/ace_cpp_old/Framer.cpp101
-rw-r--r--arduino/ace_cpp_old/Framer.h51
-rw-r--r--arduino/ace_cpp_old/Makefile7
-rw-r--r--arduino/ace_cpp_old/SafeSerial.cpp59
-rw-r--r--arduino/ace_cpp_old/SafeSerial.h23
-rw-r--r--arduino/ace_cpp_old/ace.ino13
-rw-r--r--arduino/ace_cpp_old/arduino.mk379
-rw-r--r--arduino/ace_old/Makefile7
-rw-r--r--arduino/ace_old/ace.ino117
-rw-r--r--arduino/ace_old/arduino.mk379
-rw-r--r--arduino/ace_old/debug.h9
-rw-r--r--arduino/ace_old/link.c103
-rw-r--r--arduino/ace_old/link.h24
-rw-r--r--arduino/ace_old/physical.c61
-rw-r--r--arduino/ace_old/physical.h19
-rw-r--r--arduino/ace_old/transport.c166
-rw-r--r--arduino/ace_old/transport.h32
17 files changed, 0 insertions, 1550 deletions
diff --git a/arduino/ace_cpp_old/Framer.cpp b/arduino/ace_cpp_old/Framer.cpp
deleted file mode 100644
index 03335af..0000000
--- a/arduino/ace_cpp_old/Framer.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "Framer.h"
-
-Framer::Framer():
- state(WAITING),
- position(-1),
- checksum(0) {
-}
-
-void Framer::reset() {
- position = -1;
- checksum = 0x00;
-}
-
-void Framer::accept(uint8_t byte) {
-
- //if a new byte would cause an overflow, restart frame
- //note that this should not happen if both communicating parties have defined the same maximum frame length
- if (position >= MAX_FRAME_SIZE) {
- reset();
- return;
- }
-
- if (position != -1) { // i.e. a previous byte exists
- frameBuffer[position] = staged;
- checksum = checksum ^ staged;
- }
-
- position += 1;
- staged = byte;
-
-}
-
-void Framer::put(uint8_t byte) {
-
- switch(state) {
- case ESCAPING:
- accept(byte);
- state = RECEIVING;
- break;
-
- case WAITING:
- if (byte == START) {
- reset();
- state = RECEIVING;
- }
- break;
-
- case RECEIVING:
- switch(byte) {
- case ESCAPE:
- state = ESCAPING;
- break;
- case START:
- reset();
- break;
- case STOP:
- state = WAITING;
- if (staged == checksum) { //at this point, staged byte is the checksum sent in the frame (last byte of frame)
- onFrame(position, frameBuffer);
- }
- break;
-
- default:
- accept(byte);
- break;
- }
- }
-}
-
-
-
-void Framer::send(uint16_t length, const uint8_t * const data) {
- uint8_t checksum = 0x00;
- uint8_t byte;
-
- onSendByte(START);
- for (int i = 0; i < length; ++i) {
- byte = data[i];
- if (isCommandByte(byte))
- onSendByte(ESCAPE);
- checksum = checksum ^ byte;
- isCommandByte(byte);
- }
- if (isCommandByte(checksum)) {
- onSendByte(ESCAPE);
- }
- onSendByte(checksum);
- onSendByte(STOP);
-};
-
-
- //~ cli();
- //~ TCCR1A = 0; // set entire TCCR1A register to 0
- //~ TCCR1B = 0; // same for TCCR1B
- //~ // turn on CTC mode:
- //~ TCCR1B |= (1 << WGM12);
- //~ // set CS31 for 64 prescaler
- //~ TCCR1B |= (1 << CS11);
- //~ // set compare match register to desired timer count:
- //~ OCR1A = F_CPU / 1000 / 64; // should be 250 for F_CPU=16Mhz and f = 1000Hz
- //~ sei();
diff --git a/arduino/ace_cpp_old/Framer.h b/arduino/ace_cpp_old/Framer.h
deleted file mode 100644
index f06bebb..0000000
--- a/arduino/ace_cpp_old/Framer.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef FRAMER_H
-#define FRAMER_H
-
-#include <inttypes.h>
-
-#define MAX_PACKET_SIZE 64
-#define MAX_FRAME_SIZE MAX_PACKET_SIZE + 3
-
-class Framer {
-private:
-
- enum LinkState {
- WAITING,
- RECEIVING,
- ESCAPING
- };
-
- static const uint8_t ESCAPE = 0x02;
- static const uint8_t START = 0x03;
- static const uint8_t STOP = 0x10;
-
- LinkState state; //current state
- uint8_t frameBuffer[MAX_FRAME_SIZE]; //data of current frame
- uint8_t staged; //previous byte read, not defined when position == -1
-
- int16_t position; //position of next byte to be read into frame buffer, can also be -1 if no byte has yet been staged
- uint8_t checksum;
-
-
- inline void reset(); //reset current frame
- inline void accept(uint8_t byte); //reads a data byte (not a command byte) and takes an appropraiet action by modifying internal state
- inline static bool isCommandByte(uint8_t byte) {return (byte == START || byte == STOP || byte == ESCAPE);}
-
-
-protected:
-
- Framer();
- void put(uint8_t byte);
- void send(uint16_t length, const uint8_t * const data);
-
- /* Called when a byte is to be sent.
- * @param byte the byte to be sent */
- virtual void onSendByte(uint8_t byte) = 0;
-
- /* Called when a valid frame is received. */
- virtual void onFrame(uint16_t length, uint8_t *data) = 0;
-
-};
-
-
-#endif /* FRAMER_H */
diff --git a/arduino/ace_cpp_old/Makefile b/arduino/ace_cpp_old/Makefile
deleted file mode 100644
index 5ed9f66..0000000
--- a/arduino/ace_cpp_old/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-#SOURCES := main.cc other.cc
-#LIBRARIES := EEPROM
-
-ARDUINODIR=$(ARDUINO_HOME)
-BOARD=mega2560
-export LIBRARIES=LiquidCrystal
-include arduino.mk
diff --git a/arduino/ace_cpp_old/SafeSerial.cpp b/arduino/ace_cpp_old/SafeSerial.cpp
deleted file mode 100644
index bab930e..0000000
--- a/arduino/ace_cpp_old/SafeSerial.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "SafeSerial.h"
-
-#include <avr/interrupt.h>
-
-typedef struct {
- uint8_t buffer[SERIAL_BUFFER_SIZE];
- volatile uint16_t head;
- volatile uint16_t tail;
-} ring_buffer;
-
-static ring_buffer tx_buffer = {{0}, 0, 0};
-
-SafeSerial::begin(uint32_t baud) {
- //enable double speed transmission
- *ucsrXa |= (1 << u2xX);
-
- uint16_t baudSetting = (F_CPU / 4 / baud - 1) / 2;
- // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
- *ubrrXh = baudSetting >> 8;
- *ubrrXl = baudSetting;
-
- // defaults to 8-bit, no parity, 1 stop bit
- *ucsrXb |= (1 << *exenX) | (1 << *txenX) | (1 << *rxcieX);
- *ucsrXb &= ~(1 << *udrieX) | (1 << *txenX) | (1 << *rxcieX);
-}
-
-
-//receive
-ISR(USART0_RX_vect) {
- uint8_t c = UDR0;
- serial.put(c);
-}
-
-//data register empty
-ISR(USART0_UDRE_vect) {
- if (tx_buffer.head == tx_buffer.tail) {
- //buffer empty, disable interruot
- UCSR0B &= ~(1 << UDRIE0);
- } else {
- uint8_t c = tx_buffer.buffer[tx_buffer.tail];
- tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
- UDR0 = c; //write next byte
- }
-}
-
-void SafeSerial::send(uint8_t byte) {
- uint16_t i = (tx_buffer.head + 1) % SERIAL_BUFFER_SIZE;
-
- // If the output buffer is full, there's nothing for it other than to
- // wait for the interrupt handler to empty it a bit
-if (i == tx_buffer.tail) return;
- //while (i == tx_buffer.tail) {};
-
- tx_buffer.buffer[tx_buffer.head] = byte;
- tx_buffer.head = i;
-
- //enable data register empty interrupt
- UCSR0B |= (1 << UDRIE0);
-};
diff --git a/arduino/ace_cpp_old/SafeSerial.h b/arduino/ace_cpp_old/SafeSerial.h
deleted file mode 100644
index 12dba3e..0000000
--- a/arduino/ace_cpp_old/SafeSerial.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef SAFESERIAL_H
-#define SAFESERIAL_H
-
-#include <inttypes.h>
-#include "Framer.h"
-
-//#define MAX_PACKET_SIZE 64
-//#define MAX_FRAME_SIZE MAX_PACKET_SIZE + 3
-
-#define SERIAL_BUFFER_SIZE 64
-
-class SafeSerial: public Framer {
-private:
- void sendByte(uint8_t byte);
-
-
-protected:
- /* virtual */ void onSendByte(uint8_t byte) {};
- /* virtual */ void onFrame(uint16_t length, uint8_t *data) {};
-
-};
-
-#endif /* SAFESERIAL_H */
diff --git a/arduino/ace_cpp_old/ace.ino b/arduino/ace_cpp_old/ace.ino
deleted file mode 100644
index 2ca0347..0000000
--- a/arduino/ace_cpp_old/ace.ino
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "Arduino.h"
-
-#include "SafeSerial.h"
-
-volatile SafeSerial s;
-
-void setup() {
-
-}
-
-void loop() {
- s;
-}
diff --git a/arduino/ace_cpp_old/arduino.mk b/arduino/ace_cpp_old/arduino.mk
deleted file mode 100644
index 9fce9c7..0000000
--- a/arduino/ace_cpp_old/arduino.mk
+++ /dev/null
@@ -1,379 +0,0 @@
-#_______________________________________________________________________________
-#
-# edam's Arduino makefile
-#_______________________________________________________________________________
-# version 0.4
-#
-# Copyright (C) 2011, 2012 Tim Marston <tim@ed.am>.
-#
-# 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.
-#
-# <file> 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))
-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)
-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 += $(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 (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
-
-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; }
- 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 -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDS_FILE) | \
- 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 \
- 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) -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 $@ -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/arduino/ace_old/Makefile b/arduino/ace_old/Makefile
deleted file mode 100644
index 5ed9f66..0000000
--- a/arduino/ace_old/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-#SOURCES := main.cc other.cc
-#LIBRARIES := EEPROM
-
-ARDUINODIR=$(ARDUINO_HOME)
-BOARD=mega2560
-export LIBRARIES=LiquidCrystal
-include arduino.mk
diff --git a/arduino/ace_old/ace.ino b/arduino/ace_old/ace.ino
deleted file mode 100644
index 33984dc..0000000
--- a/arduino/ace_old/ace.ino
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "link.h"
-#include "physical.h"
-#include "transport.h"
-
-
-// include the library code:
-#include <LiquidCrystal.h>
-
-// initialize the library with the numbers of the interface pins
-LiquidCrystal lcd(8, 9, 4, 5, 6, 11);
-
-int freeRam () {
- extern int __heap_start, *__brkval;
- int v;
- return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
-}
-
-#define LED_PIN 13
-uint8_t msg_buffer[] = {97,98,99};
- message msg = {msg_buffer, 3};
-
-void setup() {
- pinMode(LED_PIN, OUTPUT);
- lcd.begin(16, 2);
- init_physical_layer(115200);
- init_transport_layer(200);
-
-}
-
-
-void step_circle() {
- static volatile uint8_t position = 0;
- static const char chars[] = {'|', '/', '-', '\\'};
- position = position + 1;
- if (position >= 4) position = 0;
-
- lcd.setCursor(15, 0);
- lcd.print(chars[position]);
-}
-
-
-void loop() {
-
- //lcd.print(freeRam());
-
- int x = analogRead (0);
- //lcd.setCursor(10,1);
- if (x < 100) {
- //lcd.print ("Right ");
- }
- else if (x < 200) {
- //lcd.print ("Up ");
- }
- else if (x < 400){
- //lcd.print ("Down ");
- }
- else if (x < 600){
-// lcd.print ("Raw ");
- to_physical_layer(97);
- }
- else if (x < 800){
- lcd.setCursor(0,0);
- lcd.print ("SENDING...");
- to_transport_layer(&msg);
- lcd.print ("DONE");
- }
- else {
-
- }
-
- delay(100);
-
- //step_circle();
-}
-
-/*void from_physical_layer(uint8_t byte) {
- if (byte == 'A') digitalWrite(LED_PIN, HIGH);
- else digitalWrite(LED_PIN, LOW);
-}*/
-/*void from_link_layer(packet* s) {
- if (s->data[0] == 'A') digitalWrite(LED_PIN, HIGH);
- else digitalWrite(LED_PIN, LOW);
-
-};*/
-
-
-static volatile uint32_t errs = 0;
-void from_transport_layer(transport_code code, message* s) {
- lcd.clear();
- lcd.setCursor(0,0);
- if (code == RECEIVED) {
- lcd.print("RECEIVED");
- lcd.setCursor(0,1);
- for (int i = 0; i < s->length; ++i) lcd.write(s->data[i]);
- }
-
- if (code == SEND_SUCCESS) {
- lcd.print("SENT");
- for (int i = 0; i < s->length; ++i) lcd.write(s->data[i]);
- }
-
- if (code >= SEND_ERROR) {
- lcd.print("ERROR");
- lcd.setCursor(0,1);
- switch(code) {
- case NO_ACK:
- lcd.print("NO ACK");
- break;
- case BAD_ACK:
- lcd.print("BAD ACK");
- break;
- case BUSY:
- lcd.print("BUSY");
- break;
- }
- }
-} //implemented in transport
diff --git a/arduino/ace_old/arduino.mk b/arduino/ace_old/arduino.mk
deleted file mode 100644
index 9fce9c7..0000000
--- a/arduino/ace_old/arduino.mk
+++ /dev/null
@@ -1,379 +0,0 @@
-#_______________________________________________________________________________
-#
-# edam's Arduino makefile
-#_______________________________________________________________________________
-# version 0.4
-#
-# Copyright (C) 2011, 2012 Tim Marston <tim@ed.am>.
-#
-# 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.
-#
-# <file> 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))
-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)
-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 += $(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 (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
-
-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; }
- 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 -nEe '/^#/d; /^[^.]+\.name=/p' $(BOARDS_FILE) | \
- 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 \
- 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) -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 $@ -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/arduino/ace_old/debug.h b/arduino/ace_old/debug.h
deleted file mode 100644
index d10d85b..0000000
--- a/arduino/ace_old/debug.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef MY_DEBUG_H
-#define MY_DEBUG_H
-
-// include the library code:
-#include <Arduino.h>
-#include <LiquidCrystal.h>
-
-
-#endif
diff --git a/arduino/ace_old/link.c b/arduino/ace_old/link.c
deleted file mode 100644
index 408e14e..0000000
--- a/arduino/ace_old/link.c
+++ /dev/null
@@ -1,103 +0,0 @@
-#include "link.h"
-#include "physical.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-
-typedef enum {
- WAITING,
- RECEIVING,
- ESCAPING
-} link_state;
-
-#define FRAME_ESCAPE 0x02
-#define FRAME_START 0x03
-#define FRAME_END 0x10
-
-
-void from_physical_layer(uint8_t byte) {
- static link_state state = WAITING;
- static uint16_t position = 0; //read position
- static uint8_t packet_data_buffer[MAX_PACKET_SIZE];
- static packet received = {packet_data_buffer, 0};
- static uint8_t checksum = 0x00;
-
- static bool previous_exists = false;
- static uint8_t previous_byte;
-
- #define start_receiving() \
- position = 0; \
- previous_exists = false; \
- checksum = 0x00
-
- #define accept(byte) \
- if (position >= MAX_PACKET_SIZE) {start_receiving(); return;} \
- if (previous_exists) { \
- packet_data_buffer[position] = previous_byte; \
- position = position + 1; \
- checksum = checksum ^ previous_byte; \
- previous_byte = byte; \
- } else { \
- previous_byte = byte; \
- previous_exists = true; \
- }
-
-
- switch(state) {
- case ESCAPING:
- accept(byte);
- state = RECEIVING;
- break;
-
- case WAITING:
- if (byte == FRAME_START) {
- start_receiving();
- state = RECEIVING;
- }
- break;
- case RECEIVING:
- switch(byte) {
- case FRAME_ESCAPE:
- state = ESCAPING;
- break;
- case FRAME_START:
- start_receiving();
- break;
- case FRAME_END:
- state = WAITING;
- uint8_t sent_checksum = previous_byte;
- if (sent_checksum == checksum) {
- received.length = position;
- from_link_layer(&received);
- }
-
- break;
- default:
- accept(byte);
- break;
- }
- }
-
- #undef accept
- #undef start_receiving
-}
-
-void to_link_layer(packet* s) {
- uint8_t checksum = 0x00;
- uint8_t byte;
- int i;
-
- to_physical_layer(FRAME_START);
- for (i = 0; i < (s->length); ++i) {
- byte = s->data[i];
- if (byte == FRAME_START || byte == FRAME_END || byte == FRAME_ESCAPE)
- to_physical_layer(FRAME_ESCAPE);
- checksum = checksum ^ byte;
- to_physical_layer(byte);
- }
- if (checksum == FRAME_START || checksum == FRAME_END || checksum == FRAME_ESCAPE)
- to_physical_layer(FRAME_ESCAPE);
- to_physical_layer(checksum);
- to_physical_layer(FRAME_END);
-};
diff --git a/arduino/ace_old/link.h b/arduino/ace_old/link.h
deleted file mode 100644
index 797145e..0000000
--- a/arduino/ace_old/link.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef LINK_H
-#define LINK_H
-
-#include <inttypes.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MAX_PACKET_SIZE 256
-
-typedef struct {
- uint8_t* data;
- uint16_t length;
-} packet;
-
-void to_link_layer(packet* s); //implemented in link
-void from_link_layer(packet* r); //should be implemented in transport
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* LINK_H */
diff --git a/arduino/ace_old/physical.c b/arduino/ace_old/physical.c
deleted file mode 100644
index 17e15d7..0000000
--- a/arduino/ace_old/physical.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "physical.h"
-#include "link.h"
-
-#include <avr/interrupt.h>
-
-typedef struct {
- uint8_t buffer[SERIAL_BUFFER_SIZE];
- volatile uint16_t head;
- volatile uint16_t tail;
-} ring_buffer;
-
-static ring_buffer tx_buffer = {{0}, 0, 0};
-
-
-void init_physical_layer(uint32_t baud) {
- //enable double speed transmission
- UCSR0A |= (1 << U2X0);
-
- uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
- // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
- UBRR0H = baud_setting >> 8;
- UBRR0L = baud_setting;
-
- // defaults to 8-bit, no parity, 1 stop bit
- UCSR0B |= (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0);
- UCSR0B &= ~(1 << UDRIE0) | (1 << TXEN0) | (1 << RXCIE0);
-}
-
-
-//receive
-ISR(USART0_RX_vect) {
- uint8_t c = UDR0;
- from_physical_layer(c);
-}
-
-//data register empty
-ISR(USART0_UDRE_vect) {
- if (tx_buffer.head == tx_buffer.tail) {
- //buffer empty, disable interruot
- UCSR0B &= ~(1 << UDRIE0);
- } else {
- uint8_t c = tx_buffer.buffer[tx_buffer.tail];
- tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
- UDR0 = c; //write next byte
- }
-}
-
-void to_physical_layer(uint8_t byte) {
- uint16_t i = (tx_buffer.head + 1) % SERIAL_BUFFER_SIZE;
-
- // If the output buffer is full, there's nothing for it other than to
- // wait for the interrupt handler to empty it a bit
-if (i == tx_buffer.tail) return;
- //while (i == tx_buffer.tail) {};
-
- tx_buffer.buffer[tx_buffer.head] = byte;
- tx_buffer.head = i;
-
- //enable data register empty interrupt
- UCSR0B |= (1 << UDRIE0);
-};
diff --git a/arduino/ace_old/physical.h b/arduino/ace_old/physical.h
deleted file mode 100644
index 74272ff..0000000
--- a/arduino/ace_old/physical.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef PHYSICAL_H
-#define PHYSICAL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <inttypes.h>
-#define SERIAL_BUFFER_SIZE 64
-
-void init_physical_layer(uint32_t baud);
-void to_physical_layer(uint8_t s); //implemented in physical
-void from_physical_layer(uint8_t r); //should be implemented in link
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* PHYSICAL_H */
diff --git a/arduino/ace_old/transport.c b/arduino/ace_old/transport.c
deleted file mode 100644
index 986165e..0000000
--- a/arduino/ace_old/transport.c
+++ /dev/null
@@ -1,166 +0,0 @@
-#include "transport.h"
-#include "link.h"
-
-#include <stdlib.h>
-#include <stdbool.h>
-#include <avr/interrupt.h>
-
-//ms
-#define EXTRA_TIME 200
-#define MAX_RESENDS 5
-#define MAX_SEQ 255
-
-#define next_seq(k) if (k < MAX_SEQ) k = k + 1; else k = 0
-
-#define DATA 0x05
-#define ACK 0x06
-
-
-static void start_sending(message* msg, bool resend);
-static void stop_sending();
-
-
-typedef enum {
- RECEIVED_PACKET,
- TIMEOUT
-} event_kind;
-
-typedef struct {
- event_kind kind;
- packet* payload;
-} event;
-
-static void disassemble_packet(packet* p, uint8_t* seq, uint8_t* command, uint8_t** msg, uint16_t* message_length) {
- if (seq != NULL) *seq = p->data[0];
- if (command != NULL) *command = p->data[1];
- if (msg != NULL) *msg = &(p->data[2]);
- if (message_length != NULL) *message_length = p->length - 2;
-}
-
-static void assemble_packet(packet* p, uint8_t seq, uint8_t command, uint8_t* msg, uint16_t message_length) {
- p->data[0] = seq;
- p->data[1] = command;
- int i;
- for (i = 0; i < message_length; ++i) {
- p->data[i+2] = msg[i];
- }
- p->length = message_length + 2;
-}
-
-static packet* ack(uint8_t seq) {
- static uint8_t ack_buffer[] = {0, ACK};
- static packet ack_packet = {ack_buffer, 2};
- ack_buffer[0] = seq;
- return &ack_packet;
-}
-
-static volatile bool awaiting_ack = false;
-static volatile uint8_t last_sent_seq = 0;
-static volatile uint8_t resends = 0;
-static volatile uint8_t last_sent_buffer[MAX_PACKET_SIZE];
-static volatile packet last_sent = {last_sent_buffer, 0};
-
-static void process_event(event* e) {
- static uint8_t last_received_seq = 0;
-
- switch(e->kind) {
- case RECEIVED_PACKET: {
- uint8_t seq;
- uint8_t cmd;
- static message msg;
- disassemble_packet(e->payload, &seq, &cmd, &msg.data, &msg.length);
-
- if (!awaiting_ack) {
- if (cmd == DATA) {
- if (last_received_seq != seq) {
- last_received_seq = seq;
- from_transport_layer(RECEIVED, &msg);
- }
- to_link_layer(ack(seq));
- }
- //ignore case in which an ack is received even though none is awaited
-
- } else { //waiting for an ack
- stop_sending();
- disassemble_packet(&last_sent, NULL, NULL, &msg.data, &msg.length);
- if (cmd == ACK && seq == last_sent_seq) {
- from_transport_layer(SEND_SUCCESS, &msg);
- } else {
- from_transport_layer(BAD_ACK, &msg);
- }
- }
- } break;
- case TIMEOUT:
- if (resends > MAX_RESENDS) {
- message msg;
- disassemble_packet(&last_sent, NULL, NULL, &msg.data, &msg.length);
- stop_sending();
- from_transport_layer(NO_ACK, &msg);
- } else {
- start_sending(NULL, true);
- }
- break;
- }
-}
-
-static void start_sending(message* msg, bool resend) {
- if (resend) {
- resends = resends + 1;
- } else {
- next_seq(last_sent_seq);
- assemble_packet(&last_sent, last_sent_seq, DATA, msg->data, msg->length);
- resends = 0;
- TIMSK1 |= (1 << OCIE1A);
- }
-
- awaiting_ack = true;
- to_link_layer(&last_sent);
-}
-
-static void stop_sending() {
- TIMSK1 &= ~(1 << OCIE1A);
- awaiting_ack = false;
-}
-
-static volatile uint32_t ticks;
-static volatile uint32_t max_ticks;
-
-void init_transport_layer(uint32_t timeout_millis) {
- cli();
- TCCR1A = 0; // set entire TCCR1A register to 0
- TCCR1B = 0; // same for TCCR1B
- // turn on CTC mode:
- TCCR1B |= (1 << WGM12);
- // set CS31 for 64 prescaler
- TCCR1B |= (1 << CS11);
- // set compare match register to desired timer count:
- OCR1A = F_CPU / 1000 / 64; // should be 250 for F_CPU=16Mhz and f = 1000Hz
- sei();
-
- //the timer should now interrupt every ms
- max_ticks = timeout_millis;
-}
-
-ISR(TIMER1_COMPA_vect) {
- static event e = {TIMEOUT, NULL};
-
- ticks = ticks + 1;
- if (ticks > max_ticks) {
- process_event(&e);
- ticks = 0;
- }
-}
-
-void from_link_layer(packet* r) {
- static event e = {RECEIVED_PACKET, NULL};
- e.payload = r;
- process_event(&e);
-}
-
-void to_transport_layer(message* s) {
- if (!awaiting_ack)
- start_sending(s, false);
- else
- from_transport_layer(BUSY, s);
-}
-
diff --git a/arduino/ace_old/transport.h b/arduino/ace_old/transport.h
deleted file mode 100644
index 233d19c..0000000
--- a/arduino/ace_old/transport.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef TRANSPORT_H
-#define TRANSPORT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <inttypes.h>
-
-typedef struct {
- uint8_t* data;
- uint16_t length;
-} message;
-
-typedef enum {
- RECEIVED = 0,
- SEND_SUCCESS = 1,
- SEND_ERROR = 2,
- NO_ACK = 3,
- BAD_ACK = 4,
- BUSY = 5
-} transport_code;
-
-void init_transport_layer(uint32_t timeout_millis);
-void to_transport_layer(message* s); //implemented in transport
-void from_transport_layer(transport_code code, message* r); //should be implemented in application
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* TRANSPORT_H */