chipKIT® Development Platform

Inspired by Arduino™

SPI interface

Created Wed, 22 Jul 2015 22:15:46 +0000 by fayazr


fayazr

Wed, 22 Jul 2015 22:15:46 +0000

I am using an AMIS 30543 stepper driver with the Digilent Wifire , however i am getting errors regarding the SPI interface and the AMIS libraries for arduino.

error: 'SPISettings' does not name a type

error: 'class SPIClass' has no member named 'beginTransaction'

error: 'class SPIClass' has no member named 'endTransaction'


majenko

Wed, 22 Jul 2015 22:29:02 +0000

It sounds like your library is trying to use functions that are in the newer Arduino SPI library but haven't made it across to the chipKIT SPI library (which is old), and I don't think actually works properly on the Wi-Fire at the moment anyway.

We normally recommend that you port your code (and the library) to use the DSPI library instead which works well with the Wi-Fire.

Eventually the SPI library is going to be re-written to incorporate the DSPI library and provide the exact same interface as the current Arduino SPI library. It's somewhere on the list of things to do.


fayazr

Thu, 23 Jul 2015 00:39:16 +0000

I tried the SPI example that comes with the MPIDE i.e. File->Examples->SPI->BaromtericPressureSensor and compiled it for Chipkit wifire. I got the same set of errors for SPI.

Also is there a tutorial to port to DSPI,

Thanks


majenko

Thu, 23 Jul 2015 12:40:56 +0000

Yep, those errors are because you're on the Wi-Fire and the SPI library doesn't (yet) work with it.

To use DSPI you need to add:

#include <DSPI.h>

DSPI0 SPI;

to the top of your program. Most of the rest is then the same as the SPI library, but there are a few differences.

Within the DSPI library folder there is a file "Digilent chipKIT SPI Library.pdf" which tells you most things. It's a little out of date and some enhanced functions have been added, but that should cover most things for you.


Gary Freegard

Thu, 23 Jul 2015 15:14:44 +0000

Hi

Just had a quick look at AMIS30543.h, SPISettings (line 63), SPI.beginTransaction (line 73) and SPI.endTransaction(line 79) can be remarked out.

SPISettings is used to define a type that holds the settings required.

beginTransaction is used to start the spi using the desire settings

endTransaction , stops spi.

For further details have a look here, functions are list on the right. [url]https://www.arduino.cc/en/Reference/SPI[/url]

Used the following methods to set up SPI in 'setup', change the divider value to one that is suitable for the device.

SPI.begin();  
  	SPI.setClockDivider(0);
  	SPI.setDataMode(SPI_MODE0);

//PIC32 does not support selectable shift direction. // they always shift left (MSB first)

from SPI.cpp

Or you could try DSPI library as Martin has said.

Hope this helps.

Gary