Skip to content

Commit afce653

Browse files
committed
Version 2.0.1 - 5th June 2022
1 parent d11a3cb commit afce653

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ For more information and examples see [Tiny I2C Routines for all AVR Microcontro
77

88
The main difference between these routines and the standard Arduino Wire library is that these don't use buffers, so have much smaller memory requirements and don't impose a limit on transmissions.
99

10+
Version 2.0.1 increases the number of bytes you can specify in a single transfer.
11+
1012
## Compatibility
1113
These I2C routines are designed to provide master I2C functionality for all Microchip/Atmel AVR processors. Over the years different generations of AVR chips have featured three different, incompatible peripherals to handle I2C:
1214

@@ -71,7 +73,7 @@ Starts a transaction with the slave device at the specified address, and specifi
7173
The **type** parameter can have the following values:
7274

7375
* 0: Write to the device.
74-
* 1 to 32767: Read from the device. The number specifies how many bytes you are going to read.
76+
* 1 to 2147483647: Read from the device. The number specifies how many bytes you are going to read.
7577
* -1: Read an unspecified number of bytes from the device.
7678

7779
If **type** is specified as -1 you must identify the last byte read by calling **TinyI2C.readlast()** rather than  **TinyI2C.read()**.

TinyI2CMaster.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* TinyI2C v2.0.0
1+
/* TinyI2C v2.0.1
22
3-
David Johnson-Davies - www.technoblogy.com - Unreleased
3+
David Johnson-Davies - www.technoblogy.com - 5th June 2022
44
55
CC BY 4.0
66
Licensed under a Creative Commons Attribution 4.0 International license:
@@ -111,7 +111,7 @@ bool TinyI2CMaster::write (uint8_t data) {
111111
}
112112

113113
// Start transmission by sending address
114-
bool TinyI2CMaster::start (uint8_t address, int readcount) {
114+
bool TinyI2CMaster::start (uint8_t address, int32_t readcount) {
115115
if (readcount != 0) { I2Ccount = readcount; readcount = 1; }
116116
uint8_t addressRW = address<<1 | readcount;
117117

@@ -144,7 +144,7 @@ bool TinyI2CMaster::start (uint8_t address, int readcount) {
144144
return true; // Start successfully completed
145145
}
146146

147-
bool TinyI2CMaster::restart(uint8_t address, int readcount) {
147+
bool TinyI2CMaster::restart(uint8_t address, int32_t readcount) {
148148
return TinyI2CMaster::start(address, readcount);
149149
}
150150

@@ -209,7 +209,7 @@ bool TinyI2CMaster::write (uint8_t data) {
209209
}
210210

211211
// Start transmission by sending address
212-
bool TinyI2CMaster::start (uint8_t address, int readcount) {
212+
bool TinyI2CMaster::start (uint8_t address, int32_t readcount) {
213213
bool read;
214214
if (readcount == 0) read = 0; // Write
215215
else { I2Ccount = readcount; read = 1; } // Read
@@ -224,7 +224,7 @@ bool TinyI2CMaster::start (uint8_t address, int readcount) {
224224
else return (TWSR & 0xF8) == TWSR_MTX_ADR_ACK;
225225
}
226226

227-
bool TinyI2CMaster::restart(uint8_t address, int readcount) {
227+
bool TinyI2CMaster::restart(uint8_t address, int32_t readcount) {
228228
return TinyI2CMaster::start(address, readcount);
229229
}
230230

@@ -285,7 +285,7 @@ bool TinyI2CMaster::write (uint8_t data) {
285285
}
286286

287287
// Start transmission by sending address
288-
bool TinyI2CMaster::start (uint8_t address, int readcount) {
288+
bool TinyI2CMaster::start (uint8_t address, int32_t readcount) {
289289
bool read;
290290
if (readcount == 0) read = 0; // Write
291291
else { I2Ccount = readcount; read = 1; } // Read
@@ -302,7 +302,7 @@ bool TinyI2CMaster::start (uint8_t address, int readcount) {
302302
return true; // Return true if slave gave an ACK
303303
}
304304

305-
bool TinyI2CMaster::restart(uint8_t address, int readcount) {
305+
bool TinyI2CMaster::restart(uint8_t address, int32_t readcount) {
306306
return TinyI2CMaster::start(address, readcount);
307307
}
308308

TinyI2CMaster.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* TinyI2C v2.0.0
1+
/* TinyI2C v2.0.1
22
3-
David Johnson-Davies - www.technoblogy.com - 16th February 2022
3+
David Johnson-Davies - www.technoblogy.com - 5th June 2022
44
55
CC BY 4.0
66
Licensed under a Creative Commons Attribution 4.0 International license:
@@ -23,12 +23,12 @@ class TinyI2CMaster {
2323
uint8_t read(void);
2424
uint8_t readLast(void);
2525
bool write(uint8_t data);
26-
bool start(uint8_t address, int readcount);
27-
bool restart(uint8_t address, int readcount);
26+
bool start(uint8_t address, int32_t readcount);
27+
bool restart(uint8_t address, int32_t readcount);
2828
void stop(void);
2929

3030
private:
31-
int I2Ccount;
31+
int32_t I2Ccount;
3232
uint8_t transfer(uint8_t data);
3333
};
3434

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=TinyI2C
2-
version=2.0.0
2+
version=2.0.1
33
author=Technoblogy
44
maintainer=David Johnson-Davies <[email protected]>
55
sentence=Minimal I2C master routines for AVR microcontrollers.

0 commit comments

Comments
 (0)