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


Rodrigo Peixoto <rodrigopex@...>
 

Great!

Make it available and share the link with us. It will be enough for now.

"code dump" (+1)

Abraço,
Rodrigo Peixoto


On Thu, 13 Dec 2018 at 13:07 Stefan Jaritz <stefan@...> wrote:

Merci!

I took the tlv320dac310x audio codec driver as template. Done a very specific driver for the tlv320aic3204 from TI. It is not streamlined with the zephyr audio api. I can send it to you or put it on my github repro.

Maybe it is worth thinking about adding a "code dump" place, were people can share there code. This codes is may not fulfilling the zephyr quality standards but can be a good starting point for everyone who tries to create drivers etc.

Best regards,

Stefan


On 12/12/2018 11:38, Rodrigo Peixoto wrote:
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 https://github.com/zephyrproject-rtos/zephyr/tree/master/drivers/sensor/th02. This is a simple one and it implements the Sensor Driver API. This API is described here https://github.com/zephyrproject-rtos/zephyr/blob/master/include/sensor.h. If you need interrupts on it, you need to write the proper code for that. You can take a look at the sensor driver https://github.com/zephyrproject-rtos/zephyr/tree/master/drivers/sensor/mcp9808.

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


Best regards,
Rodrigo Peixoto
Co-founder and Technical advisor

+55 (82) 98144-8585
http://ayna.tech | Skype: rodrigopex




Em seg, 10 de dez de 2018 às 15:00, Stefan Jaritz <stefan@...> escreveu:
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




--
Rodrigo Peixoto
Co-founder and Technical guru

+55 (82) 98144-8585
http://ayna.tech | Skype: rodrigopex

.

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