5 years, 9 months ago.

I2C slave & I2C Master

Hello Is it possible to reconfigure an I2C module and switch between I2C slave and I2C master during runtime using the Mbed framework?

Example:--

1). Configure a Mbed board as an I2C slave. 2). Then at some point reconfigure the same I2C port as an I2C master (after a specific slave i2c command is received or a push switch is pressed).

Thanks

1 Answer

5 years, 8 months ago.

Hi, probably yes...

something...

//….
I2C *master;
I2CSlave *slave;
//********************************************
        if (/*something*/) {  
            master = new I2C(PB_3, PB_10);
            slave = new I2CSlave(PB_9, PB_8);
        }else{
            master = new I2C(PB_9, PB_8);
            slave = new I2CSlave(PB_3, PB_10);
        }
//********************************************
delete slave;
delete master;