.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 cmp #spi_p::STATUS::XFER beq @status_XFER cmp #spi_p::STATUS::XFER_SIZEL beq @status_XFER_SIZEL cmp #spi_p::STATUS::XFER_SIZEH beq @status_XFER_SIZEH @status_UNKNOWN: lda #'?' bra @update_status_end @status_ERROR: lda #'E' bra @update_status_end @status_DONE: lda #'O' bra @update_status_end @status_XFER_SIZEL: lda #'1' bra @update_status_end @status_XFER_SIZEH: lda #'2' 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%x/%x%x|%x%x|%c",status_str,trans_bytes+1,trans_bytes,spi_p::recv_size+1,spi_p::recv_size,spi_p::buffer_size+1,spi_p::buffer_size,status_char PrintNC status_str @loop: wai ; 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 sta trans_bytes+1 jmp @update_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 cmp #'D' beq @spi_jump2 jmp @update_status ; any other key @spi_begin: 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_read jmp @print_menu @spi_jump: jsr spi_p::end_read jsr lcd::clear Print "---START SPI---" jmp CODE_START @spi_jump2: jsr spi_p::end_read jsr lcd::clear Printf " >>> %x%x >>> ", spi_p::buffer_ptr+1, spi_p::buffer_ptr jmp (spi_p::buffer_ptr) @return_home: jsr spi_p::end_read jmp home .endproc .rodata MENU: .byte "A> Beg. Transfer" .byte "B> Stop Transfer" .asciiz "C> Jump Home <*" ; .asciiz "0b0p Status: X" BEGIN: .asciiz "---BEGIN SPI---" START: .asciiz "---START SPI---"