start spi work
This commit is contained in:
parent
e0ba885132
commit
ae17478c14
67
main.s65
67
main.s65
@ -27,15 +27,16 @@
|
||||
; LCD
|
||||
; .include "utility.asm6502"
|
||||
LCD_IO = IO1
|
||||
.include "lcd.s65"
|
||||
.include "system/lcd.s65"
|
||||
; Keypad Reading
|
||||
KP_IO = IO2
|
||||
.include "keypad.s65"
|
||||
.include "system/keypad.s65"
|
||||
; SPI
|
||||
SPI_IO = IO1
|
||||
SPI_IO = IO2
|
||||
.include "system/spi.s65"
|
||||
; Printer
|
||||
.include "printer.s65"
|
||||
.include "programs/printer.s65"
|
||||
.include "programs/print_slow.s65"
|
||||
; Digital Humidity and Temerature Sensor
|
||||
; .include "dht.s65"
|
||||
|
||||
@ -48,20 +49,20 @@ nmi:
|
||||
jsr lcd_char
|
||||
rti
|
||||
irq:
|
||||
IRQ_VAR = 0
|
||||
; read IRFs, while bit 7 ist set handle interrupts
|
||||
; Print str_irq
|
||||
@irq_io1:
|
||||
; todo use a reserved address instead of 0
|
||||
lda IO1+IO::IFR
|
||||
sta 0
|
||||
bbr7 0,@irq_io2
|
||||
bbs2 0,@irq_spi_p ; check SR
|
||||
lda SPI_IO+IO::IFR
|
||||
sta IRQ_VAR
|
||||
bbr7 IRQ_VAR,@irq_io2
|
||||
bbs2 IRQ_VAR,@irq_spi_p ; check SR
|
||||
@irq_io2:
|
||||
lda IO2+IO::IFR
|
||||
sta 0
|
||||
bbr7 0,@irq_return
|
||||
bbs4 0,@irq_keypad ; check CB1
|
||||
; lda IO2+IO::IFR
|
||||
; sta IRQ_VAR
|
||||
; bbr7 IRQ_VAR,@irq_return
|
||||
; bbs4 IRQ_VAR,@irq_keypad ; check CB1
|
||||
; this should never be reached
|
||||
jsr lcd_clear
|
||||
Print str_irq_unknown
|
||||
; force reset interrupt flags
|
||||
lda #$ff
|
||||
@ -86,7 +87,7 @@ irq:
|
||||
reset:
|
||||
jsr lcd_init
|
||||
|
||||
jsr kp_init
|
||||
; jsr kp_init
|
||||
|
||||
jsr spi_p_init
|
||||
|
||||
@ -114,53 +115,34 @@ reset:
|
||||
.endproc
|
||||
|
||||
.proc home
|
||||
.macro wait
|
||||
wait:
|
||||
stz 1
|
||||
stz 2
|
||||
.repeat 2
|
||||
nop
|
||||
.endrepeat
|
||||
inc 1
|
||||
bne wait
|
||||
inc 2
|
||||
bne wait
|
||||
.endmacro
|
||||
|
||||
; jsr rb_keypad_read
|
||||
lda KB_LAST
|
||||
jsr rb_keypad_read
|
||||
beq home
|
||||
stz KB_LAST
|
||||
; beq home
|
||||
cmp #'A'
|
||||
jeq printer
|
||||
cmp #'B'
|
||||
jeq SPI_CODE_START
|
||||
; jeq dht_request
|
||||
cmp #'C'
|
||||
jeq print_1
|
||||
cmp #'D'
|
||||
jeq print_2
|
||||
cmp '4'
|
||||
bra debug
|
||||
|
||||
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
|
||||
jeq return_home
|
||||
|
||||
jmp home
|
||||
|
||||
debug:
|
||||
DEBUG_LED_ON 0
|
||||
jmp home
|
||||
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
print_1:
|
||||
Print message_1
|
||||
jsr lcd_clear
|
||||
PrintSlow message_1,10
|
||||
jmp home
|
||||
|
||||
print_2:
|
||||
Print message_2
|
||||
jsr lcd_clear
|
||||
PrintSlow message_2,10
|
||||
jmp home
|
||||
|
||||
.segment "RODATA"
|
||||
@ -172,7 +154,8 @@ message_2:
|
||||
.asciiz "================"
|
||||
message_menu:
|
||||
.byte "<A> Printer "
|
||||
.byte "<B> Temperatur "
|
||||
; .byte "<B> Temperatur "
|
||||
.byte "<B> Run from SPI"
|
||||
.byte "<C> Text 1 "
|
||||
.asciiz "<D> Text 2 "
|
||||
str_irq:
|
||||
|
@ -9,10 +9,14 @@
|
||||
|
||||
.ifndef INCLUDE_SPI
|
||||
INCLUDE_SPI = 1
|
||||
.segment "CODE"
|
||||
.segment "CODE"
|
||||
|
||||
SPI_CODE_START = $3000
|
||||
SPI_PAGES_WRITTEN = $2fff
|
||||
SPI_BYTES_WRITTEN = $2ffe
|
||||
|
||||
|
||||
.struct SPI_P_Pins
|
||||
.struct SPI_P_Pins
|
||||
; VIA addresses
|
||||
DDR_a .word ; address of the data direction register
|
||||
R_a .word ; address of the register
|
||||
@ -24,13 +28,15 @@ INCLUDE_SPI = 1
|
||||
; settings
|
||||
CPOL .byte ; Clock Polarity
|
||||
CPHA .byte ; Clock Phase
|
||||
.endstruct
|
||||
.endstruct
|
||||
|
||||
;********************************************************************************
|
||||
; @function Initialize the IO Adapter for SPI
|
||||
; @param ARG0-1 Address of the SPI_Pins struct
|
||||
;********************************************************************************
|
||||
.proc spi_p_init
|
||||
stz SPI_PAGES_WRITTEN
|
||||
stz SPI_BYTES_WRITTEN
|
||||
; todo USE MASKS
|
||||
; set Shift register to shift in under external clock on CB1
|
||||
lda #IO::ACR::SR_SIN_PHIE
|
||||
@ -39,13 +45,16 @@ INCLUDE_SPI = 1
|
||||
; enable SR interrupts
|
||||
lda #(IO::IRQ::IRQ | IO::IRQ::SR)
|
||||
sta SPI_IO + IO::IER
|
||||
DEBUG_LED_ON 1
|
||||
rts
|
||||
.endproc
|
||||
|
||||
.proc spi_p_read
|
||||
DEBUG_LED_ON 0
|
||||
; print received byte
|
||||
lda SPI_IO + IO::SR
|
||||
jsr lcd_char
|
||||
inc SPI_BYTES_WRITTEN
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user