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