X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fatmel.git;a=blobdiff_plain;f=beginners%2Fseason_junior.asm;h=9171e7c57128f3289017444e242ce0789a0f557b;hp=b9551528395be6cc5270a0a2a2ff3d30f900454a;hb=322f236d2088f0ffc8335fa10fd52a7cc2317519;hpb=e108908a7b122bb99cfc6521e0f049f587d7c0bc diff --git a/beginners/season_junior.asm b/beginners/season_junior.asm index b955152..9171e7c 100644 --- a/beginners/season_junior.asm +++ b/beginners/season_junior.asm @@ -3,57 +3,537 @@ ; author: hackbard@hackdaworld.dyndns.org ; -include "../include/2313def.inc" +; at90s2313 +; setup: ; +; vcc card --- atmel vcc +; vcc cam --- +; rst cam --- atmel int0 (pd2) +; rst card --- atmel (pd4) +; clk card -\ +; - atmel t1 (pd5) +; clk cam -/ +; gnd card --- gnd cam --- atmel gnd +; i/o card --- atmel icp (pd6) +; i/o cam --- atmel int1 (pd3) + +.include "../include/2313def.inc" + + +; ####### +; defines +; ####### + +; baudrate = clock freq / etu +; std smartcard etu: 372 +; other smartcards: 625 +.equ etu = 625 +.equ etu_h = 312 +.equ baudrate = 8 ; UBRR value for 57600 bits/s (8mhz clock) + +; sizes +.equ uart_data_len = 4 + +; names for registers +.def tmp = r16 +.def bitcount = r17 +.def tmp1 = r18 +.def tmp2 = r19 +.def byte = r20 +.def overflow_counter = r21 +.def counter_l = r22 +.def counter_h = r23 +.def state = r24 +.def state_m = r25 +.def mode = r26 +.def counter_l_tmp = r27 +.def counter_h_tmp = r28 +.def one = r1 +.def zero = r0 + +; state +.equ LOW = (1<<0) +.equ LOW_F = 1 +.equ HIGH = (1<<1) +.equ HIGH_F = 2 +; mode +.equ STUPID = (1<<0) ; forward cam <-> card communication +.equ STUPID_F = 1 +.equ COOL = (1<<1) ; send time (clocks) & state via uart +.equ COOL_F = 2 +.equ ELITE = (1<<2) ; create bytes, maybe even whole command arrays +.equ ELITE_F = 3 +.equ GODLIKE = (1<<3) ; filter and mask for commands to card - send rejected via uart only +.equ GODLIKE_F = 4 +.equ INCREDIBLE_HACK = (1<<4) ; destroy all your hardware +.equ INCREDIBLE_HACK_F = 5 +; leds +.equ LED_CARD = PB0 +.equ LED_CAM = PB1 +.equ LED_FWD_TO_CAM = PB2 +.equ LED_FWD_TO_CARD = PB3 +.equ LED_OVERFLOW = PB4 + +; but there is only stupid and cool mode right now %) + + +; ############# +; programm code +; ############# + +; ------------------ ; interrupt vectors: -; +; ------------------ ; reset -rjmp INIT ; init routine +rjmp INIT -; int 0 -rjmp REC_FROM_CARD ; smartcard sends data, we listen +; int0 +rjmp RST_CAM -; 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 +rjmp REC_CARD ; 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 +rjmp UART_OUT ; uart tx complete -reti ; maybe we need it later +reti ; analog comparator -reti ; not in use +reti -; +; ------------ ; init routine -; +; ------------ INIT: +; output low on rst to card while init +sbi DDRD,DDD4 +cbi PORTD,PD4 + ; set stackpointer -ldi r16,low(RAMEND) -out SPL,r16 +ldi tmp,low(RAMEND) +out SPL,tmp + +; enable interrupts int0,int1,sleep +ldi tmp,((1<