Shop OBEX P1 Docs P2 Docs Learn Events
pass spi object — Parallax Forums

pass spi object

slcottslcott Posts: 27
edited 2010-06-08 21:49 in Propeller 1
I'm still learning how to use the propeller. The propeller on my board is trying to communicate over SPI to multiple chips. I'd like to use an SPI object in each of the spin files that I have associated with each of the IC's that the microprocessor communicates with.
  • Some of my objects
    DAC : "digital analog converter"
    ADC : "analog digital converter"
    FPU : "floating point unit"
    SPI : "spi asm"

It seems that only one of my objects can allocate the SPI object at a time. Can I pass this object around or should I just implement the SPI interface within each of the different objects that I am working with.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-06-08 21:49
    You need an obj section in each of the objects that want to use SPI which defines it's own instance of SPI. But be aware that some objects might be designed as a singleton. This means that only one instance is allowed. This is the case when the object has DAT variables. (DAT constants -for example strings- are OK).

    Of course the different SPI objects should all work on different PINs if they run in different COGs. Otherwise, if you run the different SPI instances in different COGs AND you want to use the same SPI bus, you have to add code to synchronize the access.
Sign In or Register to comment.