yangsong8-a1 opened a new pull request, #22219:
URL: https://github.com/apache/nuttx/pull/22219

   ## Summary
     
     Add a callback-backed dummy I2C lower-half driver and RPMsg I2C support
     (client + server).
     
     The dummy bus lets board code register software-only I2C targets backed
     by callbacks, useful for transport validation and testing.
     
     The RPMsg client forwards I2C transfers to a remote NuttX instance; the
     RPMsg server exports a local I2C bus to remote clients.
     
     ## Impact
     
     New drivers, no existing code changed.  Three new Kconfig options:
     `CONFIG_I2C_DUMMY`, `CONFIG_I2C_RPMSG`, `CONFIG_I2C_RPMSG_SERVER`.
     
     ## Testing
     
     Host GCC, Ubuntu 22.04.
     
     **Builds (CMake + Make, no new warnings):**
     - sim:nsh with `I2C`, `I2C_DRIVER`, `I2C_DUMMY`
     - sim:rpserver with `I2C`, `I2C_DRIVER`, `I2C_DUMMY`, `I2C_RPMSG_SERVER`
     - sim:rpproxy with `I2C`, `I2C_DRIVER`, `I2C_RPMSG`
     
     **Dummy bus (sim:nsh):**
     
     A temporary test program registers a dummy device at address 0x50 with
     an echo callback, writes 4 bytes and reads them back:
     
     nsh> hello
     === I2C dummy bus test ===
     i2c_dummy_initialize: OK
     i2c_register(/dev/i2c99): 0
     --- Write 4 bytes to 0x50 ---
       dummy_xfer: addr=0x50 flags=0x00 len=4
       dummy_xfer: wrote 4 bytes
     I2C_TRANSFER(write): ret=0
     --- Read 4 bytes from 0x50 ---
       dummy_xfer: addr=0x50 flags=0x01 len=4
       dummy_xfer: read 4 bytes back
     I2C_TRANSFER(read): ret=0 data=de ad be ef
     MATCH: read data matches written data
     --- Transfer to nonexistent addr 0x60 ---
     I2C_TRANSFER(0x60): ret=-6 (expected -6=-ENXIO)
     === I2C dummy bus test done ===
     
     **RPMsg I2C (sim:rpserver + sim:rpproxy):**
     
     The server registers a dummy I2C bus as the RPMsg I2C backend.  The
     proxy client connects over RPMsg and does a write/read roundtrip:
     
     server> [   10.280162] [server] rpmsg_rtc_server_sync: rpmsg rtc server 
sync time:1795427110
     [    0.090146] [proxy] rpmsg_rtc_ept_cb: rpmsg rtc client sync 
time:1795427110
     hello
     === I2C rpmsg SERVER setup ===
     i2c_dummy_initialize: OK
     i2c_rpmsg_server_initialize: ret=0
     Server ready. Waiting for client transfers...
     server> cu /dev/ttyproxy
     proxy>
     proxy> hello
     === I2C rpmsg CLIENT test ===
     i2c_rpmsg_initialize: OK
     i2c_register(/dev/i2c0): 0
     --- Write 4 bytes to 0x50 ---
       SERVER dummy_xfer: addr=0x50 flags=0x00 len=4
       SERVER dummy_xfer: addr=0x50 flags=0x01 len=4
     I2C_TRANSFER(write): ret=0
     --- Read 4 bytes from 0x50 ---
     I2C_TRANSFER(read): ret=0 data=ca fe ba be
     MATCH: rpmsg I2C roundtrip OK
     === I2C rpmsg CLIENT test done ===
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to