{"action":"created","issue":{"url":"https://api.github.com/repos/mbedmicro/mbed/issues/1393","labels_url":"https://api.github.com/repos/mbedmicro/mbed/issues/1393/labels{/name}","comments_url":"https://api.github.com/repos/mbedmicro/mbed/issues/1393/comments","events_url":"https://api.github.com/repos/mbedmicro/mbed/issues/1393/events","html_url":"https://github.com/mbedmicro/mbed/issues/1393","id":113547175,"number":1393,"title":"nRF51822 I2C code always assumes you are using NRF_TWI1 - locks up if not!!","user":{"login":"Timmmm","id":376842,"avatar_url":"https://avatars.githubusercontent.com/u/376842?v=3","gravatar_id":"","url":"https://api.github.com/users/Timmmm","html_url":"https://github.com/Timmmm","followers_url":"https://api.github.com/users/Timmmm/followers","following_url":"https://api.github.com/users/Timmmm/following{/other_user}","gists_url":"https://api.github.com/users/Timmmm/gists{/gist_id}","starred_url":"https://api.github.com/users/Timmmm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Timmmm/subscriptions","organizations_url":"https://api.github.com/users/Timmmm/orgs","repos_url":"https://api.github.com/users/Timmmm/repos","events_url":"https://api.github.com/users/Timmmm/events{/privacy}","received_events_url":"https://api.github.com/users/Timmmm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-27T10:00:25Z","updated_at":"2015-10-27T10:07:57Z","closed_at":null,"body":"The nRF51822 has two I2C/SPI peripherals. Each can be used for I2C *or* SPI, but not both.\r\n\r\nThe code in `i2c_api.c` and `spi_api.c` uses a first-come-first-served principle, and keeps track of which peripheral is being used for what. This is great. That's how it should be.\r\n\r\nUnfortunately it makes calls to functions in `twi_master.c` that are *hard-coded* to use `NRF_TWI1`. If you happen to have code that initialises SPI first (giving it the second peripheral for some reason), and then I2C, the I2C will get `NRF_TWI0`. It will then fiddle around with NRF_TWI1 (the second I2C/SPI peripheral) which will then cause SPI to lock up when you use it.\r\n\r\nIt honestly seems like someone just forgot to finish writing the code!\r\n\r\nI've written some code which seems to fix this, but I haven't looked into how all the PPI stuff interacts with it so I'm not 100% sure. It is definitely an improvement though and fixes my specific use."},"comment":{"url":"https://api.github.com/repos/mbedmicro/mbed/issues/comments/151441686","html_url":"https://github.com/mbedmicro/mbed/issues/1393#issuecomment-151441686","issue_url":"https://api.github.com/repos/mbedmicro/mbed/issues/1393","id":151441686,"user":{"login":"0xc0170","id":2963726,"avatar_url":"https://avatars.githubusercontent.com/u/2963726?v=3","gravatar_id":"","url":"https://api.github.com/users/0xc0170","html_url":"https://github.com/0xc0170","followers_url":"https://api.github.com/users/0xc0170/followers","following_url":"https://api.github.com/users/0xc0170/following{/other_user}","gists_url":"https://api.github.com/users/0xc0170/gists{/gist_id}","starred_url":"https://api.github.com/users/0xc0170/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xc0170/subscriptions","organizations_url":"https://api.github.com/users/0xc0170/orgs","repos_url":"https://api.github.com/users/0xc0170/repos","events_url":"https://api.github.com/users/0xc0170/events{/privacy}","received_events_url":"https://api.github.com/users/0xc0170/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T10:07:57Z","updated_at":"2015-10-27T10:07:57Z","body":"Send a pull request. In the worst case, it will help us to fix it as you already spent some time looking at the code. In the best one, will be merged and this issue will be resolved\r\n\r\nThanks for reporting"}}