Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9868 Discussions

Chip Select addressing for shield

BStar1
New Contributor I
1,593 Views

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)

{

MCP2515_SELECT();

spi_readwrite(MCP_RESET);

MCP2515_UNSELECT();

delay(10);

}

0 Kudos
7 Replies
ADRIAN_B_Intel
Employee
337 Views

hi,

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,

-a

BStar1
New Contributor I
337 Views

Thanks for your post Ado.

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

https://github.com/watterott/CANdiy-Shield watterott/CANdiy-Shield · GitHub

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

http://www.seeedstudio.com/wiki/CAN-BUS_Shield 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

BStar1
New Contributor I
337 Views

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

# endif

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

LBarr11
New Contributor I
337 Views

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.

BStar1
New Contributor I
337 Views

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.

LBarr11
New Contributor I
337 Views

Try this one:

__ARDUINO_X86__

 

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__

BStar1
New Contributor I
337 Views

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

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

# endif

Reply