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
40 #include "../common/OWConfig.s"
\r
41 #include "../common/OWCRC16.s"
\r
44 .comm addr,1 ;zweites Adressbyte ist unnoetig (Warum auch immer fuer 32 Byte 16 Bit Adressen verwendet werden....)
\r
45 .comm crcsave,1 ; zwischenspeicherspeicher fuer crc nur zweites byte....
\r
46 //.extern am2302_temp,2
\r
53 .macro COMMAND_TABLE
\r
54 rjmp h_readmemoryaddr
\r
56 rjmp h_readmemorycrc1
\r
57 rjmp h_readmemorycrc2
\r
58 rjmp h_writememoryaddr
\r
60 rjmp h_writememorycrc1
\r
61 rjmp h_writememorycrc2
\r
62 rjmp h_writememoryreadback
\r
69 #include "../common/OWRomFunctions.s"
\r
70 #include "../common/OWTimerInterrupt.s"
\r
74 ; Ab hier Geraeteabhaenging
\r
75 #define OW_READ_MEMORY_ADDR OW_FIRST_COMMAND+0
\r
76 #define OW_READ_MEMORY OW_FIRST_COMMAND+1
\r
77 #define OW_READ_MEMORY_CRC1 OW_FIRST_COMMAND+2
\r
78 #define OW_READ_MEMORY_CRC2 OW_FIRST_COMMAND+3
\r
79 #define OW_WRITE_MEMORY_ADDR OW_FIRST_COMMAND+4
\r
80 #define OW_WRITE_MEMORY OW_FIRST_COMMAND+5
\r
81 #define OW_WRITE_MEMORY_CRC1 OW_FIRST_COMMAND+6
\r
82 #define OW_WRITE_MEMORY_CRC2 OW_FIRST_COMMAND+7
\r
83 #define OW_WRITE_MEMORY_READBACK OW_FIRST_COMMAND+8
\r
84 #define OW_CONVERT OW_FIRST_COMMAND+9
\r
85 #define OW_CONVERT_CRC1 OW_FIRST_COMMAND+10
\r
86 #define OW_CONVERT_CRC2 OW_FIRST_COMMAND+11
\r
87 #define OW_CONVERT_CONV OW_FIRST_COMMAND+12
\r
89 ;---------------------------------------------------
\r
90 ; READ COMMAND and start operation
\r
91 ;---------------------------------------------------
\r
97 FLASH_COMMANDS ; muss zu erst sein....
\r
99 cset 0xAA,OW_READ_MEMORY_ADDR
\r
100 cset 0x55,OW_WRITE_MEMORY_ADDR
\r
101 cset 0x3C,OW_CONVERT
\r
103 #ifdef _CHANGEABLE_ID_
\r
106 ldi r_mode,OW_SLEEP
\r
111 cpi r_bytep,0 ;erstes Adressbyte ?
\r
112 brne h_readmemory_addr_byte1 ;nein dann weiter
\r
113 andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen
\r
114 sts addr,r_rwbyte ;speichern des ersten bytes
\r
115 rjmp handle_end_inc
\r
116 h_readmemory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert!
\r
117 ldi r_mode,OW_READ_MEMORY ;weiter zu read Memory
\r
118 ;;ldi r_bcount,1 ;ist unten
\r
119 ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
\r
127 breq h_readmemory_init_crc
\r
130 ;andi r_bytep,0x1F ist oben
\r
131 configZ pack,r_bytep
\r
134 rjmp handle_end ;sendet das Byte und geht zu h_readmemory
\r
135 h_readmemory_init_crc:; init erstes CRC byte
\r
141 ldi r_mode,OW_READ_MEMORY_CRC1
\r
145 ldi r_mode,OW_SLEEP
\r
148 h_readmemorycrc1:;init zweites CRC Byte
\r
149 lds r_rwbyte,crcsave
\r
151 ldi r_mode,OW_READ_MEMORY_CRC2
\r
153 h_readmemorycrc2:;weiteres senden..... nach zweitem Byte
\r
156 brne h_readmemory_end; ende des speichers
\r
157 ldi r_mode,OW_READ_MEMORY
\r
158 CRCInit1 ;Start with new CRC
\r
162 cpi r_bytep,0 ;erstes Adressbyte ?
\r
163 brne h_writememory_addr_byte1 ;nein dann weiter
\r
164 andi r_rwbyte,0x1F ; nur Adressen zwischen 0 und 0x1F zulassen
\r
165 sts addr,r_rwbyte ;speichern des ersten bytes
\r
169 h_writememory_addr_byte1: ;zweiters Addressbyte wird nicht gespeichert!
\r
170 ldi r_mode,OW_WRITE_MEMORY ;weiter zu read Memory
\r
171 ;ldi r_bcount,1 ;; _________________________________________________in handle_end integrieren.....
\r
173 rjmp handle_end ;read Memory Byte
\r
176 configZ pack,r_bytep
\r
179 ldi r_mode,OW_WRITE_MEMORY_CRC1
\r
180 ldi r_sendflag,1 ;jetzt sendet der Slave zum Master
\r
188 lds r_rwbyte,crcsave
\r
190 ldi r_mode,OW_WRITE_MEMORY_CRC2
\r
194 configZ pack,r_temp
\r
197 ldi r_mode,OW_WRITE_MEMORY_READBACK
\r
199 h_writememoryreadback:
\r
208 ldi r_mode,OW_WRITE_MEMORY
\r
212 cpi r_bytep,0 ;erstes Adressbyte ?
\r
213 brne h_convert_byte1 ;nein dann weiter
\r
215 sts pack+0x20,r_rwbyte
\r
218 h_convert_byte1: ;zweies byte glesen go crc#
\r
219 sts pack+0x21,r_rwbyte
\r
225 ldi r_mode,OW_CONVERT_CRC1
\r
230 lds r_rwbyte,crcsave
\r
232 ldi r_mode,OW_CONVERT_CRC2
\r
236 sts gcontrol,r_temp
\r
238 ldi r_mode,OW_CONVERT_CONV
\r
240 ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
\r
244 rjmp handle_end_no_bcount
\r
249 #include "../common/OWPinInterrupt.s"
\r