summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--software/ihu/i2c.inc12
-rw-r--r--software/ihu/ihu.asm3
2 files changed, 6 insertions, 9 deletions
diff --git a/software/ihu/i2c.inc b/software/ihu/i2c.inc
index bbd424f..072d01d 100644
--- a/software/ihu/i2c.inc
+++ b/software/ihu/i2c.inc
@@ -30,15 +30,11 @@
;; -------------------------------------
i2c_init
- bsf STATUS,RP0 ; make them outputs first
- bcf I2C_SDA ; every write access is read-update-write
- bcf I2C_SCL ; therefore the second bcf SDA sets SCL again
- bcf STATUS,RP0 ; because of the external pull-up
- bcf I2C_SCL
- bcf I2C_SDA
+ movlw I2C_MASK ; as every write access is read-update-write this needs
+ andwf I2C_PORT,f ; to be done in one step (external pull-ups!)
bsf STATUS,RP0
- bsf I2C_SDA
- bsf I2C_SCL
+ movlw ~I2C_MASK
+ iorwf I2C_PORT,f
bcf STATUS,RP0
return
diff --git a/software/ihu/ihu.asm b/software/ihu/ihu.asm
index eef9547..33ca45d 100644
--- a/software/ihu/ihu.asm
+++ b/software/ihu/ihu.asm
@@ -71,7 +71,8 @@
#define I2C_SCL PORTD,0
#define I2C_SDA PORTD,1
I2C_PORT EQU PORTD
-I2C_SDA_MASK EQU b'00000010'
+I2C_MASK EQU b'00000011'
+I2C_SDA_MASK EQU b'00000010'
#define CTR_SS PORTD,2
#define BAT_SS PORTD,3
#define MPU_EN PORTD,4