X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=beginners%2Fseason_junior.asm;h=35d51d1f09b914b17b9b5bd1aa70594355f80047;hb=b9abd3ff7f4bb2ce8e56d3fec911968990cace60;hp=8380e9215d7cdb6d4d04181f0ebe475d109c48e4;hpb=c8b18c7c3560c9de4704291ca764cd1041228380;p=my-code%2Fatmel.git diff --git a/beginners/season_junior.asm b/beginners/season_junior.asm index 8380e92..35d51d1 100644 --- a/beginners/season_junior.asm +++ b/beginners/season_junior.asm @@ -6,6 +6,7 @@ ; at90s2313 ; setup: +; ; vcc card --- atmel vcc ; vcc cam --- ; rst cam --- atmel int0 (pd2) @@ -19,23 +20,65 @@ .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. -; +; ####### +; defines +; ####### + +; baudrate = clock freq / etu +; std smartcard etu: 372 +; other smartcards: 625 +.equ etu = 625 +.equ etu_h = 312 +.equ baudrate = 5 ; UBRR value for 76800 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 + +; but there is only stupid and cool mode right now %) + + +; ############# +; programm code +; ############# + +; ------------------ ; interrupt vectors: -; +; ------------------ ; reset rjmp INIT @@ -53,7 +96,7 @@ rjmp REC_CARD reti ; timer/counter overflow 1 -rjmp CLK_OVERFLOW +rjmp T1_OVERFLOW ; timer/counter overflow 0 reti @@ -70,202 +113,329 @@ reti ; analog comparator reti -; +; ------------ ; init routine -; - -MAIN: -rjmp MAIN +; ------------ 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 -ldi r16,((1<