Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/definitions.asm @ 813:c87b9f2fb2f6
wakeup from deep sleep mode automatically upon USB connect
author | heinrichsweikamp |
---|---|
date | Tue, 14 Apr 2015 14:50:11 +0200 |
parents | 4f06017d89a8 |
children | 2a0e5d884fc3 |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
803
diff
changeset
|
2 ; Copyright (C) 2015 HeinrichsWeikamp GbR |
0 | 3 |
4 ; This program is free software: you can redistribute it and/or modifyn 3 of the License, or | |
5 ; (at your option) any later version. | |
6 | |
7 ; This program is distributed in the hope that it will be useful, | |
8 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 ; GNU General Public License for more details. | |
11 | |
12 ; You should have received a copy of the GNU General Public License | |
13 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 | |
15 | |
16 ; Defines, I/O Ports and variables | |
17 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
18 ; written: 10/30/05 | |
19 ; last updated: 01/23/08 | |
163 | 20 ; 2011/01/20: [jDG] Create a common file included in ASM and C code. |
0 | 21 ; known bugs: |
22 ; ToDo: | |
23 | |
797 | 24 #DEFINE softwareversion_x d'3' ; Software version XX.YY |
809 | 25 #DEFINE softwareversion_y d'03' ; Software version XX.YY |
0 | 26 |
797 | 27 #DEFINE softwareversion_beta 0 ; (and 0 for release) |
140 | 28 |
733 | 29 #DEFINE max_custom_number d'73' ; Number of last used custom function |
0 | 30 |
178
29ff788487fc
Added German ???? & French ???? characters in small font.
JeanDo
parents:
176
diff
changeset
|
31 ; International extension. Selecting messages source: |
605 | 32 #DEFINE ENGLISH ; Use english_text.asm |
188 | 33 ;#DEFINE FRENCH ; Use french_text.asm |
535 | 34 ;#DEFINE GERMAN ; Use german_text.asm |
182 | 35 ;#DEFINE SPANISH ; Use spanish_text.asm |
424 | 36 ;#DEFINE RUSSIAN ; Use russian_text.asm |
605 | 37 ;#DEFINE ITALIAN ; Use italian_text.asm |
182 | 38 |
444 | 39 ;#DEFINE DISPLAY_TEST ; Enables Display-Test in RAW data menu |
140 | 40 |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
41 #DEFINE logbook_profile_version 0x21 ; Do not touch! |
178
29ff788487fc
Added German ???? & French ???? characters in small font.
JeanDo
parents:
176
diff
changeset
|
42 #DEFINE T0CON_debounce b'00000000' ; Timer0 Switch Debounce |
0 | 43 |
777
b92ee354baae
show bailout in logbook, 2.91 beta release
heinrichsweikamp
parents:
775
diff
changeset
|
44 ;#DEFINE __DEBUG |
463 | 45 |
46 ; CPU Speed Settings | |
47 ; Standard 16MHz mode | |
48 ; #DEFINE SPBRG_VALUE d'34' | |
49 ; #DEFINE OSCCON_VALUE b'01101100' ; 4MHz (x4 PLL) | |
537 | 50 ; #DEFINE SSPSTAT_VALUE b'00000000' ; with slew rate control (400kHz) |
463 | 51 ; #DEFINE SSPADD_VALUE d'8' ; 400kHz I2C clock @ 16MHz Fcy |
52 ; #DEFINE T0CON_VALUE b'00011111' ; Timer0 | |
485 | 53 ; #DEFINE SPEED_16MHz |
463 | 54 ; Experimental 32MHz mode |
55 #DEFINE SPBRG_VALUE d'68' | |
56 #DEFINE OSCCON_VALUE b'01111100' ; 8MHz (x4 PLL) | |
537 | 57 ; #DEFINE SSPADD_VALUE d'16' ; 400kHz I2C clock @ 32MHz Fcy |
58 #DEFINE SSPADD_VALUE d'32' ; 200kHz I2C clock @ 32MHz Fcy | |
59 #DEFINE SSPSTAT_VALUE b'00000000' ; with slew rate control | |
760 | 60 ; #DEFINE T0CON_VALUE b'00010000' ; Timer0 1:2 -> 32ms |
61 ; #DEFINE T0CON_VALUE b'00010011' ; Timer0 1:16 -> 256ms | |
62 #DEFINE T0CON_VALUE b'00010010' ; Timer0 1:8 -> 128ms | |
485 | 63 #DEFINE SPEED_32MHz |
463 | 64 |
0 | 65 #DEFINE FT_SMALL .0 |
66 #DEFINE FT_MEDIUM .1 | |
67 #DEFINE FT_LARGE .2 | |
775 | 68 #DEFINE FT_HUGE .3 |
0 | 69 |
415
d022c62a1df5
fixing issue with end-of-dive threshold in high-altitude mode
heinrichsweikamp
parents:
409
diff
changeset
|
70 ; "Better Gas" behavior |
d022c62a1df5
fixing issue with end-of-dive threshold in high-altitude mode
heinrichsweikamp
parents:
409
diff
changeset
|
71 ; better_gas_window <= minimum_change_depth ! |
d022c62a1df5
fixing issue with end-of-dive threshold in high-altitude mode
heinrichsweikamp
parents:
409
diff
changeset
|
72 ; minimum_change_depth >=5 ! |
d022c62a1df5
fixing issue with end-of-dive threshold in high-altitude mode
heinrichsweikamp
parents:
409
diff
changeset
|
73 #DEFINE minimum_change_depth .3 ; [m] |
d022c62a1df5
fixing issue with end-of-dive threshold in high-altitude mode
heinrichsweikamp
parents:
409
diff
changeset
|
74 #DEFINE better_gas_window .3 ; [m] |
d022c62a1df5
fixing issue with end-of-dive threshold in high-altitude mode
heinrichsweikamp
parents:
409
diff
changeset
|
75 |
0 | 76 ; Color Definitions: 8Bit RGB b'RRRGGGBB' |
426 | 77 #DEFINE color_red b'11100000' ; (7,0,0) |
78 #DEFINE color_dark_red b'10000101' ; (4,1,1) | |
79 #DEFINE color_violet b'11101011' ; (7,2,3) | |
80 #DEFINE color_blue b'11000111' ; (6,1,3) | |
81 #DEFINE color_green b'00011100' ; (0,7,0) | |
82 #DEFINE color_dark_green b'00111001' ; (1,6,1) | |
83 #DEFINE color_yellow b'11111101' ; (7,7,1) | |
84 #DEFINE color_white b'11111111' ; (7,7,3) | |
85 #DEFINE color_black b'00000000' ; (0,0,0) | |
86 #DEFINE color_deepblue b'00000010' ; (0,0,2) | |
87 #DEFINE color_grey b'01001010' ; (2,2,2) | |
88 #DEFINE color_cyan b'11011111' ; (6,7,3) | |
452
05ec97e106da
Minor changes: Tp? curve in orange. Ceilling stippled area.
JeanDo
parents:
450
diff
changeset
|
89 #DEFINE color_orange b'11111000' ; (7,6,0) |
426 | 90 #DEFINE color_pink b'11111010' ; (7,6,2) |
0 | 91 |
577 | 92 #DEFINE warn_depth d'1' |
93 #DEFINE warn_cns d'2' | |
94 #DEFINE warn_gf d'3' | |
95 #DEFINE warn_ppo2 d'4' | |
96 #DEFINE warn_velocity d'5' | |
97 #DEFINE warn_ceiling d'6' | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
70
diff
changeset
|
98 #DEFINE warn_gas_in_gaslist d'7' |
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
70
diff
changeset
|
99 |
0 | 100 ;Configuration bits |
101 CONFIG OSC = IRCIO67 ;Internal oscillator block, port function on RA6 and RA7 | |
102 CONFIG FCMEN = OFF ;Fail-Safe Clock Monitor disabled | |
103 CONFIG IESO = OFF ;Oscillator Switchover mode disabled | |
104 | |
105 CONFIG PWRT = ON ;PWRT enabled | |
106 CONFIG BOREN = OFF ;Brown-out Reset disabled in hardware and software | |
107 | |
108 CONFIG WDT = OFF ;WDT disabled | |
109 CONFIG WDTPS = 128 ;1:128 | |
110 | |
111 CONFIG MCLRE = ON ;MCLR pin enabled; RE3 input pin disabled | |
112 CONFIG LPT1OSC = OFF ;Timer1 configured for higher power operation | |
113 CONFIG PBADEN = OFF ;PORTB<4> and PORTB<1:0> Configured as Digital I/O Pins on Reset | |
114 | |
115 CONFIG DEBUG = OFF ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins | |
116 CONFIG XINST = OFF ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode) | |
117 CONFIG LVP = OFF ;Single-Supply ICSP disabled | |
118 CONFIG STVREN = OFF ;Stack full/underflow will not cause Reset | |
119 | |
142 | 120 ;============================================================================= |
165 | 121 ; Reserve space for C-code data space. Eg.when calling log. |
122 ; Note: overlayed with md_hash temporary space. | |
123 c_code_data_stack EQU 0x800 | |
0 | 124 |
164 | 125 ;============================================================================= |
430 | 126 ; ACCESS0 data |
127 ; | |
128 tmp0 udata_acs 0x04C ; Bank 0 ACCESS area for small tmp data. | |
129 tmp equ 0x04C | |
130 res .20 ; What is left from the C library. | |
131 | |
132 ;============================================================================= | |
164 | 133 ; BANK0 data |
134 ; | |
135 bank0 udata 0x060 ;Bank 0 | |
167 | 136 |
137 global letter, win_color1, win_top, win_leftx2 | |
138 global win_font, win_invert | |
139 global win_height, win_width, win_bargraph | |
140 | |
164 | 141 letter res .26 ;letter buffer |
142 win_color1 res 1 | |
143 win_color2 res 1 | |
681 | 144 win_color3 res 1 |
706 | 145 win_color4 res 1 |
146 win_color5 res 1 | |
147 win_color6 res 1 | |
164 | 148 win_top res 1 ; Box/text position (0..239). |
149 win_height res 1 ; Box/text height (1..240) | |
150 win_leftx2 res 1 ; Box/text position (0..159) | |
151 win_width res 1 ; box width (1..160) | |
152 win_font res 1 | |
153 win_invert res 1 | |
681 | 154 win_bargraph res 1 ; DISP_box swicth to black after this position (0..159). |
164 | 155 win_flags res 1 ; flip_screen flag, transparent fonts, etc... |
123 | 156 |
164 | 157 pressureSum res 2 ; Stabilize surface presure by a long averaging window [mbar] |
158 pressureCount res 1 ; Count of pressure values. | |
159 pressureAvg res 2 ; save averaged pressure x16, for altimeter_menu | |
160 pressureRef res 2 ; Pressure at sea level [mbar] | |
161 altitude res 2 ; Last computed altitude [m] | |
0 | 162 |
164 | 163 ;============================================================================= |
164 ; BANK1 data | |
165 ; | |
166 bank1 udata 0x100 ;Bank 1 | |
0 | 167 |
164 | 168 prod_temp res 2 ;Trashed by isr_mult16x16, for sensor compensations |
0 | 169 |
164 | 170 secs res 1 ;realtime clock |
171 mins res 1 | |
172 hours res 1 | |
173 day res 1 | |
174 month res 1 | |
175 year res 1 | |
0 | 176 |
164 | 177 waitms_temp res 1 ;variables required for wait routines |
178 wait_temp res 1 ; " + used to copy data to c code + used for temp/testing | |
179 ; never use wait_temp in interrupt routines (isr) and never call any wait routine in interrupts | |
180 | |
174 | 181 textnumber res 1 ; for textdisplay |
164 | 182 textaddress res 2 |
0 | 183 |
164 | 184 average_depth_hold res 4 ; Holds Sum of depths (Resettable) |
185 average_depth_hold_total res 4 ; Holds Sum of depths (Non-Resettable) | |
186 b0_lo res 1 ; Temp (calculate_average) | |
187 b0_hi res 1 ; Temp (calculate_average) | |
188 average_divesecs res 2 ; Used for resetable average depth display | |
189 surface_interval res 2 ; Surface Interval [mins] | |
0 | 190 |
164 | 191 flag1 res 1 ;Flag register 33 |
192 flag2 res 1 | |
193 flag3 res 1 | |
194 flag4 res 1 | |
195 flag5 res 1 ; has to be exacly here, is modified by c-code (no sensor int) | |
196 flag6 res 1 | |
197 flag7 res 1 | |
198 flag8 res 1 | |
199 flag9 res 1 | |
200 flag10 res 1 | |
201 flag11 res 1 | |
202 flag12 res 1 | |
203 flag13 res 1 | |
204 flag14 res 1 | |
205 flag15 res 1 | |
681 | 206 flag16 res 1 |
0 | 207 |
681 | 208 DISPLAY1_temp res 1 ; Temp variables for display output |
209 DISPLAY2_temp res 1 | |
210 DISPLAY3_temp res 1 | |
211 DISPLAY4_temp res 1 ; Used in "Displaytext" | |
0 | 212 |
167 | 213 global hi,lo ; Make them visible from C-code |
164 | 214 lo res 1 ; bin to dec conversion routine |
215 hi res 1 | |
216 lo_temp res 1 | |
217 hi_temp res 1 | |
218 temp3 res 1 ; used in valconv math | |
219 temp4 res 1 ; used in valconv math | |
220 ignore_digits res 1 | |
0 | 221 |
164 | 222 temp1 res 1 ; Multipurpose Temp variables used in valconv math |
223 temp2 res 1 ; used in valconv math | |
0 | 224 |
164 | 225 ext_ee_temp1 res 1 ; External EEPROM Temp 1 used in I2C EEPROM |
226 ext_ee_temp2 res 1 ; External EEPROM Temp 2 used in I2C EEPROM | |
227 | |
228 isr1_temp res 1 ; ISR temp variables | |
0 | 229 |
164 | 230 timer1int_counter1 res 1 ;Timer 1 counter |
231 timer1int_counter2 res 1 ;Timer 1 counter | |
0 | 232 |
164 | 233 uart1_temp res 1 ;RS232 temp variables |
234 uart2_temp res 1 ;70 | |
0 | 235 |
164 | 236 divA res 2 ;math routines |
237 divB res 1 | |
238 xC res 4 | |
239 xA res 2 | |
240 xB res 2 | |
241 sub_c res 2 | |
242 sub_a res 2 | |
243 sub_b res 2 | |
244 | |
245 dLSB res 1 ;Pressure sensor interface | |
246 dMSB res 1 | |
247 clock_count res 1 | |
248 ppO2_setpoint_store res 1 ; Actual setpoint | |
0 | 249 |
164 | 250 ; Pressure/Temperatuse sensor data |
251 W1 res 2 ; Raw (packed) calibration data | |
252 W2 res 2 | |
253 W3 res 2 | |
254 W4 res 2 ; 100 | |
255 C1 res 2 ; Decoded calibration data | |
256 C2 res 2 | |
257 C3 res 2 | |
704 | 258 C4 res 2 ; Here: C4-250 |
164 | 259 C5 res 2 |
260 C6 res 2 | |
261 D1 res 2 ; raw pressure | |
262 D2 res 2 ; raw temperature | |
0 | 263 |
164 | 264 isr_divA res 2 ; Data for ISR math subroutines |
265 isr_divB res 1 | |
266 isr_xC res 4 | |
267 isr_xA res 2 | |
268 isr_xB res 2 | |
0 | 269 |
164 | 270 xdT res 2 ; Tmp for temperature compensation (in ISR) |
271 xdT2 res 2 | |
272 OFF res 2 | |
273 SENS res 2 | |
0 | 274 |
398
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
275 amb_pressure_avg res 2 ; ambient pressure summing buffer[mbar] |
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
276 amb_pressure res 2 ; ambient pressure [mbar] |
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
277 rel_pressure res 2 ; amb_pressure - surface pressure [mbar] |
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
278 max_pressure res 2 ; Max. pressure for the dive [mbar] |
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
279 avr_rel_pressure res 2 ; Average rel. pressure (Average depth) for the dive [mbar], Resettable |
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
280 avr_rel_pressure_total res 2 ; Average rel. pressure (Average depth) for the dive [mbar], Non-Resettable |
164 | 281 last_pressure res 2 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
333
diff
changeset
|
282 temperature_avg res 2 ; Temperature summing buffer. |
387 | 283 temperature res 2 ; Final temperature. SIGNED. |
284 last_temperature res 2 ; Last displayed temperature (used to detect changes). | |
164 | 285 |
286 last_surfpressure res 2 ; Divemode | |
287 last_surfpressure_15min res 2 | |
288 last_surfpressure_30min res 2 | |
289 divemins res 2 ; Minutes | |
290 divesecs res 1 ; seconds | |
291 samplesecs res 1 ; counts the seconds until the next sample is stored in divemode | |
292 samplesecs_value res 1 ; holds the CF20 value | |
293 decodata res 2 ; Deco data | |
294 mintemp res 2 ; min temperature | |
295 ProfileFlagByte res 1 ; stores number of addional bytes per sample | |
777
b92ee354baae
show bailout in logbook, 2.91 beta release
heinrichsweikamp
parents:
775
diff
changeset
|
296 EventByte res 1 ; Stores the Event type plus flags |
164 | 297 AlarmType res 1 ; 0= No Alarm |
0 | 298 ; 1= SLOW |
299 ; 2= DecoStop missed | |
300 ; 3= DeepStop missed | |
301 ; 4= ppO2 Low Warning | |
302 ; 5= ppO2 High Warning | |
303 ; 6= manual marker | |
304 | |
164 | 305 divisor_temperature res 1 ; divisors for profile storage |
306 divisor_deco res 1 | |
374 | 307 divisor_gf res 1 |
164 | 308 divisor_ppo2 res 1 |
309 divisor_deco_debug res 1 | |
367 | 310 divisor_cns res 1 |
0 | 311 |
164 | 312 timeout_counter res 1 ; Timeout counter variables |
313 timeout_counter2 res 1 | |
314 timeout_counter3 res 1 ; pre-menu timeout counter | |
0 | 315 |
164 | 316 menupos res 1 ; cursor position |
317 menupos2 res 1 | |
318 menupos3 res 1 ; used in Logbook, Set Time and divemode | |
0 | 319 |
164 | 320 eeprom_address res 2 ; external EEPROM |
321 eeprom_header_address res 2 | |
0 | 322 |
164 | 323 batt_voltage res 2 ; Battery voltage in mV |
0 | 324 |
164 | 325 i2c_temp res 1 ; I²C timeout counter |
326 i2c_temp2 res 1 ; 200 | |
327 | |
398
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
328 sim_pressure res 2 ; hold simulated pressure in mbar if in Simulator mode |
0 | 329 |
164 | 330 profile_temp res 2 ; temp variable for profile view |
331 profile_temp2 res 2 ; temp variable for profile view | |
0 | 332 |
164 | 333 nofly_time res 2 ; No Fly time in Minutes (Calculated after Dive) |
334 | |
335 cf_checker_counter res 1 ; counts custom functions to check for warning symbol | |
0 | 336 |
164 | 337 char_I_O2_ratio res 1 ; 02 ratio |
338 | |
647 | 339 active_gas res 1 ; Holds number of active gas (1-5) |
340 active_diluent res 1 ; Holds number of active diluent (1-5) | |
0 | 341 |
789 | 342 debug_char res 6 ; For debugmode |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
343 |
164 | 344 apnoe_mins res 1 ; single descent minutes for Apnoe mode |
345 apnoe_secs res 1 ; single descent seconds for Apnoe mode | |
346 apnoe_max_pressure res 2 ; Max. Pressure in Apnoe mode | |
347 apnoe_timeout_counter res 1 ; counts minutes for apnoe timeout | |
348 apnoe_surface_mins res 1 ; Surface interval mins for Apnoe mode | |
349 apnoe_surface_secs res 1 ; Surface interval secs for Apnoe mode | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
560
diff
changeset
|
350 customfunction_temp1 res 1 ; used in GETCUSTOM8 and GETCUSTOM15 |
164 | 351 |
681 | 352 decoplan_page res 1 ; used in DISP_MultiGF,... |
235 | 353 temp10 res 2 ; used in customview |
0 | 354 |
164 | 355 fatal_error_code res 1 ; holds error code value |
0 | 356 |
221 | 357 convert_value_temp res 3 ; used in menu_battery_state_convert_date |
164 | 358 time_correction_value res 1 ; Adds to Seconds on midnight |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
283
diff
changeset
|
359 gaslist_active res 1 ; Holds flags for active gases |
254 | 360 desaturation_time_buffer res 2 ; buffer for desat time |
357
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
351
diff
changeset
|
361 total_divetime_seconds res 2 ; counts dive seconds regardless of CF01 (18h max.) |
164 | 362 |
598
f3735da18809
NEW: CF65: Show a safety stop for no-deco dives
heinrichsweikamp
parents:
597
diff
changeset
|
363 safety_stop_countdown res 1 ; counts seconds of safety stop |
627
8d2dc109ecfc
NEW: Gaslist highlights "better gas" in divemode
heinrichsweikamp
parents:
625
diff
changeset
|
364 better_gas_number res 1 ; number (1-5) of the "better gas" in divemode, =0: no better gas available |
598
f3735da18809
NEW: CF65: Show a safety stop for no-deco dives
heinrichsweikamp
parents:
597
diff
changeset
|
365 |
674 | 366 marker_depth res 2 ; rel. pressure [mbar] of last set marker |
367 marker_time res 3 ; divetime mins:2 and sec of last marker | |
368 | |
760 | 369 sim_btm_time res 1 ; Simulated bottom time |
370 sim_btm_depth res 1 ; Simulated max depth | |
371 sim_CNS res 1 ; Backup CNS value during decoplanning. | |
372 | |
789 | 373 on_time_seconds res 3 ; Counts on-time seconds since last full charge |
760 | 374 |
647 | 375 |
522 | 376 ASSERT_BANK1 MACRO tag |
377 Ifdef __DEBUG | |
378 local @end | |
379 movlw 1 | |
380 xorwf BSR,W | |
381 bz @end | |
382 | |
383 movlw low(tag) | |
384 movff WREG,temp10+0 | |
385 movlw high(tag) | |
529 | 386 movff WREG,temp10+1 |
681 | 387 call DISP_resetdebugger |
522 | 388 @end: |
389 Endif | |
390 ENDM | |
164 | 391 ;============================================================================= |
0 | 392 ; C-code Routines |
393 ; PART 2 | |
116 | 394 extern deco_calc_CNS_decrease_15min |
395 extern deco_calc_CNS_fraction | |
396 extern deco_calc_desaturation_time | |
397 extern deco_calc_hauptroutine | |
278 | 398 extern deco_calc_tissue |
116 | 399 extern deco_calc_percentage |
400 extern deco_calc_wo_deco_step_1_min | |
369 | 401 extern deco_calc_dive_interval |
116 | 402 extern deco_clear_CNS_fraction |
439
b9cf06de8aca
BUGFIX: Decoplanner accumulates CNS during ascent (bug #55)
JeanDo
parents:
430
diff
changeset
|
403 extern deco_calc_CNS_planning |
116 | 404 extern deco_clear_tissue |
405 extern deco_hash | |
406 extern deco_pull_tissues_from_vault | |
407 extern deco_push_tissues_to_vault | |
224 | 408 extern deco_gas_volumes |
0 | 409 |
164 | 410 ;============================================================================= |
0 | 411 ;I/O Ports (I=Input, O=Output) |
164 | 412 ; |
0 | 413 #DEFINE sensor_SDO PORTA,1 ;O |
681 | 414 #DEFINE DISPLAY_rw PORTA,2 ;0 |
415 #DEFINE DISPLAY_hv PORTA,3 ;O | |
0 | 416 #DEFINE sensor_SDI PORTA,4 ;I |
681 | 417 #DEFINE DISPLAY_cs PORTA,5 ;O |
0 | 418 #DEFINE sensor_CLK PORTA,7 ;O |
419 | |
420 #DEFINE SWITCH2 PORTB,0 ;I (Right) | |
421 #DEFINE SWITCH1 PORTB,1 ;I (Left) | |
681 | 422 #DEFINE DISPLAY_vdd PORTB,2 ;O |
0 | 423 #DEFINE LED_blue PORTB,3 ;0 |
424 #DEFINE LED_red PORTB,4 ;O | |
425 | |
426 #DEFINE CHRG_OUT PORTC,1 ;O | |
427 #DEFINE CHRG_IN PORTC,2 ;I | |
428 | |
681 | 429 #DEFINE DISPLAY_d1 PORTD,0 ;O |
430 #DEFINE DISPLAY_d2 PORTD,1 ;O | |
431 #DEFINE DISPLAY_d3 PORTD,2 ;O | |
432 #DEFINE DISPLAY_d4 PORTD,3 ;O | |
433 #DEFINE DISPLAY_d5 PORTD,4 ;O | |
434 #DEFINE DISPLAY_d6 PORTD,5 ;O | |
435 #DEFINE DISPLAY_d7 PORTD,6 ;O | |
436 #DEFINE DISPLAY_d8 PORTD,7 ;O | |
0 | 437 |
681 | 438 #DEFINE DISPLAY_rs PORTE,0 ;0 |
439 #DEFINE DISPLAY_nreset PORTE,1 ;0 | |
440 #DEFINE DISPLAY_e_nwr PORTE,2 ;0 | |
0 | 441 |
142 | 442 ; Bank0 flags |
681 | 443 #DEFINE win_flip_screen win_flags,0 ; 180° rotation of the DISPLAY screen. |
444 #DEFINE win_display_type win_flags,1 ; =1: Display1, =0: Display0 | |
142 | 445 |
0 | 446 ; Flags |
330 | 447 #DEFINE tts_extra_time flag1,0 ; Showing "Future TTS" customview |
448 #DEFINE uart_dump_screen flag1,1 ; Screen copy to USB. | |
0 | 449 #DEFINE pre_zero_flag flag1,2 ; leading zeros |
450 #DEFINE neg_flag flag1,3 ; e.g. Sub_16 (sub_c = sub_a - sub_b) | |
349
ed137d66ac65
Preparations for new "0x21" logbook format
heinrichsweikamp
parents:
344
diff
changeset
|
451 #DEFINE logbook_format_0x21 flag1,4 ; =1: New 0x21 Logbook header format |
0 | 452 #DEFINE leading_zeros flag1,5 ; display leading zeros? |
453 #DEFINE show_last3 flag1,6 ; show only three figures | |
454 #DEFINE leftbind flag1,7 ; leftbinded output | |
455 | |
456 #DEFINE onesecupdate flag2,0 ;=1 after any second | |
457 #DEFINE divemode flag2,1 ;=1 if in divemode | |
458 #DEFINE oneminupdate flag2,2 ;=1 after any minute | |
459 #DEFINE realdive flag2,3 ; dive was longer then one minute? | |
460 #DEFINE sleepmode flag2,4 ;=1 if in sleepmode | |
598
f3735da18809
NEW: CF65: Show a safety stop for no-deco dives
heinrichsweikamp
parents:
597
diff
changeset
|
461 #DEFINE safety_stop_active flag2,5 ;=1 The safety stop is currently displayed |
0 | 462 #DEFINE premenu flag2,6 ; Premenu/Divemenu selected |
463 #DEFINE menubit flag2,7 ; menu | |
464 | |
465 #DEFINE menubit2 flag3,0 ; menu | |
466 #DEFINE menubit3 flag3,1 ; menu | |
467 #DEFINE set_minutes flag3,2 ; set minutes (not hours) | |
578 | 468 #DEFINE internal_eeprom_write3 flag3,3 ;=1: start routine to access internal EEPROM BANK 2 via the UART |
0 | 469 #DEFINE menubit4 flag3,4 ; quit set time |
470 #DEFINE display_velocity flag3,5 ; velocity is displayed | |
471 #DEFINE temp_changed flag3,6 ; temperature changed | |
472 #DEFINE pres_changed flag3,7 ; pressure changed | |
473 | |
474 #DEFINE set_year flag4,0 ; Menu Settime | |
666 | 475 #DEFINE use_aGF flag4,0 ; =1: Use alternative GF in divemode |
0 | 476 #DEFINE set_day flag4,1 ; Menu Settime |
477 #DEFINE set_month flag4,2 ; Menu Settime | |
478 #DEFINE store_sample flag4,3 ;=1 after any CF20 seconds in divemode | |
479 #DEFINE divemode2 flag4,4 ; displayed divetime stopped? | |
480 #DEFINE header_stored flag4,5 ; header already stored | |
481 #DEFINE first_FD flag4,6 ; 1st 0xFD in EEPROM found | |
482 #DEFINE first_FA flag4,6 ; 1st 0xFA in EEPROM found | |
483 #DEFINE second_FD flag4,7 ; 2nd 0xFD in EEPROM found | |
484 #DEFINE second_FA flag4,7 ; 2nd 0xFA in EEPROM found | |
485 | |
408
3e0192f6c241
NEW: End-of-Dive countdown displayed after surfacing
heinrichsweikamp
parents:
406
diff
changeset
|
486 #DEfINE timeout_display flag5,0 ; =1: The divemode timeout is displayed |
0 | 487 #DEFINE eeprom_blockwrite flag5,1 ; EEPROM blockwrite active |
681 | 488 #DEFINE DISPLAY_brightness_high flag5,2 ; =1: High brightness, =0: Eco mode |
0 | 489 #DEFINE low_battery_state flag5,3 ;=1 if battery low |
490 #DEFINE DP_done flag5,4 ; valconv | |
491 #DEFINE DP_done2 flag5,5 ; valconv | |
492 #DEFINE pressure_refresh flag5,6 ; Pressure and temperature refreshed | |
493 #DEFINE no_sensor_int flag5,7 ; block any further access to pressure sensor | |
494 | |
495 #DEFINE cc_active flag6,0 ;=1: Constant Current mode aktive (Charger) | |
496 #DEFINE cv_active flag6,1 ;=1: Constant Voltage mode aktive (Charger) | |
497 #DEFINE ignore_digit5 flag6,2 ;=1: ignores digit 5 in valconv | |
498 #DEFINE switch_left flag6,3 ;=1: left switch pressed | |
499 #DEFINE switch_right flag6,4 ;=1: right switch pressed | |
500 #DEFINE uart_settime flag6,5 ;=1: enter time sync routine | |
455
c512a868937c
last work for 2.0: Fixing 32kB boundary read for logbook
heinrichsweikamp
parents:
453
diff
changeset
|
501 #DEFINE eeprom_switched_b1 flag6,6 ;=1: EEPROM read switched to bank1 |
0 | 502 #DEFINE twosecupdate flag6,7 ;=1: after any two seconds |
503 | |
504 #DEFINE dekostop_active flag7,0 ;=1: in deocompression mode | |
505 #DEFINE all_dives_shown flag7,1 ;=1: all dives in loogbook shown, abort further scanning | |
506 #DEFINE return_from_profileview flag7,2 ;=1: set cursor to same position again | |
507 #DEFINE logbook_profile_view flag7,3 ;=1: Show details/profile in logbook | |
508 #DEFINE logbook_page_not_empty flag7,4 ;=1: actual logbook page is not empty | |
509 #DEFINE dump_external_eeprom flag7,5 ;=1: enter download-routine | |
510 #DEFINE simulatormode_active flag7,6 ;=1: Simulator mode active, override pressure sensor readings | |
511 #DEFINE all_zeros_flag flag7,7 ;=1: display all zeros from here (valconv_v2.asm) | |
512 | |
513 #DEFINE internal_eeprom_write flag8,0 ;=1: start routine to access internal EEPROM BANK 0 via the UART | |
514 #DEFINE update_divetime flag8,1 ;=1: update divetime display | |
515 #DEFINE display_set_xgas flag8,2 ;=1: Display Set Gas menu in Divemode | |
516 #DEFINE FLAG_active_descent flag8,3 ;=1: A Descent in Apnoe mode is active | |
517 #DEFINE display_see_deco flag8,4 ;=1: Display decoplan in Divemode | |
518 #DEFINE display_set_gas flag8,5 ;=1: Display Gaslist menu in Divemode | |
398
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
393
diff
changeset
|
519 #DEFINE high_altitude_mode flag8,6 ;=1: Unit was manually turned on with ambient pressure <880mbar |
0 | 520 #DEFINE rs232_recieve_overflow flag8,7 ;=1: An RS232 timeout overflow occoured |
521 | |
522 #DEFINE nofly_active flag9,0 ;=1: Do not fly! | |
523 #DEFINE ppO2_display_active flag9,1 ;=1: ppO2 value is displayed | |
524 #DEFINE ppO2_show_value flag9,2 ;=1: show ppO2 value! | |
598
f3735da18809
NEW: CF65: Show a safety stop for no-deco dives
heinrichsweikamp
parents:
597
diff
changeset
|
525 #DEFINE uart_reset_battery_stats flag9,3;=1: Reset the battery statistics (UART String FFF) |
0 | 526 #DEFINE ignore_digit3 flag9,4 ;=1: ignores digits 3-5 in valconv |
598
f3735da18809
NEW: CF65: Show a safety stop for no-deco dives
heinrichsweikamp
parents:
597
diff
changeset
|
527 #DEFINE show_safety_stop flag9,5 ;=1: Show the safety stop |
0 | 528 #DEFINE output_to_postinc_only flag9,6 ;=1: Do not call wordprocessor in output |
529 #DEFINE uart_send_hash flag9,7 ;=1: Send the MD2 hash via UART | |
530 | |
64 | 531 #DEFINE last_ceiling_gf_shown flag10,0 ;=1: Last stop already shown |
0 | 532 #DEFINE uart_send_int_eeprom flag10,1 ;=1: Send internal EEPROM BANK 0 |
533 #DEFINE uart_reset_decodata flag10,2 ;=1: Reset deco data | |
534 #DEFINE manual_gas_changed flag10,3 ;=1: Manual Gas changed during dive | |
535 #DEFINE stored_gas_changed flag10,4 ;=1: Stored Gas changed during dive | |
536 #DEFINE event_occured flag10,5 ;=1: An Event has occured during the current sample interval | |
537 #DEFINE new_profile_format flag10,6 ;=1: Current Dive in Logbook uses new ProfileFormat | |
538 #DEFINE gauge_mode flag10,7 ;=1: Gauge mode active | |
539 | |
540 #DEFINE FLAG_const_ppO2_mode flag11,0 ;=1: const ppO2 mode active | |
541 #DEFINE gas_setup_page2 flag11,1 ;=1: page two of gassetup active | |
542 #DEFINE logbook_header_drawn flag11,2 ;=1: The "Logbook" Header in the List view is already drawn | |
543 #DEFINE ignore_digit4 flag11,3 ;=1: Ignores digits 4-5 in valconv | |
544 #DEFINE charge_done flag11,4 ;=1: Complete charge cycle done | |
545 #DEFINE initialize_battery1 flag11,5 ;=1: Battery memory need to be initialised | |
665
259e4c1bf3c2
grey-out TTS and ceiling after gas change (until new plan is ready)
heinrichsweikamp
parents:
660
diff
changeset
|
546 #DEFINE decoplan_invalid flag11,6 ;=1: Decoplan still invalid (After a gas change) |
0 | 547 #DEFINE charge_started flag11,7 ;=1: Charger started in CC mode |
548 | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
273
diff
changeset
|
549 #DEFINE setpoint_changed flag12,0 ;=1: Setpoint was changed in divemode, store in profile |
283
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
278
diff
changeset
|
550 #DEFINE uart_115200_bootloader flag12,1 ;=1: Look for 115200 Baud bootloader |
0 | 551 #DEFINE debug_mode flag12,2 ;=1: Debugmode active |
552 #DEFINE neg_flag_isr flag12,3 ;=1: ISR Negative flag (Math) | |
553 #DEFINE select_bailoutgas flag12,4 ;=1: Select Bailout instead of Setpoint in Gaslist | |
554 #DEFINE FLAG_apnoe_mode flag12,5 ;=1: Apnoe mode selected | |
578 | 555 #DEFINE uart_send_int_eeprom3 flag12,6 ;=1: Send internal EEPROM BANK 2 |
0 | 556 #DEFINE uart_send_int_eeprom2 flag12,7 ;=1: Send internal EEPROM BANK 1 |
557 | |
558 #DEFINE internal_eeprom_write2 flag13,0 ;=1: start routine to access internal EEPROM BANK 1 via the UART | |
559 #DEFINE button_delay_done flag13,1 ;=1: Button was pressed for more then 500ms, start counting | |
219
b6dd54b3567c
NEW: De/Activate gases underwater (Gaslist -> Gas6.. -> Actve?)
heinrichsweikamp
parents:
215
diff
changeset
|
560 #DEFINE display_set_active flag13,2 ;=1: De/Activate gases underwater menu is visible |
0 | 561 #DEFINE deco_mode_changed flag13,3 ;=1: The Decomode was changes, show decomode description! |
681 | 562 #DEFINE DISP_velocity_display flag13,4 ;=1: Velocity is displayed |
517 | 563 #DEFINE depth_greater_100m flag13,5 ;=1: Depth is greater then 100m |
0 | 564 #DEFINE display_set_setpoint flag13,6 ;=1: SetPoint list active |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
97
diff
changeset
|
565 #DEFINE toggle_customview flag13,7 ;=1: Next customview |
0 | 566 |
567 #DEFINE enter_error_sleep flag14,0 ;=1: Sleep immediately displaying the error using LED codes | |
647 | 568 #DEFINE display_set_diluent flag14,1 ;=1: Diluent list active |
3 | 569 #DEFINE is_bailout flag14,2 ;=1: CC mode, but bailout active! |
0 | 570 #DEFINE standalone_simulator flag14,3 ;=1: Standalone Simulator active |
571 #DEFINE display_set_simulator flag14,4 ;=1: Show Divemode simulator menu | |
572 #DEFINE displaytext_high flag14,5 ;=1: Show/Use Texts 255-511 in Texttable | |
8 | 573 #DEFINE better_gas_available flag14,6 ;=1: A better gas is available and a gas change is advised in divemode |
482
8e1fb9cdd62a
lock sensor for surfacemode until value is stable
heinrichsweikamp
parents:
481
diff
changeset
|
574 #DEFINE s_unlock_after_sleep flag14,7 ;=1: Sensor unlocked for divemode and battery history |
0 | 575 |
576 #DEFINE restore_deco_data flag15,0 ;=1: Restore Decodata after the dive from 0x380 buffer | |
577 #DEFINE uart_store_tissue_data flag15,1 ;=1: Store tissue data for next simualted dive! | |
111 | 578 #DEFINE reset_average_depth flag15,2 ;=1: Average Depth will be resetted |
17 | 579 #DEFINE blinking_better_gas flag15,3 ;=1: Gas is currently blinking |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
97
diff
changeset
|
580 #DEFINE menu3_active flag15,4 ;=1: menu entry three in divemode menu is active |
137 | 581 #DEFINE no_deco_customviews flag15,5 ;=1: Selected mode is Apnoe or Gauge |
517 | 582 #DEFINE maxdepth_greater_100m flag15,6 ;=1: Max Depth greater>100m |
253
3a4096f32526
show CNS in logbook for all dives made with V1.84beta and later
heinrichsweikamp
parents:
248
diff
changeset
|
583 #DEFINE show_cns_in_logbook flag15,7 ;=1: Show CNS value in logbook (>= V1.84) |
0 | 584 |
730 | 585 #DEFINE store_bailout_event flag16,0 ;=1: Store the bailout event |
780 | 586 #DEFINE gaschange_cnt_active flag16,1 ;=1: The gas switch countdown is active |
253
3a4096f32526
show CNS in logbook for all dives made with V1.84beta and later
heinrichsweikamp
parents:
248
diff
changeset
|
587 |