From d854067c7475a5caef754cafedc8ca8d67f7ee73 Mon Sep 17 00:00:00 2001 From: Matthew Coates Date: Tue, 11 Dec 2007 22:34:36 -0500 Subject: [PATCH] Fixed line breaks. --- cameras/Nikon_OML-L3.inc | 446 +++++++++++++++++++++++------------------------ openinterval.asm | 332 +++++++++++++++++------------------ 2 files changed, 389 insertions(+), 389 deletions(-) diff --git a/cameras/Nikon_OML-L3.inc b/cameras/Nikon_OML-L3.inc index 72e319b..3385b01 100644 --- a/cameras/Nikon_OML-L3.inc +++ b/cameras/Nikon_OML-L3.inc @@ -1,223 +1,223 @@ -; Infrared remote control for Nikon D70 with Atmel 8bit MCU -; -; Copyright (C) 2005, 2006 Michele Bighignoli - Laives (BZ) - ITALY # www.bigmike.it/ircontrol -; -; Version 2.0.0-OI - 12/2007 -; Modified by Matt Coates (mattjackets+openinterval at gmail.com) -; for use as an include file for the OpenInterval project -; (http://repo.or.cz/w/OpenInterval.git) -; -; 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 St, Fifth Floor, Boston, MA 02110-1301 USA -; -; -; Implementation note: -; --------------------------- -; IR led is controlled by PD0 (with NPN transistor). -; Led is "on" when PD0 is high. -; -; This code has tested with ATTiny2313 and ATMEGA8535 with 8.0 MHz Xtal -; -; Should work with every Atmel 8bit MCU -; -; -; Special thanks to: -; ------------------ -; Gerhard Schmidt (DG4FAC) - http://www.avr-asm-tutorial.net/index.html -; Brian Hammill - http://www.ipass.net/~hammill -; -; -; WaveForm data (03/2006 version): -; -; Infrared period = 26us (~38.4kHz) -; -; Strart pulse: 2000us -; pause: 27830us -; 1st pulse: 390us -; pause: 1580us -; 2nd pulse: 410us -; pause: 3580us -; 3rd pulse: 400us -; longpause: 63200us -; -; REPEAT ONE TIME -; - -.DEF DelayReg = R23 -.DEF MainLoopC = R22 -.DEF Counter = R21 -.DEF Counter2 = R20 - -delay130: -; This is a 13.0 uS delay (104 cycles @ 8MHz) -; -; sbi/cbi = 2 cycles -; rcall = 3 cycles -; - nop - nop -; -delay130_led_on: - nop - nop - nop -; -delay130_led_off: - nop - nop - ldi DelayReg,30 ; 1 cycle -delay130_loop: - dec DelayReg ; 1 cycle - brne delay130_loop ; 2 cycle if jump to label, 1 if not - ret ; 4 cycles - - -; Code executed at startup - -shutterrelease: - ldi MainLoopC,2 ; Send a complete waveform 2 times - -mainloop: - -; Send start pulse (2000 uS) - ldi Counter,77 ; (13 uS * 2 ) * 77 = 2002 uS -startpulse: - sbi irport,irpin ; LED on - rcall delay130_led_on ; Wait 13.0 uS - cbi irport,irpin ; LED off - rcall delay130_led_off ; wait 13.0 uS - dec Counter - brne startpulse - -; Pause (27830 uS) - ldi Counter,237 -startpause: - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - dec Counter - brne startpause - - rcall delay130_led_off - -; Send first pulse (390 uS) - ldi Counter,15 -pulse1: - sbi irport,irpin ; LED on - rcall delay130_led_on - cbi irport,irpin ; LED off - rcall delay130_led_off - dec Counter - brne pulse1 - -; Pause (1580 uS) - ldi Counter,118 -pause1: - rcall delay130 - dec Counter - brne pause1 - - ldi Counter,5 -pause1b: - dec Counter - brne pause1b - - -; Send 2nd pulse (410 uS) -; -; NOTE: with Counter=16 the pulse width is 416 uS (counting the last "led off" time) -; using Counter=15 and an additional "led on", it's possible to add the last 7 uS (led off) to the pause 2 -; -; Counter=15 = 390 uS + -; "led on" = 13 uS = -; TOTAL = 403 uS -; - - ldi Counter,15 -pulse2: - sbi irport,irpin ; LED on - rcall delay130_led_on - cbi irport,irpin ; LED off - rcall delay130_led_off - dec Counter - brne pulse2 - - sbi irport,irpin ; LED on - rcall delay130_led_on - cbi irport,irpin ; LED off - -; Pause (3580 uS + 7 uS from pulse2 = 3587 uS) - ldi Counter,136 -pause2: - rcall delay130 - rcall delay130 - dec Counter - brne pause2 - -; Send 3th pulse (400 uS) - (in real world = 403 uS) - ldi Counter,15 -pulse3: - sbi irport,irpin ; LED on - rcall delay130_led_on - cbi irport,irpin ; LED off - rcall delay130_led_off - dec Counter - brne pulse3 - - sbi irport,irpin ; LED on - rcall delay130_led_on - cbi irport,irpin ; LED off - - dec MainLoopC -; No long pause before sleep - breq returnfromshutterrelease - - -; Pause for 63200 uS - ldi Counter,239 -longpause: - ldi Counter2,10 -longpause1: - rcall delay130 - rcall delay130 - dec Counter2 - brne longpause1 - dec Counter - brne longpause - -; At moment : 63126 uS + 3 uS from pulse3 = 63129 uS - - ldi Counter,5 -longpause2: - rcall delay130 - dec Counter - brne longpause2 - -; At moment 63193 uS + 3 uS from pulse3 = 63196 uS - - ldi Counter,10 ; 3,75 uS -longpause3: - dec Counter - brne longpause3 - - rjmp mainloop - -returnfromshutterrelease: - ret +; Infrared remote control for Nikon D70 with Atmel 8bit MCU +; +; Copyright (C) 2005, 2006 Michele Bighignoli - Laives (BZ) - ITALY # www.bigmike.it/ircontrol +; +; Version 2.0.0-OI - 12/2007 +; Modified by Matt Coates (mattjackets+openinterval at gmail.com) +; for use as an include file for the OpenInterval project +; (http://repo.or.cz/w/OpenInterval.git) +; +; 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 St, Fifth Floor, Boston, MA 02110-1301 USA +; +; +; Implementation note: +; --------------------------- +; IR led is controlled by PD0 (with NPN transistor). +; Led is "on" when PD0 is high. +; +; This code has tested with ATTiny2313 and ATMEGA8535 with 8.0 MHz Xtal +; +; Should work with every Atmel 8bit MCU +; +; +; Special thanks to: +; ------------------ +; Gerhard Schmidt (DG4FAC) - http://www.avr-asm-tutorial.net/index.html +; Brian Hammill - http://www.ipass.net/~hammill +; +; +; WaveForm data (03/2006 version): +; +; Infrared period = 26us (~38.4kHz) +; +; Strart pulse: 2000us +; pause: 27830us +; 1st pulse: 390us +; pause: 1580us +; 2nd pulse: 410us +; pause: 3580us +; 3rd pulse: 400us +; longpause: 63200us +; +; REPEAT ONE TIME +; + +.DEF DelayReg = R23 +.DEF MainLoopC = R22 +.DEF Counter = R21 +.DEF Counter2 = R20 + +delay130: +; This is a 13.0 uS delay (104 cycles @ 8MHz) +; +; sbi/cbi = 2 cycles +; rcall = 3 cycles +; + nop + nop +; +delay130_led_on: + nop + nop + nop +; +delay130_led_off: + nop + nop + ldi DelayReg,30 ; 1 cycle +delay130_loop: + dec DelayReg ; 1 cycle + brne delay130_loop ; 2 cycle if jump to label, 1 if not + ret ; 4 cycles + + +; Code executed at startup + +shutterrelease: + ldi MainLoopC,2 ; Send a complete waveform 2 times + +mainloop: + +; Send start pulse (2000 uS) + ldi Counter,77 ; (13 uS * 2 ) * 77 = 2002 uS +startpulse: + sbi irport,irpin ; LED on + rcall delay130_led_on ; Wait 13.0 uS + cbi irport,irpin ; LED off + rcall delay130_led_off ; wait 13.0 uS + dec Counter + brne startpulse + +; Pause (27830 uS) + ldi Counter,237 +startpause: + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + dec Counter + brne startpause + + rcall delay130_led_off + +; Send first pulse (390 uS) + ldi Counter,15 +pulse1: + sbi irport,irpin ; LED on + rcall delay130_led_on + cbi irport,irpin ; LED off + rcall delay130_led_off + dec Counter + brne pulse1 + +; Pause (1580 uS) + ldi Counter,118 +pause1: + rcall delay130 + dec Counter + brne pause1 + + ldi Counter,5 +pause1b: + dec Counter + brne pause1b + + +; Send 2nd pulse (410 uS) +; +; NOTE: with Counter=16 the pulse width is 416 uS (counting the last "led off" time) +; using Counter=15 and an additional "led on", it's possible to add the last 7 uS (led off) to the pause 2 +; +; Counter=15 = 390 uS + +; "led on" = 13 uS = +; TOTAL = 403 uS +; + + ldi Counter,15 +pulse2: + sbi irport,irpin ; LED on + rcall delay130_led_on + cbi irport,irpin ; LED off + rcall delay130_led_off + dec Counter + brne pulse2 + + sbi irport,irpin ; LED on + rcall delay130_led_on + cbi irport,irpin ; LED off + +; Pause (3580 uS + 7 uS from pulse2 = 3587 uS) + ldi Counter,136 +pause2: + rcall delay130 + rcall delay130 + dec Counter + brne pause2 + +; Send 3th pulse (400 uS) - (in real world = 403 uS) + ldi Counter,15 +pulse3: + sbi irport,irpin ; LED on + rcall delay130_led_on + cbi irport,irpin ; LED off + rcall delay130_led_off + dec Counter + brne pulse3 + + sbi irport,irpin ; LED on + rcall delay130_led_on + cbi irport,irpin ; LED off + + dec MainLoopC +; No long pause before sleep + breq returnfromshutterrelease + + +; Pause for 63200 uS + ldi Counter,239 +longpause: + ldi Counter2,10 +longpause1: + rcall delay130 + rcall delay130 + dec Counter2 + brne longpause1 + dec Counter + brne longpause + +; At moment : 63126 uS + 3 uS from pulse3 = 63129 uS + + ldi Counter,5 +longpause2: + rcall delay130 + dec Counter + brne longpause2 + +; At moment 63193 uS + 3 uS from pulse3 = 63196 uS + + ldi Counter,10 ; 3,75 uS +longpause3: + dec Counter + brne longpause3 + + rjmp mainloop + +returnfromshutterrelease: + ret diff --git a/openinterval.asm b/openinterval.asm index 2cf78a5..98961f5 100644 --- a/openinterval.asm +++ b/openinterval.asm @@ -1,166 +1,166 @@ -; OpenInterval -; -; Copyright 2007 Matthew F. Coates (mattjackets+openinterval at gmail.com) -; -; 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 3 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, see . - -.include "include/tn12def.inc" -.EQU buttonPin = 1 ; button -.EQU syncPin = 3 ; sync LED port -.EQU irPort = PORTB; ir LED port -.EQU irPin = 4 ; ir LED pin -.equ FREQ = 0 ; start out with no interval - -.def temp = r16 -.def tcounter = r17 -.def tcounter2 = r18 -.def mode = r19 -.def DelayReg2 = r24 - -.cseg -.org 0x0000 - -reset: - rjmp init ; Reset handler - rjmp INT0_hand ; INT0 handler - reti ; Pin change handler - rjmp TIM0_OVF ; Timer0 overflow handler - reti ; EEPROM Ready handler - reti ; Analog Comparator handler - -;camera include file goes here -.include "cameras/Nikon_OML-L3.inc" - -init: -; enable sleep mode and INT0 on falling edge - ldi temp, (1 << SE) | (1 << ISC01) & (0 << ISC00) - out MCUCR, temp - -; disable ACD - ldi temp, (1 << ACD) - out ACSR, temp - -; enable timer0 -; ldi temp, 0 -; out TCNT0, temp - -; set timer prescaler 1024 - ldi temp, (1 << CS02) | (1 << CS00) - out TCCR0, temp - -; enable timer overflow - ldi temp, (1 << TOIE0) - out TIMSK, temp - -; enable INT0 interrupt - ldi temp, (1 << INT0) - out GIMSK, temp - - ldi temp,0 - ldi DelayReg,FREQ - ldi tcounter,FREQ - ldi mode,0 - -; Set portB input - sbi PORTB,buttonPin ; set b4 config. to enable internal pull-up. - cbi DDRB,buttonPin -; Set portB output - sbi DDRB,irPin - sbi DDRB,syncPin - - sbi irPort,irPin ; LED off - rcall shutterrelease - sei - -GoToSleep: - sleep - rjmp GoToSleep - -TIM0_OVF: ; -- handle timer0 overflow, trigger shutter - cpi mode,1 - breq TIMING - sbi portb,syncPin - cpi tcounter2, 0 - brne SKIP - cpi tcounter,0 - brne SKIP - cbi portb,syncPin - mov tcounter, DelayReg - rcall shutterrelease -skip: - dec tcounter - cpi tcounter,0 - breq dectcounter2 - reti -DecTCounter2: - dec tcounter2 - reti -Timing: - inc DelayReg - cpi DelayReg,0 - breq INCDelayReg2 - reti - -INCDelayReg2: - inc DelayReg2 - reti - -INT0_hand: - ldi Counter,255 -intpause: - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - rcall delay130 - dec Counter - brne intpause - - cpi mode,1 - breq setdelay - -; enable timer0 - ldi temp, 0 - out TCNT0, temp - cbi portb,SyncPin - ldi mode,1 ; timing mode - reti - -SetDelay: - sbi portb,syncPin - mov tcounter,DelayReg - mov tcounter2,DelayReg2 - ldi mode,2 ; running mode - - reti +; OpenInterval +; +; Copyright 2007 Matthew F. Coates (mattjackets+openinterval at gmail.com) +; +; 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 3 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, see . + +.include "include/tn12def.inc" +.EQU buttonPin = 1 ; button +.EQU syncPin = 3 ; sync LED port +.EQU irPort = PORTB; ir LED port +.EQU irPin = 4 ; ir LED pin +.equ FREQ = 0 ; start out with no interval + +.def temp = r16 +.def tcounter = r17 +.def tcounter2 = r18 +.def mode = r19 +.def DelayReg2 = r24 + +.cseg +.org 0x0000 + +reset: + rjmp init ; Reset handler + rjmp INT0_hand ; INT0 handler + reti ; Pin change handler + rjmp TIM0_OVF ; Timer0 overflow handler + reti ; EEPROM Ready handler + reti ; Analog Comparator handler + +;camera include file goes here +.include "cameras/Nikon_OML-L3.inc" + +init: +; enable sleep mode and INT0 on falling edge + ldi temp, (1 << SE) | (1 << ISC01) & (0 << ISC00) + out MCUCR, temp + +; disable ACD + ldi temp, (1 << ACD) + out ACSR, temp + +; enable timer0 +; ldi temp, 0 +; out TCNT0, temp + +; set timer prescaler 1024 + ldi temp, (1 << CS02) | (1 << CS00) + out TCCR0, temp + +; enable timer overflow + ldi temp, (1 << TOIE0) + out TIMSK, temp + +; enable INT0 interrupt + ldi temp, (1 << INT0) + out GIMSK, temp + + ldi temp,0 + ldi DelayReg,FREQ + ldi tcounter,FREQ + ldi mode,0 + +; Set portB input + sbi PORTB,buttonPin ; set b4 config. to enable internal pull-up. + cbi DDRB,buttonPin +; Set portB output + sbi DDRB,irPin + sbi DDRB,syncPin + + sbi irPort,irPin ; LED off + rcall shutterrelease + sei + +GoToSleep: + sleep + rjmp GoToSleep + +TIM0_OVF: ; -- handle timer0 overflow, trigger shutter + cpi mode,1 + breq TIMING + sbi portb,syncPin + cpi tcounter2, 0 + brne SKIP + cpi tcounter,0 + brne SKIP + cbi portb,syncPin + mov tcounter, DelayReg + rcall shutterrelease +skip: + dec tcounter + cpi tcounter,0 + breq dectcounter2 + reti +DecTCounter2: + dec tcounter2 + reti +Timing: + inc DelayReg + cpi DelayReg,0 + breq INCDelayReg2 + reti + +INCDelayReg2: + inc DelayReg2 + reti + +INT0_hand: + ldi Counter,255 +intpause: + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + rcall delay130 + dec Counter + brne intpause + + cpi mode,1 + breq setdelay + +; enable timer0 + ldi temp, 0 + out TCNT0, temp + cbi portb,SyncPin + ldi mode,1 ; timing mode + reti + +SetDelay: + sbi portb,syncPin + mov tcounter,DelayReg + mov tcounter2,DelayReg2 + ldi mode,2 ; running mode + + reti -- 2.11.4.GIT