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_
38 #include "../common/OWConfig.s"
39 #include "../common/OWCRC8.s"
43 //.extern am2302_temp,2
45 #if defined(__AVR_ATtiny25__)
52 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)
57 sbic _SFR_IO_ADDR(EECR), EEPE
60 out _SFR_IO_ADDR(EEARH), r_temp
62 out _SFR_IO_ADDR(EEARL), r_temp
63 sbi _SFR_IO_ADDR(EECR), EERE
64 in r_temp,_SFR_IO_ADDR(EEDR)
66 rcall hrc_recall_eeprom_func1
70 rjmp h_readscratchpad1
71 rjmp h_writescratchpad1
72 rjmp h_readscratchpad_adr2
73 rjmp h_readscratchpad2
74 rjmp h_writescratchpad_adr2
75 rjmp h_writescratchpad2
78 #include "../common/OWRomFunctionsDual.s"
79 #include "../common/OWTimerInterrupt.s"
83 ; Ab hier Geraeteabhaenging
84 #define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0
85 #define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1
86 #define OW_READ_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+2
87 #define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+3
88 #define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+4
89 #define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+5
92 ;---------------------------------------------------
93 ; READ COMMAND and start operation
94 ;---------------------------------------------------
100 FLASH_COMMANDS ; muss zu erst sein....
102 cjmp 0xBE,hrc_set_readscratchpad1
103 cjmp 0x4E,hrc_set_writescratchpad1
104 cjmp 0x44,hrc_set_convertT1
105 cjmp 0x48,hrc_copy_scratchpad1
106 cjmp 0xB8,hrc_recall_eeprom1
108 #ifdef _CHANGEABLE_ID_
114 hrc_set_readscratchpad1:
115 ldi r_mode,OW_READ_SCRATCHPAD1
118 rjmp h_readscratchpad1
120 hrc_set_writescratchpad1:
121 ldi r_mode,OW_WRITE_SCRATCHPAD1
122 ldi r_bytep,2 ;start to write in 2
126 rcall hrc_recall_eeprom_func1
135 rjmp handle_end_sleep
138 hrc_copy_scratchpad1:
140 configZ pack1,r_bytep
142 hrc_copy_scratchpad_EEPROM_write1:
143 sbic _SFR_IO_ADDR(EECR), EEPE
144 rjmp hrc_copy_scratchpad_EEPROM_write1
145 ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
146 out _SFR_IO_ADDR(EECR), r_temp
148 out _SFR_IO_ADDR(EEARH),r_temp
149 out _SFR_IO_ADDR(EEARL), r_bytep
151 out _SFR_IO_ADDR(EEDR), r_rwbyte
152 sbi _SFR_IO_ADDR(EECR), EEMPE
153 sbi _SFR_IO_ADDR(EECR), EEPE
156 brne hrc_copy_scratchpad_EEPROM_write1
160 hrc_recall_eeprom_func1:
162 configZ pack1,r_bytep
165 hrc_recall_eeprom_EEPROM_read1:
166 sbic _SFR_IO_ADDR(EECR), EEPE
167 rjmp hrc_recall_eeprom_EEPROM_read1
168 out _SFR_IO_ADDR(EEARH), r_temp
169 out _SFR_IO_ADDR(EEARL), r_bytep
170 sbi _SFR_IO_ADDR(EECR), EERE
171 in r_rwbyte,_SFR_IO_ADDR(EEDR)
175 brne hrc_recall_eeprom_EEPROM_read1
183 ;---------------------------------------------------
185 ;---------------------------------------------------
189 breq h_readscratchpad_crc1
191 breq h_readscratchpad_all1
192 configZ pack1,r_bytep
194 rjmp h_readscratchpad_endc1
195 h_readscratchpad_crc1:
197 h_readscratchpad_endc1:
201 h_readscratchpad_all1:
202 rjmp handle_end_sleep
208 ;---------------------------------------------------
210 ;---------------------------------------------------
213 configZ pack1,r_bytep
216 breq h_writescratchpad_all1
219 h_writescratchpad_all1:
220 ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1
222 rjmp handle_end_sleep
224 ;*****************************************************************************************************************************************************************************************
225 ;*****************************************************************************************************************************************************************************************
226 ;*****************************************************************************************************************************************************************************************
227 ;*****************************************************************************************************************************************************************************************
228 ;*****************************************************************************************************************************************************************************************
237 FLASH_COMMANDS ; muss zu erst sein....
239 cset 0xBE,OW_READ_SCRATCHPAD_ADR2
240 cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2
241 cjmp 0x44,hrc_set_convertT2
242 cjmp 0xB4,hrc_set_convertV2
244 #ifdef _CHANGEABLE_ID_
247 rjmp handle_end_sleep
253 lds r_temp,am2302_temp
255 lds r_temp,am2302_temp+1
257 rjmp handle_end_sleep
261 rjmp hrc_set_convertVV2
266 rjmp hrc_set_convertend2
270 lds r_temp,am2302_hum
272 lds r_temp,am2302_hum+1
275 rjmp handle_end_sleep
279 ;---------------------------------------------------
281 ;---------------------------------------------------
283 h_readscratchpad_adr2:
287 #if defined(__AVR_ATtiny25__)
288 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
292 ldi r_mode,OW_READ_SCRATCHPAD2
296 breq h_readscratchpad_crc2
298 breq h_readscratchpad_all2
304 h_readscratchpad_crc2:
307 h_readscratchpad_all2:
308 rjmp handle_end_sleep
313 ;---------------------------------------------------
315 ;---------------------------------------------------
316 h_writescratchpad_adr2:
320 #if defined(__AVR_ATtiny25__)
321 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
324 ldi r_mode,OW_WRITE_SCRATCHPAD2
329 breq h_writescratchpad_all2
335 h_writescratchpad_all2:
336 rjmp handle_end_sleep
346 #include "../common/OWPinInterrupt.s"