comparison src/sleepmode.asm @ 629:237931377539

3.07 stable release
author heinrichsweikamp
date Fri, 29 Nov 2019 18:48:11 +0100
parents cd58f7fc86db
children 185ba2f91f59
comparison
equal deleted inserted replaced
628:cd58f7fc86db 629:237931377539
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File sleepmode.asm combined next generation V3.03.6 3 ; File sleepmode.asm combined next generation V3.06.1
4 ; 4 ;
5 ; Sleep Mode 5 ; Sleep Mode
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================== 8 ;==============================================================================
21 #include "external_flash.inc" 21 #include "external_flash.inc"
22 #include "ghostwriter.inc" 22 #include "ghostwriter.inc"
23 #include "i2c.inc" 23 #include "i2c.inc"
24 #include "mcp.inc" 24 #include "mcp.inc"
25 #include "wait.inc" 25 #include "wait.inc"
26 #include "tft_outputs.inc" 26 #include "tft_outputs.inc"
27 27
28 28
29 extern vault_decodata_into_eeprom 29 extern vault_decodata_into_eeprom
30 extern power_up_switches ; from hwos.asm 30 extern power_up_switches ; from hwos.asm
31 31
72 ENDIF 72 ENDIF
73 73
74 bsf sleepmode ; flag being in sleep mode 74 bsf sleepmode ; flag being in sleep mode
75 bsf block_sensor_interrupt ; suspend ISR from executing sensor interrupts 75 bsf block_sensor_interrupt ; suspend ISR from executing sensor interrupts
76 76
77 IFDEF _external_sensor
78 call disable_ir_s8 ; power-down IR/S8 interrupts 77 call disable_ir_s8 ; power-down IR/S8 interrupts
79 call mcp_sleep ; power-down RX power supply 78 call mcp_sleep ; power-down RX power supply
80 ENDIF
81 79
82 clrf ADCON0 ; power-down ADC module 80 clrf ADCON0 ; power-down ADC module
83 call disable_rs232 ; power-down USB 81 call disable_rs232 ; power-down USB
84 call I2C_sleep_compass ; power-down compass 82 call I2C_sleep_compass ; power-down compass
85 83
174 btfsc switch_right ; right switch pressed? 172 btfsc switch_right ; right switch pressed?
175 bcf sleepmode ; YES - terminate sleep mode 173 bcf sleepmode ; YES - terminate sleep mode
176 174
177 btfsc battery_gauge_available ; is a battery gauge IC available? 175 btfsc battery_gauge_available ; is a battery gauge IC available?
178 bra one_sec_sleep_1 ; YES - check for charger 176 bra one_sec_sleep_1 ; YES - check for charger
177 btfsc ble_available ; Skip "USB" check in all Bluetooth models (Required for very old OSTC sport)
178 bra one_sec_sleep_2 ; - continue
179 btfsc vusb_in ; NO - USB plugged in? 179 btfsc vusb_in ; NO - USB plugged in?
180 bcf sleepmode ; YES - terminate sleep mode 180 bcf sleepmode ; YES - terminate sleep mode
181 bra one_sec_sleep_2 ; - continue 181 bra one_sec_sleep_2 ; - continue
182 182
183 one_sec_sleep_1: 183 one_sec_sleep_1:
385 385
386 banksel common 386 banksel common
387 btfsc charge_in_sleep ; already showing charge screen? 387 btfsc charge_in_sleep ; already showing charge screen?
388 bra sleepmode_sleepwalk ; YES - skip the actual sleep (But wait) 388 bra sleepmode_sleepwalk ; YES - skip the actual sleep (But wait)
389 389
390 banksel T7GCON ; switch bank, T7* is outside access RAM 390 ; banksel T7GCON ; switch bank, T7* is outside access RAM
391 clrf T7GCON ; reset timer7 gate control register 391 ; clrf T7GCON ; reset timer7 gate control register
392 movlw b'10001101' ; 1:1 prescaler -> 2 seconds @ 32768 Hz, not synced 392 ; movlw b'10001101' ; 1:1 prescaler -> 2 seconds @ 32768 Hz, not synced
393 movwf T7CON 393 ; movwf T7CON
394 sleep 394 sleep
395 sleep 395 sleep
396 clrf T7GCON ; reset timer7 gate control register 396 ; clrf T7GCON ; reset timer7 gate control register
397 movlw b'10001001' ; 1:1 prescaler -> 2 seconds @ 32768 Hz, synced 397 ; movlw b'10001001' ; 1:1 prescaler -> 2 seconds @ 32768 Hz, synced
398 movwf T7CON 398 ; movwf T7CON
399 sleepmode_sleep_1: 399 sleepmode_sleep_1:
400 movff BSR_backup,BSR ; restore BSR 400 movff BSR_backup,BSR ; restore BSR
401 return 401 return
402 402
403 403