summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-03 23:23:10 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-03 23:23:10 +0000
commit9e66e972c1980a192a948b3a1a9b71b787594b32 (patch)
treec309e0e44a508d72c02cdeb5fdfc884479ae34df
parentfirst working uart (diff)
added command code translation
git-svn-id: https://svn.spreadspace.org/pic/trunk@28 a09c6847-51d9-44de-8ef2-e725cf50f3c7
-rw-r--r--bootloader/bootloader.asm68
1 files changed, 59 insertions, 9 deletions
diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm
index e9ba646..a1b858e 100644
--- a/bootloader/bootloader.asm
+++ b/bootloader/bootloader.asm
@@ -34,6 +34,7 @@ USERVECT EQU H'100'
ISRVECT EQU USERVECT + H'4'
FSS EQU 8
+ ;; ERROR codes
E_OK EQU 0
E_INV_CMD EQU 1
E_BAD_CSUM EQU 2
@@ -42,17 +43,35 @@ E_FLASH_WERR EQU 4
E_ADDR_INVALID EQU 5
E_ADDR_PROHIB EQU 6
-CMD_IDENTIFY EQU 'i'
-CMD_BOOT EQU 'b'
-CMD_RESET EQU 'r'
-CMD_R_FLASH EQU 'f'
-CMD_W_FLASH EQU 'F'
-CMD_R_EEPROM EQU 'e'
-CMD_W_EEPROM EQU 'E'
-CMD_R_CONFIG EQU 'c'
-CMD_W_CONFIG EQU 'C'
+ ;; CMD codes
+CCMD_IDENTIFY EQU 'i'
+CMD_IDENTIFY EQU 0
+CCMD_BOOT EQU 'b'
+CMD_BOOT EQU 1
+CCMD_RESET EQU 'r'
+CMD_RESET EQU 2
+
+CCMD_R_FLASH EQU 'f'
+CMD_R_FLASH EQU 3
+
+CCMD_W_FLASH EQU 'F'
+CMD_W_FLASH EQU 4
+
+CCMD_R_EEPROM EQU 'e'
+CMD_R_EEPROM EQU 5
+
+CCMD_W_EEPROM EQU 'E'
+CMD_W_EEPROM EQU 6
+
+CCMD_R_CONFIG EQU 'c'
+CMD_R_CONFIG EQU 7
+
+CCMD_W_CONFIG EQU 'C'
+CMD_W_CONFIG EQU 8
+
+ ;; ...
CNT1 EQU H'0020'
CNT2 EQU H'0021'
@@ -77,6 +96,36 @@ uart_tx_byte
movwf TXREG
return
+translate_cmd_codes
+ xorlw CCMD_IDENTIFY
+ btfsc STATUS,Z
+ retlw CMD_IDENTIFY
+ xorlw CCMD_BOOT ^ CCMD_IDENTIFY
+ btfsc STATUS,Z
+ retlw CMD_BOOT
+ xorlw CCMD_RESET ^ CCMD_BOOT
+ btfsc STATUS,Z
+ retlw CMD_RESET
+ xorlw CCMD_R_FLASH ^ CCMD_RESET
+ btfsc STATUS,Z
+ retlw CMD_R_FLASH
+ xorlw CCMD_W_FLASH ^ CCMD_R_FLASH
+ btfsc STATUS,Z
+ retlw CMD_W_FLASH
+ xorlw CCMD_R_EEPROM ^ CCMD_W_FLASH
+ btfsc STATUS,Z
+ retlw CMD_R_EEPROM
+ xorlw CCMD_W_EEPROM ^ CCMD_R_EEPROM
+ btfsc STATUS,Z
+ retlw CMD_W_EEPROM
+ xorlw CCMD_R_CONFIG ^ CCMD_W_EEPROM
+ btfsc STATUS,Z
+ retlw CMD_R_CONFIG
+ xorlw CCMD_W_CONFIG ^ CCMD_R_CONFIG
+ btfsc STATUS,Z
+ retlw CMD_W_CONFIG
+ retlw H'FF'
+
;; -------------------------------------
;; Bootloader (init)
boot
@@ -123,6 +172,7 @@ uart_rx_byte
; TODO: move to input string
;; TODO: check if command is finished and jump
;; to 'exec_cmd'
+ call translate_cmd_codes
call uart_tx_byte
goto wait_cmd
goto exec_cmd