nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

arch/arm/src/stm32/stm32_i2cslave_v2.c: add STM32 I2C Slave support f…

Open zdebanos opened this issue 6 months ago • 2 comments

This commit adds the lowerhalf driver support for the I2C Slave. While not currently ideal, it is compatible with the upperhalf i2c slave driver. A workqueue can be used to delegate the isr work to the upperhalf driver. But keep in mind wq introduces a lot of delay and in certain scenarios, it is better to write your own better upperhalf driver.

Summary and impact

Added I2C Slave support for the STM32 devices. Use with the current implementation of upper half driver.

Testing

Tested on a custom STM32F302 board with two I2C peripherals configured as slaves. Succesfully tested basic posix calls (open, close, read, write). Tested primarly with CMake but also compiled with the default makefile system. Tested on WSL/Win10.

zdebanos avatar Jun 17 '25 14:06 zdebanos

Thank you Mateusz and Alan, as soon as I touch the company's PC I'll fix the issues. Also I realized I forgot to commit the headers so the peripherals could be initialized in the board config. Also I'll add some documentation and basic usage.

zdebanos avatar Jun 17 '25 18:06 zdebanos

Fixed coding issues. Compiles OK. But I've got a question - where should I put the documentation? I found a generic page (https://nuttx.apache.org/docs/latest/components/drivers/special/i2c.html) about the I2C drivers, but not arch related.

zdebanos avatar Jun 20 '25 08:06 zdebanos

@raiden00pl @acassis just reminding myself :)

zdebanos avatar Jun 23 '25 21:06 zdebanos

@zdebanos I saw it is failing because of typos only:

/home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/stm32/Kconfig:10762: retransfered ==> retransferred /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/stm32/Kconfig:10765: transfered ==> transferred /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/stm32/Kconfig:10766: reseted ==> reset /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/stm32/stm32_i2cslave_v2.c:100: deffering ==> differing, deferring

Please send a fix to the Kconfig

acassis avatar Jun 23 '25 21:06 acassis

oh, I did not understand the output of the check, thanks for clearing that up!

zdebanos avatar Jun 23 '25 21:06 zdebanos

Yes, it is confuse, I think it should just show a summary with errors instead of the verbose log

acassis avatar Jun 23 '25 21:06 acassis

Fixed

zdebanos avatar Jun 23 '25 21:06 zdebanos

@acassis @raiden00pl I modified the I2C Documentation in Documentation/components/drivers/special/i2c.rst, the documentation now elaborates further on the I2C slave and features an example with STM32 initialization.

zdebanos avatar Jul 01 '25 14:07 zdebanos