Daisy as SPI Slave

Hello!

I’m working with Daisy in the Arduino IDE. I don’t come from a coding background so excuse my lack of knowledge.

I’m interested in a simple way to program Daisy as a full-duplex SPI slave. I’ve done a bit of digging and only found STM32 SPI slave integration for Blue Pill boards and a few others (STM32duino forums). What’s the best way to go about this?

Thanks!

I don’t think they’ve started documenting this yet. No offense, but generally, people that want to add custom peripherals would understand how to get started with necessary code. So it’s not surprising if existing devices is prioritized in documentation.

First of all, you should look at libdaisy sources - SPI handler, its usage for OLED display

The sample SPI DMA project from STM may also shed some light (same MCU family, but not identical).

Perhaps you can get a better example from one of the developers.

1 Like

Thanks @antisvin!

You have a fair point, my understanding is limited and I hope to change that. I assumed there was no “simple” way to do this for someone like myself but I thought I’d ask. I’ll look into the documentation that you have provided and continue to educate myself. :slightly_smiling_face:

No worries, everyone has to start from something. What exactly are you trying to do with SPI? As far as digital connectivity goes, starting with something like UART or I2C is much easier to understand.

I’m attempting to use another STM32 chip (F0 or F1 Nucleo board) for the UI of a synth (pots, buttons, screen etc.). I may be able to cram everything I need onto Daisy, but using two chips seemed like an elegant option that would leave me with some room to expand Daisy’s sonic capabilities in the future.

I was digging into I2C because it does seem much simpler and has more provided documentation. The consensus online seemed to be that SPI is the way to go for an application like this. It sounds like I2C might be the logical next step for me.

Thanks!

If you were worried about CPU resources, they would be negligible. This is generally handled using DMA and interrupts, so normal DSP code will run on MCU until peripheral has some data and configured callback is executed. I would expect your UI handling code to take 1-2% on an MCU as powerful as Daisy’s. But you should check if you have enough available pins.

Also, I think that in for the case you describe serial connection over UART is good enough. It’s simpler than I2C and you only need to send device state once per audio buffer.

1 Like

That’s good to know UI handling code is so light on Daisy’s MCU. I’m going try UART and also consider whether another board is even necessary.

Thanks for the help!

Have any luck communicating over UART to an external device? I’m trying to do a similar thing (separate MCU for interfacing and displays and Daisy for audio synthesis). Which pins are you using? Would you be able to post some example code?
Thanks.

I am also interested in knowing if anyone is communcating to another MCU and how they are doing it. All of my attempts to use I2C to pass settings back and forth to a ESP8266 NodeMcu have failed. No problems on the Daisy side, the 8266 does not support Master or Slave writer-reader modes. I would like to stay with the 8266 because I have several of them on hand. I need to use the ESP8266’s WiFi AP mode to power an Adroid phone app. I am now considering whether or not to use the SoftwareSerial library and sure could use some hints or suggestions.
Thank you.

I’m planning to use UART for communicating between Daisy Patch and other devices. I will repurpose serial MIDI pins for this. However, current code in libDaisy (which I’m not using) seems to be written to be used only serial MIDI usage in mind. Baudrate is hardcoded, buffer size is small and code isn’t written to be used with larger buffer in mind.