2023-10-27 16:50:58 +02:00
|
|
|
.segment "CODE"
|
2023-10-26 19:51:20 +02:00
|
|
|
.include "system/system.h65"
|
|
|
|
|
|
|
|
;********************************************************************************
|
|
|
|
; Interrupts
|
|
|
|
;********************************************************************************
|
|
|
|
nmi:
|
2023-10-27 16:50:58 +02:00
|
|
|
lda #'%'
|
|
|
|
jsr _lcd_char
|
2023-10-26 19:51:20 +02:00
|
|
|
rti
|
|
|
|
irq:
|
|
|
|
; lda IFR2 todo: verify that the line below does the same thing
|
|
|
|
lda IO2+IO_IFR
|
|
|
|
sta 0
|
|
|
|
; todo: decide wether to read keypad or dht
|
|
|
|
ora #%10100000
|
|
|
|
; jsr lcd_char ;TODO: Remove
|
|
|
|
jsr kp_read
|
|
|
|
rti
|
2023-10-27 16:50:58 +02:00
|
|
|
; bbs1 0,irq_keypad
|
2023-10-26 19:51:20 +02:00
|
|
|
lda #'-'
|
|
|
|
jsr _lcd_char
|
2023-10-27 16:50:58 +02:00
|
|
|
; bbs4 0,irq_dht
|
|
|
|
; bbs6 0,irq_dht
|
2023-10-26 19:51:20 +02:00
|
|
|
rti
|
|
|
|
irq_keypad:
|
|
|
|
jsr kp_read
|
|
|
|
rti
|
|
|
|
irq_dht:
|
2023-10-27 16:50:58 +02:00
|
|
|
lda IO1 + IO_T1CL ;T1L2 ; clear interrupt flag
|
|
|
|
; jsr dht_irq
|
2023-10-26 19:51:20 +02:00
|
|
|
rti
|
|
|
|
|
|
|
|
;********************************************************************************
|
|
|
|
; Reset sequence
|
|
|
|
;********************************************************************************
|
|
|
|
reset:
|
|
|
|
lda #%11111111
|
2023-10-27 16:50:58 +02:00
|
|
|
sta IO1 + IO_DDRA
|
2023-10-26 19:51:20 +02:00
|
|
|
.macro SET_DEBUG_LED_OFF
|
|
|
|
lda #%00000000
|
2023-10-27 16:50:58 +02:00
|
|
|
sta IO1 + IO_RANH
|
2023-10-26 19:51:20 +02:00
|
|
|
.endmacro
|
|
|
|
.macro SET_DEBUG_LED_ON
|
|
|
|
lda #%11111111
|
2023-10-27 16:50:58 +02:00
|
|
|
sta IO1 + IO_RANH
|
2023-10-26 19:51:20 +02:00
|
|
|
.endmacro
|
|
|
|
SET_DEBUG_LED_OFF
|
|
|
|
jsr lcd_init
|
|
|
|
|
|
|
|
SET_DEBUG_LED_ON
|
2023-10-27 16:50:58 +02:00
|
|
|
.repeat 1000
|
|
|
|
nop
|
|
|
|
.endrepeat
|
|
|
|
SET_DEBUG_LED_OFF
|
2023-10-26 19:51:20 +02:00
|
|
|
; jsr kp_init
|
|
|
|
|
2023-10-27 16:50:58 +02:00
|
|
|
; ; INIT DHT
|
|
|
|
; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
|
|
|
|
; sta IER2
|
|
|
|
; lda #%00111111 ; set Timer 1 to interrupt when loaded
|
|
|
|
; and ACR2
|
|
|
|
; sta ACR2
|
|
|
|
; lda #%00000001 ; set PCR2 bit 0 CA1 pos edge interrupt
|
|
|
|
; ora PCR2
|
|
|
|
; sta PCR2
|
|
|
|
; stz DHT_STATUS
|
2023-10-26 19:51:20 +02:00
|
|
|
|
|
|
|
; enable interrupts
|
|
|
|
cli
|
|
|
|
|
|
|
|
.proc return_home
|
|
|
|
ldx #$00
|
|
|
|
@return_home:
|
|
|
|
lda menu,x
|
|
|
|
beq @return_home_done
|
|
|
|
sta TO_PRINT,x
|
|
|
|
inx
|
|
|
|
bra @return_home
|
|
|
|
@return_home_done:
|
|
|
|
jsr lcd_print_clear
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc home
|
|
|
|
jsr kb_read
|
|
|
|
beq home
|
|
|
|
cmp #'A'
|
|
|
|
jeq printer
|
|
|
|
cmp #'B'
|
2023-10-27 16:50:58 +02:00
|
|
|
; jeq dht_request
|
2023-10-26 19:51:20 +02:00
|
|
|
cmp #'C'
|
|
|
|
beq print_1
|
|
|
|
cmp #'D'
|
|
|
|
beq print_2
|
|
|
|
|
|
|
|
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
|
|
|
|
beq return_home
|
|
|
|
|
|
|
|
bra home
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
print_1:
|
|
|
|
ldx #$00
|
|
|
|
@print_1:
|
|
|
|
lda message_1,x
|
|
|
|
sta TO_PRINT,x
|
|
|
|
inx
|
|
|
|
bne @print_1
|
|
|
|
jsr lcd_print_clear
|
|
|
|
jmp home
|
|
|
|
|
|
|
|
print_2:
|
|
|
|
ldx #$00
|
|
|
|
@print_2:
|
|
|
|
lda message_2,x
|
|
|
|
sta TO_PRINT,x
|
|
|
|
inx
|
|
|
|
bne @print_2
|
|
|
|
jsr lcd_print_clear
|
|
|
|
jmp home
|
|
|
|
|
2023-10-27 16:50:58 +02:00
|
|
|
.segment "RODATA"
|
2023-10-26 19:51:20 +02:00
|
|
|
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
|
|
|
|
message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) "
|
|
|
|
menu:
|
|
|
|
.byte "<A> Printer "
|
|
|
|
.byte "<B> Temperatur "
|
|
|
|
.byte "<C> Text 1 "
|
|
|
|
.asciiz "<D> Text 2 "
|
|
|
|
|
2023-10-27 16:50:58 +02:00
|
|
|
.segment "CODE"
|
2023-10-26 19:51:20 +02:00
|
|
|
;********************************************************************************
|
|
|
|
; Modules
|
|
|
|
;********************************************************************************
|
|
|
|
; LCD
|
|
|
|
; .include "utility.asm6502"
|
2023-10-27 16:50:58 +02:00
|
|
|
LCD_IO = IO1
|
|
|
|
.include "lcd.s65"
|
2023-10-26 19:51:20 +02:00
|
|
|
; Keypad Reading
|
2023-10-27 16:50:58 +02:00
|
|
|
KP_IO = IO1
|
|
|
|
.include "keypad.s65"
|
2023-10-26 19:51:20 +02:00
|
|
|
; Printer
|
2023-10-27 16:50:58 +02:00
|
|
|
.include "printer.s65"
|
2023-10-26 19:51:20 +02:00
|
|
|
; Digital Humidity and Temerature Sensor
|
2023-10-27 16:50:58 +02:00
|
|
|
; .include "dht.s65"
|
2023-10-26 19:51:20 +02:00
|
|
|
;********************************************************************************
|
|
|
|
; reset vector
|
|
|
|
;********************************************************************************
|
2023-10-27 16:50:58 +02:00
|
|
|
.segment "RESET_VECTOR"
|
2023-10-26 19:51:20 +02:00
|
|
|
.word nmi
|
|
|
|
.word reset
|
|
|
|
.word irq
|