Is there any SPI example?

Hello,

I’m looking for an SPI example.
The one provided in the link below is incomplete…

It is saying that there is a SPI communication example provided.

//Here is an example of SPI communication
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>

#include <wiringx.h>

int main(void)
{
    int fd_spi;

    if(wiringXSetup("duo", NULL) == -1) {
        wiringXGC();
        return -1;
    }

    if ((fd_spi = wiringXSPISetup(0, 500000)) <0) {
        printf("SPI Setup failed: %d\n", fd_spi);
        wiringXGC();
        return -1;
    }

    //**TODO**
}

may be you can try to use spi in user type driver.
I use it to handle the tft-spi module :this the tips

1 Like

That looks nice, but it is made in go language. I will need some example in c or c++.

It’s made in C, may be the translation makes you confused. it use the “/dev/spidev0.0” file that is a classical way for linux to operate spi. you can also find some example in github, it’s no limit to cv1800b, totally different from the wiringX library, many embedded linux examples use it.

1 Like

well I was clicking the wrong link… and not this one https://jihulab.com/tinnu/mpu_cv18xx_lvgl_demo