pyb.SPI vs pyb.machine.SPI?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
kwiley
Posts: 8
Joined: Wed May 16, 2018 5:53 pm
Contact:

pyb.SPI vs pyb.machine.SPI?

Post by kwiley » Wed May 16, 2018 9:04 pm

The documentation has similar, but not identical, APis for SPI communication under the top pyb module and under the secondary pyb.machine module. What's the difference and what criteria determine which module I should use?

Thanks.

User avatar
pythoncoder
Posts: 2584
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: pyb.SPI vs pyb.machine.SPI?

Post by pythoncoder » Thu May 17, 2018 6:33 am

The pyb library is only available for STM processors (e.g. the Pyboard). So if you're using something else or want to write portable code you need to use machine.

On STM kit it's up to you. I tend to use pyb. It's rock-solid reliable as it's been around for a long time, has some STM specific functionality and is perhaps better documented.
Peter Hinch

kwiley
Posts: 8
Joined: Wed May 16, 2018 5:53 pm
Contact:

Re: pyb.SPI vs pyb.machine.SPI?

Post by kwiley » Thu May 17, 2018 4:17 pm

Thank you. I've have had no luck with SPI communications yet. I don't know if I'm using the PyBoard SPI library incorrectly or if I'm accessing the other devices' SPI APIs incorrectly (probably the latter of course). It's driving me crazy. I2C works fine, but I've had no luck with SPI yet.

Post Reply