{"action":"created","issue":{"url":"https://api.github.com/repos/spark/firmware/issues/598","labels_url":"https://api.github.com/repos/spark/firmware/issues/598/labels{/name}","comments_url":"https://api.github.com/repos/spark/firmware/issues/598/comments","events_url":"https://api.github.com/repos/spark/firmware/issues/598/events","html_url":"https://github.com/spark/firmware/issues/598","id":105631877,"number":598,"title":"Addition of Wire.reset()","user":{"login":"pomplesiegel","id":1450352,"avatar_url":"https://avatars.githubusercontent.com/u/1450352?v=3","gravatar_id":"","url":"https://api.github.com/users/pomplesiegel","html_url":"https://github.com/pomplesiegel","followers_url":"https://api.github.com/users/pomplesiegel/followers","following_url":"https://api.github.com/users/pomplesiegel/following{/other_user}","gists_url":"https://api.github.com/users/pomplesiegel/gists{/gist_id}","starred_url":"https://api.github.com/users/pomplesiegel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pomplesiegel/subscriptions","organizations_url":"https://api.github.com/users/pomplesiegel/orgs","repos_url":"https://api.github.com/users/pomplesiegel/repos","events_url":"https://api.github.com/users/pomplesiegel/events{/privacy}","received_events_url":"https://api.github.com/users/pomplesiegel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-09T16:21:36Z","updated_at":"2015-09-09T16:57:13Z","closed_at":null,"body":"We have experienced an issue wherein a MCP23017 port expander gets into a bad state and holds SDA down to ground indefinitely. When this occurs, it seems the only way to purge the bus is to send additional clock pulses down SCL to force the slave to release SDA. See [this AD app note] (http://www.analog.com/media/en/technical-documentation/application-notes/54305147357414AN686_0.pdf) and [this forum post] (http://www.microchip.com/forums/m175368.aspx).\r\nAfter days of testing, it appears the solution below is quite effective, successfully purging the bus on 7 photons hundreds of times over this period. Would it make sense to include something similar to this as `Wire.reset()` in the Wire library?\r\n\r\n````cpp\r\nvoid RestartI2cBus()\r\n{\r\n  HAL_Pin_Mode(D0, INPUT_PULLUP); //Turn SCA into high impedance input\r\n  HAL_Pin_Mode(D1, OUTPUT); //Turn SCL into a normal GPO \r\n  HAL_GPIO_Write(D1, HIGH); // Start idle HIGH\r\n  \r\n  //Generate 9 pulses on SCL to tell slave to release the bus\r\n  for(int i=0; i <9; i++)\r\n  {\r\n    HAL_GPIO_Write(D1, LOW);\r\n    delayMicroseconds(100);\r\n    HAL_GPIO_Write(D1, HIGH);\r\n    delayMicroseconds(100);\r\n  }\r\n\r\n  //Change SCL to be an input\r\n  HAL_Pin_Mode(D1, INPUT_PULLUP);\r\n\r\n  //Start i2c over again\r\n  Wire.begin(); \r\n  delay(50);\r\n}\r\n````"},"comment":{"url":"https://api.github.com/repos/spark/firmware/issues/comments/138973949","html_url":"https://github.com/spark/firmware/issues/598#issuecomment-138973949","issue_url":"https://api.github.com/repos/spark/firmware/issues/598","id":138973949,"user":{"login":"m-mcgowan","id":2465470,"avatar_url":"https://avatars.githubusercontent.com/u/2465470?v=3","gravatar_id":"","url":"https://api.github.com/users/m-mcgowan","html_url":"https://github.com/m-mcgowan","followers_url":"https://api.github.com/users/m-mcgowan/followers","following_url":"https://api.github.com/users/m-mcgowan/following{/other_user}","gists_url":"https://api.github.com/users/m-mcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/m-mcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-mcgowan/subscriptions","organizations_url":"https://api.github.com/users/m-mcgowan/orgs","repos_url":"https://api.github.com/users/m-mcgowan/repos","events_url":"https://api.github.com/users/m-mcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/m-mcgowan/received_events","type":"User","site_admin":false},"created_at":"2015-09-09T16:57:13Z","updated_at":"2015-09-09T16:57:13Z","body":"This sounds like a great idea! "}}