add spi menu
This commit is contained in:
parent
6f11898806
commit
e1a8f96ac9
92
programs/spi-menu.s65
Normal file
92
programs/spi-menu.s65
Normal file
@ -0,0 +1,92 @@
|
||||
.include "system/spi.s65"
|
||||
.include "util/string.s65"
|
||||
.ifndef INCLUDE_SPI_MENU
|
||||
INCLUDE_SPI_MENU = 1
|
||||
|
||||
.scope 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_CMD_SET_ADDRESS | LCD_LINE4)
|
||||
jsr _lcd_cmd
|
||||
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
|
||||
@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::SPI_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---"
|
||||
|
||||
.endscope
|
||||
.endif ; guard
|
Loading…
Reference in New Issue
Block a user