{"action":"created","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2116","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2116/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2116/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2116/events","html_url":"https://github.com/RIOT-OS/RIOT/issues/2116","id":50430499,"number":2116,"title":"periph/spi: Use context pointer instead of spi_t enum","user":{"login":"gebart","id":317506,"avatar_url":"https://avatars.githubusercontent.com/u/317506?v=3","gravatar_id":"","url":"https://api.github.com/users/gebart","html_url":"https://github.com/gebart","followers_url":"https://api.github.com/users/gebart/followers","following_url":"https://api.github.com/users/gebart/following{/other_user}","gists_url":"https://api.github.com/users/gebart/gists{/gist_id}","starred_url":"https://api.github.com/users/gebart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gebart/subscriptions","organizations_url":"https://api.github.com/users/gebart/orgs","repos_url":"https://api.github.com/users/gebart/repos","events_url":"https://api.github.com/users/gebart/events{/privacy}","received_events_url":"https://api.github.com/users/gebart/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/Device+driver","name":"Device driver","color":"0052cc"},{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/enhancement","name":"enhancement","color":"f17070"}],"state":"open","locked":false,"assignee":{"login":"jfischer-phytec-iot","id":9864546,"avatar_url":"https://avatars.githubusercontent.com/u/9864546?v=3","gravatar_id":"","url":"https://api.github.com/users/jfischer-phytec-iot","html_url":"https://github.com/jfischer-phytec-iot","followers_url":"https://api.github.com/users/jfischer-phytec-iot/followers","following_url":"https://api.github.com/users/jfischer-phytec-iot/following{/other_user}","gists_url":"https://api.github.com/users/jfischer-phytec-iot/gists{/gist_id}","starred_url":"https://api.github.com/users/jfischer-phytec-iot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfischer-phytec-iot/subscriptions","organizations_url":"https://api.github.com/users/jfischer-phytec-iot/orgs","repos_url":"https://api.github.com/users/jfischer-phytec-iot/repos","events_url":"https://api.github.com/users/jfischer-phytec-iot/events{/privacy}","received_events_url":"https://api.github.com/users/jfischer-phytec-iot/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2014-11-29T16:37:35Z","updated_at":"2015-01-16T10:17:43Z","closed_at":null,"body":"The current `periph/spi.h` API is a bit limited with regards to hardware dependent settings. I propose replacing the `spi_t dev` parameter passed to all functions by a pointer to a struct with context information. One of the parameters in the struct would still be the device number, but it opens the possibilities of adding more configuration parameters as well. The context struct would have a hardware independent beginning and hardware dependent variables appended. It would be possible to handle the Chip Select signals within the SPI driver itself instead of needing to use GPIO API functions in the slave device drivers.\r\n\r\nSome usage examples: the Kinetis CPU has hardware chip select capability, which needs some extra bits to be set in the data register when pushing a new byte to the SPI bus, these bits can not be passed using the current API. Another feature that would be possible and which I would use is the ability to choose between multiple timing and clock polarity/phase settings depending on which device I am addressing.\r\nThe Kinetis SPI hardware also has a FIFO queue for transfer operations, which means that it is possible to queue several bytes to different devices and put the core to sleep while they are being transferred on the wire, the CS signals are asserted/deasserted by the hardware for each individual transfer queued.\r\n\r\nI guess that Cortex-M devices from other manufacturers have similar functionality in their SPI hardware as well.\r\n\r\nI would like your opinions on this alternate API design."},"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/70233929","html_url":"https://github.com/RIOT-OS/RIOT/issues/2116#issuecomment-70233929","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/2116","id":70233929,"user":{"login":"gebart","id":317506,"avatar_url":"https://avatars.githubusercontent.com/u/317506?v=3","gravatar_id":"","url":"https://api.github.com/users/gebart","html_url":"https://github.com/gebart","followers_url":"https://api.github.com/users/gebart/followers","following_url":"https://api.github.com/users/gebart/following{/other_user}","gists_url":"https://api.github.com/users/gebart/gists{/gist_id}","starred_url":"https://api.github.com/users/gebart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gebart/subscriptions","organizations_url":"https://api.github.com/users/gebart/orgs","repos_url":"https://api.github.com/users/gebart/repos","events_url":"https://api.github.com/users/gebart/events{/privacy}","received_events_url":"https://api.github.com/users/gebart/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T10:17:43Z","updated_at":"2015-01-16T10:17:43Z","body":"@jfischer-phytec-iot I am interested in seeing what difference it makes for the actual performance of the RF device to use HW CS, (when considering other parts, such as packet processing etc.) and thus, if it is worth it really to make the driver platform specific (if the HW CS is the only Kinetis specific part).\r\n\r\nThe GPIO CS translates to something like 4 machine instructions, which is pretty small compared to the I/O time for sending a 128 byte packet over the SPI bus at 10 MHz bit rate."}}