2 // Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
3 // All rights reserved.
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the
15 // * All advertising materials mentioning features or use of this
16 // software must display the following acknowledgement: This product
17 // includes software developed by tm3d.de and its contributors.
18 // * Neither the name of tm3d.de nor the names of its contributors may
19 // be used to endorse or promote products derived from this software
20 // without specific prior written permission.
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #define _CHANGEABLE_ID_
36 #define _ZERO_POLLING_
37 #include "../common/OWConfig.s"
38 #include "../common/OWCRC16.s"
47 rjmp h_writescratchpad
48 rjmp h_writescratchpad_crc
51 rjmp h_readmemory_addr
53 rjmp h_readmemorycounter_addr
54 rjmp h_readmemorycounter
55 rjmp h_readmemorycounter_ex
58 #include "../common/OWRomFunctions.s"
59 #include "../common/OWTimerInterrupt.s"
63 ; Ab hier Geraeteabhaenging
64 #define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+0
65 #define OW_WRITE_SCRATCHPAD_CRC OW_FIRST_COMMAND+1
66 #define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+2
67 #define OW_COPY_SCRATCHPAD OW_FIRST_COMMAND+3
68 #define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+4
69 #define OW_READ_MEMORY OW_FIRST_COMMAND+5
70 #define OW_READ_MEMORYCOUNTER_ADDR OW_FIRST_COMMAND+6
71 #define OW_READ_MEMORYCOUNTER OW_FIRST_COMMAND+7
72 #define OW_READ_MEMORYCOUNTER_EX OW_FIRST_COMMAND+8
74 ;---------------------------------------------------
75 ; READ COMMAND and start operation
76 ;---------------------------------------------------
82 FLASH_COMMANDS ; muss zu erst sein....
84 cset 0x0F,OW_WRITE_SCRATCHPAD
85 cjmp 0xAA,hrc_set_readscratchpad
86 cset 0x5A,OW_COPY_SCRATCHPAD
87 cset 0xF0,OW_READ_MEMORY_ADDR
88 cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR
90 #ifdef _CHANGEABLE_ID_
96 hrc_set_readscratchpad:
97 ldi r_mode,OW_READ_SCRATCHPAD
106 breq h_writescratchpad_block
107 brsh h_writescratchpad_set_eoffset ;;33
108 rjmp handle_end ;handle_end zu weit entfernt fuer br...
109 h_writescratchpad_set_eoffset:
111 breq h_writescratchpad_setcrc
114 sts pack+2,r_temp ;AA und PF cleared
116 ;Start writeing to 32 Byte Block ; skip status byte
117 h_writescratchpad_block:
118 lds r_temp,pack ; Adresse low byte
119 andi r_temp,0x1F ;32 byte
120 add r_bytep,r_temp ;Zur angegebenen Startadresse springen
121 ;ori r_temp,0x20 ; Set PF flag
122 sts pack+2,r_temp ;E4:E0 vorher setzen
123 ; Byte 3 ueberspringen
126 h_writescratchpad_setcrc:
132 com r_temp ; invertieren , komischer name.....
134 ldi r_mode,OW_WRITE_SCRATCHPAD_CRC
137 h_writescratchpad_crc:
139 breq h_writescratchpad_crc_end
143 h_writescratchpad_crc_end:
144 rjmp handle_end_sleep
149 breq h_readscratchpad_end
151 brne h_readscratchpad_read_byte
152 h_readscratchpad_set_offset:
158 h_readscratchpad_read_byte:
162 h_readscratchpad_end:
163 rjmp handle_end_sleep
169 brsh h_copyscratchpad_ok
174 brne h_copyscratchpad_nok
176 breq h_copyscratchpad_ok
183 h_copyscratchpad_nok:
187 rjmp handle_end_sleep
192 brne h_readmrmory_addr_byte1
195 h_readmrmory_addr_byte1:
197 ldi r_mode,OW_READ_MEMORY
208 rjmp h_readmemory_end
214 configZ pack+3,r_bytep
218 rjmp handle_end_sleep
227 h_readmemorycounter_addr:
229 brne h_readmrmorycounter_addr_byte1
234 h_readmrmorycounter_addr_byte1:
236 ldi r_mode,OW_READ_MEMORYCOUNTER
240 rjmp h_readmemorycounter2
244 ldi r_temp,1 ;inc leider kein c flag
250 breq h_readmemorycounter_next
253 h_readmemorycounter2: ;Lesen von dem worauf die erstenzwei bytes zeigen
256 configZ pack+3,r_bytep
260 //h_readmemorycounter_end:
261 // ldi r_mode,OW_SLEEP
264 h_readmemorycounter_next: ; rest lesen
265 ldi r_mode,OW_READ_MEMORYCOUNTER_EX
275 brne h_readmemorycounter_cFF
281 configZ counters,r_temp2
290 rjmp h_readmemorycounter_ex
291 h_readmemorycounter_cFF:
298 h_readmemorycounter_ex:
301 breq h_readmemorycounter_ex_end
303 brne h_readmemorycounter_ex2
310 h_readmemorycounter_ex2:
315 h_readmemorycounter_ex_end:
318 ldi r_temp,1 ;inc leider kein c flag
322 sbrc r_temp2,1 ;am ene von allem
323 rjmp h_readmemorycounter_ex_sleep
325 ldi r_mode,OW_READ_MEMORYCOUNTER
328 rjmp h_readmemorycounter2
329 h_readmemorycounter_ex_sleep:
338 #include "../common/OWPinInterrupt.s"