comparison src/divemode.asm @ 192:efe70488a04b

voting logic for external monitoring
author heinrichsweikamp
date Mon, 03 Nov 2014 17:25:19 +0100
parents 39f6c07ce2f6
children 901c10831e4e
comparison
equal deleted inserted replaced
191:d049511b25c6 192:efe70488a04b
308 bra calc_deko_divemode2a ; Never fallback 308 bra calc_deko_divemode2a ; Never fallback
309 309
310 btfsc is_bailout ; In bailout? 310 btfsc is_bailout ; In bailout?
311 bra calc_deko_divemode2a ; Never fallback in bailout 311 bra calc_deko_divemode2a ; Never fallback in bailout
312 ; Check if we should fallback to SP1 312 ; Check if we should fallback to SP1
313 btfsc use_02_sensor1 313 btfsc use_O2_sensor1
314 bra calc_deko_divemode2a ; At least one sensor is active, no fallback 314 bra calc_deko_divemode2a ; At least one sensor is active, no fallback
315 btfsc use_02_sensor2 315 btfsc use_O2_sensor2
316 bra calc_deko_divemode2a ; At least one sensor is active, no fallback 316 bra calc_deko_divemode2a ; At least one sensor is active, no fallback
317 btfsc use_02_sensor3 317 btfsc use_O2_sensor3
318 bra calc_deko_divemode2a ; At least one sensor is active, no fallback 318 bra calc_deko_divemode2a ; At least one sensor is active, no fallback
319 ; No sensor in use -> fallback 319 ; No sensor in use -> fallback
320 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always fallback to SP1), overwrite sensor result 320 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always fallback to SP1), overwrite sensor result
321 bsf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure 321 bsf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
322 322
393 ; sum up sensor values (in xA:2) and active sensors in (xB:2) 393 ; sum up sensor values (in xA:2) and active sensors in (xB:2)
394 clrf xB+0 394 clrf xB+0
395 clrf xB+1 395 clrf xB+1
396 clrf xA+0 396 clrf xA+0
397 clrf xA+1 397 clrf xA+1
398 btfss use_02_sensor1 ; Sensor1 active? 398 btfss use_O2_sensor1 ; Sensor1 active?
399 bra divemode_setup_sensor_values2 ; No
400 btfss voting_logic_sensor1 ; Sensor within voting logic?
399 bra divemode_setup_sensor_values2 ; No 401 bra divemode_setup_sensor_values2 ; No
400 movf o2_ppo2_sensor1,W 402 movf o2_ppo2_sensor1,W
401 addwf xA+0 403 addwf xA+0
402 movlw .0 404 movlw .0
403 addwfc xA+1 ; Add into xA:2 405 addwfc xA+1 ; Add into xA:2
404 incf xB+0,F ; Add a sensor 406 incf xB+0,F ; Add a sensor
405 divemode_setup_sensor_values2: 407 divemode_setup_sensor_values2:
406 btfss use_02_sensor2 ; Sensor2 active? 408 btfss use_O2_sensor2 ; Sensor2 active?
409 bra divemode_setup_sensor_values3 ; No
410 btfss voting_logic_sensor2 ; Sensor within voting logic?
407 bra divemode_setup_sensor_values3 ; No 411 bra divemode_setup_sensor_values3 ; No
408 movf o2_ppo2_sensor2,W 412 movf o2_ppo2_sensor2,W
409 addwf xA+0 413 addwf xA+0
410 movlw .0 414 movlw .0
411 addwfc xA+1 ; Add into xA:2 415 addwfc xA+1 ; Add into xA:2
412 incf xB+0,F ; Add a sensor 416 incf xB+0,F ; Add a sensor
413 divemode_setup_sensor_values3: 417 divemode_setup_sensor_values3:
414 btfss use_02_sensor3 ; Sensor3 active? 418 btfss use_O2_sensor3 ; Sensor3 active?
419 bra divemode_setup_sensor_values4 ; No
420 btfss voting_logic_sensor3 ; Sensor within voting logic?
415 bra divemode_setup_sensor_values4 ; No 421 bra divemode_setup_sensor_values4 ; No
416 movf o2_ppo2_sensor3,W 422 movf o2_ppo2_sensor3,W
417 addwf xA+0 423 addwf xA+0
418 movlw .0 424 movlw .0
419 addwfc xA+1 ; Add into xA:2 425 addwfc xA+1 ; Add into xA:2
1221 movff WREG,active_gas ; Set for logbook and display 1227 movff WREG,active_gas ; Set for logbook and display
1222 rcall setup_gas_registers ; With WREG=Gas 0-4 1228 rcall setup_gas_registers ; With WREG=Gas 0-4
1223 return 1229 return
1224 1230
1225 dive_boot_cc: 1231 dive_boot_cc:
1232 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
1233 bsf voting_logic_sensor1
1234 bsf voting_logic_sensor2
1235 bsf voting_logic_sensor3
1226 rcall divemode_setup_sensor_values ; setup sensor values 1236 rcall divemode_setup_sensor_values ; setup sensor values
1237
1227 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor 1238 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor
1228 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1) 1239 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1)
1229 extern get_first_dil_to_WREG 1240 extern get_first_dil_to_WREG
1230 call get_first_dil_to_WREG ; Gets first gas (0-4) into WREG 1241 call get_first_dil_to_WREG ; Gets first gas (0-4) into WREG
1231 movff WREG,char_I_first_gas ; Copy for compatibility 1242 movff WREG,char_I_first_gas ; Copy for compatibility