2023-12-08 22:56:35 +01:00
|
|
|
.include "spi.h65"
|
|
|
|
.include "string.h65"
|
|
|
|
.include "keypad.h65"
|
|
|
|
.include "lcd.h65"
|
2023-12-16 02:41:19 +01:00
|
|
|
.include "chars.h65"
|
2023-12-08 22:56:35 +01:00
|
|
|
.import home:absolute
|
2023-12-27 16:56:14 +01:00
|
|
|
.import CODE_START: absolute
|
|
|
|
.import __SPI_SIZE__
|
2023-12-08 00:13:02 +01:00
|
|
|
|
2023-12-08 22:56:35 +01:00
|
|
|
.export spi_menu
|
2023-12-08 00:13:02 +01:00
|
|
|
.bss
|
2023-12-27 16:56:14 +01:00
|
|
|
trans_bytes: .res 2 ; used to check if screen needs to be updated
|
|
|
|
status_char: .res 1
|
2023-12-08 00:13:02 +01:00
|
|
|
status_str: .res 17 ; 16 + null
|
|
|
|
|
|
|
|
.code
|
|
|
|
.proc spi_menu
|
|
|
|
stz trans_bytes
|
2023-12-27 16:56:14 +01:00
|
|
|
stz trans_bytes+1
|
2023-12-08 00:13:02 +01:00
|
|
|
@print_menu:
|
2023-12-08 22:56:35 +01:00
|
|
|
jsr lcd::clear
|
2023-12-08 00:13:02 +01:00
|
|
|
Print MENU
|
2023-12-27 16:56:14 +01:00
|
|
|
|
|
|
|
@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
|
|
|
|
|
2023-12-08 00:13:02 +01:00
|
|
|
@print_status:
|
2023-12-09 23:32:43 +01:00
|
|
|
lda #lcd::LINE4
|
|
|
|
jsr lcd::set_position
|
2023-12-27 16:56:14 +01:00
|
|
|
Strf "%x%xb Status: %c",status_str,trans_bytes+1,trans_bytes,status_char
|
2023-12-16 02:41:19 +01:00
|
|
|
PrintNC status_str
|
2023-12-08 00:13:02 +01:00
|
|
|
@loop:
|
|
|
|
; check if a byte has been transferred
|
2023-12-27 16:56:14 +01:00
|
|
|
@check_received:
|
|
|
|
lda spi_p::recv_bytes
|
2023-12-08 00:13:02 +01:00
|
|
|
cmp trans_bytes
|
2023-12-22 02:17:36 +01:00
|
|
|
beq @read_keypad
|
2023-12-27 16:56:14 +01:00
|
|
|
@byte_received:
|
2023-12-22 02:17:36 +01:00
|
|
|
sta trans_bytes
|
2023-12-27 16:56:14 +01:00
|
|
|
lda spi_p::recv_bytes+1
|
|
|
|
lda trans_bytes+1
|
2023-12-08 00:13:02 +01:00
|
|
|
bra @print_status
|
|
|
|
@read_keypad:
|
2023-12-08 22:56:35 +01:00
|
|
|
lda kp::_DEBUG_VAL
|
2023-12-08 00:13:02 +01:00
|
|
|
beq @loop
|
|
|
|
; TODO debug
|
|
|
|
sta 0
|
2023-12-08 22:56:35 +01:00
|
|
|
stz kp::_DEBUG_VAL
|
2023-12-08 00:13:02 +01:00
|
|
|
lda 0
|
|
|
|
cmp #'*'
|
|
|
|
beq @return_home
|
|
|
|
cmp #'A'
|
|
|
|
beq @spi_begin
|
|
|
|
cmp #'B'
|
|
|
|
beq @spi_end
|
|
|
|
cmp #'C'
|
|
|
|
beq @spi_jump
|
2023-12-27 16:56:14 +01:00
|
|
|
bra @update_status ; any other key
|
2023-12-08 00:13:02 +01:00
|
|
|
@spi_begin:
|
2023-12-27 16:56:14 +01:00
|
|
|
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
|
2023-12-08 00:13:02 +01:00
|
|
|
jmp @print_menu
|
|
|
|
@spi_end:
|
|
|
|
jsr spi_p::end
|
|
|
|
jmp @print_menu
|
|
|
|
@spi_jump:
|
|
|
|
jsr spi_p::end
|
2023-12-08 22:56:35 +01:00
|
|
|
jsr lcd::clear
|
2023-12-08 00:13:02 +01:00
|
|
|
Print START
|
2023-12-27 16:56:14 +01:00
|
|
|
jmp CODE_START
|
2023-12-08 00:13:02 +01:00
|
|
|
@return_home:
|
|
|
|
jsr spi_p::end
|
|
|
|
jmp home
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
.rodata
|
|
|
|
MENU:
|
2023-12-20 12:27:54 +01:00
|
|
|
.byte "A> Beg. Transfer"
|
2023-12-08 00:13:02 +01:00
|
|
|
.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---"
|