.define etu_h 312
.define baudrate 5 ; UBRR value for 76800 bits/s (8mhz clock)
+; sizes
+.define uart_data_len 4
+.define uart_data_len_f 3
+
; names for registers
.define tmp r16
.define bitcount r17
.define mode r26
.define counter_l_tmp r27
.define counter_h_tmp r28
+.define address_h r31
+.define address_l r30
.define one r1
.define zero r0
ldi mode,(STUPID|COOL)
ldi counter_l_tmp,0
ldi counter_h_tmp,0
+ldi address_h,SRAM_START_H
ldi tmp,1
mov one,tmp
ldi tmp,0
REC_CARD:
; save counter
-in counter_l,ICR1L
+In counter_l,ICR1L
in counter_h,ICR1H
; toggle state
; send time and state via uart
sbrc mode,COOL_F
-rcall SEND_TO_UART ; -> prepare date & enable uart dre interrupt (sbi UCR,UDRIE)
+rcall PREPARE_UART
; return
reti
TOGGLE_ICP_SENSE:
; toggle according to state
-cbi TCCR1B,ICES1
-sbrs state,HIGH
-sbi TCCR1B,ICES1
+in tmp,TCCR1B
+cbi tmp,ICES1
+sbrs state,HIGH ; maybe toggle according to TCCR1B?
+sbi tmp,ICES1
+out TCCR1B,tmp
; return
ret
; fwd_to_cam routine
; ------------------
+FWD_TO_CAM:
+
+; disable external interrupt 1 while toggling edge
+in tmp,GIMSK
+cbr tmp,INT1
+out GIMSK,tmp
+
; output state on port to cam
-mov tmp,state
-andi tmp,HIGH
-lsl tmp ; as we have to set pd3 (dirty, shorter way?)
+in tmp1,PORTD
+sbr tmp1,PD3
+sbrs state,HIGH_F
+cbr tmp1,PD3
+
+; configure as output and push-pull low/high
sbi DDRD,DDD3
-out PORTD,tmp ; <- hunz: low or high if pd3 bit is set ?
+out PORTD,tmp1;
+
+; reenable external interrupt 1
+cbr tmp,INT1
+out GIMSK,tmp
; return
ret
+; --------------------
+; prepare_uart routine
+; --------------------
-; zzZZzZzZZZ .... hier gehts weiter !!!
+PREPARE_UART:
-;
-; rec_cam routines
-;
+; by now just send state and counter, so there is no data to prepare
+
+; enable uart data register empty interrupt
+sbi UCR,UDRIE
+
+; return
+ret
+
+
+; ---------------
+; rec_cam routine
+; ---------------
REC_CAM:
-; decide what to do
-sbic PORTD,PD3
-rjmp REC_CAM_HIGH
-rjmp REC_CAM_LOW
+; first thing - pullup on
+cbi DDRD,DDD3
+sbi DDRD,PD3
-REC_CAM_HIGH:
+; save counter
+in counter_l,ICR1L
+in counter_h,ICR1H
-; output high on port to card
-sbi PORTD,PD6
+; toggle state
+eor state,state_m
+
+; toggle int sense
+rcall TOGGLE_INT_SENSE
-; toggle int1 sense
-in r16,MCUCR
-cbr r16,ISC10
-out MCUCR,r16
+HIER FEHLT NOCH VIEL ...
+; return
reti
-REC_CAM_LOW:
+; ------------------------
+: toggle_int_sense routine
+; ------------------------
-; output low on port to card
-cbi PORTD,PD6
+TOGGLE_INT_SENSE:
-; toggle int 1 sense
-in r16,MCUCR
-sbr r16,ISC10
-out MCUCR,r16
+in tmp,MCUCR
+cbr tmp,ISC10
+sbis state,HIGH_F
+sbr tmp,ISC10
+out MCUCR,tmp
-reti
+; return
+ret
-;
+; -------------------
; t1_overflow routine
-;
+; -------------------
T1_OVERFLOW:
-add r22,r1 ; inc counter overflow register
+; increment counter overflow
+add overflow_counter,one
+; return
reti
-;
+; ---------------
; rst_cam routine
-;
+; ---------------
RST_CAM:
-; decide what to do
-sbic PORTD,PD2
-rjmp RST_CAM_HIGH
-rjmp RST_CAM_LOW
-
-RST_CAM_HIGH:
+; pull down rst from card
+sbi DDRD,DDD4
+cbi PORTD,PD4
-; output high on rst port to card
-sbi PORTD,PD4
+; jump to init
+rjmp INIT
-; toggle int0 sense
-in r16,MCUCR
-cbr r16,ISC00
-out MCUCR,r16
+; ----------------
+; uart_out routine
+; ----------------
-reti
+UART_OUT:
-RST_CAM_LOW:
+; disable uart data register empty interrupt
+cbi UCR,UDRIE
-; output low on rst port to cam
-cbi PORTD,PD4
+; init counter
+mov address_l,zero
-; toggle int0 sense
-in r16,MCUCR
-sbr r16,ISC00
-out MCUCR,r16
+; send the data
+rcall UART_SEND
+; return
reti
-;
-; uart_out routines
-;
-
-UART_OUT:
-
-;
-; hier weiter ...
-;
+.... wahhh ! zzZz