Does Freedom Metal support communication over SPI1?

Hello!

I’ve just started working with my HiFive1 Rev B over this past week, and I’ve been hoping to start interacting with the ESP32 device.

I’m more software-oriented by trade, so it’s been nice to use the abstractions provided by the Freedom Metal library where I can. I was planning to use it (i.e. <metal/spi.h>) to communicate with the ESP32 device, but haven’t had any luck.

I tried mimicking the usage from the SPI example provided with the library, but I didn’t have success. I understand that there are a few exchanges necessary to send a piece of data, so I also tried multiple transfer calls to see if that would work, but to no avail.

In the case that I do just one call to metal_spi_transfer with the "AT\r\n" command, I get the single character “C” followed by null bytes in my response buffer as described in this post.

When I break it into three separate metal_spi_transfer calls (i.e. “send” header, length header, data), I end up just having null bytes in the final response buffer.

I tried to diagnose this by searching for the implementation of metal_spi_transfer. I was able to find functions for SPI0 transfer in this file in the Metal repo, but not for SPI1.

My question is, does the Freedom Metal library actually have support for talking with the WiFi device over SPI1? If not, I’m happy to study kjarvel’s and Disasm’s implementations. If it does, though, I’d appreciate any pointers, since I’d like to use an official library if I can.

Thanks!

I believe that Metal library supports SPI1, but WiFi communication requires rather strict timings and Metal implementation can be bad at it. I’d recommend using a logic analyzer to check that signals you get don’t have pauses between bytes and large delays between CS and data.

Gotcha, interesting. Maybe I’ll take a look at that – for the moment, I’ve moved to transcribing a couple implementations I’ve found. Thanks for the response!