comparison code_part1/OSTC_code_asm_part1/sleepmode.asm @ 341:2144f19fa1eb

BUGFIX protect against ISR changing pressure/temperature while reading it.
author JeanDo
date Fri, 20 May 2011 00:48:30 +0200
parents ceedf078b2d8
children cec312042b94 562f1bc79f3c
comparison
equal deleted inserted replaced
340:ecbbbd423e86 341:2144f19fa1eb
76 76
77 call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only 77 call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only
78 movlb b'00000001' 78 movlb b'00000001'
79 movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure 79 movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure
80 movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure 80 movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure
81 movff amb_pressure+0,last_surfpressure_15min+0 ; save new airpressure 81 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure
82 movff amb_pressure+1,last_surfpressure_15min+1 ; save new airpressure
83 82
84 clrf divemins+1 ; reset counter 83 clrf divemins+1 ; reset counter
85 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi 84 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi
86 movff lo,sub_a+0 ; max. "allowed" airpressure in mBar 85 movff lo,sub_a+0 ; max. "allowed" airpressure in mBar
87 movff hi,sub_a+1 86 movff hi,sub_a+1
96 movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar 95 movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar
97 movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar 96 movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar
98 97
99 onemin_sleep2: 98 onemin_sleep2:
100 ;calc_deko_sleepmode: 99 ;calc_deko_sleepmode:
101 movff amb_pressure+0,int_I_pres_respiration+0 ; LOW copy pressure to deco routine 100 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine
102 movff amb_pressure+1,int_I_pres_respiration+1 ; HIGH
103 GETCUSTOM8 d'11' ; Saturation multiplier % 101 GETCUSTOM8 d'11' ; Saturation multiplier %
104 movff WREG,char_I_saturation_multiplier 102 movff WREG,char_I_saturation_multiplier
105 GETCUSTOM8 d'12' ; Desaturation multiplier % 103 GETCUSTOM8 d'12' ; Desaturation multiplier %
106 movff WREG,char_I_desaturation_multiplier 104 movff WREG,char_I_desaturation_multiplier
107 call deco_calc_wo_deco_step_1_min ; "calc_tissue_sleep" 105 call deco_calc_wo_deco_step_1_min ; "calc_tissue_sleep"
132 130
133 ; compare current ambient pressure with threshold 131 ; compare current ambient pressure with threshold
134 GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi 132 GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi
135 movff lo,sub_a+0 ; power on if ambient pressure is greater threshold 133 movff lo,sub_a+0 ; power on if ambient pressure is greater threshold
136 movff hi,sub_a+1 134 movff hi,sub_a+1
137 movff amb_pressure+0,sub_b+0 135 SAFE_2BYTE_COPY amb_pressure, sub_b
138 movff amb_pressure+1,sub_b+1
139 call sub16 ; sub_c = sub_a - sub_b 136 call sub16 ; sub_c = sub_a - sub_b
140 bsf sleepmode 137 bsf sleepmode
141 btfsc neg_flag ; Wake up from Sleep? 138 btfsc neg_flag ; Wake up from Sleep?
142 bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up! 139 bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up!
143 clrf divemins+0 140 clrf divemins+0