Adafruit_Blinka: Problem with spi and MicroPython

I ran into an issue trying to use Blinka under Micropython on a Raspberry Pi Pico. I was trying to see if I could use an “airlift” with the esp32spi library. The first problem had simple “workaround”: The esp32spi library uses time.monotonic() but time.monotonic() is not provided by the micropython time module… It looks like a simple fix is to just use time.time() use MP but it does mean a lot of CP code won’t work without modification… I did make that change and ran into some more significant issues that may indicate bigger problems, but I wanted to point out the time.monotonic issue to see if I was missing some thing simple to get around it.

The second issue may be more significant: after replacing the time.monotonic() called with time.time() in adafruit_esp32spi.py I ran into this

MPY: soft reboot
MicroPython v1.15 on 2021-04-18; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> 
>>> 
>>> import esp32spi_simpletest
ESP32 SPI webclient test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "esp32spi_simpletest.py", line 50, in <module>
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 335, in status
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 324, in _send_command_get_response
  File "adafruit_esp32spi/adafruit_esp32spi.py", line 232, in _send_command
  File "adafruit_bus_device/spi_device.py", line 76, in __enter__
  File "/lib/busio.py", line 377, in configure
AttributeError: type object 'SPI' has no attribute 'MSB'
>>> 

Any suggestions on how to proceed?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

Looks like time is implemented per-port in MicroPython. Here is the STM one: https://github.com/micropython/micropython/blob/master/ports/stm32/modutime.c