; ; CNC touch probe driver ; ; Copyright (c) 2009 Michael Buesch ; ; 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 ; Trip switch 1 .equ PROBESW2_BIT = 1 ; Trip switch 2 .equ PROBESW3_BIT = 2 ; Trip switch 3 .equ PROBEEN_BIT = 3 ; Probe-enable switch .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