How to write a own I2C(slave) driver? #i2s #slave #driver


Stefan Jaritz
 

Hey,

I am currently checking the documentation for a "How to do an I2C slave driver" and I did not find some tutorial.

Hopefully some guys can quickly tell me how to do it.

My hardware setup: custom stm32f412 board + IC connected via I2C_1 (Pin B9 & B8)

I created an out of tree board and added at the dts file:

&i2c1 {
    status = "ok";
    clock-frequency = <I2C_BITRATE_FAST>;
};

I setup the pins in the pinmux.c with these two lines:

#ifdef CONFIG_I2C_1
    {STM32_PIN_PB8, STM32F4_PINMUX_FUNC_PB8_I2C1_SCL},
    {STM32_PIN_PB9, STM32F4_PINMUX_FUNC_PB9_I2C1_SDA},
#endif

Think form this side the I2C should be rightfully configured.

Now I like to access the IC connected via I2C_1. How to do that?

How I link my code to the I2C_1 device, write the protocoll functions and build an API around that?

Any ideas examples are welcome!

Stefan

Join users@lists.zephyrproject.org to automatically receive all group messages.