diff --git a/libraries/I2C_24LC1025/.arduino-ci.yml b/libraries/I2C_24LC1025/.arduino-ci.yml index ff5659b9..cecf5850 100644 --- a/libraries/I2C_24LC1025/.arduino-ci.yml +++ b/libraries/I2C_24LC1025/.arduino-ci.yml @@ -2,6 +2,10 @@ compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: - uno - - leonardo - - due - - zero + # - due + # - zero + # - leonardo + - m4 + - esp32 + # - esp8266 + # - mega2560 diff --git a/libraries/I2C_24LC1025/I2C_24LC1025.cpp b/libraries/I2C_24LC1025/I2C_24LC1025.cpp index b2537629..a450f2f2 100644 --- a/libraries/I2C_24LC1025/I2C_24LC1025.cpp +++ b/libraries/I2C_24LC1025/I2C_24LC1025.cpp @@ -1,7 +1,7 @@ // // FILE: I2C_24LC1025.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.4 +// VERSION: 0.1.6 // PURPOSE: I2C_24LC1025 library for Arduino with EEPROM I2C_24LC1025 et al. // // HISTORY: @@ -11,13 +11,14 @@ // 0.1.3 2021-02-02 add updateBlock(); // 0.1.4 2021-05-27 fix library.properties; // 0.1.5 2021-08-30 fix #3 I2C_DEVICESIZE_24LC512 => I2C_DEVICESIZE_24LC1025 +// 0.1.6 2021-12-19 update library.json, license, minor edits #include "I2C_24LC1025.h" -// TWI buffer needs max 2 bytes for eeprom address -// 1 byte for eeprom register address is available in txbuffer +// TWI buffer needs max 2 bytes for EEPROM address +// 1 byte for EEPROM register address is available in TX buffer #if defined(ESP32) || defined(ESP8266) #define I2C_BUFFERSIZE 128 #else @@ -126,7 +127,7 @@ uint32_t I2C_24LC1025::readBlock(const uint32_t memoryAddress, uint8_t* buffer, addr += cnt; buffer += cnt; len -= cnt; - yield(); // For OS scheduling etc + yield(); // For OS scheduling } return rv; } @@ -158,7 +159,7 @@ int I2C_24LC1025::updateBlock(const uint32_t memoryAddress, const uint8_t* buffe addr += cnt; buffer += cnt; len -= cnt; - yield(); // For OS scheduling etc + yield(); // For OS scheduling } return rv; } @@ -214,7 +215,7 @@ void I2C_24LC1025::_beginTransmission(uint32_t memoryAddress) delayMicroseconds(50); } uint16_t memAddr = (memoryAddress & 0xFFFF); - _wire->beginTransmission(_actualAddress); // device addres + bit 16 + _wire->beginTransmission(_actualAddress); // device address + bit 16 _wire->write((memAddr >> 8) & 0xFF); // highByte _wire->write(memAddr & 0xFF); // lowByte } @@ -278,3 +279,4 @@ int I2C_24LC1025::_ReadBlock(uint32_t memoryAddress, uint8_t* buffer, const uint // -- END OF FILE -- + diff --git a/libraries/I2C_24LC1025/I2C_24LC1025.h b/libraries/I2C_24LC1025/I2C_24LC1025.h index 9198da3c..a4cb39ce 100644 --- a/libraries/I2C_24LC1025/I2C_24LC1025.h +++ b/libraries/I2C_24LC1025/I2C_24LC1025.h @@ -2,7 +2,7 @@ // // FILE: I2C_24LC1025.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.5 +// VERSION: 0.1.6 // PURPOSE: I2C_24LC1025 library for Arduino with EEPROM 24FC1025 et al. // HISTORY: See I2C_24LC1025.cpp // URL: https://github.com/RobTillaart/I2C_24LC1025 @@ -12,7 +12,7 @@ #include "Wire.h" -#define I2C_24LC1025_VERSION (F("0.1.5")) +#define I2C_24LC1025_VERSION (F("0.1.6")) #define I2C_DEVICESIZE_24LC1025 131072 @@ -32,25 +32,25 @@ public: bool isConnected(); - // writes a byte to memaddr + // writes a byte to memoryAddress int writeByte(const uint32_t memoryAddress, const uint8_t value); - // writes length bytes from buffer to EEPROM + // writes length bytes from buffer to EEPROM int writeBlock(const uint32_t memoryAddress, const uint8_t *buffer, const uint32_t length); - // set length bytes in the EEPROM to the same value. + // set length bytes in the EEPROM to the same value. int setBlock(const uint32_t memoryAddress, const uint8_t value, const uint32_t length); - // returns the value stored in memaddr + // returns the value stored in memoryAddress uint8_t readByte(const uint32_t memoryAddress); - // reads length bytes into buffer + // reads length bytes into buffer uint32_t readBlock(const uint32_t memoryAddress, uint8_t *buffer, const uint32_t length); - // updates a byte at memory address, writes only if there is a new value. - // return 0 if data is same or written OK, error code otherwise. + // updates a byte at memory address, writes only if there is a new value. + // return 0 if data is same or written OK, error code otherwise. int updateByte(const uint32_t memoryAddress, const uint8_t value); - // updates a block in memory, writes only if there is a new value. - // only to be used when you expect to write same buffer multiple times. - // test your performance gains! + // updates a block in memory, writes only if there is a new value. + // only to be used when you expect to write same buffer multiple times. + // test your performance gains! int updateBlock(const uint32_t memoryAddress, const uint8_t* buffer, const uint32_t length); @@ -62,10 +62,10 @@ public: private: uint8_t _deviceAddress; uint8_t _actualAddress; // a.k.a. controlByte - uint32_t _lastWrite; + uint32_t _lastWrite = 0; uint32_t _deviceSize = I2C_DEVICESIZE_24LC1025; uint8_t _pageSize = I2C_PAGESIZE_24LC1025; - int _error; // TODO. + int _error = 0; // TODO. void _beginTransmission(uint32_t memoryAddress); @@ -79,4 +79,6 @@ private: bool _debug = true; }; + // -- END OF FILE -- + diff --git a/libraries/I2C_24LC1025/LICENSE b/libraries/I2C_24LC1025/LICENSE index a8b455d0..5777550e 100644 --- a/libraries/I2C_24LC1025/LICENSE +++ b/libraries/I2C_24LC1025/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2021 Rob Tillaart +Copyright (c) 2021-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/libraries/I2C_24LC1025/README.md b/libraries/I2C_24LC1025/README.md index 338201b7..666e279c 100644 --- a/libraries/I2C_24LC1025/README.md +++ b/libraries/I2C_24LC1025/README.md @@ -8,7 +8,7 @@ # I2C_24LC1025 - I2C 1MB EEPROM -Arduino library for for external I2C EEPROM - 24LC1025 and equivalents e.g. 24AA1025/24FC1025 +Arduino library for for external I2C EEPROM - 24LC1025 and equivalents e.g. 24AA1025/24FC1025. ## Description @@ -32,7 +32,7 @@ Most important change is 32 bit memory addresses. ### Constructor -- **I2C_24LC1025(uint8_t deviceAddress, TwoWire \*wire = &Wire)** constructor, optional Wire interface +- **I2C_24LC1025(uint8_t deviceAddress, TwoWire \*wire = &Wire)** constructor, optional Wire interface. - **bool begin()** initializes the I2C bus and checks if the device is available on the I2C bus. - **bool begin(uint8_t sda, uint8_t scl)** idem for ESP32 / ESP8266 and alike. - **bool isConnected()** test to see if device is on the bus. @@ -41,7 +41,8 @@ Most important change is 32 bit memory addresses. ### Core functions - **int writeByte(uint32_t memoryAddress, uint8_t value)** write a single byte to the specified memory address. -- **int updateByte(uint32_t memoryAddress, uint8_t value)** write a single byte, but only if changed. Returns 0 if value was same or write succeeded. +- **int updateByte(uint32_t memoryAddress, uint8_t value)** write a single byte, but only if changed. +Returns 0 if value was same or write succeeded. - **int writeBlock(uint32_t memoryAddress, uint8_t \* buffer, uint32_t length)** write a buffer starting at the specified memory address. - **int updateBlock(uint32_t memoryAddress, uint8_t \* buffer, uint32_t length)** write a buffer starting at the specified memory address, but only if changed - **int setBlock(uint32_t memoryAddress, uint8_t value, uint32_t length)** writes the same byte to length places starting at the specified memory address. Returns 0 if OK. diff --git a/libraries/I2C_24LC1025/examples/24LC1025_format/24LC1025_format.ino b/libraries/I2C_24LC1025/examples/24LC1025_format/24LC1025_format.ino index 2f686a69..50aad892 100644 --- a/libraries/I2C_24LC1025/examples/24LC1025_format/24LC1025_format.ino +++ b/libraries/I2C_24LC1025/examples/24LC1025_format/24LC1025_format.ino @@ -11,6 +11,7 @@ I2C_24LC1025 ee(0x50); uint32_t start, stop; + void setup() { Serial.begin(115200); @@ -37,8 +38,11 @@ void setup() Serial.println("\nDone..."); } + void loop() { } + // -- END OF FILE -- + diff --git a/libraries/I2C_24LC1025/examples/24LC1025_test/24LC1025_test.ino b/libraries/I2C_24LC1025/examples/24LC1025_test/24LC1025_test.ino index f095e260..cd8433c2 100644 --- a/libraries/I2C_24LC1025/examples/24LC1025_test/24LC1025_test.ino +++ b/libraries/I2C_24LC1025/examples/24LC1025_test/24LC1025_test.ino @@ -1,9 +1,8 @@ // // FILE: 24LC1025_test.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: demo -// DATE: 2020 +// DATE: 2020-??-?? // (c) : MIT // @@ -44,6 +43,7 @@ void setup() Serial.println("\nDone..."); } + void loop() { } @@ -92,5 +92,5 @@ void test(uint32_t offset) } - // -- END OF FILE -- + diff --git a/libraries/I2C_24LC1025/examples/24LC1025_test_read/24LC1025_test_read.ino b/libraries/I2C_24LC1025/examples/24LC1025_test_read/24LC1025_test_read.ino index 1ec671d4..926117e2 100644 --- a/libraries/I2C_24LC1025/examples/24LC1025_test_read/24LC1025_test_read.ino +++ b/libraries/I2C_24LC1025/examples/24LC1025_test_read/24LC1025_test_read.ino @@ -1,20 +1,18 @@ // // FILE: 24LC1025_test_read.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: demo // DATE: 2020 // (c) : MIT -// #include "I2C_24LC1025.h" I2C_24LC1025 ee(0x50); - uint32_t start, stop; + void setup() { Serial.begin(115200); @@ -110,6 +108,7 @@ void setup() Serial.println("\nDone..."); } + void loop() { } @@ -135,7 +134,6 @@ void dump(uint32_t from, uint32_t to) } - void test(uint32_t offset) { Serial.println(); @@ -158,5 +156,5 @@ void test(uint32_t offset) } - // -- END OF FILE -- + diff --git a/libraries/I2C_24LC1025/library.json b/libraries/I2C_24LC1025/library.json index c2eccbe6..a7f5c261 100644 --- a/libraries/I2C_24LC1025/library.json +++ b/libraries/I2C_24LC1025/library.json @@ -1,6 +1,6 @@ { "name": "I2C_24LC1025", - "keywords": "24FC1025 24xx1025", + "keywords": "24FC1025,24xx1025", "description": "24FC1025 I2C EEPROM", "authors": [ @@ -15,8 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/I2C_24LC1025" }, - "version": "0.1.5", + "version": "0.1.6", "license": "MIT", "frameworks": "arduino", - "platforms": "*" + "platforms": "*", + "headers": "I2C_24LC1025.h" } diff --git a/libraries/I2C_24LC1025/library.properties b/libraries/I2C_24LC1025/library.properties index 4497343e..737aff68 100644 --- a/libraries/I2C_24LC1025/library.properties +++ b/libraries/I2C_24LC1025/library.properties @@ -1,5 +1,5 @@ name=I2C_24LC1025 -version=0.1.5 +version=0.1.6 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library for 24FC1025 I2C EEPROM diff --git a/libraries/I2C_24LC1025/test/unit_test_001.cpp b/libraries/I2C_24LC1025/test/unit_test_001.cpp index 435d12cf..710ba100 100644 --- a/libraries/I2C_24LC1025/test/unit_test_001.cpp +++ b/libraries/I2C_24LC1025/test/unit_test_001.cpp @@ -38,6 +38,7 @@ unittest_setup() { + fprintf(stderr, "I2C_24LC1025_VERSION: %s\n", (char *) I2C_24LC1025_VERSION); } unittest_teardown() @@ -45,6 +46,13 @@ unittest_teardown() } +unittest(test_constants) +{ + assertEqual(131072, I2C_DEVICESIZE_24LC1025); + assertEqual( 128, I2C_PAGESIZE_24LC1025); +} + + unittest(test_constructor) { Wire.resetMocks();