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

Rodrigo Peixoto <rodrigopex@...>

Stefan, Is that IC a sensor? 
Do you need to use interrupt on it?

I would suggest you to start taking a look at the code from the sensor This is a simple one and it implements the Sensor Driver API. This API is described here If you need interrupts on it, you need to write the proper code for that. You can take a look at the sensor driver

Good luck and let us know if you face any issue. 

Best regards,
Rodrigo Peixoto
Co-founder and Technical advisor

+55 (82) 98144-8585 | Skype: rodrigopex

Em seg, 10 de dez de 2018 às 15:00, Stefan Jaritz <stefan@...> escreveu:


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

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!


Join to automatically receive all group messages.