Compare commits

..

No commits in common. "182b8a2d752fcc679e25d179e0f01d21ba001198" and "d5631307b0a8caa160d144a59acc23cb25691eb2" have entirely different histories.

4 changed files with 37 additions and 86 deletions

View File

@ -1,8 +1,6 @@
MEMORY { MEMORY {
RAM_ZP: start = $0000, size = $100, type = rw, file = "", fill = yes; RAM_ZP: start = $0000, size = $100, type = rw, file = "", fill = yes;
# RAM: start = $0100, size = $5eff, type = rw, file = "", fill = yes; RAM: start = $0100, size = $5eff, type = rw, file = "", fill = yes;
RAM: start = $0100, size = $4eff, type = rw, file = "", fill = yes;
SPI: start = $5000, size = $1000, type = rw, file = "spi.bin", fill = no;
VIA1: start = $6000, size = $600f, type = rw, file = "", fill = yes; VIA1: start = $6000, size = $600f, type = rw, file = "", fill = yes;
VIA2: start = $7000, size = $700f, type = rw, file = "", fill = yes; VIA2: start = $7000, size = $700f, type = rw, file = "", fill = yes;
ROM: start = $8000, size = $8000, type = ro, file = %O, fill = yes; ROM: start = $8000, size = $8000, type = ro, file = %O, fill = yes;
@ -15,5 +13,4 @@ SEGMENTS {
CODE: load = ROM, type = ro; CODE: load = ROM, type = ro;
RODATA: load = ROM, type = ro; RODATA: load = ROM, type = ro;
RESET_VECTOR: load = ROM, type = ro, start = $FFFA; RESET_VECTOR: load = ROM, type = ro, start = $FFFA;
SPI: load = SPI, type = rw;
} }

View File

@ -44,25 +44,24 @@ SPI_IO = IO2
;******************************************************************************** ;********************************************************************************
; Interrupts ; Interrupts
;******************************************************************************** ;********************************************************************************
.zeropage
IRQ_VAR: .res 1
.code .code
nmi: nmi:
lda #'%' lda #'%'
jsr lcd_char jsr lcd_char
rti rti
irq: irq:
IRQ_VAR = 0
; read IRFs, while bit 7 ist set handle interrupts ; read IRFs, while bit 7 ist set handle interrupts
; @irq_io1: @irq_io1:
; lda SPI_IO+IO::IFR lda SPI_IO+IO::IFR
; sta IRQ_VAR
; bbr7 IRQ_VAR,@irq_io2
@irq_io2:
lda IO2+IO::IFR
sta IRQ_VAR sta IRQ_VAR
bbr7 IRQ_VAR,@irq_return bbr7 IRQ_VAR,@irq_io2
bbs1 IRQ_VAR,@irq_keypad ; check CB1
bbs2 IRQ_VAR,@irq_spi_p ; check SR bbs2 IRQ_VAR,@irq_spi_p ; check SR
@irq_io2:
; lda IO2+IO::IFR
; sta IRQ_VAR
; bbr7 IRQ_VAR,@irq_return
; bbs4 IRQ_VAR,@irq_keypad ; check CB1
; this should never be reached ; this should never be reached
jsr lcd_clear jsr lcd_clear
Print str_irq_unknown Print str_irq_unknown
@ -77,9 +76,9 @@ irq:
@irq_spi_p: @irq_spi_p:
jsr spi_p_read jsr spi_p_read
bra @irq_return bra @irq_return
; @irq_dht: @irq_dht:
; lda IO1 + IO::T1CL ;T1L2 ; clear interrupt flag lda IO1 + IO::T1CL ;T1L2 ; clear interrupt flag
; bra @irq_return bra @irq_return
@irq_return: @irq_return:
rti rti
@ -89,16 +88,15 @@ irq:
reset: reset:
jsr lcd_init jsr lcd_init
; jsr kp_init
jsr spi_p_init
lda #$ff lda #$ff
sta IO1 + IO::DDRA sta IO1 + IO::DDRA
DEBUG_LED_OFF 0 DEBUG_LED_OFF 0
DEBUG_LED_OFF 1 DEBUG_LED_OFF 1
jsr kp_init
jsr spi_p_init
; ; INIT DHT ; ; INIT DHT
; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2 ; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
; sta IER2 ; sta IER2
@ -130,26 +128,7 @@ reset:
jeq print_1 jeq print_1
cmp #'D' cmp #'D'
jeq print_2 jeq print_2
cmp #'0'
bne @l1
DEBUG_LED_OFF 0
jmp home
@l1:
cmp #'#'
bne @l2
DEBUG_LED_ON 0
jmp home
@l2:
cmp #'8'
bne @l3
DEBUG_LED_OFF 1
jmp home
@l3:
cmp #'9'
bne @l4
DEBUG_LED_ON 1
jmp home
@l4:
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home) cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
jeq return_home jeq return_home
@ -168,11 +147,7 @@ print_2:
jmp home jmp home
.rodata .rodata
message_1: message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
.byte " Powered by "
.byte "......6502......"
.byte " **** "
.asciiz "www.quintern.xyz"
message_2: message_2:
.byte " Hello " .byte " Hello "
.byte " there " .byte " there "

View File

