92 lines
1.7 KiB
Plaintext
92 lines
1.7 KiB
Plaintext
.include "spi.h65"
|
|
.include "string.h65"
|
|
.include "keypad.h65"
|
|
.include "lcd.h65"
|
|
.import home:absolute
|
|
.import SPI_IO
|
|
|
|
.export spi_menu
|
|
.bss
|
|
trans_bytes: .res 1
|
|
trans_pages: .res 1
|
|
status: .res 1
|
|
status_str: .res 17 ; 16 + null
|
|
|
|
.code
|
|
.proc spi_menu
|
|
stz trans_bytes
|
|
stz trans_pages
|
|
lda #'X'
|
|
sta status
|
|
@print_menu:
|
|
jsr lcd::clear
|
|
Print MENU
|
|
@print_status:
|
|
Strf FMT_STATUS,status_str,trans_pages,trans_bytes,status
|
|
lda #lcd::LINE4
|
|
jsr lcd::set_position
|
|
Print status_str
|
|
@loop:
|
|
; check if a byte has been transferred
|
|
@check_byte:
|
|
lda spi_p::bytes_written
|
|
cmp trans_bytes
|
|
bne @byte_written
|
|
@check_page:
|
|
lda spi_p::pages_written
|
|
cmp trans_pages
|
|
bne @page_written
|
|
bra @read_keypad
|
|
@byte_written:
|
|
sta trans_bytes
|
|
; bra @print_status
|
|
bra @read_keypad
|
|
@page_written:
|
|
sta trans_pages
|
|
bra @print_status
|
|
@read_keypad:
|
|
lda kp::_DEBUG_VAL
|
|
beq @loop
|
|
; TODO debug
|
|
sta 0
|
|
stz kp::_DEBUG_VAL
|
|
lda 0
|
|
cmp #'*'
|
|
beq @return_home
|
|
cmp #'A'
|
|
beq @spi_begin
|
|
cmp #'B'
|
|
beq @spi_end
|
|
cmp #'C'
|
|
beq @spi_jump
|
|
bra @loop
|
|
@spi_begin:
|
|
lda #'@'
|
|
sta status
|
|
jsr spi_p::begin
|
|
jmp @print_menu
|
|
@spi_end:
|
|
lda #'X'
|
|
sta status
|
|
jsr spi_p::end
|
|
jmp @print_menu
|
|
@spi_jump:
|
|
jsr spi_p::end
|
|
jsr lcd::clear
|
|
Print START
|
|
jmp spi_p::CODE_START
|
|
@return_home:
|
|
jsr spi_p::end
|
|
jmp home
|
|
.endproc
|
|
|
|
.rodata
|
|
MENU:
|
|
.byte "A> Beg. Transfer"
|
|
.byte "B> Stop Transfer"
|
|
.asciiz "C> Jump Home <*"
|
|
; .asciiz "0b0p Status: X"
|
|
FMT_STATUS: .asciiz "%x%xb Status:%x"
|
|
BEGIN: .asciiz "---BEGIN SPI---"
|
|
START: .asciiz "---START SPI---"
|