remove the uc directory

This commit is contained in:
Bart Van Der Meerssche 2010-07-07 16:45:15 +02:00
parent 3a28838b29
commit fcf5ed7d0e
22 changed files with 0 additions and 2071 deletions

View File

@ -1,278 +0,0 @@
# Arduino 0011 Makefile
# Arduino adaptation by mellis, eighthave, oli.keller
#
# This makefile allows you to build sketches from the command line
# without the Arduino environment (or Java).
#
# Detailed instructions for using the makefile:
#
# 1. Copy this file into the folder with your sketch. There should be a
# file with the extension .pde (e.g. foo.pde)
#
# 2. Below, modify the line containing "TARGET" to refer to the name of
# of your program's file without an extension (e.g. TARGET = foo).
#
# 3. Modify the line containg "INSTALL_DIR" to point to the directory that
# contains the Arduino installation (for example, under Mac OS X, this
# might be /Applications/arduino-0011).
#
# 4. Modify the line containing "PORT" to refer to the filename
# representing the USB or serial connection to your Arduino board
# (e.g. PORT = /dev/tty.USB0). If the exact name of this file
# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*).
#
# 5. Set the line containing "MCU" to match your board's processor.
# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
# change F_CPU to 8000000.
#
# 6. At the command line, change to the directory containing your
# program's file and the makefile.
#
# 7. Type "make" and press enter to compile/verify your program.
#
# 8. Type "make upload", reset your Arduino board, and press enter to
# upload your program to the Arduino board.
#
# $Id$
###############################################################################
#
# project specific settings:
#
TARGET = main
#
# Predefine the TYPE and SENSORx C macros in main.h via this Makefile.
# Override the defaults on the command line by typing:
# make PHASE=x METERCONST=y SENSOR0=z ...
#
DBG = 0
#
TYPE = 2300501
PHASE = 1
METERCONST= 5508
#
SENSOR0 = 0123456789abcdef0123456789abcde0
SENSOR1 = 0123456789abcdef0123456789abcde1
SENSOR2 = 0123456789abcdef0123456789abcde2
SENSOR3 = 0123456789abcdef0123456789abcde3
#
CEXTRA = -D DBG=$(DBG) -D PHASE=$(PHASE) -D METERCONST=$(METERCONST) -D 'SENSOR0="$(SENSOR0)"' -D 'SENSOR1="$(SENSOR1)"' -D 'SENSOR2="$(SENSOR2)"' -D 'SENSOR3="$(SENSOR3)"'
###############################################################################
###############################################################################
#
# serial uploader settings
#
PORT = /dev/ttyUSB*
UPLOAD_RATE = 19200
AVRDUDE_PROGRAMMER = usbtiny
#
# HINT: If you want to use the automatic reset feature which comes with Arduino
# Diecimila, put the follwoing in your avrdude.conf:
# (Use the systemwide $(INSTALL_DIR)/tools/avr/etc/avrdude.conf or create a
# local $HOME/.avrduderc file)
#
# programmer
# id = "arduino";
# desc = "Arduino Serial Bootloader";
# type = stk500;
# reset = 7;
# # since Arduino Diecimila the serial DTR line can be used to trigger a reset!
# ;
#
# After this you can specify AVRDUDE_PROGRAMMER = arduino, above.
# On older boards you can manually ad this reset feature. Wire a cable from the
# FTDI 232 Chip's DTR pin (the number differs from package to package, see datasheet)
# to the RESET line of the ATmega. Inbetween this connection must be a 100nF capacitor.
#####################################################################################
#####################################################################################
#
# hardware dependent settings
#
MCU = atmega48
F_CPU = 1000000
#####################################################################################
#####################################################################################
#
# Below here nothing should be changed...
#
#####################################################################################
AVR_TOOLS_PATH = /usr/bin
SRC = wiring/serial.c
FORMAT = ihex
# Name of this Makefile (used for "make depend").
MAKEFILE = Makefile
# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
DEBUG = stabs
OPT = s
# Place -D or -U options here
CDEFS = -DF_CPU=$(F_CPU)
CXXDEFS = -DF_CPU=$(F_CPU)
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99
CDEBUG = -g$(DEBUG)
CWARN = -Wall -Wstrict-prototypes
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
LDFLAGS = -lm
# Programming support using avrdude. Settings and variables.
AVRDUDE_PORT = $(PORT)
AVRDUDE_WRITE_FUSES= -U lfuse:w:0x6E:m -U hfuse:w:0xD6:m -U efuse:w:0x1:m
AVRDUDE_WRITE_FLASH = -U flash:w:bin/$(TARGET).hex
AVRDUDE_WRITE_EEPROM = -U eeprom:w:bin/$(TARGET).eep
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) -b $(UPLOAD_RATE)
# Program settings
CC = $(AVR_TOOLS_PATH)/avr-gcc
CXX = $(AVR_TOOLS_PATH)/avr-g++
OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
AR = $(AVR_TOOLS_PATH)/avr-ar
SIZE = $(AVR_TOOLS_PATH)/avr-size
NM = $(AVR_TOOLS_PATH)/avr-nm
AVRDUDE = avrdude
REMOVE = rm -f
MV = mv -f
# Define all object files.
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: bin_files build sizeafter
build: elf hex eep
bin_files: $(TARGET).c
@test -d bin || mkdir bin
@cp $(TARGET).c bin/$(TARGET).c
elf: bin/$(TARGET).elf
hex: bin/$(TARGET).hex
eep: bin/$(TARGET).eep
lss: bin/$(TARGET).lss
sym: bin/$(TARGET).sym
# Program the device.
upload: bin/$(TARGET).hex
@$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FUSES) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) bin/$(TARGET).hex
ELFSIZE = $(SIZE) bin/$(TARGET).elf
sizebefore:
@if [ -f bin/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
sizeafter:
@if [ -f bin/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
coff: bin/$(TARGET).elf
$(COFFCONVERT) -O coff-avr bin/$(TARGET).elf $(TARGET).cof
extcoff: $(TARGET).elf
$(COFFCONVERT) -O coff-ext-avr bin/$(TARGET).elf $(TARGET).cof
.SUFFIXES: .elf .hex .eep .lss .sym
.elf.hex:
@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
.elf.eep:
@$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
.elf.lss:
$(OBJDUMP) -h -S $< > $@
# Create a symbol table from ELF output file.
.elf.sym:
$(NM) -n $< > $@
# Link: create ELF output file from library.
bin/$(TARGET).elf: $(TARGET).c bin/core.a
@$(CC) $(ALL_CFLAGS) -o $@ bin/$(TARGET).c -L. bin/core.a $(LDFLAGS)
bin/core.a: $(OBJ)
@for i in $(OBJ); do $(AR) rcs bin/core.a $$i; done
# Compile: create object files from C++ source files.
.cpp.o:
@$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
# Compile: create object files from C source files.
.c.o:
@$(CC) -c $(ALL_CFLAGS) $< -o $@
# Compile: create assembler files from C source files.
.c.s:
$(CC) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files.
.S.o:
$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean:
@$(REMOVE) bin/$(TARGET).hex bin/$(TARGET).eep bin/$(TARGET).cof bin/$(TARGET).elf \
bin/$(TARGET).map bin/$(TARGET).sym bin/$(TARGET).lss bin/$(TARGET).c bin/core.a \
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
depend:
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
then \
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
$(MAKEFILE).$$$$ && \
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
fi
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
>> $(MAKEFILE); \
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend bin_files sizebefore sizeafter

View File

@ -1,182 +0,0 @@
// Copyright (c) 2008 jokamajo.org
// $Id$
// define section, move to main.h later on
// macro's
#ifndef __AVR_ATmega168__
#define __AVR_ATmega168__
#endif
#define METER0 "cccccccccccccccccccccccccccccccc"
#define METER1 "dddddddddddddddddddddddddddddddd"
#define METER2 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
#define METER3 "ffffffffffffffffffffffffffffffff"
#define START 0
#define END3 0xffffffff
#define END2 0xeeeeeeee
#define END1 0xdddddddd
#define END0 0xcccccccc
// pin definitions
#define METER0PIN 2
#define METER1PIN 3
#define METER2PIN 4
#define METER3PIN 9
#define POTPIN0 6
#define POTPIN1 7
#define POTPIN2 8
#define LEDPIN 13
// end of define
// pin/register/ISR definitions
#include <avr/interrupt.h>
// eeprom library
#include <avr/eeprom.h>
// watchdog timer library
#include <avr/wdt.h>
// variable declarations
uint16_t i;
typedef struct {
boolean pulse0;
boolean toggle0;
boolean pulse1;
boolean toggle1;
boolean pulse2;
boolean toggle2;
boolean pulse3;
boolean toggle3;
} struct_aux;
volatile struct_aux aux = {false, false, false, false, false, false, false, false};
typedef struct {
char meter[513]; //don't forget to reserve a byte for a terminating NULL
} struct_meas;
volatile struct_meas EEMEM EEPROM_measurements;
volatile struct_meas measurements;
// interrupt service routine for analog comparator
ISR(ANALOG_COMP_vect) {
digitalWrite(LEDPIN, HIGH); // sets the LED on
UCSR0B &= ~((1<<RXEN0) | (1<<TXEN0)); //disable UART Tx and Rx
ADCSRA &= ~(1<<ADEN); //disable ADC
ACSR |= (1<<ACD); //disable AC
// PRR |= (1<<PRUSART0) | (1<<PRADC);
eeprom_write_block((const void*)&measurements, (void*)&EEPROM_measurements, sizeof(measurements));
}
// interrupt service routine for watchdog timeout
ISR(WDT_vect) {
}
// disable WDT
void WDT_off(void) {
cli();
wdt_reset();
// clear the WDT reset flag in the status register
MCUSR &= ~(1<<WDRF);
// timed sequence to be able to change the WDT settings afterwards
WDTCSR |= (1<<WDCE) | (1<<WDE);
// disable WDT
WDTCSR = 0x00;
}
// enable WDT
void WDT_on(void) {
// enable the watchdog timer (1s)
wdt_enable(WDTO_1S);
// set watchdog interrupt enable flag
WDTCSR |= (1<<WDIE);
}
void setup()
{
// WDT_off(); -> moved the call to this function to start of the main loop, before init
// clock settings: divide by 8 to get a 1Mhz clock, allows us to set the BOD level to 1.8V (DS p.37)
CLKPR = (1<<CLKPCE);
CLKPR = (1<<CLKPS1) | (1<<CLKPS0);
// load meterid's and metervalues from EEPROM
// eeprom_read_block((void*)&measurements, (const void*)&EEPROM_measurements, sizeof(measurements));
// init serial port
Serial.begin(4800);
delay(100);
pinMode(LEDPIN, OUTPUT);
// DP2=INT0 configuration
pinMode(METER0PIN, INPUT);
// turn on the internal 20k pull-up resistor
digitalWrite(METER0PIN, HIGH);
// set INT0 (=METER0PIN) active LOW interrupt
// DP3=INT1 configuration
pinMode(METER1PIN, INPUT);
// turn on the internal 20k pull-up resistor
digitalWrite(METER1PIN, HIGH);
// set INT1 (=METER1PIN) active LOW interrupt
// PD4=PCINT20 configuration
pinMode(METER2PIN, INPUT);
// turn on the internal 20k pull-up resistor
digitalWrite(METER2PIN, HIGH);
//enable pin change interrupt on PCINT20
PCMSK2 |= (1<<PCINT20);
//pin change interrupt enable 2
PCICR |= (1<<PCIE2);
// PB1=PCINT1 configuration
pinMode(METER3PIN, INPUT);
// turn on the internal 20k pull-up resistor
digitalWrite(METER3PIN, HIGH);
//enable pin change interrupt on PCINT1
PCMSK0 |= (1<<PCINT1);
//pin change interrupt enable 0
PCICR |= (1<<PCIE0);
// analog comparator setup for brown-out detection
// DP6=Vcc+R20k configuration
pinMode(POTPIN0, INPUT);
// turn on the internal 20k pull-up resistor
digitalWrite(POTPIN0, HIGH);
// DP7=AIN1 just configure as input to obtain high impedance
pinMode(POTPIN1, INPUT);
// DP8=GND configuration + connect the DP8 pin to GND
pinMode(POTPIN2, INPUT);
// comparing AIN1 (Vcc/4.4) to bandgap reference (1.1V)
// bandgap select | AC interrupt enable | AC interrupt on rising edge (DS p.243)
ACSR |= (1<<ACBG) | (1<<ACIE) | (1<<ACIS1) | (1<<ACIS0);
WDT_on();
//set global interrupt enable in SREG to 1 (DS p.12)
sei();
for(i=0; i<sizeof(measurements.meter); i++)
measurements.meter[i] = 0x12;
}
void loop()
{
// reset the watchdog timer
wdt_reset();
Serial.println("msg testing the integrity of the UART interface");
delay(500);
}

View File

@ -1,154 +0,0 @@
[CAM Processor Job]
Description[en]="<b>Generates Extended Gerber Format</b><p>\nThis CAM job consists of five sections that generate data for a two layer board.<p><p>\nYou will get five gerber files that contain data for:<br>\ncomponent side *.cmp<br>\nsolder side *.sol<br>\nsilkscreen component side *.plc<br>\nsolder stop component side *.stc<br>\nsolder stop solder sid *.sts<br>"
Section=Sec_1
Section=Sec_2
Section=Sec_3
Section=Sec_4
Section=Sec_5
Section=Sec_6
Section=Sec_7
Section=Sec_8
[Sec_1]
Name[en]="Top Copper"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=""
Rack=""
Scale=1
Output=".GTL"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 1 17 18 20"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_2]
Name[en]="Bottom Copper"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=".whl"
Rack=""
Scale=1
Output=".GBL"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 16 17 18"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_3]
Name[en]="Top Silkscreen"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=".whl"
Rack=""
Scale=1
Output=".GTO"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 21 25"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_4]
Name[en]="Top Paste"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=".whl"
Rack=""
Scale=1
Output=".GTP"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 31"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_5]
Name[en]="Bottom Silkscreen"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=""
Rack=""
Scale=1
Output=".GBO"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 22"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_6]
Name[en]="Top Soldermask"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=".whl"
Rack=""
Scale=1
Output=".GTS"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 29"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_7]
Name[en]="Bottom Soldermask"
Prompt[en]=""
Device="GERBER_RS274X"
Wheel=".whl"
Rack=""
Scale=1
Output=".GBS"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 30"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"
[Sec_8]
Name[en]="Drill File"
Prompt[en]=""
Device="EXCELLON"
Wheel=""
Rack="/Users/icarus75/Documents/eagle/flukso.sensor.board.v2.0/flukso.sensor.board.v2.0.DRL"
Scale=1
Output=".DRD"
Flags="0 0 0 1 0 1 1"
Emulate="0 0 0"
Offset="0.0mil 0.0mil"
Sheet=1
Tolerance="0 0 0 0 0 0"
Pen="0.0mil 0"
Page="12000.0mil 8000.0mil"
Layers=" 44 45"
Colors=" 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 6 6 4 8 8 8 8 8 8 8 8 8 8 8 8 8 4 4 1 1 1 1 3 3 1 2 6 8 8 5 8 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 4 3 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0"

View File

@ -1,72 +0,0 @@
description[en] = <b>EAGLE Design Rules</b>\n<p>\nThe default Design Rules have been set to cover\na wide range of applications. Your particular design\nmay have different requirements, so please make the\nnecessary adjustments and save your customized\ndesign rules under a new name.
layerSetup = (1*16)
mtCopper = 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm
mtIsolate = 1.5mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm
mdWireWire = 10mil
mdWirePad = 10mil
mdWireVia = 10mil
mdPadPad = 10mil
mdPadVia = 10mil
mdViaVia = 10mil
mdSmdPad = 10mil
mdSmdVia = 10mil
mdSmdSmd = 10mil
mdViaViaSameLayer = 8mil
mnLayersViaInSmd = 2
mdCopperDimension = 40mil
mdDrill = 10mil
mdSmdStop = 0mil
msWidth = 10mil
msDrill = 24mil
msMicroVia = 9.99mm
msBlindViaRatio = 0.500000
rvPadTop = 0.250000
rvPadInner = 0.250000
rvPadBottom = 0.250000
rvViaOuter = 0.250000
rvViaInner = 0.250000
rvMicroViaOuter = 0.250000
rvMicroViaInner = 0.250000
rlMinPadTop = 10mil
rlMaxPadTop = 20mil
rlMinPadInner = 10mil
rlMaxPadInner = 20mil
rlMinPadBottom = 10mil
rlMaxPadBottom = 20mil
rlMinViaOuter = 8mil
rlMaxViaOuter = 20mil
rlMinViaInner = 8mil
rlMaxViaInner = 20mil
rlMinMicroViaOuter = 4mil
rlMaxMicroViaOuter = 20mil
rlMinMicroViaInner = 4mil
rlMaxMicroViaInner = 20mil
psTop = -1
psBottom = -1
psFirst = -1
psElongationLong = 100
psElongationOffset = 100
mvStopFrame = 0.100000
mvCreamFrame = 0.000000
mlMinStopFrame = 0mil
mlMaxStopFrame = 20mil
mlMinCreamFrame = 0mil
mlMaxCreamFrame = 0mil
mlViaStopLimit = 0mil
srRoundness = 0.000000
srMinRoundness = 0mil
srMaxRoundness = 0mil
slThermalGap = 0.500000
slMinThermalGap = 20mil
slMaxThermalGap = 100mil
slAnnulusIsolate = 20mil
slThermalIsolate = 10mil
slAnnulusRestring = 0
slThermalRestring = 1
slThermalsForVias = 0
checkGrid = 0
checkAngle = 0
checkFont = 1
checkRestrict = 1
useDiameter = 13
maxErrors = 50

View File

@ -1,72 +0,0 @@
description = <b>EAGLE Design Rules</b>\n<p>\nThe default Design Rules have been set to cover\na wide range of applications. Your particular design\nmay have different requirements, so please make the\nnecessary adjustments and save your customized\ndesign rules under a new name.
layerSetup = (1*16)
mtCopper = 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm
mtIsolate = 1.5mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm
mdWireWire = 8mil
mdWirePad = 8mil
mdWireVia = 8mil
mdPadPad = 8mil
mdPadVia = 8mil
mdViaVia = 8mil
mdSmdPad = 8mil
mdSmdVia = 8mil
mdSmdSmd = 8mil
mdViaViaSameLayer = 8mil
mnLayersViaInSmd = 2
mdCopperDimension = 40mil
mdDrill = 10mil
mdSmdStop = 0mil
msWidth = 8mil
msDrill = 0.6mm
msMicroVia = 0mil
msBlindViaRatio = 0.000000
rvPadTop = 0.250000
rvPadInner = 0.250000
rvPadBottom = 0.250000
rvViaOuter = 0.250000
rvViaInner = 0.250000
rvMicroViaOuter = 0.250000
rvMicroViaInner = 0.250000
rlMinPadTop = 10mil
rlMaxPadTop = 20mil
rlMinPadInner = 10mil
rlMaxPadInner = 20mil
rlMinPadBottom = 10mil
rlMaxPadBottom = 20mil
rlMinViaOuter = 8mil
rlMaxViaOuter = 20mil
rlMinViaInner = 8mil
rlMaxViaInner = 20mil
rlMinMicroViaOuter = 8mil
rlMaxMicroViaOuter = 20mil
rlMinMicroViaInner = 8mil
rlMaxMicroViaInner = 20mil
psTop = -1
psBottom = -1
psFirst = -1
psElongationLong = 100
psElongationOffset = 100
mvStopFrame = 0.100000
mvCreamFrame = 0.000000
mlMinStopFrame = 0mil
mlMaxStopFrame = 20mil
mlMinCreamFrame = 0mil
mlMaxCreamFrame = 0mil
mlViaStopLimit = 0mil
srRoundness = 0.000000
srMinRoundness = 0mil
srMaxRoundness = 0mil
slThermalGap = 0.500000
slMinThermalGap = 20mil
slMaxThermalGap = 100mil
slAnnulusIsolate = 20mil
slThermalIsolate = 10mil
slAnnulusRestring = 0
slThermalRestring = 1
slThermalsForVias = 0
checkGrid = 0
checkAngle = 0
checkFont = 1
checkRestrict = 1
useDiameter = 13
maxErrors = 50

Binary file not shown.

View File

@ -1,350 +0,0 @@
//
// main.c : AVR uC code for flukso sensor board
//
// Copyright (c) 2008-2009 jokamajo.org
// 2010 flukso.net
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <string.h>
#include <stdlib.h>
#include "wiring/wiring_private.h"
#include "main.h"
#include <avr/io.h>
// pin/register/ISR definitions
#include <avr/interrupt.h>
// eeprom library
#include <avr/eeprom.h>
// watchdog timer library
#include <avr/wdt.h>
// variable declarations
volatile struct state aux[4] = {{false, false, START, 0}, {false, false, START, 0}, {false, false, START, 0}, {false, false, START, 0}};
volatile struct sensor EEMEM EEPROM_measurements[4] = {{SENSOR0, START}, {SENSOR1, START}, {SENSOR2, START}, {SENSOR3, START}};
volatile struct sensor measurements[4];
volatile uint8_t muxn = 0;
volatile uint16_t timer = 0;
// interrupt service routine for INT0
ISR(INT0_vect) {
measurements[2].value++;
aux[2].pulse = true;
}
// interrupt service routine for INT1
ISR(INT1_vect) {
measurements[3].value++;
aux[3].pulse = true;
}
// interrupt service routine for PCI2 (PCINT20)
/**
ISR(PCINT2_vect) {
if (aux[4].toggle == false) {
aux[4].toggle = true;
}
else {
measurements[4].value++;
aux[4].pulse = true;
aux[4].toggle = false;
}
}
**/
// interrupt service routine for ADC
ISR(TIMER2_COMPA_vect) {
#if DBG > 0
PORTD |= (1<<PD4);
#endif
// read ADC result
// add to nano(Wh) counter
#if PHASE == 2
MacU16X16to32(aux[0].nano, METERCONST, ADC);
#else
MacU16X16to32(aux[muxn].nano, METERCONST, ADC);
#endif
if (aux[muxn].nano > WATT) {
measurements[muxn].value++;
aux[muxn].pulse = true;
aux[muxn].nano -= WATT;
aux[muxn].pulse_count++;
}
if (timer == SECOND) {
aux[muxn].nano_start = aux[muxn].nano_end;
aux[muxn].nano_end = aux[muxn].nano;
aux[muxn].pulse_count_final = aux[muxn].pulse_count;
aux[muxn].pulse_count = 0;
aux[muxn].power = true;
}
// cycle through the available ADC input channels (0 and 1)
muxn++;
if (!(muxn &= 0x1)) timer++;
if (timer > SECOND) timer = 0;
ADMUX &= 0xF8;
ADMUX |= muxn;
// start a new ADC conversion
ADCSRA |= (1<<ADSC);
#if DBG > 0
PORTD &= ~(1<<PD4);
#endif
#if DBG > 1
aux[muxn].nano = WATT+1;
timer = SECOND;
#endif
}
// interrupt service routine for analog comparator
ISR(ANALOG_COMP_vect) {
uint8_t i;
//debugging:
//measurements[3].value = END3;
//measurements[2].value = END2;
//measurements[1].value = END1;
//measurements[0].value = END0;
//disable uC sections to consume less power while writing to EEPROM
//disable UART Tx and Rx:
UCSR0B &= ~((1<<RXEN0) | (1<<TXEN0));
//disable ADC:
ADCSRA &= ~(1<<ADEN);
for (i=0; i<4; i++)
eeprom_write_block((const void*)&measurements[i].value, (void*)&EEPROM_measurements[i].value, 4);
//indicate writing to EEPROM has finished by lighting up the green LED
PORTB |= (1<<PB5);
//enable UART Tx and Rx:
UCSR0B |= (1<<RXEN0) | (1<<TXEN0);
// enable ADC and start a first ADC conversion
ADCSRA |= (1<<ADEN) | (1<<ADSC);
printString("msg BROWN-OUT\n");
}
// interrupt service routine for watchdog timeout
ISR(WDT_vect) {
uint8_t i;
for (i=0; i<4; i++)
eeprom_write_block((const void*)&measurements[i].value, (void*)&EEPROM_measurements[i].value, 4);
printString("msg WDT\n");
}
// disable WDT
void WDT_off(void) {
cli();
wdt_reset();
// clear the WDT reset flag in the status register
MCUSR &= ~(1<<WDRF);
// timed sequence to be able to change the WDT settings afterwards
WDTCSR |= (1<<WDCE) | (1<<WDE);
// disable WDT
WDTCSR = 0x00;
}
// enable WDT
void WDT_on(void) {
// enable the watchdog timer (2s)
wdt_enable(WDTO_2S);
// set watchdog interrupt enable flag
WDTCSR |= (1<<WDIE);
}
void setup()
{
// WDT_off(); -> moved the call to this function to start of the main loop, before init
// clock settings: divide by 8 to get a 1Mhz clock, allows us to set the BOD level to 1.8V (DS p.37)
CLKPR = (1<<CLKPCE);
CLKPR = (1<<CLKPS1) | (1<<CLKPS0);
// load meterid's and metervalues from EEPROM
eeprom_read_block((void*)&measurements, (const void*)&EEPROM_measurements, sizeof(measurements));
// init serial port
beginSerial(4800);
_delay_ms(100);
//LEDPIN=PB5/SCK configured as output pin
DDRB |= (1<<PB5);
// PD2=INT0 and PD3=INT1 configuration
// set as input pin with 20k pull-up enabled
PORTD |= (1<<PD2) | (1<<PD3);
// INT0 and INT1 to trigger an interrupt on a falling edge
EICRA = (1<<ISC01) | (1<<ISC11);
// enable INT0 and INT1 interrupts
EIMSK = (1<<INT0) | (1<<INT1);
#if DBG > 0
// re-use PD4 pin for tracing interrupt times
DDRD |= (1<<DDD4);
#else
// PD4=PCINT20 configuration
// set as input pin with 20k pull-up enabled
PORTD |= (1<<PD4);
//enable pin change interrupt on PCINT20
PCMSK2 |= (1<<PCINT20);
//pin change interrupt enable 2
PCICR |= (1<<PCIE2);
#endif
// analog comparator setup for brown-out detection
// PD7=AIN1 configured by default as input to obtain high impedance
// disable digital input cicuitry on AIN0 and AIN1 pins to reduce leakage current
DIDR1 |= (1<<AIN1D) | (1<<AIN0D);
// comparing AIN1 (Vcc/4.4) to bandgap reference (1.1V)
// bandgap select | AC interrupt enable | AC interrupt on rising edge (DS p.243)
ACSR |= (1<<ACBG) | (1<<ACIE) | (1<<ACIS1) | (1<<ACIS0);
// Timer2 set to CTC mode (DS p.146, 154, 157)
TCCR2A |= 1<<WGM21;
#if DBG > 0
// Toggle pin OC2A=PB3 on compare match
TCCR2A |= 1<<COM2A0;
#endif
// Set PB3 as output pin
DDRB |= (1<<DDB3);
// Timer2 clock prescaler set to 8 => fTOV2 = 1000kHz / 256 / 8 = 488.28Hz (DS p.158)
TCCR2B |= (1<<CS21);
// Enable output compare match interrupt for timer2 (DS p.159)
TIMSK2 |= (1<<OCIE2A);
// Increase sampling frequency to 1250Hz (= 625Hz per channel)
OCR2A = 0x63;
// disable digital input cicuitry on ADCx pins to reduce leakage current
DIDR0 |= (1<<ADC5D) | (1<<ADC4D) | (1<<ADC3D) | (1<<ADC2D) | (1<<ADC1D) | (1<<ADC0D);
// select VBG as reference for ADC
ADMUX |= (1<<REFS1) | (1<<REFS0);
// ADC prescaler set to 8 => 1000kHz / 8 = 125kHz (DS p.258)
ADCSRA |= (1<<ADPS1) | (1<<ADPS0);
// enable ADC and start a first ADC conversion
ADCSRA |= (1<<ADEN) | (1<<ADSC);
//set global interrupt enable in SREG to 1 (DS p.12)
sei();
}
void send(uint8_t msg_type, const struct sensor *measurement, const struct state *aux)
{
uint8_t i = 46;
char message[49];
uint32_t value = 0;
int32_t rest;
uint8_t pulse_count;
switch (msg_type) {
case PULSE:
// blink the green LED
PORTB |= (1<<PB5);
_delay_ms(20);
PORTB &= ~(1<<PB5);
cli();
value = measurement->value;
sei();
strcpy(message, "pls ");
break;
case POWER:
cli();
rest = aux->nano_end - aux->nano_start;
pulse_count = aux->pulse_count_final;
sei();
MacU16X16to32(value, (uint16_t)(labs(rest)/65536), 242);
value /= 1024;
if (rest >= 0)
value += pulse_count*3600;
else
value = pulse_count*3600 - value;
strcpy(message, "pwr ");
break;
}
strcpy(&message[4], measurement->id);
strcpy(&message[36], ":0000000000\n");
do { // generate digits in reverse order
message[i--] = '0' + value % 10; // get next digit
} while ((value /= 10) > 0); // delete it
printString(message);
}
void loop()
{
uint8_t i;
// check whether we have to send out a pls or pwr to the deamon
for (i=0; i<4; i++) {
if (aux[i].pulse == true) {
send(PULSE, (const struct sensor *)&measurements[i], (const struct state *)&aux[i]);
aux[i].pulse = false;
}
if (aux[i].power == true) {
send(POWER, (const struct sensor *)&measurements[i], (const struct state *)&aux[i]);
aux[i].power = false;
}
}
wdt_reset();
}
int main(void)
{
uint8_t i;
WDT_off();
setup();
// insert a startup delay of 20s to prevent interference with redboot
// interrupts are already enabled at this stage
// so the pulses are counted but not sent to the deamon
for (i=0; i<4; i++) _delay_ms(5000);
serialFlush();
printString("\n");
WDT_on();
for (;;) loop();
return 0;
}

View File

@ -1,112 +0,0 @@
//
// main.h : AVR uC header file for flukso sensor board
// Copyright (c) 2008-2009 jokamajo.org
// Copyright (c) 2010 flukso.net
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
//
# define PULSE 0
# define POWER 1
# define WATT 1000000000
# define SECOND 624 // 625Hz - 1
#ifndef SENSOR0
#error "SENSOR0 not defined"
#endif
#ifndef SENSOR1
#error "SENSOR1 not defined"
#endif
#ifndef SENSOR2
#error "SENSOR2 not defined"
#endif
#ifndef SENSOR3
#error "SENSOR3 not defined"
#endif
#ifndef PHASE
#error "PHASE not defined"
#endif
#ifndef METERCONST
#error "METERCONST not defined"
#endif
#define START 0
#define END3 0xffffffff
#define END2 0xeeeeeeee
#define END1 0xdddddddd
#define END0 0xcccccccc
// This macro performs a 16x16 -> 32 unsigned MAC in 37 cycles with operands and results in memory
// based on http://www2.ife.ee.ethz.ch/~roggend/publications/wear/DSPMic_v1.1.pdf par 3.4 and table 31.
#define MacU16X16to32(uint_32Acc, uint_16In1, uint_16In2) \
asm volatile ( \
"clr r2 \n\t" \
"mul %B2, %B1 \n\t" \
"movw r4, r0 \n\t" \
"mul %A2, %A1 \n\t" \
"add %A0, r0 \n\t" \
"adc %B0, r1 \n\t" \
"adc %C0, r4 \n\t" \
"adc %D0, r5 \n\t" \
"mul %B2, %A1 \n\t" \
"add %B0, r0 \n\t" \
"adc %C0, r1 \n\t" \
"adc %D0, r2 \n\t" \
"mul %A2, %B1 \n\t" \
"add %B0, r0 \n\t" \
"adc %C0, r1 \n\t" \
"adc %D0, r2 \n\t" \
"clr r1 \n\t" \
: \
"+r" (uint_32Acc) \
: \
"a" (uint_16In1), \
"a" (uint_16In2) \
: \
"r2", "r4", "r5" \
)
// datastructures
struct state {
boolean pulse;
boolean toggle;
uint32_t nano;
uint16_t adc;
boolean power;
uint32_t nano_start;
uint32_t nano_end;
uint8_t pulse_count;
uint8_t pulse_count_final;
};
struct sensor {
char id[33];
uint32_t value;
};
// prototypes
void WDT_off(void);
void WDT_on(void);
void send(uint8_t msg_type, const struct sensor *measurement, const struct state *aux);

View File

@ -1,515 +0,0 @@
#ifndef Binary_h
#define Binary_h
#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
#define B00000000 0
#define B1 1
#define B01 1
#define B001 1
#define B0001 1
#define B00001 1
#define B000001 1
#define B0000001 1
#define B00000001 1
#define B10 2
#define B010 2
#define B0010 2
#define B00010 2
#define B000010 2
#define B0000010 2
#define B00000010 2
#define B11 3
#define B011 3
#define B0011 3
#define B00011 3
#define B000011 3
#define B0000011 3
#define B00000011 3
#define B100 4
#define B0100 4
#define B00100 4
#define B000100 4
#define B0000100 4
#define B00000100 4
#define B101 5
#define B0101 5
#define B00101 5
#define B000101 5
#define B0000101 5
#define B00000101 5
#define B110 6
#define B0110 6
#define B00110 6
#define B000110 6
#define B0000110 6
#define B00000110 6
#define B111 7
#define B0111 7
#define B00111 7
#define B000111 7
#define B0000111 7
#define B00000111 7
#define B1000 8
#define B01000 8
#define B001000 8
#define B0001000 8
#define B00001000 8
#define B1001 9
#define B01001 9
#define B001001 9
#define B0001001 9
#define B00001001 9
#define B1010 10
#define B01010 10
#define B001010 10
#define B0001010 10
#define B00001010 10
#define B1011 11
#define B01011 11
#define B001011 11
#define B0001011 11
#define B00001011 11
#define B1100 12
#define B01100 12
#define B001100 12
#define B0001100 12
#define B00001100 12
#define B1101 13
#define B01101 13
#define B001101 13
#define B0001101 13
#define B00001101 13
#define B1110 14
#define B01110 14
#define B001110 14
#define B0001110 14
#define B00001110 14
#define B1111 15
#define B01111 15
#define B001111 15
#define B0001111 15
#define B00001111 15
#define B10000 16
#define B010000 16
#define B0010000 16
#define B00010000 16
#define B10001 17
#define B010001 17
#define B0010001 17
#define B00010001 17
#define B10010 18
#define B010010 18
#define B0010010 18
#define B00010010 18
#define B10011 19
#define B010011 19
#define B0010011 19
#define B00010011 19
#define B10100 20
#define B010100 20
#define B0010100 20
#define B00010100 20
#define B10101 21
#define B010101 21
#define B0010101 21
#define B00010101 21
#define B10110 22
#define B010110 22
#define B0010110 22
#define B00010110 22
#define B10111 23
#define B010111 23
#define B0010111 23
#define B00010111 23
#define B11000 24
#define B011000 24
#define B0011000 24
#define B00011000 24
#define B11001 25
#define B011001 25
#define B0011001 25
#define B00011001 25
#define B11010 26
#define B011010 26
#define B0011010 26
#define B00011010 26
#define B11011 27
#define B011011 27
#define B0011011 27
#define B00011011 27
#define B11100 28
#define B011100 28
#define B0011100 28
#define B00011100 28
#define B11101 29
#define B011101 29
#define B0011101 29
#define B00011101 29
#define B11110 30
#define B011110 30
#define B0011110 30
#define B00011110 30
#define B11111 31
#define B011111 31
#define B0011111 31
#define B00011111 31
#define B100000 32
#define B0100000 32
#define B00100000 32
#define B100001 33
#define B0100001 33
#define B00100001 33
#define B100010 34
#define B0100010 34
#define B00100010 34
#define B100011 35
#define B0100011 35
#define B00100011 35
#define B100100 36
#define B0100100 36
#define B00100100 36
#define B100101 37
#define B0100101 37
#define B00100101 37
#define B100110 38
#define B0100110 38
#define B00100110 38
#define B100111 39
#define B0100111 39
#define B00100111 39
#define B101000 40
#define B0101000 40
#define B00101000 40
#define B101001 41
#define B0101001 41
#define B00101001 41
#define B101010 42
#define B0101010 42
#define B00101010 42
#define B101011 43
#define B0101011 43
#define B00101011 43
#define B101100 44
#define B0101100 44
#define B00101100 44
#define B101101 45
#define B0101101 45
#define B00101101 45
#define B101110 46
#define B0101110 46
#define B00101110 46
#define B101111 47
#define B0101111 47
#define B00101111 47
#define B110000 48
#define B0110000 48
#define B00110000 48
#define B110001 49
#define B0110001 49
#define B00110001 49
#define B110010 50
#define B0110010 50
#define B00110010 50
#define B110011 51
#define B0110011 51
#define B00110011 51
#define B110100 52
#define B0110100 52
#define B00110100 52
#define B110101 53
#define B0110101 53
#define B00110101 53
#define B110110 54
#define B0110110 54
#define B00110110 54
#define B110111 55
#define B0110111 55
#define B00110111 55
#define B111000 56
#define B0111000 56
#define B00111000 56
#define B111001 57
#define B0111001 57
#define B00111001 57
#define B111010 58
#define B0111010 58
#define B00111010 58
#define B111011 59
#define B0111011 59
#define B00111011 59
#define B111100 60
#define B0111100 60
#define B00111100 60
#define B111101 61
#define B0111101 61
#define B00111101 61
#define B111110 62
#define B0111110 62
#define B00111110 62
#define B111111 63
#define B0111111 63
#define B00111111 63
#define B1000000 64
#define B01000000 64
#define B1000001 65
#define B01000001 65
#define B1000010 66
#define B01000010 66
#define B1000011 67
#define B01000011 67
#define B1000100 68
#define B01000100 68
#define B1000101 69
#define B01000101 69
#define B1000110 70
#define B01000110 70
#define B1000111 71
#define B01000111 71
#define B1001000 72
#define B01001000 72
#define B1001001 73
#define B01001001 73
#define B1001010 74
#define B01001010 74
#define B1001011 75
#define B01001011 75
#define B1001100 76
#define B01001100 76
#define B1001101 77
#define B01001101 77
#define B1001110 78
#define B01001110 78
#define B1001111 79
#define B01001111 79
#define B1010000 80
#define B01010000 80
#define B1010001 81
#define B01010001 81
#define B1010010 82
#define B01010010 82
#define B1010011 83
#define B01010011 83
#define B1010100 84
#define B01010100 84
#define B1010101 85
#define B01010101 85
#define B1010110 86
#define B01010110 86
#define B1010111 87
#define B01010111 87
#define B1011000 88
#define B01011000 88
#define B1011001 89
#define B01011001 89
#define B1011010 90
#define B01011010 90
#define B1011011 91
#define B01011011 91
#define B1011100 92
#define B01011100 92
#define B1011101 93
#define B01011101 93
#define B1011110 94
#define B01011110 94
#define B1011111 95
#define B01011111 95
#define B1100000 96
#define B01100000 96
#define B1100001 97
#define B01100001 97
#define B1100010 98
#define B01100010 98
#define B1100011 99
#define B01100011 99
#define B1100100 100
#define B01100100 100
#define B1100101 101
#define B01100101 101
#define B1100110 102
#define B01100110 102
#define B1100111 103
#define B01100111 103
#define B1101000 104
#define B01101000 104
#define B1101001 105
#define B01101001 105
#define B1101010 106
#define B01101010 106
#define B1101011 107
#define B01101011 107
#define B1101100 108
#define B01101100 108
#define B1101101 109
#define B01101101 109
#define B1101110 110
#define B01101110 110
#define B1101111 111
#define B01101111 111
#define B1110000 112
#define B01110000 112
#define B1110001 113
#define B01110001 113
#define B1110010 114
#define B01110010 114
#define B1110011 115
#define B01110011 115
#define B1110100 116
#define B01110100 116
#define B1110101 117
#define B01110101 117
#define B1110110 118
#define B01110110 118
#define B1110111 119
#define B01110111 119
#define B1111000 120
#define B01111000 120
#define B1111001 121
#define B01111001 121
#define B1111010 122
#define B01111010 122
#define B1111011 123
#define B01111011 123
#define B1111100 124
#define B01111100 124
#define B1111101 125
#define B01111101 125
#define B1111110 126
#define B01111110 126
#define B1111111 127
#define B01111111 127
#define B10000000 128
#define B10000001 129
#define B10000010 130
#define B10000011 131
#define B10000100 132
#define B10000101 133
#define B10000110 134
#define B10000111 135
#define B10001000 136
#define B10001001 137
#define B10001010 138
#define B10001011 139
#define B10001100 140
#define B10001101 141
#define B10001110 142
#define B10001111 143
#define B10010000 144
#define B10010001 145
#define B10010010 146
#define B10010011 147
#define B10010100 148
#define B10010101 149
#define B10010110 150
#define B10010111 151
#define B10011000 152
#define B10011001 153
#define B10011010 154
#define B10011011 155
#define B10011100 156
#define B10011101 157
#define B10011110 158
#define B10011111 159
#define B10100000 160
#define B10100001 161
#define B10100010 162
#define B10100011 163
#define B10100100 164
#define B10100101 165
#define B10100110 166
#define B10100111 167
#define B10101000 168
#define B10101001 169
#define B10101010 170
#define B10101011 171
#define B10101100 172
#define B10101101 173
#define B10101110 174
#define B10101111 175
#define B10110000 176
#define B10110001 177
#define B10110010 178
#define B10110011 179
#define B10110100 180
#define B10110101 181
#define B10110110 182
#define B10110111 183
#define B10111000 184
#define B10111001 185
#define B10111010 186
#define B10111011 187
#define B10111100 188
#define B10111101 189
#define B10111110 190
#define B10111111 191
#define B11000000 192
#define B11000001 193
#define B11000010 194
#define B11000011 195
#define B11000100 196
#define B11000101 197
#define B11000110 198
#define B11000111 199
#define B11001000 200
#define B11001001 201
#define B11001010 202
#define B11001011 203
#define B11001100 204
#define B11001101 205
#define B11001110 206
#define B11001111 207
#define B11010000 208
#define B11010001 209
#define B11010010 210
#define B11010011 211
#define B11010100 212
#define B11010101 213
#define B11010110 214
#define B11010111 215
#define B11011000 216
#define B11011001 217
#define B11011010 218
#define B11011011 219
#define B11011100 220
#define B11011101 221
#define B11011110 222
#define B11011111 223
#define B11100000 224
#define B11100001 225
#define B11100010 226
#define B11100011 227
#define B11100100 228
#define B11100101 229
#define B11100110 230
#define B11100111 231
#define B11101000 232
#define B11101001 233
#define B11101010 234
#define B11101011 235
#define B11101100 236
#define B11101101 237
#define B11101110 238
#define B11101111 239
#define B11110000 240
#define B11110001 241
#define B11110010 242
#define B11110011 243
#define B11110100 244
#define B11110101 245
#define B11110110 246
#define B11110111 247
#define B11111000 248
#define B11111001 249
#define B11111010 250
#define B11111011 251
#define B11111100 252
#define B11111101 253
#define B11111110 254
#define B11111111 255
#endif

View File

@ -1,159 +0,0 @@
/*
wiring_serial.c - serial functions.
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
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., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
*/
#include "wiring_private.h"
// Define constants and variables for buffering incoming serial data. We're
// using a ring buffer (I think), in which rx_buffer_head is the index of the
// location to which to write the next incoming character and rx_buffer_tail
// is the index of the location from which to read.
#define RX_BUFFER_SIZE 1
unsigned char rx_buffer[RX_BUFFER_SIZE];
int rx_buffer_head = 0;
int rx_buffer_tail = 0;
void beginSerial(long baud)
{
UBRR0H = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8;
UBRR0L = ((F_CPU / 16 + baud / 2) / baud - 1);
// enable rx and tx
sbi(UCSR0B, RXEN0);
sbi(UCSR0B, TXEN0);
// enable interrupt on complete reception of a byte
sbi(UCSR0B, RXCIE0);
// defaults to 8-bit, no parity, 1 stop bit
}
void serialWrite(unsigned char c)
{
while (!(UCSR0A & (1 << UDRE0)))
;
UDR0 = c;
}
int serialAvailable()
{
return (RX_BUFFER_SIZE + rx_buffer_head - rx_buffer_tail) % RX_BUFFER_SIZE;
}
int serialRead()
{
// if the head isn't ahead of the tail, we don't have any characters
if (rx_buffer_head == rx_buffer_tail) {
return -1;
} else {
unsigned char c = rx_buffer[rx_buffer_tail];
rx_buffer_tail = (rx_buffer_tail + 1) % RX_BUFFER_SIZE;
return c;
}
}
void serialFlush()
{
// don't reverse this or there may be problems if the RX interrupt
// occurs after reading the value of rx_buffer_head but before writing
// the value to rx_buffer_tail; the previous value of rx_buffer_head
// may be written to rx_buffer_tail, making it appear as if the buffer
// were full, not empty.
rx_buffer_head = rx_buffer_tail;
}
SIGNAL(SIG_USART_RECV)
{
unsigned char c = UDR0;
int i = (rx_buffer_head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != rx_buffer_tail) {
rx_buffer[rx_buffer_head] = c;
rx_buffer_head = i;
}
}
void printByte(unsigned char c)
{
serialWrite(c);
}
void printString(const char *s)
{
while (*s)
printByte(*s++);
}
void printIntegerInBase(unsigned long n, unsigned long base)
{
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
unsigned long i = 0;
if (n == 0) {
printByte('0');
return;
}
while (n > 0) {
buf[i++] = n % base;
n /= base;
}
for (; i > 0; i--)
printByte(buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10);
}
void printInteger(long n)
{
if (n < 0) {
printByte('-');
n = -n;
}
printIntegerInBase(n, 10);
}
void printHex(unsigned long n)
{
printIntegerInBase(n, 16);
}
void printOctal(unsigned long n)
{
printIntegerInBase(n, 8);
}
void printBinary(unsigned long n)
{
printIntegerInBase(n, 2);
}

View File

@ -1,119 +0,0 @@
/*
wiring.h - Partial implementation of the Wiring API for the ATmega8.
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
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., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: wiring.h 387 2008-03-08 21:30:00Z mellis $
*/
#ifndef Wiring_h
#define Wiring_h
#include <avr/io.h>
#include "binary.h"
#ifdef __cplusplus
extern "C"{
#endif
#define HIGH 0x1
#define LOW 0x0
#define INPUT 0x0
#define OUTPUT 0x1
#define true 0x1
#define false 0x0
#define PI 3.14159265
#define HALF_PI 1.57079
#define TWO_PI 6.283185
#define DEG_TO_RAD 0.01745329
#define RAD_TO_DEG 57.2957786
#define SERIAL 0x0
#define DISPLAY 0x1
#define LSBFIRST 0
#define MSBFIRST 1
#define CHANGE 1
#define FALLING 2
#define RISING 3
#define INTERNAL 3
#define DEFAULT 1
#define EXTERNAL 0
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif
#define int(x) ((int)(x))
#define char(x) ((char)(x))
#define long(x) ((long)(x))
#define byte(x) ((uint8_t)(x))
#define float(x) ((float)(x))
#define boolean(x) ((uint8_t)((x)==0?0:1))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
#define interrupts() sei()
#define noInterrupts() cli()
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
typedef uint8_t boolean;
typedef uint8_t byte;
void init(void);
void beginSerial(long);
void serialWrite(unsigned char);
int serialAvailable(void);
int serialRead(void);
void serialFlush(void);
void printByte(unsigned char c);
void printString(const char *s);
void printInteger(long n);
void printHex(unsigned long n);
void printOctal(unsigned long n);
void printBinary(unsigned long n);
void printIntegerInBase(unsigned long n, unsigned long base);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val);
void setup(void);
void loop(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif

View File

@ -1,58 +0,0 @@
/*
wiring_private.h - Internal header file.
Part of Arduino - http://www.arduino.cc/
Copyright (c) 2005-2006 David A. Mellis
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., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
$Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
*/
#ifndef WiringPrivate_h
#define WiringPrivate_h
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
#include <stdarg.h>
#include "wiring.h"
#ifdef __cplusplus
extern "C"{
#endif
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#define EXTERNAL_INT_0 0
#define EXTERNAL_INT_1 1
#define EXTERNAL_NUM_INTERRUPTS 2
typedef void (*voidFuncPtr)(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif