6 Replies Latest reply on Nov 4, 2015 1:55 PM by CMata_Intel

    using spi CS0

    DrProton

      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?

        • 1. Re: using spi CS0
          CMata_Intel

          Hi DrProton,

           

          Have you tried with SPI examples from the Arduino IDE or maybe with 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

          • 2. Re: using spi CS0
            DrProton

            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

            • 3. Re: using spi CS0
              DrProton

              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]

              }

              • 4. Re: using spi CS0
                DrProton

                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.

                • 5. Re: using spi CS0
                  CMata_Intel

                  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:

                  Edison spidev for CS0

                  Re: Question about Write/Read SPI functions for Edison (Mraa)

                   

                  Kind regards,

                  Charlie