; author: hackbard@hackdaworld.dyndns.org
;
+
+; at90s2313
+; setup:
+; vcc card --- vcc cam
+; rst card --- rst cam --- atmel t0 (pd4)
+; clk card --- clk cam --- atmel t1 (pd5)
+; gnd card --- gnd cam --- atmel gnd
+; i/o card --- atmel int0 (pd2)
+; i/o cam --- atmel int1 (pd3)
+
include "../include/2313def.inc"
+
;
; interrupt vectors:
;
; reset
-rjmp INIT ; init routine
+rjmp INIT
-; int 0
-rjmp REC_FROM_CARD ; smartcard sends data, we listen
+; int0
+rjmp REC_CARD
-; int 1
-rjmp REC_FROM_CAM ; cam sends data, we listen
+; int1
+rjmp REC_CAM
; timer/counter capt 1
-reti ; we just count the smartcard clocks
+reti
; timer/counter compare
-reti ; not in use
+reti
; timer/counter overflow 1
-reti ; not in use
+rjmp T1_OVERFLOW
; timer/counter overflow 0
-reti ; not in use
+reti
; uart rx complete
-reti ; maybe we need it later
+reti
; uart data register empty
-reti ; maybe we need it later
+reti
; uart tx complete
-reti ; maybe we need it later
+reti
; analog comparator
-reti ; not in use
+reti
;
; init routine
ldi r16,low(RAMEND)
out SPL,r16
+; enable interrupts int0,int1
+ldi r16,((1<<INT0)|(1<<INT1))
+out GIMSK,r16
+; int0/1 setup
+ldi r16,((1<<ISC01)|(1<<ISC00)|(1<<ISC11)|(1<<ISC10))
+out MCUCR,r16
+sbis PORTD,PORTD2
+cbi MCUCR,ISC00
+sbis PORTD,PORTD3
+cbi MCUCR,ISC10
+
+; enable t/c overflow interrupt
+sbi TIMSK,TOIE1
+; setup t/c
+ldi r16,((1<<CS12)|(1<<CS11)|(1<<CS10))
+out TCCR1B,r16
+
; enable interrupts (global)
-ldi r16,(1<<7)
-out SREG,r16
+sei
+
+;
+; rec_card routine
+;
+REC_CARD:
+; get port status
+in .... continue here .. :)