From 1a739c9496a735db3fda5ed85f1adca39ed15c68 Mon Sep 17 00:00:00 2001 From: Spence Konde Date: Sun, 23 Aug 2015 04:34:25 -0400 Subject: [PATCH 01/12] Update USI_TWI_Master.h --- USI_TWI_Master.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/USI_TWI_Master.h b/USI_TWI_Master.h index 53c12ad..449024b 100644 --- a/USI_TWI_Master.h +++ b/USI_TWI_Master.h @@ -89,6 +89,19 @@ # define PIN_USI_SCL PINA4 #endif +#if defined(__AVR_ATtiny1634__) + #define DDR_USI DDRB + #define PORT_USI PORTB + #define PIN_USI PINB + #define DDR_USI_SCL DDRC + #define PORT_USI_SCL PORTC + #define PIN_USI_SCL PINC + #define PORT_USI_SDA PORTB1 + #define PORT_USI_SCL PORTC1 + #define PIN_USI_SDA PINB1 + #define PIN_USI_SCL PINC1 +#endif + #if defined(__AVR_AT90Tiny2313__) | defined(__AVR_ATtiny2313__) #define DDR_USI DDRB #define PORT_USI PORTB From 2e4b9abd72c6d1ca265252e115f3ade432942c21 Mon Sep 17 00:00:00 2001 From: Spence Konde Date: Sun, 23 Aug 2015 04:36:16 -0400 Subject: [PATCH 02/12] Update USI_TWI_Master.h --- USI_TWI_Master.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/USI_TWI_Master.h b/USI_TWI_Master.h index 449024b..6b073b4 100644 --- a/USI_TWI_Master.h +++ b/USI_TWI_Master.h @@ -128,6 +128,12 @@ #define TRUE 1 #define FALSE 0 +#ifndef DDR_USI_SCL +#define DDR_USI_SCL DDR_USI +#define PORT_USI_SCL PORT_USI +#define PIN_USI_SCL PIN_USI +#endif + //********** Prototypes **********// void USI_TWI_Master_Initialise( void ); From 7b0779f1bb5a4292aab058cde43219382b7f4227 Mon Sep 17 00:00:00 2001 From: Spence Konde Date: Sun, 23 Aug 2015 04:39:33 -0400 Subject: [PATCH 03/12] Support chips with USI DI, SCL on different ports. --- USI_TWI_Master.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/USI_TWI_Master.cpp b/USI_TWI_Master.cpp index a12f223..7da5d37 100644 --- a/USI_TWI_Master.cpp +++ b/USI_TWI_Master.cpp @@ -46,9 +46,9 @@ union USI_TWI_state void USI_TWI_Master_Initialise( void ) { PORT_USI |= (1< Date: Sun, 23 Aug 2015 04:42:56 -0400 Subject: [PATCH 04/12] Revert "Support chips with USI DI, SCL on different ports." This reverts commit 7b0779f1bb5a4292aab058cde43219382b7f4227. --- USI_TWI_Master.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/USI_TWI_Master.cpp b/USI_TWI_Master.cpp index 7da5d37..a12f223 100644 --- a/USI_TWI_Master.cpp +++ b/USI_TWI_Master.cpp @@ -46,9 +46,9 @@ union USI_TWI_state void USI_TWI_Master_Initialise( void ) { PORT_USI |= (1< Date: Thu, 17 Sep 2015 02:03:04 -0400 Subject: [PATCH 05/12] Support things like the 1634 --- USI_TWI_Master.cpp | 18 ++++++------ USI_TWI_Master.h | 14 +++++----- examples/Tiny1634_EEPROM/AT24_EEPROM.ino | 35 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 examples/Tiny1634_EEPROM/AT24_EEPROM.ino diff --git a/USI_TWI_Master.cpp b/USI_TWI_Master.cpp index a12f223..03802be 100644 --- a/USI_TWI_Master.cpp +++ b/USI_TWI_Master.cpp @@ -46,9 +46,9 @@ union USI_TWI_state void USI_TWI_Master_Initialise( void ) { PORT_USI |= (1< +//Demo of reading AT24 EEPROM with ATTiny1634, and logging the results to serial. Reads the first 256 bytes. +//#define DoWrite //uncomment to write consecutive integers to first 256 bytes while sketch runs + + +byte i=0; + + +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); + TinyWireM.begin(); // initialize I2C lib + Serial.println("Tinywire begun"); +} + +void loop() { + // put your main code here, to run repeatedly: + +#ifdef DoWrite + TinyWireM.beginTransmission(0x50); + TinyWireM.send(0x00); + TinyWireM.send(i); + TinyWireM.send(i); + TinyWireM.endTransmission(); // Send to the slave + delay(500); +#endif + TinyWireM.beginTransmission(0x50); + TinyWireM.send(0x00); + TinyWireM.send(i); + TinyWireM.endTransmission(); + TinyWireM.requestFrom(0x50,1); + Serial.println(TinyWireM.receive()); + delay(500); + i++; +} From cbd71fe71948bf64b4c8cbc63fbc1841f95bbb70 Mon Sep 17 00:00:00 2001 From: Spence Konde Date: Thu, 17 Sep 2015 02:12:32 -0400 Subject: [PATCH 06/12] fix naming mistake --- examples/Tiny1634_EEPROM/{AT24_EEPROM.ino => Tiny1634_EEPROM.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/Tiny1634_EEPROM/{AT24_EEPROM.ino => Tiny1634_EEPROM.ino} (100%) diff --git a/examples/Tiny1634_EEPROM/AT24_EEPROM.ino b/examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino similarity index 100% rename from examples/Tiny1634_EEPROM/AT24_EEPROM.ino rename to examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino From 15872eb8b3ed6553d534ea5dcd993114e328a7c8 Mon Sep 17 00:00:00 2001 From: Spence Konde Date: Mon, 16 Nov 2015 02:15:55 -0500 Subject: [PATCH 07/12] 1 more byte on the buffer So you can read/write 16 bytes at a time from AT24 EEPROM without fear. --- TinyWireM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TinyWireM.h b/TinyWireM.h index f1852c1..effd71f 100644 --- a/TinyWireM.h +++ b/TinyWireM.h @@ -41,7 +41,7 @@ #include "Arduino.h" #define USI_SEND 0 // indicates sending to TWI #define USI_RCVE 1 // indicates receiving from TWI -#define USI_BUF_SIZE 18 // bytes in message buffer +#define USI_BUF_SIZE 19 // bytes in message buffer //class USI_TWI : public Stream class USI_TWI From 5b0d9f49c1e3c63062242d5589079ed8d79fd2e4 Mon Sep 17 00:00:00 2001 From: "Spence Konde (aka Dr. Azzy)" Date: Mon, 16 Nov 2015 03:15:29 -0500 Subject: [PATCH 08/12] Update Tiny1634_EEPROM.ino --- examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino b/examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino index b0a5a3d..c1993cc 100644 --- a/examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino +++ b/examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino @@ -1,6 +1,7 @@ #include -//Demo of reading AT24 EEPROM with ATTiny1634, and logging the results to serial. Reads the first 256 bytes. +//Demo of reading AT24 EEPROM, and logging the results to serial. Reads the first 256 bytes. //#define DoWrite //uncomment to write consecutive integers to first 256 bytes while sketch runs +//comment out Serial statements for boards without hardware serial. byte i=0; @@ -8,9 +9,9 @@ byte i=0; void setup() { // put your setup code here, to run once: - Serial.begin(9600); + Serial.begin(9600); //comment out if you're using a chip w/out serial. TinyWireM.begin(); // initialize I2C lib - Serial.println("Tinywire begun"); + Serial.println("Tinywire begun"); //comment out if you're using a chip w/out serial. } void loop() { @@ -29,7 +30,7 @@ void loop() { TinyWireM.send(i); TinyWireM.endTransmission(); TinyWireM.requestFrom(0x50,1); - Serial.println(TinyWireM.receive()); + Serial.println(TinyWireM.receive()); //comment out if you're using a chip w/out serial. delay(500); i++; } From 9d093a2eeb0f9e20fc2276c6e999a7322da46792 Mon Sep 17 00:00:00 2001 From: Spence Konde Date: Mon, 16 Nov 2015 03:17:07 -0500 Subject: [PATCH 09/12] Rename --- .../Tiny1634_EEPROM.ino => AT24_EEPROM/AT24_EEPROM.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{Tiny1634_EEPROM/Tiny1634_EEPROM.ino => AT24_EEPROM/AT24_EEPROM.ino} (100%) diff --git a/examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino b/examples/AT24_EEPROM/AT24_EEPROM.ino similarity index 100% rename from examples/Tiny1634_EEPROM/Tiny1634_EEPROM.ino rename to examples/AT24_EEPROM/AT24_EEPROM.ino From 35360d1c767ab5dd614402a9f2ed9cc539f26ecd Mon Sep 17 00:00:00 2001 From: "Spence Konde (aka Dr. Azzy)" Date: Fri, 4 Nov 2016 20:35:50 -0400 Subject: [PATCH 10/12] Fix #1 --- USI_TWI_Master.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/USI_TWI_Master.h b/USI_TWI_Master.h index 4f34217..8ff6366 100644 --- a/USI_TWI_Master.h +++ b/USI_TWI_Master.h @@ -89,6 +89,18 @@ # define PIN_USI_SCL PINA4 #endif +#if defined(__AVR_ATtiny167__) | defined(__AVR_ATtiny87__) + # define DDR_USI DDRB + # define PORT_USI PORTB + # define PIN_USI PINB + # define PORT_USI_SDA PORTB0 + # define PORT_USI_SCL PORTB2 + # define PIN_USI_SDA PINB0 + # define PIN_USI_SCL PINB2 + + +#endif + #if defined(__AVR_ATtiny1634__) #define DDR_USI DDRB #define PORT_USI PORTB From be34c42359b2142c347a1b7740291b6afff1249e Mon Sep 17 00:00:00 2001 From: "Spence Konde (aka Dr. Azzy)" Date: Sat, 13 May 2017 17:03:36 -0400 Subject: [PATCH 11/12] Fix bug with endTransmission --- TinyWireM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TinyWireM.cpp b/TinyWireM.cpp index d65a5ed..5ed5a23 100644 --- a/TinyWireM.cpp +++ b/TinyWireM.cpp @@ -57,7 +57,7 @@ size_t USI_TWI::write(uint8_t data){ // buffers up data to send } uint8_t USI_TWI::endTransmission() { - endTransmission(1); + return endTransmission(1); } uint8_t USI_TWI::endTransmission(uint8_t stop){ // actually sends the buffer From d515cf7c5c322cb265c83f6bc099d5323f5371bc Mon Sep 17 00:00:00 2001 From: "Spence Konde (aka Dr. Azzy)" Date: Fri, 8 Jun 2018 17:56:35 -0400 Subject: [PATCH 12/12] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index cbf740e..9aa58ec 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +# STOP - IF USING MY CORE, DO NOT USE THIS LIBRARY # +## MY CORE NOW HAS UNIVERSAL Wire.h LIBRARY. Just use Wire.h and unmodified I2C device libraries ## + TinyWireM =========