{"action":"created","issue":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1717","repository_url":"https://api.github.com/repos/espressif/arduino-esp32","labels_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1717/labels{/name}","comments_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1717/comments","events_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1717/events","html_url":"https://github.com/espressif/arduino-esp32/pull/1717","id":347167265,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1ODU1NjAy","number":1717,"title":"ReSTART fix, with others","user":{"login":"stickbreaker","id":2858309,"node_id":"MDQ6VXNlcjI4NTgzMDk=","avatar_url":"https://avatars0.githubusercontent.com/u/2858309?v=4","gravatar_id":"","url":"https://api.github.com/users/stickbreaker","html_url":"https://github.com/stickbreaker","followers_url":"https://api.github.com/users/stickbreaker/followers","following_url":"https://api.github.com/users/stickbreaker/following{/other_user}","gists_url":"https://api.github.com/users/stickbreaker/gists{/gist_id}","starred_url":"https://api.github.com/users/stickbreaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stickbreaker/subscriptions","organizations_url":"https://api.github.com/users/stickbreaker/orgs","repos_url":"https://api.github.com/users/stickbreaker/repos","events_url":"https://api.github.com/users/stickbreaker/events{/privacy}","received_events_url":"https://api.github.com/users/stickbreaker/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-08-02T20:43:28Z","updated_at":"2018-09-15T22:28:59Z","closed_at":"2018-08-14T09:51:15Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/espressif/arduino-esp32/pulls/1717","html_url":"https://github.com/espressif/arduino-esp32/pull/1717","diff_url":"https://github.com/espressif/arduino-esp32/pull/1717.diff","patch_url":"https://github.com/espressif/arduino-esp32/pull/1717.patch"},"body":"pr #1665 introduce a problem with ReSTART, when solving this problem I found an interaction between the TxFifo refill, RxFifo empty and CMD[] fill.  during certain sequences a dataqueue command would be skipped, this skipping resulted in a mismatch between the contents of the TxFifo and the i2c command sequence.  The problem manifested as an ACK error. \r\nIn addition to this required bug fix I propose:\r\n* `Wire.begin()` be changed from a `void` to a `bool` this will allow the reset functionality of `Wire.begin()` to be reported.  Currently `Wire.begin()` attempts to reset the i2c Peripheral, but cannot report success/failure.\r\n* `Wire.busy()` be added. this `bool` function returns the hardware status of the bus. This status can be use in multi-master environments for application level interleaving of commands, also in single master environment, it can be used to detect a 'hung' bus.  With the functional change to `Wire.begin()` this allows app level recover of a hung bus.\r\n* `Wire.lastError()` value updated for all errors, previously when interleaving `Wire.endTransmission(false)` and `Wire.readTransmission(false)`, the 128 byte `Wire.write()` buffer was exhausted without generating and error(very exotic). I discovered this error when I created a sequence of directed reads to a EEPROM. Each directed read used 2 bytes of the 128 byte `write()` buffer, so after 64 consecutive ReSTART writes with ReSTART reads, `Wire()`  had no room to record the directed address bytes.  It generated just a NAK check without setting the EEPROMs internal register address.  The succeeding ReSTART read succeeded at incorrect address.\r\n* Changes to the HAL layer:\r\n* * added `i2cGetStatus()` which returns the i2c peripheral status word, used to detect bus_busy currently\r\n* * added `i2cDebug()` programmatic control of debug buffer output\r\n* * changed `i2cAddQueue()` to allow data_only queue element this will allow a i2c transaction to use multiple data buffer pointers.\r\n* * removed direct access to `i2cDumpInts()`, `i2cDumpI2c()` from app, instead, use `i2cDebug()` to set trigger points \r\n"},"comment":{"url":"https://api.github.com/repos/espressif/arduino-esp32/issues/comments/421645926","html_url":"https://github.com/espressif/arduino-esp32/pull/1717#issuecomment-421645926","issue_url":"https://api.github.com/repos/espressif/arduino-esp32/issues/1717","id":421645926,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTY0NTkyNg==","user":{"login":"CaptIgmu","id":14364314,"node_id":"MDQ6VXNlcjE0MzY0MzE0","avatar_url":"https://avatars2.githubusercontent.com/u/14364314?v=4","gravatar_id":"","url":"https://api.github.com/users/CaptIgmu","html_url":"https://github.com/CaptIgmu","followers_url":"https://api.github.com/users/CaptIgmu/followers","following_url":"https://api.github.com/users/CaptIgmu/following{/other_user}","gists_url":"https://api.github.com/users/CaptIgmu/gists{/gist_id}","starred_url":"https://api.github.com/users/CaptIgmu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CaptIgmu/subscriptions","organizations_url":"https://api.github.com/users/CaptIgmu/orgs","repos_url":"https://api.github.com/users/CaptIgmu/repos","events_url":"https://api.github.com/users/CaptIgmu/events{/privacy}","received_events_url":"https://api.github.com/users/CaptIgmu/received_events","type":"User","site_admin":false},"created_at":"2018-09-15T22:28:59Z","updated_at":"2018-09-15T22:28:59Z","author_association":"CONTRIBUTOR","body":"@ifrew Those MPU9250 routines are from @kriswiner and based on using a Teensy board. Similar routines are used for the EM7180 Sensor Hub based [Ultimate Sensor Fusion Solution - MPU9250](https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution-mpu9250/) and the newer more accurate [Ultimate Sensor Fusion Solution - LSM6DSM + LIS2MD](https://www.tindie.com/products/onehorse/ultimate-sensor-fusion-solution-lsm6dsm--lis2md/). I struggled for a long time to get reliable ESP32 i2c _**reads**_ of my original USFS board until @stickbreaker merged his improved I2C routines up to v1.0.0-rc3. After that, I2C reads _**broke**_ again! It was the comment from @stickbreaker: _**You can try changing the sampling code to not have ReSTART, It may not actually be necessary for the proper operation of the sensor.**_ Correct! The ESP32 is not like the Teensy ARM Cortex boards, so we do not need this for i2c _**reads**_:\r\n```\r\nWire.endTransmission(false); // Send the Tx buffer, but send a restart to keep connection alive\r\n```\r\nMy code originally looked like this:\r\n```\r\nWire.endTransmission(I2C_NOSTOP); // Send the Tx buffer, but send a restart to keep connection alive\r\n```\r\nSo I changed my define at program start:\r\n```\r\n// #define I2C_NOSTOP false  // for compatibility with Teensy i2c to keep connection Alive for reads but BREAKS ESP32 i2c system! Not needed.\r\n#define I2C_NOSTOP true    // This works for improved i2c routines from @StickBreaker    RMB ***\r\n```\r\nSo now I can again communicate with my USFS board! All is not perfect though, my @kriswiner based code is interrupt driven and over time, some interrupts are missed. There may need to be more ongoing tweaks to the @stickbreaker i2c routines . . .\r\n\r\n"}}
{"actor":{"display_login":"CaptIgmu"}}