mayl
Setup Circuits.SPI GPIO?
i’m trying to use Circuits.SPI from the basic mix nerves.new template. I can ssh in and then from the iex terminal I can open a SPI bus ({:ok, spi0} = Circuits.SPI.open("spidev0.0")) . Then I can run a transfer: {:ok, resp} = Circuits.SPI.transfer(spi0, <<0xAA, 0xFF>>) which returns {:ok, <<0, 0>>}. So from a software perspective, everything seems like it’s working. But I can only get 0’s back, and when I look at the SPI pins with an oscilloscope I see no activity on any of them during when the transfers are supposed to happen.
I’ve noticed that if I check the status of the relevant GPIO, that pins that ought to be outputs are reported as inputs:
iex(15)> Circuits.GPIO.status("P9_22 [spi0_sclk]")
{:ok, %{pull_mode: :none, direction: :input, consumer: "P9_22"}}
Does that indicate something significant, and do I need to do something more to setup SPI? The last time I used nerves was several years ago and I remember stuff like this being very fluid - no extra setup required, so I’m suspicious that I’ve done something wrong…
Marked As Solved
mayl
I don’t know why I do this so often, but it seems like every time I write up a question about something on the internet I figure the answer out for myself 10 minutes later.
For posterity, what I was missing was that I need to use config-pin on the bbb to setup the pins in SPI mode. There is a line about this in the Circuits.SPI readme, but because the SPI peripheral is enabled in the device tree and shows up I incorrectly thought this was not the issue.
Sorry for the noise!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








