Mercurial > public > hwos_code
comparison 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 |
comparison
equal
deleted
inserted
replaced
625:5c2ca77ce2df | 626:be8787f2034d |
---|---|
64 clrf sm_temp1 | 64 clrf sm_temp1 |
65 clrf sm_temp2 | 65 clrf sm_temp2 |
66 clrf sm_timer1 | 66 clrf sm_timer1 |
67 clrf sm_timer2 | 67 clrf sm_timer2 |
68 clrf sm_timer3 | 68 clrf sm_timer3 |
69 call speed_normal | 69 ; call speed_normal |
70 call speed_eco | |
70 bsf no_sensor_int ; inhibit sensor interrupts | 71 bsf no_sensor_int ; inhibit sensor interrupts |
71 clrf ADCON0 ; power-down ADC module | 72 clrf ADCON0 ; power-down ADC module |
72 | 73 |
73 sleeploop_pre: | 74 sleeploop_pre: |
74 bcf deep_sleep ; normal sleep mode | 75 bcf deep_sleep ; normal sleep mode |
125 | 126 |
126 btfsc deep_sleep ; enter deep sleep? | 127 btfsc deep_sleep ; enter deep sleep? |
127 bra deepsleep ; YES | 128 bra deepsleep ; YES |
128 | 129 |
129 no_deepsleep: | 130 no_deepsleep: |
131 bcf deep_sleep ; Clear flag to avoid putting the unit into deep sleep immediately when removed from charger | |
130 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5ms timer7 wakeup) | 132 rcall sleepmode_sleep ; wait at least 35 ms (every 62.5ms timer7 wakeup) |
131 | 133 |
132 ; Any button pressed in sleep? | 134 ; Any button pressed in sleep? |
133 ; btfsc switch_left | 135 ; btfsc switch_left |
134 ; rcall onesec_sleep1a | 136 ; rcall onesec_sleep1a |
141 bra sleeploop_loop ; do loop until something happens | 143 bra sleeploop_loop ; do loop until something happens |
142 | 144 |
143 deepsleep: | 145 deepsleep: |
144 btfss analog_switches | 146 btfss analog_switches |
145 bra no_deepsleep ; no analog switches, no deep sleep required | 147 bra no_deepsleep ; no analog switches, no deep sleep required |
148 btfsc cc_active ; Charging? | |
149 bra no_deepsleep ; Yes, no deep sleep required | |
146 | 150 |
147 bcf PIE1,0 ; stop timer 1 interrupt | 151 bcf PIE1,0 ; stop timer 1 interrupt |
148 bcf PIE2,1 ; stop timer 2 interrupt | 152 bcf PIE2,1 ; stop timer 2 interrupt |
149 bcf PIE5,3 ; stop timer 7 interrupt | 153 bcf PIE5,3 ; stop timer 7 interrupt |
150 bcf INTCON,4 ; stop INT0 interrupt | 154 bcf INTCON,4 ; stop INT0 interrupt |
159 rcall onesec_deepsleep ; YES - check accelerometer | 163 rcall onesec_deepsleep ; YES - check accelerometer |
160 | 164 |
161 btfsc onesecupdate ; one second in sleep? | 165 btfsc onesecupdate ; one second in sleep? |
162 rcall onesec_sleep ; YES - check switches, check pressure sensor, etc. | 166 rcall onesec_sleep ; YES - check switches, check pressure sensor, etc. |
163 | 167 |
168 btfsc cc_active ; Charging? | |
169 bcf deep_sleep ; Yes, no deep sleep required | |
170 | |
164 rcall sleepmode_sleep | 171 rcall sleepmode_sleep |
165 | 172 |
166 btfss deep_sleep ; enter normal sleep mode? | 173 btfss deep_sleep ; enter normal sleep mode? |
167 bra sleeploop_pre ; Yes | 174 bra sleeploop_pre ; Yes |
168 | 175 |
189 return | 196 return |
190 | 197 |
191 deepsleep_get_accel: | 198 deepsleep_get_accel: |
192 call I2C_init_compass ; required for compass1 | 199 call I2C_init_compass ; required for compass1 |
193 call I2C_init_accelerometer ; required for compass2 | 200 call I2C_init_accelerometer ; required for compass2 |
201 rcall sleepmode_sleep | |
194 call I2C_RX_accelerometer ; read accelerometer | 202 call I2C_RX_accelerometer ; read accelerometer |
195 call I2C_sleep_compass ; required for compass1 | 203 call I2C_sleep_compass ; required for compass1 |
196 call I2C_sleep_accelerometer ; required for compass2 | 204 call I2C_sleep_accelerometer ; required for compass2 |
197 movff accel_DZ+0,WREG | 205 movff accel_DZ+0,WREG |
198 return | 206 return |