diff src/adc_lightsensor.asm @ 120:e2f04bb2539c

battery check in sleep
author heinrichsweikamp
date Fri, 27 Jun 2014 15:52:43 +0200
parents abd30446e1cd
children 9a637c9bb19a
line wrap: on
line diff
--- a/src/adc_lightsensor.asm	Fri Jun 27 10:44:06 2014 +0200
+++ b/src/adc_lightsensor.asm	Fri Jun 27 15:52:43 2014 +0200
@@ -32,6 +32,31 @@
 
     call    lt2942_get_accumulated_charge
     call    lt2942_get_voltage
+    bcf     LEDr
+    bcf     TRISJ,2                 ; Chrg-Out output
+    bsf     CHRG_OUT
+
+    btfss   CHRG_IN
+    bra     cc_active
+
+    bcf     CHRG_OUT
+    bsf     TRISJ,2                 ; Chrg-Out high impedance
+
+    WAITMS  d'1'
+
+    btfsc   CHRG_IN
+    return
+;cv_active:
+    bsf     LEDr                    ; Indicate charging
+    call    lt2942_charge_done      ; Reset accumulating registers to 0xFFFF
+    WAITMS  d'10'
+    bcf     LEDr                    ; Indicate charging
+    return
+
+cc_active:
+    bsf     LEDr                    ; Indicate charging
+    bcf     CHRG_OUT
+    bsf     TRISJ,2                 ; Chrg-Out high impedance
     return
 
 get_battery_voltage1: