{"id":22665074,"url":"https://github.com/smfsw/ci2c","last_synced_at":"2025-10-10T20:12:59.799Z","repository":{"id":159708962,"uuid":"79145734","full_name":"SMFSW/cI2C","owner":"SMFSW","description":"Arduino Hardware I2C for AVR (plain c)","archived":false,"fork":false,"pushed_at":"2025-04-30T21:26:18.000Z","size":711,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T22:32:26.035Z","etag":null,"topics":["arduino","arduino-library","avr","i2c-bus"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SMFSW.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-01-16T18:18:01.000Z","updated_at":"2025-04-30T21:26:21.000Z","dependencies_parsed_at":"2023-07-13T13:46:06.313Z","dependency_job_id":null,"html_url":"https://github.com/SMFSW/cI2C","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/SMFSW/cI2C","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SMFSW%2FcI2C","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SMFSW%2FcI2C/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SMFSW%2FcI2C/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SMFSW%2FcI2C/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SMFSW","download_url":"https://codeload.github.com/SMFSW/cI2C/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SMFSW%2FcI2C/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005265,"owners_count":26083861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-library","avr","i2c-bus"],"created_at":"2024-12-09T13:19:17.247Z","updated_at":"2025-10-10T20:12:59.794Z","avatar_url":"https://github.com/SMFSW.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cI2C\n\n[![author](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/SMFSW/a9a2b2a02fda1b33461d53ddfe69d649/raw/auth_SMFSW.json)](https://github.com/SMFSW)\n![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/SMFSW/a9a2b2a02fda1b33461d53ddfe69d649/raw/cI2C_status_badge.json)\n[![license](https://img.shields.io/badge/License-MIT-darkred.svg)](LICENSE)\n[![CodeFactor](https://www.codefactor.io/repository/github/smfsw/ci2c/badge)](https://www.codefactor.io/repository/github/smfsw/ci2c)\n\n![platform](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/SMFSW/a9a2b2a02fda1b33461d53ddfe69d649/raw/platform_INO.json)\n\n[![doxy](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/SMFSW/a9a2b2a02fda1b33461d53ddfe69d649/raw/tool_DOXY.json)](https://smfsw.github.io/cI2C)\n[![re_note](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/SMFSW/a9a2b2a02fda1b33461d53ddfe69d649/raw/tool_RN.json)](ReleaseNotes.md)\n\nArduino Hardware I2C for AVR (plain c)\n\nHardware I2C library for AVR MCUs (lib intended for I2C protocols development in c, for easier ports to other MCUs)\n\n## Library choice\n\n* cI2C library implements I2C bus for AVR targets (Uno, Nano, Mega...)\n  * you may prefer this one when:\n    * working on AVR targets\n    * interrupts are not needed\n* WireWrapper implements I2C bus for every platform that includes Wire library\n  * you would have to use this one when:\n    * working on non-AVR targets\n    * portability is needed (using Wire library)\n\nNo refactoring is required when switching between **cI2C** \u0026 **WireWrapper** libs;\nBoth libs share same Typedefs, Functions \u0026 Parameters.\n\n## Notes\n\n* cI2C is written in plain c (intentionally)\n* cI2C does not use any interrupt (yet, but soon will have to)\n* cI2C is designed to act as bus Master (Slave mode will be considered in future releases)\n* cI2C is set to work on AVR targets only\n  * for other targets, you may use **WireWrapper** instead (will be using Wire)\n\n## Usage\n\nThis library is intended to be able to work with multiple slaves connected on the same I2C bus.\nThus, the I2C bus and Slaves are defined separately.\n\n* On one hand, I2C bus has to be initialized with appropriate speed:\n  * use `I2C_init(speed)`: speed can be chosen from `I2C_SPEED` enum for convenience, or passing an integer as parameter\n* On the other hand, Slave(s) have to be defined and initialized too:\n  * use `I2C_SLAVE` typedef to declare slaves structs\n  * use `I2C_slave_init(pSlave, addr, regsize)`\n    * `pSlave`: pointer to the slave struct to initialize\n    * `addr`: slave I2C address (don't shift addr, lib takes care of that)\n    * `regsize`: width of internal slave registers (to be chosen from `I2C_INT_SIZE`)\n  * in case you need to use custom R/W procedures for a particular slave:\n    * use `I2C_slave_set_rw_func(pSlave, pFunc, rw)`\n      * `pSlave`: pointer to the slave declaration to initialize\n      * `pFunc`: pointer to the Read or Write bypass function\n      * `rw`: can be chosen from `I2C_RW` enum (wr=0, rd=1)\n\nAfter all inits are done, the lib can basically be used this way:\n* `I2C_read(pSlave, regaddr, pData, bytes)`\n  * `pSlave`: pointer to the slave struct to read from\n  * `regaddr`: start address to read from\n  * `pData`: pointer to the place where datas read will be stored\n  * `bytes`: number of bytes to read from slave\n  * returns `true` if read is ok, `false` otherwise\n* `I2C_write(pSlave, regaddr, pData, bytes)`\n  * `pSlave`: pointer to the slave struct to write to\n  * `regaddr`: start address to write to\n  * `pData`: pointer to the block of datas to write to slave\n  * `bytes`: number of bytes to write to slave\n  * returns `true` if write is ok, `false` otherwise\n\n## Examples included\n\nfollowing examples should work with any I2C EEPROM/FRAM with address 0x50\n(yet function to get Chip ID are device dependent (and will probably only work on FUJITSU devices))\n* [ci2c_master_write.ino](examples/ci2c_master_write/ci2c_master_write.ino): Write some bytes to FRAM and compare them with what's read afterwards\n* [ci2c_master_read.ino](examples/ci2c_master_read/ci2c_master_read.ino): Read some bytes in FRAM\n* [ci2c_advanced.ino](examples/ci2c_advanced/ci2c_advanced.ino): Redirecting slave write \u0026 read functions (to custom functions following typedef)\n\n## See also\n\n**cI2C**\n* [cI2C github](https://github.com/SMFSW/cI2C) - C implementation of this library\n\n**WireWrapper**\n* [WireWrapper github](https://github.com/SMFSW/WireWrapper) - Cpp implementation using Wire Wrapper\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmfsw%2Fci2c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmfsw%2Fci2c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmfsw%2Fci2c/lists"}