I am trying to run an accelerometer sensor using the SPI class, however I am getting an error as follows:
Traceback (most recent call last):
File "<stdin>", line 77, in <module>
File "<stdin>", line 64, in reg_read
OSError: [Errno 22] EINVAL
The code to my driver program can be found here: https://github.com/Yadnik1/Accel-10-cli ... 20click.py
It would be very helpful if someone can please tell me the mistake I am making.
OSError: [Errno 22] EINVAL for SPI operation
Re: OSError: [Errno 22] EINVAL for SPI operation
I am only guessing here ... is the error to do with <cs>. Maybe it needs to be global.
Re: OSError: [Errno 22] EINVAL for SPI operation
This is being returned from Zephyr -- i.e. spi_transceive is returning EINVAL...
Do any SPI operations work? (e.g. read). Does it work if you use SoftSPI instead?
Re: OSError: [Errno 22] EINVAL for SPI operation
I tried basic SPI commands, the program is as follows:
from machine import SPI,Pin
spi = SPI("SPI_0")
cs = Pin(("GPIO_0", 8), Pin.OUT)
msg = bytearray()
spi.write(msg)
This too returns an error:
File "<stdin>", line 5, in <module>
OSError: [Errno 22] EINVAL
I tried making changes to the device tree file as well and also tried it on an alternative board having the Zephyr port.(CC1352R launchxl),
However I am getting the same error.Can you please have a look and suggest what may be going wrong.
Thank you!!
from machine import SPI,Pin
spi = SPI("SPI_0")
cs = Pin(("GPIO_0", 8), Pin.OUT)
msg = bytearray()
spi.write(msg)
This too returns an error:
File "<stdin>", line 5, in <module>
OSError: [Errno 22] EINVAL
I tried making changes to the device tree file as well and also tried it on an alternative board having the Zephyr port.(CC1352R launchxl),
However I am getting the same error.Can you please have a look and suggest what may be going wrong.
Thank you!!
Re: OSError: [Errno 22] EINVAL for SPI operation
Can you try SoftSPI and see if that works?
Re: OSError: [Errno 22] EINVAL for SPI operation
I tried taking SoftSPI into use, however the module does not exist.I get this error:
ImportError: can't import name SoftSPI
Any other factor that I can look into?I am also trying to look into Zephyr part of things.
Thank you!!
ImportError: can't import name SoftSPI
Any other factor that I can look into?I am also trying to look into Zephyr part of things.
Thank you!!
Re: OSError: [Errno 22] EINVAL for SPI operation
Is there a way that we can tell from this file:https://github.com/micropython/micropyt ... hine_spi.c
whether these modules are added or not?
whether these modules are added or not?
Re: OSError: [Errno 22] EINVAL for SPI operation
import machine
dir (machine)
Will tell you all classes on machine.
dir (machine)
Will tell you all classes on machine.
Re: OSError: [Errno 22] EINVAL for SPI operation
Thank you Robert,
The output I get is as follows:
>>> dir (machine)
['__name__', 'I2C', 'Pin', 'SPI', 'Signal', 'UART', 'idle', 'reset', 'reset_cause']
The output I get is as follows:
>>> dir (machine)
['__name__', 'I2C', 'Pin', 'SPI', 'Signal', 'UART', 'idle', 'reset', 'reset_cause']