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
38 #include "../common/OWConfig.s"
\r
39 #include "../common/OWCRC16.s"
\r
42 .comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)
\r
43 .comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....
\r
44 //.extern am2302_temp,2
\r
51 .macro COMMAND_TABLE
\r
52 rjmp h_readmemoryaddr
\r
54 rjmp h_readmemorycrc1
\r
55 rjmp h_readmemorycrc2
\r
56 rjmp h_writememoryaddr
\r
58 rjmp h_writememorycrc1
\r
59 rjmp h_writememorycrc2
\r
60 rjmp h_writememoryreadback
\r
67 #include "../common/OWRomFunctions.s"
\r
68 #include "../common/OWTimerInterrupt.s"
\r
72 ; Ab hier Geraeteabhaenging
\r
73 #define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0
\r
74 #define OW_READ_MEMORY OW_FIRST_COMMAND+1
\r
75 #define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2
\r
76 #define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3
\r
77 #define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4
\r
78 #define OW_WRITE_MEMORY OW_FIRST_COMMAND+5
\r
79 #define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6
\r
80 #define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7
\r
81 #define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8
\r
82 #define OW_CONVERT OW_FIRST_COMMAND+9
\r
83 #define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10
\r
84 #define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11
\r
85 #define OW_CONVERT_CONV OW_FIRST_COMMAND+12
\r
87 ;---------------------------------------------------
\r
88 ; READ COMMAND and start operation
\r
89 ;---------------------------------------------------
\r
95 FLASH_COMMANDS ; muss zu erst sein....
\r
97 cset 0xAA,OW_READ_MEMORY_ADDR
\r
98 cset 0x55,OW_WRITE_MEMORY_ADDR
\r
99 cset 0x3C,OW_CONVERT
\r
101 #ifdef _CHANGEABLE_ID_
\r
104 ldi r_mode,OW_SLEEP
\r
109 cpi r_bytep,0 ;erstes Adressbyte ?
\r
110 brne h_readmemory_addr_byte1 ;nein dann weiter
\r
111 andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen
\r
112 sts addr,r_rwbyte ;speichern des ersten bytes
\r
113 rjmp handle_end_inc
\r
114 h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert!
\r
115 ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory
\r
116 ;;ldi r_bcount,1 ;ist unten
\r
117 ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
\r
125 breq h_readmemory_init_crc
\r
128 ;andi r_bytep,0x1F ist oben
\r
129 configZ pack,r_bytep
\r
132 rjmp handle_end ;sendet das Byte und geht zu h_readmemory
\r
133 h_readmemory_init_crc:; init erstes CRC byte
\r
139 ldi r_mode,OW_READ_MEMORY_CRC1
\r
143 //ldi r_mode,OW_SLEEP
\r
145 rjmp handle_end_sleep
\r
146 h_readmemorycrc1:;init zweites CRC Byte
\r
147 lds r_rwbyte,crcsave
\r
149 ldi r_mode,OW_READ_MEMORY_CRC2
\r
151 h_readmemorycrc2:;weiteres senden..... nach zweitem Byte
\r
154 brne h_readmemory_end; ende des speichers
\r
155 ldi r_mode,OW_READ_MEMORY
\r
156 CRCInit1 ;Start with new CRC
\r
160 cpi r_bytep,0 ;erstes Adressbyte ?
\r
161 brne h_writememory_addr_byte1 ;nein dann weiter
\r
162 andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen
\r
163 sts addr,r_rwbyte ;speichern des ersten bytes
\r
167 h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert!
\r
168 ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory
\r
169 ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....
\r
171 rjmp handle_end ;read Memory Byte
\r
174 configZ pack,r_bytep
\r
177 ldi r_mode,OW_WRITE_MEMORY_CRC1
\r
178 ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
\r
186 lds r_rwbyte,crcsave
\r
188 ldi r_mode,OW_WRITE_MEMORY_CRC2
\r
192 configZ pack,r_temp
\r
195 ldi r_mode,OW_WRITE_MEMORY_READBACK
\r
197 h_writememoryreadback:
\r
206 ldi r_mode,OW_WRITE_MEMORY
\r
210 cpi r_bytep,0 ;erstes Adressbyte ?
\r
211 brne h_convert_byte1 ;nein dann weiter
\r
213 sts pack+0x20,r_rwbyte
\r
216 h_convert_byte1: ;zweies byte glesen go crc#
\r
217 sts pack+0x21,r_rwbyte
\r
223 ldi r_mode,OW_CONVERT_CRC1
\r
228 lds r_rwbyte,crcsave
\r
230 ldi r_mode,OW_CONVERT_CRC2
\r
234 sts gcontrol,r_temp
\r
236 ldi r_mode,OW_CONVERT_CONV
\r
238 ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
\r
242 rjmp handle_end_no_bcount
\r
247 #include "../common/OWPinInterrupt.s"
\r