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.
34 #define _CHANGEABLE_ID_
35 #include "../common/OWConfig.s"
36 #include "../common/OWCRC16.s"
48 #include "../common/OWRomFunctions.s"
49 #include "../common/OWTimerInterrupt.s"
53 ; Ab hier Geraeteabhaenging
54 #define OW_CHANNEL_ACCESS OW_FIRST_COMMAND+0
56 ;---------------------------------------------------
57 ; READ COMMAND and start operation
58 ;---------------------------------------------------
64 FLASH_COMMANDS ; muss zu erst sein....
66 cset 0x0F,OW_WRITE_SCRATCHPAD
67 cjmp 0xAA,hrc_set_readscratchpad
68 cset 0x5A,OW_COPY_SCRATCHPAD
69 cset 0xF0,OW_READ_MEMORY_ADDR
70 cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR
71 #ifdef _CHANGEABLE_ID_
77 hrc_set_readscratchpad:
78 ldi r_mode,OW_READ_SCRATCHPAD
87 breq h_writescratchpad_block
88 brsh h_writescratchpad_set_eoffset ;;33
89 rjmp handle_end ;handle_end zu weit entfernt fuer br...
90 h_writescratchpad_set_eoffset:
92 breq h_writescratchpad_setcrc
95 sts pack+2,r_temp ;AA und PF cleared
97 ;Start writeing to 32 Byte Block ; skip status byte
98 h_writescratchpad_block:
99 lds r_temp,pack ; Adresse low byte
100 andi r_temp,0x1F ;32 byte
101 add r_bytep,r_temp ;Zur angegebenen Startadresse springen
102 ;ori r_temp,0x20 ; Set PF flag
103 sts pack+2,r_temp ;E4:E0 vorher setzen
104 ; Byte 3 ueberspringen
107 h_writescratchpad_setcrc:
113 com r_temp ; invertieren , komischer name.....
115 ldi r_mode,OW_WRITE_SCRATCHPAD_CRC
118 h_writescratchpad_crc:
120 breq h_writescratchpad_crc_end
124 h_writescratchpad_crc_end:
125 rjmp handle_end_sleep
130 breq h_readscratchpad_end
132 brne h_readscratchpad_read_byte
133 h_readscratchpad_set_offset:
139 h_readscratchpad_read_byte:
143 h_readscratchpad_end:
144 rjmp handle_end_sleep
150 brsh h_copyscratchpad_ok
155 brne h_copyscratchpad_nok
157 breq h_copyscratchpad_ok
164 h_copyscratchpad_nok:
168 rjmp handle_end_sleep
173 brne h_readmrmory_addr_byte1
176 h_readmrmory_addr_byte1:
178 ldi r_mode,OW_READ_MEMORY
189 rjmp h_readmemory_end
195 configZ pack+3,r_bytep
199 rjmp handle_end_sleep
208 h_readmemorycounter_addr:
210 brne h_readmrmorycounter_addr_byte1
215 h_readmrmorycounter_addr_byte1:
217 ldi r_mode,OW_READ_MEMORYCOUNTER
221 rjmp h_readmemorycounter2
225 ldi r_temp,1 ;inc leider kein c flag
231 breq h_readmemorycounter_next
234 h_readmemorycounter2: ;Lesen von dem worauf die erstenzwei bytes zeigen
237 configZ pack+3,r_bytep
241 //h_readmemorycounter_end:
242 // ldi r_mode,OW_SLEEP
245 h_readmemorycounter_next: ; rest lesen
246 ldi r_mode,OW_READ_MEMORYCOUNTER_EX
256 brne h_readmemorycounter_cFF
262 configZ counters,r_temp2
271 rjmp h_readmemorycounter_ex
272 h_readmemorycounter_cFF:
279 h_readmemorycounter_ex:
282 breq h_readmemorycounter_ex_end
284 brne h_readmemorycounter_ex2
291 h_readmemorycounter_ex2:
296 h_readmemorycounter_ex_end:
299 ldi r_temp,1 ;inc leider kein c flag
303 sbrc r_temp2,1 ;am ene von allem
304 rjmp h_readmemorycounter_ex_sleep
306 ldi r_mode,OW_READ_MEMORYCOUNTER
309 rjmp h_readmemorycounter2
310 h_readmemorycounter_ex_sleep:
319 #include "../common/OWPinInterrupt.s"