implemented "stupid mode" - direct card/cam io
authorhackbard <hackbard>
Thu, 11 Dec 2003 02:40:24 +0000 (02:40 +0000)
committerhackbard <hackbard>
Thu, 11 Dec 2003 02:40:24 +0000 (02:40 +0000)
beginners/season_junior.asm

index 94ba21c..9c02191 100644 (file)
 ; i/o card --- atmel int0 (pd2)
 ; i/o cam  --- atmel int1 (pd3)
 
-include "../include/2313def.inc"
+.include "../include/2313def.inc"
 
+; functions by now:
+;
+; stupid mode only by now. just see what cam/card do and redirect
+; this to card/cam.
+;
+; next implementation:
+; 
+; try to read one byte of card/cam communication and output via uart.
+; output time information in some way.
+;
+; future:
+;
+; buffer/parse whole strings and decide whether to send to card or not.
 
 ;
 ; interrupt vectors:
@@ -67,27 +80,124 @@ out SPL,r16
 ldi r16,((1<<INT0)|(1<<INT1))
 out GIMSK,r16
 ; int0/1 setup
-ldi r16,((1<<ISC01)|(1<<ISC00)|(1<<ISC11)|(1<<ISC10))
+ldi r16,((1<<ISC01)|(1<<ISC00)|(1<<ISC10)|(1<<ISC11))
+out MCUCR,r16
+in r16,MCUCR
+sbic PORTD,PD2
+cbr r16,ISC00
+out MCUCR,r16
+sbic PORTD,PD3
+cbr r16,ISC10
 out MCUCR,r16
-sbis PORTD,PORTD2
-cbi MCUCR,ISC00
-sbis PORTD,PORTD3
-cbi MCUCR,ISC10
 
 ; enable t/c overflow interrupt
-sbi TIMSK,TOIE1
+ldi r16,(1<<TOIE1)
+out TIMSK,r16
 ; setup t/c
 ldi r16,((1<<CS12)|(1<<CS11)|(1<<CS10))
 out TCCR1B,r16
 
+; init bitcounter and overflow counter
+ldi r20,0 ; bitcounter
+ldi r21,0 ; register for constructing the byte
+ldi r22,0 ; overflow counter
+
+; constant 1 in r1
+ldi r16,1
+mov r1,r16
+
 ; enable interrupts (global)
 sei
 
 ;
-; rec_card routine
+; rec_card routines
 ;
 
 REC_CARD:
 
-; get port status
-in .... continue here .. :)
+; int0 -> input, int1 -> output
+ldi r16,(1<<DDD3)
+out DDRD,r16
+
+; decide what to do
+sbic PORTD,PD2
+rjmp REC_CARD_HIGH
+rjmp REC_CARD_LOW
+
+REC_CARD_HIGH:
+
+; output high on port to cam
+ldi r16,(1<<PD3)
+out PORTD,r16
+
+; toggle int0 sense
+in r16,MCUCR
+cbr r16,ISC00
+out MCUCR,r16
+
+reti
+
+REC_CARD_LOW:
+
+; output low on port to cam
+ldi r16,0
+out PORTD,r16
+
+; toggle int0 sense
+in r16,MCUCR
+cbr r16,ISC00
+out MCUCR,r16
+
+reti
+
+;
+; rec_cam routines
+;
+
+REC_CAM:
+
+; int1 -> input, int0 -> output
+ldi r16,(1<<DDD2)
+out DDRD,r16
+
+; decide what to do
+sbic PORTD,PD3
+rjmp REC_CAM_HIGH
+rjmp REC_CAM_LOW
+
+REC_CAM_HIGH:
+
+; output high on port to card
+ldi r16,(1<<PD2)
+out PORTD,r16
+
+; toggle int1 sense
+in r16,MCUCR
+cbr r16,ISC10
+out MCUCR,r16
+
+reti
+
+REC_CAM_LOW:
+
+; output low on port to card
+ldi r16,0
+out PORTD,r16
+
+; toggle int 1 sense
+in r16,MCUCR
+cbr r16,ISC10
+out MCUCR,r16
+
+reti
+
+;
+; t1_overflow routine
+;
+
+T1_OVERFLOW:
+
+add r22,r1 ; inc counter overflow register
+
+reti
+