mayl

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

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!

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

We're in Beta

About us Mission Statement