tonton81 / SPI_MSTransfer_T4

17 stars 4 forks source link

More info in the readme.md or example sketch notes would help a noob like me! #1

Open IanKirkEdwards opened 2 years ago

IanKirkEdwards commented 2 years ago

Hi, I'm trying to set up several teensy4.0 boards as SPI slaves with an Arduino Mega 2560 Pro Mini as a Master. I read in Paul's documentation about the SPI features how Slave mode is not supported. His page recommends this library for setting up the teensy as a slave device. I have been looking at the Slave and Master examples sketches and am not experienced enough to understand what's going on yet. I sent the library to couple of coder friends to ask for their help but I figured I should ask the source! Any help would be greatly appreciated!

tonton81 commented 2 years ago

the examples should just work, just need to make sure you wire it up properly

Lysandr commented 2 years ago

Agree here, seems like great code but I'm having trouble understanding even what the examples are trying to accomplish.

tonton81 commented 2 years ago

Are the examples not working for you Lysandr? The examples are pretty minimal, but easy to understand once you see it working

Lysandr commented 2 years ago

the Slave side example does not set up data to be requested by the master. You don't have any comments for anything, so all the examples are quite unhelpful

tonton81 commented 2 years ago

This was based off the older version, but I assume you didn't check the source code?

https://github.com/tonton81/SPI_MSTransfer_T4/blob/76a0a7891c3a2bba235e8ebff6abb0da87143ed7/SPI_MSTransfer_T4.h#L127

thats for the slave, exactly the same way as the master. the slave just queues the transfer. the master consumes it after.

EdsgnDesigner commented 1 year ago

Add this function to master example when ever you want to get the data from the slave. Populate (buf, size, id, data..)

mySPI1234.processdata(arrayDataName, sizeofbufarray, ..,.);

Add this to the slave example to populate the data. uint16_t buf2[5] = { 0xBEEF, 0xF7, 0xF8, 0xF9, 0xDEAD }; transfer(buf2, 5, random(0x1000, 0x8000));

I think....