{"action":"created","issue":{"url":"https://api.github.com/repos/firmata/protocol/issues/26","repository_url":"https://api.github.com/repos/firmata/protocol","labels_url":"https://api.github.com/repos/firmata/protocol/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/firmata/protocol/issues/26/comments","events_url":"https://api.github.com/repos/firmata/protocol/issues/26/events","html_url":"https://github.com/firmata/protocol/issues/26","id":57749653,"number":26,"title":"Add proposal for SPI","user":{"login":"soundanalogous","id":401539,"avatar_url":"https://avatars.githubusercontent.com/u/401539?v=3","gravatar_id":"","url":"https://api.github.com/users/soundanalogous","html_url":"https://github.com/soundanalogous","followers_url":"https://api.github.com/users/soundanalogous/followers","following_url":"https://api.github.com/users/soundanalogous/following{/other_user}","gists_url":"https://api.github.com/users/soundanalogous/gists{/gist_id}","starred_url":"https://api.github.com/users/soundanalogous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soundanalogous/subscriptions","organizations_url":"https://api.github.com/users/soundanalogous/orgs","repos_url":"https://api.github.com/users/soundanalogous/repos","events_url":"https://api.github.com/users/soundanalogous/events{/privacy}","received_events_url":"https://api.github.com/users/soundanalogous/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-02-15T22:37:03Z","updated_at":"2016-03-01T19:00:26Z","closed_at":null,"body":"via conversation with @ajfisher on gitter:\r\n\r\nThere was a pull-request for SPI opened a while back: firmata/arduino#135. However, it's going to be more complex than just wrapping the Arduino SPI api (since that would be inefficient). Lets start by drafting a protocol here: https://github.com/firmata/protocol.\r\n\r\nMy initial thoughts are that it should have a SPI_CONFIG message (like I2C and many other features in Firmata). The config message should let the user specify the following:\r\n\r\nCS/SS pin (this is also how you'll keep track of multiple SPI devices)\r\nbit order (LSB or MSB first)\r\ndata mode (see the 4 modes defined here)\r\nclock divider? (I'm not sure how this would work in Firmata or if it even applies... I think it depends on if a hardware enabled SS pin is selected on the board)\r\nWe'll need a way to call SPI.begin and SPI.end. I'm not sure if it's better to call begin when the config message is received or if there is any advantage in having it be a separate command. SPI_END can be a simple message to call SPI.end, perhaps also specifying the CS pin to be compliant with Arduino Due's extended SPI protocol (for other boards this parameter would simply be ignored in the implementation).\r\n\r\nWe'll need a SPI_REQUEST message. It should contain the CS/SS pin number and the data to be sent via SPI.transfer(val) on the board. It will be more efficient to send multiple bytes rather than a single byte (this likely also depends on the particular device) - so in the implementation you'd call SPI.transfer(val) multiple times for a single SPI_REQUEST rather than sending a separate Request for each byte). We'll need a strategy around buffering as well (more for the implementation than the protocol). It will be helpful to look across a variety of SPI devices to see what what type of data is sent... what would constitute a \"packet\". Be aware however of the 64 byte serial data buffer on Arduino since this will likely come into play. It would also be helpful to support a READ_CONTINUOUSLY mode like I2C Firmata (this is especially useful for SPI-based sensors).\r\n\r\nAnd we need a SPI_REPLY message to send data back the the Firmata client. This should include the CS pin, maybe the number of bytes in the reply and whether or not this is the full packet (or if it's broken up into multiple packets). Perhaps this is as simple as indicating if this is the LAST set of data.\r\n\r\nAlso try to support Arduino Due's extended SPI feature as an option. You'd add this to the protocol for SPI_END and SPI_REQUEST (although I'm not sure how beneficial this extended set would be in a Firmata client library... may add more complexity than it's worth). This is lower priority."},"comment":{"url":"https://api.github.com/repos/firmata/protocol/issues/comments/190852685","html_url":"https://github.com/firmata/protocol/issues/26#issuecomment-190852685","issue_url":"https://api.github.com/repos/firmata/protocol/issues/26","id":190852685,"user":{"login":"soundanalogous","id":401539,"avatar_url":"https://avatars.githubusercontent.com/u/401539?v=3","gravatar_id":"","url":"https://api.github.com/users/soundanalogous","html_url":"https://github.com/soundanalogous","followers_url":"https://api.github.com/users/soundanalogous/followers","following_url":"https://api.github.com/users/soundanalogous/following{/other_user}","gists_url":"https://api.github.com/users/soundanalogous/gists{/gist_id}","starred_url":"https://api.github.com/users/soundanalogous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soundanalogous/subscriptions","organizations_url":"https://api.github.com/users/soundanalogous/orgs","repos_url":"https://api.github.com/users/soundanalogous/repos","events_url":"https://api.github.com/users/soundanalogous/events{/privacy}","received_events_url":"https://api.github.com/users/soundanalogous/received_events","type":"User","site_admin":false},"created_at":"2016-03-01T19:00:26Z","updated_at":"2016-03-01T19:00:26Z","body":"The latest iteration of the SPI proposal is here: https://github.com/firmata/protocol/pull/27"}}