2 // Copyright (c) 2015, Tobias Mueller tm(at)tm3d.de
\r
3 // All rights reserved.
\r
5 // Redistribution and use in source and binary forms, with or without
\r
6 // modification, are permitted provided that the following conditions are
\r
9 // * Redistributions of source code must retain the above copyright
\r
10 // notice, this list of conditions and the following disclaimer.
\r
11 // * Redistributions in binary form must reproduce the above copyright
\r
12 // notice, this list of conditions and the following disclaimer in the
\r
13 // documentation and/or other materials provided with the
\r
15 // * All advertising materials mentioning features or use of this
\r
16 // software must display the following acknowledgement: This product
\r
17 // includes software developed by tm3d.de and its contributors.
\r
18 // * Neither the name of tm3d.de nor the names of its contributors may
\r
19 // be used to endorse or promote products derived from this software
\r
20 // without specific prior written permission.
\r
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
\r
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
\r
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
\r
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
\r
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
34 #define _CHANGEABLE_ID_
\r
35 #include "../common/OWConfig.s"
\r
36 #include "../common/OWCRC16.s"
\r
44 .macro COMMAND_TABLE
\r
45 rjmp h_channelaccess
\r
48 #include "../common/OWRomFunctions.s"
\r
49 #include "../common/OWTimerInterrupt.s"
\r
53 ; Ab hier Geraeteabhaenging
\r
54 #define OW_CHANNEL_ACCESS OW_FIRST_COMMAND+0
\r
56 ;---------------------------------------------------
\r
57 ; READ COMMAND and start operation
\r
58 ;---------------------------------------------------
\r
64 FLASH_COMMANDS ; muss zu erst sein....
\r
66 cset 0x0F,OW_WRITE_SCRATCHPAD
\r
67 cjmp 0xAA,hrc_set_readscratchpad
\r
68 cset 0x5A,OW_COPY_SCRATCHPAD
\r
69 cset 0xF0,OW_READ_MEMORY_ADDR
\r
70 cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR
\r
71 #ifdef _CHANGEABLE_ID_
\r
77 hrc_set_readscratchpad:
\r
78 ldi r_mode,OW_READ_SCRATCHPAD
\r
80 rjmp h_readscratchpad
\r
83 configZ pack,r_bytep
\r
87 breq h_writescratchpad_block
\r
88 brsh h_writescratchpad_set_eoffset ;;33
\r
89 rjmp handle_end ;handle_end zu weit entfernt fuer br...
\r
90 h_writescratchpad_set_eoffset:
\r
92 breq h_writescratchpad_setcrc
\r
95 sts pack+2,r_temp ;AA und PF cleared
\r
97 ;Start writeing to 32 Byte Block ; skip status byte
\r
98 h_writescratchpad_block:
\r
99 lds r_temp,pack ; Adresse low byte
\r
100 andi r_temp,0x1F ;32 byte
\r
101 add r_bytep,r_temp ;Zur angegebenen Startadresse springen
\r
102 ;ori r_temp,0x20 ; Set PF flag
\r
103 sts pack+2,r_temp ;E4:E0 vorher setzen
\r
104 ; Byte 3 ueberspringen
\r
105 rjmp handle_end_inc
\r
107 h_writescratchpad_setcrc:
\r
113 com r_temp ; invertieren , komischer name.....
\r
115 ldi r_mode,OW_WRITE_SCRATCHPAD_CRC
\r
118 h_writescratchpad_crc:
\r
120 breq h_writescratchpad_crc_end
\r
121 configZ pack,r_bytep
\r
123 rjmp handle_end_inc
\r
124 h_writescratchpad_crc_end:
\r
125 rjmp handle_end_sleep
\r
130 breq h_readscratchpad_end
\r
132 brne h_readscratchpad_read_byte
\r
133 h_readscratchpad_set_offset:
\r
139 h_readscratchpad_read_byte:
\r
140 configZ pack,r_bytep
\r
142 rjmp handle_end_inc
\r
143 h_readscratchpad_end:
\r
144 rjmp handle_end_sleep
\r
150 brsh h_copyscratchpad_ok
\r
151 configZ pack,r_bytep
\r
155 brne h_copyscratchpad_nok
\r
157 breq h_copyscratchpad_ok
\r
160 h_copyscratchpad_ok:
\r
164 h_copyscratchpad_nok:
\r
168 rjmp handle_end_sleep
\r
173 brne h_readmrmory_addr_byte1
\r
175 rjmp handle_end_inc
\r
176 h_readmrmory_addr_byte1:
\r
177 sts pack+1,r_rwbyte
\r
178 ldi r_mode,OW_READ_MEMORY
\r
189 rjmp h_readmemory_end
\r
195 configZ pack+3,r_bytep
\r
199 rjmp handle_end_sleep
\r
208 h_readmemorycounter_addr:
\r
210 brne h_readmrmorycounter_addr_byte1
\r
215 h_readmrmorycounter_addr_byte1:
\r
216 sts pack+1,r_rwbyte
\r
217 ldi r_mode,OW_READ_MEMORYCOUNTER
\r
221 rjmp h_readmemorycounter2
\r
222 h_readmemorycounter:
\r
225 ldi r_temp,1 ;inc leider kein c flag
\r
231 breq h_readmemorycounter_next
\r
234 h_readmemorycounter2: ;Lesen von dem worauf die erstenzwei bytes zeigen
\r
237 configZ pack+3,r_bytep
\r
241 //h_readmemorycounter_end:
\r
242 // ldi r_mode,OW_SLEEP
\r
245 h_readmemorycounter_next: ; rest lesen
\r
246 ldi r_mode,OW_READ_MEMORYCOUNTER_EX
\r
256 brne h_readmemorycounter_cFF
\r
262 configZ counters,r_temp2
\r
264 sts pack+35,r_temp
\r
266 sts pack+36,r_temp
\r
268 sts pack+37,r_temp
\r
270 sts pack+38,r_temp
\r
271 rjmp h_readmemorycounter_ex
\r
272 h_readmemorycounter_cFF:
\r
274 sts pack+35,r_temp
\r
275 sts pack+36,r_temp
\r
276 sts pack+37,r_temp
\r
277 sts pack+38,r_temp
\r
279 h_readmemorycounter_ex:
\r
282 breq h_readmemorycounter_ex_end
\r
284 brne h_readmemorycounter_ex2
\r
291 h_readmemorycounter_ex2:
\r
293 configZ pack,r_bytep
\r
296 h_readmemorycounter_ex_end:
\r
299 ldi r_temp,1 ;inc leider kein c flag
\r
303 sbrc r_temp2,1 ;am ene von allem
\r
304 rjmp h_readmemorycounter_ex_sleep
\r
306 ldi r_mode,OW_READ_MEMORYCOUNTER
\r
309 rjmp h_readmemorycounter2
\r
310 h_readmemorycounter_ex_sleep:
\r
311 ldi r_mode,OW_SLEEP
\r
319 #include "../common/OWPinInterrupt.s"
\r