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
36 #define _HANDLE_CC_COMMAND_
\r
39 #include "../common/OWConfig.s"
\r
40 #include "../common/OWCRC8.s"
\r
44 //.extern am2302_temp,2
\r
46 #if defined(__AVR_ATtiny25__)
\r
51 .extern am2302_temp,2
\r
52 .extern am2302_hum,2
\r
53 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)
\r
56 .macro CHIP_INIT ;r_temp is pushed other Registers should be saved
\r
60 sbic _SFR_IO_ADDR(EECR), EEPE
\r
61 rjmp Init_EEPROM_read
\r
63 out _SFR_IO_ADDR(EEARH), r_temp
\r
65 out _SFR_IO_ADDR(EEARL), r_temp
\r
66 sbi _SFR_IO_ADDR(EECR), EERE
\r
67 in r_temp,_SFR_IO_ADDR(EEDR)
\r
69 rcall hrc_recall_eeprom_func1
\r
74 .macro COMMAND_TABLE
\r
75 rjmp h_readscratchpad1
\r
76 rjmp h_writescratchpad1
\r
78 rjmp h_readscratchpad_adr2
\r
79 rjmp h_readscratchpad2
\r
80 rjmp h_writescratchpad_adr2
\r
81 rjmp h_writescratchpad2
\r
84 #include "../common/OWRomFunctionsDual.s"
\r
85 #include "../common/OWTimerInterrupt.s"
\r
89 ; Ab hier Geraeteabhaenging
\r
90 #define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0
\r
91 #define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1
\r
92 #define OW_CONVERT_RUN1 OW_FIRST_COMMAND+2
\r
93 #define OW_READ_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+3
\r
94 #define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+4
\r
95 #define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+5
\r
96 #define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+6
\r
99 ;---------------------------------------------------
\r
100 ; READ COMMAND and start operation
\r
101 ;---------------------------------------------------
\r
103 #ifdef _HANDLE_CC_COMMAND_
\r
106 cjmp 0x44,hrc_set_convertT12
\r
107 ldi r_mode,OW_SLEEP
\r
114 #ifndef _DIS_FLASH_
\r
115 FLASH_COMMANDS ; muss zu erst sein....
\r
117 cjmp 0xBE,hrc_set_readscratchpad1
\r
118 cjmp 0x4E,hrc_set_writescratchpad1
\r
119 cjmp 0x44,hrc_set_convertT1
\r
120 cjmp 0x48,hrc_copy_scratchpad1
\r
121 cjmp 0xB8,hrc_recall_eeprom1
\r
123 #ifdef _CHANGEABLE_ID_
\r
126 ldi r_mode,OW_SLEEP
\r
129 hrc_set_readscratchpad1:
\r
130 ldi r_mode,OW_READ_SCRATCHPAD1
\r
133 rjmp h_readscratchpad1
\r
135 hrc_set_writescratchpad1:
\r
136 ldi r_mode,OW_WRITE_SCRATCHPAD1
\r
137 ldi r_bytep,2 ;start to write in 2
\r
140 hrc_recall_eeprom1:
\r
141 rcall hrc_recall_eeprom_func1
\r
144 #ifdef _HANDLE_CC_COMMAND_
\r
145 hrc_set_convertT12:
\r
147 sts gcontrol,r_temp
\r
148 lds r_temp,am2302_temp
\r
150 lds r_temp,am2302_temp+1
\r
152 rjmp hrc_set_convertT12b
\r
157 sts gcontrol,r_temp
\r
158 hrc_set_convertT12b:
\r
159 ldi r_mode,OW_CONVERT_RUN1
\r
160 ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
\r
164 rjmp handle_end_no_bcount
\r
168 hrc_copy_scratchpad1:
\r
170 configZ pack1,r_bytep
\r
172 hrc_copy_scratchpad_EEPROM_write1:
\r
173 sbic _SFR_IO_ADDR(EECR), EEPE
\r
174 rjmp hrc_copy_scratchpad_EEPROM_write1
\r
175 ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
\r
176 out _SFR_IO_ADDR(EECR), r_temp
\r
178 out _SFR_IO_ADDR(EEARH),r_temp
\r
179 out _SFR_IO_ADDR(EEARL), r_bytep
\r
181 out _SFR_IO_ADDR(EEDR), r_rwbyte
\r
182 sbi _SFR_IO_ADDR(EECR), EEMPE
\r
183 sbi _SFR_IO_ADDR(EECR), EEPE
\r
186 brne hrc_copy_scratchpad_EEPROM_write1
\r
190 hrc_recall_eeprom_func1:
\r
192 configZ pack1,r_bytep
\r
195 hrc_recall_eeprom_EEPROM_read1:
\r
196 sbic _SFR_IO_ADDR(EECR), EEPE
\r
197 rjmp hrc_recall_eeprom_EEPROM_read1
\r
198 out _SFR_IO_ADDR(EEARH), r_temp
\r
199 out _SFR_IO_ADDR(EEARL), r_bytep
\r
200 sbi _SFR_IO_ADDR(EECR), EERE
\r
201 in r_rwbyte,_SFR_IO_ADDR(EEDR)
\r
205 brne hrc_recall_eeprom_EEPROM_read1
\r
213 ;---------------------------------------------------
\r
215 ;---------------------------------------------------
\r
219 breq h_readscratchpad_crc1
\r
221 breq h_readscratchpad_all1
\r
222 configZ pack1,r_bytep
\r
224 rjmp h_readscratchpad_endc1
\r
225 h_readscratchpad_crc1:
\r
227 h_readscratchpad_endc1:
\r
231 h_readscratchpad_all1:
\r
232 rjmp handle_end_sleep
\r
238 ;---------------------------------------------------
\r
240 ;---------------------------------------------------
\r
242 h_writescratchpad1:
\r
243 configZ pack1,r_bytep
\r
246 breq h_writescratchpad_all1
\r
249 h_writescratchpad_all1:
\r
250 ;ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1 -->VOC use different
\r
252 rjmp handle_end_sleep
\r
254 ;*****************************************************************************************************************************************************************************************
\r
255 ;*****************************************************************************************************************************************************************************************
\r
256 ;*****************************************************************************************************************************************************************************************
\r
257 ;*****************************************************************************************************************************************************************************************
\r
258 ;*****************************************************************************************************************************************************************************************
\r
266 #ifndef _DIS_FLASH_
\r
267 FLASH_COMMANDS ; muss zu erst sein....
\r
269 cset 0xBE,OW_READ_SCRATCHPAD_ADR2
\r
270 cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2
\r
271 cjmp 0x44,hrc_set_convertT2
\r
272 cjmp 0xB4,hrc_set_convertV2
\r
274 //cljmp 0x85,hrc_fw_configinfo2
\r
275 #ifdef _CHANGEABLE_ID_
\r
278 rjmp handle_end_sleep
\r
283 sts gcontrol,r_temp
\r
284 lds r_temp,am2302_temp
\r
286 lds r_temp,am2302_temp+1
\r
288 rjmp handle_end_sleep
\r
292 rjmp hrc_set_convertVV2
\r
297 rjmp hrc_set_convertend2
\r
298 hrc_set_convertVV2:
\r
300 sts gcontrol,r_temp
\r
301 lds r_temp,am2302_hum
\r
303 lds r_temp,am2302_hum+1
\r
305 hrc_set_convertend2:
\r
306 rjmp handle_end_sleep
\r
310 ;---------------------------------------------------
\r
312 ;---------------------------------------------------
\r
314 h_readscratchpad_adr2:
\r
318 #if defined(__AVR_ATtiny25__)
\r
319 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
\r
323 ldi r_mode,OW_READ_SCRATCHPAD2
\r
327 breq h_readscratchpad_crc2
\r
329 breq h_readscratchpad_all2
\r
332 configZ pack2,r_temp
\r
334 rjmp handle_end_inc
\r
335 h_readscratchpad_crc2:
\r
337 rjmp handle_end_inc
\r
338 h_readscratchpad_all2:
\r
339 rjmp handle_end_sleep
\r
344 ;---------------------------------------------------
\r
346 ;---------------------------------------------------
\r
347 h_writescratchpad_adr2:
\r
351 #if defined(__AVR_ATtiny25__)
\r
352 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
\r
355 ldi r_mode,OW_WRITE_SCRATCHPAD2
\r
358 h_writescratchpad2:
\r
360 breq h_writescratchpad_all2
\r
363 configZ pack2,r_temp
\r
365 rjmp handle_end_inc
\r
366 h_writescratchpad_all2:
\r
367 rjmp handle_end_sleep
\r
377 #include "../common/OWPinInterrupt.s"
\r