Spi examples?

Hi,

I am a bit confused, I see that there is an spi.cpp file containing functions

is there an example using these ? cannot find it anywhere

ideally I would need the daisy seed to behave as a slave to an arduino

thanks for your help

Hi Phil!

I assume you’re meaning to write your software in C++;
Here’s the documentation page for SPI, this page has some information on Receive as well as Transmit. libDaisy SPI Documentation

Here’s a starting point for Blocking SPI receive. If you want non blocking receive, you’ll use the DMA functions instead.

int main(void)
{
    // Init the seed and so on...
    hw.Init();

    // SpiHandle object and Spi Configuration object
    SpiHandle spi_handle;
    SpiHandle::Config spi_conf;
 
    // Set some configurations
    spi_conf.periph = SpiHandle::Peripheral::SPI_1;
    spi_conf.mode = SpiHandle::Mode::SLAVE;
    spi_conf.direction = SpiHandle::Direction::TWO_LINES_RX_ONLY;
    spi_conf.nss = SpiHandle::NSS::NSS_HARD_INPUT;

    spi_conf.pin_config.sclk = Pin(PORTG, 11);
    spi_conf.pin_config.miso = Pin(PORTB, 4); // won't use this, but here it is anyways
    spi_conf.pin_config.mosi = Pin(PORTB, 5);
    spi_conf.pin_config.nss = Pin(PORTG, 10);
 
    // Initialize the handle using our configuration
    spi_handle.Init(spi_conf);

    // any final initialization...
    
    // infinite loop
    while(1)
    {
        // Blocking read of 4 bytes from SPI
        uint8_t buffer[4];
        spi_handle.BlockingReceive(buffer, 4);
    }
}

That being said, we don’t have an official SPI receive examples at the moment, but we definitely should! I’ll write some and add them to libDaisy under the examples folder when I get a chance. Here’s the folder where those live: libDaisy/examples

wow thanks, man

btw , can I debug the daisy with another jtag debugger than the official one ?
I have an ATMEL ICE jtag board, not sure if it is compatible

thx

I live in EU, I found this version, not sure I can trust it, it looks nothing like what is on the US shop

Electrosmith - STlink V3 Mini Debugger | Accessories | Effects | Schneidersladen - Modular Synths

image

On the left is the STLINK V3 MINI, which uses a micro-USB cable.
This has been replaced by STLINK V3 MINI-e, on the right, which uses a USB-C cable.

Both work fine with Daisy, as long as you have up-to-date software installed for STLINK and OpenOCD.

E-S could do a better job of making this clear on their website. They switched over to the newer one a while back, without any mention.

thanks, I thought I asked THE impolite question , when asking if I could use the ATMEL-ICE

I don’t think it is impolite, I just don’t know if it works with the software, and the STLINK is quite cheap, unless you buy it from ElectroSmith.

oh they sent me the new one after all