.include "tn2313def.inc" .equ SEG_G =0x1000 .equ SEG_P_G =0x4000 .equ SEG_L_G =0x2000 .equ SEG_SR =0x8000 .equ SEG_P_D =0x2 .equ SEG_L_D =0x1 .equ SEG_D =0x4 .equ KROPKA =0x8 .equ zero =SEG_G+SEG_P_G+SEG_L_G+SEG_P_D+SEG_L_D+SEG_D .equ jeden =SEG_P_G+SEG_P_D .equ dwa =SEG_G+SEG_P_G+SEG_SR+SEG_L_D+SEG_D .equ trzy =SEG_G+SEG_P_G+SEG_SR+SEG_P_D+SEG_D .equ cztery =SEG_L_G+SEG_P_G+SEG_SR+SEG_P_D .equ piec =SEG_G+SEG_L_G+SEG_SR+SEG_P_D+SEG_D .equ szesc =SEG_G+SEG_L_G+SEG_SR+SEG_P_D+SEG_L_D+SEG_D .equ siedem =SEG_G+SEG_P_G+SEG_P_D .equ osiem =SEG_G+SEG_P_G+SEG_L_G+SEG_SR+SEG_P_D+SEG_L_D+SEG_D .equ dziewiec=SEG_G+SEG_P_G+SEG_L_G+SEG_SR+SEG_P_D+SEG_D .equ litstopien=SEG_G+SEG_P_G+SEG_L_G+SEG_SR .equ litc =SEG_G+SEG_L_G+SEG_L_D+SEG_D .equ litj =SEG_L_D + SEG_D + SEG_P_D + SEG_P_G .equ litd =SEG_L_D+SEG_D+SEG_P_D+SEG_SR+SEG_P_G .equ litp =SEG_L_D+SEG_L_G+SEG_G+SEG_SR+SEG_P_G .equ litn =SEG_SR+SEG_P_D+SEG_L_D .equ MINUS = 10 .equ NIC = 11 .equ STOPIEN = 12 .equ C = 13 .equ J = 14 .equ D = 15 .equ P = 16 .equ N = 17 .equ PORT595 =PORTB .equ DDR595 =DDRB .equ DIN =PB4 .equ CLK =PB6 .equ LOAD =PB3 .equ _1WDDR = DDRB .equ _1WPIN = PINB .equ _1WL = PB2 .equ _1WPORT = PORTB ;rejestry .def sregtmp =r0 .def tmpi1 =r1 .def wysl_i =r2 .def ZERO =r3 .def mig1 =r4 .def mig2 =r5 .def przyc =r6 .def stp =r7 .def ptmp =r8 .def jasnosc =r9 .def ile_czuj=r10 .def stan =r11 ;0-czas, 1-data, 2-temp .def stan_tmp=r12 .def mig2r =r13 .def rjasnosc=r14 ;r15 ;tylko dla search_rom .def powtorz=r11 .def ostatni=r12 .def licznik=r13 .def ostatni_zero =r14 .def dana=r15 .def tmp =r16 .def tmp1 =r17 .def L =r18 .def ARGD =r19 .def LSB =r20 .def tmpi2 =r20 .def MSB =r21 .def tmpi =r22 .def ustaw_i =r23 .def ARG =r24 .def ARGL =r24 .def ARGH =r25 .def X =r26 .def tryb =r27 .def LY =r28 .def HY =r29 .def LZ =r30 .def HZ =r31 .macro adpmZ ldi r30, (@0*2)&255 ldi r31, @0>>7 .endmacro .macro lsr16 lsr @1 ror @0 .endmacro .macro adi subi @0, 256-@1 .endmacro .dseg w: .byte 7 minusik: .byte 1 minusik1: .byte 1 minusik2: .byte 1 temperatura1: .byte 2 temperatura2: .byte 2 czas: sek: .byte 1 min: .byte 1 godz: .byte 1 dzient: .byte 1 dzienm: .byte 1 mies: .byte 1 rok: .byte 1 konf: jasn_dzien: .byte 1 jasn_noc: .byte 1 pocz_dnia: .byte 1 pocz_nocy: .byte 1 cykl: .byte 1 czasc: .byte 1 rom: ukl1: .byte 8 ukl2: .byte 8 dtemp: .byte 1 .cseg ldi tmp, RAMEND ;stos out SPL, tmp ldi tmp, 1<0 nie sprawdzaj ret przyc_dalej: in tmpi, PIND sbrs tmpi, 0 rjmp wcisniety sbrs tmpi, 1 rjmp wcisniety in tmpi, PINA sbrs tmpi, 1 rjmp wcisniety clr stp ret wcisniety: mov tmpi, stp cpi tmpi, 255 breq wpisz_przyc inc stp cpi tmpi, 2 breq wpisz_przyc ret wpisz_przyc: clr tmpi2 in tmpi, PIND sbrs tmpi, 0 ori tmpi2, 1 sbrs tmpi, 1 ori tmpi2, 2 in tmpi, PINA sbrs tmpi, 1 ori tmpi2, 4 mov przyc, tmpi2 ret przycisk: mov ptmp, przyc clr przyc ret wygas_zero: lds tmpi, w+6 cpi tmpi, 11 brsh niezero ld tmpi, X cpi tmpi, 0 brne niezero ldi tmpi, NIC st X, tmpi niezero: ret main: clr przyc ldi X, w pet_zer: st X+, ZERO cpi X, dtemp brlo pet_zer st X, ZERO ldi ARG, 7 ldi ARGH, 1 rcall i2cSend ldi X, konf ;wczytaj ustawienia ldi ARG, 8 ldi ARGH, 6 rcall i2cReceive rcall search_rom and ile_czuj, ile_czuj brne nie_wylacz_temp sts cykl, ZERO nie_wylacz_temp: ldi tmp, 1<