avr: make REED module usable with one and two output pins.

This commit is contained in:
Martin Preuss
2024-10-06 01:31:44 +02:00
parent adcb037976
commit d7705590fe
3 changed files with 30 additions and 20 deletions

View File

@@ -13,7 +13,7 @@
; AtTiny84
; --------
; VCC 1 14 GND
; PB0 2 13 PA0 REED_OUT
; REED_OUT2 PB0 2 13 PA0 REED_OUT1
; PB1 3 12 PA1 COM-DATA
; /RESET PB3 4 11 PA2 REED_IN1
; [KEY1] PB2 5 10 PA3 LED
@@ -125,10 +125,15 @@
; Reed
;
.equ REEDOUT_DDR = DDRA
.equ REEDOUT_PORT = PORTA
.equ REEDOUT_PIN = PINA
.equ REEDOUT_PINNUM = PORTA0
.equ REEDOUT1_DDR = DDRA
.equ REEDOUT1_PORT = PORTA
.equ REEDOUT1_PIN = PINA
.equ REEDOUT1_PINNUM = PORTA0
.equ REEDOUT2_DDR = DDRB
.equ REEDOUT2_PORT = PORTB
.equ REEDOUT2_PIN = PINB
.equ REEDOUT2_PINNUM = PORTB0
.equ REED1_DDR = DDRA
.equ REED1_PORT = PORTA

View File

@@ -122,20 +122,20 @@
; Reed
;
.equ REEDOUT_DDR = DDRA
.equ REEDOUT_PORT = PORTA
.equ REEDOUT_PIN = PINA
.equ REEDOUT_PINNUM = PORTA0
.equ REEDOUT1_DDR = DDRA
.equ REEDOUT1_PORT = PORTA
.equ REEDOUT1_PIN = PINA
.equ REEDOUT1_PINNUM = PORTA5
.equ REED1_DDR = DDRA
.equ REED1_PORT = PORTA
.equ REED1_PIN = PINA
.equ REED1_PINNUM = PORTA2
.equ REED1_DDR = DDRB
.equ REED1_PORT = PORTB
.equ REED1_PIN = PINB
.equ REED1_PINNUM = PORTB0
.equ REED2_DDR = DDRA
.equ REED2_PORT = PORTA
.equ REED2_PIN = PINA
.equ REED2_PINNUM = PORTA5
.equ REED2_DDR = DDRB
.equ REED2_PORT = PORTB
.equ REED2_PIN = PINB
.equ REED2_PINNUM = PORTB1

View File

@@ -124,15 +124,20 @@ REED_Init:
ldi r17, (reedDataEnd-reedDataBegin)
rcall Utils_FillSram ; (r17, x)
cbi REEDOUT_PORT, REEDOUT_PINNUM ; set common reed port to low
sbi REEDOUT_DDR, REEDOUT_PINNUM ; set common reed output port as output
cbi REED1_PORT, REED1_PINNUM ; disable internal pullup for DATA
cbi REED1_DDR, REED1_PINNUM ; set reed1 port as input
cbi REED2_PORT, REED2_PINNUM ; disable internal pullup for DATA
cbi REED2_DDR, REED2_PINNUM ; set reed2 port as input
cbi REEDOUT1_PORT, REEDOUT1_PINNUM ; set common reed port to low
sbi REEDOUT1_DDR, REEDOUT1_PINNUM ; set common reed output port as output
.ifdef REEDOUT2_DDR
cbi REEDOUT2_PORT, REEDOUT2_PINNUM ; set common reed port to low
sbi REEDOUT2_DDR, REEDOUT2_PINNUM ; set common reed output port as output
.endif
rcall reedSetupConfig ; initial setup from EEPROM, if possible
ret