diff options
author | Leonard Kugis <leonard@kug.is> | 2020-08-28 13:22:16 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2020-08-28 13:22:16 +0200 |
commit | 0c9fcab3477fadbdb56333d6e4a5ab3e1618c4b3 (patch) | |
tree | d4775615aeb301b2c285948cbddf733c8d8bab88 /Software/pinlock.asm | |
parent | 82c8f6dc7ea8ca115adc91ffe5454796b2ae92fc (diff) |
Software
Implemented basic functionality.
Diffstat (limited to 'Software/pinlock.asm')
-rw-r--r-- | Software/pinlock.asm | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Software/pinlock.asm b/Software/pinlock.asm new file mode 100644 index 0000000..b119723 --- /dev/null +++ b/Software/pinlock.asm @@ -0,0 +1,72 @@ +.include "m16def.inc" +.def tmp0 = r16 +.def par0 = r17 +.def par1 = r18 +.def cnt = r19 +.def tmp1 = r20 +.def tmp2 = r21 + +init: + ldi tmp0, HIGH(RAMEND) + out SPH, tmp0 + ldi tmp0, LOW(RAMEND) + ldi par0, 0xFF + ldi par1, 0xFF + rcall wait + out SPL, tmp0 + ldi tmp0, 0b11111111 + out DDRA, tmp0 + ldi tmp0, 0b11111111 + out DDRB, tmp0 + ldi tmp0, 0x31 + mov cnt, tmp0 + out PORTA, tmp0 + ldi tmp0, 0x42 + out PORTB, tmp0 + ldi tmp0, 0b11000000 + out DDRD, tmp0 + ldi tmp0, 0b00000000 + out PORTD, tmp0 + +main: + ldi par0, 0b11000011 + rcall status + +wait: + mov tmp0, par0 + dec par0 + nop + brne wait + mov par0, tmp0 + dec par1 + nop + brne wait + inc cnt + out PORTA, cnt + ret + +; Output the status +; par0 = Status bits +status: + ldi tmp0, 1 +status_loop: + mov tmp1, par0 + and tmp1, tmp0 + cp tmp0, tmp1 + breq status_set + ldi tmp1, 0b00111111 + out PORTD, tmp1 + ldi tmp1, 0b10111111 + out PORTD, tmp1 + rjmp status_end +status_set: + ldi tmp1, 0b01111111 + out PORTD, tmp1 + ldi tmp1, 0b11111111 + out PORTD, tmp1 + rjmp status_end +status_end: + lsl tmp0 + cpi tmp0, 0 + brne status_loop + ret |