ldi r16,((1<<CS12)|(1<<CS11)|(1<<CS10)|(1<<ICNC1))
out TCCR1B,r16
+; configure uart - interrupt enabled when i/o
+ldi r16,3
+out UBRR,r16
+sbi UCR,TXEN
+
; init bitcounter and overflow counter
ldi r20,0 ; bitcounter
ldi r21,0 ; register for constructing the byte
REC_CARD_HIGH:
+; save counter
+in r24,ICR1L
+in r25,ICR1H
+
; output high on port to cam
sbi PORTD,PD3
;cbr r16,ICES1
;out TCCR1B,r16
-; build the byte ;) - still wrong!
-ori r21,1
-lsl r21
+; status tu submit
+ldi r26,1
-;
-; hier gehts weiter ...
-;
+; enable uart dre interrupt
+sbi UCR,UDRIE
reti
REC_CARD_LOW:
+; save counter
+in r27,ICR1L
+in r28,ICR1H
+
; output low on port to cam
-ldi r16,0
-out PORTD,r16
+cbi PORTD,PD3
-; toggle int0 sense
-in r16,MCUCR
-cbr r16,ISC00
-out MCUCR,r16
+; toggle icp sense
+sbi TCCR1B,ICES1
+
+; status to submit
+ldi r26,0
+
+; enable uart dre interrupt
+sbi UCR,UDRIE
reti
REC_CAM:
-; int1 -> input, int0 -> output
-ldi r16,(1<<DDD2)
-out DDRD,r16
-
; decide what to do
sbic PORTD,PD3
rjmp REC_CAM_HIGH
REC_CAM_HIGH:
; output high on port to card
-ldi r16,(1<<PD2)
-out PORTD,r16
+sbi PORTD,PD6
; toggle int1 sense
in r16,MCUCR
REC_CAM_LOW:
; output low on port to card
-ldi r16,0
-out PORTD,r16
+cbi PORTD,PD6
; toggle int 1 sense
in r16,MCUCR
-cbr r16,ISC10
+sbr r16,ISC10
out MCUCR,r16
reti
reti
+;
+; rst_cam routine
+;
+
+RST_CAM:
+
+; decide what to do
+sbic PORTD,PD2
+rjmp RST_CAM_HIGH
+rjmp RST_CAM_LOW
+
+RST_CAM_HIGH:
+
+; output high on rst port to card
+sbi PORTD,PD4
+
+; toggle int0 sense
+in r16,MCUCR
+cbr r16,ISC00
+out MCUCR,r16
+
+reti
+
+RST_CAM_LOW:
+
+; output low on rst port to cam
+cbi PORTD,PD4
+
+; toggle int0 sense
+in r16,MCUCR
+sbr r16,ISC00
+out MCUCR,r16
+
+reti
+
+;
+; uart_out routines
+;
+
+UART_OUT:
+
+;
+; hier weiter ...
+;