annotate src/sleepmode.asm @ 626:be8787f2034d

compass3 support for 3.01 branch
author heinrichsweikamp
date Sun, 23 Jun 2019 15:21:16 +0200
parents ca4556fb60b9
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 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
3 ; File sleepmode.asm Version 2.99e
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Sleepmode
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
8 ;==============================================================================
0
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-12 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
12 #include "hwos.inc" ; Mandatory header
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
14 #include "surfmode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
15 #include "tft.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
16 #include "isr.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
17 #include "start.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
18 #include "adc_lightsensor.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
19 #include "math.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
20 #include "ms5541.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
21 #include "wait.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
22 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
23 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
24 #include "ghostwriter.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
25 #include "i2c.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
26 #include "mcp.inc"
0
heinrichsweikamp
parents:
diff changeset
27
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 123
diff changeset
28
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
29 extern vault_decodata_into_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
30
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
31
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
32 ;---- Private local variables -------------------------------------------------
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 123
diff changeset
33
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
34 CBLOCK local1 ; max size is 16 Byte !!!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
35 sm_temp1 ; sleepmode temporary 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
36 sm_temp2 ; sleepmode temporary 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
37 sm_timer1 ; timer for pressure check every 10 seconds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
38 sm_timer2 ; timer for 10 minutes tasks (updating of tissues)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
39 sm_timer3 ; timer for 15 minutes tasks (updating of surface pressure)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
40 ENDC ; used: 5 byte, remaining: 11 byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
41
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
42
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
43 slmode CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
44
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
45 ;==============================================================================
0
heinrichsweikamp
parents:
diff changeset
46
heinrichsweikamp
parents:
diff changeset
47 global sleeploop
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
48 sleeploop: ; enter sleep mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
49 call disable_ir_s8 ; IR/S8 off
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
50 call mcp_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
51 bcf LEDg
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
52 bcf LEDr
0
heinrichsweikamp
parents:
diff changeset
53 call TFT_Display_FadeOut
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
54 call TFT_DisplayOff ; display off
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
55
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
56 IFDEF _screendump
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
57 bcf enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (screen dump)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
58 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
59
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
60 call disable_rs232 ; USB off
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
61 call vault_decodata_into_eeprom ; store deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
62 call ext_flash_enable_protection ; enable write protection for external flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
63 call update_battery_registers ; update battery registers into EEPROM
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
64 clrf sm_temp1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
65 clrf sm_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
66 clrf sm_timer1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
67 clrf sm_timer2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
68 clrf sm_timer3
626
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
69 ; call speed_normal
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
70 call speed_eco
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
71 bsf no_sensor_int ; inhibit sensor interrupts
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
72 clrf ADCON0 ; power-down ADC module
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
73
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
74 sleeploop_pre:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
75 bcf deep_sleep ; normal sleep mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
76 call I2C_sleep_accelerometer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
77 call I2C_sleep_compass
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
78 btfss analog_switches ; OSTC with analog switches?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
79 bra sleeploop_loop ; NO - no analog switches
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
80
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
81 bsf power_sw1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
82 btfss power_sw1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
83 bra $-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
84 bsf power_sw2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
85 btfss power_sw2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
86 bra $-4
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
87 movlw .4 ; wait for button circuity
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
88 movwf sm_temp1 ; used as temp
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
89 bcf onesecupdate
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
90
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
91 sleeploop_pre1:
491
66b9b8c082a9 minor new sleepmode fix
heinrichsweikamp
parents: 490
diff changeset
92 rcall sleepmode_sleep
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
93 btfss onesecupdate ; wait 1 second
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
94 bra sleeploop_pre1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
95 bcf onesecupdate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
96 decfsz sm_temp1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
97 bra sleeploop_pre1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
98 movlw .32 ; wait for button circuity
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
99 movwf sm_temp1 ; used as temp
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
100
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
101 sleeploop_pre2:
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
102 call get_analog_switches
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
103 decfsz sm_temp1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
104 bra sleeploop_pre2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
105
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
106 bcf PIR1,TMR1IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
107 bcf INTCON,INT0IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
108 bcf INTCON3,INT1IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
109 bcf PIR5,TMR7IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
110 bcf switch_left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
111 bcf switch_right
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
112 bcf analog_sw2_pressed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
113 bcf analog_sw1_pressed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
114 bsf PIE1,0 ; (re)start timer 1 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
115 bsf PIE2,1 ; (re)start timer 2 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
116 bsf PIE5,3 ; (re)start timer 7 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
117 bsf INTCON,4 ; (re)start INT0 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
118 bsf INTCON3,3 ; (re)start INT1 interrupt
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
119
0
heinrichsweikamp
parents:
diff changeset
120 sleeploop_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
121 btfsc onesecupdate ; one second in sleep?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
122 rcall onesec_sleep ; check switches, check pressure sensor, etc.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
123
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
124 btfss sleepmode ; wake up? (This bit will be set in other routines)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
125 goto restart ; YES
0
heinrichsweikamp
parents:
diff changeset
126
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
127 btfsc deep_sleep ; enter deep sleep?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
128 bra deepsleep ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
129
491
66b9b8c082a9 minor new sleepmode fix
heinrichsweikamp
parents: 490
diff changeset
130 no_deepsleep:
626
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
131 bcf deep_sleep ; Clear flag to avoid putting the unit into deep sleep immediately when removed from charger
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
132 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5ms timer7 wakeup)
0
heinrichsweikamp
parents:
diff changeset
133
heinrichsweikamp
parents:
diff changeset
134 ; Any button pressed in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
135 ; btfsc switch_left
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
136 ; rcall onesec_sleep1a
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
137 ; btfsc switch_right
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
138 ; rcall onesec_sleep1a
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
139 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
140 ; btfss sleepmode ; wake up? (this bit will be set in other routines)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
141 ; goto restart ; YES
0
heinrichsweikamp
parents:
diff changeset
142
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
143 bra sleeploop_loop ; do loop until something happens
0
heinrichsweikamp
parents:
diff changeset
144
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
145 deepsleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
146 btfss analog_switches
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
147 bra no_deepsleep ; no analog switches, no deep sleep required
626
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
148 btfsc cc_active ; Charging?
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
149 bra no_deepsleep ; Yes, no deep sleep required
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
150
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
151 bcf PIE1,0 ; stop timer 1 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
152 bcf PIE2,1 ; stop timer 2 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
153 bcf PIE5,3 ; stop timer 7 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
154 bcf INTCON,4 ; stop INT0 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
155 bcf INTCON3,3 ; stop INT1 interrupt
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
156 bcf power_sw1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
157 bcf power_sw2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
158 rcall deepsleep_get_accel ; read accelerometer into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
159 movwf sm_temp1 ; store init value
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
160
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
161 deepsleep_loop:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
162 btfsc onesecupdate ; one second in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
163 rcall onesec_deepsleep ; YES - check accelerometer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
164
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
165 btfsc onesecupdate ; one second in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
166 rcall onesec_sleep ; YES - check switches, check pressure sensor, etc.
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
167
626
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
168 btfsc cc_active ; Charging?
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
169 bcf deep_sleep ; Yes, no deep sleep required
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
170
491
66b9b8c082a9 minor new sleepmode fix
heinrichsweikamp
parents: 490
diff changeset
171 rcall sleepmode_sleep
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
172
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
173 btfss deep_sleep ; enter normal sleep mode?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
174 bra sleeploop_pre ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
175
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
176 bra deepsleep_loop ; do loop until something happens
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
177
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
178 onesec_deepsleep:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
179 rcall deepsleep_get_accel ; read accelerometer into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
180 subwf sm_temp1,W ; sm_temp1 - accel_DZ+0 -> WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
181 btfsc STATUS,N ; result negative?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
182 negf WREG ; YES - negate it
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
183 movwf sm_temp2 ; change of acceleration in Z-axis
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
184 movlw .50 ; threshold (mg)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
185 cpfslt sm_temp2 ; bigger then the threshold?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
186 bcf deep_sleep ; YES
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
187
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
188 ; extern piezo_config_tx
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
189 ; movff sm_temp1,WREG
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
190 ; call piezo_config_tx
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
191 ; movff accel_DZ+0,WREG
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
192 ; call piezo_config_tx
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
193 ; movff sm_temp2,WREG
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
194 ; call piezo_config_tx
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
195
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
196 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
197
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
198 deepsleep_get_accel:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
199 call I2C_init_compass ; required for compass1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
200 call I2C_init_accelerometer ; required for compass2
626
be8787f2034d compass3 support for 3.01 branch
heinrichsweikamp
parents: 604
diff changeset
201 rcall sleepmode_sleep
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
202 call I2C_RX_accelerometer ; read accelerometer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
203 call I2C_sleep_compass ; required for compass1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
204 call I2C_sleep_accelerometer ; required for compass2
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
205 movff accel_DZ+0,WREG
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
206 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
207
134
4574aed5cd4c Show clock in Apnea mode, minor layout changes in Apnea mode
heinrichsweikamp
parents: 133
diff changeset
208 onehour_sleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
209 call update_battery_registers ; update battery registers into EEPROM
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
210 call vault_decodata_into_eeprom ; update deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
211 bcf onehourupdate ; all done
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
212 return
0
heinrichsweikamp
parents:
diff changeset
213
heinrichsweikamp
parents:
diff changeset
214 onemin_sleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
215 btfsc onehourupdate ; one hour in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
216 rcall onehour_sleep ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
217
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
218 btfsc battery_gauge_available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
219 call get_battery_voltage ; check for charger
198
c511dc403d7e (Slightly) reduce current consumption in Eco and sleep mode
heinrichsweikamp
parents: 134
diff changeset
220
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
221 ;---- update tissues and CNS every 10 minutes when gradient factor is 0 (no supersaturation in any tissue any more)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
222 movff int_O_gradient_factor+0,WREG ; get gradient factor, only the lower byte is used for the value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
223 tstfsz WREG ; gradient factor = 0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
224 bra onemin_sleep1 ; NO - continue with air pressure compensation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
225 incf sm_timer2,F ; count-up...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
226 movlw d'9' ; ...to 9
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
227 cpfsgt sm_timer2 ; 10 minutes over?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
228 bra onemin_sleep1 ; NO - continue with air pressure compensation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
229 clrf sm_timer2 ; reset counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
230 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; copy pressure to deco routine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
231 call deco_calc_dive_interval_10min ; calculate 10 minutes under surface conditions
0
heinrichsweikamp
parents:
diff changeset
232 banksel common
heinrichsweikamp
parents:
diff changeset
233
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
234 onemin_sleep1:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
235 ;---- adjust air pressure compensation any 15 minutes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
236 incf sm_timer3,F ; count-up...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
237 movlw d'14' ; ...to 14
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
238 cpfsgt sm_timer3 ; 15 minutes over?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
239 bra onemin_sleep2 ; NO - continue with every-minute-tasks
0
heinrichsweikamp
parents:
diff changeset
240
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
241 ; Tasks every 15 minutes in sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
242 bsf deep_sleep ; enter deep-sleep mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
243 clrf sm_timer3 ; reset counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
244
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
245 SAFE_2BYTE_COPY last_surfpressure_15min, last_surfpressure_30min ; save older air pressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
246 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new air pressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
247
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
248 movlw LOW max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
249 movff WREG,sub_a+0 ; max. "allowed" air pressure in mbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
250 movlw HIGH max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
251 movff WREG,sub_a+1 ; max. "allowed" air pressure in mbar
0
heinrichsweikamp
parents:
diff changeset
252 movff last_surfpressure_15min+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
253 movff last_surfpressure_15min+1,sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
254 call subU16 ; sub_c = sub_a - sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
255 btfss neg_flag ; Is 1080mbar < amb_pressure ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
256 bra onemin_sleep2 ; NO: current air pressure is lower then "allowed" air pressure, ok!
0
heinrichsweikamp
parents:
diff changeset
257
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
258 ; not ok! Overwrite with max. "allowed" air pressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
259 movlw LOW max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
260 movff WREG,last_surfpressure_15min+0 ; max. "allowed" air pressure in mbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
261 movlw HIGH max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
262 movff WREG,last_surfpressure_15min+1 ; max. "allowed" air pressure in mbar
0
heinrichsweikamp
parents:
diff changeset
263
heinrichsweikamp
parents:
diff changeset
264 onemin_sleep2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
265 ; Tasks every minute in sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
266
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
267 ;---- update tissues and CNS every minute when gradient factor is >0 (supersaturation in at least one tissue)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
268 movff int_O_gradient_factor+0,WREG ; get gradient factor, only the lower byte is used for the value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
269 tstfsz WREG ; gradient factor = 0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
270 bra onemin_sleep3 ; NO - do tissue update on 1 minute schedule
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
271 bra onemin_sleep4 ; YES - tissue update is done on 10 minutes schedule
0
heinrichsweikamp
parents:
diff changeset
272
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
273 onemin_sleep3:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
274 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; copy pressure to deco routine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
275 call deco_calc_dive_interval_1min ; calculate 1 minute under surface conditions
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
276 banksel common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
277
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
278 onemin_sleep4:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
279 bcf oneminupdate ; all done
0
heinrichsweikamp
parents:
diff changeset
280 return
heinrichsweikamp
parents:
diff changeset
281
heinrichsweikamp
parents:
diff changeset
282 onesec_sleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
283 btfsc oneminupdate ; one minute in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
284 rcall onemin_sleep ; YES - do one-minute tasks, e.g. calculate desaturation
198
c511dc403d7e (Slightly) reduce current consumption in Eco and sleep mode
heinrichsweikamp
parents: 134
diff changeset
285
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
286 btfsc battery_gauge_available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
287 call get_battery_voltage ; check for charger
120
e2f04bb2539c battery check in sleep
heinrichsweikamp
parents: 50
diff changeset
288
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
289 incf sm_timer1,F ; counts to #test_pressure_in_sleep (10)
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
290 movlw d'10'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
291 cpfsgt sm_timer1 ; here: temp variable
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
292 bra onesec_sleep1 ; #test_pressure_in_sleep not done yet
0
heinrichsweikamp
parents:
diff changeset
293
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
294 clrf sm_timer1 ; clear counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
295 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
296 ; compare current ambient pressure with wake_up_from_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
297 movlw LOW wake_up_from_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
298 movwf sub_a+0 ; power on if ambient pressure is greater threshold
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
299 movlw HIGH wake_up_from_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
300 movwf sub_a+1 ; power on if ambient pressure is greater threshold
0
heinrichsweikamp
parents:
diff changeset
301 SAFE_2BYTE_COPY amb_pressure, sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
302 call subU16 ; is (1160mbar - averaged(amb_pressure)) < 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
303 btfsc neg_flag ; wake up from sleep?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
304 bra onesec_sleep1a ; YES - skip button checks, wake up!
0
heinrichsweikamp
parents:
diff changeset
305
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
306 btfsc battery_gauge_available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
307 bra onesec_sleep1 ; no wake-up with cR hardware
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
308 btfsc vusb_in ; USB plugged in?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
309 bra onesec_sleep1a ; YES - skip button checks, wake up
0
heinrichsweikamp
parents:
diff changeset
310
heinrichsweikamp
parents:
diff changeset
311 onesec_sleep1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
312 bcf onesecupdate ; clear flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
313 btfsc switch_left ; left switch pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
314 bra onesec_sleep1a ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
315 btfsc switch_right ; right switch pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
316 bra onesec_sleep1a ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
317 return ; NO to both - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
318
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
319 onesec_sleep1a: ; at least one button pressed or amb_pressure -> wake_up_from_sleep
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
320 bcf sleepmode ; wake up
0
heinrichsweikamp
parents:
diff changeset
321 SAFE_2BYTE_COPY last_surfpressure_30min, amb_pressure ; copy for compatibility
heinrichsweikamp
parents:
diff changeset
322 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
323 movff WREG,sensor_state_counter ; reset sensor state counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
324 bcf no_sensor_int ; normal sensor interrupt mode
0
heinrichsweikamp
parents:
diff changeset
325 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
326
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
327 pressuretest_sleep_fast: ; get pressure without averaging (faster to save some power in sleep mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
328 banksel isr_backup ; back to Bank0 ISR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
329 clrf amb_pressure_avg+0 ; clear pressure average registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
330 clrf amb_pressure_avg+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
331 clrf temperature_avg+0 ; clear temperature average registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
332 clrf temperature_avg+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
333 call get_temperature_start ; start temperature integration (73.5 us)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
334 banksel common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
335 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5 ms timer7 wakeup)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
336 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5 ms timer7 wakeup)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
337 banksel isr_backup ; back to Bank0 ISR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
338 call get_temperature_value ; state 1: get temperature
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
339 call get_pressure_start ; start pressure integration
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
340 banksel common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
341 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5 ms timer7 wakeup)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
342 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5 ms timer7 wakeup)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
343 banksel isr_backup ; back to bank0 ISR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
344 call get_pressure_value ; state2: get pressure (51 us)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
345 call calculate_compensation ; calculate temperature compensated pressure (27 us)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
346 banksel common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
347 SAFE_2BYTE_COPY amb_pressure_avg, amb_pressure ; copy for compatibility
0
heinrichsweikamp
parents:
diff changeset
348 return
heinrichsweikamp
parents:
diff changeset
349
heinrichsweikamp
parents:
diff changeset
350 sleepmode_sleep:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
351 banksel 0xF16 ; addresses F16h through F5Fh are also used by SFRs, but are not part of the access RAM
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
352 clrf T7GCON ; reset timer7 gate control register
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
353 movlw b'10001101' ; 1:1 prescaler -> 2 seconds @ 32768 Hz, not synced
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
354 movwf T7CON
0
heinrichsweikamp
parents:
diff changeset
355 sleep
198
c511dc403d7e (Slightly) reduce current consumption in Eco and sleep mode
heinrichsweikamp
parents: 134
diff changeset
356 sleep
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
357 clrf T7GCON ; reset timer7 gate control register
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
358 movlw b'10001001' ; 1:1 prescaler -> 2 seconds @ 32768Hz, synced
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
359 movwf T7CON
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
360 banksel common ; back to bank1
0
heinrichsweikamp
parents:
diff changeset
361 return
heinrichsweikamp
parents:
diff changeset
362
heinrichsweikamp
parents:
diff changeset
363 END