aboutsummaryrefslogtreecommitdiff
path: root/libraries/Wire/utility
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/Wire/utility')
-rw-r--r--libraries/Wire/utility/twi.c16
-rw-r--r--libraries/Wire/utility/twi.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/libraries/Wire/utility/twi.c b/libraries/Wire/utility/twi.c
index 201d7d1..d7d72bc 100644
--- a/libraries/Wire/utility/twi.c
+++ b/libraries/Wire/utility/twi.c
@@ -91,6 +91,22 @@ void twi_init(void)
}
/*
+ * Function twi_disable
+ * Desc disables twi pins
+ * Input none
+ * Output none
+ */
+void twi_disable(void)
+{
+ // disable twi module, acks, and twi interrupt
+ TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
+
+ // deactivate internal pullups for twi.
+ digitalWrite(SDA, 0);
+ digitalWrite(SCL, 0);
+}
+
+/*
* Function twi_slaveInit
* Desc sets slave address and enables interrupt
* Input none
diff --git a/libraries/Wire/utility/twi.h b/libraries/Wire/utility/twi.h
index 6526593..4c52bc5 100644
--- a/libraries/Wire/utility/twi.h
+++ b/libraries/Wire/utility/twi.h
@@ -39,6 +39,7 @@
#define TWI_STX 4
void twi_init(void);
+ void twi_disable(void);
void twi_setAddress(uint8_t);
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);