2023-11-11 12:13:47 +01:00
|
|
|
.include "system/system.s65"
|
|
|
|
.code
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-10-30 22:17:19 +01:00
|
|
|
.macro DEBUG_LED_OFF nr
|
2023-11-01 13:13:23 +01:00
|
|
|
lda IO1 + IO::RA
|
2023-10-30 22:17:19 +01:00
|
|
|
.if nr = 0
|
|
|
|
and #%11111110
|
|
|
|
.else
|
|
|
|
and #%11111101
|
|
|
|
.endif
|
2023-11-01 13:13:23 +01:00
|
|
|
sta IO1 + IO::RA
|
2023-10-30 22:17:19 +01:00
|
|
|
.endmacro
|
|
|
|
|
|
|
|
.macro DEBUG_LED_ON nr
|
2023-11-01 13:13:23 +01:00
|
|
|
lda IO1 + IO::RA
|
2023-10-30 22:17:19 +01:00
|
|
|
.if nr = 0
|
|
|
|
ora #%00000001
|
|
|
|
.else
|
|
|
|
ora #%00000010
|
|
|
|
.endif
|
2023-11-01 13:13:23 +01:00
|
|
|
sta IO1 + IO::RA
|
2023-10-30 22:17:19 +01:00
|
|
|
.endmacro
|
|
|
|
|
2023-10-28 03:48:27 +02:00
|
|
|
;********************************************************************************
|
|
|
|
; Modules
|
|
|
|
;********************************************************************************
|
|
|
|
; LCD
|
|
|
|
; .include "utility.asm6502"
|
|
|
|
LCD_IO = IO1
|
2023-11-09 12:10:00 +01:00
|
|
|
.include "system/lcd.s65"
|
2023-10-28 03:48:27 +02:00
|
|
|
; Keypad Reading
|
2023-10-30 22:17:19 +01:00
|
|
|
KP_IO = IO2
|
2023-11-09 12:10:00 +01:00
|
|
|
.include "system/keypad.s65"
|
2023-10-30 22:17:19 +01:00
|
|
|
; SPI
|
2023-11-09 12:10:00 +01:00
|
|
|
SPI_IO = IO2
|
2023-10-30 22:17:19 +01:00
|
|
|
.include "system/spi.s65"
|
2023-10-28 03:48:27 +02:00
|
|
|
; Printer
|
2023-11-09 12:10:00 +01:00
|
|
|
.include "programs/printer.s65"
|
|
|
|
.include "programs/print_slow.s65"
|
2023-10-28 03:48:27 +02:00
|
|
|
; Digital Humidity and Temerature Sensor
|
|
|
|
; .include "dht.s65"
|
|
|
|
|
2023-10-30 22:17:19 +01:00
|
|
|
|
2023-10-26 19:51:20 +02:00
|
|
|
;********************************************************************************
|
|
|
|
; Interrupts
|
|
|
|
;********************************************************************************
|
2023-11-11 12:13:47 +01:00
|
|
|
.code
|
2023-10-26 19:51:20 +02:00
|
|
|
nmi:
|
2023-10-27 16:50:58 +02:00
|
|
|
lda #'%'
|
2023-11-01 13:13:23 +01:00
|
|
|
jsr lcd_char
|
2023-10-26 19:51:20 +02:00
|
|
|
rti
|
|
|
|
irq:
|
2023-11-09 12:10:00 +01:00
|
|
|
IRQ_VAR = 0
|
2023-10-30 22:17:19 +01:00
|
|
|
; read IRFs, while bit 7 ist set handle interrupts
|
|
|
|
@irq_io1:
|
2023-11-09 12:10:00 +01:00
|
|
|
lda SPI_IO+IO::IFR
|
|
|
|
sta IRQ_VAR
|
|
|
|
bbr7 IRQ_VAR,@irq_io2
|
|
|
|
bbs2 IRQ_VAR,@irq_spi_p ; check SR
|
2023-10-30 22:17:19 +01:00
|
|
|
@irq_io2:
|
2023-11-09 12:10:00 +01:00
|
|
|
; lda IO2+IO::IFR
|
|
|
|
; sta IRQ_VAR
|
|
|
|
; bbr7 IRQ_VAR,@irq_return
|
|
|
|
; bbs4 IRQ_VAR,@irq_keypad ; check CB1
|
2023-10-30 22:17:19 +01:00
|
|
|
; this should never be reached
|
2023-11-09 12:10:00 +01:00
|
|
|
jsr lcd_clear
|
2023-10-30 22:17:19 +01:00
|
|
|
Print str_irq_unknown
|
|
|
|
; force reset interrupt flags
|
|
|
|
lda #$ff
|
2023-11-01 13:13:23 +01:00
|
|
|
sta IO1 + IO::IFR
|
|
|
|
sta IO2 + IO::IFR
|
2023-10-30 22:17:19 +01:00
|
|
|
bra @irq_return
|
|
|
|
@irq_keypad:
|
|
|
|
jsr kp_read_on_irq
|
2023-11-01 13:13:23 +01:00
|
|
|
bra @irq_return
|
2023-10-30 22:17:19 +01:00
|
|
|
@irq_spi_p:
|
|
|
|
jsr spi_p_read
|
2023-11-01 13:13:23 +01:00
|
|
|
bra @irq_return
|
2023-10-30 22:17:19 +01:00
|
|
|
@irq_dht:
|
2023-11-01 13:13:23 +01:00
|
|
|
lda IO1 + IO::T1CL ;T1L2 ; clear interrupt flag
|
|
|
|
bra @irq_return
|
2023-10-30 22:17:19 +01:00
|
|
|
@irq_return:
|
2023-10-26 19:51:20 +02:00
|
|
|
rti
|
|
|
|
|
|
|
|
;********************************************************************************
|
|
|
|
; Reset sequence
|
|
|
|
;********************************************************************************
|
|
|
|
reset:
|
|
|
|
jsr lcd_init
|
|
|
|
|
2023-11-09 12:10:00 +01:00
|
|
|
; jsr kp_init
|
2023-10-30 22:17:19 +01:00
|
|
|
|
2023-11-01 13:13:23 +01:00
|
|
|
jsr spi_p_init
|
|
|
|
|
2023-10-30 22:17:19 +01:00
|
|
|
lda #$ff
|
2023-11-01 13:13:23 +01:00
|
|
|
sta IO1 + IO::DDRA
|
|
|
|
DEBUG_LED_OFF 0
|
|
|
|
DEBUG_LED_OFF 1
|
2023-10-26 19:51:20 +02:00
|
|
|
|
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
|
2023-10-28 03:48:27 +02:00
|
|
|
Print message_menu
|
2023-10-26 19:51:20 +02:00
|
|
|
.endproc
|
|
|
|
|
|
|
|
.proc home
|
2023-11-09 12:10:00 +01:00
|
|
|
jsr rb_keypad_read
|
2023-10-26 19:51:20 +02:00
|
|
|
beq home
|
2023-10-30 22:17:19 +01:00
|
|
|
; beq home
|
2023-10-26 19:51:20 +02:00
|
|
|
cmp #'A'
|
|
|
|
jeq printer
|
|
|
|
cmp #'B'
|
2023-11-09 12:10:00 +01:00
|
|
|
jeq SPI_CODE_START
|
2023-10-27 16:50:58 +02:00
|
|
|
; jeq dht_request
|
2023-10-26 19:51:20 +02:00
|
|
|
cmp #'C'
|
2023-10-28 03:48:27 +02:00
|
|
|
jeq print_1
|
2023-10-26 19:51:20 +02:00
|
|
|
cmp #'D'
|
2023-10-28 03:48:27 +02:00
|
|
|
jeq print_2
|
2023-10-26 19:51:20 +02:00
|
|
|
|
|
|
|
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
|
2023-10-30 22:17:19 +01:00
|
|
|
jeq return_home
|
2023-10-26 19:51:20 +02:00
|
|
|
|
2023-10-30 22:17:19 +01:00
|
|
|
jmp home
|
2023-10-26 19:51:20 +02:00
|
|
|
.endproc
|
|
|
|
|
2023-11-09 12:10:00 +01:00
|
|
|
|
2023-10-26 19:51:20 +02:00
|
|
|
print_1:
|
2023-11-09 12:10:00 +01:00
|
|
|
jsr lcd_clear
|
|
|
|
PrintSlow message_1,10
|
2023-10-26 19:51:20 +02:00
|
|
|
jmp home
|
|
|
|
|
|
|
|
print_2:
|
2023-11-09 12:10:00 +01:00
|
|
|
jsr lcd_clear
|
|
|
|
PrintSlow message_2,10
|
2023-10-26 19:51:20 +02:00
|
|
|
jmp home
|
|
|
|
|
2023-11-11 12:13:47 +01:00
|
|
|
.rodata
|
2023-10-26 19:51:20 +02:00
|
|
|
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
|
2023-10-30 22:17:19 +01:00
|
|
|
message_2:
|
2023-11-11 12:13:47 +01:00
|
|
|
.byte " Hello "
|
|
|
|
.byte " there "
|
2023-10-30 22:17:19 +01:00
|
|
|
.byte " <3 "
|
|
|
|
.asciiz "================"
|
2023-10-28 03:48:27 +02:00
|
|
|
message_menu:
|
2023-10-26 19:51:20 +02:00
|
|
|
.byte "<A> Printer "
|
2023-11-09 12:10:00 +01:00
|
|
|
; .byte "<B> Temperatur "
|
|
|
|
.byte "<B> Run from SPI"
|
2023-10-26 19:51:20 +02:00
|
|
|
.byte "<C> Text 1 "
|
|
|
|
.asciiz "<D> Text 2 "
|
2023-10-30 22:17:19 +01:00
|
|
|
str_irq:
|
|
|
|
.asciiz "IRQ detected! "
|
|
|
|
str_irq_unknown:
|
|
|
|
.asciiz "Unknown IRQ src!"
|
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
|