-// Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the
-// distribution.
-// * All advertising materials mentioning features or use of this
-// software must display the following acknowledgement: This product
-// includes software developed by tm3d.de and its contributors.
-// * Neither the name of tm3d.de nor the names of its contributors may
-// be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-.global TIMER_INTERRUPT
-TIMER_INTERRUPT:
- sdb
- push r_temp
- in r_temp,_SFR_IO_ADDR(SREG)
- push r_temp
- cdb
- sbic OW_PIN,OW_PINN ; abkuerzung wenn Leitung schon h
- rjmp tint_end ; Leitung 1 kein Reset
- ldi r_temp,0
- out TCNT_REG,r_temp
- CLEAR_TOV_FLAG
-tint_loop_rend:
- sbis OW_PIN,OW_PINN ;warten bis leitung wieder h
- rjmp tint_loop_rend
- JMP_NO_TOV ;ueberspringe wenn kein ueberlauf
- rjmp tint_overrun
- in r_temp,TCNT_REG ;schauen ob es lange genug gedauert hat fuer reset
- cpi r_temp,OWT_RESET2
- brlo tint_end
-tint_overrun:
- ldi r_temp,0
- out TCNT_REG,r_temp
- ;zwischen Reset und Presets
-tint_loop_res_pres:
- in r_temp,TCNT_REG
- cpi r_temp,OWT_RESET_PRESENT
- brlo tint_loop_res_pres ;Warten zwischen reset und presets
- sbi OW_DDR,OW_PINN ;presents impuls
- ;reset impuls
-tint_loop_pres:
- in r_temp,TCNT_REG
- cpi r_temp,OWT_PRESENT
- brlo tint_loop_pres
- cbi OW_DDR,OW_PINN
- ldi r_temp,OW_READ_ROM_COMMAND ; Initialisieren von Rom command
- sts mode,r_temp
- ldi r_temp,1
- sts reset_indicator,r_temp
- sts bcount,r_temp ;bit eins
- clr r_temp
- sts sendflag,r_temp ;empfangen (rom_command)
- ;sts wzero,r_temp ;alles 0
- RESETZEROMARKER
- CLEAR_INTERRUPT_FLAG
-tint_end:
- ;CLEAR_INTERRUPT_FLAG
- DIS_TIM_INT
- pop r_temp
- out _SFR_IO_ADDR(SREG),r_temp
- pop r_temp
- reti
-;;;
+// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// All rights reserved. \r
+// \r
+// Redistribution and use in source and binary forms, with or without \r
+// modification, are permitted provided that the following conditions are \r
+// met: \r
+// \r
+// * Redistributions of source code must retain the above copyright \r
+// notice, this list of conditions and the following disclaimer. \r
+// * Redistributions in binary form must reproduce the above copyright \r
+// notice, this list of conditions and the following disclaimer in the \r
+// documentation and/or other materials provided with the \r
+// distribution. \r
+// * All advertising materials mentioning features or use of this \r
+// software must display the following acknowledgement: This product \r
+// includes software developed by tm3d.de and its contributors. \r
+// * Neither the name of tm3d.de nor the names of its contributors may \r
+// be used to endorse or promote products derived from this software \r
+// without specific prior written permission. \r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+\r
+.global TIMER_INTERRUPT\r
+TIMER_INTERRUPT:\r
+ sdb\r
+ push r_temp\r
+ in r_temp,_SFR_IO_ADDR(SREG) \r
+ push r_temp\r
+ push r_temp2\r
+ cdb\r
+ sbic OW_PIN,OW_PINN ; abkuerzung wenn Leitung schon h\r
+ rjmp tint_end ; Leitung 1 kein Reset\r
+ ldi r_temp,0 \r
+ out TCNT_REG,r_temp\r
+ CLEAR_TOV_FLAG\r
+ ldi r_temp2,3 ;3x overrun for timeout\r
+tint_loop_rend:\r
+ JMP_NO_TOV ;ueberspringe wenn kein ueberlauf\r
+ rjmp tint_handle_timeout\r
+ sbis OW_PIN,OW_PINN ;warten bis leitung wieder h \r
+ rjmp tint_loop_rend\r
+ ;JMP_NO_TOV ;ueberspringe wenn kein ueberlauf\r
+ cpi r_temp2,3\r
+ ;rjmp tint_overrun\r
+ brne tint_overrun\r
+ in r_temp,TCNT_REG ;schauen ob es lange genug gedauert hat fuer reset\r
+ cpi r_temp,OWT_RESET2 \r
+ brlo tint_end\r
+tint_overrun:\r
+ ldi r_temp,0\r
+ out TCNT_REG,r_temp\r
+ ;zwischen Reset und Presets\r
+tint_loop_res_pres:\r
+ in r_temp,TCNT_REG\r
+ cpi r_temp,OWT_RESET_PRESENT\r
+ brlo tint_loop_res_pres ;Warten zwischen reset und presets\r
+ sbi OW_DDR,OW_PINN ;presents impuls\r
+ ;reset impuls\r
+tint_loop_pres:\r
+ in r_temp,TCNT_REG\r
+ cpi r_temp,OWT_PRESENT\r
+ brlo tint_loop_pres\r
+ cbi OW_DDR,OW_PINN \r
+ ldi r_temp,OW_READ_ROM_COMMAND ; Initialisieren von Rom command\r
+ sts mode,r_temp\r
+ ldi r_temp,1\r
+ sts reset_indicator,r_temp\r
+ sts bcount,r_temp ;bit eins\r
+ clr r_temp\r
+ sts sendflag,r_temp ;empfangen (rom_command)\r
+ ;sts wzero,r_temp ;alles 0 \r
+ RESETZEROMARKER\r
+ CLEAR_INTERRUPT_FLAG\r
+tint_end:\r
+ ;CLEAR_INTERRUPT_FLAG\r
+ DIS_TIM_INT\r
+ pop r_temp2\r
+ pop r_temp\r
+ out _SFR_IO_ADDR(SREG),r_temp\r
+ pop r_temp\r
+ reti\r
+;;;\r
+\r
+tint_handle_timeout:\r
+ dec r_temp2\r
+ breq tint_end\r
+ CLEAR_TOV_FLAG\r
+ rjmp tint_loop_rend
\ No newline at end of file