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
49 sbic _SFR_IO_ADDR(EECR), EEPE
52 out _SFR_IO_ADDR(EEARH), r_temp
54 out _SFR_IO_ADDR(EEARL), r_temp
55 sbi _SFR_IO_ADDR(EECR), EERE
56 in r_temp,_SFR_IO_ADDR(EEDR)
58 rcall hrc_recall_eeprom_func
63 rjmp h_writescratchpad
66 #include "../common/OWRomFunctions.s"
67 #include "../common/OWTimerInterrupt.s"
71 ; Ab hier Geraeteabhaenging
72 #define OW_READ_SCRATCHPAD OW_FIRST_COMMAND+0
73 #define OW_WRITE_SCRATCHPAD OW_FIRST_COMMAND+1
76 ;---------------------------------------------------
77 ; READ COMMAND and start operation
78 ;---------------------------------------------------
84 FLASH_COMMANDS ; muss zu erst sein....
86 cjmp 0xBE,hrc_set_readscratchpad
87 cjmp 0x4E,hrc_set_writescratchpad
88 cjmp 0x44,hrc_set_convertT
89 cjmp 0x48,hrc_copy_scratchpad
90 cjmp 0xB8,hrc_recall_eeprom
92 #ifdef _CHANGEABLE_ID_
98 hrc_set_readscratchpad:
99 ldi r_mode,OW_READ_SCRATCHPAD
102 rjmp h_readscratchpad
104 hrc_set_writescratchpad:
105 ldi r_mode,OW_WRITE_SCRATCHPAD
106 ldi r_bytep,2 ;start to write in 2
110 rcall hrc_recall_eeprom_func
118 ;lds temp,am2302_temp
120 ;lds temp,am2302_temp+1
131 ; cp r_temp,r_temp2 ;higher than or equal to TH
132 ; brge hrc_set_convertT_set_arlarm
134 ; cp r_temp,r_temp2 ;lower than or equal to TL
135 ; brlt hrc_set_convertT_set_arlarm
136 ; breq hrc_set_convertT_set_arlarm
137 ; rjmp hrc_set_convertT_end
138 ;hrc_set_convertT_set_arlarm:
140 ;hrc_set_convertT_end:
141 ; sts alarmflag,r_rwbyte
142 rjmp handle_end_sleep
149 hrc_copy_scratchpad_EEPROM_write:
150 sbic _SFR_IO_ADDR(EECR), EEPE
151 rjmp hrc_copy_scratchpad_EEPROM_write
152 ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
153 out _SFR_IO_ADDR(EECR), r_temp
155 out _SFR_IO_ADDR(EEARH),r_temp
156 out _SFR_IO_ADDR(EEARL), r_bytep
158 out _SFR_IO_ADDR(EEDR), r_rwbyte
159 sbi _SFR_IO_ADDR(EECR), EEMPE
160 sbi _SFR_IO_ADDR(EECR), EEPE
163 brne hrc_copy_scratchpad_EEPROM_write
167 hrc_recall_eeprom_func:
172 hrc_recall_eeprom_EEPROM_read:
173 sbic _SFR_IO_ADDR(EECR), EEPE
174 rjmp hrc_recall_eeprom_EEPROM_read
175 out _SFR_IO_ADDR(EEARH), r_temp
176 out _SFR_IO_ADDR(EEARL), r_bytep
177 sbi _SFR_IO_ADDR(EECR), EERE
178 in r_rwbyte,_SFR_IO_ADDR(EEDR)
182 brne hrc_recall_eeprom_EEPROM_read
190 ;---------------------------------------------------
192 ;---------------------------------------------------
196 breq h_readscratchpad_crc
198 breq h_readscratchpad_all
201 rjmp h_readscratchpad_endc
202 h_readscratchpad_crc:
204 h_readscratchpad_endc:
208 h_readscratchpad_all:
209 rjmp handle_end_sleep
215 ;---------------------------------------------------
217 ;---------------------------------------------------
223 breq h_writescratchpad_all
226 h_writescratchpad_all:
227 ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1
229 rjmp handle_end_sleep
236 #include "../common/OWPinInterrupt.s"