SPI documentation

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

SPI documentation

Post by A.Harrenberg »

Hi PoltoS,

the online documentation for SPI has some 404 pages, at least SPISetting and Due Extended SPI usage.

For SetDataMode there are 4 possible values for the mode named, but not described. It is written it is clock polarity and phase, but which mode is which combination?

Would be great if you can check and update the documentation.

I have a cheap MFRC522 RFID reader which uses SPI and I would like to connect it to the Z-Uno...

Regards,
Andreas.
fhem.de - ZWave development support
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: SPI documentation

Post by A.Harrenberg »

Hi,

so for the modes it seems that this is the standard definition for the polarity and the phase:

Mode CPOL CPHA
0 0 0
1 0 1
2 1 0
3 1 1

Regards,
Andreas.
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: SPI documentation

Post by PoltoS »

Thanks, fixed the doc
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: SPI documentation

Post by A.Harrenberg »

Hi PoltoS,

in the documentation for SPI the call for SPISettings or SPI.beginTransaction() is described as

Code: Select all

SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)); 
, but this does give an compiler error:

Code: Select all

no viable conversion from 'SPISettings' to 'SPISettings *'
In the SPI lib for the ZUNO the beginTransaction is defined as

Code: Select all

void beginTransaction(SPISettings * settings);
, in the SPI lib for the Arduino it is defined as

Code: Select all

inline static void beginTransaction(SPISettings settings)
I tried to adapt the ZUNO lib, but it seems that with the sdccp compiler only a pointer is allowed.

So I use

Code: Select all

SPISettings SPIS(4000000, MSBFIRST, SPI_MODE0);
to initialize the settings (by the way, in the example there is a "14000000" given, which seems to large...) and then just pass the pointer to SPIS to beginTransaction():

Code: Select all

      SPI.begin();
      SPI.beginTransaction(&SPIS);
Is that the intended way? If yes, then the documentation should be adapted. If not, how to do it correctly?

Best regards,
Andreas.
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: SPI documentation

Post by PoltoS »

This is correct, we can not pass objects as parameters but reference (pointer) only. The API is slightly different from Arduino.

14MHz looks like a typo. Fixed
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: SPI documentation

Post by A.Harrenberg »

Hi PoltoS,

thnx for fixing the documentation, but the description for SPISettings is still showing the "old" syntax with the object:

Code: Select all

SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)) 
Would be great if you can update that as well.

Regards,
Andreas.
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: SPI documentation

Post by PoltoS »

Done. We will soon make an example with SPI.

Have you made something meanwhile
A.Harrenberg
Posts: 201
Joined: 05 Sep 2016 22:27

Re: SPI documentation

Post by A.Harrenberg »

Hi PoltoS,

working with the simple library for the RCF522 is not successfull, the sketch is resetting after a while or when I present the tag to the reader. I gave up on this one and will try again if you release a new version, I can only think of some internal problems. This is described here.

In the meantime I tried to convert a larger library for the RFC522 from the Arduino to the ZUNO, but I am also stuck there. I end up with an "unknown error" saying that the index for the list is ouf of bounce, but there is no linenumber, so I can't find the issue... This is described here

Other than these two failed attempts I did not work with the SPI library.

Will the new example for the SPI come along with a new version of the ZUNO? :?: Are there plans for the next release?

Regards,
Andreas.
fhem.de - ZWave development support
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: SPI documentation

Post by PoltoS »

We have changed nothing in SPI, so the example will work with the existing too.

We have fixes some potential problems and will release the new version next week.

From what we see, most problems arise from stack overflow. We will soon add some "debugging" tools to notify user about stack overflow and some other problems.
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: SPI documentation

Post by PoltoS »

May be try to minimize the number of wrapped function calls and make more global variables instead of local. This will free some stack.
Post Reply