http://docs.micropython.org/en/latest/p ... e.SPI.html
how is it supposed to work? while there is a constructor info in docs for pyb.SPI - there is nothing for machine.SPI
also how is it possible to specify which SPI bus/interface to use on PyBoard? (in pyb.SPI there is a "bus" argument for that)
machine.SPI constructor
Re: machine.SPI constructor
Those docs are, unfortunately, out of date. They reflect the wipy's implementation and need to be updated for esp8266 and new pyboard behaviour. There is no longer a "mode" argument to the constructor / init function.
To construct a hardware instance use: machine.SPI('X').
To construct a software instance use: machine.SPI(sck=pin_sck, mosi=pin_mosi, miso=pin_miso).
To construct a hardware instance use: machine.SPI('X').
To construct a software instance use: machine.SPI(sck=pin_sck, mosi=pin_mosi, miso=pin_miso).
Re: machine.SPI constructor
what does 'X' mean? where is it possible to see the code? can't find it. there are so many different modmachine.c and spi.c files...Damien wrote:To construct a hardware instance use: machine.SPI('X').
Re: machine.SPI constructor
On the pyboard there is an X half and a Y half. On the X half, all of the pins start with the letter X, and on the Y half, all of the pins start with the letter Y.
To determine exactly which pins are used for SPI for X and which for Y, I normally look at the boards mpconfigboard.h file. For the original pyboard, this is here:
https://github.com/micropython/micropyt ... .h#L58-L68
To determine exactly which pins are used for SPI for X and which for Y, I normally look at the boards mpconfigboard.h file. For the original pyboard, this is here:
https://github.com/micropython/micropyt ... .h#L58-L68
Re: machine.SPI constructor
it could be obvious for pyb.SPI, but when it is machine.SPI - this is not anymore. But it looks like it is not 'X' anymore but 0, 1 etc.
Re: machine.SPI constructor
The stmhal SPI constructor takes either an int, (1 refers to SPI1, 2 refers to SPI2). It can also take a string argument, in which case it gets mapped according to the MICROPY_HW_SPIx_NAME macros from the mpconfigboard.h file.
See: the spi_find function in spi.c:
https://github.com/micropython/micropyt ... #L166-L196
See: the spi_find function in spi.c:
https://github.com/micropython/micropyt ... #L166-L196
Re: machine.SPI constructor
ok, thanks