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
37 #define _NO_BOOTLOADER_PIN_
\r
41 #include "../common/OWConfig.s"
\r
42 #include "../common/OWCRC8.s"
\r
46 #if defined(__AVR_ATtiny25__)
\r
54 .comm block,1 ; Block der augegeben, geschrieben wird (Parameter von READ/WRITE Scratchpad)
\r
55 .comm cpsp,1 ; Copy Scratchpad marker
\r
58 .macro CHIP_INIT ;r_temp is pushed other Registers should be saved
\r
64 sbic _SFR_IO_ADDR(EECR), EEPE
\r
65 rjmp Init_EEPROM_read
\r
67 out _SFR_IO_ADDR(EEARH), r_temp
\r
69 out _SFR_IO_ADDR(EEARL), r_temp
\r
70 sbi _SFR_IO_ADDR(EECR), EERE
\r
71 in r_temp,_SFR_IO_ADDR(EEDR)
\r
73 rcall hrc_recall_eeprom_func1
\r
78 .macro COMMAND_TABLE
\r
79 rjmp h_readscratchpad1
\r
80 rjmp h_writescratchpad1
\r
82 rjmp h_readscratchpad_adr2
\r
83 rjmp h_readscratchpad2
\r
84 rjmp h_writescratchpad_adr2
\r
85 rjmp h_writescratchpad2
\r
86 rjmp h_copyscratchpad_adr2
\r
89 #include "../common/OWRomFunctionsDual.s"
\r
90 #include "../common/OWTimerInterrupt.s"
\r
94 ; Ab hier Geraeteabhaenging
\r
95 #define OW_READ_SCRATCHPAD1 OW_FIRST_COMMAND+0
\r
96 #define OW_WRITE_SCRATCHPAD1 OW_FIRST_COMMAND+1
\r
97 #define OW_CONVERT_RUN1 OW_FIRST_COMMAND+2
\r
98 #define OW_READ_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+3
\r
99 #define OW_READ_SCRATCHPAD2 OW_FIRST_COMMAND+4
\r
100 #define OW_WRITE_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+5
\r
101 #define OW_WRITE_SCRATCHPAD2 OW_FIRST_COMMAND+6
\r
102 #define OW_COPY_SCRATCHPAD_ADR2 OW_FIRST_COMMAND+7
\r
105 ;---------------------------------------------------
\r
106 ; READ COMMAND and start operation
\r
107 ;---------------------------------------------------
\r
109 #ifdef _HANDLE_CC_COMMAND_
\r
112 cjmp 0x44,hrc_set_convertT12
\r
113 rjmp h_readcccommand ;fuehre DS2438 commands aus...
\r
114 //ldi r_mode,OW_SLEEP
\r
121 #ifndef _DIS_FLASH_
\r
122 FLASH_COMMANDS ; muss zu erst sein....
\r
124 cjmp 0x44,hrc_set_convertT1
\r
126 cjmp 0xBE,hrc_set_readscratchpad1
\r
127 cjmp 0x4E,hrc_set_writescratchpad1
\r
128 cjmp 0x48,hrc_copy_scratchpad1
\r
129 cjmp 0xB8,hrc_recall_eeprom1
\r
131 #ifdef _CHANGEABLE_ID_
\r
134 ldi r_mode,OW_SLEEP
\r
137 hrc_set_readscratchpad1:
\r
138 ldi r_mode,OW_READ_SCRATCHPAD1
\r
141 rjmp h_readscratchpad1
\r
143 hrc_set_writescratchpad1:
\r
144 ldi r_mode,OW_WRITE_SCRATCHPAD1
\r
145 ldi r_bytep,2 ;start to write in 2
\r
148 hrc_recall_eeprom1:
\r
149 rcall hrc_recall_eeprom_func1
\r
152 #ifdef _HANDLE_CC_COMMAND_
\r
153 hrc_set_convertT12:
\r
155 sts gcontrol,r_temp
\r
156 lds r_temp,DS2438_2_TEMP
\r
158 lds r_temp,DS2438_2_TEMP+1
\r
160 rjmp hrc_set_convertT12b
\r
165 sts gcontrol,r_temp
\r
166 hrc_set_convertT12b:
\r
167 ldi r_mode,OW_CONVERT_RUN1
\r
168 ldi r_sendflag,3 ;set bit 0 and 1 for no zero polling
\r
172 rjmp handle_end_no_bcount
\r
176 hrc_copy_scratchpad1:
\r
178 configZ pack1,r_bytep
\r
180 hrc_copy_scratchpad_EEPROM_write1:
\r
181 sbic _SFR_IO_ADDR(EECR), EEPE
\r
182 rjmp hrc_copy_scratchpad_EEPROM_write1
\r
183 ldi r_temp, (0<<EEPM1)|(0<<EEPM0)
\r
184 out _SFR_IO_ADDR(EECR), r_temp
\r
186 out _SFR_IO_ADDR(EEARH),r_temp
\r
187 out _SFR_IO_ADDR(EEARL), r_bytep
\r
189 out _SFR_IO_ADDR(EEDR), r_rwbyte
\r
190 sbi _SFR_IO_ADDR(EECR), EEMPE
\r
191 sbi _SFR_IO_ADDR(EECR), EEPE
\r
194 brne hrc_copy_scratchpad_EEPROM_write1
\r
198 hrc_recall_eeprom_func1:
\r
200 configZ pack1,r_bytep
\r
203 hrc_recall_eeprom_EEPROM_read1:
\r
204 sbic _SFR_IO_ADDR(EECR), EEPE
\r
205 rjmp hrc_recall_eeprom_EEPROM_read1
\r
206 out _SFR_IO_ADDR(EEARH), r_temp
\r
207 out _SFR_IO_ADDR(EEARL), r_bytep
\r
208 sbi _SFR_IO_ADDR(EECR), EERE
\r
209 in r_rwbyte,_SFR_IO_ADDR(EEDR)
\r
213 brne hrc_recall_eeprom_EEPROM_read1
\r
221 ;---------------------------------------------------
\r
223 ;---------------------------------------------------
\r
227 breq h_readscratchpad_crc1
\r
229 breq h_readscratchpad_all1
\r
230 configZ pack1,r_bytep
\r
232 rjmp h_readscratchpad_endc1
\r
233 h_readscratchpad_crc1:
\r
235 h_readscratchpad_endc1:
\r
239 h_readscratchpad_all1:
\r
240 rjmp handle_end_sleep
\r
246 ;---------------------------------------------------
\r
248 ;---------------------------------------------------
\r
250 h_writescratchpad1:
\r
251 configZ pack1,r_bytep
\r
254 breq h_writescratchpad_all1
\r
257 h_writescratchpad_all1:
\r
258 ;ori r_rwbyte,0x1F ; Alle unteren Bits sind immer 1 -->VOC use different
\r
260 rjmp handle_end_sleep
\r
262 ;*****************************************************************************************************************************************************************************************
\r
263 ;*****************************************************************************************************************************************************************************************
\r
264 ;*****************************************************************************************************************************************************************************************
\r
265 ;*****************************************************************************************************************************************************************************************
\r
266 ;*****************************************************************************************************************************************************************************************
\r
274 #ifndef _DIS_FLASH_
\r
275 FLASH_COMMANDS ; muss zu erst sein....
\r
277 cset 0xBE,OW_READ_SCRATCHPAD_ADR2
\r
278 cset 0x4E,OW_WRITE_SCRATCHPAD_ADR2
\r
279 cjmp 0x44,hrc_set_convertT2
\r
280 cjmp 0xB4,hrc_set_convertV2
\r
281 cset 0x48,OW_COPY_SCRATCHPAD_ADR2
\r
283 //cljmp 0x85,hrc_fw_configinfo2
\r
284 #ifdef _CHANGEABLE_ID_
\r
287 rjmp handle_end_sleep
\r
292 sts gcontrol,r_temp
\r
293 lds r_temp,DS2438_2_TEMP
\r
295 lds r_temp,DS2438_2_TEMP+1
\r
297 rjmp handle_end_sleep
\r
300 sts gcontrol,r_temp
\r
303 rjmp hrc_set_convertVV2
\r
304 lds r_temp,DS2438_2_VDD
\r
306 lds r_temp,DS2438_2_VDD+1
\r
308 rjmp hrc_set_convertend2
\r
309 hrc_set_convertVV2:
\r
311 sts gcontrol,r_temp
\r
312 lds r_temp,DS2438_2_VAD
\r
314 lds r_temp,DS2438_2_VAD+1
\r
316 hrc_set_convertend2:
\r
317 rjmp handle_end_sleep
\r
321 ;---------------------------------------------------
\r
323 ;---------------------------------------------------
\r
325 h_readscratchpad_adr2:
\r
329 #if defined(__AVR_ATtiny25__)
\r
330 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
\r
334 ldi r_mode,OW_READ_SCRATCHPAD2
\r
338 breq h_readscratchpad_crc2
\r
340 breq h_readscratchpad_all2
\r
343 configZ pack2,r_temp
\r
345 rjmp handle_end_inc
\r
346 h_readscratchpad_crc2:
\r
348 rjmp handle_end_inc
\r
349 h_readscratchpad_all2:
\r
350 rjmp handle_end_sleep
\r
355 ;---------------------------------------------------
\r
357 ;---------------------------------------------------
\r
358 h_writescratchpad_adr2:
\r
362 #if defined(__AVR_ATtiny25__)
\r
363 andi r_rwbyte,0x01 ;nur Page 0 und 1 und das immer wiederholen
\r
366 ldi r_mode,OW_WRITE_SCRATCHPAD2
\r
369 h_writescratchpad2:
\r
371 breq h_writescratchpad_all2
\r
374 configZ pack2,r_temp
\r
376 rjmp handle_end_inc
\r
377 h_writescratchpad_all2:
\r
378 rjmp handle_end_sleep
\r
381 h_copyscratchpad_adr2:
\r
382 ori r_rwbyte,0x80 ;hoechstes bit ist 1 zum Testen
\r
384 rjmp handle_end_sleep
\r
391 #include "../common/OWPinInterrupt.s"
\r