From ec88f7822ffc1f0329afaa8df07a14997b89aed9 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 14 Feb 2017 11:29:39 -0600 Subject: [PATCH 01/16] Initial commit of the I2C EEPROM device --- I2CEEBlockDevice.cpp | 138 +++++++++++++++++++++++++ I2CEEBlockDevice.h | 149 +++++++++++++++++++++++++++ LICENSE | 165 ++++++++++++++++++++++++++++++ README.md | 44 ++++++++ TESTS/block_device/i2cee/main.cpp | 145 ++++++++++++++++++++++++++ 5 files changed, 641 insertions(+) create mode 100644 I2CEEBlockDevice.cpp create mode 100644 I2CEEBlockDevice.h create mode 100644 LICENSE create mode 100644 README.md create mode 100644 TESTS/block_device/i2cee/main.cpp diff --git a/I2CEEBlockDevice.cpp b/I2CEEBlockDevice.cpp new file mode 100644 index 00000000000..4ebfe2d245c --- /dev/null +++ b/I2CEEBlockDevice.cpp @@ -0,0 +1,138 @@ +/* Simple access class for I2C EEPROM chips like Microchip 24LC + * Copyright (c) 2015 Robin Hourahane + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "I2CEEBlockDevice.h" + +#define I2CEE_TIMEOUT 10000 + + +I2CEEBlockDevice::I2CEEBlockDevice( + PinName sda, PinName scl, uint8_t addr, + bd_size_t size, bd_size_t block, int freq) + : _i2c(sda, scl), _i2c_addr(addr), _size(size), _block(block) +{ + _i2c.frequency(freq); +} + +bd_error_t I2CEEBlockDevice::init() +{ + return _sync(); +} + +bd_error_t I2CEEBlockDevice::deinit() +{ + return 0; +} + +bd_error_t I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) +{ + // Check the address and size fit onto the chip. + if (!is_valid_read(addr, size)) { + return BD_ERROR_PARAMETER; + } + + _i2c.start(); + if (!_i2c.write(_i2c_addr | 0) || + !_i2c.write((char)(addr >> 8)) || + !_i2c.write((char)(addr & 0xff))) { + return BD_ERROR_DEVICE_ERROR; + } + _i2c.stop(); + + if (_i2c.read(_i2c_addr, static_cast(buffer), size) < 0) { + return BD_ERROR_DEVICE_ERROR; + } + + return 0; +} + +bd_error_t I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size) +{ + // Check the addr and size fit onto the chip. + if (!is_valid_program(addr, size)) { + return BD_ERROR_PARAMETER; + } + + // While we have some more data to write. + while (size > 0) { + uint32_t off = addr % _block; + uint32_t chunk = (off + size < _block) ? size : (_block - off); + + _i2c.start(); + if (!_i2c.write(_i2c_addr | 0) || + !_i2c.write((char)(addr >> 8)) || + !_i2c.write((char)(addr & 0xff))) { + return BD_ERROR_DEVICE_ERROR; + } + + for (unsigned i = 0; i < chunk; i++) { + _i2c.write(static_cast(buffer)[i]); + } + _i2c.stop(); + + bd_error_t err = _sync(); + if (err) { + return err; + } + + addr += chunk; + size -= chunk; + buffer = static_cast(buffer) + chunk; + } + + return 0; +} + +bd_error_t I2CEEBlockDevice::erase(bd_addr_t addr, bd_size_t size) +{ + // No erase needed + return 0; +} + +bd_error_t I2CEEBlockDevice::_sync() +{ + // The chip doesn't ACK while writing to the actual EEPROM + // so loop trying to do a zero byte write until it is ACKed + // by the chip. + for (int i = 0; i < I2CEE_TIMEOUT; i++) { + if (_i2c.write(_i2c_addr | 0, 0, 0) < 1) { + return 0; + } + + wait_ms(1); + } + + return BD_ERROR_DEVICE_ERROR; +} + +bd_size_t I2CEEBlockDevice::get_read_size() +{ + return 1; +} + +bd_size_t I2CEEBlockDevice::get_program_size() +{ + return 1; +} + +bd_size_t I2CEEBlockDevice::get_erase_size() +{ + return 1; +} + +bd_size_t I2CEEBlockDevice::size() +{ + return _size; +} diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h new file mode 100644 index 00000000000..417de6dd708 --- /dev/null +++ b/I2CEEBlockDevice.h @@ -0,0 +1,149 @@ +/* Simple access class for I2C EEPROM chips like Microchip 24LC + * Copyright (c) 2015 Robin Hourahane + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MBED_I2CEEPROM_BLOCK_DEVICE_H +#define MBED_I2CEEPROM_BLOCK_DEVICE_H + +/* If the target has no I2C support then I2CEEPROM is not supported */ +#ifdef DEVICE_I2C + +#include +#include "BlockDevice.h" + + +/** BlockDevice for I2C based flash device such as + * Microchip's 24LC or ATMEL's AT24C ranges + * + * @code + * #include "mbed.h" + * #include "I2CEEBlockDevice.h" + * + * // Create 24LC device with 32Kbytes of memory + * I2CEEBlockDevice flash(D14, D15, 0xa0, 32*1024); + * + * int main() { + * printf("flash test\n"); + * mx52r.init(); + * printf("flash size: %llu\n", flash.size()); + * printf("flash read size: %llu\n", flash.get_read_size()); + * printf("flash program size: %llu\n", flash.get_program_size()); + * printf("flash erase size: %llu\n", flash.get_erase_size()); + * + * uint8_t *buffer = malloc(flash.get_erase_size()); + * sprintf(buffer, "Hello World!\n"); + * flash.erase(0, flash.get_erase_size()); + * flash.program(buffer, 0, flash.get_erase_size()); + * flash.read(buffer, 0, flash.get_erase_size()); + * printf("%s", buffer); + * + * flash.deinit(); + * } + */ +class I2CEEBlockDevice : public BlockDevice { +public: + /** Constructor to create an I2CEEBlockDevice on I2C pins + * + * @param sda The pin name for the sda line of the I2C bus. + * @param scl The pin name for the scl line of the I2C bus. + * @param addr The 8bit I2C address of the chip, common range 0xa0 - 0xae. + * @param size The size of the device in bytes + * @param block The page size of the device in bytes, defaults to 32bytes + * @param freq The frequency of the I2C bus, defaults to 400K. + */ + I2CEEBlockDevice( + PinName sda, PinName scl, uint8_t address, + bd_size_t size, bd_size_t block=32, + int bus_speed=400000); + + /** Initialize a block device + * + * @return 0 on success or a negative error code on failure + */ + virtual bd_error_t init(); + + /** Deinitialize a block device + * + * @return 0 on success or a negative error code on failure + */ + virtual bd_error_t deinit(); + + /** Read blocks from a block device + * + * @param buffer Buffer to write blocks to + * @param addr Address of block to begin reading from + * @param size Size to read in bytes, must be a multiple of read block size + * @return 0 on success, negative error code on failure + */ + virtual bd_error_t read(void *buffer, bd_addr_t addr, bd_size_t size); + + /** Program blocks to a block device + * + * The blocks must have been erased prior to being programmed + * + * @param buffer Buffer of data to write to blocks + * @param addr Address of block to begin writing to + * @param size Size to write in bytes, must be a multiple of program block size + * @return 0 on success, negative error code on failure + */ + virtual bd_error_t program(const void *buffer, bd_addr_t addr, bd_size_t size); + + /** Erase blocks on a block device + * + * The state of an erased block is undefined until it has been programmed + * + * @param addr Address of block to begin erasing + * @param size Size to erase in bytes, must be a multiple of erase block size + * @return 0 on success, negative error code on failure + */ + virtual bd_error_t erase(bd_addr_t addr, bd_size_t size); + + /** Get the size of a readable block + * + * @return Size of a readable block in bytes + */ + virtual bd_size_t get_read_size(); + + /** Get the size of a programable block + * + * @return Size of a programable block in bytes + * @note Must be a multiple of the read size + */ + virtual bd_size_t get_program_size(); + + /** Get the size of a eraseable block + * + * @return Size of a eraseable block in bytes + * @note Must be a multiple of the program size + */ + virtual bd_size_t get_erase_size(); + + /** Get the total size of the underlying device + * + * @return Size of the underlying device in bytes + */ + virtual bd_size_t size(); + +private: + I2C _i2c; + uint8_t _i2c_addr; + uint32_t _size; + uint32_t _block; + + bd_error_t _sync(); +}; + +#endif /* DEVICE_SPI */ + +#endif /* MBED_SD_BLOCK_DEVICE_H */ diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..59cd3f8a320 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..6456e84cc63 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# I2C EEPROM Driver + +Block device driver for I2C based EEPROM devices such as the 24LC or AT24C series of devices. + +EEPROM devices support much higher read/write cycles than flash based memory, at a cost in terms of size. Additionally, I2C EEPROM devices support byte-level read/writes with buffering of around 32bytes during writes. + +**Note:** The I2C convention for EEPROM devices does not support inspection of the memory layout of the device, so the size must be specified during construction of the driver. + +More info on EEPROM can be found on wikipedia: +https://en.wikipedia.org/wiki/EEPROM + +``` cpp +// Here's an example using a 24LC256 on a GR PEACH +#include "mbed.h" +#include "I2CEEBlockDevice.h" + +// Create EEPROM device on I2C bus with 32kbytes of memory +I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024); + +int main() { + printf("i2cee test\n"); + + // Initialize the device and print the memory layout + i2cee.init(); + printf("i2cee size: %llu\n", i2cee.size()); + printf("i2cee read size: %llu\n", i2cee.get_read_size()); + printf("i2cee program size: %llu\n", i2cee.get_program_size()); + printf("i2cee erase size: %llu\n", i2cee.get_erase_size()); + + // Write "Hello World!" to the first block + uint8_t *buffer = malloc(i2cee.get_erase_size()); + sprintf(buffer, "Hello World!\n"); + i2cee.erase(0, i2cee.get_erase_size()); + i2cee.program(buffer, 0, i2cee.get_erase_size()); + + // Read back what was stored + i2cee.read(buffer, 0, i2cee.get_erase_size()); + printf("%s", buffer); + + // Deinitialize the device + i2cee.deinit(); +} +``` + diff --git a/TESTS/block_device/i2cee/main.cpp b/TESTS/block_device/i2cee/main.cpp new file mode 100644 index 00000000000..4b80b4f676e --- /dev/null +++ b/TESTS/block_device/i2cee/main.cpp @@ -0,0 +1,145 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" + +#include "I2CEEBlockDevice.h" +#include + +using namespace utest::v1; + +//#if !I2CEE_INSTALLED +//#error [NOT_SUPPORTED] I2CEE Required +//#endif + +#define TEST_PINS D14, D15 +#define TEST_ADDR 0xa0 +#define TEST_SIZE 32*1024 +#define TEST_BLOCK_SIZE 64 +#define TEST_FREQ 400000 +#define TEST_BLOCK_COUNT 10 +#define TEST_ERROR_MASK 16 + +const struct { + const char *name; + bd_size_t (BlockDevice::*method)(); +} ATTRS[] = { + {"read size", &BlockDevice::get_read_size}, + {"program size", &BlockDevice::get_program_size}, + {"erase size", &BlockDevice::get_erase_size}, + {"total size", &BlockDevice::size}, +}; + + +void test_read_write() { + I2CEEBlockDevice bd(TEST_PINS, TEST_ADDR, + TEST_SIZE, TEST_BLOCK_SIZE, TEST_FREQ); + + int err = bd.init(); + TEST_ASSERT_EQUAL(0, err); + + for (unsigned a = 0; a < sizeof(ATTRS)/sizeof(ATTRS[0]); a++) { + static const char *prefixes[] = {"", "k", "M", "G"}; + for (int i = 3; i >= 0; i--) { + bd_size_t size = (bd.*ATTRS[a].method)(); + if (size >= (1ULL << 10*i)) { + printf("%s: %llu%sbytes (%llubytes)\n", + ATTRS[a].name, size >> 10*i, prefixes[i], size); + break; + } + } + } + + bd_size_t block_size = bd.get_erase_size(); + uint8_t *write_block = new uint8_t[block_size]; + uint8_t *read_block = new uint8_t[block_size]; + uint8_t *error_mask = new uint8_t[TEST_ERROR_MASK]; + unsigned addrwidth = ceil(log(bd.size()-1) / log(16))+1; + + for (int b = 0; b < TEST_BLOCK_COUNT; b++) { + // Find a random block + bd_addr_t block = (rand()*block_size) % bd.size(); + + // Use next random number as temporary seed to keep + // the address progressing in the pseudorandom sequence + unsigned seed = rand(); + + // Fill with random sequence + srand(seed); + for (bd_size_t i = 0; i < block_size; i++) { + write_block[i] = 0xff & rand(); + } + + // Write, sync, and read the block + printf("test %0*llx:%llu...\n", addrwidth, block, block_size); + + err = bd.write(write_block, block, block_size); + TEST_ASSERT_EQUAL(0, err); + + printf("write %0*llx:%llu ", addrwidth, block, block_size); + for (int i = 0; i < block_size && i < 16; i++) { + printf("%02x", write_block[i]); + } + if (block_size > 16) { + printf("...\n"); + } + printf("\n"); + + err = bd.read(read_block, block, block_size); + TEST_ASSERT_EQUAL(0, err); + + printf("read %0*llx:%llu ", addrwidth, block, block_size); + for (int i = 0; i < block_size && i < 16; i++) { + printf("%02x", read_block[i]); + } + if (block_size > 16) { + printf("..."); + } + printf("\n"); + + // Find error mask for debugging + memset(error_mask, 0, TEST_ERROR_MASK); + bd_size_t error_scale = block_size / (TEST_ERROR_MASK*8); + + srand(seed); + for (bd_size_t i = 0; i < TEST_ERROR_MASK*8; i++) { + for (bd_size_t j = 0; j < error_scale; j++) { + if ((0xff & rand()) != read_block[i*error_scale + j]) { + error_mask[i/8] |= 1 << (i%8); + } + } + } + + printf("error %0*llx:%llu ", addrwidth, block, block_size); + for (int i = 0; i < TEST_ERROR_MASK; i++) { + printf("%02x", error_mask[i]); + } + printf("\n"); + + // Check that the data was unmodified + srand(seed); + for (bd_size_t i = 0; i < block_size; i++) { + TEST_ASSERT_EQUAL(0xff & rand(), read_block[i]); + } + } + + err = bd.deinit(); + TEST_ASSERT_EQUAL(0, err); +} + + +// Test setup +utest::v1::status_t test_setup(const size_t number_of_cases) { + GREENTEA_SETUP(30, "default_auto"); + return verbose_test_setup_handler(number_of_cases); +} + +Case cases[] = { + Case("Testing read write random blocks", test_read_write), +}; + +Specification specification(test_setup, cases); + +int main() { + return !Harness::run(specification); +} From f3272ad5ba4875abde17758fe38ba0fddf39f363 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 7 Mar 2017 17:34:30 -0600 Subject: [PATCH 02/16] Updated to match API changes in mbed OS --- I2CEEBlockDevice.cpp | 30 +++++++++++++----------------- I2CEEBlockDevice.h | 24 ++++++++++-------------- TESTS/block_device/i2cee/main.cpp | 11 +++++------ 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/I2CEEBlockDevice.cpp b/I2CEEBlockDevice.cpp index 4ebfe2d245c..3ae66fc3a38 100644 --- a/I2CEEBlockDevice.cpp +++ b/I2CEEBlockDevice.cpp @@ -26,22 +26,20 @@ I2CEEBlockDevice::I2CEEBlockDevice( _i2c.frequency(freq); } -bd_error_t I2CEEBlockDevice::init() +int I2CEEBlockDevice::init() { return _sync(); } -bd_error_t I2CEEBlockDevice::deinit() +int I2CEEBlockDevice::deinit() { return 0; } -bd_error_t I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) +int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) { // Check the address and size fit onto the chip. - if (!is_valid_read(addr, size)) { - return BD_ERROR_PARAMETER; - } + MBED_ASSERT(is_valid_read(addr, size)); _i2c.start(); if (!_i2c.write(_i2c_addr | 0) || @@ -58,12 +56,10 @@ bd_error_t I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) return 0; } -bd_error_t I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size) +int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size) { // Check the addr and size fit onto the chip. - if (!is_valid_program(addr, size)) { - return BD_ERROR_PARAMETER; - } + MBED_ASSERT(is_valid_program(addr, size)); // While we have some more data to write. while (size > 0) { @@ -82,7 +78,7 @@ bd_error_t I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size } _i2c.stop(); - bd_error_t err = _sync(); + int err = _sync(); if (err) { return err; } @@ -95,13 +91,13 @@ bd_error_t I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size return 0; } -bd_error_t I2CEEBlockDevice::erase(bd_addr_t addr, bd_size_t size) +int I2CEEBlockDevice::erase(bd_addr_t addr, bd_size_t size) { // No erase needed return 0; } -bd_error_t I2CEEBlockDevice::_sync() +int I2CEEBlockDevice::_sync() { // The chip doesn't ACK while writing to the actual EEPROM // so loop trying to do a zero byte write until it is ACKed @@ -117,22 +113,22 @@ bd_error_t I2CEEBlockDevice::_sync() return BD_ERROR_DEVICE_ERROR; } -bd_size_t I2CEEBlockDevice::get_read_size() +bd_size_t I2CEEBlockDevice::get_read_size() const { return 1; } -bd_size_t I2CEEBlockDevice::get_program_size() +bd_size_t I2CEEBlockDevice::get_program_size() const { return 1; } -bd_size_t I2CEEBlockDevice::get_erase_size() +bd_size_t I2CEEBlockDevice::get_erase_size() const { return 1; } -bd_size_t I2CEEBlockDevice::size() +bd_size_t I2CEEBlockDevice::size() const { return _size; } diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index 417de6dd708..635ffd2d129 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -15,9 +15,6 @@ */ #ifndef MBED_I2CEEPROM_BLOCK_DEVICE_H #define MBED_I2CEEPROM_BLOCK_DEVICE_H - -/* If the target has no I2C support then I2CEEPROM is not supported */ -#ifdef DEVICE_I2C #include #include "BlockDevice.h" @@ -71,13 +68,13 @@ class I2CEEBlockDevice : public BlockDevice { * * @return 0 on success or a negative error code on failure */ - virtual bd_error_t init(); + virtual int init(); /** Deinitialize a block device * * @return 0 on success or a negative error code on failure */ - virtual bd_error_t deinit(); + virtual int deinit(); /** Read blocks from a block device * @@ -86,7 +83,7 @@ class I2CEEBlockDevice : public BlockDevice { * @param size Size to read in bytes, must be a multiple of read block size * @return 0 on success, negative error code on failure */ - virtual bd_error_t read(void *buffer, bd_addr_t addr, bd_size_t size); + virtual int read(void *buffer, bd_addr_t addr, bd_size_t size); /** Program blocks to a block device * @@ -97,7 +94,7 @@ class I2CEEBlockDevice : public BlockDevice { * @param size Size to write in bytes, must be a multiple of program block size * @return 0 on success, negative error code on failure */ - virtual bd_error_t program(const void *buffer, bd_addr_t addr, bd_size_t size); + virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size); /** Erase blocks on a block device * @@ -107,33 +104,33 @@ class I2CEEBlockDevice : public BlockDevice { * @param size Size to erase in bytes, must be a multiple of erase block size * @return 0 on success, negative error code on failure */ - virtual bd_error_t erase(bd_addr_t addr, bd_size_t size); + virtual int erase(bd_addr_t addr, bd_size_t size); /** Get the size of a readable block * * @return Size of a readable block in bytes */ - virtual bd_size_t get_read_size(); + virtual bd_size_t get_read_size() const; /** Get the size of a programable block * * @return Size of a programable block in bytes * @note Must be a multiple of the read size */ - virtual bd_size_t get_program_size(); + virtual bd_size_t get_program_size() const; /** Get the size of a eraseable block * * @return Size of a eraseable block in bytes * @note Must be a multiple of the program size */ - virtual bd_size_t get_erase_size(); + virtual bd_size_t get_erase_size() const; /** Get the total size of the underlying device * * @return Size of the underlying device in bytes */ - virtual bd_size_t size(); + virtual bd_size_t size() const; private: I2C _i2c; @@ -141,9 +138,8 @@ class I2CEEBlockDevice : public BlockDevice { uint32_t _size; uint32_t _block; - bd_error_t _sync(); + int _sync(); }; -#endif /* DEVICE_SPI */ #endif /* MBED_SD_BLOCK_DEVICE_H */ diff --git a/TESTS/block_device/i2cee/main.cpp b/TESTS/block_device/i2cee/main.cpp index 4b80b4f676e..2f191818cca 100644 --- a/TESTS/block_device/i2cee/main.cpp +++ b/TESTS/block_device/i2cee/main.cpp @@ -8,10 +8,6 @@ using namespace utest::v1; -//#if !I2CEE_INSTALLED -//#error [NOT_SUPPORTED] I2CEE Required -//#endif - #define TEST_PINS D14, D15 #define TEST_ADDR 0xa0 #define TEST_SIZE 32*1024 @@ -22,7 +18,7 @@ using namespace utest::v1; const struct { const char *name; - bd_size_t (BlockDevice::*method)(); + bd_size_t (BlockDevice::*method)() const; } ATTRS[] = { {"read size", &BlockDevice::get_read_size}, {"program size", &BlockDevice::get_program_size}, @@ -73,7 +69,10 @@ void test_read_write() { // Write, sync, and read the block printf("test %0*llx:%llu...\n", addrwidth, block, block_size); - err = bd.write(write_block, block, block_size); + err = bd.erase(block, block_size); + TEST_ASSERT_EQUAL(0, err); + + err = bd.program(write_block, block, block_size); TEST_ASSERT_EQUAL(0, err); printf("write %0*llx:%llu ", addrwidth, block, block_size); From bb61ee8da8a767b853aa17f84840616819c4beee Mon Sep 17 00:00:00 2001 From: Ashok Rao Date: Tue, 21 Mar 2017 17:24:46 +0000 Subject: [PATCH 03/16] Adding explicit type conversion to overloaded log function as ARMCC fails to compile --- TESTS/block_device/i2cee/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TESTS/block_device/i2cee/main.cpp b/TESTS/block_device/i2cee/main.cpp index 2f191818cca..846b5235197 100644 --- a/TESTS/block_device/i2cee/main.cpp +++ b/TESTS/block_device/i2cee/main.cpp @@ -50,7 +50,7 @@ void test_read_write() { uint8_t *write_block = new uint8_t[block_size]; uint8_t *read_block = new uint8_t[block_size]; uint8_t *error_mask = new uint8_t[TEST_ERROR_MASK]; - unsigned addrwidth = ceil(log(bd.size()-1) / log(16))+1; + unsigned addrwidth = ceil(log(float(bd.size()-1)) / log(float(16)))+1; for (int b = 0; b < TEST_BLOCK_COUNT; b++) { // Find a random block From 69da7212615388b3525e712348effce5f1876cfa Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 16 Jul 2017 13:23:19 -0500 Subject: [PATCH 04/16] Renamed LICENSE -> LICENSE.md --- LICENSE => LICENSE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE.md (100%) diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md From 2be4fafeb0b83527eeb936c3f3fc7cdbec9e8d60 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 16 Jul 2017 13:24:42 -0500 Subject: [PATCH 05/16] Added support for Travis CI --- .travis.yml | 28 ++++++++++++++++++++++++++++ I2CEEBlockDevice.h | 42 +++++++++++++++++++++++++----------------- README.md | 2 +- 3 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..ce00e0ee9c9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +script: + # Check that examples compile + - sed -n '/``` cpp/,${/```$/q;/```/d;p}' README.md > main.cpp && + PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F + --source=. --build=BUILD/K82F/GCC_ARM -j0 && + rm main.cpp + - sed -n '/@code/,${/@endcode/q;/@/d;s/^ \*//;p}' I2CEEBlockDevice.h > main.cpp && + PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F + --source=. --build=BUILD/K82F/GCC_ARM -j0 && + rm main.cpp + + # Check that tests compile + - rm -r BUILD && PYTHONPATH=mbed-os python mbed-os/tools/test.py + -t GCC_ARM -m K82F --source=. --build=BUILD/TESTS/K82F/GCC_ARM -j0 + -n tests* + +python: + - "2.7" + +install: + # Get arm-none-eabi-gcc + - sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded + - sudo apt-get update -qq + - sudo apt-get install -qq gcc-arm-none-eabi --force-yes + # Get dependencies + - git clone https://github.com/armmbed/mbed-os.git + # Install python dependencies + - sudo pip install -r mbed-os/requirements.txt diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index 635ffd2d129..5f31f7f790d 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -24,29 +24,37 @@ * Microchip's 24LC or ATMEL's AT24C ranges * * @code + * // Here's an example using a 24LC256 on a GR PEACH * #include "mbed.h" * #include "I2CEEBlockDevice.h" - * - * // Create 24LC device with 32Kbytes of memory - * I2CEEBlockDevice flash(D14, D15, 0xa0, 32*1024); - * + * + * // Create EEPROM device on I2C bus with 32kbytes of memory + * I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024); + * * int main() { - * printf("flash test\n"); - * mx52r.init(); - * printf("flash size: %llu\n", flash.size()); - * printf("flash read size: %llu\n", flash.get_read_size()); - * printf("flash program size: %llu\n", flash.get_program_size()); - * printf("flash erase size: %llu\n", flash.get_erase_size()); - * - * uint8_t *buffer = malloc(flash.get_erase_size()); + * printf("i2cee test\n"); + * + * // Initialize the device and print the memory layout + * i2cee.init(); + * printf("i2cee size: %llu\n", i2cee.size()); + * printf("i2cee read size: %llu\n", i2cee.get_read_size()); + * printf("i2cee program size: %llu\n", i2cee.get_program_size()); + * printf("i2cee erase size: %llu\n", i2cee.get_erase_size()); + * + * // Write "Hello World!" to the first block + * char *buffer = (char*)malloc(i2cee.get_erase_size()); * sprintf(buffer, "Hello World!\n"); - * flash.erase(0, flash.get_erase_size()); - * flash.program(buffer, 0, flash.get_erase_size()); - * flash.read(buffer, 0, flash.get_erase_size()); + * i2cee.erase(0, i2cee.get_erase_size()); + * i2cee.program(buffer, 0, i2cee.get_erase_size()); + * + * // Read back what was stored + * i2cee.read(buffer, 0, i2cee.get_erase_size()); * printf("%s", buffer); - * - * flash.deinit(); + * + * // Deinitialize the device + * i2cee.deinit(); * } + * @endcode */ class I2CEEBlockDevice : public BlockDevice { public: diff --git a/README.md b/README.md index 6456e84cc63..4d2bc22d3db 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ int main() { printf("i2cee erase size: %llu\n", i2cee.get_erase_size()); // Write "Hello World!" to the first block - uint8_t *buffer = malloc(i2cee.get_erase_size()); + char *buffer = (char*)malloc(i2cee.get_erase_size()); sprintf(buffer, "Hello World!\n"); i2cee.erase(0, i2cee.get_erase_size()); i2cee.program(buffer, 0, i2cee.get_erase_size()); From 55ff892f0c56816f1775f23e47e14dae767235be Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Sun, 7 May 2017 14:19:55 +0200 Subject: [PATCH 06/16] Saving struct example --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/README.md b/README.md index 4d2bc22d3db..8c373f1ab23 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ EEPROM devices support much higher read/write cycles than flash based memory, at More info on EEPROM can be found on wikipedia: https://en.wikipedia.org/wiki/EEPROM +## Basic example + ``` cpp // Here's an example using a 24LC256 on a GR PEACH #include "mbed.h" @@ -42,3 +44,58 @@ int main() { } ``` +## Saving struct example +``` cpp +// Here's an example using a 24LC256 to store a C struct +#include "mbed.h" +#include "I2CEEBlockDevice.h" + +#define BLOCK_SIZE 32 + +// Create EEPROM device on I2C bus with 32kbytes of memory +I2CEEBlockDevice i2cee(P0_0, P0_1, 0xA0, 32*1024, BLOCK_SIZE); + +uint8_t setting_block_size; + +struct t_setting { + uint8_t version; + char name[20]; +} setting = { + 1, + "Hello World!" +}; + +int main() { + printf("i2cee struct test\n"); + + // No. of bytes to be stored, but topped up to be multiplied by block size + unsigned int setting_block_size = ceil(sizeof(setting)/(double)BLOCK_SIZE)*BLOCK_SIZE; + + // Temporary buffer + char *buffer = (char*)malloc(setting_block_size); + + // Initialize the device + i2cee.init(); + + // Save struct to EEPROM + printf("\nSaving struct version: %u, name: %s\n", setting.version, setting.name); + memcpy(buffer, &setting, sizeof(setting)); + i2cee.program(buffer, 0, setting_block_size); + + // Get back what was stored + t_setting tmp; //Re-make the struct + memset(buffer, 0, sizeof(buffer)); // empty buffer, not nessesary but helps when debugging + + if (i2cee.read(buffer, 0, setting_block_size ) == 0){ // get data into buffer + // Convert what we read into struct + memcpy(&tmp, buffer, sizeof(tmp)); // copy only size of struct not setting_block_size + printf("\nTemporary struct version: %u, name: %s\n", tmp.version, tmp.name); + } else { + printf("Error when reading\n"); + } + + // Deinitialize the device + i2cee.deinit(); +} +``` + From 87056697f404f1c4d336ea46ac80d33e364e5564 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Mon, 18 Jun 2018 20:35:54 +0200 Subject: [PATCH 07/16] option to pass I2C object --- I2CEEBlockDevice.cpp | 17 ++++++++++++++++- I2CEEBlockDevice.h | 22 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/I2CEEBlockDevice.cpp b/I2CEEBlockDevice.cpp index 3ae66fc3a38..134df11cfa7 100644 --- a/I2CEEBlockDevice.cpp +++ b/I2CEEBlockDevice.cpp @@ -21,11 +21,26 @@ I2CEEBlockDevice::I2CEEBlockDevice( PinName sda, PinName scl, uint8_t addr, bd_size_t size, bd_size_t block, int freq) - : _i2c(sda, scl), _i2c_addr(addr), _size(size), _block(block) + : _i2c_p(new I2C(sda, scl)), _i2c(*_i2c_p), _i2c_addr(addr), + _size(size), _block(block) { _i2c.frequency(freq); } +I2CEEBlockDevice::I2CEEBlockDevice( + I2C &i2c_obj, uint8_t addr, + bd_size_t size, bd_size_t block) + : _i2c_p(NULL), _i2c(i2c_obj), _i2c_addr(addr), + _size(size), _block(block) +{ +} +I2CEEBlockDevice::~I2CEEBlockDevice() +{ + if (_i2c_p != NULL){ + delete _i2c_p; + } +} + int I2CEEBlockDevice::init() { return _sync(); diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index 5f31f7f790d..110eed64826 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -70,7 +70,24 @@ class I2CEEBlockDevice : public BlockDevice { I2CEEBlockDevice( PinName sda, PinName scl, uint8_t address, bd_size_t size, bd_size_t block=32, - int bus_speed=400000); + int bus_speed=400000); + + /** Constructor to create an I2CEEBlockDevice on I2C pins + * + * @param i2c The I2C instance + * @param addr The 8bit I2C address of the chip, common range 0xa0 - 0xae. + * @param size The size of the device in bytes + * @param block The page size of the device in bytes, defaults to 32bytes + * @param freq The frequency of the I2C bus, defaults to 400K. + */ + I2CEEBlockDevice( + I2C &i2c_obj, uint8_t address, + bd_size_t size, bd_size_t block=32); + + /** Destructor of I2CEEBlockDevice + */ + + virtual ~I2CEEBlockDevice(); /** Initialize a block device * @@ -141,7 +158,8 @@ class I2CEEBlockDevice : public BlockDevice { virtual bd_size_t size() const; private: - I2C _i2c; + I2C *_i2c_p; + I2C &_i2c; uint8_t _i2c_addr; uint32_t _size; uint32_t _block; From ffcc8501049e7f9594954f58f5e6e95a18c28683 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Mon, 18 Jun 2018 21:47:40 +0200 Subject: [PATCH 08/16] requested changes --- I2CEEBlockDevice.cpp | 42 ++++++++++++++++++++---------------------- I2CEEBlockDevice.h | 7 +++---- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/I2CEEBlockDevice.cpp b/I2CEEBlockDevice.cpp index 134df11cfa7..59f9926fe2d 100644 --- a/I2CEEBlockDevice.cpp +++ b/I2CEEBlockDevice.cpp @@ -21,24 +21,22 @@ I2CEEBlockDevice::I2CEEBlockDevice( PinName sda, PinName scl, uint8_t addr, bd_size_t size, bd_size_t block, int freq) - : _i2c_p(new I2C(sda, scl)), _i2c(*_i2c_p), _i2c_addr(addr), - _size(size), _block(block) + : _i2c_addr(addr), _size(size), _block(block) { - _i2c.frequency(freq); + _i2c = new I2C(sda, scl); + _i2c->frequency(freq); } I2CEEBlockDevice::I2CEEBlockDevice( - I2C &i2c_obj, uint8_t addr, + I2C * i2c_obj, uint8_t addr, bd_size_t size, bd_size_t block) - : _i2c_p(NULL), _i2c(i2c_obj), _i2c_addr(addr), - _size(size), _block(block) + : _i2c_addr(addr), _size(size), _block(block) { + _i2c = i2c_obj; } I2CEEBlockDevice::~I2CEEBlockDevice() { - if (_i2c_p != NULL){ - delete _i2c_p; - } + _i2c->~I2C(); } int I2CEEBlockDevice::init() @@ -56,15 +54,15 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) // Check the address and size fit onto the chip. MBED_ASSERT(is_valid_read(addr, size)); - _i2c.start(); - if (!_i2c.write(_i2c_addr | 0) || - !_i2c.write((char)(addr >> 8)) || - !_i2c.write((char)(addr & 0xff))) { + _i2c->start(); + if (!_i2c->write(_i2c_addr | 0) || + !_i2c->write((char)(addr >> 8)) || + !_i2c->write((char)(addr & 0xff))) { return BD_ERROR_DEVICE_ERROR; } - _i2c.stop(); + _i2c->stop(); - if (_i2c.read(_i2c_addr, static_cast(buffer), size) < 0) { + if (_i2c->read(_i2c_addr, static_cast(buffer), size) < 0) { return BD_ERROR_DEVICE_ERROR; } @@ -81,17 +79,17 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size uint32_t off = addr % _block; uint32_t chunk = (off + size < _block) ? size : (_block - off); - _i2c.start(); - if (!_i2c.write(_i2c_addr | 0) || - !_i2c.write((char)(addr >> 8)) || - !_i2c.write((char)(addr & 0xff))) { + _i2c->start(); + if (!_i2c->write(_i2c_addr | 0) || + !_i2c->write((char)(addr >> 8)) || + !_i2c->write((char)(addr & 0xff))) { return BD_ERROR_DEVICE_ERROR; } for (unsigned i = 0; i < chunk; i++) { - _i2c.write(static_cast(buffer)[i]); + _i2c->write(static_cast(buffer)[i]); } - _i2c.stop(); + _i2c->stop(); int err = _sync(); if (err) { @@ -118,7 +116,7 @@ int I2CEEBlockDevice::_sync() // so loop trying to do a zero byte write until it is ACKed // by the chip. for (int i = 0; i < I2CEE_TIMEOUT; i++) { - if (_i2c.write(_i2c_addr | 0, 0, 0) < 1) { + if (_i2c->write(_i2c_addr | 0, 0, 0) < 1) { return 0; } diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index 110eed64826..d85643d1739 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -74,14 +74,14 @@ class I2CEEBlockDevice : public BlockDevice { /** Constructor to create an I2CEEBlockDevice on I2C pins * - * @param i2c The I2C instance + * @param i2c The I2C instance pointer * @param addr The 8bit I2C address of the chip, common range 0xa0 - 0xae. * @param size The size of the device in bytes * @param block The page size of the device in bytes, defaults to 32bytes * @param freq The frequency of the I2C bus, defaults to 400K. */ I2CEEBlockDevice( - I2C &i2c_obj, uint8_t address, + I2C * i2c_obj, uint8_t address, bd_size_t size, bd_size_t block=32); /** Destructor of I2CEEBlockDevice @@ -158,8 +158,7 @@ class I2CEEBlockDevice : public BlockDevice { virtual bd_size_t size() const; private: - I2C *_i2c_p; - I2C &_i2c; + I2C * _i2c; uint8_t _i2c_addr; uint32_t _size; uint32_t _block; From b440d721140d07734648417d8f0ed47f7ed88e97 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 25 Jul 2018 11:40:00 -0500 Subject: [PATCH 09/16] Changed I2C default instance to use placement new --- I2CEEBlockDevice.cpp | 6 ++++-- I2CEEBlockDevice.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/I2CEEBlockDevice.cpp b/I2CEEBlockDevice.cpp index 59f9926fe2d..e1870ab529b 100644 --- a/I2CEEBlockDevice.cpp +++ b/I2CEEBlockDevice.cpp @@ -23,7 +23,7 @@ I2CEEBlockDevice::I2CEEBlockDevice( bd_size_t size, bd_size_t block, int freq) : _i2c_addr(addr), _size(size), _block(block) { - _i2c = new I2C(sda, scl); + _i2c = new (_i2c_buffer) I2C(sda, scl); _i2c->frequency(freq); } @@ -36,7 +36,9 @@ I2CEEBlockDevice::I2CEEBlockDevice( } I2CEEBlockDevice::~I2CEEBlockDevice() { - _i2c->~I2C(); + if (_i2c == (I2C*)_i2c_buffer) { + _i2c->~I2C(); + } } int I2CEEBlockDevice::init() diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index d85643d1739..da4732d1e75 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -159,6 +159,7 @@ class I2CEEBlockDevice : public BlockDevice { private: I2C * _i2c; + uint32_t _i2c_buffer[sizeof(I2C) / sizeof(uint32_t)]; uint8_t _i2c_addr; uint32_t _size; uint32_t _block; From 0eb3475c75e9dff7c6c43f95746fdd2b1c68c2f9 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Fri, 11 Jan 2019 14:10:29 +0100 Subject: [PATCH 10/16] add missing get_type() from BlockDevice --- I2CEEBlockDevice.cpp | 5 +++++ I2CEEBlockDevice.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/I2CEEBlockDevice.cpp b/I2CEEBlockDevice.cpp index e1870ab529b..7a0fed2a6d4 100644 --- a/I2CEEBlockDevice.cpp +++ b/I2CEEBlockDevice.cpp @@ -147,3 +147,8 @@ bd_size_t I2CEEBlockDevice::size() const { return _size; } + +const char *I2CEEBlockDevice::get_type() const +{ + return "I2CEE"; +} diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index da4732d1e75..0e083eae672 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -156,6 +156,12 @@ class I2CEEBlockDevice : public BlockDevice { * @return Size of the underlying device in bytes */ virtual bd_size_t size() const; + + /** Get the BlockDevice class type. + * + * @return A string representation of the BlockDevice class type. + */ + virtual const char *get_type() const; private: I2C * _i2c; From b87c0f60f3b2ea2d6a980721daba721108dd5408 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 29 May 2019 16:20:22 -0500 Subject: [PATCH 11/16] Fixed travis issues - Needed new gcc-arm-embedded ppa - dist: Trusty did not allow apt-get update to work - test.py is no longer working as it once was - Needed to update pip versions --- .travis.yml | 34 ++++++++++++++++------------------ I2CEEBlockDevice.h | 2 +- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce00e0ee9c9..db59ff7e5b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,19 @@ +dist: xenial +language: python +python: 2.7 + +install: + # Get arm-none-eabi-gcc + - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa + - sudo apt-get update -qq + - sudo apt-get install -qq gcc-arm-embedded + # Get dependencies + - git clone https://github.com/armmbed/mbed-os.git + # Install python dependencies +# - python -m pip install --upgrade pip==18.1 +# - python -m pip install --upgrade setuptools==40.4.3 + - pip install -r mbed-os/requirements.txt + script: # Check that examples compile - sed -n '/``` cpp/,${/```$/q;/```/d;p}' README.md > main.cpp && @@ -8,21 +24,3 @@ script: PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F --source=. --build=BUILD/K82F/GCC_ARM -j0 && rm main.cpp - - # Check that tests compile - - rm -r BUILD && PYTHONPATH=mbed-os python mbed-os/tools/test.py - -t GCC_ARM -m K82F --source=. --build=BUILD/TESTS/K82F/GCC_ARM -j0 - -n tests* - -python: - - "2.7" - -install: - # Get arm-none-eabi-gcc - - sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded - - sudo apt-get update -qq - - sudo apt-get install -qq gcc-arm-none-eabi --force-yes - # Get dependencies - - git clone https://github.com/armmbed/mbed-os.git - # Install python dependencies - - sudo pip install -r mbed-os/requirements.txt diff --git a/I2CEEBlockDevice.h b/I2CEEBlockDevice.h index 0e083eae672..ed2b69c13fb 100644 --- a/I2CEEBlockDevice.h +++ b/I2CEEBlockDevice.h @@ -16,7 +16,7 @@ #ifndef MBED_I2CEEPROM_BLOCK_DEVICE_H #define MBED_I2CEEPROM_BLOCK_DEVICE_H -#include +#include "mbed.h" #include "BlockDevice.h" From b0d36ebfc1b689b7146bf1e78ec4704a69311ac8 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 13 Jun 2019 11:32:53 -0500 Subject: [PATCH 12/16] Remove mbed.h includes from I2CEEBlockDevice --- .../blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp | 2 ++ .../blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h | 9 ++++----- targets/targets.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp index 7a0fed2a6d4..9182eaf198a 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ #include "I2CEEBlockDevice.h" +#include "mbed_wait_api.h" +using namespace mbed; #define I2CEE_TIMEOUT 10000 diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h index ed2b69c13fb..a86631e1307 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h @@ -16,9 +16,8 @@ #ifndef MBED_I2CEEPROM_BLOCK_DEVICE_H #define MBED_I2CEEPROM_BLOCK_DEVICE_H -#include "mbed.h" #include "BlockDevice.h" - +#include "I2C.h" /** BlockDevice for I2C based flash device such as * Microchip's 24LC or ATMEL's AT24C ranges @@ -81,7 +80,7 @@ class I2CEEBlockDevice : public BlockDevice { * @param freq The frequency of the I2C bus, defaults to 400K. */ I2CEEBlockDevice( - I2C * i2c_obj, uint8_t address, + mbed::I2C * i2c_obj, uint8_t address, bd_size_t size, bd_size_t block=32); /** Destructor of I2CEEBlockDevice @@ -164,8 +163,8 @@ class I2CEEBlockDevice : public BlockDevice { virtual const char *get_type() const; private: - I2C * _i2c; - uint32_t _i2c_buffer[sizeof(I2C) / sizeof(uint32_t)]; + mbed::I2C * _i2c; + uint32_t _i2c_buffer[sizeof(mbed::I2C) / sizeof(uint32_t)]; uint8_t _i2c_addr; uint32_t _size; uint32_t _block; diff --git a/targets/targets.json b/targets/targets.json index 8a525f8fd4d..325c32c6ccf 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -1470,7 +1470,7 @@ }, "K64F": { "supported_form_factors": ["ARDUINO"], - "components_add": ["SD", "FLASHIAP"], + "components_add": ["SD", "FLASHIAP", "I2CEE"], "core": "Cortex-M4F", "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], "extra_labels": [ From 7ff5a45a24f92fdc7fdae7d9c426d22c5ec57160 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Tue, 6 Aug 2019 15:57:16 +0200 Subject: [PATCH 13/16] replace wait with rtos sleep --- .../storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp index 9182eaf198a..57016e99375 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ #include "I2CEEBlockDevice.h" -#include "mbed_wait_api.h" +#include "rtos/ThisThread.h" using namespace mbed; #define I2CEE_TIMEOUT 10000 @@ -124,7 +124,7 @@ int I2CEEBlockDevice::_sync() return 0; } - wait_ms(1); + rtos::ThisThread::sleep_for(1); } return BD_ERROR_DEVICE_ERROR; From 7b0a8f23a2dcc4aab4777b08639a0a05ca0558d4 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Tue, 13 Aug 2019 21:42:10 +0200 Subject: [PATCH 14/16] atyle format --- .../COMPONENT_I2CEE/I2CEEBlockDevice.cpp | 37 ++++++++------ .../COMPONENT_I2CEE/I2CEEBlockDevice.h | 51 ++++++++++--------- .../TESTS/block_device/i2cee/main.cpp | 44 +++++++++++----- 3 files changed, 77 insertions(+), 55 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp index 57016e99375..42bbce7c96b 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp @@ -18,11 +18,11 @@ using namespace mbed; #define I2CEE_TIMEOUT 10000 - + I2CEEBlockDevice::I2CEEBlockDevice( - PinName sda, PinName scl, uint8_t addr, - bd_size_t size, bd_size_t block, int freq) + PinName sda, PinName scl, uint8_t addr, + bd_size_t size, bd_size_t block, int freq) : _i2c_addr(addr), _size(size), _block(block) { _i2c = new (_i2c_buffer) I2C(sda, scl); @@ -30,15 +30,15 @@ I2CEEBlockDevice::I2CEEBlockDevice( } I2CEEBlockDevice::I2CEEBlockDevice( - I2C * i2c_obj, uint8_t addr, - bd_size_t size, bd_size_t block) + I2C *i2c_obj, uint8_t addr, + bd_size_t size, bd_size_t block) : _i2c_addr(addr), _size(size), _block(block) { _i2c = i2c_obj; } I2CEEBlockDevice::~I2CEEBlockDevice() { - if (_i2c == (I2C*)_i2c_buffer) { + if (_i2c == (I2C *)_i2c_buffer) { _i2c->~I2C(); } } @@ -59,50 +59,55 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) MBED_ASSERT(is_valid_read(addr, size)); _i2c->start(); + if (!_i2c->write(_i2c_addr | 0) || - !_i2c->write((char)(addr >> 8)) || - !_i2c->write((char)(addr & 0xff))) { + !_i2c->write((char)(addr >> 8)) || + !_i2c->write((char)(addr & 0xff))) { return BD_ERROR_DEVICE_ERROR; } + _i2c->stop(); - if (_i2c->read(_i2c_addr, static_cast(buffer), size) < 0) { + if (_i2c->read(_i2c_addr, static_cast(buffer), size) < 0) { return BD_ERROR_DEVICE_ERROR; } return 0; } - + int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size) { // Check the addr and size fit onto the chip. MBED_ASSERT(is_valid_program(addr, size)); - + // While we have some more data to write. while (size > 0) { uint32_t off = addr % _block; uint32_t chunk = (off + size < _block) ? size : (_block - off); _i2c->start(); + if (!_i2c->write(_i2c_addr | 0) || - !_i2c->write((char)(addr >> 8)) || - !_i2c->write((char)(addr & 0xff))) { + !_i2c->write((char)(addr >> 8)) || + !_i2c->write((char)(addr & 0xff))) { return BD_ERROR_DEVICE_ERROR; } for (unsigned i = 0; i < chunk; i++) { - _i2c->write(static_cast(buffer)[i]); + _i2c->write(static_cast(buffer)[i]); } + _i2c->stop(); int err = _sync(); + if (err) { return err; } addr += chunk; size -= chunk; - buffer = static_cast(buffer) + chunk; + buffer = static_cast(buffer) + chunk; } return 0; @@ -129,7 +134,7 @@ int I2CEEBlockDevice::_sync() return BD_ERROR_DEVICE_ERROR; } - + bd_size_t I2CEEBlockDevice::get_read_size() const { return 1; diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h index a86631e1307..4cc94ce209c 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h @@ -15,10 +15,10 @@ */ #ifndef MBED_I2CEEPROM_BLOCK_DEVICE_H #define MBED_I2CEEPROM_BLOCK_DEVICE_H - + #include "BlockDevice.h" #include "I2C.h" - + /** BlockDevice for I2C based flash device such as * Microchip's 24LC or ATMEL's AT24C ranges * @@ -26,36 +26,37 @@ * // Here's an example using a 24LC256 on a GR PEACH * #include "mbed.h" * #include "I2CEEBlockDevice.h" - * + * * // Create EEPROM device on I2C bus with 32kbytes of memory * I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024); - * + * * int main() { * printf("i2cee test\n"); - * + * * // Initialize the device and print the memory layout * i2cee.init(); * printf("i2cee size: %llu\n", i2cee.size()); * printf("i2cee read size: %llu\n", i2cee.get_read_size()); * printf("i2cee program size: %llu\n", i2cee.get_program_size()); * printf("i2cee erase size: %llu\n", i2cee.get_erase_size()); - * + * * // Write "Hello World!" to the first block * char *buffer = (char*)malloc(i2cee.get_erase_size()); * sprintf(buffer, "Hello World!\n"); * i2cee.erase(0, i2cee.get_erase_size()); * i2cee.program(buffer, 0, i2cee.get_erase_size()); - * + * * // Read back what was stored * i2cee.read(buffer, 0, i2cee.get_erase_size()); * printf("%s", buffer); - * + * * // Deinitialize the device * i2cee.deinit(); * } * @endcode */ -class I2CEEBlockDevice : public BlockDevice { +class I2CEEBlockDevice : public BlockDevice +{ public: /** Constructor to create an I2CEEBlockDevice on I2C pins * @@ -67,21 +68,21 @@ class I2CEEBlockDevice : public BlockDevice { * @param freq The frequency of the I2C bus, defaults to 400K. */ I2CEEBlockDevice( - PinName sda, PinName scl, uint8_t address, - bd_size_t size, bd_size_t block=32, - int bus_speed=400000); + PinName sda, PinName scl, uint8_t address, + bd_size_t size, bd_size_t block = 32, + int bus_speed = 400000); - /** Constructor to create an I2CEEBlockDevice on I2C pins - * - * @param i2c The I2C instance pointer - * @param addr The 8bit I2C address of the chip, common range 0xa0 - 0xae. - * @param size The size of the device in bytes - * @param block The page size of the device in bytes, defaults to 32bytes - * @param freq The frequency of the I2C bus, defaults to 400K. - */ + /** Constructor to create an I2CEEBlockDevice on I2C pins + * + * @param i2c The I2C instance pointer + * @param addr The 8bit I2C address of the chip, common range 0xa0 - 0xae. + * @param size The size of the device in bytes + * @param block The page size of the device in bytes, defaults to 32bytes + * @param freq The frequency of the I2C bus, defaults to 400K. + */ I2CEEBlockDevice( - mbed::I2C * i2c_obj, uint8_t address, - bd_size_t size, bd_size_t block=32); + mbed::I2C *i2c_obj, uint8_t address, + bd_size_t size, bd_size_t block = 32); /** Destructor of I2CEEBlockDevice */ @@ -161,9 +162,9 @@ class I2CEEBlockDevice : public BlockDevice { * @return A string representation of the BlockDevice class type. */ virtual const char *get_type() const; - + private: - mbed::I2C * _i2c; + mbed::I2C *_i2c; uint32_t _i2c_buffer[sizeof(mbed::I2C) / sizeof(uint32_t)]; uint8_t _i2c_addr; uint32_t _size; @@ -171,6 +172,6 @@ class I2CEEBlockDevice : public BlockDevice { int _sync(); }; - + #endif /* MBED_SD_BLOCK_DEVICE_H */ diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/TESTS/block_device/i2cee/main.cpp b/components/storage/blockdevice/COMPONENT_I2CEE/TESTS/block_device/i2cee/main.cpp index 846b5235197..dd167d1c5d2 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/TESTS/block_device/i2cee/main.cpp +++ b/components/storage/blockdevice/COMPONENT_I2CEE/TESTS/block_device/i2cee/main.cpp @@ -27,20 +27,23 @@ const struct { }; -void test_read_write() { +void test_read_write() +{ I2CEEBlockDevice bd(TEST_PINS, TEST_ADDR, - TEST_SIZE, TEST_BLOCK_SIZE, TEST_FREQ); + TEST_SIZE, TEST_BLOCK_SIZE, TEST_FREQ); int err = bd.init(); TEST_ASSERT_EQUAL(0, err); - for (unsigned a = 0; a < sizeof(ATTRS)/sizeof(ATTRS[0]); a++) { + for (unsigned a = 0; a < sizeof(ATTRS) / sizeof(ATTRS[0]); a++) { static const char *prefixes[] = {"", "k", "M", "G"}; + for (int i = 3; i >= 0; i--) { bd_size_t size = (bd.*ATTRS[a].method)(); - if (size >= (1ULL << 10*i)) { + + if (size >= (1ULL << 10 * i)) { printf("%s: %llu%sbytes (%llubytes)\n", - ATTRS[a].name, size >> 10*i, prefixes[i], size); + ATTRS[a].name, size >> 10 * i, prefixes[i], size); break; } } @@ -50,11 +53,11 @@ void test_read_write() { uint8_t *write_block = new uint8_t[block_size]; uint8_t *read_block = new uint8_t[block_size]; uint8_t *error_mask = new uint8_t[TEST_ERROR_MASK]; - unsigned addrwidth = ceil(log(float(bd.size()-1)) / log(float(16)))+1; + unsigned addrwidth = ceil(log(float(bd.size() - 1)) / log(float(16))) + 1; for (int b = 0; b < TEST_BLOCK_COUNT; b++) { // Find a random block - bd_addr_t block = (rand()*block_size) % bd.size(); + bd_addr_t block = (rand() * block_size) % bd.size(); // Use next random number as temporary seed to keep // the address progressing in the pseudorandom sequence @@ -62,6 +65,7 @@ void test_read_write() { // Fill with random sequence srand(seed); + for (bd_size_t i = 0; i < block_size; i++) { write_block[i] = 0xff & rand(); } @@ -76,59 +80,70 @@ void test_read_write() { TEST_ASSERT_EQUAL(0, err); printf("write %0*llx:%llu ", addrwidth, block, block_size); + for (int i = 0; i < block_size && i < 16; i++) { printf("%02x", write_block[i]); } + if (block_size > 16) { printf("...\n"); } + printf("\n"); err = bd.read(read_block, block, block_size); TEST_ASSERT_EQUAL(0, err); printf("read %0*llx:%llu ", addrwidth, block, block_size); + for (int i = 0; i < block_size && i < 16; i++) { printf("%02x", read_block[i]); } + if (block_size > 16) { printf("..."); } + printf("\n"); // Find error mask for debugging memset(error_mask, 0, TEST_ERROR_MASK); - bd_size_t error_scale = block_size / (TEST_ERROR_MASK*8); + bd_size_t error_scale = block_size / (TEST_ERROR_MASK * 8); srand(seed); - for (bd_size_t i = 0; i < TEST_ERROR_MASK*8; i++) { + + for (bd_size_t i = 0; i < TEST_ERROR_MASK * 8; i++) { for (bd_size_t j = 0; j < error_scale; j++) { - if ((0xff & rand()) != read_block[i*error_scale + j]) { - error_mask[i/8] |= 1 << (i%8); + if ((0xff & rand()) != read_block[i * error_scale + j]) { + error_mask[i / 8] |= 1 << (i % 8); } } } printf("error %0*llx:%llu ", addrwidth, block, block_size); + for (int i = 0; i < TEST_ERROR_MASK; i++) { printf("%02x", error_mask[i]); } + printf("\n"); // Check that the data was unmodified srand(seed); + for (bd_size_t i = 0; i < block_size; i++) { TEST_ASSERT_EQUAL(0xff & rand(), read_block[i]); } } - + err = bd.deinit(); TEST_ASSERT_EQUAL(0, err); } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(30, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -139,6 +154,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } From 4974c86b54f41ab40aae6161863d9e422e1acaf3 Mon Sep 17 00:00:00 2001 From: Pavel Slama Date: Tue, 13 Aug 2019 21:48:18 +0200 Subject: [PATCH 15/16] astyle fix bracket --- .../storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h index 4cc94ce209c..dbaf71b51a3 100644 --- a/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h @@ -55,8 +55,7 @@ * } * @endcode */ -class I2CEEBlockDevice : public BlockDevice -{ +class I2CEEBlockDevice : public BlockDevice { public: /** Constructor to create an I2CEEBlockDevice on I2C pins * From 3057ac16dcdf4658bb192f128fec3c81a0819592 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Thu, 29 Aug 2019 11:22:07 +0300 Subject: [PATCH 16/16] Remove I2CEE component from K64F --- targets/targets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/targets.json b/targets/targets.json index 325c32c6ccf..8a525f8fd4d 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -1470,7 +1470,7 @@ }, "K64F": { "supported_form_factors": ["ARDUINO"], - "components_add": ["SD", "FLASHIAP", "I2CEE"], + "components_add": ["SD", "FLASHIAP"], "core": "Cortex-M4F", "supported_toolchains": ["ARM", "GCC_ARM", "IAR"], "extra_labels": [