7 Replies Latest reply on Oct 23, 2013 1:06 PM by eontap

    Chip Select addressing for shield


      During Maker Faire Rome I heard at the Intel booth that for some shields the pin definitions may have to be changed to addresses, and some addresses may change as well. In my case I currently have a CAN bus shield working OK with the MEGA 2560 and as expected from the conversation not working yet on Galileo.


      Below is the a portion of the library that shows some of the values that  I assume need to be adjusted for the shield to work.


      Is there a document that explains the mapping that needs to be done for pins and addresses  ?


      Are there any Arduino pins reserved by Galileo to support compatibility with Ethernet, Serial ports, SD, Wifi, etc ?



      #define spi_readwrite SPI.transfer

      #define spi_read() spi_readwrite(0x00)


      #define SPICS   5 // use Pin 5 for chip select

      #define MCP2515_SELECT()   digitalWrite(SPICS, LOW)

      #define MCP2515_UNSELECT() digitalWrite(SPICS, HIGH)


      and a reset function, for example, looks like this:


      void MCP_CAN::mcp2515_reset(void)                                    







        • 1. Re: Chip Select addressing for shield



          As far as i know this should just work ok on Galileo as Galileo has the same pin mapping as Uno.

          No, there is no special pins reserved for SD, Wifi, Ethernet or USB host on Galileo, these just come as extra components that are built in and therefore dont need any Arduino pins to be used.


          Galileo libraries are written in basic linux user space C/C++ code so just search on the web for what you want to do to replace and AVR specific code with a Galileo code.


          can you point us at the exact shield, sketch and library you are using and we will see whats wrong here?

          many thanks,


          • 2. Re: Chip Select addressing for shield

            Thanks for your post Ado.


            The shield we are using is CANdiy and you can test with the original library they have at Github:

            watterott/CANdiy-Shield · GitHub


            For the electricity on tap project we are using a different library, a customized version of the Seedstudio CAN library:

            CAN-BUS Shield - Wiki


            If you do not have access to a CAN shield we can make our system available for remote access and let you run a simple example on a MEGA board for reference. I have extra CAN shields that can lend as well.


            Thanks again

            • 3. Re: Chip Select addressing for shield

              Some more information:


              My CAN test program for the CANdiy shield started working after I hard coded SPICS pin to 5. The original library has the following code:


              #if defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

                #define SPICS   5



              What is the proper way to define Galileo in the above statement so that the Pin selection is automated by the compiler ?

              • 4. Re: Chip Select addressing for shield

                Ah, you need a #define, like "__AVR_ATmega128" to indicate if the code is being compiled for Galileo board, to invoke chipselect (SPICS) to pin 5.


                Have to look into that.

                • 5. Re: Chip Select addressing for shield

                  Any updates on how the compiler can find out if it is compiling a library for a Galileo board ? I need a way to make the library generic before publishing it.

                  • 6. Re: Chip Select addressing for shield

                    Try this one:



                    It's in the compiler command line:

                    compiler.cpp.flags= -m32 -march=i586 --sysroot={runtime.ide.path}/hardware/tools/sysroots/i586-poky-linux-uclibc -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -D__ARDUINO_X86__

                    • 7. Re: Chip Select addressing for shield

                      I tested the two options I found on these discussions and the right one turned out to be ARDUINO_LINUX from the MACROs discussion - thanks Carlos

                      C/C++ MACROs for Intel Boards


                      In the current IDE for Galileo if you need to detect if you are compiling for a Galileo board and adjust the code you can do:


                      #if defined(ARDUINO_LINUX)

                      ->  Galileo specific code goes here