avr: added debug instr.

This commit is contained in:
Martin Preuss
2024-09-12 13:05:01 +02:00
parent 79afc70b92
commit f1fe99673b

View File

@@ -75,6 +75,7 @@ Ds18b20_Fini:
Ds18b20_Run:
ret ; debug
lds r16, ds18b20Flags
andi r16, DS18B20_FLAGS_CONV_UPDATED ; new value?
breq Ds18b20_Run_done ; nope, jump
@@ -193,7 +194,7 @@ Ds18b20_ReadRom_loop1:
sbiw xh:xl, 8
ldi r18, 8
ldi r19, DS18B20_POLYNOMIAL
rcall ds18b20Crc8Calc ; (R16, R17, R18, R20, R21, X)
rcall crc8Calc ; (R16, R17, R18, R20, R21, X)
tst r16
brne Ds18b20_ReadRom_error
sec
@@ -231,7 +232,7 @@ ds18b20ReadScratchPad_loop1:
sbiw xh:xl, 9
ldi r18, 9
ldi r19, DS18B20_POLYNOMIAL
rcall ds18b20Crc8Calc ; (R16, R17, R18, R20, R21, X)
rcall crc8Calc ; (R16, R17, R18, R20, R21, X)
tst r16
brne ds18b20ReadScratchPad_error
sbiw xh:xl, 9
@@ -245,6 +246,10 @@ ds18b20ReadScratchPad_error:
Ds18b20_SendTemp:
lds r16, ds18b20Flags
andi r16, DS18B20_FLAGS_CONV_UPDATED
breq Ds18b20_SendTemp_done
Ds18b20_SendTemp_haveValue:
ldi r16, 0xff ; destination address
ldi r17, VALUE_ID_DS18B20_TEMP ; value id
ldi r22, AQHOME_VALUETYPE_TEMP
@@ -255,43 +260,16 @@ Ds18b20_SendTemp:
ldi xl, LOW(com2SendBuffer)
ldi xh, HIGH(com2SendBuffer)
rcall CPRO_WriteReportValue
rjmp COM2_SendPacket
; ---------------------------------------------------------------------------
; @routine ds18b20Crc8Calc @global
; calc crc8 checksum using given polynomial
;
; @return r16 crc8 checksum
; @return X points directly after last checked byte
; @param X pointer to data to calc crc8 for
; @param r18 number of bytes to calc crc8 for
; @param r19 polynomial to use
; @clobbers: R16, R17, R18, R20, R21, X
ds18b20Crc8Calc:
clr r16 ; start crc
ds18b20Crc8Calc_loop1:
ld r17, X+ ; running var
ldi r20, 8 ; counter for loop2
ds18b20Crc8Calc_loop2: ; r16=crc so far, r17=current inbyte
mov r21, r16
lsr r16
eor r21, r17
lsr r17
andi r21, 1
breq ds18b20Crc8Calc_withoutPoly
eor r16, r19
ds18b20Crc8Calc_withoutPoly:
dec r20
brne ds18b20Crc8Calc_loop2
dec r18
brne ds18b20Crc8Calc_loop1
rcall COM2_SendPacket
brcc Ds18b20_SendTemp_done
lds r16, ds18b20Flags
andi r16, ~DS18B20_FLAGS_CONV_UPDATED
sts ds18b20Flags, r16
sec
ret
Ds18b20_SendTemp_done:
clc
ret
; @end
DS18B20_END: