comparison src/divemode.asm @ 277:24daa6523218

1.79beta - update internal sensor registers during boot
author heinrichsweikamp
date Mon, 18 May 2015 14:24:50 +0200
parents 653a3ab08062
children 14719662fb95
comparison
equal deleted inserted replaced
276:e4cb495aed3d 277:24daa6523218
307 btfsc setpoint_fallback ; Are we in Fallback? 307 btfsc setpoint_fallback ; Are we in Fallback?
308 rcall check_fallback_clear ; Yes, check if we still have fallback condition 308 rcall check_fallback_clear ; Yes, check if we still have fallback condition
309 309
310 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure 310 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
311 311
312 btfss FLAG_ccr_mode ; In CCR mode? 312 btfsc FLAG_ccr_mode ; In CCR mode?
313 bra calc_deko_divemode2a ; Skip all the following if not in CCR mode 313 rcall calc_deko_divemode_sensor ; External sensor stuff
314 314
315 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor
316 bra calc_deko_divemode2a
317 rcall divemode_setup_sensor_values ; Setup sensor values
318 call check_sensors ; Check O2 sensor thresholds for fallback
319 movff sensor_setpoint,char_I_const_ppO2; Copy sensor result
320
321 TSTOSS opt_sensor_fallback ; =1: Fallback to SP1 when sensor is lost
322 bra calc_deko_divemode2a ; Never fallback
323
324 btfsc is_bailout ; In bailout?
325 bra calc_deko_divemode2a ; Never fallback in bailout
326 ; Check if we should fallback to SP1
327 btfsc use_O2_sensor1
328 bra calc_deko_divemode2a ; At least one sensor is active, no fallback
329 btfsc use_O2_sensor2
330 bra calc_deko_divemode2a ; At least one sensor is active, no fallback
331 btfsc use_O2_sensor3
332 bra calc_deko_divemode2a ; At least one sensor is active, no fallback
333 ; No sensor in use -> fallback
334 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always fallback to SP1), overwrite sensor result
335 bsf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
336
337 calc_deko_divemode2a:
338 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; C-code needs the ambient pressure 315 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; C-code needs the ambient pressure
339 clrf WREG 316 clrf WREG
340 movff WREG,char_I_step_is_1min ; Force 2 second deco mode 317 movff WREG,char_I_step_is_1min ; Force 2 second deco mode
341 318
342 clrf TMR5L 319 clrf TMR5L
390 movff WREG,char_O_deco_status ; Stole next cycles for @5 variant. 367 movff WREG,char_O_deco_status ; Stole next cycles for @5 variant.
391 368
392 movlw .2 ; Restart countdown. 369 movlw .2 ; Restart countdown.
393 movwf apnoe_mins 370 movwf apnoe_mins
394 return ; done. 371 return ; done.
372
373 calc_deko_divemode_sensor: ; External sensor stuff
374 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor
375 return
376 rcall divemode_setup_sensor_values ; Setup sensor values
377 call check_sensors ; Check O2 sensor thresholds for fallback
378 movff sensor_setpoint,char_I_const_ppO2; Copy sensor result
379
380 TSTOSS opt_sensor_fallback ; =1: Fallback to SP1 when sensor is lost
381 return ; Never fallback
382
383 btfsc is_bailout ; In bailout?
384 return ; Never fallback in bailout
385 ; Check if we should fallback to SP1
386 btfsc use_O2_sensor1
387 return ; At least one sensor is active, no fallback
388 btfsc use_O2_sensor2
389 return ; At least one sensor is active, no fallback
390 btfsc use_O2_sensor3
391 return ; At least one sensor is active, no fallback
392 ; No sensor in use -> fallback
393 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always fallback to SP1), overwrite sensor result
394 bsf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
395 return
395 396
396 ;----------------------------------------------------------------------------- 397 ;-----------------------------------------------------------------------------
397 398
398 divemodemode_togglegf: ; Toggle aGF/GF 399 divemodemode_togglegf: ; Toggle aGF/GF
399 bcf toggle_gf ; clear flag 400 bcf toggle_gf ; clear flag
1280 incf char_I_first_gas,F ; 0-4 -> 1-5 1281 incf char_I_first_gas,F ; 0-4 -> 1-5
1281 banksel common 1282 banksel common
1282 return 1283 return
1283 1284
1284 dive_boot_cc: 1285 dive_boot_cc:
1286 bcf is_bailout ; =1: Bailout
1287 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
1288 bcf blinking_setpoint ; Reset blinking SP flag
1285 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays 1289 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
1286 bsf voting_logic_sensor1 1290 bsf voting_logic_sensor1
1287 bsf voting_logic_sensor2 1291 bsf voting_logic_sensor2
1288 bsf voting_logic_sensor3 1292 bsf voting_logic_sensor3
1289 rcall divemode_setup_sensor_values ; setup sensor values 1293 rcall divemode_setup_sensor_values ; setup sensor values
1295 movff WREG,char_I_first_gas ; Copy for compatibility 1299 movff WREG,char_I_first_gas ; Copy for compatibility
1296 rcall setup_dil_registers ; With WREG=Gas 0-4 1300 rcall setup_dil_registers ; With WREG=Gas 0-4
1297 banksel char_I_first_gas 1301 banksel char_I_first_gas
1298 incf char_I_first_gas,F ; 0-4 -> 1-5 1302 incf char_I_first_gas,F ; 0-4 -> 1-5
1299 banksel common 1303 banksel common
1304 rcall calc_deko_divemode_sensor ; External sensor stuff
1300 return 1305 return
1301 1306
1302 diveloop_boot: 1307 diveloop_boot:
1303 call restart_set_modes_and_flags 1308 call restart_set_modes_and_flags
1304 1309
1321 clrf apnoe_surface_mins 1326 clrf apnoe_surface_mins
1322 clrf apnoe_surface_secs 1327 clrf apnoe_surface_secs
1323 clrf apnoe_mins 1328 clrf apnoe_mins
1324 clrf divemins+0 1329 clrf divemins+0
1325 clrf divemins+1 1330 clrf divemins+1
1326 bcf no_more_divesecs ; =1: Do no longer show seconds in divemode 1331 bcf no_more_divesecs ; =1: Do no longer show seconds in divemode
1327 bcf divemode_menu_active 1332 bcf divemode_menu_active
1328 clrf menupos 1333 clrf menupos
1329 clrf menupos2 ; Reset to zero (Zero=no premenu or simulator task) 1334 clrf menupos2 ; Reset to zero (Zero=no premenu or simulator task)
1330 1335
1331 bcf is_bailout ; =1: Bailout
1332 btfss FLAG_ccr_mode 1336 btfss FLAG_ccr_mode
1333 rcall dive_boot_oc 1337 rcall dive_boot_oc
1334 btfsc FLAG_ccr_mode 1338 btfsc FLAG_ccr_mode
1335 rcall dive_boot_cc 1339 rcall dive_boot_cc
1336 1340