Shop OBEX P1 Docs P2 Docs Learn Events
stand alone SPI lib — Parallax Forums

stand alone SPI lib

krilliskrillis Posts: 6
edited 2007-08-19 06:21 in Propeller 1
Anybody know if there is a stand alone spi lib that will work with other devices being the master?
For example, I am not a big asm geek - especially on propeller - as it is new to me. But I am interested in
having access to a library where other devices can drive the propeller as if it was the device and the other device
is the host. Standard spi has 4 lines that connect devices to hosts. Master-In-Slave-Out, Slave-in-master-out, clock, and a chip enable or address line.

Looking at the SPIEngine, it appears that the prop will always drive the clock. This appears to be from the perspective of the host.

SoThen I noticed the femtobasic approach. They seem to have the lines defined, but its wrapped up in the sd card control code, such that unwinding it may be a task
I am not ready to try yet.

One thing I think would be really cool to test would be to have a cog setup as a master and another as a slave, and do spi across the two. This would allow testing of the library to ensure it can be configured either or both ways.

Anybody working on this? Or at least working on propeller as slave spi code?

Thanks,

Paul

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-19 06:21
    Paul,
    If you're not in a hurry, SPI works in Spin as well as in assembly, just slower. You could certainly get over 2 KBytes/second. Have a look at the BS2 Compatibility Library and its SHIFTIN and SHIFTOUT routines for the master end. You should be able to write slave routines starting from these. You have to wait for the select line to become true before you start anything, then wait for the clock edge to sample the data. WAITPNE and WAITPEQ are perfect for this.

    I don't think anyone else has done slave SPI, but I could be wrong. "Be the first on your block" to do it. Once it works in Spin, you can use the SPI engine as a template to make it work in assembly for speed (if you need to).
Sign In or Register to comment.