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 #define _ZERO_POLLING_
37 #include "../common/OWConfig.s"
38 #include "../common/OWCRC16.s"
41 .comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)
42 .comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....
43 //.extern am2302_temp,2
55 rjmp h_writememoryaddr
57 rjmp h_writememorycrc1
58 rjmp h_writememorycrc2
59 rjmp h_writememoryreadback
66 #include "../common/OWRomFunctions.s"
67 #include "../common/OWTimerInterrupt.s"
71 ; Ab hier Geraeteabhaenging
72 #define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0
73 #define OW_READ_MEMORY OW_FIRST_COMMAND+1
74 #define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2
75 #define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3
76 #define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4
77 #define OW_WRITE_MEMORY OW_FIRST_COMMAND+5
78 #define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6
79 #define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7
80 #define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8
81 #define OW_CONVERT OW_FIRST_COMMAND+9
82 #define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10
83 #define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11
84 #define OW_CONVERT_CONV OW_FIRST_COMMAND+12
86 ;---------------------------------------------------
87 ; READ COMMAND and start operation
88 ;---------------------------------------------------
94 FLASH_COMMANDS ; muss zu erst sein....
96 cset 0xAA,OW_READ_MEMORY_ADDR
97 cset 0x55,OW_WRITE_MEMORY_ADDR
100 #ifdef _CHANGEABLE_ID_
108 cpi r_bytep,0 ;erstes Adressbyte ?
109 brne h_readmemory_addr_byte1 ;nein dann weiter
110 andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen
111 sts addr,r_rwbyte ;speichern des ersten bytes
113 h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert!
114 ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory
115 ;;ldi r_bcount,1 ;ist unten
116 ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
124 breq h_readmemory_init_crc
127 ;andi r_bytep,0x1F ist oben
131 rjmp handle_end ;sendet das Byte und geht zu h_readmemory
132 h_readmemory_init_crc:; init erstes CRC byte
138 ldi r_mode,OW_READ_MEMORY_CRC1
145 h_readmemorycrc1:;init zweites CRC Byte
148 ldi r_mode,OW_READ_MEMORY_CRC2
150 h_readmemorycrc2:;weiteres senden..... nach zweitem Byte
153 brne h_readmemory_end; ende des speichers
154 ldi r_mode,OW_READ_MEMORY
155 CRCInit1 ;Start with new CRC
159 cpi r_bytep,0 ;erstes Adressbyte ?
160 brne h_writememory_addr_byte1 ;nein dann weiter
161 andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen
162 sts addr,r_rwbyte ;speichern des ersten bytes
166 h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert!
167 ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory
168 ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....
170 rjmp handle_end ;read Memory Byte
176 ldi r_mode,OW_WRITE_MEMORY_CRC1
177 ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
187 ldi r_mode,OW_WRITE_MEMORY_CRC2
194 ldi r_mode,OW_WRITE_MEMORY_READBACK
196 h_writememoryreadback:
205 ldi r_mode,OW_WRITE_MEMORY
209 cpi r_bytep,0 ;erstes Adressbyte ?
210 brne h_convert_byte1 ;nein dann weiter
212 sts pack+0x20,r_rwbyte
215 h_convert_byte1: ;zweies byte glesen go crc#
216 sts pack+0x21,r_rwbyte
222 ldi r_mode,OW_CONVERT_CRC1
229 ldi r_mode,OW_CONVERT_CRC2
235 ldi r_mode,OW_CONVERT_CONV
237 ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
241 rjmp handle_end_no_bcount
246 #include "../common/OWPinInterrupt.s"