.segment "CODE" .include "system/system.h65" ;******************************************************************************** ; Interrupts ;******************************************************************************** nmi: lda #'%' jsr _lcd_char 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 ; bbs1 0,irq_keypad lda #'-' jsr _lcd_char ; bbs4 0,irq_dht ; bbs6 0,irq_dht rti irq_keypad: jsr kp_read rti irq_dht: lda IO1 + IO_T1CL ;T1L2 ; clear interrupt flag ; jsr dht_irq rti ;******************************************************************************** ; Reset sequence ;******************************************************************************** reset: lda #%11111111 sta IO1 + IO_DDRA .macro SET_DEBUG_LED_OFF lda #%00000000 sta IO1 + IO_RANH .endmacro .macro SET_DEBUG_LED_ON lda #%11111111 sta IO1 + IO_RANH .endmacro SET_DEBUG_LED_OFF jsr lcd_init SET_DEBUG_LED_ON .repeat 1000 nop .endrepeat SET_DEBUG_LED_OFF ; jsr kp_init ; ; 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 ; 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' ; jeq dht_request 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 .segment "RODATA" message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz" message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) " menu: .byte " Printer " .byte " Temperatur " .byte " Text 1 " .asciiz " Text 2 " .segment "CODE" ;******************************************************************************** ; Modules ;******************************************************************************** ; LCD ; .include "utility.asm6502" LCD_IO = IO1 .include "lcd.s65" ; Keypad Reading KP_IO = IO1 .include "keypad.s65" ; Printer .include "printer.s65" ; Digital Humidity and Temerature Sensor ; .include "dht.s65" ;******************************************************************************** ; reset vector ;******************************************************************************** .segment "RESET_VECTOR" .word nmi .word reset .word irq