annotate src/comm.asm @ 655:c7b7b8a358cd default tip

hwOS tech 3.22 release
author heinrichsweikamp
date Mon, 29 Apr 2024 13:05:18 +0200
parents 75e90cd0c2c3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
636
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
3 ; File comm.asm * combined next generation V3.10.0
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; RS232 via USB
heinrichsweikamp
parents:
diff changeset
6 ;
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
7 ; Copyright (c) 2012, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
0
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"
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
28 #include "colorschemes.inc"
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
29
0
heinrichsweikamp
parents:
diff changeset
30
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
31 extern restart
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
32 extern option_reset_all
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
33 extern option_check_and_store_all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
34 extern option_read_serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
35 extern option_write_serial
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
36 extern gaslist_cleanup_list
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
37 extern eeprom_deco_data_write
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
38 extern eeprom_memorize_fw_checksum
0
heinrichsweikamp
parents:
diff changeset
39
heinrichsweikamp
parents:
diff changeset
40
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
41 ; timeouts
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
42 #DEFINE timeout_comm_pre_mode .240 ; [sec] timeout before communication is established
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
43 #DEFINE timeout_service_mode .120 ; [sec] timeout when communication is established
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
44
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
45 ; positioning of title
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
46 #DEFINE comm_title_row .0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
47 #DEFINE comm_title_column_usb .40
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
48 #DEFINE comm_title_column_ble .25
0
heinrichsweikamp
parents:
diff changeset
49
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
50 ; positioning of host-sent text messages
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
51 #DEFINE comm_string_row .30
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
52 #DEFINE comm_string_column .40
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
53
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
54 ; positioning of COMM mode status messages
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
55 #DEFINE comm_status1_row .70
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
56 #DEFINE comm_status1_column .10
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
57 #DEFINE comm_status2_row .100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
58 #DEFINE comm_status2_column comm_status1_column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
59 #DEFINE comm_status3_row .130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
60 #DEFINE comm_status3_column comm_status1_column
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
61 #DEFINE comm_status4_row .160
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
62 #DEFINE comm_status4_column comm_status1_column
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
63 #DEFINE comm_status5_row .190
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
64 #DEFINE comm_status5_column comm_status1_column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
65
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
66
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
67 ; positioning of COMM mode warning icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
68 #DEFINE comm_warning_row .160
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
69 #DEFINE comm_warning_column .65
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
70
0
heinrichsweikamp
parents:
diff changeset
71
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
72 ;#DEFINE testloop_avail ; uncomment if testloop code is available
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
73
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
74 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
75 comm CODE
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
76 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
77
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
78 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
79 ; Entry Point for Comm Mode / USB
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
80 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
81 global comm_mode_usb
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
82 comm_mode_usb: ; entry point for comm mode via USB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
83 WAITMS d'1' ; wait 1 ms
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
84 btfss vusb_in ; USB still plugged in?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
85 return ; NO - it was only a glitch, abort
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
86 WAITMS d'1' ; YES - wait 1 ms
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
87 btfss vusb_in ; - USB still plugged in?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
88 return ; NO - it was only a glitch, abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
89 bsf aux_flag ; YES - remember to show USB title
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
90 bra comm_mode_common ; - continue with common part
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
91
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
92
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
93 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
94 ; Entry Point for Comm Mode / BT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
95 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
96 global comm_mode_bt
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
97 comm_mode_bt: ; entry point for comm mode via BT
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
98 bcf aux_flag ; remember to show BLE title
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
99 ;bra comm_mode_common ; continue with common part
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
100
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
101
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
102 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
103 ; Common Part of Comm Mode Entry
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
104 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
105 comm_mode_common:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
106 clrf STKPTR ; reset addresses stack
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
107 call TFT_ClearScreen ; clear screen
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
108 FONT_COLOR color_greenish ; set color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
109
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
110 btfss aux_flag ; shall show USB title?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
111 bra comm_mode_common_bt ; NO - show BT title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
112 ;bra comm_mode_common_usb ; YES - show USB title
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
113
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
114 comm_mode_common_usb:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
115 WIN_SMALL comm_title_column_usb, comm_title_row ; set USB title position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
116 STRCPY_TEXT_PRINT tUsbTitle ; print USB title text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
117 bra comm_mode_common_logo ; continue with logo
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
118
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
119 comm_mode_common_bt:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
120 WIN_SMALL comm_title_column_ble, comm_title_row ; set BT title position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
121 STRCPY_TEXT_PRINT tBleTitle ; print BT title text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
122 ;bra comm_mode_common_logo ; continue with logo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
123
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
124 comm_mode_common_logo:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
125 WIN_TOP .10 ; set position of USB/BLE logo, row
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
126 WIN_LEFT .1 ; set position of USB/BLE logo, column
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
127 btfss battery_gauge_available ; "+" bootloader ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
128 bra comm_mode_common_logo2 ; YES - show logo type 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
129 ;bra comm_mode_common_logo1 ; NO - show logo type 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
130
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
131 comm_mode_common_logo1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
132 TFT_WRITE_PROM_IMAGE_BY_ADDR comm_logo_1 ; show USB/BT logo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
133 bra comm_mode_common_start ; continue with starting message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
134
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
135 comm_mode_common_logo2:
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
136 btfsc dn_flag
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
137 bra comm_mode_common_logo3
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
138 TFT_WRITE_PROM_IMAGE_BY_ADDR comm_logo_2 ; show BT logo / OSTC+
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
139 bra comm_mode_common_start ; continue with starting message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
140
654
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
141 comm_mode_common_logo3:
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
142 TFT_WRITE_PROM_IMAGE_BY_ADDR comm_logo_3 ; show BT logo / dn
75e90cd0c2c3 hwOS sport 10.77 release
heinrichsweikamp
parents: 651
diff changeset
143
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
144 comm_mode_common_start:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
145 WIN_SMALL comm_status1_column,comm_status1_row ; set position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
146 FONT_COLOR_MEMO ; set standard color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
147 STRCPY_TEXT_PRINT tUsbStarting ; print status message "starting..."
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
148
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
149 WIN_TINY .40,.240-.16 ; set output position to bottom line
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
150 call TFT_print_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
151
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
152 IFDEF _screendump
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
153 bcf screen_dump_avail ; disable screen dump function
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
154 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
155
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
156 bcf switch_right ; clear potential left-over right button event
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
157 call enable_rs232 ; enable serial comm, also sets CPU to normal speed
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
158
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
159 WIN_SMALL comm_status1_column+.80,comm_status1_row ; set position after starting message
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
160 FONT_COLOR_MEMO ; set standard color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
161 STRCPY_TEXT_PRINT tUsbStartDone ; print (adding to status message) "done..."
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
162
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
163 movlw timeout_comm_pre_mode ; get timeout for phase without communication established yet
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
164 movwf comm_timeout_timer ; initialize timeout counter
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
165 ;bra comm_mode_selection_loop ; continue with mode selection loop
0
heinrichsweikamp
parents:
diff changeset
166
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
167
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
168 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
169 ; Mode Selection Loop: Download Mode or Service Mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
170 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
171 comm_mode_selection_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
172 bcf trigger_full_second ; clear 'one second elapsed' flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
173 bcf LEDr ; switch off red LED / power down TR co-processor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
174 dcfsnz comm_timeout_timer,F ; decrement timeout, reached zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
175 bra comm_service_exit ; YES - timeout, exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
176 ;bra comm_mode_selection_loop_1 ; NO - try to receive a byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
177 comm_mode_selection_loop_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
178 SERIAL_CC_RECEIVE lo ; (try to) receive 1 byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
179 btfsc rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
180 bra comm_mode_selection_loop_2 ; YES - check for comm mode termination
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
181 movf lo,W ; NO - copy received byte to lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
182 xorlw 0xAA ; - service mode start byte received?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
183 bz comm_service_mode_check ; YES - check if correct key will be send
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
184 movf lo,W ; NO - copy received byte to lo again
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
185 xorlw 0xBB ; - download mode start byte received?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
186 bz comm_download_mode ; YES - enter command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
187 ;bra comm_mode_selection_loop_2 ; NO - check for comm mode termination
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
188 comm_mode_selection_loop_2:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
189 btfsc ble_available ; BT available?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
190 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
191 btfss vusb_in ; NO - USB plugged in?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
192 bra comm_service_exit_nousb_delay ; NO - disconnected, check for vusb_in glitch
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
193 ;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
194 comm_mode_selection_loop_3:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
195 btfsc switch_right ; right button pressed?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
196 bra comm_service_exit ; YES - exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
197 btfsc trigger_full_second ; NO - did 1 second elapsed meanwhile?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
198 bra comm_mode_selection_loop ; YES - loop with clocking down timeout counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
199 bra comm_mode_selection_loop_1 ; NO - loop without clocking down timeout counter
0
heinrichsweikamp
parents:
diff changeset
200
heinrichsweikamp
parents:
diff changeset
201
heinrichsweikamp
parents:
diff changeset
202 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
203 ; Check Service Mode Pass-Key and notify Service Mode on Success
0
heinrichsweikamp
parents:
diff changeset
204 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
205 comm_service_mode_check:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
206 SERIAL_LC_SEND 0x4B ; request peer to send service key
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
207
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
208 ; receive a 3 byte service key transmitted in big-endian, echo each byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
209
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
210 clrf WREG ; clear WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
211
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
212 SERIAL_CC_RECEIVE lo ; receive 1st byte, store in lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
213 xorwf lo,W ; exclusive-or received byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
214 xorlw UPPER (comm_service_key) ; exclusive-or expected byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
215 SERIAL_CC_SEND lo ; echo 1st byte
0
heinrichsweikamp
parents:
diff changeset
216
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
217 SERIAL_CC_RECEIVE lo ; receive 2nd byte, store in lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
218 xorwf lo,W ; exclusive-or received byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
219 xorlw HIGH (comm_service_key & 0xFFFF) ; exclusive-or expected byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
220 SERIAL_CC_SEND lo ; echo 2nd byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
221
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
222 SERIAL_CC_RECEIVE lo ; receive 3rd byte, store in lo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
223 xorwf lo,W ; exclusive-or received byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
224 xorlw LOW (comm_service_key & 0xFFFF) ; exclusive-or expected byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
225 SERIAL_CC_SEND lo ; echo 3rd byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
226
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
227 ; check for correct service key
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
228 tstfsz WREG ; received expected service key?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
229 bra comm_mode_selection_loop ; NO - back to mode selection loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
230 WIN_SMALL comm_status2_column, comm_status2_row ; YES - print service mode enabled message
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
231 FONT_COLOR_MEMO ; - set standard color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
232 STRCPY_TEXT_PRINT tUsbServiceMode ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
233 bsf comm_service_mode ; - enable service mode commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
234 bra comm_command_loop ; - enter command loop
0
heinrichsweikamp
parents:
diff changeset
235
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
236
0
heinrichsweikamp
parents:
diff changeset
237 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
238 ; Notify RX Timeout occurred
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
239 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
240 comm_command_timeout:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
241 WIN_SMALL comm_status4_column, comm_status4_row ; select font and output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
242 FONT_COLOR_WARNING ; set warning color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
243 STRCPY_PRINT "Data Rx Timeout" ; print failure message
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
244 FONT_COLOR_MEMO ; back to standard color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
245 bra comm_drain_rx_queue ; continue with draining the RX queue
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
246
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
247
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
248 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
249 ; Notify Error in Parameters
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
250 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
251 comm_command_error:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
252 WIN_SMALL comm_status4_column, comm_status4_row ; select font and output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
253 FONT_COLOR_WARNING ; set warning color
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 636
diff changeset
254 STRCPY_PRINT "Unknown Parameter" ; print failure message
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
255 FONT_COLOR_MEMO ; back to standard color
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 636
diff changeset
256 bra comm_service_exit ; abort
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
257 ;bra comm_drain_rx_queue ; continue with draining the RX queue
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
258
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
259
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
260 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
261 ; Drain the RX Queue until next Timeout
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
262 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
263 comm_drain_rx_queue:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
264 bsf INTCON,GIE ; re-enable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
265 comm_drain_rx_queue_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
266 btfsc switch_right ; right button (abort) pressed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
267 bra comm_service_exit ; YES - exit comm mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
268 SERIAL_CC_RECEIVE WREG ; NO - (try to) receive one byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
269 btfss rs232_rx_timeout ; - got a byte?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
270 bra comm_drain_rx_queue_loop ; YES - try to drain more bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
271 bra comm_command_loop ; NO - re-enter command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
272
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
273
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
274 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
275 ; Debug Code - show Number of Bytes received
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
276 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
277 IFDEF _comm_debug
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
278 comm_command_debug:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
279 WIN_SMALL comm_status5_column, comm_status5_row ; select font and output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
280 FONT_COLOR_MEMO ; set standard color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
281 STRCPY "last RX: " ; print label
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
282 output_9999 ; print number of bytes received (0-9999)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
283 STRCAT_PRINT " Byte" ; finalize output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
284 bra comm_command_loop ; re-enter command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
285 ENDIF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
286
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
287
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
288 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
289 ; Notify Download Mode selected
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
290 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
291 comm_download_mode:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
292 SERIAL_LC_SEND 0xBB ; inform peer download mode will be started
0
heinrichsweikamp
parents:
diff changeset
293
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
294 WIN_SMALL comm_status2_column, comm_status2_row ; set position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
295 FONT_COLOR_MEMO ; set standard color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
296 STRCPY_TEXT_PRINT tUsbDownloadMode ; print download mode enabled message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
297 bcf comm_service_mode ; disable service mode commands
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
298 ;bra comm_command_loop ; enter command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
299
0
heinrichsweikamp
parents:
diff changeset
300
heinrichsweikamp
parents:
diff changeset
301 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
302 ; Command Loop: await, decode and execute Commands
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
303 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
304 comm_command_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
305 bsf INTCON,GIE ; re-enable all interrupts
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
306
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
307 ; restart command timeout
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
308 movlw timeout_service_mode ; get timeout value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
309 movwf comm_timeout_timer ; reload timeout timer
0
heinrichsweikamp
parents:
diff changeset
310
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
311 ; request peer to send a command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
312 movlw 0x4D ; default request code is 0x4D for download mode active
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
313 btfsc comm_service_mode ; service mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
314 movlw 0x4C ; YES - change request to 0x4C for service mode active
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
315 SERIAL_CC_SEND WREG ; send request
0
heinrichsweikamp
parents:
diff changeset
316
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
317 ; wait for peer to send a command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
318 comm_command_loop_wait:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
319 SERIAL_CC_RECEIVE lo ; (try to) receive a command byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
320 btfss rs232_rx_timeout ; timeout?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
321 bra comm_command_decode ; NO - decode and execute the command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
322 btfsc comm_service_mode ; YES - service mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
323 btg LEDr ; YES - blink in service mode
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
324 btfsc ble_available ; - BT available?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
325 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
326 btfss vusb_in ; NO - USB still plugged in?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
327 bra comm_service_exit_nousb ; NO - disconnected -> exit comm mode
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
328 ;bra comm_command_loop_wait_1 ; YES - proceed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
329
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
330 comm_command_loop_wait_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
331 btfsc switch_right ; right button (abort) pressed?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
332 bra comm_service_exit ; YES - exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
333 btfss trigger_full_second ; NO - did 1 second elapsed meanwhile?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
334 bra comm_command_loop_wait ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
335 dcfsnz comm_timeout_timer,F ; YES - decrement the timeout timer, reached zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
336 bra comm_service_exit ; YES - exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
337 bcf trigger_full_second ; NO - clear 'one second elapsed' flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
338 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
339
cf9ce6053dee New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents: 337
diff changeset
340
cf9ce6053dee New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents: 337
diff changeset
341 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
342 ; Macro for easier writing of Command Decoding Rules
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
343 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
344 command_decode macro command_id,command_function
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
345 movf lo,W ; copy received command to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
346 xorlw command_id ; exclusive-or with command ID
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
347 btfsc STATUS,Z ; received command = command ID ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
348 goto command_function ; YES - execute command
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
349 endm
0
heinrichsweikamp
parents:
diff changeset
350
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
351
0
heinrichsweikamp
parents:
diff changeset
352 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
353 ; Decode and execute a Command
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
354 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
355 comm_command_decode:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
356 bcf LEDr ; switch off red led
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
357
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
358 ; decode and execute standard commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
359 command_decode 0x6E,comm_show_text ; n show a text on the screen
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
360 command_decode 0x69,comm_identify ; i send ID: serial, firmware, and custom text
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
361 command_decode 0x6A,comm_hardware_descriptor ; j send ID: hardware descriptor byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
362 command_decode 0x60,comm_feature_and_hardware ; ' send ID: more detailed information
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
363 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
364 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
365 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
366 command_decode 0x62,comm_set_time ; b set the real time clock
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
367 command_decode 0x63,comm_set_custom_text ; c write a new custom text
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
368 command_decode 0x72,comm_read_option ; r read an option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
369 command_decode 0x77,comm_write_option ; w write an option value (into RAM)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
370 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
371 command_decode 0xFF,comm_service_exit ; exit comm mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
372 IFDEF _screendump
636
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
373 command_decode 0x6C,TFT_dump_screen_comm ; l dump the screen contents
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
374 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
375
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
376 btfss comm_service_mode ; service mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
377 bra comm_command_loop ; NO - ignore unrecognized command, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
378
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
379 ; decode and execute additional service mode commands
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
380 command_decode 0x23,comm_reset_battery_gauge ; # reset the battery gauge registers
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
381 command_decode 0x22,comm_erase_complete_logbook ; " reset all logbook pointers and the logbook
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
382 command_decode 0x20,comm_read_range ;' ' read a memory range from the external FLASH
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
383 command_decode 0x40,comm_erase_single_4kb ; @ erase a single 4 kB block - Warning: no confirmation or built-in safety here...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
384 command_decode 0x42,comm_erase_range_4kb ; B erase a range of 4 kB blocks - Warning: no confirmation or built-in safety here...
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
385 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
386 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
387 command_decode 0x50,comm_firmware_update ; P initiate firmware update
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
388 command_decode 0xC1,comm_cold_start ; start low-level bootloader
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
389 IFDEF testloop_avail
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
390 command_decode 0x74,testloop ; t start raw-data test loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
391 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
392
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
393 bra comm_command_loop ; ignore unrecognized command, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
394
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
395
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
396 ;-----------------------------------------------------------------------------
636
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
397 ; Screendump
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
398 ;
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
399 IFDEF _screendump
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
400 TFT_dump_screen_comm:
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
401 call TFT_dump_screen ; dump the screen contents and set screen_dump_avail
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
402 ;bra comm_service_exit ; exit comm mode
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
403 ENDIF
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
404
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
405
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
406 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
407 ; Exit Comm Mode
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
408 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
409 comm_service_exit:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
410 WIN_SMALL comm_status3_column, comm_status3_row ; print "Exited" message
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
411 FONT_COLOR_MEMO ; set standard color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
412 STRCPY_TEXT_PRINT tUsbExit ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
413 bra comm_service_exit_common ; acknowledge exit command and restart
0
heinrichsweikamp
parents:
diff changeset
414
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
415 comm_service_exit_nousb_delay:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
416 WAITMS d'200' ; wait 200 ms
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
417 btfsc vusb_in ; USB sensed again?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
418 bra comm_mode_selection_loop_3 ; YES - was just a glitch, continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
419 ;bra comm_service_exit_nousb ; NO - proceed exiting
0
heinrichsweikamp
parents:
diff changeset
420
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
421 comm_service_exit_nousb:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
422 WIN_SMALL comm_status3_column, comm_status3_row ; print "Port closed" message
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
423 FONT_COLOR_MEMO ; set standard color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
424 STRCPY_TEXT_PRINT tUsbClosed ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
425 ;bra comm_service_exit_common ; proceed exiting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
426
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
427 comm_service_exit_common:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
428 SERIAL_LC_SEND 0xFF ; acknowledge exit command
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
429 WAITS .1 ; wait 1 second to give the serial I/F time
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
430 ; to send the 0xFF before it gets shut down
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
431 call disable_rs232 ; shut down comm port
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
432 bcf LEDr ; switch off red LED
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
433 WAITS .1 ; wait 1 second for BT module supply to drain
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
434 goto restart ; restart
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
435
0
heinrichsweikamp
parents:
diff changeset
436
heinrichsweikamp
parents:
diff changeset
437 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
438 ; Set Real-Time-Clock
0
heinrichsweikamp
parents:
diff changeset
439 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
440 comm_set_time:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
441 bcf INTCON,GIE ; disable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
442 SERIAL_LC_SEND 0x62 ; acknowledge command
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
443 SERIAL_RR_RECEIVE mpr,.6 ; (try to) receive 6 bytes: hour, minute, second, month, day, year
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
444 bsf INTCON,GIE ; re-enable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
445
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
446 btfsc rs232_rx_timeout ; got all 6 bytes?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
447 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
448
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
449 movff mpr+0,rtc_latched_hour ; map the received bytes onto the rtc_latched variables
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
450 movff mpr+1,rtc_latched_mins ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
451 movff mpr+2,rtc_latched_secs ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
452 movff mpr+3,rtc_latched_month ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
453 movff mpr+4,rtc_latched_day ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
454 movff mpr+5,rtc_latched_year ; ...
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
455 call rtc_set_rtc ; write time and date to RTC module
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
456 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
457
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
458
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
459 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
460 ; Write a 15 char Text to the OSTC Display
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
461 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
462 comm_show_text:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
463 ; set font and output position (needs to be done before SERIAL_RR_RECEIVE)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
464 WIN_SMALL comm_string_column, comm_string_row
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
465 FONT_COLOR_MEMO ; set standard color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
466
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
467 bcf INTCON,GIE ; disable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
468 SERIAL_LC_SEND 0x6E ; acknowledge command
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
469 SERIAL_RR_RECEIVE buffer,.16 ; (try to) receive 16 chars into the string buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
470 bsf INTCON,GIE ; re-enable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
471
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
472 movlw .15 ; set maximum text length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
473 call TFT_buffer_trim_length ; fill or trim the text to correct length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
474 PRINT ; print text to screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
475 bra comm_command_loop ; done, back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
476
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
477
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
478 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
479 ; Send Serial (2 bytes low:high), Firmware (major.minor) and Custom Text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
480 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
481 comm_identify:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
482 SERIAL_LC_SEND 0x69 ; acknowledge command
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
483
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
484 ; send OSTC serial number
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
485 call eeprom_serial_number_read ; read OSTC serial number
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
486 SERIAL_CC_SEND mpr+0 ; send serial number, low byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
487 SERIAL_CC_SEND mpr+1 ; send serial number, high byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
488
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
489 ; send firmware version
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
490 SERIAL_LC_SEND fw_version_major ; send firmware version, major
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
491 SERIAL_LC_SEND fw_version_minor ; send firmware version, minor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
492
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
493 ; send custom text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
494 SERIAL_RR_SEND opt_name,opt_name_length
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
495
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
496 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
497
0
heinrichsweikamp
parents:
diff changeset
498
heinrichsweikamp
parents:
diff changeset
499 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
500 ; Send short Hardware Descriptor
0
heinrichsweikamp
parents:
diff changeset
501 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
502 comm_hardware_descriptor:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
503 SERIAL_LC_SEND 0x6A ; acknowledge command
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
504 rcall comm_helper_hw_descriptor ; send hardware descriptor
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
505 bra comm_command_loop ; done, back to command loop
0
heinrichsweikamp
parents:
diff changeset
506
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
507
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 223
diff changeset
508 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
509 ; Helper Function for sending Hardware Descriptor
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 223
diff changeset
510 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
511 comm_helper_hw_descriptor:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
512 movf HW_descriptor,W ; get hardware descriptor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
513 bcf WREG,6 ; clear bit 6 for reason of compatibility with 3rd party software
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
514 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
515 SERIAL_CC_SEND WREG ; send modified hardware descriptor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
516 return
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
517
0
heinrichsweikamp
parents:
diff changeset
518
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
519 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
520 ; Send detailed Hardware Descriptor
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
521 ;
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 426
diff changeset
522 comm_feature_and_hardware:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
523 SERIAL_LC_SEND 0x60 ; acknowledge command
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
524
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
525 SERIAL_LC_SEND 0x00 ; send hardware high byte (fixed zero)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
526 rcall comm_helper_hw_descriptor ; send hardware descriptor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
527 SERIAL_LC_SEND 0x00 ; send feature high byte (fixed zero)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
528 SERIAL_LC_SEND 0x00 ; send feature low byte (fixed zero)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
529 SERIAL_LC_SEND 0x00 ; send model descriptor byte (fixed zero)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
530
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
531 bra comm_command_loop ; done, back to command loop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
532
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
533
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
534 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
535 ; Helper Function to retrieve a Header, hide the internal Profile Version,
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
536 ; and to check if the Header is empty
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
537 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
538 comm_helper_read_header:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
539 ; copy header from FLASH into memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
540 call log_header_addr_by_index ; compute header start address from index in WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
541 FLASH_RR_READ header_buffer,.256 ; copy from FLASH to header buffer
0
heinrichsweikamp
parents:
diff changeset
542
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
543 ; hide internal profile version ID from the outside
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
544 movff header_buffer+index_profile_version,WREG ; get byte at the profile version position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
545 infsnz WREG,W ; was the byte = 0xFF (i.e. empty header) ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
546 return ; YES - leave it as it is (WREG now 0)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
547 decf WREG,W ; NO - restore the profile version
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
548 andlw b'00111111' ; - keep only the external part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
549 movff WREG,header_buffer+index_profile_version ; - write back the cleaned byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
550 return ; - done (WREG now ext. profile version)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
551
0
heinrichsweikamp
parents:
diff changeset
552
heinrichsweikamp
parents:
diff changeset
553 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
554 ; Send Dive Headers in short or full Format
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
555 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
556 comm_send_headers_short:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
557 SERIAL_LC_SEND 0x6D ; acknowledge command
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
558 bcf aux_flag ; send short headers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
559 bra comm_send_headers_common ; continue with common part
0
heinrichsweikamp
parents:
diff changeset
560
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
561 comm_send_headers_full:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
562 SERIAL_LC_SEND 0x61 ; acknowledge command
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
563 bsf aux_flag ; send full headers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
564 ;bra comm_send_headers_common ; continue with common part
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
565
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
566 comm_send_headers_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
567 clrf ex ; start with dive having index 0
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
568
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
569 comm_send_headers_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
570 movf ex,W ; get index into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
571 rcall comm_helper_read_header ; get header into header_buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
572
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
573 btfss aux_flag ; shall send full headers?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
574 bra comm_send_headers_loop_short; NO - send short headers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
575 ;bra comm_send_headers_loop_full ; YES - send full headers
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
576
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
577 comm_send_headers_loop_full:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
578 SERIAL_RR_SEND header_buffer,.256 ; send the full header
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
579 bra comm_send_headers_loop_com ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
580
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
581 comm_send_headers_loop_short:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
582 ; send the fractions of the short header (16 byte/dive)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
583 SERIAL_RR_SEND header_buffer+index_profile_byte_count,.13
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
584 SERIAL_RR_SEND header_buffer+index_total_dives, .2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
585 SERIAL_CC_SEND header_buffer+index_profile_version ; .1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
586 ;bra comm_send_headers_loop_com ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
587
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
588 comm_send_headers_loop_com:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
589 incfsz ex ; increment index, wrap-around. i.e. all dives done ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
590 bra comm_send_headers_loop ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
591 bra comm_command_loop ; YES - done, back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
592
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
593
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
594 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
595 ; Send one full Dive
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
596 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
597 comm_send_dive:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
598 SERIAL_LC_SEND 0x66 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
599
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
600 SERIAL_CC_RECEIVE WREG ; (try to) receive the dive index
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
601 btfsc rs232_rx_timeout ; got dive index?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
602 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
603
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
604 rcall comm_helper_read_header ; read header into header_buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
605 bz comm_send_dive_exit ; abort if header contains no dive
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
606
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
607 ; get the start and end address of the profile data
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
608 MOVTT header_buffer+index_profile_start_address,ext_flash_address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
609 MOVTT header_buffer+index_profile_end_address, ext_flash_end_pointer
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
610
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
611 ; header start code sequence present?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
612 bcf aux_flag ; default to no profile available
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
613
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
614 FLASH_CW_READ_0x20 ; get the 1st byte of profile data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
615 xorlw 0xFA ; 1st byte = header start byte?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
616 bnz comm_send_dive_modify_header; NO - no profile data available
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
617
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
618 FLASH_CW_READ_0x20 ; get the 2nd byte of profile data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
619 xorlw 0xFA ; 2nd byte = header start byte?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
620 bnz comm_send_dive_modify_header; NO - no profile data available
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
621
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
622 EXT_FLASH_INC_ADDRESS_0x20 .2 ; skip the 3rd and 4th byte (dive number)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
623
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
624 FLASH_CW_READ_0x20 ; get the 5th byte of profile data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
625 xorlw 0xFA ; 5th byte = header start byte?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
626 bnz comm_send_dive_modify_header; NO - no profile data available
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
627
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
628 FLASH_CW_READ_0x20 ; get the 6th byte of profile data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
629 xorlw 0xFA ; 6th byte = header start byte?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
630 bnz comm_send_dive_modify_header; NO - no profile data available
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
631
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
632 bsf aux_flag ; memorize profile data available
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
633 bra comm_send_dive_header ; continue with sending header
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
634
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
635 comm_send_dive_modify_header:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
636 ; set profile data start and end address to 0x000000
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
637 CLRR header_buffer+index_profile_start_address,.6
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
638
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
639 ; set hi = 0x00, lo = 0x08
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
640 MOVLI 0x0008,mpr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
641
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
642 ; set byte count to 0x000008
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
643 movff lo,header_buffer+index_profile_byte_count+0 ; = 0x08
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
644 movff hi,header_buffer+index_profile_byte_count+1 ; = 0x00
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
645 movff hi,header_buffer+index_profile_byte_count+2 ; = 0x00
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
646
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
647 comm_send_dive_header:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
648 SERIAL_RR_SEND header_buffer,.256 ; send the header from the buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
649
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
650 btfss aux_flag ; profile data available?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
651 bra comm_send_dive_empty_profile; NO - send empty profile
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
652
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
653 comm_send_dive_profile:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
654 FLASH_CW_READ_0x20 ; read one byte and increment address with rollover at 0x200000
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
655 SERIAL_CC_SEND WREG ; transmit the byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
656
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
657 ; 24 bit compare of current address with end address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
658 movf ext_flash_end_pointer+0,W ; check low byte of addresses
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
659 cpfseq ext_flash_address+0 ; current address = end address ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
660 bra comm_send_dive_profile ; NO - more bytes to do, loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
661
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
662 movf ext_flash_end_pointer+1,W ; check high byte of addresses
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
663 cpfseq ext_flash_address+1 ; current address = end address ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
664 bra comm_send_dive_profile ; NO - more bytes to do, loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
665
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
666 movf ext_flash_end_pointer+2,W ; check upper byte of addresses
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
667 cpfseq ext_flash_address+2 ; current address = end address ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
668 bra comm_send_dive_profile ; NO - more bytes to do, loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
669
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
670 comm_send_dive_exit:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
671 bra comm_command_loop ; done, back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
672
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
673 comm_send_dive_empty_profile:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
674
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
675 ; send profile length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
676 SERIAL_RR_SEND header_buffer+index_profile_byte_count,.3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
677
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
678 SERIAL_LC_SEND 0xFD ; send end-of-profile sequence, byte 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
679 SERIAL_LC_SEND 0xFD ; send end-of-profile sequence, byte 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
680
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
681 bra comm_command_loop ; done, back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
682
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
683
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
684 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
685 ; Reset all Options to Factory Default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
686 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
687 comm_option_reset_all:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
688 SERIAL_LC_SEND 0x78 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
689 call option_reset_all ; reset all options to factory default
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 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
694 ; Set Custom Text (opt_name_length ASCII chars)
631
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_set_custom_text:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
697 CLRR opt_name,opt_name_length ; clear old custom text
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
698
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
699 bcf INTCON,GIE ; disable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
700 SERIAL_LC_SEND 0x63 ; acknowledge command
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
701 SERIAL_RR_RECEIVE opt_name,opt_name_length ; receive new custom text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
702 bsf INTCON,GIE ; re-enable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
703 bsf option_changed ; flag that EEPROM needs to be updated
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
704
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
705 bra comm_command_loop ; done, back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
706
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
707
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
708 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
709 ; Reset Battery Gauge
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
710 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
711 comm_reset_battery_gauge:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
712 ; SERIAL_LC_SEND 0x23 ; acknowledge command (not done)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
713 call reset_battery_gauge_and_lt2942 ; reset battery registers and battery gauge chip
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
714 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
715
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
716
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
717 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
718 ; Erase complete Logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
719 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
720 comm_erase_complete_logbook:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
721 ; SERIAL_LC_SEND 0x22 ; acknowledge command (not done)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
722 call erase_complete_logbook ; erase complete logbook
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
723 bra comm_command_loop ; done, back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
724
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
725
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
726 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
727 ; Start Bootloader (aka perform cold start)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
728 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
729 comm_cold_start:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
730 ; SERIAL_LC_SEND 0xC1 ; acknowledge command (not done)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
731
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
732 WIN_SMALL comm_status3_column, comm_status3_row ; set position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
733 FONT_COLOR_MEMO ; set standard color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
734 STRCPY_TEXT_PRINT tUsbLlBld ; print "Low-level Bootloader" message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
735
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
736 WIN_TOP comm_warning_row ; set row for icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
737 WIN_LEFT comm_warning_column ; set column for icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
738 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show a warning icon
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
739
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
740 bsf LEDr ; switch on red LED
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
741
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
742 call eeprom_deco_data_write ; update deco data in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
743 call eeprom_battery_gauge_write ; update battery gauge in EEPROM
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
744 btfsc option_changed ; do the options need to be stored to EEPROM ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
745 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
746
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
747 ; WAITS .1 ; wait 1 second to give the serial I/F time
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
748 ; ; to send the ackn before it gets shut down
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
749
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
750 goto 0x1FF0C ; jump into the bootloader code for cold start
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
751
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
752
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
753 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
754 ; Send Firmware to Bootloader (aka initiate Firmware Update)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
755 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
756 comm_firmware_update:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
757 bcf INTCON,GIE ; disable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
758 SERIAL_LC_SEND 0x50 ; acknowledge command
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
759 SERIAL_RR_RECEIVE buffer,.5 ; (try to) receive 5 byte checksum
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
760 bsf INTCON,GIE ; re-enable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
761
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
762 btfsc rs232_rx_timeout ; got all 5 bytes?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
763 bra comm_send_firmware_abort ; NO - abort
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
764
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
765 ; check the checksum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
766 movlw 0x55 ; initialize checksum check-byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
767 movwf hi ; store in hi
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
768 INIT_BUFFER ; go back to start of the buffer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
769 movlw .5 ; 5 bytes to process
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
770 movwf lo ; initialize loop counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
771 comm_firmware_update_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
772 movf POSTINC2,W ; get a checksum byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
773 xorwf hi,F ; xor checksum byte with check-byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
774 rlncf hi,F ; rotate check-byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
775 decfsz lo,F ; decrement loop counter, done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
776 bra comm_firmware_update_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
777 tstfsz hi ; YES - check-byte zero?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
778 bra comm_send_firmware_failed ; NO - checksum not valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
779
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
780 ; checksum is valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
781 SERIAL_LC_SEND 0x4C ; inform checksum is ok
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
782 WAITS .1 ; wait 1 second to give the serial I/F time
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
783 ; to send the 0x4C before it gets shut down
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
784 ;bra comm_firmware_update_exec ; execute update
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
785
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
786 global comm_firmware_update_exec
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
787 comm_firmware_update_exec:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
788 call eeprom_memorize_fw_checksum ; memorize fw checksum in EEPROM
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
789 call eeprom_deco_data_write ; update deco data in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
790 call eeprom_battery_gauge_write ; update battery gauge in EEPROM
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
791 btfsc option_changed ; do the options need to be stored to EEPROM ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
792 call option_check_and_store_all ; YES - check and store all option values in EEPROM
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
793 goto 0x1FDF0 ; jump into the bootloader code for firmware update
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
794
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
795
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
796 comm_send_firmware_failed:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
797 ; select font and output position
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
798 WIN_SMALL comm_string_column, comm_string_row
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
799 FONT_COLOR_WARNING ; set warning color
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
800 STRCPY_PRINT "Checksum failed" ; print failure message (fill to 15 chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
801 ;bra comm_send_firmware_abort ; abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
802
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
803 comm_send_firmware_abort:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
804 SERIAL_LC_SEND 0xFF ; send checksum failure message
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
805 bra comm_command_loop ; done, back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
806
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
807
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
808 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
809 ; Erase a single Block or a Range of Blocks
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
810 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
811 comm_erase_single_4kb:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
812 bcf INTCON,GIE ; disable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
813 bcf aux_flag ; do a single block only
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
814 ; SERIAL_LC_SEND 0x40 ; acknowledge command (not done)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
815 bra comm_erase_get_start ; continue with getting start address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
816
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
817 comm_erase_range_4kb:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
818 bcf INTCON,GIE ; disable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
819 bsf aux_flag ; do a range of blocks
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
820 SERIAL_LC_SEND 0x42 ; acknowledge command
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
821 ;bra comm_erase_get_start ; continue with getting start address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
822
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
823 comm_erase_get_start:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
824 rcall comm_get_start_address ; (try to) get the start address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
825 btfsc rs232_rx_timeout ; got start address?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
826 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
827 btfsc aux_flag ; YES - shall erase a range of blocks?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
828 bra comm_erase_get_count ; YES - get the block count
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
829 movlw .1 ; NO - set 1 block to do
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
830 movwf WREG ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
831 bra comm_erase_common ; - start the erasing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
832
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
833 comm_erase_get_count:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
834 SERIAL_CC_RECEIVE WREG ; (try to) receive the block count
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
835 btfsc rs232_rx_timeout ; got block count?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
836 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
837 tstfsz WREG ; YES - block count = 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
838 bra comm_erase_common ; NO - start the erasing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
839 bra comm_command_error ; YES - invalid, show error message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
840
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
841 comm_erase_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
842 bsf INTCON,GIE ; re-enable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
843 call ext_flash_erase_range ; erase #WREG 4kB blocks starting at ext_flash_address
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
844 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
845
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
846
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
847 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
848 ; Write a Stream of Bytes to the FLASH beginning at given Start Address, finish on Timeout
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
849 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
850 comm_write_range_stream:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
851 bcf INTCON,GIE ; disable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
852 SERIAL_LC_SEND 0x30 ; acknowledge command
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
853
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
854 rcall comm_get_start_address ; (try to) get the start address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
855 btfsc rs232_rx_timeout ; got a complete start address?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
856 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
857
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
858 IFDEF _comm_debug
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
859 CLRI mpr ; clear mpr to be used as a 16 bit counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
860 ENDIF
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
861
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
862 comm_write_range_stream_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
863 SERIAL_CC_RECEIVE WREG ; (try to) receive one byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
864 btfsc rs232_rx_timeout ; got a byte?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
865 IFNDEF _comm_debug
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
866 bra comm_command_loop ; NO - timeout, done, back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
867 ELSE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
868 bra comm_command_debug ; NO - timeout, done, show number of bytes received
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
869 ENDIF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
870 ; bsf NCTS ; YES - hold Bluetooth chip (requires PC/Android/iOS side to use flow control...)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
871 call ext_flash_write_byte_0x40_nowait; - write byte to FLASH, increase address with rollover at 0x400000, does not wait on FLASH
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
872 ; bcf NCTS ; - release Bluetooth chip (requires PC/Android/iOS side to use flow control...)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
873 IFDEF _comm_debug
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
874 INCI mpr ; increment counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
875 ENDIF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
876 bra comm_write_range_stream_loop ; - loop
157
5ee76921e359 make new parameters configurable through pc
heinrichsweikamp
parents: 150
diff changeset
877
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
878
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
879 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
880 ; Write a Block of 256 Bytes to the FLASH beginning at given Start Address (low byte needs to be zero)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
881 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
882 comm_write_range_block:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
883 bcf INTCON,GIE ; disable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
884 SERIAL_LC_SEND 0x31 ; acknowledge command
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
885
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
886 rcall comm_get_start_address ; (try to) get the start address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
887 btfsc rs232_rx_timeout ; got a complete start address?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
888 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
889
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
890 tstfsz ext_flash_address+0 ; low byte of start address = 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
891 bra comm_command_error ; NO - show error message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
892
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
893 SERIAL_RR_RECEIVE buffer,.256 ; (try to) receive 256 byte and buffer them in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
894 bsf INTCON,GIE ; re-enable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
895 btfsc rs232_rx_timeout ; got all 256 bytes?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
896 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
897
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
898 FLASH_RR_WRITE buffer,.256 ; copy from memory to FLASH
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
899 bra comm_command_loop ; done, back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
900
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
901
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
902 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
903 ; Read a Memory Range from FLASH given by Start Address and Byte Count
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
904 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
905 comm_read_range:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
906 bcf INTCON,GIE ; disable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
907 SERIAL_LC_SEND 0x20 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
908
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
909 ; receive start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
910 rcall comm_get_start_address ; (try to) get the start address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
911 btfsc rs232_rx_timeout ; got a complete start address?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
912 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
913
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
914 ; receive byte count
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
915 rcall comm_get_length ; (try to) get the byte count
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
916 btfsc rs232_rx_timeout ; got a complete byte count?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
917 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
918
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
919 bsf INTCON,GIE ; re-enable all interrupts
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
920
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
921 ; decrement byte counter by 1 so that all bytes will be done when the counter wraps around to 0xFFFFFF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
922 EXT_FLASH_DEC_LENGTH
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
923
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
924 ; check validity of the byte count
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
925 movlw 0x40 ; now the byte count is allowed to be 0x3FFFFF at max
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
926 cpfslt ext_flash_length_counter+2 ; length count < 0x40(0000) ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
927 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
928
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
929 ; stream bytes from FLASH
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
930 call ext_flash_read_block_start ; read first byte from FLASH into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
931 bra comm_read_range_loop_start ; jump into transmit loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
932 comm_read_range_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
933 call ext_flash_read_block_0x40 ; read next byte into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
934 comm_read_range_loop_start:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
935 SERIAL_CC_SEND WREG ; transmit byte
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
936 EXT_FLASH_DEC_LENGTH ; decrement byte counter
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
937 btfss ext_flash_length_counter+2,7; under-run?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
938 bra comm_read_range_loop ; NO - continue loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
939 call ext_flash_read_block_stop ; YES - end reading from FLASH
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
940 bra comm_command_loop ; - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
941
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
942
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
943 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
944 ; 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
945 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
946 comm_get_start_address:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
947 SERIAL_RR_RECEIVE ext_flash_address,.3 ; (try to) receive 3 bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
948 btfsc rs232_rx_timeout ; timeout?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
949 return ; YES - abort, no usable address available
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
950
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
951 ; remap address from network byte format (big endian) to host format (little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
952 movf ext_flash_address+0,W
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
953 movff ext_flash_address+2,ext_flash_address+0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
954 movwf ext_flash_address+2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
955
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
956 return ; done, complete start address available
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
957
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
958
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
959 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
960 ; Receive a 3 byte length (on serial: big-endian, in memory: little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
961 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
962 comm_get_length:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
963 SERIAL_RR_RECEIVE ext_flash_length_counter,.3 ; receive 3 bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
964 btfsc rs232_rx_timeout ; timeout?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
965 return ; YES - abort, no usable address available
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
966
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
967 ; remap address from network byte format (big endian) to host format (little-endian)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
968 movf ext_flash_length_counter+0,W
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
969 movff ext_flash_length_counter+2,ext_flash_length_counter+0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
970 movwf ext_flash_length_counter+2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
971
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
972 return ; done, complete start address available
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
973
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
974
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
975 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
976 ; Read an Option Value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
977 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
978 comm_read_option:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
979 SERIAL_LC_SEND 0x72 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
980 SERIAL_CC_RECEIVE lo ; (try to) receive option index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
981 btfsc rs232_rx_timeout ; received option index?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
982 bra comm_command_loop ; NO - show rx timeout message and back to command loop
651
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
983
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
984 ; option index 0x00 - 0x0F: unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
985 movlw 0x0F ; last option index of the unused range
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
986 cpfsgt lo ; received option index > end of unused range ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
987 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
988
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
989 ; option index 0x10 - 0x19: gases & diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
990 movlw 0x19 ; last option index for gases / diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
991 cpfsgt lo ; received option index > end of gas/dil range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
992 bra comm_read_gas_dil ; NO - process gas/dil read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
993
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
994 ; option index 0x1A - 0x1E: setpoints
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
995 movlw 0x1E ; last option index for setpoint
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
996 cpfsgt lo ; received option index > end of setpoint range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
997 bra comm_read_sp ; NO - process setpoint read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
998
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
999 ; option index = 0x49 - special handling button polarity
651
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1000 movlw 0x49
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1001 cpfseq lo ; received option index for button polarity ?
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1002 bra $+4 ; NO
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1003 bra comm_read_button_polarity ; YES - process button polarity read
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1004
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1005 ; option index 0x1F - 0xF9: options managed by option table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1006 movlw 0xF9 ; last option index for options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1007 cpfsgt lo ; received option index > end of options range?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1008 bra comm_read_option_index ; YES - process option value read via index
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1009
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1010 bra comm_command_error ; NO - illegal option index
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1011
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1012
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1013 ;-----------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1014 ; Write an Option Value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1015 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1016 comm_write_option:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1017 bcf INTCON,GIE ; disable all interrupts
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1018 SERIAL_LC_SEND 0x77 ; acknowledge command
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1019 SERIAL_CC_RECEIVE lo ; (try to) receive option index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1020 btfsc rs232_rx_timeout ; got a byte?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1021 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1022
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1023 ; option index 0x00 - 0x0F: unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1024 movlw 0x0F ; last option index of the unused range
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1025 cpfsgt lo ; received option index > end of unused range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1026 bra comm_write_unused ; NO - but need to consume the option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1027
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1028 ; option index 0x10 - 0x19: gases & diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1029 movlw 0x19 ; last option index for gases / diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1030 cpfsgt lo ; received option index > end of gas/dil range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1031 bra comm_write_gas_dil ; NO - process gas/dil write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1032
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1033 ; option index 0x1A - 0x1E: setpoints
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1034 movlw 0x1E ; last option index for setpoint
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1035 cpfsgt lo ; received option index > end of setpoint range ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1036 bra comm_write_sp ; NO - process setpoint write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1037
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1038 ; option index = 0x49 - special handling button polarity
651
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1039 movlw 0x49
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1040 cpfseq lo ; received option index for button polarity ?
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1041 bra $+4 ; NO
682c514c53c0 3.21 release preparations
heinrichsweikamp
parents: 640
diff changeset
1042 bra comm_write_button_polarity ; YES - process button polarity write
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1043
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1044 ; option index 0x1F - 0xF9: options managed by option table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1045 movlw 0xF9 ; last option index for options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1046 cpfsgt lo ; received option index > end of options range?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1047 bra comm_write_option_index ; YES - process option value write via index
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1048
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1049 bra comm_write_unused ; NO - illegal option index
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1050
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1051
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1052 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1053 ; Read an Option Value via its Serial Index
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1054 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1055 comm_read_option_index:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1056 call option_read_serial ; try to find the option and read its value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1057 tstfsz WREG ; option found?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1058 bra comm_read_setting_fail ; NO - send dummy value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1059 SERIAL_CC_SEND hi ; YES - send read value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1060 bra comm_command_loop ; - done, back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1061
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1062 comm_read_setting_fail:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1063 SERIAL_LC_SEND 0x00 ; send a dummy value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1064 bra comm_command_error ; back to command loop with failure message
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1065
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1066
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1067 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1068 ; Write an Option Value via its Serial Index
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1069 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1070 comm_write_option_index:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1071 SERIAL_CC_RECEIVE hi ; (try to) receive option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1072 btfsc rs232_rx_timeout ; got a byte?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1073 bra comm_command_timeout ; NO - abort
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1074 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
1075 tstfsz WREG ; - option found and new value valid ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1076 bra comm_command_error ; NO - back to command loop with failure message
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1077 bra comm_command_loop ; YES - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1078
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1079 comm_write_unused:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1080 SERIAL_CC_RECEIVE WREG ; consume unused option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1081 bra comm_command_error ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1082
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1083
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1084 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1085 ; Read Button Polarity
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1086 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1087 comm_read_button_polarity:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1088 SERIAL_CC_SEND button_polarity ; send current button polarity setting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1089 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1090
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1091
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1092 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1093 ; Write Button Polarity
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1094 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1095 comm_write_button_polarity:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1096 SERIAL_CC_RECEIVE hi ; (try to) receive configuration value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1097 btfsc rs232_rx_timeout ; got configuration value?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1098 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1099 movff hi,button_polarity ; YES - store button polarity in memory and EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1100 EEPROM_CC_WRITE button_polarity,eeprom_button_polarity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1101 bra comm_command_loop ; - done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1102
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1103
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1104 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1105 ; Read a Gas/Diluent Dataset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1106 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1107 ; memory map is as follows:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1108 ; -------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1109 ; 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
1110 ; 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
1111 ; 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
1112 ; 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
1113 ; opt_gas_type res 5 ; OC/bailout gas type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1114 ; opt_dil_type res 5 ; dil type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1115 ; 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
1116 ; opt_dil_change res 5 ; change depths for diluents
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1117 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1118 comm_read_gas_dil:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1119 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
1120 movlw 0x10 ; compute gas index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1121 subwf lo,W ; ...making WREG point to O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1122 SERIAL_CC_SEND PLUSW0 ; send O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1123 addlw .10 ; increment WREG by 10 to point to He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1124 SERIAL_CC_SEND PLUSW0 ; send He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1125 addlw .10 ; increment WREG by 10 to point to gas/diluent type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1126 SERIAL_CC_SEND PLUSW0 ; send gas/diluent type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1127 addlw .10 ; increment WREG by 10 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1128 SERIAL_CC_SEND PLUSW0 ; send change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1129 bra comm_command_loop ; done, back to command loop
110
d39493c786a2 BUGFIX: OSTC settings via USB issues
heinrichsweikamp
parents: 97
diff changeset
1130
79
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
1131
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1132 ; ----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1133 ; Write a Gas/Diluent Dataset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1134 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1135 ; memory map is as follows:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1136 ; -------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1137 ; 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
1138 ; 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
1139 ; 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
1140 ; 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
1141 ; opt_gas_type res 5 ; OC/bailout gas type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1142 ; opt_dil_type res 5 ; dil type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1143 ; 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
1144 ; opt_dil_change res 5 ; change depths for diluents
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1145 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1146 comm_write_gas_dil:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1147 SERIAL_RR_RECEIVE hi,.4 ; (try to) receive 4 option values
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1148 btfsc rs232_rx_timeout ; got all 4 bytes?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1149 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
1150
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1151 ; check validity of O2 value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1152 movlw gaslist_min_o2-.1 ; get min value minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1153 cpfsgt hi ; received O2% >= min ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1154 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1155 movlw gaslist_max_o2+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1156 cpfslt hi ; received O2% <= max ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1157 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1158
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1159 ; check validity of He value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1160 movlw gaslist_max_He+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1161 cpfslt up ; received O2% <= max ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1162 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1163
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1164 IFDEF _helium
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1165 ; check O2% + He% <= 100%
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1166 movlw .100 ; load WREG with 100%
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1167 bsf STATUS,C ; set carry = clear borrow
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1168 subfwb hi,W ; subtract O2% from WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1169 subfwb up,W ; subtract He% from WREG
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1170 btfss STATUS,C ; result negative?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1171 bra comm_command_error ; YES - show error message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1172 ENDIF ; _helium
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1173
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1174 ; check validity of type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1175 movlw 0x14 ; last option index for gases
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1176 cpfsgt lo ; received option index > end of gas range ?
636
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1177 bra comm_write_check_gas ; NO - check type for gases
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1178 ;bra comm_write_check_dil ; YES - check type for diluents
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1179
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1180 comm_write_check_dil:
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1181 ; check validity of type for a diluent
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1182 movlw num_dil_types ; load number of diluent types
2737ddc643bb 3.11 release
heinrichsweikamp
parents: 634
diff changeset
1183 bra comm_write_check_com ; continue with common part
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1184
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1185 comm_write_check_gas:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1186 ; check validity of type for a gas
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1187 movlw num_gas_types ; load number of gas types
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1188 ;bra comm_write_check_com ; continue with common part
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1189
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1190 comm_write_check_com:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1191 cpfslt ex ; received type < max ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1192 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1193
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1194 ; check validity of change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1195 movlw gaslist_max_change_depth+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1196 cpfslt ul ; received change depth <= max ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1197 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1198
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1199 ; all values ok, can finally be written
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1200 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
1201 movlw 0x10 ; compute gas index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1202 subwf lo,W ; ...making WREG point to O2 ratio
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1203
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1204 movff hi,PLUSW0 ; set O2 ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1205 addlw .10 ; increment WREG by 10 to point to He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1206 movff up,PLUSW0 ; set He ratio
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1207 addlw .10 ; increment WREG by 10 to point to gas/dil type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1208 movff ex,PLUSW0 ; set gas/dil type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1209 addlw .10 ; increment WREG by 10 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1210 movff ul,PLUSW0 ; set change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1211
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1212 bsf option_changed ; flag that EEPROM needs to be updated
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1213 bra comm_command_loop ; done, back to command loop
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
1214
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1215
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1216 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1217 ; Read a Setpoint Dataset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1218 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1219 ; memory map is as follows:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 593
diff changeset
1220 ; -------------------------
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1221 ; opt_setpoint_cbar res 5 ; setpoints in cbar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1222 ; opt_setpoint_change res 5 ; change depth for the setpoints in meter
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1223 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1224 comm_read_sp:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1225 lfsr FSR0,opt_setpoint_cbar ; load base address of setpoint cbar values
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1226 movlw 0x1A ; compute SP index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1227 subwf lo,W ; ...making WREG point to cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1228 SERIAL_CC_SEND PLUSW0 ; send setpoint cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1229 addlw .5 ; increment WREG by 5 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1230 SERIAL_CC_SEND PLUSW0 ; send change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1231 bra comm_command_loop ; done, back to command loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1232
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1233
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1234 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1235 ; Write a Setpoint Dataset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1236 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1237 ; memory map is as follows:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1238 ; -------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1239 ; opt_setpoint_cbar res 5 ; setpoints in cbar
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1240 ; opt_setpoint_change res 5 ; change depths in meter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1241 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1242 comm_write_sp:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1243 SERIAL_RR_RECEIVE hi,.2 ; (try to) receive 2 option values
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1244 btfsc rs232_rx_timeout ; got both bytes?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1245 bra comm_command_timeout ; NO - show rx timeout message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1246
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1247 ; check validity of setpoint value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1248 movlw gaslist_sp_min-.1 ; get min value minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1249 cpfsgt hi ; received O2% >= min ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1250 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1251 movlw gaslist_sp_max+.1 ; get max value plus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1252 cpfslt hi ; received O2% <= max ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1253 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1254
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1255 ; check validity of change depth
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1256 movlw gaslist_sp_max_depth+.1 ; get max value plus 1
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1257 cpfslt up ; received change depth <= max ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1258 bra comm_command_error ; NO - show error message and back to command loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1259
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1260 lfsr FSR0,opt_setpoint_cbar ; load base address of setpoint cbar values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1261 movlw 0x1A ; compute SP index from option index...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1262 subwf lo,W ; ...making WREG point to cbar value
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1263
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1264 bnz comm_write_sp_exec ; selected SP is 2...5 -> execute write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1265 tstfsz up ; SP1: change depth = 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1266 bra comm_command_error ; NO - show error message and back to command loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1267
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1268 comm_write_sp_exec:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1269 movff hi,PLUSW0 ; set cbar value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1270 addlw .5 ; increment WREG by 5 to point to change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1271 movff up,PLUSW0 ; set change depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1272
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1273 bsf option_changed ; flag that EEPROM needs to be updated
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
1274 bra comm_command_loop ; done, back to command loop
80
db920ca01491 new commands in download mode:
mh@mh-THINK.localdomain
parents: 79
diff changeset
1275
79
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
1276 ;-----------------------------------------------------------------------------
0fc8113ddf6d new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents: 69
diff changeset
1277
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
1278 END