Page 1 of 1

i2c = I2C("I2C_0") function of the zephyr port of Micropython

Posted: Sun Jul 18, 2021 2:15 pm
by Yadnik
what is the significance of the I2C_0 in i2c = I2C("I2C_0") , for initialising the i2c variable.It can be seen here:https://github.com/micropython/micropyt ... /README.md .
Thank you!!

Re: i2c = I2C("I2C_0") function of the zephyr port of Micropython

Posted: Mon Jul 19, 2021 2:02 am
by jimmo
Yadnik wrote:
Sun Jul 18, 2021 2:15 pm
what is the significance of the I2C_0 in i2c = I2C("I2C_0") , for initialising the i2c variable
Zephyr's driver model defines the various peripherals by name (and this is configured in the board/mcu definitions and will correspond to pins etc). MicroPython just makes those names available to the machine API.

See https://docs.zephyrproject.org/latest/r ... index.html

I'm not 100% exactly how you know which pins it will correspond to (most MCUs will have default pins for a given peripheral). I notice for example that ESP32 conifgures the default pins in the devicetree config -- https://github.com/zephyrproject-rtos/z ... /esp32.dts Other boards might inherit it from the MCU config.

Re: i2c = I2C("I2C_0") function of the zephyr port of Micropython

Posted: Tue Jul 20, 2021 12:39 pm
by Yadnik
Thank you very much.
In my case the UART and Pin class work perfectly, however I face issues with i2c and spi where although I can import the class but I get device not found on doing
i2c=I2C('I2C_0') in case of i2c and spi=SPI('SPI_0') in case of spi.
It would be very helpful if you can please guide me if you know the solution.