Get Pins from SPI

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Get Pins from SPI

Post by mcauser » Sat May 12, 2018 6:33 am

Is it possible to get a Pin object from an SPI object?

Code: Select all

>>> from machine import Pin, SPI
>>> spi = SPI(2)
>>> spi.init(baudrate=6000000, polarity=0, phase=0)
>>> print(spi)
SPI(2, baudrate=5250000, polarity=0, phase=0, bits=8)
I know the MISO pin on my board is B14. Instead of typing this...

Code: Select all

>>> miso = Pin('B14', Pin.IN)
>>> miso.value()
I'm hoping to get it from the SPI object. Something like this...

Code: Select all

>>> spi.miso.value()

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

Re: Get Pins from SPI

Post by pythoncoder » Mon May 14, 2018 6:12 am

That looks like it might make a worthwhile PR ;)
Peter Hinch
Index to my micropython libraries.

Post Reply