diff src/i2c.asm @ 18:4e3f133dfbf4

add new opt_compass_gain option to work with more magnetic battery types
author heinrichsweikamp
date Wed, 03 Jul 2013 11:37:47 +0200
parents 11d4fc797f74
children 9b7dd3103545
line wrap: on
line diff
--- a/src/i2c.asm	Mon Jun 24 12:25:01 2013 +0200
+++ b/src/i2c.asm	Wed Jul 03 11:37:47 2013 +0200
@@ -240,10 +240,14 @@
     rcall       I2C_TX
 ;	movlw		b'01101001'        ; ConfigA:  3Hz, 8 Samples averaged, Test Mode (Positive Bias)
 	movlw		b'01101000'        ; ConfigA:  3Hz, 8 Samples averaged
-;    movlw		b'00111000'        ; ConfigA: 75Hz, 2 Samples averaged
     rcall       I2C_TX
-	movlw		b'00100000'        ; ConfigB, 1090Gauss Gain
-;	movlw		b'10000000'        ; ConfigB,  440Gauss Gain
+    movff       opt_compass_gain,i2c_temp    ; 0-7 (230LSB/Gauss to 1370LSB/Gaus)
+    swapf       i2c_temp,F
+    comf        i2c_temp,F
+    bcf         STATUS,C
+    rlcf        i2c_temp
+    movf        i2c_temp,W
+    clrf        i2c_temp
     rcall       I2C_TX
 	movlw		b'00000000'        ; Continous Mode
     rcall       I2C_TX
@@ -261,8 +265,15 @@
 	movlw		0x00
     rcall       I2C_TX
     movlw		b'00111000'        ; ConfigA: 75Hz, 2 Samples averaged
+;    movlw		b'00111001'        ; ConfigA: 75Hz, 2 Samples averaged, Test Mode (Positive Bias)
     rcall       I2C_TX
-	movlw		b'00100000'        ; ConfigB, 1090Gauss Gain
+    movff       opt_compass_gain,i2c_temp    ; 0-7 (230LSB/Gauss to 1370LSB/Gaus)
+    swapf       i2c_temp,F
+    comf        i2c_temp,F
+    bcf         STATUS,C
+    rlcf        i2c_temp
+    movf        i2c_temp,W
+    clrf        i2c_temp
     rcall       I2C_TX
 	movlw		b'00000000'        ; Continous Mode
     rcall       I2C_TX