From 9b1eb21f2bffaa3f42702cb73b9f19eae2fee761 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Fri, 28 Aug 2020 14:18:30 +0200 Subject: Software Implemented display function. --- Software/pinlock.asm | 70 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 8 deletions(-) (limited to 'Software/pinlock.asm') diff --git a/Software/pinlock.asm b/Software/pinlock.asm index b119723..ee80741 100644 --- a/Software/pinlock.asm +++ b/Software/pinlock.asm @@ -18,18 +18,26 @@ init: 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 + ldi par0, 0 + ldi par1, 0 + rcall display + ldi par0, 1 + ldi par1, 1 + rcall display + ldi par0, 2 + ldi par1, 2 + rcall display + ldi par0, 3 + ldi par1, 3 + rcall display + main: - ldi par0, 0b11000011 + ldi par0, 0b11111111 rcall status wait: @@ -41,8 +49,6 @@ wait: dec par1 nop brne wait - inc cnt - out PORTA, cnt ret ; Output the status @@ -70,3 +76,51 @@ status_end: cpi tmp0, 0 brne status_loop ret + +; Display the digit on a given display +; par0 = Display number +; par1 = Digit +display: + mov tmp0, par1 + andi tmp0, 0x0F + cpi par0, 0 + breq display_0 + cpi par0, 1 + breq display_1 + cpi par0, 2 + breq display_2 + cpi par0, 3 + breq display_3 + ret +display_0: + in tmp1, PORTA + andi tmp1, 0xF0 + or tmp1, tmp0 + out PORTA, tmp1 + ret +display_1: + in tmp1, PORTB + andi tmp1, 0xF0 + or tmp1, tmp0 + out PORTB, tmp1 + ret +display_2: + in tmp1, PORTA + andi tmp1, 0x0F + lsl tmp0 + lsl tmp0 + lsl tmp0 + lsl tmp0 + or tmp1, tmp0 + out PORTA, tmp1 + ret +display_3: + in tmp1, PORTB + andi tmp1, 0x0F + lsl tmp0 + lsl tmp0 + lsl tmp0 + lsl tmp0 + or tmp1, tmp0 + out PORTB, tmp1 + ret -- cgit v1.2.1