2 // Copyright (c) 2017, 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 #define _ZERO_POLLING_
\r
36 //#define _HANDLE_CC_COMMAND_
\r
39 #include "../common/OWConfig.s"
\r
40 #include "../common/OWCRC16.s"
\r
43 .extern counters1,16
\r
46 .extern counters2,16
\r
48 #define pack2 pack1
\r
49 ;same EEPROM for Attiny44
\r
53 .macro CHIP_INIT ;r_temp is pushed other Registers should be saved
\r
56 .macro COMMAND_TABLE
\r
57 rjmp h_writescratchpad1
\r
58 rjmp h_writescratchpad_crc1
\r
59 rjmp h_readscratchpad1
\r
60 rjmp h_copyscratchpad1
\r
61 rjmp h_readmemory_addr1
\r
63 rjmp h_readmemorycounter_addr1
\r
64 rjmp h_readmemorycounter1
\r
65 rjmp h_readmemorycounter_ex1
\r
69 rjmp h_accesswrite_read2
\r
72 #include "../common/OWRomFunctionsDual.s"
\r
73 #include "../common/OWTimerInterrupt.s"
\r
77 ; Ab hier Geraeteabhaenging
\r
78 #define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+0
\r
79 #define OW_WRITE_SCRATCHPAD_CRC1 OW_FIRST_COMMAND+1
\r
80 #define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+2
\r
81 #define OW_COPY_SCRATCHPAD1 OW_FIRST_COMMAND+3
\r
82 #define OW_READ_MEMORY_ADDR1 OW_FIRST_COMMAND+4
\r
83 #define OW_READ_MEMORY1 OW_FIRST_COMMAND+5
\r
84 #define OW_READ_MEMORYCOUNTER_ADDR1 OW_FIRST_COMMAND+6
\r
85 #define OW_READ_MEMORYCOUNTER1 OW_FIRST_COMMAND+7
\r
86 #define OW_READ_MEMORYCOUNTER_EX1 OW_FIRST_COMMAND+8
\r
88 #define OW_ACCESSREAD2 OW_FIRST_COMMAND+9
\r
89 #define OW_ACCESSWRITE2 OW_FIRST_COMMAND+10
\r
90 #define OW_ACCESSWRITE_READ2 OW_FIRST_COMMAND+11
\r
93 ;---------------------------------------------------
\r
94 ; READ COMMAND and start operation
\r
95 ;---------------------------------------------------
\r
100 FLASH_COMMANDS ; muss zu erst sein....
\r
102 cset 0x0F,OW_WRITE_SCRATCHPAD1
\r
103 cjmp 0xAA,hrc_set_readscratchpad1
\r
104 cset 0x5A,OW_COPY_SCRATCHPAD1
\r
105 cset 0xF0,OW_READ_MEMORY_ADDR1
\r
106 cset 0xA5,OW_READ_MEMORYCOUNTER_ADDR1
\r
108 #ifdef _CHANGEABLE_ID_
\r
111 ldi r_mode,OW_SLEEP
\r
114 hrc_set_readscratchpad1:
\r
115 ldi r_mode,OW_READ_SCRATCHPAD1
\r
117 rjmp h_readscratchpad1
\r
119 h_writescratchpad1:
\r
120 configZ pack1,r_bytep
\r
124 breq h_writescratchpad_block1
\r
125 brsh h_writescratchpad_set_eoffset1 ;;33
\r
126 rjmp handle_end ;handle_end zu weit entfernt fuer br...
\r
127 h_writescratchpad_set_eoffset1:
\r
129 breq h_writescratchpad_setcrc1
\r
132 sts pack1+2,r_temp ;AA und PF cleared
\r
134 ;Start writeing to 32 Byte Block ; skip status byte
\r
135 h_writescratchpad_block1:
\r
136 lds r_temp,pack1 ; Adresse low byte
\r
137 andi r_temp,0x1F ;32 byte
\r
138 add r_bytep,r_temp ;Zur angegebenen Startadresse springen
\r
139 ;ori r_temp,0x20 ; Set PF flag
\r
140 sts pack1+2,r_temp ;E4:E0 vorher setzen
\r
141 ; Byte 3 ueberspringen
\r
142 rjmp handle_end_inc
\r
144 h_writescratchpad_setcrc1:
\r
148 sts pack1+43,r_temp
\r
150 com r_temp ; invertieren , komischer name.....
\r
151 sts pack1+44,r_temp
\r
152 ldi r_mode,OW_WRITE_SCRATCHPAD_CRC1
\r
155 h_writescratchpad_crc1:
\r
157 breq h_writescratchpad_crc_end1
\r
158 configZ pack1,r_bytep
\r
160 rjmp handle_end_inc
\r
161 h_writescratchpad_crc_end1:
\r
162 rjmp handle_end_sleep
\r
167 breq h_readscratchpad_end1
\r
169 brne h_readscratchpad_read_byte1
\r
170 h_readscratchpad_set_offset1:
\r
176 h_readscratchpad_read_byte1:
\r
177 configZ pack1,r_bytep
\r
179 rjmp handle_end_inc
\r
180 h_readscratchpad_end1:
\r
181 rjmp handle_end_sleep
\r
187 brsh h_copyscratchpad_ok1
\r
188 configZ pack1,r_bytep
\r
192 brne h_copyscratchpad_nok1
\r
194 breq h_copyscratchpad_ok1
\r
197 h_copyscratchpad_ok1:
\r
201 h_copyscratchpad_nok1:
\r
205 rjmp handle_end_sleep
\r
208 h_readmemory_addr1:
\r
210 brne h_readmrmory_addr_byte11
\r
212 rjmp handle_end_inc
\r
213 h_readmrmory_addr_byte11:
\r
214 sts pack1+1,r_rwbyte
\r
215 ldi r_mode,OW_READ_MEMORY1
\r
218 rjmp h_readmemory21
\r
221 lds r_temp2,pack1+1
\r
226 rjmp h_readmemory_end1
\r
232 configZ pack1+3,r_bytep
\r
236 rjmp handle_end_sleep
\r
245 h_readmemorycounter_addr1:
\r
247 brne h_readmrmorycounter_addr_byte11
\r
252 h_readmrmorycounter_addr_byte11:
\r
253 sts pack1+1,r_rwbyte
\r
254 ldi r_mode,OW_READ_MEMORYCOUNTER1
\r
258 rjmp h_readmemorycounter21
\r
259 h_readmemorycounter1:
\r
261 lds r_temp2,pack1+1
\r
262 ldi r_temp,1 ;inc leider kein c flag
\r
268 breq h_readmemorycounter_next1
\r
269 sts pack1+1,r_temp2
\r
271 h_readmemorycounter21: ;Lesen von dem worauf die erstenzwei bytes zeigen
\r
274 configZ pack1+3,r_bytep
\r
278 //h_readmemorycounter_end:
\r
279 // ldi r_mode,OW_SLEEP
\r
282 h_readmemorycounter_next1: ; rest lesen
\r
283 ldi r_mode,OW_READ_MEMORYCOUNTER_EX1
\r
290 brne h_readmemorycounter_cFF1
\r
296 configZ counters1,r_temp2
\r
298 sts pack1+35,r_temp
\r
300 sts pack1+36,r_temp
\r
302 sts pack1+37,r_temp
\r
304 sts pack1+38,r_temp
\r
305 rjmp h_readmemorycounter_ex1
\r
306 h_readmemorycounter_cFF1:
\r
308 sts pack1+35,r_temp
\r
309 sts pack1+36,r_temp
\r
310 sts pack1+37,r_temp
\r
311 sts pack1+38,r_temp
\r
313 h_readmemorycounter_ex1:
\r
316 breq h_readmemorycounter_ex_end1
\r
318 brne h_readmemorycounter_ex21
\r
321 sts pack1+43,r_temp
\r
324 sts pack1+44,r_temp
\r
325 h_readmemorycounter_ex21:
\r
327 configZ pack1,r_bytep
\r
330 h_readmemorycounter_ex_end1:
\r
332 lds r_temp2,pack1+1
\r
333 ldi r_temp,1 ;inc leider kein c flag
\r
337 sbrc r_temp2,1 ;am ene von allem
\r
338 rjmp h_readmemorycounter_ex_sleep1
\r
340 ldi r_mode,OW_READ_MEMORYCOUNTER1
\r
341 sts pack1+1,r_temp2
\r
343 rjmp h_readmemorycounter21
\r
344 h_readmemorycounter_ex_sleep1:
\r
345 ldi r_mode,OW_SLEEP
\r
352 ;*****************************************************************************************************************************************************************************************
\r
353 ;*****************************************************************************************************************************************************************************************
\r
354 ;*****************************************************************************************************************************************************************************************
\r
355 ;*****************************************************************************************************************************************************************************************
\r
356 ;*****************************************************************************************************************************************************************************************
\r
361 #ifndef _DIS_FLASH_
\r
362 FLASH_COMMANDS ; muss zu erst sein....
\r
364 cjmp 0xF5,hrc_accessread2
\r
365 cset 0x5A,OW_ACCESSWRITE2
\r
366 /* cset 0xBE,OW_READ_SCRATCHPAD_ADR2
\r
367 cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2
\r
368 cjmp 0x44,hrc_set_convertT2
\r
369 cjmp 0xB4,hrc_set_convertV2*/
\r
371 //cljmp 0x85,hrc_fw_configinfo2
\r
372 #ifdef _CHANGEABLE_ID_
\r
375 rjmp handle_end_sleep
\r
380 ldi r_mode,OW_ACCESSREAD2
\r
382 lds r_temp,pin_state
\r
384 mov r_rwbyte,r_temp
\r
394 h_accesswrite_read2:
\r
395 rjmp handle_end_sleep
\r
401 breq h_accesswrite_compl2
\r
403 rjmp handle_end_inc
\r
404 h_accesswrite_compl2:
\r
408 brne h_accesswrite_error2
\r
409 sts pin_set,r_rwbyte
\r
410 ldi r_mode,OW_ACCESSWRITE_READ2
\r
413 rjmp handle_end_inc
\r
414 h_accesswrite_error2:
\r
415 rjmp handle_end_sleep
\r
417 ;---------------------------------------------------
\r
419 ;---------------------------------------------------
\r
420 h_writescratchpad_adr2:
\r
424 #if defined(__AVR_ATtiny25__)
\r
425 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
\r
428 ldi r_mode,OW_WRITE_SCRATCHPAD2
\r
431 h_writescratchpad2:
\r
433 breq h_writescratchpad_all2
\r
436 configZ pack2,r_temp
\r
438 rjmp handle_end_inc
\r
439 h_writescratchpad_all2:
\r
440 rjmp handle_end_sleep
\r
450 #include "../common/OWPinInterrupt.s"
\r