107 lines
2.0 KiB
Plaintext
107 lines
2.0 KiB
Plaintext
.include "spi.h65"
|
|
.include "string.h65"
|
|
.include "keypad.h65"
|
|
.include "lcd.h65"
|
|
.include "chars.h65"
|
|
.import home:absolute
|
|
.import CODE_START: absolute
|
|
.import __SPI_SIZE__
|
|
|
|
.export spi_menu
|
|
.bss
|
|
trans_bytes: .res 2 ; used to check if screen needs to be updated
|
|
status_char: .res 1
|
|
status_str: .res 17 ; 16 + null
|
|
|
|
.code
|
|
.proc spi_menu
|
|
stz trans_bytes
|
|
stz trans_bytes+1
|
|
@print_menu:
|
|
jsr lcd::clear
|
|
Print MENU
|
|
|
|
@update_status:
|
|
lda spi_p::status
|
|
cmp #spi_p::STATUS::ERROR
|
|
beq @status_ERROR
|
|
cmp #spi_p::STATUS::DONE
|
|
beq @status_DONE
|
|
bra @status_XFER
|
|
@status_ERROR:
|
|
lda #'E'
|
|
bra @update_status_end
|
|
@status_DONE:
|
|
lda #'O'
|
|
bra @update_status_end
|
|
@status_XFER:
|
|
lda #'X'
|
|
@update_status_end:
|
|
sta status_char
|
|
|
|
@print_status:
|
|
lda #lcd::LINE4
|
|
jsr lcd::set_position
|
|
Strf "%x%xb Status: %c",status_str,trans_bytes+1,trans_bytes,status_char
|
|
PrintNC status_str
|
|
@loop:
|
|
; check if a byte has been transferred
|
|
@check_received:
|
|
lda spi_p::recv_bytes
|
|
cmp trans_bytes
|
|
beq @read_keypad
|
|
@byte_received:
|
|
sta trans_bytes
|
|
lda spi_p::recv_bytes+1
|
|
lda trans_bytes+1
|
|
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 @update_status ; any other key
|
|
@spi_begin:
|
|
lda #<CODE_START
|
|
sta ARG0
|
|
lda #>CODE_START
|
|
sta ARG1
|
|
lda #<__SPI_SIZE__
|
|
sta ARG2
|
|
lda #>__SPI_SIZE__
|
|
sta ARG3
|
|
jsr spi_p::begin_read
|
|
jmp @print_menu
|
|
@spi_end:
|
|
jsr spi_p::end
|
|
jmp @print_menu
|
|
@spi_jump:
|
|
jsr spi_p::end
|
|
jsr lcd::clear
|
|
Print START
|
|
jmp 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---"
|