@ -4,7 +4,7 @@
; @device 4x4 Matrix Keypad ; @device 4x4 Matrix Keypad
; @details ; @details
; The LCD must be connected to a W65C22N Interface Chip: ; The LCD must be connected to a W65C22N Interface Chip:
; - IO.RA0-7 -> ; - IO.RB0-7 ->
; @requires KP_IO: Base Address of IO Chip ; @requires KP_IO: Base Address of IO Chip
; @depends IO-W65C22N ; @depends IO-W65C22N
;******************************************************************************** ;********************************************************************************
@ -30,23 +30,22 @@ RBUF_MEM_END = RBUF_MEM_START + KP_BUF_SIZE - 1
.proc kp_init .proc kp_init
; todo remove later and test ; todo remove later and test
lda #$ff lda #$ff
sta KP_IO+IO::DDRA sta KP_IO+IO::DDRB
stz KP_IO+IO::RA stz KP_IO+IO::RB
; INIT KEYPAD ; INIT KEYPAD
; todo: use masks ; todo: use masks
lda #%11110000; KP_IO+IO::RA 0-3 output lda #%00001111; KP_IO+IO::RB 0-3 output
sta KP_IO+IO::DDRA sta KP_IO+IO::DDRB
; output 0, key press will pull input pin low stz KP_IO+IO::RB ; KP_IO+IO::RB 4-7 1 so keypad press can be detected
stz KP_IO+IO::RA
stz KP_IO+IO::ACR stz KP_IO+IO::ACR
; lda #%00010000 ; set CA1 to interrupt on pos. edge ; lda #%00010000 ; set CB1 to interrupt on pos. edge
; todo: use masks ; todo: use masks
lda #IO::PCR::CA1_IP_AE lda #IO::PCR::CB1_IP_AE
sta KP_IO+IO::PCR sta KP_IO+IO::PCR
jsr rb_keypad_init ; init keybuffer jsr rb_keypad_init ; init keybuffer
lda #(IO::IRQ::IRQ | IO::IRQ::CA1) ; enable interrupt for CA1 on KP_IO lda #(IO::IRQ::IRQ | IO::IRQ::CB1) ; enable interrupt for CB1 on KP_IO
sta KP_IO+IO::IER sta KP_IO+IO::IER
rts rts
.endproc .endproc
@ -61,24 +60,23 @@ RBUF_MEM_END = RBUF_MEM_START + KP_BUF_SIZE - 1
.proc kp_read_on_irq .proc kp_read_on_irq
; test each "row" and check which column is 1 ; test each "row" and check which column is 1
; todo dont check every column if the value has been found ; todo dont check every column if the value has been found
lda #%11100000 lda #%00001110
ldx #$00 ldx #$00
jsr @kp_read_column jsr @kp_read_column
lda #%11010000 lda #%00001101
ldx #$08 ldx #$08
jsr @kp_read_column jsr @kp_read_column
lda #%10110000 lda #%00001011
ldx #$04 ldx #$04
jsr @kp_read_column jsr @kp_read_column
lda #%01110000 lda #%00000111
ldx #$0c ldx #$0c
jsr @kp_read_column jsr @kp_read_column
stz KP_IO+IO::RA stz KP_IO+IO::RB ; todo why all zero?
lda KP_IO+IO::RA ; todo: verify that this is necessary so that rows 1-3 dont refire immediately after they are armed again because of stz
rts rts
@kp_read_column: @kp_read_column:
sta KP_IO+IO::RA sta KP_IO+IO::RB
lda KP_IO+IO::RA lda KP_IO+IO::RB
sta _KP_COLUMN ; store result in zeropage so that bbr can be used sta _KP_COLUMN ; store result in zeropage so that bbr can be used
bbr4 _KP_COLUMN,@kp_write bbr4 _KP_COLUMN,@kp_write
inx inx

View File

@ -6,7 +6,6 @@
;******************************************************************************** ;********************************************************************************
.include "system/system.s65" .include "system/system.s65"
.include "programs/print_slow.s65"
.ifndef INCLUDE_SPI .ifndef INCLUDE_SPI
INCLUDE_SPI = 1 INCLUDE_SPI = 1
@ -15,24 +14,7 @@ INCLUDE_SPI = 1
.bss .bss
SPI_PAGES_WRITTEN: .res 1 SPI_PAGES_WRITTEN: .res 1
SPI_BYTES_WRITTEN: .res 1 SPI_BYTES_WRITTEN: .res 1
.segment "SPI" SPI_CODE_START: .res $1000
SPI_CODE_START: ; .res $1000
lda $1000
sta $1000
lda $1000
sta $1000
lda $1000
sta $1000
lda IO1 + IO::RA
lda IO1 + IO::RA
bra SPI_CODE_START
; jsr lcd_clear
; PrintSlow msg,20
; jmp home
; msg:
; .asciiz "YO DAS WAR SPI"
.code .code
.struct SPI_P_Pins .struct SPI_P_Pins
@ -72,9 +54,8 @@ SPI_CODE_START: ; .res $1000
DEBUG_LED_ON 0 DEBUG_LED_ON 0
; print received byte ; print received byte
lda SPI_IO + IO::SR lda SPI_IO + IO::SR
sta SPI_CODE_START,x
inc SPI_BYTES_WRITTEN
jsr lcd_char jsr lcd_char
inc SPI_BYTES_WRITTEN
rts rts
.endproc .endproc