Problem with spi and MicroPython
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (11 by maintainers)
Top GitHub 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
I think this is heavily related to #7 (as a great idea for a potential fix).