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
107 #ifdef _CHANGEABLE_ID_
113 hrc_set_readscratchpad1:
114 ldi r_mode,OW_READ_SCRATCHPAD1
117 rjmp h_readscratchpad1
119 hrc_set_writescratchpad1:
120 ldi r_mode,OW_WRITE_SCRATCHPAD1
121 ldi r_bytep,2 ;start to write in 2
125 rcall hrc_recall_eeprom_func1
134 rjmp handle_end_sleep
137 hrc_copy_scratchpad1:
139 configZ pack1,r_bytep
141 hrc_copy_scratchpad_EEPROM_write1:
142 sbic _SFR_IO_ADDR(EECR), EEPE
143 rjmp hrc_copy_scratchpad_EEPROM_write1
144 ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
145 out _SFR_IO_ADDR(EECR), r_temp
147 out _SFR_IO_ADDR(EEARH),r_temp
148 out _SFR_IO_ADDR(EEARL), r_bytep
150 out _SFR_IO_ADDR(EEDR), r_rwbyte
151 sbi _SFR_IO_ADDR(EECR), EEMPE
152 sbi _SFR_IO_ADDR(EECR), EEPE
155 brne hrc_copy_scratchpad_EEPROM_write1
159 hrc_recall_eeprom_func1:
161 configZ pack1,r_bytep
164 hrc_recall_eeprom_EEPROM_read1:
165 sbic _SFR_IO_ADDR(EECR), EEPE
166 rjmp hrc_recall_eeprom_EEPROM_read1
167 out _SFR_IO_ADDR(EEARH), r_temp
168 out _SFR_IO_ADDR(EEARL), r_bytep
169 sbi _SFR_IO_ADDR(EECR), EERE
170 in r_rwbyte,_SFR_IO_ADDR(EEDR)
174 brne hrc_recall_eeprom_EEPROM_read1
182 ;---------------------------------------------------
184 ;---------------------------------------------------
188 breq h_readscratchpad_crc1
190 breq h_readscratchpad_all1
191 configZ pack1,r_bytep
193 rjmp h_readscratchpad_endc1
194 h_readscratchpad_crc1:
196 h_readscratchpad_endc1:
200 h_readscratchpad_all1:
201 rjmp handle_end_sleep
207 ;---------------------------------------------------
209 ;---------------------------------------------------
212 configZ pack1,r_bytep
215 breq h_writescratchpad_all1
218 h_writescratchpad_all1:
219 ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1
221 rjmp handle_end_sleep
223 ;*****************************************************************************************************************************************************************************************
224 ;*****************************************************************************************************************************************************************************************
225 ;*****************************************************************************************************************************************************************************************
226 ;*****************************************************************************************************************************************************************************************
227 ;*****************************************************************************************************************************************************************************************
236 FLASH_COMMANDS ; muss zu erst sein....
238 cset 0xBE,OW_READ_SCRATCHPAD_ADR2
239 cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2
240 cjmp 0x44,hrc_set_convertT2
241 cjmp 0xB4,hrc_set_convertV2
242 #ifdef _CHANGEABLE_ID_
245 rjmp handle_end_sleep
251 lds r_temp,am2302_temp
253 lds r_temp,am2302_temp+1
255 rjmp handle_end_sleep
259 rjmp hrc_set_convertVV2
264 rjmp hrc_set_convertend2
268 lds r_temp,am2302_hum
270 lds r_temp,am2302_hum+1
273 rjmp handle_end_sleep
277 ;---------------------------------------------------
279 ;---------------------------------------------------
281 h_readscratchpad_adr2:
285 #if defined(__AVR_ATtiny25__)
286 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
290 ldi r_mode,OW_READ_SCRATCHPAD2
294 breq h_readscratchpad_crc2
296 breq h_readscratchpad_all2
302 h_readscratchpad_crc2:
305 h_readscratchpad_all2:
306 rjmp handle_end_sleep
311 ;---------------------------------------------------
313 ;---------------------------------------------------
314 h_writescratchpad_adr2:
318 #if defined(__AVR_ATtiny25__)
319 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
322 ldi r_mode,OW_WRITE_SCRATCHPAD2
327 breq h_writescratchpad_all2
333 h_writescratchpad_all2:
334 rjmp handle_end_sleep
344 #include "../common/OWPinInterrupt.s"