From 561f27d9bfac0de35b949c326d6432ca64864ba9 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 26 Jul 2009 20:28:11 +0200 Subject: Add touchprobe firmware Signed-off-by: Michael Buesch --- touchprobe/firmware/Makefile | 43 ++++ touchprobe/firmware/m8def.inc | 467 +++++++++++++++++++++++++++++++++++++++ touchprobe/firmware/touchprobe.S | 178 +++++++++++++++ 3 files changed, 688 insertions(+) create mode 100644 touchprobe/firmware/Makefile create mode 100644 touchprobe/firmware/m8def.inc create mode 100644 touchprobe/firmware/touchprobe.S diff --git a/touchprobe/firmware/Makefile b/touchprobe/firmware/Makefile new file mode 100644 index 0000000..7be8c66 --- /dev/null +++ b/touchprobe/firmware/Makefile @@ -0,0 +1,43 @@ +ASM ?= avra +AVRDUDE ?= avrdude +AVRDUDE_ARCH ?= m8 +AVRDUDE_SPEED ?= 1 +PROGRAMMER ?= avrisp2 +PROGPORT ?= usb + +LFUSE = 0xE0 +HFUSE = 0xD9 + + +NAME = touchprobe +HEX = $(NAME).S.hex + +all: $(HEX) + +$(HEX): $(NAME).S m8def.inc + $(ASM) $(NAME).S + -srec_cat $(HEX) -Intel -Output $(NAME).S.bin -Binary + @echo + @echo "Successfully built the firmware" + +install: all + $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \ + -c $(PROGRAMMER) -P $(PROGPORT) -U flash:w:$(HEX) + +avrdude: + $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \ + -c $(PROGRAMMER) -P $(PROGPORT) -t + +reset: + $(AVRDUDE) -B $(AVRDUDE_SPEED) -p $(AVRDUDE_ARCH) \ + -c $(PROGRAMMER) -P $(PROGPORT) \ + -U signature:r:/dev/null:i -q -q + +writefuse: + $(AVRDUDE) -B 10 -p $(AVRDUDE_ARCH) \ + -c $(PROGRAMMER) -P $(PROGPORT) -q -q \ + -U lfuse:w:$(LFUSE):m \ + -U hfuse:w:$(HFUSE):m + +clean: + -rm -f *~ *.cof *.hex *.obj *.bin *.bak *.cache.* *.o diff --git a/touchprobe/firmware/m8def.inc b/touchprobe/firmware/m8def.inc new file mode 100644 index 0000000..eff65db --- /dev/null +++ b/touchprobe/firmware/m8def.inc @@ -0,0 +1,467 @@ +;*************************************************************************** +;* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y +;* +;* Number :AVR000 +;* File Name :"m8def.inc" +;* Title :Register/Bit Definitions for the ATmega8 +;* Date :07.09.2001 +;* Version :1.00 +;* Support telephone :+47 72 88 43 88 (ATMEL Norway) +;* Support fax :+47 72 88 43 99 (ATMEL Norway) +;* Support E-mail :avr@atmel.no +;* Target MCU :ATmega8 +;* +;* DESCRIPTION +;* When including this file in the assembly program file, all I/O register +;* names and I/O register bit names appearing in the data book can be used. +;* In addition, the six registers forming the three data pointers X, Y and +;* Z have been assigned names XL - ZH. Highest RAM address for Internal +;* SRAM is also defined +;* +;* The Register names are represented by their hexadecimal address. +;* +;* The Register Bit names are represented by their bit number (0-7). +;* +;* Please observe the difference in using the bit names with instructions +;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc" +;* (skip if bit in register set/cleared). The following example illustrates +;* this: +;* +;* in r16,PORTB ;read PORTB latch +;* sbr r16,(1< +; +; 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. + +.listmac +.include "m8def.inc" + + +.def zero = r0 ; Always zero'd +.def sregsave = r1 ; SREG scratch space for IRQ handlers +.def t0 = r16 ; Temp reg 0 +.def t1 = r17 ; Temp reg 1 +.def t2 = r18 ; Temp reg 2 +.def t3 = r19 ; Temp reg 3 +.def buzzcount = r25 ; Buzzer duration counter + + +; Hardware definitions +.equ PROBESW_PIN = PINC ; Probe switches input +.equ PROBESW1_BIT = 0 +.equ PROBESW2_BIT = 1 +.equ PROBESW3_BIT = 2 +.equ PROBESW_MASK = (1<= DELAY_1MS_LOOP + cpi t3, DELAY_1MS_LOOP + brlo __mdelay_timer_loop + dec t2 ; Decrement the 1ms loop counter + brne __mdelay_1ms_loop + subi t0, low(1) + sbci t1, high(1) + brne __mdelay_loop ; Wait another millisecond + out TCCR0, zero ; Stop timer0 + pop t3 + pop t2 + ret -- cgit v1.2.3