annotate src/comm.asm @ 633:690c48db7b5b

3.09 beta 2 release
author heinrichsweikamp
date Thu, 05 Mar 2020 15:06:14 +0100
parents 185ba2f91f59
children 4050675965ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
3 ; File comm.asm combined next generation V3.08.8
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; RS232 via USB
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-22 : [mH] Creation
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
11 ; 2012-02-11 : [jDG] Added 0x63 set custom text, and "i" identify
0
heinrichsweikamp
parents:
diff changeset
12
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 273
diff changeset
13 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
14 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "wait.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "surfmode.inc"
heinrichsweikamp
parents:
diff changeset
22 #include "rtc.inc"
heinrichsweikamp
parents:
diff changeset
23 #include "adc_lightsensor.inc"
299
6c4800af27ac Make char_I_bottom_usage and char_I_deco_usage configurable from PC
heinrichsweikamp
parents: 275
diff changeset
24 #include "shared_definitions.h"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
25 #include "math.inc"
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
26 #include "i2c.inc"
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
27 #include "logbook.inc"
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
28
0
heinrichsweikamp
parents:
diff changeset
29
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
30 extern restart
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
31 extern option_reset_all
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
32 extern option_check_and_store_all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
33 extern option_read_serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
34 extern option_write_serial
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
35 extern gaslist_cleanup_list
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
36 extern eeprom_deco_data_write
0
heinrichsweikamp
parents:
diff changeset
37
heinrichsweikamp
parents:
diff changeset
38
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
39 ; timeouts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
40 #DEFINE timeout_comm_pre_mode .240 ; [sec] timeout before communication is established
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
41 #DEFINE timeout_service_mode .120 ; [sec] timeout when communication is established
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
42
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
43 ; positioning of title
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
44 #DEFINE comm_title_row .0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
45 #DEFINE comm_title_column_usb .40
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
46 #DEFINE comm_title_column_ble .25
0
heinrichsweikamp
parents:
diff changeset
47
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
48 ; positioning of host-sent text messages
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
49 #DEFINE comm_string_row .30
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
50 #DEFINE comm_string_column .40
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
51
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
52 ; positioning of COMM mode status messages
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
53 #DEFINE comm_status1_row .70
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
54 #DEFINE comm_status1_column .10
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
55 #DEFINE comm_status2_row .100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
56 #DEFINE comm_status2_column comm_status1_column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
57 #DEFINE comm_status3_row .130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
58 #DEFINE comm_status3_column comm_status1_column
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
59 #DEFINE comm_status4_row .160
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
60 #DEFINE comm_status4_column comm_status1_column
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
61
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
62 ; positioning of COMM mode warning icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
63 #DEFINE comm_warning_row .160
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
64 #DEFINE comm_warning_column .65
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
65
0
heinrichsweikamp
parents:
diff changeset
66
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
67 ;#DEFINE testloop_avail ; uncomment if testloop code is available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
68
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
69
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
70 comm CODE
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
71
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
72 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
73
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
74 global comm_mode_usb
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
75 comm_mode_usb: ; entry point for comm mode via USB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
76 WAITMS d'1' ; wait 1 ms
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
77 btfss vusb_in ; USB still plugged in?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
78 return ; NO - it was only a glitch, abort
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
79 WAITMS d'1' ; YES - wait 1 ms
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
80 btfss vusb_in ; - USB still plugged in?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
81 return ; NO - it was only a glitch, abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
82 bsf aux_flag ; YES - remember to show USB title
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
83 bra comm_mode_common ; - continue with common part
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
84
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
85 global comm_mode_ble
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
86 comm_mode_ble: ; entry point for comm mode via BLE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
87 bcf aux_flag ; remember to show BLE title
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
88 ;bra comm_mode_common ; continue with common part
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
89
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
90 comm_mode_common:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
91 clrf STKPTR ; reset addresses stack
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
92 call TFT_ClearScreen ; clear screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
93 WIN_COLOR color_greenish ; set color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
94
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
95 btfss aux_flag ; shall show USB title?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
96 bra comm_mode_common_1 ; NO - show BLE title
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
97 WIN_SMALL comm_title_column_usb, comm_title_row ; YES - set USB title position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
98 STRCPY_TEXT_PRINT tUsbTitle ; - print USB title text
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
99 bra comm_mode_common_2 ; - continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
100
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
101 comm_mode_common_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
102 WIN_SMALL comm_title_column_ble, comm_title_row ; set BLE title position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
103 STRCPY_TEXT_PRINT tBleTitle ; print BLE title text
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
104 ;bra comm_mode_common_2 ; continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
105
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
106 comm_mode_common_2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
107 call TFT_standard_color ; set standard color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
108 WIN_TOP .10 ; set position of USB/BLE logo, row
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
109 WIN_LEFT .1 ; set position of USB/BLE logo, column
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
110 btfsc battery_gauge_available ; "+" bootloader ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
111 bra comm_mode_common_3 ; NO - show logo type 1
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
112 TFT_WRITE_PROM_IMAGE_BY_ADDR usb_ble_logo_2 ; YES - show USB/BLE logo 2
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
113 bra comm_mode_common_4 ; - continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
114
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
115 comm_mode_common_3:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
116 TFT_WRITE_PROM_IMAGE_BY_ADDR usb_ble_logo_1 ; show logo type 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
117 ;bra comm_mode_common_4 ; continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
118
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
119 comm_mode_common_4:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
120 WIN_SMALL comm_status1_column,comm_status1_row ; print status message "starting..."
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
121 STRCPY_TEXT_PRINT tUsbStarting ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
122
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
123 WIN_TINY .40,.240-.16 ; set output position to bottom line
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
124 call TFT_show_serial_and_firmware ; show serial number and firmware version
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
125
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
126 IFDEF _screendump
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
127 bcf screen_dump_avail ; disable screen dump function
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
128 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
129
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
130 bcf switch_right ; clear potential left-over right button event
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
131 call enable_rs232 ; enable serial comm, also sets CPU to normal speed
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
132
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
133 WIN_SMALL comm_status1_column+.80,comm_status1_row ; print (adding to status message) "done..."
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
134 STRCPY_TEXT_PRINT tUsbStartDone ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
135
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
136 movlw timeout_comm_pre_mode ; get timeout for phase without communication established yet
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
137 movwf comm_timeout_timer ; initialize timeout counter
0
heinrichsweikamp
parents:
diff changeset
138
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
139 comm_mode_selection_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
140 bcf trigger_full_second ; clear 'one second elapsed' flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
141 bcf LEDr ; switch off red LED / power down TR co-processor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
142 dcfsnz comm_timeout_timer,F ; decrement timeout, reached zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
143 bra comm_service_exit ; YES - timeout, exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
144 ;bra comm_mode_selection_loop_1 ; NO - try to receive a byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
145 comm_mode_selection_loop_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
146 SERIAL_CC_RECEIVE lo ; (try to) receive 1 byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
147 btfsc rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
148 bra comm_mode_selection_loop_2 ; YES - check for comm mode termination
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
149 movf lo,W ; NO - copy received byte to lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
150 xorlw 0xAA ; - service mode start byte received?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
151 bz comm_service_mode_check ; YES - check if correct key will be send
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
152 movf lo,W ; NO - copy received byte to lo again
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
153 xorlw 0xBB ; - download mode start byte received?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
154 bz comm_download_mode ; YES - enter command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
155 ;bra comm_mode_selection_loop_2 ; NO - check for comm mode termination
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
156 comm_mode_selection_loop_2:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
157 btfsc ble_available ; BLE available?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
158 bra comm_mode_selection_loop_3 ; YES - skip USB check check (required for very old OSTC sport)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
159 btfss vusb_in ; NO - USB plugged in?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
160 bra comm_service_exit_nousb_delay ; NO - disconnected, check for vusb_in glitch
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
161 ;bra comm_mode_selection_loop_3 ; YES - check for exit button or continue looping
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
162 comm_mode_selection_loop_3:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
163 btfsc switch_right ; right button pressed?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
164 bra comm_service_exit ; YES - exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
165 btfsc trigger_full_second ; NO - did 1 second elapsed meanwhile?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
166 bra comm_mode_selection_loop ; YES - loop with clocking down timeout counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
167 bra comm_mode_selection_loop_1 ; NO - loop without clocking down timeout counter
0
heinrichsweikamp
parents:
diff changeset
168
heinrichsweikamp
parents:
diff changeset
169
heinrichsweikamp
parents:
diff changeset
170 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
171 ; Received start byte for service mode, await service key
0
heinrichsweikamp
parents:
diff changeset
172 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
173 comm_service_mode_check:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
174
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
175 SERIAL_LC_SEND 0x4B ; request peer to send service key
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
176
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
177 ; receive a 3 byte service key transmitted in big-endian, echo each byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
178
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
179 clrf WREG ; clear WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
180
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
181 SERIAL_CC_RECEIVE lo ; receive 1st byte, store in lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
182 xorwf lo,W ; exclusive-or received byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
183 xorlw UPPER (comm_service_key) ; exclusive-or expected byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
184 SERIAL_CC_SEND lo ; echo 1st byte
0
heinrichsweikamp
parents:
diff changeset
185
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
186 SERIAL_CC_RECEIVE lo ; receive 2nd byte, store in lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
187 xorwf lo,W ; exclusive-or received byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
188 xorlw HIGH (comm_service_key & 0xFFFF) ; exclusive-or expected byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
189 SERIAL_CC_SEND lo ; echo 2nd byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
190
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
191 SERIAL_CC_RECEIVE lo ; receive 3rd byte, store in lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
192 xorwf lo,W ; exclusive-or received byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
193 xorlw LOW (comm_service_key & 0xFFFF) ; exclusive-or expected byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
194 SERIAL_CC_SEND lo ; echo 3rd byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
195
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
196 ; check for correct service key
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
197 tstfsz WREG ; received expected service key?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
198 bra comm_mode_selection_loop ; NO - back to mode selection loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
199 WIN_SMALL comm_status2_column, comm_status2_row ; YES - print service mode enabled message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
200 STRCPY_TEXT_PRINT tUsbServiceMode ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
201 bsf comm_service_mode ; - enable service mode commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
202 bra comm_command_loop ; - enter command loop
0
heinrichsweikamp
parents:
diff changeset
203
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
204
0
heinrichsweikamp
parents:
diff changeset
205 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
206 ; Received start byte for download mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
207 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
208 comm_download_mode:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
209 SERIAL_LC_SEND 0xBB ; inform peer download mode will be started
0
heinrichsweikamp
parents:
diff changeset
210
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
211 WIN_SMALL comm_status2_column, comm_status2_row ; print download mode enabled message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
212 STRCPY_TEXT_PRINT tUsbDownloadMode ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
213 bcf comm_service_mode ; disable service mode commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
214 bra comm_command_loop ; enter command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
215
0
heinrichsweikamp
parents:
diff changeset
216
heinrichsweikamp
parents:
diff changeset
217 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
218 ; Notify RX timeout occurred
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
219 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
220 comm_command_timeout:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
221 ; select font and output position
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
222 WIN_SMALL comm_string_column, comm_string_row
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
223 call TFT_warning_color ; select color
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
224 STRCPY_PRINT "Data Rx Timeout" ; print failure message (fill to 15 chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
225 call TFT_standard_color ; back to standard color
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
226 bra comm_command_loop ; re-enter command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
227
0
heinrichsweikamp
parents:
diff changeset
228
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
229 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
230 ; Notify error in parameters
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
231 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
232 comm_command_error:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
233 ; select font and output position
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
234 WIN_SMALL comm_string_column, comm_string_row
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
235 call TFT_warning_color ; switch to waring color
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
236 STRCPY_PRINT "Parameter Error" ; print failure message (fill to 15 chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
237 call TFT_standard_color ; back to standard color
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
238 ;bra comm_command_loop ; re-enter command loop
0
heinrichsweikamp
parents:
diff changeset
239
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
240
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
241 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
242 ; Command loop: wait for a command
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
243 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
244 comm_command_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
245 ; (re-)initialize
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
246 bsf INTCON,GIE ; re-enable all interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
247 movlw timeout_service_mode ; get timeout value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
248 movwf comm_timeout_timer ; reload timeout timer
0
heinrichsweikamp
parents:
diff changeset
249
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
250 ; request peer to send a command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
251 movlw 0x4D ; default request code is 0x4D for download mode active
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
252 btfsc comm_service_mode ; service mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
253 movlw 0x4C ; YES - change request to 0x4C for service mode active
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
254 SERIAL_CC_SEND WREG ; send request
0
heinrichsweikamp
parents:
diff changeset
255
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
256 ; wait for peer to send a command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
257 comm_command_loop_wait:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
258 SERIAL_CC_RECEIVE lo ; (try to) receive a command byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
259 btfss rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
260 bra comm_command_decode ; NO - decode and execute the command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
261 btfsc comm_service_mode ; YES - service mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
262 btg LEDr ; YES - blink in service mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
263 btfsc ble_available ; - BLE available?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
264 bra comm_command_loop_wait_1 ; YES - skip USB check (required for very old OSTC sport)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
265 btfss vusb_in ; NO - USB still plugged in?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
266 bra comm_service_exit_nousb ; NO - disconnected -> exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
267 comm_command_loop_wait_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
268 btfsc switch_right ; right button (abort) pressed?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
269 bra comm_service_exit ; YES - exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
270 btfss trigger_full_second ; NO - did 1 second elapsed meanwhile?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
271 bra comm_command_loop_wait ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
272 dcfsnz comm_timeout_timer,F ; YES - decrement the timeout timer, reached zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
273 bra comm_service_exit ; YES - exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
274 bcf trigger_full_second ; NO - clear 'one second elapsed' flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
275 bra comm_command_loop_wait ; - loop
346
cf9ce6053dee New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents: 337
diff changeset
276
cf9ce6053dee New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents: 337
diff changeset
277
cf9ce6053dee New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents: 337
diff changeset
278 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
279 ; Macro for easier writing of command decoding rules
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
280 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
281 command_decode macro command_id,command_function
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
282 movf lo,W ; copy received command to WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
283 xorlw command_id ; exclusive-or with command ID
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
284 btfsc STATUS,Z ; received command = command ID ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
285 goto command_function ; YES - execute command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
286 endm
0
heinrichsweikamp
parents:
diff changeset
287
heinrichsweikamp
parents:
diff changeset
288 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
289 ; Decode and execute a command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
290 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
291 comm_command_decode:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
292 bcf LEDr ; switch off red led
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
293
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
294 ; decode and execute standard commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
295 command_decode 0x6E,comm_show_text ; n show a text on the screen
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
296 command_decode 0x69,comm_identify ; i send ID: serial, firmware, and custom text
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
297 command_decode 0x6A,comm_hardware_descriptor ; j send ID: hardware descriptor byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
298 command_decode 0x60,comm_feature_and_hardware ; ' send ID: more detailed information
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
299 command_decode 0x6D,comm_send_headers_short ; m send all headers in compact format
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
300 command_decode 0x61,comm_send_headers_full ; a send all headers is full format
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
301 command_decode 0x66,comm_send_dive ; f send header and profile for one dive
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
302 command_decode 0x62,comm_set_time ; b set the real time clock
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
303 command_decode 0x63,comm_set_custom_text ; c write a new custom text
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
304 command_decode 0x72,comm_read_option ; r read an option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
305 command_decode 0x77,comm_write_option ; w write an option value (into RAM)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
306 command_decode 0x78,comm_option_reset_all ; x reset all option values to their factory default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
307 command_decode 0xFF,comm_service_exit ; exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
308 IFDEF _screendump
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
309 command_decode 0x6C,TFT_dump_screen ; l dump the screen contents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
310 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
311
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
312 btfss comm_service_mode ; service mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
313 bra comm_command_loop ; NO - ignore unrecognized command, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
314
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
315 ; decode and execute additional service mode commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
316 command_decode 0x23,comm_reset_battery_gauge ; # reset the battery gauge registers
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
317 command_decode 0x22,comm_erase_complete_logbook ; " reset all logbook pointers and the logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
318 command_decode 0x20,comm_read_range ;' ' read a memory range from the external FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
319 command_decode 0x40,comm_erase_4kb ; @ erase one 4 kB block - Warning: no confirmation or built-in safety here...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
320 command_decode 0x42,comm_erase_range4kb ; B erase a range of 4 kB blocks - Warning: no confirmation or built-in safety here...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
321 command_decode 0x30,comm_write_range_stream ; 0 write a stream of bytes starting at ext_flash_address:3 until timeout
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
322 command_decode 0x31,comm_write_range_block ; 1 write a block of 256 bytes starting at ext_flash_address:3
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
323 command_decode 0x50,comm_firmware_update ; P initiate firmware update
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
324 command_decode 0xC1,comm_cold_start ; start low-level bootloader
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
325 IFDEF testloop_avail
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
326 command_decode 0x74,testloop ; t start raw-data test loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
327 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
328
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
329 bra comm_command_loop ; ignore unrecognized command, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
330
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
331
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
332 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
333 ; Exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
334 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
335 comm_service_exit:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
336 WIN_SMALL comm_status3_column, comm_status3_row ; print "Exited" message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
337 STRCPY_TEXT_PRINT tUsbExit ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
338 bra comm_service_exit_common ; acknowledge exit command and restart
0
heinrichsweikamp
parents:
diff changeset
339
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
340 comm_service_exit_nousb_delay:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
341 WAITMS d'200' ; wait 200 ms
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
342 btfsc vusb_in ; USB sensed again?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
343 bra comm_mode_selection_loop_3 ; YES - was just a glitch, continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
344 ;bra comm_service_exit_nousb ; NO - proceed exiting
0
heinrichsweikamp
parents:
diff changeset
345
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
346 comm_service_exit_nousb:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
347 WIN_SMALL comm_status3_column, comm_status3_row ; print "Port closed" message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
348 STRCPY_TEXT_PRINT tUsbClosed ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
349 ;bra comm_service_exit_common ; proceed exiting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
350
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
351 comm_service_exit_common:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
352 SERIAL_LC_SEND 0xFF ; acknowledge exit command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
353 call wait_1s ; wait <= 1 second
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
354 call wait_1s ; wait 1 second
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
355 call disable_rs232 ; shut down comm port
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
356 bcf LEDr ; switch off red LED
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
357 goto restart ; restart
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
358
0
heinrichsweikamp
parents:
diff changeset
359
heinrichsweikamp
parents:
diff changeset
360 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
361 ; Set Real-Time-Clock
0
heinrichsweikamp
parents:
diff changeset
362 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
363 comm_set_time:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
364 SERIAL_LC_SEND 0x62 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
365
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
366 ; receive 6 bytes coming in sequence: hour, minute, second, month, day, year
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
367 SERIAL_RR_RECEIVE_RAM mpr,.6
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
368
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
369 ; got all 6 bytes?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
370 btfsc rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
371 bra comm_command_timeout ; YES - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
372
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
373 ; map the received bytes onto the rtc_latched variables
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
374 movff mpr+0,rtc_latched_hour
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
375 movff mpr+1,rtc_latched_mins
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
376 movff mpr+2,rtc_latched_secs
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
377 movff mpr+3,rtc_latched_month
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
378 movff mpr+4,rtc_latched_day
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
379 movff mpr+5,rtc_latched_year
0
heinrichsweikamp
parents:
diff changeset
380
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
381 ; set the RTC
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
382 call rtc_set_rtc ; write time and date to RTC module
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
383
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
384 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
385
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
386
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
387 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
388 ; Write a 15 char text to the OSTC display
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
389 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
390 comm_show_text:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
391 ; set font and output position of the text to show
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
392 WIN_SMALL comm_string_column, comm_string_row
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
393
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
394 SERIAL_LC_SEND 0x6E ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
395
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
396 SERIAL_RR_RECEIVE_RAM buffer,.16 ; (try to) receive 16 chars and write them to 'buffer' using FSR2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
397 STRCAT_PRINT "" ; dump whatever was received to the screen
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
398
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
399 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
400
0
heinrichsweikamp
parents:
diff changeset
401
heinrichsweikamp
parents:
diff changeset
402 ;-----------------------------------------------------------------------------
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
403 ; Reply Serial (2 bytes low:high), firmware (major.minor) and custom text
0
heinrichsweikamp
parents:
diff changeset
404 ;
heinrichsweikamp
parents:
diff changeset
405 comm_identify:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
406 SERIAL_LC_SEND 0x69 ; acknowledge command
0
heinrichsweikamp
parents:
diff changeset
407
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
408 ;---- send OSTC serial number
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
409 call eeprom_serial_number_read ; read OSTC serial number
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
410 SERIAL_CC_SEND mpr+0 ; send serial number, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
411 SERIAL_CC_SEND mpr+1 ; send serial number, high byte
0
heinrichsweikamp
parents:
diff changeset
412
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
413 ;---- send firmware version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
414 SERIAL_LC_SEND fw_version_major ; send firmware version, major
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
415 SERIAL_LC_SEND fw_version_minor ; send firmware version, minor
0
heinrichsweikamp
parents:
diff changeset
416
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
417 ;---- send custom text
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
418 SERIAL_RR_SEND_RAM opt_name,opt_name_length
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
419
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
420 bra comm_command_loop ; done, back to command loop
0
heinrichsweikamp
parents:
diff changeset
421
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
422
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 223
diff changeset
423 ;-----------------------------------------------------------------------------
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 223
diff changeset
424 ; Reply hardware descriptor byte
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 223
diff changeset
425 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
426 comm_hardware_descriptor:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
427 SERIAL_LC_SEND 0x6A ; acknowledge command
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 223
diff changeset
428
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
429 movf HW_descriptor,W ; get hardware descriptor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
430 bcf WREG,6 ; clear bit 6 for reason of compatibility with 3rd party software
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
431 bcf WREG,7 ; clear bit 7 for reason of compatibility with 3rd party software
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
432 SERIAL_CC_SEND WREG ; send modified hardware descriptor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
433
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
434 bra comm_command_loop ; done, back to command loop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
435
0
heinrichsweikamp
parents:
diff changeset
436
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
437 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
438 ; Reply detailed hardware descriptor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
439 ;
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 426
diff changeset
440 comm_feature_and_hardware:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
441 SERIAL_LC_SEND 0x60 ; acknowledge command
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
442
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
443 SERIAL_LC_SEND 0x00 ; send hardware high byte (fixed zero)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
444
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
445 movf HW_descriptor,W ; get hardware descriptor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
446 bcf WREG,6 ; clear bit 6 for reason of compatibility with 3rd party software
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
447 bcf WREG,7 ; clear bit 7 for reason of compatibility with 3rd party software
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
448 SERIAL_CC_SEND WREG ; send modified hardware low byte
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
449
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
450 SERIAL_LC_SEND 0x00 ; send feature high byte (fixed zero)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
451 SERIAL_LC_SEND 0x00 ; send feature low byte (fixed zero)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
452
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
453 SERIAL_LC_SEND 0x00 ; send model descriptor byte (fixed zero)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
454
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
455 bra comm_command_loop ; done, back to command loop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
456
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
457
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
458 ;-----------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
459
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
460 comm_send_headers_short:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
461 SERIAL_LC_SEND 0x6D ; acknowledge command
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
462
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
463 ; send short header (16 bytes/dive)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
464 ; index 0: 0x200009 - 0x200016 + 0x200050 - 0x200051 + 0x200008
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
465 ; 1: 0x201009 - 0x201016 + 0x201050 - 0x201051 + 0x201008
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
466 ; 2: 0x202009 - 0x202016 + 0x202050 - 0x202051 + 0x202008
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
467 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
468 ; 255: 0x2FF009 - 0x2FF016 + 0x2FF050 - 0x2FF051 + 0x2FF008
0
heinrichsweikamp
parents:
diff changeset
469
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
470 clrf ex ; start with dive having index 0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
471 comm_send_headers_short_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
472 movf ex,W ; get index into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
473 call log_header_addr_by_index ; compute header start address from index, result in mpr
0
heinrichsweikamp
parents:
diff changeset
474
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
475 ; assemble the short header - part 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
476 movlw index_profile_byte_count ; adjust start address to first block to go into the short header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
477 movwf mpr+0 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
478 FLASH_RR_READ mpr,header_buffer,.13 ; read 13 bytes from header into buffer
0
heinrichsweikamp
parents:
diff changeset
479
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
480 ; assemble the short header - part 2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
481 movlw index_total_dives ; adjust start address to second block to into the short header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
482 movwf mpr+0 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
483 FLASH_RR_READ mpr,header_buffer+.13,.2 ; read 2 bytes from header into buffer
0
heinrichsweikamp
parents:
diff changeset
484
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
485 ; assemble the short header - part 3
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
486 movlw index_profile_version ; adjust start address to third block to go into the short header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
487 movwf mpr+0 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
488 FLASH_RR_READ mpr,header_buffer+.15,.1 ; read 1 byte from header into buffer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
489
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
490 ; send the assembled short header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
491 SERIAL_RR_SEND_RAM header_buffer,.16 ; send buffer, 16 bytes to do
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
492
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
493 ; go to next header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
494 incfsz ex ; increment index, wrap-around. i.e. all dives done ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
495 bra comm_send_headers_short_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
496 bra comm_command_loop ; YES - done, back to command loop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
497
0
heinrichsweikamp
parents:
diff changeset
498
heinrichsweikamp
parents:
diff changeset
499 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
500
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
501 comm_send_headers_full:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
502 SERIAL_LC_SEND 0x61 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
503
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
504 ; send complete headers (256 bytes/dive)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
505 ; index 0: 0x200000 - 0x2000FF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
506 ; 1: 0x201000 - 0x2010FF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
507 ; 2: 0x202000 - 0x2020FF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
508 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
509 ; 255: 0x2FF000 - 0x2FF0FF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
510
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
511 clrf ex ; start with dive having index 0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
512 comm_send_headers_full_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
513 movf ex,W ; get index into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
514 call log_header_addr_by_index ; compute header start address from index, result in mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
515 FLASH_RR_READ mpr,header_buffer,.256 ; get header from FLASH into memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
516 SERIAL_RR_SEND_RAM header_buffer,.256 ; send the header from memory to RS232
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
517 incfsz ex ; increment index, wrap-around. i.e. all dives done ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
518 bra comm_send_headers_full_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
519 bra comm_command_loop ; YES - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
520
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
521
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
522 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
523 ; Send one full dive
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
524 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
525 comm_send_dive:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
526 SERIAL_LC_SEND 0x66 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
527
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
528 SERIAL_CC_RECEIVE WREG ; (try to) receive the dive index (0-255)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
529 btfsc rs232_rx_timeout ; got dive index?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
530 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
531
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
532 call log_header_addr_by_index ; compute header start address from index, result in mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
533 FLASH_RR_READ mpr,header_buffer,.256; copy the complete header into the buffer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
534
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
535 ; get pointers and length of profile data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
536 MOVTT header_buffer+index_profile_start_address,ext_flash_address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
537 MOVTT header_buffer+index_profile_end_address, ext_flash_end_pointer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
538 MOVTT header_buffer+index_profile_byte_count, ext_flash_length_counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
539
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
540 ; check if profile data are available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
541 movf ext_flash_address+0,W ; compare low byte of start and end pointer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
542 cpfseq ext_flash_end_pointer+0 ; equal?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
543 bra comm_send_dive1 ; NO - profile data available, continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
544
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
545 movf ext_flash_address+1,W ; compare high byte of start and end pointer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
546 cpfseq ext_flash_end_pointer+1 ; equal?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
547 bra comm_send_dive1 ; NO - profile data available, continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
548
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
549 movf ext_flash_address+2,W ; compare upper byte of start and end pointer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
550 cpfseq ext_flash_end_pointer+2 ; equal?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
551 bra comm_send_dive1 ; NO - profile data available, continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
552
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
553 bra comm_command_loop ; start = end -> no profile data available, abort, back to command loop
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
554
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
555 comm_send_dive1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
556 ; send the header from the buffer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
557 SERIAL_RR_SEND_RAM header_buffer,.256
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
558
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
559 ; send the profile directly from the FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
560 ext_flash_inc_address_0x20 .6 ; skip the first 6 bytes (short header) of the profile data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
561 ext_flash_dec_length .3 ; adopt the length count (short by 3 bytes)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
562 ext_flash_dec_length .1 ; decrement length count by 1 so that all bytes will be
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
563 ; done when the counter has wrapped around to 0xFFFFFF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
564 movlw 0x20 ; now the length count is allowed to be 0x1FFFFF at max
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
565 cpfslt ext_flash_length_counter+2 ; length count < 0x20(0000) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
566 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
567 call ext_flash_read_block_start ; YES - read first byte from FLASH into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
568 bra comm_send_dive_loop_start ; - jump into transmit loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
569 comm_send_dive_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
570 call ext_flash_read_block_0x20 ; read next byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
571 comm_send_dive_loop_start:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
572 SERIAL_CC_SEND WREG ; transmit byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
573 ext_flash_dec_length .1 ; decrement length counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
574 btfss ext_flash_length_counter+2,7; under-run?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
575 bra comm_send_dive_loop ; NO - continue loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
576 call ext_flash_read_block_stop ; YES - end reading from FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
577 bra comm_command_loop ; - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
578
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
579
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
580 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
581 ; Reset all Options to Factory Default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
582 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
583 comm_option_reset_all:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
584 SERIAL_LC_SEND 0x78 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
585 call option_reset_all ; reset all options to factory default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
586 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
587
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
588
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
589 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
590 ; Set Custom Text String (opt_name_length ASCII chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
591 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
592 comm_set_custom_text:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
593 CLRR opt_name,opt_name_length ; clear old custom text
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
594 SERIAL_LC_SEND 0x63 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
595
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
596 ; receive new custom text (less than opt_name_length characters may be sent)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
597 SERIAL_RR_RECEIVE_RAM opt_name,opt_name_length
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
598
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
599 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
600
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
601
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
602 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
603 ; Reset Battery Gauge
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
604 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
605 comm_reset_battery_gauge:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
606 ; SERIAL_LC_SEND 0x23 ; acknowledge command (not done)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
607 call reset_battery_gauge_and_lt2942 ; reset battery registers and battery gauge chip
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
608 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
609
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
610
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
611 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
612 ; Erase complete Logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
613 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
614 comm_erase_complete_logbook:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
615 ; SERIAL_LC_SEND 0x22 ; acknowledge command (not done)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
616 call erase_complete_logbook ; erase complete logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
617 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
618
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
619
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
620 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
621 ; Start Bootloader (aka perform cold start)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
622 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
623 comm_cold_start:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
624 ; SERIAL_LC_SEND 0xC1 ; acknowledge command (not done)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
625 ; call rs232_wait_tx ; wait for completion of transmit before hardware goes into reboot
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
626
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
627 WIN_SMALL comm_status3_column, comm_status3_row ; print "Low-level Bootloader" message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
628 STRCPY_TEXT_PRINT tUsbLlBld ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
629
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
630 WIN_TOP comm_warning_row ; set row for icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
631 WIN_LEFT comm_warning_column ; set column for icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
632 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show a warning icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
633
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
634 bsf LEDr ; switch on red LED
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
635
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
636 call eeprom_deco_data_write ; update deco data in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
637 call eeprom_battery_gauge_write ; update battery gauge in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
638 btfsc options_changed ; do the options need to be stored to EEPROM ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
639 call option_check_and_store_all ; YES - check and store all option values in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
640
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
641 goto 0x1FF0C ; jump into the bootloader code
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
642
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
643
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
644 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
645 ; Send Firmware to Bootloader (aka initiate firmware update)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
646 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
647 comm_firmware_update:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
648 SERIAL_LC_SEND 0x50 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
649
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
650 SERIAL_RR_RECEIVE_RAM buffer,.5 ; (try to) receive 5 byte checksum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
651 btfsc rs232_rx_timeout ; got all 5 bytes?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
652 bra comm_send_firmware_abort ; NO - abort
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
653
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
654 ; check the checksum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
655 movlw 0x55 ; initialize checksum check-byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
656 movwf hi ; store in hi
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
657 lfsr FSR2,buffer ; load base address of buffer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
658 movlw .5 ; 5 bytes to process
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
659 movwf lo ; initialize loop counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
660 comm_firmware_update_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
661 movf POSTINC2,W ; get a checksum byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
662 xorwf hi,F ; xor checksum byte with check-byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
663 rlncf hi,F ; rotate check-byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
664 decfsz lo,F ; decrement loop counter, done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
665 bra comm_firmware_update_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
666 tstfsz hi ; YES - check-byte zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
667 bra comm_send_firmware_failed ; NO - checksum not valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
668
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
669 ; checksum is valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
670 SERIAL_LC_SEND 0x4C ; inform checksum is ok
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
671 call rs232_wait_tx ; wait for completion of transmit before hardware goes into reboot
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
672
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
673 call eeprom_deco_data_write ; update deco data in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
674 call eeprom_battery_gauge_write ; update battery gauge in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
675 btfsc options_changed ; do the options need to be stored to EEPROM ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
676 call option_check_and_store_all ; YES - check and store all option values in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
677
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
678 goto 0x1FDF0 ; jump into the bootloader code
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
679
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
680 comm_send_firmware_failed:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
681 ; select font and output position
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
682 WIN_SMALL comm_string_column, comm_string_row
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
683 call TFT_warning_color ; select color
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
684 STRCPY_PRINT "Checksum failed" ; print failure message (fill to 15 chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
685 call TFT_standard_color ; back to standard color
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
686 ;bra comm_send_firmware_abort ; abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
687
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
688 comm_send_firmware_abort:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
689 SERIAL_LC_SEND 0xFF ; send abort message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
690 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
691
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
692
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
693 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
694 ; Erase a Memory Range given byte Start Address and Number of 4 kB Blocks
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
695 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
696 comm_erase_range4kb:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
697 SERIAL_LC_SEND 0x42 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
698 bcf INTCON,GIE ; disable all interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
699 rcall comm_get_start_address ; (try to) get the start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
700 btfsc rs232_rx_timeout ; got start address?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
701 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
702
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
703 ; (try to) receive the block count (1 byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
704 SERIAL_CC_RECEIVE ext_flash_length_counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
705 btfsc rs232_rx_timeout ; got block count?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
706 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
707
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
708 ; erase blocks (number of blocks to do was received in ext_flash_length_counter:1)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
709 comm_erase_range4kb_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
710 call ext_flash_erase_4kB ; erase a 4 kB block
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
711 ; increase start address by 0x1000 (4kB):
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
712 ; nothing to do with low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
713 movlw 0x10 ; add 0x10...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
714 addwf ext_flash_address+1,F ; ... to high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
715 movlw 0x00 ; add 0x00...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
716 addwfc ext_flash_address+2,F ; ... plus carry bit to upper byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
717 btfsc ext_flash_address+2,6 ; reached 0x400000 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
718 bra comm_command_loop ; YES - at end of address range, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
719 decfsz ext_flash_length_counter,F ; NO - decrement number of blocks to do, all blocks done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
720 bra comm_erase_range4kb_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
721 bra comm_command_loop ; YES - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
722
79
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
723
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
724 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
725 ; Erase one Memory Block of 4 kB Size
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
726 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
727 comm_erase_4kb:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
728 ; SERIAL_LC_SEND 0x40 ; acknowledge command (not done)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
729 bcf INTCON,GIE ; disable all interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
730 rcall comm_get_start_address ; (try to) get the start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
731 btfsc rs232_rx_timeout ; got a complete start address?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
732 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
733 call ext_flash_erase_4kB ; YES - erase memory block
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
734 bra comm_command_loop ; - done, back to command loop
157
5ee76921e359 make new parameters configurable through pc
heinrichsweikamp
parents: 150
diff changeset
735
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
736
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
737 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
738 ; Write a stream of bytes to the FLASH beginning at given start address, end on timeout
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
739 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
740 comm_write_range_stream:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
741 SERIAL_LC_SEND 0x30 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
742 bcf INTCON,GIE ; disable all interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
743 rcall comm_get_start_address ; (try to) get the start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
744 btfsc rs232_rx_timeout ; got a complete start address?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
745 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
746
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
747 ; steam bytes to FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
748 comm_write_range_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
749 SERIAL_CC_RECEIVE WREG ; (try to) receive a byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
750 btfsc rs232_rx_timeout ; got a byte?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
751 bra comm_command_loop ; NO - end of byte stream, done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
752 ; bsf NCTS ; YES - hold Bluetooth chip (requires PC/Android/iOS side to use flow control...)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
753 call write_byte_ext_flash_plus_comms ; - write data byte to FLASH and increase address with rollover at 0x400000
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
754 ; bcf NCTS ; - release Bluetooth chip (requires PC/Android/iOS side to use flow control...)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
755 bra comm_write_range_loop ; - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
756
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
757
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
758 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
759 ; Write a block of 256 bytes to the FLASH beginning at given start address (low byte needs to be zero)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
760 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
761 comm_write_range_block:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
762 SERIAL_LC_SEND 0x31 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
763 bcf INTCON,GIE ; disable all interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
764
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
765 rcall comm_get_start_address ; (try to) get the start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
766 btfsc rs232_rx_timeout ; got a complete start address?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
767 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
768
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
769 tstfsz ext_flash_address+0 ; low byte of address = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
770 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
771
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
772 SERIAL_RR_RECEIVE_RAM buffer,.256 ; (try to) receive 256 byte and buffer them in memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
773 btfsc rs232_rx_timeout ; got all 256 bytes?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
774 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
775
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
776 FLASH_RR_WRITE buffer,ext_flash_address,.256 ; copy from memory to FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
777 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
778
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
779
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
780 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
781 ; Read a range from FLASH given by start address and length
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
782 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
783 comm_read_range:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
784 SERIAL_LC_SEND 0x20 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
785 bcf INTCON,GIE ; disable all interrupts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
786
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
787 ; receive start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
788 rcall comm_get_start_address ; (try to) get the start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
789 btfsc rs232_rx_timeout ; got a complete start address?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
790 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
791
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
792 ; receive length
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
793 rcall comm_get_length ; (try to) get the length
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
794 btfsc rs232_rx_timeout ; got a complete length?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
795 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
796
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
797 ; stream bytes from FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
798 ext_flash_dec_length .1 ; decrement length count by 1 so that all bytes will be
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
799 ; done when the counter has wrapped around to 0xFFFFFF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
800
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
801 movlw 0x40 ; now the length count is allowed to be 0x3FFFFF at max
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
802 cpfslt ext_flash_length_counter+2 ; length count < 0x40(0000) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
803 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
804 call ext_flash_read_block_start ; YES - read first byte from FLASH into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
805 bra comm_read_range_loop_start ; - jump into transmit loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
806 comm_read_range_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
807 call ext_flash_read_block_0x40 ; read next byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
808 comm_read_range_loop_start:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
809 SERIAL_CC_SEND WREG ; transmit byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
810 ext_flash_dec_length .1 ; decrement length counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
811 btfss ext_flash_length_counter+2,7; under-run?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
812 bra comm_read_range_loop ; NO - continue loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
813 call ext_flash_read_block_stop ; YES - end reading from FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
814 bra comm_command_loop ; - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
815
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
816
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
817 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
818 ; Receive a 3 byte FLASH address (on serial: big-endian, in memory: little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
819 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
820 comm_get_start_address:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
821 SERIAL_RR_RECEIVE_RAM ext_flash_address,.3 ; receive 3 bytes
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
822 btfsc rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
823 return ; YES - abort, no usable address available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
824
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
825 ; remap address from network byte format (big endian) to host format (little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
826 movf ext_flash_address+0,W
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
827 movff ext_flash_address+2,ext_flash_address+0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
828 movwf ext_flash_address+2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
829
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
830 return ; done, complete start address available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
831
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
832
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
833 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
834 ; Receive a 3 byte length (on serial: big-endian, in memory: little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
835 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
836 comm_get_length:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
837 SERIAL_RR_RECEIVE_RAM ext_flash_length_counter,.3 ; receive 3 bytes
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
838 btfsc rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
839 return ; YES - abort, no usable address available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
840
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
841 ; remap address from network byte format (big endian) to host format (little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
842 movf ext_flash_length_counter+0,W
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
843 movff ext_flash_length_counter+2,ext_flash_length_counter+0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
844 movwf ext_flash_length_counter+2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
845
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
846 return ; done, complete start address available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
847
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
848
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
849 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
850 ; Read an Option Value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
851 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
852 comm_read_option:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
853 SERIAL_LC_SEND 0x72 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
854 SERIAL_CC_RECEIVE lo ; (try to) receive option index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
855 btfsc rs232_rx_timeout ; received option index?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
856 bra comm_command_loop ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
857
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
858 ; option index 0x00 - 0x0F: unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
859 movlw 0x0F ; last option index of the unused range
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
860 cpfsgt lo ; received option index > end of unused range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
861 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
862
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
863 ; option index 0x10 - 0x19: gases & diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
864 movlw 0x19 ; last option index for gases / diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
865 cpfsgt lo ; received option index > end of gas/dil range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
866 bra comm_read_gas_dil ; NO - process gas/dil read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
867
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
868 ; option index 0x1A - 0x1E: setpoints
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
869 movlw 0x1E ; last option index for setpoint
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
870 cpfsgt lo ; received option index > end of setpoint range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
871 bra comm_read_sp ; NO - process setpoint read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
872
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
873 ; option index = 0x49 - special handling button polarity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
874 movf lo,W ; copy option index to WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
875 iorlw 0x49 ; received option index for button polarity ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
876 bz comm_read_button_polarity ; YES - process button polarity read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
877
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
878 ; option index 0x1F - 0xFF: options managed by option-table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
879 call option_read_serial ; try to find the option and read its value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
880 tstfsz WREG ; option found?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
881 bra comm_read_setting_fail ; NO - send dummy value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
882 SERIAL_CC_SEND hi ; YES - send read value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
883 bra comm_command_loop ; - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
884
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
885 comm_read_setting_fail:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
886 SERIAL_LC_SEND 0x00 ; send a dummy value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
887 bra comm_command_error ; back to command loop with failure message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
888
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
889
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
890 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
891 ; Write an Option Value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
892 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
893 comm_write_option:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
894 SERIAL_LC_SEND 0x77 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
895 SERIAL_CC_RECEIVE lo ; (try to) receive option index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
896 btfsc rs232_rx_timeout ; got a byte?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
897 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
898
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
899 ; option index 0x00 - 0x0F: unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
900 movlw 0x0F ; last option index of the unused range
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
901 cpfsgt lo ; received option index > end of unused range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
902 bra comm_write_unused ; NO - but need to consume the option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
903
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
904 ; option index 0x10 - 0x19: gases & diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
905 movlw 0x19 ; last option index for gases / diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
906 cpfsgt lo ; received option index > end of gas/dil range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
907 bra comm_write_gas_dil ; NO - process gas/dil write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
908
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
909 ; option index 0x1A - 0x1E: setpoints
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
910 movlw 0x1E ; last option index for setpoint
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
911 cpfsgt lo ; received option index > end of setpoint range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
912 bra comm_write_sp ; NO - process setpoint write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
913
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
914 ; option index = 0x49 - special handling button polarity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
915 movf lo,W ; copy option index to WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
916 iorlw 0x49 ; received option index for button polarity ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
917 bz comm_write_button_polarity ; YES - process button polarity write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
918
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
919 ; option index 0x1F - 0xFF: options managed by option-table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
920 SERIAL_CC_RECEIVE hi ; (try to) receive option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
921 btfsc rs232_rx_timeout ; got a byte?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
922 bra comm_command_timeout ; NO - abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
923 call option_write_serial ; YES - try to find the option and write new value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
924 tstfsz WREG ; - option found and new value valid ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
925 bra comm_command_error ; NO - back to command loop with failure message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
926 bra comm_command_loop ; YES - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
927
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
928 comm_write_unused:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
929 SERIAL_CC_RECEIVE WREG ; consume unused option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
930 bra comm_command_error ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
931
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
932
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
933 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
934 ; Read button polarity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
935 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
936 comm_read_button_polarity:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
937 SERIAL_CC_SEND button_polarity ; send current button polarity setting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
938 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
939
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
940
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
941 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
942 ; Write button polarity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
943 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
944 comm_write_button_polarity:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
945 SERIAL_CC_RECEIVE hi ; (try to) receive configuration value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
946 btfsc rs232_rx_timeout ; got configuration value?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
947 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
948 movff hi,button_polarity ; YES - store button polarity in memory and EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
949 EEPROM_CC_WRITE button_polarity,eeprom_button_polarity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
950 bra comm_command_loop ; - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
951
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
952
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
953 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
954 ; Read a gas/diluent dataset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
955 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
956 ; Memory map is as follows:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
957 ; -------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
958 ; opt_gas_O2_ratio res 5 ; O2 ratios of OC/bailout gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
959 ; opt_dil_O2_ratio res 5 ; O2 ratios of diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
960 ; opt_gas_He_ratio res 5 ; He ratios of OC/bailout gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
961 ; opt_dil_He_ratio res 5 ; He ratios of diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
962 ; opt_gas_type res 5 ; OC/bailout gas type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
963 ; opt_dil_type res 5 ; dil type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
964 ; opt_gas_change res 5 ; change depths for OC/Bailout gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
965 ; opt_dil_change res 5 ; change depths for diluents
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
966 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
967 comm_read_gas_dil:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
968 lfsr FSR0,opt_gas_O2_ratio ; load base address of gas data arrays
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
969 movlw 0x10 ; compute gas index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
970 subwf lo,W ; ...making WREG point to O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
971 SERIAL_CC_SEND PLUSW0 ; send O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
972 addlw .10 ; increment WREG by 10 to point to He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
973 SERIAL_CC_SEND PLUSW0 ; send He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
974 addlw .10 ; increment WREG by 10 to point to gas/diluent type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
975 SERIAL_CC_SEND PLUSW0 ; send gas/diluent type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
976 addlw .10 ; increment WREG by 10 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
977 SERIAL_CC_SEND PLUSW0 ; send change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
978 bra comm_command_loop ; done, back to command loop
110
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 97
diff changeset
979
79
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
980
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
981 ; ----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
982 ; Write a gas/diluent dataset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
983 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
984 ; Memory map is as follows:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
985 ; -------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
986 ; opt_gas_O2_ratio res 5 ; O2 ratios of OC/bailout gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
987 ; opt_dil_O2_ratio res 5 ; O2 ratios of diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
988 ; opt_gas_He_ratio res 5 ; He ratios of OC/bailout gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
989 ; opt_dil_He_ratio res 5 ; He ratios of diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
990 ; opt_gas_type res 5 ; OC/bailout gas type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
991 ; opt_dil_type res 5 ; dil type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
992 ; opt_gas_change res 5 ; change depths for OC/Bailout gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
993 ; opt_dil_change res 5 ; change depths for diluents
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
994 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
995 comm_write_gas_dil:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
996 SERIAL_RR_RECEIVE_RAM hi,.4 ; (try to) receive 4 option values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
997 btfsc rs232_rx_timeout ; got all 4 bytes?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
998 bra comm_command_timeout ; NO - abort, back to command loop
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
999
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1000 ; check validity of O2 value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1001 movlw gaslist_min_o2-.1 ; get min value minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1002 cpfsgt hi ; received O2% >= min ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1003 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1004 movlw gaslist_max_o2+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1005 cpfslt hi ; received O2% <= max ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1006 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1007
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1008 ; check validity of He value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1009 movlw gaslist_max_He+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1010 cpfslt up ; received O2% <= max ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1011 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1012
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1013 ; check O2% + He% <= 100%
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1014 movlw .100 ; load 100%
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1015 bsf STATUS,C ; set carry = clear borrow
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1016 subfwb hi,W ; subtract O2% from 100%
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1017 btfss STATUS,C ; result negative?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1018 bra comm_command_error ; YES - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1019 subfwb up,W ; NO - subtract He%
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1020 btfss STATUS,C ; - now negative?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1021 bra comm_command_error ; YES - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1022
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1023 ; check validity of type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1024 movlw 0x14 ; last option index for gases
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1025 cpfsgt lo ; received option index > end of gas range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1026 bra comm_write_dil ; YES - check type for diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1027 ;bra comm_write_gas ; NO - check type for gases
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1028
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1029 comm_write_gas:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1030 ; check validity of type for a gas
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1031 movlw num_gas_types ; load number of gas types
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1032 bra comm_write_gas_dil_common ; continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1033
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1034 comm_write_dil:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1035 ; check validity of type for a diluent
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1036 movlw num_dil_types ; load number of diluent types
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1037 ;bra comm_write_gas_dil_common ; continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1038
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1039 comm_write_gas_dil_common:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1040 cpfslt ex ; received type < max ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1041 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1042
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1043 ; check validity of change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1044 movlw gaslist_max_change_depth+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1045 cpfslt ul ; received change depth <= max ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1046 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1047
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1048 ; all values ok, can finally be written
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1049 lfsr FSR0,opt_gas_O2_ratio ; load base address of gas data arrays
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1050 movlw 0x10 ; compute gas index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1051 subwf lo,W ; ...making WREG point to O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1052 movff hi,PLUSW0 ; set O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1053 addlw .10 ; increment WREG by 10 to point to He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1054 movff up,PLUSW0 ; set He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1055 addlw .10 ; increment WREG by 10 to point to gas/dil type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1056 movff ex,PLUSW0 ; set gas/dil type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1057 addlw .10 ; increment WREG by 10 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1058 movff ul,PLUSW0 ; set change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1059
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1060 bra comm_command_loop ; done, back to command loop
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
1061
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1062
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1063 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1064 ; Read a setpoint dataset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1065 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1066 ; Memory map is as follows:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1067 ; -------------------------
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1068 ; opt_setpoint_cbar res 5 ; setpoints in cbar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1069 ; opt_setpoint_change res 5 ; change depth for the setpoints in meter
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1070 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1071 comm_read_sp:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1072 lfsr FSR0,opt_setpoint_cbar ; load base address of setpoint cbar values
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1073 movlw 0x1A ; compute SP index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1074 subwf lo,W ; ...making WREG point to cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1075 SERIAL_CC_SEND PLUSW0 ; send setpoint cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1076 addlw .5 ; increment WREG by 5 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1077 SERIAL_CC_SEND PLUSW0 ; send change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1078 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1079
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1080
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1081 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1082 ; Write a setpoint dataset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1083 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1084 ; Memory map is as follows:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1085 ; -------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1086 ; opt_setpoint_cbar res 5 ; setpoints in cbar
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1087 ; opt_setpoint_change res 5 ; change depths in meter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1088 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1089 comm_write_sp:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1090 SERIAL_RR_RECEIVE_RAM hi,.2 ; (try to) receive 2 option values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1091 btfsc rs232_rx_timeout ; got both bytes?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1092 bra comm_command_timeout ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1093
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1094 ; check validity of setpoint value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1095 movlw gaslist_sp_min-.1 ; get min value minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1096 cpfsgt hi ; received O2% >= min ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1097 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1098 movlw gaslist_sp_max+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1099 cpfslt hi ; received O2% <= max ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1100 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1101
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1102 ; check validity of change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1103 movlw sp_max_change_depth+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1104 cpfslt up ; received change depth <= max ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1105 bra comm_command_error ; NO - abort, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1106
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1107 lfsr FSR0,opt_setpoint_cbar ; load base address of setpoint cbar values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1108 movlw 0x1A ; compute SP index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1109 subwf lo,W ; ...making WREG point to cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1110 movff hi,PLUSW0 ; set cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1111 addlw .5 ; increment WREG by 5 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1112 movff up,PLUSW0 ; set change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1113
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1114 bra comm_command_loop ; done, back to command loop
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
1115
79
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
1116 ;-----------------------------------------------------------------------------
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
1117
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
1118 END