Repeated communication with 2 SPI slaves

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
danielm
Posts: 167
Joined: Mon Oct 05, 2015 12:24 pm

Repeated communication with 2 SPI slaves

Post by danielm » Fri Apr 29, 2016 3:17 pm

In my laser 3d printer controller project I need to communicate with 2 SPI slaves repeatedly. The problem is that both slaves are using different polarity and phase settings. Is there any way how to re-configure existing SPI object? Does spi.init() do this? Or is the only solution to create new SPI object with different settings over and over?

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Repeated communication with 2 SPI slaves

Post by danicampora » Fri Apr 29, 2016 3:26 pm

Wow, a laser 3D printer? Sounds like a very cool project :-)

The answer is to use spi.init(). Good luck!

Cheers,
Daniel

danielm
Posts: 167
Joined: Mon Oct 05, 2015 12:24 pm

Re: Repeated communication with 2 SPI slaves

Post by danielm » Fri Apr 29, 2016 4:49 pm

Thanks, I will try that.

You can find more info regarding our project here: http://marsaltech.com/
I will update news section in next few days :)

danielm
Posts: 167
Joined: Mon Oct 05, 2015 12:24 pm

Re: Repeated communication with 2 SPI slaves

Post by danielm » Sat Apr 30, 2016 1:20 pm

Daniel, I have another issues, hope you can help me :)

1. In main.py I create objectA as an instance of classA. This object represents one of HW modules of my controller.
2. Then I create objectB as an instance of classB. This object represents client to my backend server service.
3. By calling objectB.functionB() I want to start processing of some data loaded from a file and based on this data perform some actions on HW module by calling objectA.functionA().

The problem is that from "inside" of instantiated classB as objectB the object objectA is not "visible" (name not defined). Should I pass objectA (and all other objects representing HW resources) as parameters when creating objectB? Or are there any other solutions?

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Repeated communication with 2 SPI slaves

Post by SpotlightKid » Sat Apr 30, 2016 7:18 pm

danielm wrote:Should I pass objectA (and all other objects representing HW resources) as parameters when creating objectB?
Either that, e.g. by making it an argument to the constructor of ClassB or by having an attribute/property on the ClassB instance, which you set to the ClassA instance after instantiation of objectB, or you put both instances, objectA and objectB, in the same namespace, usually either the global one, or that of your main() function.

See also:

https://en.wikipedia.org/wiki/Design_Patterns

and

http://c2.com/cgi/wiki?CategoryStructuralPatterns


Chris

danielm
Posts: 167
Joined: Mon Oct 05, 2015 12:24 pm

Re: Repeated communication with 2 SPI slaves

Post by danielm » Sun May 01, 2016 12:23 pm

Chris, thank you for your answer ;-)

Post Reply