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

   ## Summary
     
     Two new SPI drivers:
     
     1. A callback-backed **dummy SPI bus** (`CONFIG_SPI_DUMMY`).  Board code
        provides a table of `spi_dummy_device_s` callbacks (select, status,
        send, exchange) and `spi_dummy_initialize()` returns a `struct
        spi_dev_s` that dispatches to them.  Useful for transport validation
        and testing without real hardware.
     
     2. An **RPMsg SPI** transport (`CONFIG_SPI_RPMSG` client,
        `CONFIG_SPI_RPMSG_SERVER` server).  The client creates a `struct
        spi_dev_s` that forwards SPI operations (exchange, exchangeseqs,
        status, trigger) to a remote CPU over RPMsg.  The server exports a
        local SPI bus to remote clients.  Every RPMsg message executes
        atomically on the server; bus locking never crosses the link.
     
     ## Impact
     
     New files only; no changes to existing drivers or APIs.  Adds three
     Kconfig options (`SPI_DUMMY`, `SPI_RPMSG`, `SPI_RPMSG_SERVER`) and
     documentation in `Documentation/os/drivers/special/spi.rst`.
     
     ## Testing
     
     Host: Ubuntu 22.04, x86-64, host gcc.
     
     **Dummy bus** — sim:nsh (CMake + Make), `CONFIG_SPI_DUMMY=y
     CONFIG_SPI_EXCHANGE=y CONFIG_SPI_DRIVER=y`.  A temporary test program
     (not part of this PR) registers a dummy device whose exchange callback
     XORs each byte with `0xff`, then does a 4-byte `SPI_EXCHANGE`:
     
     nsh> hello
     SPI dummy bus test
     spi_dummy_initialize: OK
     spi_register: 0
     my_exchange: nwords=4 nbits=8
     SPI_EXCHANGE: ret=0
     TX: 01 02 03 04
     RX: fe fd fc fb
     Verify: PASS
     
     **RPMsg SPI** — sim:rpserver (CMake) with `CONFIG_SPI_DUMMY=y
     CONFIG_SPI_RPMSG_SERVER=y`, sim:rpproxy (CMake) with
     `CONFIG_SPI_RPMSG=y`.  The server exports the dummy bus as `spi0`;
     the proxy connects, does a 4-byte exchange that travels over the RPMsg
     link to the server's dummy device and back:
     
     server> hello
     [server] SPI rpmsg server test
     [server] dummy SPI bus created
     [server] spi_rpmsg_server_initialize: 0
     [server] spi_register(/dev/spi0): 0
     [server] Ready. Proxy can now do transfers.
     server> [    5.030098] [server] rpmsg_rtc_server_sync: rpmsg rtc server 
sync time:1795430043
     [    0.070073] [proxy] rpmsg_rtc_ept_cb: rpmsg rtc client sync 
time:1795430043
     cu /dev/ttyproxy
     proxy> 
     proxy> 
     proxy> hello
     [proxy] SPI rpmsg client test
     [proxy] spi_rpmsg_initialize: OK
     [proxy] spi_register: 0
     [server] my_exchange: nwords=4 nbits=8
     [proxy] SPI_EXCHANGE: ret=0
     [proxy] TX: 10 20 30 40
     [proxy] RX: ef df cf bf
     [proxy] Verify: PASS
   
   


-- 
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