dec temp3
brne clkput_l
sei
-#if I2C
+#if I2C_SUPPORT
rcall rtc_set ; set hardware clock
#endif
ret
swap temp2
andi temp2,0x0f
andi temp,0x0f ;temp = low digit
- mov _tmp0,temp2
+ mov r0,temp2
ldi temp2,10
- mul temp2,_tmp0 ;high digit * 10
- add temp,_tmp0 ;high digit * 10 + low digit
+ mul temp2,r0 ;high digit * 10
+ add temp,r0 ;high digit * 10 + low digit
pop temp2
ret
ldi temp2,100
mul temp,temp2
pop temp
- mov temp2,_tmp1
- add temp,_tmp0
+ mov temp2,r1
+ add temp,r0
adc temp2,_0
ret
-#if I2C
+#if I2C_SUPPORT
; ----------------------------------------------
; Set software clock from hardware clock
brmi rtc_get_e ;i2c error
ldd temp3,z+1 ;save year
- ldd temp4,z+2
+ ldd xl, z+2
ldi temp2,2 ;register pointer. 2 = secs
std z+1,temp2
tst temp
brmi rtc_get_e
+ mov temp2,xl ;year century
ldd temp,z+4 ;get year
rol temp
rol temp
eor temp,temp3
andi temp,0x03
breq rtc_get_1
- inc temp3
- adc temp4,_0
+ subi temp3, low(-1)
+ sbci temp2, high(-1)
rtc_get_1:
ldiw x,clock
cli
rcall bcdbin2
st x+,temp ;store month
st x+,temp3 ;store year
- st x+,temp4 ;store year century
+ st x+,temp2 ;store year century
sei
rtc_get_e:
;
; Register: temp2: s
; temp3: m
-; temp4: h
+; xh: h
; xl: D
; temp: M
; yl: Yl
cli
ldd temp2,z+0 ;sec
ldd temp3,z+1 ;min
- ldd temp4,z+2 ;hours
+ ldd xh,z+2 ;hours
ldd xl,z+3 ;day
ldd temp,z+4 ;month
ldd yl,z+5 ;yearl
andi xl,0xc0
or temp,xl ; combine with day
push temp ;-2 save year/day
- mov temp,temp4
+ mov temp,xh
rcall binbcd2
push temp ;-3 save hours
mov temp,temp3
out sph,zh
ret
-#endif
+#endif /* I2C_SUPPORT */
; ----------------------------------------------
;
;
timer_print:
+ push r15 ;
+ push r14 ;
push yh
push yl
ldiw z,timer_ms
ld yh,z+
sbc temp2,yh
- ldd temp3,z+timerofs
+ ldd r14,z+timerofs
ld yl,z+
- sbc temp3,yl
+ sbc r14,yl
sei
- ldd temp4,z+timerofs
+ ldd r15,z+timerofs
ld yh,z+
- sbc temp4,yh
+ sbc r15,yh
printnewline
printstring "Timer running. Elapsed: "
printstring "."
pop temp
pop temp2
- ldi temp3,0
- ldi temp4,0
+ clr r14
+ clr r15
rcall print_ultoa
printstring "s."
pop yl
pop yh
+ pop r14
+ pop r15
ret
uptime_print:
+ push r15
+ push r14
ldiw z,cnt_1ms
cli
ld temp,z+
ld temp,z+
ld temp2,z+
- ld temp3,z+
+ ld r14,z+
sei
- ld temp4,z+
+ ld r15,z+
printnewline
printstring "Uptime: "
rcall print_ultoa
printstring ","
- ldi temp3,0
- ldi temp4,0
+ clr r14
+ clr r15
pop temp2
pop temp
rcall print_ultoa
printstring "s."
+ pop r14
+ pop r15
ret
; vim:set ts=8 noet nowrap