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

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Yadnik
Posts: 65
Joined: Thu May 13, 2021 6:01 am

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

Post by Yadnik » 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.It can be seen here:https://github.com/micropython/micropyt ... /README.md .
Thank you!!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

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

Post by jimmo » Mon Jul 19, 2021 2:02 am

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.

Yadnik
Posts: 65
Joined: Thu May 13, 2021 6:01 am

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

Post by Yadnik » Tue Jul 20, 2021 12:39 pm

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.

Post Reply