From 2de776546163efd6d18fa089b6b0e46bf05216bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu>
Date: Thu, 26 Sep 2013 08:42:28 +0000
Subject: [PATCH] Enabled the internal pull-ups for the I2C pins. Removed any
 write to the I2C pins to avoid communication errors.

---
 gpio.c              | 2 +-
 i2c.c               | 4 ++--
 tibi_dabo_battery.c | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gpio.c b/gpio.c
index 37ab5b7..72e5ba7 100755
--- a/gpio.c
+++ b/gpio.c
@@ -14,7 +14,7 @@ void InitGPIO(void)
 	 			   // Pc3 as an input (OVP)
     
 
-    PORTC=0x00;
+    PORTC=PORTC&0xF0;
 }
 
 void enable_battery(void)
diff --git a/i2c.c b/i2c.c
index b9f4236..33e42b1 100755
--- a/i2c.c
+++ b/i2c.c
@@ -51,8 +51,8 @@ void i2cInit(void)
 {
 	// set pull-up resistors on I2C bus pins
 	// TODO: should #ifdef these
-//	sbi(PORTC, 5);	// i2c SCL on ATmega163,323,16,32,etc
-//	sbi(PORTC, 4);	// i2c SDA on ATmega163,323,16,32,etc
+	sbi(PORTC, 5);	// i2c SCL on ATmega163,323,16,32,etc
+	sbi(PORTC, 4);	// i2c SDA on ATmega163,323,16,32,etc
 //	sbi(PORTD, 0);	// i2c SCL on ATmega128,64
 //	sbi(PORTD, 1);	// i2c SDA on ATmega128,64
 
diff --git a/tibi_dabo_battery.c b/tibi_dabo_battery.c
index d2e7530..e35378b 100755
--- a/tibi_dabo_battery.c
+++ b/tibi_dabo_battery.c
@@ -41,6 +41,7 @@ int main (void)
 
    // initialize the GPIO
    InitGPIO();
+   
    // initialize uart
    uartInit();
    // set desired baud rate in bps
-- 
GitLab