2 Replies Latest reply on Mar 26, 2015 9:02 AM by Intel_Alvarado

    "Undefined reference error" when i use mraa_spi_transfer_buf.


      Now, I wanna use SPI bus to read data from a slave device. like screenshot and code below, I can call "mraa_spi_write_buf" function, but when i call "mraa_spi_transfer_buf", Eclipse display "undefined reference"error when compile and link process.

      Need help. Thanks.





      [My Environment]

      Hardware: Edison mini breakout (master) <----- read slave data link -------> SPI Slave

      Software: windows 7 + Eclipse + MRAA lib




      #include <stdio.h>

      #include <string.h>

      #include <unistd.h>

      #include <math.h>

      #include <time.h>

      #include <sys/socket.h>

      #include <arpa/inet.h>

      #include <stdlib.h>

      #include <netinet/in.h>


      #include "mraa.h"


      int main(int argc, char **argv)


           int SPIfreq = 0;

           uint8_t data[] = { 0x00,0x23,0xFF,0xFF };

           uint8_t* recv;




           mraa_platform_t platform = mraa_get_platform_type();

           mraa_gpio_context gpio;


           char board_name[] = "Some weird devboard that isn't recognised...";


          /*Scan Platform type*/

          switch (platform) {

              case MRAA_INTEL_GALILEO_GEN1:

                  strcpy(board_name, "Intel Galileo Gen1");

                  gpio = mraa_gpio_init_raw(3);


              case MRAA_INTEL_GALILEO_GEN2:

                  strcpy(board_name, "Intel Galileo Gen2");

                  gpio = mraa_gpio_init(13);

                  break ;

              case MRAA_INTEL_EDISON_FAB_C:

                  strcpy(board_name, "Intel Edison");

                  //gpio = mraa_gpio_init(13);

                  break ;


              strcpy(board_name, "Nothingg");           //gpio = mraa_gpio_init(13);



          fprintf(stdout, "\n\n-------------------------------------------------------------------\n\nWelcome to libmraa\n Version: %s\n Running on %s\n",

          mraa_get_version(), board_name);

          fprintf(stdout,"\n\n Platform ID is -> %d\n\n",platform);


          mraa_spi_context spi;

          spi = mraa_spi_init(0);

          fprintf(stdout,"\n SPI Init!");

          SPIfreq = 5000000; //CLK:500K

          mraa_spi_frequency (spi, SPIfreq);

          fprintf(stdout,"\n SPI Freq set to %d!\n",SPIfreq);


          fprintf(stdout,"\n SPI Mode set to %d!",1);


          for (;;) {

                recv = mraa_spi_write_buf(spi, data, 7);

                printf("\nRECIVED-0x%x", recv[0]);



                //-- I Wanna use "transfer_buf" function now. But ..... UNDEFINE ERROR

                 mraa_spi_transfer_buf(spi, data, recv, 7);


                usleep(1000000); //Linux system function. Unit is MicroSeconds (uS) <- 1000 ms <- 1s



          return 0;