Implementing Dynamic I²C Master/Slave Switching on nRF5340 (Zephyr)

Hi,

I'm currently working on a project using the nRF5340, and I've successfully configured the I2C0 interface as a static Master in my .overlay file using the following Zephyr configuration:

&i2c0 {
    compatible = "nordic,nrf-twim";
    status = "okay";
    clock-frequency = <I2C_BITRATE_STANDARD>;
    pinctrl-0 = <&i2c0_default>;
    pinctrl-1 = <&i2c0_sleep>;
    pinctrl-names = "default", "sleep";
};

My goal is this: I'd like the I2C0 to be able to change its role and become a Slave, and vice versa, after an event (like a button press), always using the same SCL/SDA pins.
Is it possible? Can I switch on the fly (runtime) from Master mode (TWIM) to Slave mode (TWIS) on the same I2C0 peripheral?

Thanks in advance for the help!
Stefano

Parents Reply Children
No Data
Related