Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
1,372 Views

using spi CS0

Jump to solution

I designed a board around the edison module with my SPI device connected to /CS0 (GPIO110). I would like to give this interface a test, but I cannot figure out how to get the SPI to work using /CS0. It seems I need to have spidev5.0. Is there a way to either use GPIO110 as a standard GPIO and toggle /CS0 manually or modify the linux image to get spidev5.0?


Accepted Solutions
Highlighted
Employee
16 Views

Hi DrProton,

Do you have updates in this?

I was investigating about this. The CS0 is connected to the ADC module in the Arduino Expansion Board and the image was built for this behavior, this is why it is hard to use the pin. If you want to do this I suggest you to control the CS0 manually.

There are some threads that may help you with this:

Kind regards,

Charlie

View solution in original post

0 Kudos
5 Replies
Highlighted
Employee
16 Views

Hi DrProton,

Have you tried with SPI examples from the Arduino IDE or maybe with https://github.com/intel-iot-devkit/mraa/tree/master/examples MRAA?

Which Edison image are you using? You can run configure_edison –version for this

What is the output of running ls /sys/class/spidev/ ?

Regards,

Charlie

0 Kudos
Novice
16 Views

I have not tried with arduino or MRAA, I was hoping to just use regular linux stuff.

Version is 146

ls /sys/class/spidev/ returns spidev5.1

Highlighted
Novice
16 Views

I tried with this bit of code I came up with based on the spi_max7219 example. I have tried 0 and 1 as arguments to mraa_spi_init() in both cases CS1 is used.

int

main(int argc, char** argv)

{

//! [Interesting]

mraa_spi_context spi;

spi = mraa_spi_init(0);

if (spi == NULL) {

printf("Initialization of spi failed, check syslog for details, exit...\n");

exit(1);

}

printf("SPI initialised successfully\n");

mraa_spi_frequency(spi, 400000);

mraa_spi_lsbmode(spi, 0);

mraa_spi_mode(spi,MRAA_SPI_MODE1);

// Clear the display

uint8_t data[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };

uint8_t rxdata[8];

uint8_t *rxpointer;

rxpointer = mraa_spi_write_buf(spi, data, 8);

printf("Got Bytes");

int i;

for(i=0;i<8;i++)

{

rxdata[i]=rxpointer[i];

printf(" %d",rxdata[i]);

}

printf("\r\n");

free(rxpointer);

mraa_spi_stop(spi);

//! [Interesting]

}

0 Kudos
Highlighted
Novice
16 Views

When I use mraa_spi_init_raw(5,1); it works as expected on CS1, but mraa_spi_init_raw(5,0); gives an init error.

0 Kudos
Highlighted
Employee
17 Views

Hi DrProton,

Do you have updates in this?

I was investigating about this. The CS0 is connected to the ADC module in the Arduino Expansion Board and the image was built for this behavior, this is why it is hard to use the pin. If you want to do this I suggest you to control the CS0 manually.

There are some threads that may help you with this:

Kind regards,

Charlie

View solution in original post

0 Kudos