.segment "CODE" .include "system/system.h65" ;******************************************************************************** ; 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" ;******************************************************************************** ; 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 ; .repeat 1000 ; nop ; .endrepeat ; SET_DEBUG_LED_ON jsr kp_init ; SET_DEBUG_LED_OFF ; ; 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 Print message_menu ; @return_home: ; lda menu,x ; beq @return_home_done ; sta TO_PRINT,x ; jsr _lcd_char ; inx ; bra @return_home ; @return_home_done: ; jsr lcd_print_clear .endproc .proc home ; SET_DEBUG_LED_ON jsr kb_read beq home cmp #'A' jeq printer cmp #'B' ; jeq dht_request cmp #'C' jeq print_1 cmp #'D' jeq print_2 cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home) beq return_home ; .repeat 500 ; nop ; .endrepeat ; SET_DEBUG_LED_OFF ; .repeat 500 ; nop ; .endrepeat jmp home .endproc print_1: Print message_1 jmp home print_2: Print message_2 jmp home .segment "RODATA" message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz" message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) " message_menu: .byte " Printer " .byte " Temperatur " .byte " Text 1 " .asciiz " Text 2 " .segment "CODE" ;******************************************************************************** ; reset vector ;******************************************************************************** .segment "RESET_VECTOR" .word nmi .word reset .word irq