annotate src/sleepmode.asm @ 604:ca4556fb60b9

bump to 2.99beta, work on 3.00 stable
author heinrichsweikamp
date Thu, 22 Nov 2018 19:47:26 +0100
parents b455b31ce022
children c40025d8e750 be8787f2034d
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
0
heinrichsweikamp
parents:
diff changeset
69 call speed_normal
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
70 bsf no_sensor_int ; inhibit sensor interrupts
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
71 clrf ADCON0 ; power-down ADC module
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
72
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
73 sleeploop_pre:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
74 bcf deep_sleep ; normal sleep mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
75 call I2C_sleep_accelerometer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
76 call I2C_sleep_compass
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
77 btfss analog_switches ; OSTC with analog switches?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
78 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
79
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
80 bsf power_sw1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
81 btfss power_sw1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
82 bra $-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
83 bsf power_sw2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
84 btfss power_sw2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
85 bra $-4
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
86 movlw .4 ; wait for button circuity
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
87 movwf sm_temp1 ; used as temp
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
88 bcf onesecupdate
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
89
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
90 sleeploop_pre1:
491
66b9b8c082a9 minor new sleepmode fix
heinrichsweikamp
parents: 490
diff changeset
91 rcall sleepmode_sleep
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
92 btfss onesecupdate ; wait 1 second
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
93 bra sleeploop_pre1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
94 bcf onesecupdate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
95 decfsz sm_temp1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
96 bra sleeploop_pre1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
97 movlw .32 ; wait for button circuity
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
98 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
99
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
100 sleeploop_pre2:
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
101 call get_analog_switches
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
102 decfsz sm_temp1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
103 bra sleeploop_pre2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
104
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
105 bcf PIR1,TMR1IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
106 bcf INTCON,INT0IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
107 bcf INTCON3,INT1IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
108 bcf PIR5,TMR7IF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
109 bcf switch_left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
110 bcf switch_right
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
111 bcf analog_sw2_pressed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
112 bcf analog_sw1_pressed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
113 bsf PIE1,0 ; (re)start timer 1 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
114 bsf PIE2,1 ; (re)start timer 2 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
115 bsf PIE5,3 ; (re)start timer 7 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
116 bsf INTCON,4 ; (re)start INT0 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
117 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
118
0
heinrichsweikamp
parents:
diff changeset
119 sleeploop_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
120 btfsc onesecupdate ; one second in sleep?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
121 rcall onesec_sleep ; check switches, check pressure sensor, etc.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
122
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
123 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
124 goto restart ; YES
0
heinrichsweikamp
parents:
diff changeset
125
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
126 btfsc deep_sleep ; enter deep sleep?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
127 bra deepsleep ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
128
491
66b9b8c082a9 minor new sleepmode fix
heinrichsweikamp
parents: 490
diff changeset
129 no_deepsleep:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
130 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5ms timer7 wakeup)
0
heinrichsweikamp
parents:
diff changeset
131
heinrichsweikamp
parents:
diff changeset
132 ; Any button pressed in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
133 ; btfsc switch_left
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
134 ; rcall onesec_sleep1a
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
135 ; btfsc switch_right
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 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
138 ; 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
139 ; goto restart ; YES
0
heinrichsweikamp
parents:
diff changeset
140
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
141 bra sleeploop_loop ; do loop until something happens
0
heinrichsweikamp
parents:
diff changeset
142
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
143 deepsleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
144 btfss analog_switches
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
145 bra no_deepsleep ; no analog switches, no deep sleep required
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
146
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
147 bcf PIE1,0 ; stop timer 1 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
148 bcf PIE2,1 ; stop timer 2 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
149 bcf PIE5,3 ; stop timer 7 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
150 bcf INTCON,4 ; stop INT0 interrupt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
151 bcf INTCON3,3 ; stop INT1 interrupt
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
152 bcf power_sw1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
153 bcf power_sw2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
154 rcall deepsleep_get_accel ; read accelerometer into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
155 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
156
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
157 deepsleep_loop:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
158 btfsc onesecupdate ; one second in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
159 rcall onesec_deepsleep ; YES - check accelerometer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
160
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
161 btfsc onesecupdate ; one second in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
162 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
163
491
66b9b8c082a9 minor new sleepmode fix
heinrichsweikamp
parents: 490
diff changeset
164 rcall sleepmode_sleep
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
165
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
166 btfss deep_sleep ; enter normal sleep mode?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
167 bra sleeploop_pre ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
168
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
169 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
170
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
171 onesec_deepsleep:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
172 rcall deepsleep_get_accel ; read accelerometer into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
173 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
174 btfsc STATUS,N ; result negative?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
175 negf WREG ; YES - negate it
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
176 movwf sm_temp2 ; change of acceleration in Z-axis
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
177 movlw .50 ; threshold (mg)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
178 cpfslt sm_temp2 ; bigger then the threshold?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
179 bcf deep_sleep ; YES
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
180
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
181 ; extern piezo_config_tx
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
182 ; movff sm_temp1,WREG
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
183 ; call piezo_config_tx
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
184 ; movff accel_DZ+0,WREG
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
185 ; call piezo_config_tx
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
186 ; movff sm_temp2,WREG
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
187 ; call piezo_config_tx
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
188
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
189 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
190
490
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
191 deepsleep_get_accel:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
192 call I2C_init_compass ; required for compass1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
193 call I2C_init_accelerometer ; required for compass2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
194 call I2C_RX_accelerometer ; read accelerometer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
195 call I2C_sleep_compass ; required for compass1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
196 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
197 movff accel_DZ+0,WREG
8dfb93e80338 NEW: Deep Sleep mode for OSTC Plus and OSTC 2 (2017) (Entered automatically)
heinrichsweikamp
parents: 448
diff changeset
198 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
199
134
4574aed5cd4c Show clock in Apnea mode, minor layout changes in Apnea mode
heinrichsweikamp
parents: 133
diff changeset
200 onehour_sleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
201 call update_battery_registers ; update battery registers into EEPROM
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
202 call vault_decodata_into_eeprom ; update deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
203 bcf onehourupdate ; all done
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
204 return
0
heinrichsweikamp
parents:
diff changeset
205
heinrichsweikamp
parents:
diff changeset
206 onemin_sleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
207 btfsc onehourupdate ; one hour in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
208 rcall onehour_sleep ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
209
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
210 btfsc battery_gauge_available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
211 call get_battery_voltage ; check for charger
198
c511dc403d7e (Slightly) reduce current consumption in Eco and sleep mode
heinrichsweikamp
parents: 134
diff changeset
212
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
213 ;---- 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
214 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
215 tstfsz WREG ; gradient factor = 0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
216 bra onemin_sleep1 ; NO - continue with air pressure compensation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
217 incf sm_timer2,F ; count-up...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
218 movlw d'9' ; ...to 9
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
219 cpfsgt sm_timer2 ; 10 minutes over?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
220 bra onemin_sleep1 ; NO - continue with air pressure compensation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
221 clrf sm_timer2 ; reset counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
222 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
223 call deco_calc_dive_interval_10min ; calculate 10 minutes under surface conditions
0
heinrichsweikamp
parents:
diff changeset
224 banksel common
heinrichsweikamp
parents:
diff changeset
225
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
226 onemin_sleep1:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
227 ;---- adjust air pressure compensation any 15 minutes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
228 incf sm_timer3,F ; count-up...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
229 movlw d'14' ; ...to 14
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
230 cpfsgt sm_timer3 ; 15 minutes over?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
231 bra onemin_sleep2 ; NO - continue with every-minute-tasks
0
heinrichsweikamp
parents:
diff changeset
232
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
233 ; Tasks every 15 minutes in sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
234 bsf deep_sleep ; enter deep-sleep mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
235 clrf sm_timer3 ; reset counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
236
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
237 SAFE_2BYTE_COPY last_surfpressure_15min, last_surfpressure_30min ; save older air pressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
238 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new air pressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
240 movlw LOW max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
241 movff WREG,sub_a+0 ; max. "allowed" air pressure in mbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
242 movlw HIGH max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
243 movff WREG,sub_a+1 ; max. "allowed" air pressure in mbar
0
heinrichsweikamp
parents:
diff changeset
244 movff last_surfpressure_15min+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
245 movff last_surfpressure_15min+1,sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
246 call subU16 ; sub_c = sub_a - sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
247 btfss neg_flag ; Is 1080mbar < amb_pressure ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
248 bra onemin_sleep2 ; NO: current air pressure is lower then "allowed" air pressure, ok!
0
heinrichsweikamp
parents:
diff changeset
249
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
250 ; not ok! Overwrite with max. "allowed" air pressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
251 movlw LOW max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
252 movff WREG,last_surfpressure_15min+0 ; max. "allowed" air pressure in mbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
253 movlw HIGH max_surfpressure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
254 movff WREG,last_surfpressure_15min+1 ; max. "allowed" air pressure in mbar
0
heinrichsweikamp
parents:
diff changeset
255
heinrichsweikamp
parents:
diff changeset
256 onemin_sleep2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
257 ; Tasks every minute in sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
258
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
259 ;---- 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
260 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
261 tstfsz WREG ; gradient factor = 0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
262 bra onemin_sleep3 ; NO - do tissue update on 1 minute schedule
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
263 bra onemin_sleep4 ; YES - tissue update is done on 10 minutes schedule
0
heinrichsweikamp
parents:
diff changeset
264
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
265 onemin_sleep3:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
266 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
267 call deco_calc_dive_interval_1min ; calculate 1 minute under surface conditions
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
268 banksel common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
269
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
270 onemin_sleep4:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
271 bcf oneminupdate ; all done
0
heinrichsweikamp
parents:
diff changeset
272 return
heinrichsweikamp
parents:
diff changeset
273
heinrichsweikamp
parents:
diff changeset
274 onesec_sleep:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
275 btfsc oneminupdate ; one minute in sleep?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
276 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
277
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
278 btfsc battery_gauge_available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
279 call get_battery_voltage ; check for charger
120
e2f04bb2539c battery check in sleep
heinrichsweikamp
parents: 50
diff changeset
280
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
281 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
282 movlw d'10'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
283 cpfsgt sm_timer1 ; here: temp variable
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
284 bra onesec_sleep1 ; #test_pressure_in_sleep not done yet
0
heinrichsweikamp
parents:
diff changeset
285
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
286 clrf sm_timer1 ; clear counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
287 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
288 ; compare current ambient pressure with wake_up_from_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
289 movlw LOW wake_up_from_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
290 movwf sub_a+0 ; power on if ambient pressure is greater threshold
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
291 movlw HIGH wake_up_from_sleep
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
292 movwf sub_a+1 ; power on if ambient pressure is greater threshold
0
heinrichsweikamp
parents:
diff changeset
293 SAFE_2BYTE_COPY amb_pressure, sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
294 call subU16 ; is (1160mbar - averaged(amb_pressure)) < 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
295 btfsc neg_flag ; wake up from sleep?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
296 bra onesec_sleep1a ; YES - skip button checks, wake up!
0
heinrichsweikamp
parents:
diff changeset
297
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
298 btfsc battery_gauge_available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
299 bra onesec_sleep1 ; no wake-up with cR hardware
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
300 btfsc vusb_in ; USB plugged in?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
301 bra onesec_sleep1a ; YES - skip button checks, wake up
0
heinrichsweikamp
parents:
diff changeset
302
heinrichsweikamp
parents:
diff changeset
303 onesec_sleep1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
304 bcf onesecupdate ; clear flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
305 btfsc switch_left ; left switch pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
306 bra onesec_sleep1a ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
307 btfsc switch_right ; right switch pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
308 bra onesec_sleep1a ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
309 return ; NO to both - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
310
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
311 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
312 bcf sleepmode ; wake up
0
heinrichsweikamp
parents:
diff changeset
313 SAFE_2BYTE_COPY last_surfpressure_30min, amb_pressure ; copy for compatibility
heinrichsweikamp
parents:
diff changeset
314 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
315 movff WREG,sensor_state_counter ; reset sensor state counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
316 bcf no_sensor_int ; normal sensor interrupt mode
0
heinrichsweikamp
parents:
diff changeset
317 return
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 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
320 banksel isr_backup ; back to Bank0 ISR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
321 clrf amb_pressure_avg+0 ; clear pressure average registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
322 clrf amb_pressure_avg+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
323 clrf temperature_avg+0 ; clear temperature average registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
324 clrf temperature_avg+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
325 call get_temperature_start ; start temperature integration (73.5 us)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
326 banksel common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
327 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
328 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
329 banksel isr_backup ; back to Bank0 ISR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
330 call get_temperature_value ; state 1: get temperature
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
331 call get_pressure_start ; start pressure integration
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
332 banksel common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
333 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
334 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
335 banksel isr_backup ; back to bank0 ISR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
336 call get_pressure_value ; state2: get pressure (51 us)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
337 call calculate_compensation ; calculate temperature compensated pressure (27 us)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
338 banksel common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
339 SAFE_2BYTE_COPY amb_pressure_avg, amb_pressure ; copy for compatibility
0
heinrichsweikamp
parents:
diff changeset
340 return
heinrichsweikamp
parents:
diff changeset
341
heinrichsweikamp
parents:
diff changeset
342 sleepmode_sleep:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
343 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
344 clrf T7GCON ; reset timer7 gate control register
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
345 movlw b'10001101' ; 1:1 prescaler -> 2 seconds @ 32768 Hz, not synced
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
346 movwf T7CON
0
heinrichsweikamp
parents:
diff changeset
347 sleep
198
c511dc403d7e (Slightly) reduce current consumption in Eco and sleep mode
heinrichsweikamp
parents: 134
diff changeset
348 sleep
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
349 clrf T7GCON ; reset timer7 gate control register
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
350 movlw b'10001001' ; 1:1 prescaler -> 2 seconds @ 32768Hz, synced
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
351 movwf T7CON
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
352 banksel common ; back to bank1
0
heinrichsweikamp
parents:
diff changeset
353 return
heinrichsweikamp
parents:
diff changeset
354
heinrichsweikamp
parents:
diff changeset
355 END